diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ee21afdd78a1..1926afa07676f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,47 @@ +2.0.0.0-dev71 +============= +* Fixed bugs: + * Fixed an issue with displaying product on the frontend when the product flat indexer is enabled + * Fixed an issue with applying catalog price rules on the category level + * Fixed an issue where the essential cookies like CUSTOMER, CART, and so on were not created in Google Chrome + * Fixed an issue with placing orders by customers assigned to a VAT group + * Fixed an issue with incorrect error message during registration, and inability for a shopper to ask for resending a confirmation email + * Fixed an issue where the Catalog module resource Setup Upgrade logic was broken +* Modularity improvements: + * Moved abstract Core models and related logic to the Magento/Model library + * Moved the abstract DB logic and Core resource helpers to the Magento/DB library + * Eliminated the Core\Model\App class + * Moved the Magento Flag functionality to the library + * Resolved dependency of the Catalog and related modules on the Review module + * Moved indexers related logic from the Core module to the Indexer module + * Moved the Inline translation and user intended translate functionality from the Core module to a separate Translation module +* Framework Improvements: + * Covered Magento library components with unit tests: + * Magento\Config + * Magento\Convert + * Magento\Controller + * Magento\Data\Collection\Db + * Magento\Mview + * Magento\Url and Magento/Url.php + * Covered Magento application components with unit tests: + * Magento\Checkout\Model\Config + * Magento\Checkout\Model\Observer + * Magento\Checkout\Model\Type + * Magento\Sales\Model\Config + * Renamed LauncherInterface to AppInterface +* Improvements in code coverage calculation: + * Updated the whitelist filter with library code for integration tests code coverage calculation +* GitHub requests: + * [#512] (https://github.com/magento/magento2/issues/512) -- Theme Thumbnails not showing + * [#520] (https://github.com/magento/magento2/pull/502) -- Corrected Search Engine Optimization i18n + * [#519] (https://github.com/magento/magento2/issues/519) -- New Theme Activation +* Customer Service usage: + * Refactored the Log module to use Customer Service + * Refactored the RSS module to use Customer Service + * Refactored the Review module to use Customer Service + * Refactored the Catalog module to use Customer service layer + * Refactored the Downloadable module to use Customer service layer + 2.0.0.0-dev70 ============= * Fixed bugs: diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php index c12578f51af8d..86c78a3650a06 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php @@ -60,7 +60,7 @@ public function markAsReadAction() $notificationId ); $this->messageManager->addSuccess(__('The message has been marked as Read.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException( @@ -121,7 +121,7 @@ public function massMarkAsReadAction() $this->messageManager->addSuccess( __('A total of %1 record(s) have been marked as Read.', count($ids)) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException( @@ -149,7 +149,7 @@ public function removeAction() try { $model->setIsRemove(1)->save(); $this->messageManager->addSuccess(__('The message has been removed.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __("We couldn't remove the messages because of an error.")); @@ -178,7 +178,7 @@ public function massRemoveAction() } } $this->messageManager->addSuccess(__('Total of %1 record(s) have been removed.', count($ids))); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __("We couldn't remove the messages because of an error.")); diff --git a/app/code/Magento/AdminNotification/Model/Feed.php b/app/code/Magento/AdminNotification/Model/Feed.php index 3b144e83175f6..1715651a556fe 100644 --- a/app/code/Magento/AdminNotification/Model/Feed.php +++ b/app/code/Magento/AdminNotification/Model/Feed.php @@ -32,7 +32,7 @@ * @package Magento_AdminNotification * @author Magento Core Team */ -class Feed extends \Magento\Core\Model\AbstractModel +class Feed extends \Magento\Model\AbstractModel { const XML_USE_HTTPS_PATH = 'system/adminnotification/use_https'; @@ -64,7 +64,7 @@ class Feed extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Backend\App\ConfigInterface $backendConfig * @param \Magento\AdminNotification\Model\InboxFactory $inboxFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -73,7 +73,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Backend\App\ConfigInterface $backendConfig, \Magento\AdminNotification\Model\InboxFactory $inboxFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/AdminNotification/Model/Inbox.php b/app/code/Magento/AdminNotification/Model/Inbox.php index 34e31eb3525d5..cc5c4adb9e954 100644 --- a/app/code/Magento/AdminNotification/Model/Inbox.php +++ b/app/code/Magento/AdminNotification/Model/Inbox.php @@ -49,7 +49,7 @@ * @package Magento_AdminNotification * @author Magento Core Team */ -class Inbox extends \Magento\Core\Model\AbstractModel +class Inbox extends \Magento\Model\AbstractModel { const SEVERITY_CRITICAL = 1; @@ -133,13 +133,13 @@ public function parse(array $data) * @param string|string[] $description * @param string $url * @param bool $isInternal - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ public function add($severity, $title, $description, $url = '', $isInternal = true) { if (!$this->getSeverities($severity)) { - throw new \Magento\Core\Exception(__('Wrong message type')); + throw new \Magento\Model\Exception(__('Wrong message type')); } if (is_array($description)) { $description = ''; diff --git a/app/code/Magento/AdminNotification/Model/NotificationService.php b/app/code/Magento/AdminNotification/Model/NotificationService.php index 52682a63c2666..7efd5f064a218 100644 --- a/app/code/Magento/AdminNotification/Model/NotificationService.php +++ b/app/code/Magento/AdminNotification/Model/NotificationService.php @@ -52,14 +52,14 @@ public function __construct(\Magento\AdminNotification\Model\InboxFactory $notif * * @param int $notificationId * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function markAsRead($notificationId) { $notification = $this->_notificationFactory->create(); $notification->load($notificationId); if (!$notification->getId()) { - throw new \Magento\Core\Exception('Wrong notification ID specified.'); + throw new \Magento\Model\Exception('Wrong notification ID specified.'); } $notification->setIsRead(1); $notification->save(); diff --git a/app/code/Magento/AdminNotification/Model/Resource/Grid/Collection.php b/app/code/Magento/AdminNotification/Model/Resource/Grid/Collection.php index 13e63de1d03c4..98b0cb708cca4 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/Grid/Collection.php +++ b/app/code/Magento/AdminNotification/Model/Resource/Grid/Collection.php @@ -38,7 +38,7 @@ class Collection extends \Magento\AdminNotification\Model\Resource\Inbox\Collect /** * Add remove filter * - * @return \Magento\AdminNotification\Model\Resource\Grid\Collection|\Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\AdminNotification\Model\Resource\Grid\Collection|\Magento\Model\Resource\Db\Collection\AbstractCollection */ protected function _initSelect() { diff --git a/app/code/Magento/AdminNotification/Model/Resource/Inbox.php b/app/code/Magento/AdminNotification/Model/Resource/Inbox.php index c2a08fa4a2102..d11427c33e75e 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/Inbox.php +++ b/app/code/Magento/AdminNotification/Model/Resource/Inbox.php @@ -32,7 +32,7 @@ * @package Magento_AdminNotification * @author Magento Core Team */ -class Inbox extends \Magento\Core\Model\Resource\Db\AbstractDb +class Inbox extends \Magento\Model\Resource\Db\AbstractDb { /** * AdminNotification Resource initialization diff --git a/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection.php b/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection.php index 65d7f585990f7..93d4219169044 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection.php +++ b/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection.php @@ -32,7 +32,7 @@ * @package Magento_AdminNotification * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource collection initialization diff --git a/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php b/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php index 0c2d6abde7ac5..2599f958784d9 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php +++ b/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php @@ -25,7 +25,7 @@ */ namespace Magento\AdminNotification\Model\Resource\Inbox\Collection; -class Critical extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Critical extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource collection initialization diff --git a/app/code/Magento/AdminNotification/Model/Resource/System/Message.php b/app/code/Magento/AdminNotification/Model/Resource/System/Message.php index 24a35da93fb9f..eb1305f857e6d 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/System/Message.php +++ b/app/code/Magento/AdminNotification/Model/Resource/System/Message.php @@ -23,7 +23,7 @@ */ namespace Magento\AdminNotification\Model\Resource\System; -class Message extends \Magento\Core\Model\Resource\Db\AbstractDb +class Message extends \Magento\Model\Resource\Db\AbstractDb { /** * Flag that notifies whether Primary key of table is auto-incremeted diff --git a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php index 90d863c767d65..1bf58e16f7537 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php +++ b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php @@ -23,7 +23,7 @@ */ namespace Magento\AdminNotification\Model\Resource\System\Message; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * System message list @@ -46,7 +46,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\AdminNotification\Model\System\MessageList $messageList * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -55,7 +55,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\AdminNotification\Model\System\MessageList $messageList, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_messageList = $messageList; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php index 6b5f82526e4fd..1e909f5099382 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php +++ b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php @@ -35,7 +35,7 @@ class Synchronized extends \Magento\AdminNotification\Model\Resource\System\Mess /** * Store new messages in database and remove outdated messages * - * @return $this|\Magento\Core\Model\Resource\Db\AbstractDb + * @return $this|\Magento\Model\Resource\Db\AbstractDb */ public function _afterLoad() { diff --git a/app/code/Magento/AdminNotification/Model/Survey.php b/app/code/Magento/AdminNotification/Model/Survey.php index ea16a0cb2bb13..f2c12c5b43fec 100644 --- a/app/code/Magento/AdminNotification/Model/Survey.php +++ b/app/code/Magento/AdminNotification/Model/Survey.php @@ -44,12 +44,12 @@ class Survey protected $_flagCode = 'admin_notification_survey'; /** - * @var \Magento\Core\Model\Flag + * @var \Magento\Flag */ protected $_flagModel = null; /** - * @var \Magento\Core\Model\FlagFactory + * @var \Magento\FlagFactory */ protected $_flagFactory; @@ -59,10 +59,10 @@ class Survey protected $_request; /** - * @param \Magento\Core\Model\FlagFactory $flagFactory + * @param \Magento\FlagFactory $flagFactory * @param \Magento\App\RequestInterface $request */ - public function __construct(\Magento\Core\Model\FlagFactory $flagFactory, \Magento\App\RequestInterface $request) + public function __construct(\Magento\FlagFactory $flagFactory, \Magento\App\RequestInterface $request) { $this->_request = $request; $this->_flagFactory = $flagFactory; @@ -100,7 +100,7 @@ public function getSurveyUrl() /** * Return core flag model * - * @return \Magento\Core\Model\Flag + * @return \Magento\Flag */ protected function _getFlagModel() { diff --git a/app/code/Magento/AdminNotification/Model/System/Message.php b/app/code/Magento/AdminNotification/Model/System/Message.php index 2fc941aebcd51..d606ae60dfe20 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message.php +++ b/app/code/Magento/AdminNotification/Model/System/Message.php @@ -23,8 +23,7 @@ */ namespace Magento\AdminNotification\Model\System; -class Message extends \Magento\Core\Model\AbstractModel implements - \Magento\AdminNotification\Model\System\MessageInterface +class Message extends \Magento\Model\AbstractModel implements \Magento\AdminNotification\Model\System\MessageInterface { /** * @return void 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 f55c5a596632b..f4488a33c6fd0 100644 --- a/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment.php +++ b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment.php @@ -150,7 +150,7 @@ public function placeAction() $result['success'] = 1; $isError = false; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $message = $e->getMessage(); if (!empty($message)) { $this->messageManager->addError($message); diff --git a/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Payment.php b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Payment.php index 6a8183053ff85..a20c0951ae06a 100644 --- a/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Payment.php +++ b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Payment.php @@ -77,7 +77,7 @@ public function cancelAction() )->getPaymentMethodsHtml( $this->_view ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); $result['error_message'] = $e->getMessage(); } catch (\Exception $e) { diff --git a/app/code/Magento/Authorizenet/Controller/Authorizenet/Payment.php b/app/code/Magento/Authorizenet/Controller/Authorizenet/Payment.php index a9d5945137be4..c367ba997df92 100644 --- a/app/code/Magento/Authorizenet/Controller/Authorizenet/Payment.php +++ b/app/code/Magento/Authorizenet/Controller/Authorizenet/Payment.php @@ -67,7 +67,7 @@ public function cancelAction() )->getPaymentMethodsHtml( $this->_view ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); $result['error_message'] = $e->getMessage(); } catch (\Exception $e) { diff --git a/app/code/Magento/Authorizenet/Controller/Directpost/Payment.php b/app/code/Magento/Authorizenet/Controller/Directpost/Payment.php index ca5c2c6212f99..485331289dc17 100644 --- a/app/code/Magento/Authorizenet/Controller/Directpost/Payment.php +++ b/app/code/Magento/Authorizenet/Controller/Directpost/Payment.php @@ -114,7 +114,7 @@ protected function _responseAction(\Magento\Authorizenet\Helper\HelperInterface } $paymentMethod->process($data); $result['success'] = 1; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); $result['success'] = 0; $result['error_msg'] = $e->getMessage(); diff --git a/app/code/Magento/Authorizenet/Model/Authorizenet.php b/app/code/Magento/Authorizenet/Model/Authorizenet.php index 8f26a9ebbc0fd..04ac998df3aaa 100644 --- a/app/code/Magento/Authorizenet/Model/Authorizenet.php +++ b/app/code/Magento/Authorizenet/Model/Authorizenet.php @@ -497,12 +497,12 @@ public function unsetPartialAuthorizationLastActionState() * @param \Magento\Payment\Model\Info $payment * @param float $amount * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function authorize(\Magento\Object $payment, $amount) { if ($amount <= 0) { - throw new \Magento\Core\Exception(__('This is an invalid amount for authorization.')); + throw new \Magento\Model\Exception(__('This is an invalid amount for authorization.')); } $this->_initCardsStorage($payment); @@ -524,12 +524,12 @@ public function authorize(\Magento\Object $payment, $amount) * @param \Magento\Payment\Model\Info $payment * @param float $amount * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function capture(\Magento\Object $payment, $amount) { if ($amount <= 0) { - throw new \Magento\Core\Exception(__('This is an invalid amount for capture.')); + throw new \Magento\Model\Exception(__('This is an invalid amount for capture.')); } $this->_initCardsStorage($payment); if ($this->_isPreauthorizeCapture($payment)) { @@ -594,7 +594,7 @@ public function cancel(\Magento\Object $payment) * @param \Magento\Payment\Model\Info $payment * @param float $requestedAmount * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function refund(\Magento\Object $payment, $requestedAmount) { @@ -604,7 +604,7 @@ public function refund(\Magento\Object $payment, $requestedAmount) $cardsStorage->getCapturedAmount() - $cardsStorage->getRefundedAmount() ) < $requestedAmount ) { - throw new \Magento\Core\Exception(__('This is an invalid amount for refund.')); + throw new \Magento\Model\Exception(__('This is an invalid amount for refund.')); } $messages = array(); @@ -650,12 +650,12 @@ public function refund(\Magento\Object $payment, $requestedAmount) * * @param \Magento\Payment\Model\Info $payment * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function cancelPartialAuthorization(\Magento\Payment\Model\Info $payment) { if (!$payment->getAdditionalInformation($this->_splitTenderIdKey)) { - throw new \Magento\Core\Exception(__('This is an invalid split tenderId ID.')); + throw new \Magento\Model\Exception(__('This is an invalid split tenderId ID.')); } $request = $this->_getRequest(); @@ -672,7 +672,7 @@ public function cancelPartialAuthorization(\Magento\Payment\Model\Info $payment) $this->setPartialAuthorizationLastActionState(self::PARTIAL_AUTH_ALL_CANCELED); return; default: - throw new \Magento\Core\Exception(__('Something went wrong while canceling the payment.')); + throw new \Magento\Model\Exception(__('Something went wrong while canceling the payment.')); } } @@ -683,7 +683,7 @@ public function cancelPartialAuthorization(\Magento\Payment\Model\Info $payment) * @param float $amount * @param string $requestType * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _place($payment, $amount, $requestType) { @@ -762,12 +762,12 @@ protected function _place($payment, $amount, $requestType) return $this; } } - throw new \Magento\Core\Exception($defaultExceptionMessage); + throw new \Magento\Model\Exception($defaultExceptionMessage); case self::RESPONSE_CODE_DECLINED: case self::RESPONSE_CODE_ERROR: - throw new \Magento\Core\Exception($this->_wrapGatewayError($result->getResponseReasonText())); + throw new \Magento\Model\Exception($this->_wrapGatewayError($result->getResponseReasonText())); default: - throw new \Magento\Core\Exception($defaultExceptionMessage); + throw new \Magento\Model\Exception($defaultExceptionMessage); } return $this; } @@ -780,7 +780,7 @@ protected function _place($payment, $amount, $requestType) * @param string $requestType * @return $this * @throws \Magento\Payment\Model\Info\Exception - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _partialAuthorization($payment, $amount, $requestType) { @@ -811,7 +811,7 @@ protected function _partialAuthorization($payment, $amount, $requestType) $amount = $amount - $this->getCardsStorage()->getProcessedAmount(); if ($amount <= 0) { - throw new \Magento\Core\Exception(__('This is an invalid amount for partial authorization.')); + throw new \Magento\Model\Exception(__('This is an invalid amount for partial authorization.')); } $payment->setAmount($amount); $request = $this->_buildRequest($payment); @@ -879,7 +879,7 @@ protected function _isPreauthorizeCapture($payment) * @param \Magento\Payment\Model\Info $payment * @param float $requestedAmount * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _preauthorizeCapture($payment, $requestedAmount) { @@ -889,7 +889,7 @@ protected function _preauthorizeCapture($payment, $requestedAmount) $cardsStorage->getProcessedAmount() - $cardsStorage->getCapturedAmount() ) < $requestedAmount ) { - throw new \Magento\Core\Exception(__('This is an invalid amount for capture.')); + throw new \Magento\Model\Exception(__('This is an invalid amount for capture.')); } $messages = array(); @@ -933,7 +933,7 @@ protected function _preauthorizeCapture($payment, $requestedAmount) * @param float $amount * @param \Magento\Object $card * @return \Magento\Sales\Model\Order\Payment\Transaction - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _preauthorizeCaptureCardTransaction($payment, $amount, $card) { @@ -988,7 +988,7 @@ protected function _preauthorizeCaptureCardTransaction($payment, $amount, $card) $amount, $exceptionMessage ); - throw new \Magento\Core\Exception($exceptionMessage); + throw new \Magento\Model\Exception($exceptionMessage); } /** @@ -997,7 +997,7 @@ protected function _preauthorizeCaptureCardTransaction($payment, $amount, $card) * @param \Magento\Payment\Model\Info $payment * @param \Magento\Object $card * @return \Magento\Sales\Model\Order\Payment\Transaction - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _voidCardTransaction($payment, $card) { @@ -1080,7 +1080,7 @@ protected function _voidCardTransaction($payment, $card) false, $exceptionMessage ); - throw new \Magento\Core\Exception($exceptionMessage); + throw new \Magento\Model\Exception($exceptionMessage); } /** @@ -1102,7 +1102,7 @@ protected function _isTransactionExpired($realAuthTransactionId) * @param float $amount * @param \Magento\Object $card * @return \Magento\Sales\Model\Order\Payment\Transaction - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _refundCardTransaction($payment, $amount, $card) { @@ -1173,7 +1173,7 @@ protected function _refundCardTransaction($payment, $amount, $card) $amount, $exceptionMessage ); - throw new \Magento\Core\Exception($exceptionMessage); + throw new \Magento\Model\Exception($exceptionMessage); } /** @@ -1515,7 +1515,7 @@ protected function _buildRequest(\Magento\Object $payment) * * @param \Magento\Authorizenet\Model\Authorizenet\Request $request * @return \Magento\Authorizenet\Model\Authorizenet\Result - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _postRequest(\Magento\Object $request) { @@ -1549,7 +1549,7 @@ protected function _postRequest(\Magento\Object $request) $debugData['result'] = $result->getData(); $this->_debug($debugData); - throw new \Magento\Core\Exception($this->_wrapGatewayError($e->getMessage())); + throw new \Magento\Model\Exception($this->_wrapGatewayError($e->getMessage())); } $responseBody = $response->getBody(); @@ -1601,7 +1601,7 @@ protected function _postRequest(\Magento\Object $request) $r[54] ); } else { - throw new \Magento\Core\Exception(__('Something went wrong in the payment gateway.')); + throw new \Magento\Model\Exception(__('Something went wrong in the payment gateway.')); } $debugData['result'] = $result->getData(); @@ -1768,7 +1768,7 @@ protected function _isGatewayActionsLocked($payment) * @param string $messages * @param bool $isSuccessfulTransactions * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _processFailureMultitransactionAction($payment, $messages, $isSuccessfulTransactions) { @@ -1792,7 +1792,7 @@ protected function _processFailureMultitransactionAction($payment, $messages, $i } $copyOrder->save(); } - throw new \Magento\Core\Exception($this->_authorizenetData->convertMessagesToMessage($messages)); + throw new \Magento\Model\Exception($this->_authorizenetData->convertMessagesToMessage($messages)); } /** @@ -1817,7 +1817,7 @@ protected function _generateChecksum(\Magento\Object $object, $checkSumDataKeys * * @param string $transactionId * @return \Magento\Object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @link http://www.authorize.net/support/ReportingGuide_XML.pdf * @link http://developer.authorize.net/api/transaction_details/ */ @@ -1852,7 +1852,7 @@ protected function _getTransactionDetails($transactionId) $responseXmlDocument = new \Magento\Simplexml\Element($responseBody); libxml_use_internal_errors(false); } catch (\Exception $e) { - throw new \Magento\Core\Exception(__('Payment updating error.')); + throw new \Magento\Model\Exception(__('Payment updating error.')); } $response = new \Magento\Object(); diff --git a/app/code/Magento/Authorizenet/Model/Authorizenet/Debug.php b/app/code/Magento/Authorizenet/Model/Authorizenet/Debug.php index 641942d492cf8..965176635c043 100644 --- a/app/code/Magento/Authorizenet/Model/Authorizenet/Debug.php +++ b/app/code/Magento/Authorizenet/Model/Authorizenet/Debug.php @@ -43,7 +43,7 @@ * * @author Magento Core Team */ -class Debug extends \Magento\Core\Model\AbstractModel +class Debug extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index b30ed1edd0033..fb2ced68a254f 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -188,12 +188,12 @@ public function authorize(\Magento\Object $payment, $amount) * @param \Magento\Object $payment * @param float $amount * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function capture(\Magento\Object $payment, $amount) { if ($amount <= 0) { - throw new \Magento\Core\Exception(__('Invalid amount for capture.')); + throw new \Magento\Model\Exception(__('Invalid amount for capture.')); } $payment->setAmount($amount); @@ -224,12 +224,12 @@ public function capture(\Magento\Object $payment, $amount) ); return $this; } - throw new \Magento\Core\Exception($this->_wrapGatewayError($result->getResponseReasonText())); + throw new \Magento\Model\Exception($this->_wrapGatewayError($result->getResponseReasonText())); case self::RESPONSE_CODE_DECLINED: case self::RESPONSE_CODE_ERROR: - throw new \Magento\Core\Exception($this->_wrapGatewayError($result->getResponseReasonText())); + throw new \Magento\Model\Exception($this->_wrapGatewayError($result->getResponseReasonText())); default: - throw new \Magento\Core\Exception(__('Payment capturing error.')); + throw new \Magento\Model\Exception(__('Payment capturing error.')); } } @@ -259,12 +259,12 @@ public function canVoid(\Magento\Object $payment) * * @param \Magento\Object $payment * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function void(\Magento\Object $payment) { if (!$payment->getParentTransactionId()) { - throw new \Magento\Core\Exception(__('Invalid transaction ID.')); + throw new \Magento\Model\Exception(__('Invalid transaction ID.')); } $payment->setAnetTransType(self::REQUEST_TYPE_VOID); @@ -289,12 +289,12 @@ public function void(\Magento\Object $payment) ); return $this; } - throw new \Magento\Core\Exception($this->_wrapGatewayError($result->getResponseReasonText())); + throw new \Magento\Model\Exception($this->_wrapGatewayError($result->getResponseReasonText())); case self::RESPONSE_CODE_DECLINED: case self::RESPONSE_CODE_ERROR: - throw new \Magento\Core\Exception($this->_wrapGatewayError($result->getResponseReasonText())); + throw new \Magento\Model\Exception($this->_wrapGatewayError($result->getResponseReasonText())); default: - throw new \Magento\Core\Exception(__('Payment voiding error.')); + throw new \Magento\Model\Exception(__('Payment voiding error.')); } } @@ -349,16 +349,16 @@ public function refund(\Magento\Object $payment, $amount) * @param \Magento\Object $payment * @param float $amount * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _refund(\Magento\Object $payment, $amount) { if ($amount <= 0) { - throw new \Magento\Core\Exception(__('Invalid amount for refund.')); + throw new \Magento\Model\Exception(__('Invalid amount for refund.')); } if (!$payment->getParentTransactionId()) { - throw new \Magento\Core\Exception(__('Invalid transaction ID.')); + throw new \Magento\Model\Exception(__('Invalid transaction ID.')); } $payment->setAnetTransType(self::REQUEST_TYPE_CREDIT); @@ -385,12 +385,12 @@ protected function _refund(\Magento\Object $payment, $amount) ); return $this; } - throw new \Magento\Core\Exception($this->_wrapGatewayError($result->getResponseReasonText())); + throw new \Magento\Model\Exception($this->_wrapGatewayError($result->getResponseReasonText())); case self::RESPONSE_CODE_DECLINED: case self::RESPONSE_CODE_ERROR: - throw new \Magento\Core\Exception($this->_wrapGatewayError($result->getResponseReasonText())); + throw new \Magento\Model\Exception($this->_wrapGatewayError($result->getResponseReasonText())); default: - throw new \Magento\Core\Exception(__('Payment refunding error.')); + throw new \Magento\Model\Exception(__('Payment refunding error.')); } } @@ -495,7 +495,7 @@ public function setResponseData(array $postData) * Validate response data. Needed in controllers. * * @return bool true in case of validation success. - * @throws \Magento\Core\Exception In case of validation error + * @throws \Magento\Model\Exception In case of validation error */ public function validateResponse() { @@ -510,7 +510,7 @@ public function validateResponse() $this->getConfigData('login') ) ) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The transaction was declined because the response hash validation failed.') ); } @@ -522,7 +522,7 @@ public function validateResponse() * * @param array $responseData data from Authorize.net from $_POST * @return void - * @throws \Magento\Core\Exception In case of validation error or order creation error + * @throws \Magento\Model\Exception In case of validation error or order creation error */ public function process(array $responseData) { @@ -546,7 +546,7 @@ public function process(array $responseData) //check payment method $payment = $order->getPayment(); if (!$payment || $payment->getMethod() != $this->getCode()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('This payment didn\'t work out because we can\'t find this order.') ); } @@ -561,7 +561,7 @@ public function process(array $responseData) } if ($isError) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( $responseText && !$response->isApproved() ? $responseText : __( 'This payment didn\'t work out because we can\'t find this order.' ) @@ -602,7 +602,7 @@ protected function _fillPaymentByResponse(\Magento\Object $payment) * Check response code came from Authorize.net. * * @return true in case of Approved response - * @throws \Magento\Core\Exception In case of Declined or Error response from Authorize.net + * @throws \Magento\Model\Exception In case of Declined or Error response from Authorize.net */ public function checkResponseCode() { @@ -611,11 +611,11 @@ public function checkResponseCode() return true; case self::RESPONSE_CODE_DECLINED: case self::RESPONSE_CODE_ERROR: - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( $this->_wrapGatewayError($this->getResponse()->getXResponseReasonText()) ); default: - throw new \Magento\Core\Exception(__('There was a payment authorization error.')); + throw new \Magento\Model\Exception(__('There was a payment authorization error.')); } } @@ -623,12 +623,12 @@ public function checkResponseCode() * Check transaction id came from Authorize.net * * @return true in case of right transaction id - * @throws \Magento\Core\Exception In case of bad transaction id. + * @throws \Magento\Model\Exception In case of bad transaction id. */ public function checkTransId() { if (!$this->getResponse()->getXTransId()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('This payment was not authorized because the transaction ID field is empty.') ); } @@ -652,7 +652,7 @@ protected function _matchAmount($amount) * * @param \Magento\Sales\Model\Order $order * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @throws \Exception */ protected function _authOrder(\Magento\Sales\Model\Order $order) @@ -697,7 +697,7 @@ protected function _authOrder(\Magento\Sales\Model\Order $order) 'Something went wrong: the paid amount doesn\'t match the order amount. Please correct this and try again.' ); $this->_declineOrder($order, $message, true); - throw new \Magento\Core\Exception($message); + throw new \Magento\Model\Exception($message); } //capture order using AIM if needed diff --git a/app/code/Magento/Authorizenet/Model/Resource/Authorizenet/Debug.php b/app/code/Magento/Authorizenet/Model/Resource/Authorizenet/Debug.php index 645462d2ec810..7dffdead4a0ae 100644 --- a/app/code/Magento/Authorizenet/Model/Resource/Authorizenet/Debug.php +++ b/app/code/Magento/Authorizenet/Model/Resource/Authorizenet/Debug.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Debug extends \Magento\Core\Model\Resource\Db\AbstractDb +class Debug extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Authorizenet/Model/Resource/Authorizenet/Debug/Collection.php b/app/code/Magento/Authorizenet/Model/Resource/Authorizenet/Debug/Collection.php index b3d2e42d38316..4949b62de7251 100644 --- a/app/code/Magento/Authorizenet/Model/Resource/Authorizenet/Debug/Collection.php +++ b/app/code/Magento/Authorizenet/Model/Resource/Authorizenet/Debug/Collection.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Backend/App/Router/NoRouteHandler.php b/app/code/Magento/Backend/App/Router/NoRouteHandler.php index 7766ee870bda2..026c5095de1b9 100644 --- a/app/code/Magento/Backend/App/Router/NoRouteHandler.php +++ b/app/code/Magento/Backend/App/Router/NoRouteHandler.php @@ -32,12 +32,21 @@ class NoRouteHandler implements \Magento\App\Router\NoRouteHandlerInterface */ protected $_helper; + /** + * @var \Magento\App\Route\ConfigInterface + */ + protected $_routeConfig; + /** * @param \Magento\Backend\Helper\Data $helper + * @param \Magento\App\Route\ConfigInterface $routeConfig */ - public function __construct(\Magento\Backend\Helper\Data $helper) - { + public function __construct( + \Magento\Backend\Helper\Data $helper, + \Magento\App\Route\ConfigInterface $routeConfig + ) { $this->_helper = $helper; + $this->_routeConfig = $routeConfig; } /** @@ -53,7 +62,7 @@ public function process(\Magento\App\RequestInterface $request) if ($areaFrontName == $this->_helper->getAreaFrontName()) { - $moduleName = 'admin'; + $moduleName = $this->_routeConfig->getRouteFrontName('adminhtml'); $controllerName = 'noroute'; $actionName = 'index'; diff --git a/app/code/Magento/Backend/Block/Cache/Grid/Column/Statuses.php b/app/code/Magento/Backend/Block/Cache/Grid/Column/Statuses.php index 407bf6d49b095..9d30968ee929c 100644 --- a/app/code/Magento/Backend/Block/Cache/Grid/Column/Statuses.php +++ b/app/code/Magento/Backend/Block/Cache/Grid/Column/Statuses.php @@ -60,7 +60,7 @@ public function getFrameCallback() * Decorate status column values * * @param string $value - * @param \Magento\Core\Model\AbstractModel $row + * @param \Magento\Model\AbstractModel $row * @param \Magento\Backend\Block\Widget\Grid\Column $column * @param bool $isExport * @return string diff --git a/app/code/Magento/Backend/Block/Context.php b/app/code/Magento/Backend/Block/Context.php index 12b81953233f6..235f2f10913c8 100644 --- a/app/code/Magento/Backend/Block/Context.php +++ b/app/code/Magento/Backend/Block/Context.php @@ -56,7 +56,7 @@ class Context extends \Magento\View\Element\Context * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\AuthorizationInterface $authorization - * @param array $data + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -78,8 +78,8 @@ public function __construct( \Magento\Escaper $escaper, \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, - \Magento\AuthorizationInterface $authorization, - array $data = array() + \Magento\Translate\Inline\StateInterface $inlineTranslation, + \Magento\AuthorizationInterface $authorization ) { $this->_authorization = $authorization; parent::__construct( @@ -100,7 +100,7 @@ public function __construct( $escaper, $filterManager, $localeDate, - $data + $inlineTranslation ); } diff --git a/app/code/Magento/Backend/Block/Dashboard/AbstractDashboard.php b/app/code/Magento/Backend/Block/Dashboard/AbstractDashboard.php index 07e3bfb6b8827..6acb8b651f49e 100644 --- a/app/code/Magento/Backend/Block/Dashboard/AbstractDashboard.php +++ b/app/code/Magento/Backend/Block/Dashboard/AbstractDashboard.php @@ -25,7 +25,7 @@ */ namespace Magento\Backend\Block\Dashboard; -use Magento\Core\Model\Resource\Db\Collection\AbstractCollection; +use Magento\Model\Resource\Db\Collection\AbstractCollection; /** * Adminhtml dashboard tab abstract diff --git a/app/code/Magento/Backend/Block/Template/Context.php b/app/code/Magento/Backend/Block/Template/Context.php index 824c74526e6f2..7939d9d275b3e 100644 --- a/app/code/Magento/Backend/Block/Template/Context.php +++ b/app/code/Magento/Backend/Block/Template/Context.php @@ -72,6 +72,7 @@ class Context extends \Magento\View\Element\Template\Context * @param \Magento\Escaper $escaper * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\App\Filesystem $filesystem * @param \Magento\View\FileSystem $viewFileSystem * @param \Magento\View\TemplateEnginePool $enginePool @@ -82,7 +83,6 @@ class Context extends \Magento\View\Element\Template\Context * @param \Magento\Math\Random $mathRandom * @param \Magento\Data\Form\FormKey $formKey * @param \Magento\Code\NameBuilder $nameBuilder - * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -104,6 +104,7 @@ public function __construct( \Magento\Escaper $escaper, \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Translate\Inline\StateInterface $inlineTranslation, \Magento\App\Filesystem $filesystem, \Magento\View\FileSystem $viewFileSystem, \Magento\View\TemplateEnginePool $enginePool, @@ -113,8 +114,7 @@ public function __construct( \Magento\Backend\Model\Session $backendSession, \Magento\Math\Random $mathRandom, \Magento\Data\Form\FormKey $formKey, - \Magento\Code\NameBuilder $nameBuilder, - array $data = array() + \Magento\Code\NameBuilder $nameBuilder ) { $this->_authorization = $authorization; $this->_backendSession = $backendSession; @@ -139,12 +139,12 @@ public function __construct( $escaper, $filterManager, $localeDate, + $inlineTranslation, $filesystem, $viewFileSystem, $enginePool, $appState, - $storeManager, - $data + $storeManager ); } diff --git a/app/code/Magento/Backend/Block/Widget/Grid.php b/app/code/Magento/Backend/Block/Widget/Grid.php index c2cf8bce35e33..d23b146915d43 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid.php +++ b/app/code/Magento/Backend/Block/Widget/Grid.php @@ -245,13 +245,13 @@ public function getColumnSet() /** * Retrieve export block * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\View\Element\AbstractBlock|bool */ public function getExportBlock() { if (!$this->getChildBlock('grid.export')) { - throw new \Magento\Core\Exception('Export block for grid ' . $this->getNameInLayout() . ' is not defined'); + throw new \Magento\Model\Exception('Export block for grid ' . $this->getNameInLayout() . ' is not defined'); } return $this->getChildBlock('grid.export'); } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/AbstractFilter.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/AbstractFilter.php index b2fa1353ce779..b2d8658a06f10 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/AbstractFilter.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/AbstractFilter.php @@ -40,18 +40,18 @@ class AbstractFilter extends \Magento\Backend\Block\AbstractBlock implements protected $_column; /** - * @var \Magento\Core\Model\Resource\Helper + * @var \Magento\DB\Helper */ protected $_resourceHelper; /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Core\Model\Resource\Helper $resourceHelper + * @param \Magento\DB\Helper $resourceHelper * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Core\Model\Resource\Helper $resourceHelper, + \Magento\DB\Helper $resourceHelper, array $data = array() ) { $this->_resourceHelper = $resourceHelper; diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Country.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Country.php index a93ac0132f5f2..2739e7a7ba6db 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Country.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Country.php @@ -37,13 +37,13 @@ class Country extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Core\Model\Resource\Helper $resourceHelper + * @param \Magento\DB\Helper $resourceHelper * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $directoriesFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Core\Model\Resource\Helper $resourceHelper, + \Magento\DB\Helper $resourceHelper, \Magento\Directory\Model\Resource\Country\CollectionFactory $directoriesFactory, array $data = array() ) { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php index 3acc79c32e087..b11bf3d249647 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php @@ -42,14 +42,14 @@ class Date extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilt /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Core\Model\Resource\Helper $resourceHelper + * @param \Magento\DB\Helper $resourceHelper * @param \Magento\Math\Random $mathRandom * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Core\Model\Resource\Helper $resourceHelper, + \Magento\DB\Helper $resourceHelper, \Magento\Math\Random $mathRandom, \Magento\Locale\ResolverInterface $localeResolver, array $data = array() diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Price.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Price.php index d4ec0f7e044f5..0c7f01f53400c 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Price.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Price.php @@ -53,14 +53,14 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Core\Model\Resource\Helper $resourceHelper + * @param \Magento\DB\Helper $resourceHelper * @param \Magento\Directory\Model\Currency $currencyModel * @param \Magento\Directory\Model\Currency\DefaultLocator $currencyLocator * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Core\Model\Resource\Helper $resourceHelper, + \Magento\DB\Helper $resourceHelper, \Magento\Directory\Model\Currency $currencyModel, \Magento\Directory\Model\Currency\DefaultLocator $currencyLocator, array $data = array() diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Store.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Store.php index ba211f859922d..522d1ae89bf20 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Store.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Store.php @@ -39,13 +39,13 @@ class Store extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Core\Model\Resource\Helper $resourceHelper + * @param \Magento\DB\Helper $resourceHelper * @param \Magento\Core\Model\System\Store $systemStore * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Core\Model\Resource\Helper $resourceHelper, + \Magento\DB\Helper $resourceHelper, \Magento\Core\Model\System\Store $systemStore, array $data = array() ) { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Theme.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Theme.php index da8e274101860..63c14b3c39199 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Theme.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Theme.php @@ -38,13 +38,13 @@ class Theme extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Core\Model\Resource\Helper $resourceHelper + * @param \Magento\DB\Helper $resourceHelper * @param \Magento\View\Design\Theme\LabelFactory $labelFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Core\Model\Resource\Helper $resourceHelper, + \Magento\DB\Helper $resourceHelper, \Magento\View\Design\Theme\LabelFactory $labelFactory, array $data = array() ) { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Export.php b/app/code/Magento/Backend/Block/Widget/Grid/Export.php index b2dd9e60ff5e5..ce384d8e0a1b7 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Export.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Export.php @@ -84,7 +84,7 @@ public function __construct( /** * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _construct() { @@ -92,7 +92,7 @@ protected function _construct() if ($this->hasData('exportTypes')) { foreach ($this->getData('exportTypes') as $type) { if (!isset($type['urlPath']) || !isset($type['label'])) { - throw new \Magento\Core\Exception('Invalid export type supplied for grid export block'); + throw new \Magento\Model\Exception('Invalid export type supplied for grid export block'); } $this->addExportType($type['urlPath'], $type['label']); } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php index 94ff274c9ee25..9797907e323ee 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php @@ -66,7 +66,7 @@ public function getMassaction() * * @param string|\Magento\View\Element\AbstractBlock $block * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setAdditionalActionBlock($block) { @@ -75,7 +75,7 @@ public function setAdditionalActionBlock($block) } elseif (is_array($block)) { $block = $this->_createFromConfig($block); } elseif (!$block instanceof \Magento\View\Element\AbstractBlock) { - throw new \Magento\Core\Exception('Unknown block type'); + throw new \Magento\Model\Exception('Unknown block type'); } $this->setChild('additional_action', $block); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Ajax.php b/app/code/Magento/Backend/Controller/Adminhtml/Ajax.php index f2fce8f1bcab3..f11ef4f885f50 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Ajax.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Ajax.php @@ -27,6 +27,24 @@ class Ajax extends Action { + /** + * @var \Magento\Translate\Inline\ParserInterface + */ + protected $inlineParser; + + /** + * @param Action\Context $context + * @param \Magento\Translate\Inline\ParserInterface $inlineParser + */ + public function __construct( + Action\Context $context, + \Magento\Translate\Inline\ParserInterface $inlineParser + ) { + parent::__construct($context); + + $this->inlineParser = $inlineParser; + } + /** * Ajax action for inline translation * @@ -34,12 +52,16 @@ class Ajax extends Action */ public function translateAction() { - $translationParams = (array)$this->getRequest()->getPost('translate'); - $area = $this->getRequest()->getPost('area'); - /** @var \Magento\Core\Helper\Translate $translationHelper */ - $translationHelper = $this->_objectManager->get('Magento\Core\Helper\Translate'); - $response = $translationHelper->apply($translationParams, $area); + $translate = (array)$this->getRequest()->getPost('translate'); + + try { + $this->inlineParser->processAjaxPost($translate); + $response = "{success:true}"; + } catch (\Exception $e) { + $response = "{error:true,message:'" . $e->getMessage() . "'}"; + } $this->getResponse()->setBody($response); + $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); } } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache.php index beab3d046dc02..9711e112625b5 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache.php @@ -26,7 +26,7 @@ namespace Magento\Backend\Controller\Adminhtml; use Magento\Backend\App\Action; -use Magento\Core\Exception; +use Magento\Model\Exception; class Cache extends Action { diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php index 7f58c26335f0c..b243b504d747d 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php @@ -95,7 +95,7 @@ public function saveAction() $user->save(); $user->sendPasswordResetNotificationEmail(); $this->messageManager->addSuccess(__('The account has been saved.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addMessages($e->getMessages()); } catch (\Exception $e) { $this->messageManager->addError(__('An error occurred while saving account.')); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Config/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Config/Save.php index e7f01cc54d489..01747e05a59c9 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Config/Save.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Config/Save.php @@ -103,7 +103,7 @@ public function indexAction() $configModel->save(); $this->messageManager->addSuccess(__('You saved the configuration.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $messages = explode("\n", $e->getMessage()); foreach ($messages as $message) { $this->messageManager->addError($message); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php index a63deb55c5d16..ae50f92d7144d 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php @@ -291,7 +291,7 @@ public function saveAction() } $this->_redirect('adminhtml/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_getSession()->setPostData($postData); } catch (\Exception $e) { @@ -454,7 +454,7 @@ public function deleteWebsitePostAction() $this->messageManager->addSuccess(__('The website has been deleted.')); $this->_redirect('adminhtml/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Unable to delete website. Please, try again later.')); @@ -486,8 +486,8 @@ public function deleteGroupPostAction() $model->delete(); $this->messageManager->addSuccess(__('The store has been deleted.')); $this->_redirect('adminhtml/*/'); - return; - } catch (\Magento\Core\Exception $e) { + return ; + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Unable to delete store. Please, try again later.')); @@ -525,7 +525,7 @@ public function deleteStorePostAction() $this->messageManager->addSuccess(__('The store view has been deleted.')); $this->_redirect('adminhtml/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Unable to delete store view. Please, try again later.')); @@ -571,7 +571,7 @@ protected function _backupDatabase($failPath, $arguments = array()) $backupDb->createBackup($backup); $this->messageManager->addSuccess(__('The database was backed up.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect($failPath, $arguments); return; diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php b/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php index 6299fa8247723..3b9cf64c05bd4 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php @@ -28,7 +28,7 @@ use Magento\Backend\App\Action; use Magento\Catalog\Model\Category; use Magento\Catalog\Model\Product; -use Magento\Core\Exception; +use Magento\Model\Exception; use Magento\Core\Model\Url\Rewrite; /** diff --git a/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php b/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php index df6c4d3abf47f..09d40d40bed7e 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php +++ b/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php @@ -26,7 +26,7 @@ namespace Magento\Backend\Helper\Dashboard; use Magento\Core\Helper\Data as HelperData; -use Magento\Core\Model\Resource\Db\Collection\AbstractCollection; +use Magento\Model\Resource\Db\Collection\AbstractCollection; /** * Adminhtml abstract dashboard helper. diff --git a/app/code/Magento/Backend/Model/Auth.php b/app/code/Magento/Backend/Model/Auth.php index a4bc8ce2be441..7816b3f9a9457 100644 --- a/app/code/Magento/Backend/Model/Auth.php +++ b/app/code/Magento/Backend/Model/Auth.php @@ -185,7 +185,7 @@ public function login($username, $password) array('user_name' => $username, 'exception' => $e) ); throw $e; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_eventManager->dispatch( 'backend_auth_user_login_failed', array('user_name' => $username, 'exception' => $e) diff --git a/app/code/Magento/Backend/Model/Auth/Exception.php b/app/code/Magento/Backend/Model/Auth/Exception.php index 82c208d0daaff..3d854fb1ca620 100644 --- a/app/code/Magento/Backend/Model/Auth/Exception.php +++ b/app/code/Magento/Backend/Model/Auth/Exception.php @@ -32,6 +32,6 @@ * @package Magento_Backend * @author Magento Core Team */ -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { } diff --git a/app/code/Magento/Backend/Model/Config.php b/app/code/Magento/Backend/Model/Config.php index 2b73bb3a4ce6b..c9f44d9dccbec 100644 --- a/app/code/Magento/Backend/Model/Config.php +++ b/app/code/Magento/Backend/Model/Config.php @@ -73,7 +73,7 @@ class Config extends \Magento\Object /** * TransactionFactory * - * @var \Magento\Core\Model\Resource\TransactionFactory + * @var \Magento\DB\TransactionFactory */ protected $_transactionFactory; @@ -100,7 +100,7 @@ class Config extends \Magento\Object * @param \Magento\App\ConfigInterface $config * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Backend\Model\Config\Structure $configStructure - * @param \Magento\Core\Model\Resource\TransactionFactory $transactionFactory + * @param \Magento\DB\TransactionFactory $transactionFactory * @param \Magento\Backend\Model\Config\Loader $configLoader * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -110,7 +110,7 @@ public function __construct( \Magento\App\ConfigInterface $config, \Magento\Event\ManagerInterface $eventManager, \Magento\Backend\Model\Config\Structure $configStructure, - \Magento\Core\Model\Resource\TransactionFactory $transactionFactory, + \Magento\DB\TransactionFactory $transactionFactory, \Magento\Backend\Model\Config\Loader $configLoader, \Magento\Core\Model\Config\ValueFactory $configValueFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -147,9 +147,9 @@ public function save() $oldConfig = $this->_getConfig(true); $deleteTransaction = $this->_transactionFactory->create(); - /* @var $deleteTransaction \Magento\Core\Model\Resource\Transaction */ + /* @var $deleteTransaction \Magento\DB\Transaction */ $saveTransaction = $this->_transactionFactory->create(); - /* @var $saveTransaction \Magento\Core\Model\Resource\Transaction */ + /* @var $saveTransaction \Magento\DB\Transaction */ // Extends for old config data $extraOldGroups = array(); @@ -199,8 +199,8 @@ public function save() * @param string $sectionPath * @param array &$extraOldGroups * @param array &$oldConfig - * @param \Magento\Core\Model\Resource\Transaction $saveTransaction - * @param \Magento\Core\Model\Resource\Transaction $deleteTransaction + * @param \Magento\DB\Transaction $saveTransaction + * @param \Magento\DB\Transaction $deleteTransaction * @return void */ protected function _processGroup( @@ -210,8 +210,8 @@ protected function _processGroup( $sectionPath, array &$extraOldGroups, array &$oldConfig, - \Magento\Core\Model\Resource\Transaction $saveTransaction, - \Magento\Core\Model\Resource\Transaction $deleteTransaction + \Magento\DB\Transaction $saveTransaction, + \Magento\DB\Transaction $deleteTransaction ) { $groupPath = $sectionPath . '/' . $groupId; $website = $this->getWebsite(); 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 2111d0acdf7a1..6f227aed02e0f 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php @@ -61,7 +61,7 @@ class Custom extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\App\Config\Storage\WriterInterface $configWriter - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -71,7 +71,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\App\Config\Storage\WriterInterface $configWriter, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Custompath.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Custompath.php index 987ec37faa718..6e3a3e2e44601 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Custompath.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Custompath.php @@ -43,7 +43,7 @@ class Custompath extends \Magento\Core\Model\Config\Value protected function _beforeSave() { if ($this->getOldValue() != $this->getValue()) { - $this->_coreRegistry->register('custom_admin_path_redirect', true, true); + $this->_registry->register('custom_admin_path_redirect', true, true); } return $this; } diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php index 51210e433cbb1..39bdd3248e53b 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php @@ -47,9 +47,9 @@ class Observer protected $_authSession; /** - * @var \Magento\Core\Model\App + * @var \Magento\App\ResponseInterface */ - protected $_app; + protected $_response; /** * @var \Magento\Core\Model\StoreManagerInterface @@ -60,20 +60,20 @@ class Observer * @param \Magento\Backend\Helper\Data $backendData * @param \Magento\Registry $coreRegistry * @param \Magento\Backend\Model\Auth\Session $authSession - * @param \Magento\Core\Model\App $app + * @param \Magento\App\ResponseInterface $response * @param \Magento\Core\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\Backend\Helper\Data $backendData, \Magento\Registry $coreRegistry, \Magento\Backend\Model\Auth\Session $authSession, - \Magento\Core\Model\App $app, + \Magento\App\ResponseInterface $response, \Magento\Core\Model\StoreManagerInterface $storeManager ) { $this->_backendData = $backendData; $this->_coreRegistry = $coreRegistry; $this->_authSession = $authSession; - $this->_app = $app; + $this->_response = $response; $this->_storeManager = $storeManager; } @@ -93,9 +93,9 @@ public function afterCustomUrlChanged() $route = $this->_backendData->getAreaFrontName(); - $this->_app->getResponse()->setRedirect( - $this->_storeManager->getStore()->getBaseUrl() . $route - )->sendResponse(); + $this->_response + ->setRedirect($this->_storeManager->getStore()->getBaseUrl() . $route) + ->sendResponse(); exit(0); } } 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 7d2e550dc3e03..04bf0c0e0cae7 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Robots.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Robots.php @@ -47,7 +47,7 @@ class Robots extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\App\Filesystem $filesystem - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -57,7 +57,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\App\Filesystem $filesystem, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php index d9649fd4ebb44..15dca031687bb 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php @@ -45,7 +45,7 @@ class Usecustom extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\App\Config\Storage\WriterInterface $configWriter - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -55,7 +55,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\App\Config\Storage\WriterInterface $configWriter, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -67,7 +67,7 @@ public function __construct( * Validate custom url * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeSave() { @@ -75,7 +75,7 @@ protected function _beforeSave() if ($value == 1) { $customUrl = $this->getData('groups/url/fields/custom/value'); if (empty($customUrl)) { - throw new \Magento\Core\Exception(__('Please specify the admin custom URL.')); + throw new \Magento\Model\Exception(__('Please specify the admin custom URL.')); } } 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 a067e696abd2f..5c4274c14d68e 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usesecretkey.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usesecretkey.php @@ -42,7 +42,7 @@ class Usesecretkey extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Backend\Model\UrlInterface $backendUrl - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -52,7 +52,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Backend\Model\UrlInterface $backendUrl, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\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 8ef93b7089693..972557ece8025 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Baseurl.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Baseurl.php @@ -36,7 +36,7 @@ class Baseurl extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\View\Asset\MergeService $mergeService - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -46,7 +46,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\View\Asset\MergeService $mergeService, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -58,7 +58,7 @@ public function __construct( * Validate a base URL field value * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeSave() { @@ -67,11 +67,11 @@ protected function _beforeSave() if (!$this->_validateUnsecure($value) && !$this->_validateSecure($value)) { $this->_validateFullyQualifiedUrl($value); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $field = $this->getFieldConfig(); $label = $field && is_array($field) ? $field['label'] : 'value'; $msg = __('Invalid %1. %2', $label, $e->getMessage()); - $error = new \Magento\Core\Exception($msg, 0, $e); + $error = new \Magento\Model\Exception($msg, 0, $e); throw $error; } } @@ -138,12 +138,12 @@ private function _validateSecure($value) * @param array $values * @param string $value * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ private function _assertValuesOrUrl(array $values, $value) { if (!in_array($value, $values) && !$this->_isFullyQualifiedUrl($value)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Value must be a URL or one of placeholders: %1', implode(',', $values)) ); } @@ -155,14 +155,14 @@ private function _assertValuesOrUrl(array $values, $value) * @param array $values * @param string $value * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ private function _assertStartsWithValuesOrUrl(array $values, $value) { $quoted = array_map('preg_quote', $values, array_fill(0, count($values), '/')); if (!preg_match('/^(' . implode('|', $quoted) . ')(.+\/)?$/', $value) && !$this->_isFullyQualifiedUrl($value) ) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Specify a URL or path that starts with placeholder(s): %1, and ends with "/".', implode(', ', $values) @@ -177,7 +177,7 @@ private function _assertStartsWithValuesOrUrl(array $values, $value) * @param array $values * @param string $value * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ private function _assertStartsWithValuesOrUrlOrEmpty(array $values, $value) { @@ -186,9 +186,9 @@ private function _assertStartsWithValuesOrUrlOrEmpty(array $values, $value) } try { $this->_assertStartsWithValuesOrUrl($values, $value); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $msg = __('%1 An empty value is allowed as well.', $e->getMessage()); - $error = new \Magento\Core\Exception($msg, 0, $e); + $error = new \Magento\Model\Exception($msg, 0, $e); throw $error; } } @@ -198,12 +198,12 @@ private function _assertStartsWithValuesOrUrlOrEmpty(array $values, $value) * * @param string $value * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ private function _validateFullyQualifiedUrl($value) { if (!$this->_isFullyQualifiedUrl($value)) { - throw new \Magento\Core\Exception(__('Specify a fully qualified URL.')); + throw new \Magento\Model\Exception(__('Specify a fully qualified URL.')); } } 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 4031c6c4ac8c4..059904ef3c3c8 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Currency/AbstractCurrency.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/AbstractCurrency.php @@ -53,7 +53,7 @@ abstract class AbstractCurrency extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -63,7 +63,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 ee85bbe14467a..2154477dad9b5 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php @@ -44,7 +44,7 @@ class Allow extends AbstractCurrency * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Locale\CurrencyInterface $localeCurrency - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -55,7 +55,7 @@ public function __construct( \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Locale\CurrencyInterface $localeCurrency, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -77,7 +77,7 @@ public function __construct( * Check allowed currencies is available in installed currencies * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _afterSave() { @@ -99,7 +99,7 @@ protected function _afterSave() } if ($exceptions) { - throw new \Magento\Core\Exception(join("\n", $exceptions)); + throw new \Magento\Model\Exception(join("\n", $exceptions)); } return $this; diff --git a/app/code/Magento/Backend/Model/Config/Backend/Currency/Base.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/Base.php index 06d08f84dd6f1..8776f5eeb83c0 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Currency/Base.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/Base.php @@ -36,12 +36,12 @@ class Base extends AbstractCurrency * Check base currency is available in installed currencies * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _afterSave() { if (!in_array($this->getValue(), $this->_getInstalledCurrencies())) { - throw new \Magento\Core\Exception(__('Sorry, we haven\'t installed the base currency you selected.')); + throw new \Magento\Model\Exception(__('Sorry, we haven\'t installed the base currency you selected.')); } return $this; } 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 aebb63e6e4c31..d564eef8ae76a 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Currency/Cron.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/Cron.php @@ -44,7 +44,7 @@ class Cron extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -54,7 +54,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Backend/Model/Config/Backend/Currency/DefaultCurrency.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/DefaultCurrency.php index 1822c25933f9c..95dd5c3304b81 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Currency/DefaultCurrency.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/DefaultCurrency.php @@ -37,18 +37,18 @@ class DefaultCurrency extends AbstractCurrency * Check default currency is available in allowed currencies * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _afterSave() { if (!in_array($this->getValue(), $this->_getInstalledCurrencies())) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Sorry, we haven\'t installed the default display currency you selected.') ); } if (!in_array($this->getValue(), $this->_getAllowedCurrencies())) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Sorry, the default display currency you selected in not available in allowed currencies.') ); } diff --git a/app/code/Magento/Backend/Model/Config/Backend/Email/Address.php b/app/code/Magento/Backend/Model/Config/Backend/Email/Address.php index 40de02605ace1..eb67af0d76aef 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Email/Address.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Email/Address.php @@ -29,7 +29,7 @@ */ namespace Magento\Backend\Model\Config\Backend\Email; -use Magento\Core\Exception; +use Magento\Model\Exception; class Address extends \Magento\Core\Model\Config\Value { diff --git a/app/code/Magento/Backend/Model/Config/Backend/Email/Sender.php b/app/code/Magento/Backend/Model/Config/Backend/Email/Sender.php index a9643614b9c31..4fa9d9e57aaf1 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Email/Sender.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Email/Sender.php @@ -35,19 +35,19 @@ class Sender extends \Magento\Core\Model\Config\Value * Check sender name validity * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeSave() { $value = $this->getValue(); if (!preg_match("/^[\S ]+$/", $value)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The sender name "%1" is not valid. Please use only visible characters and spaces.', $value) ); } if (strlen($value) > 255) { - throw new \Magento\Core\Exception(__('Maximum sender name length is 255. Please correct your settings.')); + throw new \Magento\Model\Exception(__('Maximum sender name length is 255. Please correct your settings.')); } return $this; } diff --git a/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php b/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php index f1a927c37d5e4..d418f55fb6512 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 extends \Magento\Core\Model\Config\Value implements \Magento\App * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Encryption\EncryptorInterface $encryptor - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -50,7 +50,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Encryption\EncryptorInterface $encryptor, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Backend/Model/Config/Backend/File.php b/app/code/Magento/Backend/Model/Config/Backend/File.php index 343960f238625..b89281cc29bba 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/File.php +++ b/app/code/Magento/Backend/Model/Config/Backend/File.php @@ -67,7 +67,7 @@ class File extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\File\UploaderFactory $uploaderFactory * @param \Magento\Backend\Model\Config\Backend\File\RequestData\RequestDataInterface $requestData * @param \Magento\App\Filesystem $filesystem - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -79,7 +79,7 @@ public function __construct( \Magento\Core\Model\File\UploaderFactory $uploaderFactory, \Magento\Backend\Model\Config\Backend\File\RequestData\RequestDataInterface $requestData, \Magento\App\Filesystem $filesystem, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -94,7 +94,7 @@ public function __construct( * Save uploaded file before saving config value * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeSave() { @@ -117,7 +117,7 @@ protected function _beforeSave() $uploader->addValidateCallback('size', $this, 'validateMaxSize'); $result = $uploader->save($uploadDir); } catch (\Exception $e) { - throw new \Magento\Core\Exception($e->getMessage()); + throw new \Magento\Model\Exception($e->getMessage()); } $filename = $result['file']; @@ -143,7 +143,7 @@ protected function _beforeSave() * * @param string $filePath Path to temporary uploaded file * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validateMaxSize($filePath) { @@ -152,7 +152,7 @@ public function validateMaxSize($filePath) $directory->getRelativePath($filePath) )['size'] > $this->_maxFileSize * 1024 ) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The file you\'re uploading exceeds the server size limit of %1 kilobytes.', $this->_maxFileSize) ); } @@ -174,7 +174,7 @@ protected function _addWhetherScopeInfo() * Return path to directory for upload file * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getUploadDir() { @@ -182,7 +182,7 @@ protected function _getUploadDir() /* @var $fieldConfig \Magento\Simplexml\Element */ if (!array_key_exists('upload_dir', $fieldConfig)) { - throw new \Magento\Core\Exception(__('The base directory to upload file is not specified.')); + throw new \Magento\Model\Exception(__('The base directory to upload file is not specified.')); } if (is_array($fieldConfig['upload_dir'])) { 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 a9fc8488f21b0..fbbbf9c28dafe 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Image/Adapter.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Image/Adapter.php @@ -47,7 +47,7 @@ class Adapter extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Image\AdapterFactory $imageFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -57,7 +57,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Image\AdapterFactory $imageFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -68,7 +68,7 @@ public function __construct( /** * Checks if chosen image adapter available * - * @throws \Magento\Core\Exception If some of adapter dependencies was not loaded + * @throws \Magento\Model\Exception If some of adapter dependencies was not loaded * @return \Magento\Backend\Model\Config\Backend\File */ protected function _beforeSave() @@ -77,7 +77,7 @@ protected function _beforeSave() $this->_imageFactory->create($this->getValue()); } catch (\Exception $e) { $message = __('The specified image adapter cannot be used because of: ' . $e->getMessage()); - throw new \Magento\Core\Exception($message); + throw new \Magento\Model\Exception($message); } return $this; diff --git a/app/code/Magento/Backend/Model/Config/Backend/Image/Favicon.php b/app/code/Magento/Backend/Model/Config/Backend/Image/Favicon.php index 7ba10cef12b18..647a96dda7d3e 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Image/Favicon.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Image/Favicon.php @@ -41,7 +41,7 @@ class Favicon extends \Magento\Backend\Model\Config\Backend\Image * Return path to directory for upload file * * @return string - * @throw \Magento\Core\Exception + * @throw \Magento\Model\Exception */ protected function _getUploadDir() { diff --git a/app/code/Magento/Backend/Model/Config/Backend/Image/Logo.php b/app/code/Magento/Backend/Model/Config/Backend/Image/Logo.php index 537981da703b1..7622de5e097d1 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Image/Logo.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Image/Logo.php @@ -41,7 +41,7 @@ class Logo extends \Magento\Backend\Model\Config\Backend\Image * Return path to directory for upload file * * @return string - * @throw \Magento\Core\Exception + * @throw \Magento\Model\Exception */ protected function _getUploadDir() { diff --git a/app/code/Magento/Backend/Model/Config/Backend/Locale.php b/app/code/Magento/Backend/Model/Config/Backend/Locale.php index 9b51050c250e9..14d3714fa52e1 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Locale.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Locale.php @@ -60,7 +60,7 @@ class Locale extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Website\Factory $websiteFactory * @param \Magento\Core\Model\StoreFactory $storeFactory * @param \Magento\Locale\CurrencyInterface $localeCurrency - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data * @@ -75,7 +75,7 @@ public function __construct( \Magento\Core\Model\Website\Factory $websiteFactory, \Magento\Core\Model\StoreFactory $storeFactory, \Magento\Locale\CurrencyInterface $localeCurrency, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -88,7 +88,7 @@ public function __construct( /** * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _afterSave() { @@ -137,7 +137,7 @@ protected function _afterSave() } } if ($exceptions) { - throw new \Magento\Core\Exception(join("\n", $exceptions)); + throw new \Magento\Model\Exception(join("\n", $exceptions)); } return $this; diff --git a/app/code/Magento/Backend/Model/Config/Backend/Locale/Timezone.php b/app/code/Magento/Backend/Model/Config/Backend/Locale/Timezone.php index d597f97925dd3..144a11eee4185 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Locale/Timezone.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Locale/Timezone.php @@ -29,7 +29,7 @@ */ namespace Magento\Backend\Model\Config\Backend\Locale; -use Magento\Core\Exception; +use Magento\Model\Exception; class Timezone extends \Magento\Core\Model\Config\Value { 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 d2852cb7eacca..a4a0a725b3b18 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Log/Cron.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Log/Cron.php @@ -51,7 +51,7 @@ class Cron extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param string $runModelPath * @param array $data @@ -62,7 +62,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, $runModelPath = '', array $data = array() @@ -76,7 +76,7 @@ public function __construct( * Cron settings after save * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _afterSave() { @@ -111,7 +111,7 @@ protected function _afterSave() $configValue->load(self::CRON_MODEL_PATH, 'path'); $configValue->setValue($this->_runModelPath)->setPath(self::CRON_MODEL_PATH)->save(); } catch (\Exception $e) { - throw new \Magento\Core\Exception(__('We can\'t save the Cron expression.')); + throw new \Magento\Model\Exception(__('We can\'t save the Cron expression.')); } } } diff --git a/app/code/Magento/Backend/Model/Config/Backend/Secure.php b/app/code/Magento/Backend/Model/Config/Backend/Secure.php index 381035a2b3b64..91742ff6a4b76 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Secure.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Secure.php @@ -36,7 +36,7 @@ class Secure extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\View\Asset\MergeService $mergeService - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -46,7 +46,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\View\Asset\MergeService $mergeService, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 ff7fdadb17b4f..b4dbe01c9b22e 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\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Helper\File\Storage $coreFileStorage - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -50,7 +50,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Helper\File\Storage $coreFileStorage, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Backend/Model/Config/Backend/Translate.php b/app/code/Magento/Backend/Model/Config/Backend/Translate.php index 9eb8cb2a180a4..46fa8c0a74ef7 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Translate.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Translate.php @@ -59,7 +59,7 @@ class Translate extends \Magento\Core\Model\Config\Value * @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 + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -70,7 +70,7 @@ public function __construct( \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\App\Cache\TypeListInterface $cacheTypeList, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 98b1a95cc07a3..f6832e85d8759 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php @@ -70,13 +70,13 @@ public function shouldCloneFields() /** * Retrieve clone model * - * @return \Magento\Core\Model\AbstractModel - * @throws \Magento\Core\Exception + * @return \Magento\Model\AbstractModel + * @throws \Magento\Model\Exception */ public function getCloneModel() { if (!isset($this->_data['clone_model']) || !$this->_data['clone_model']) { - throw new \Magento\Core\Exception('Config form fieldset clone model required to be able to clone fields'); + throw new \Magento\Model\Exception('Config form fieldset clone model required to be able to clone fields'); } return $this->_cloneModelFactory->create($this->_data['clone_model']); } diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Group/Proxy.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Group/Proxy.php index 80d75266460be..51d5d9af5ea1f 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Group/Proxy.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Group/Proxy.php @@ -187,7 +187,7 @@ public function shouldCloneFields() /** * Retrieve clone model * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ public function getCloneModel() { diff --git a/app/code/Magento/Backend/Model/Locale/Manager.php b/app/code/Magento/Backend/Model/Locale/Manager.php index fe9d0ecc99597..7483b085a0e5e 100644 --- a/app/code/Magento/Backend/Model/Locale/Manager.php +++ b/app/code/Magento/Backend/Model/Locale/Manager.php @@ -78,7 +78,7 @@ public function switchBackendInterfaceLocale($localeCode) $this->_authSession->getUser()->setInterfaceLocale($localeCode); - $this->_translator->setLocale($localeCode)->init(null, true); + $this->_translator->setLocale($localeCode)->loadData(null, true); return $this; } diff --git a/app/code/Magento/Backend/Model/Locale/Resolver.php b/app/code/Magento/Backend/Model/Locale/Resolver.php index 958b7d16a3fd0..31f6a1a19de5d 100644 --- a/app/code/Magento/Backend/Model/Locale/Resolver.php +++ b/app/code/Magento/Backend/Model/Locale/Resolver.php @@ -52,7 +52,7 @@ class Resolver extends \Magento\Locale\Resolver /** * @param \Magento\Locale\ScopeConfigInterface $scopeConfig - * @param \Magento\AppInterface $app + * @param \Magento\App\CacheInterface $cache * @param \Magento\LocaleFactory $localeFactory * @param string $defaultLocalePath * @param \Magento\ObjectManager $objectManager @@ -60,11 +60,11 @@ class Resolver extends \Magento\Locale\Resolver * @param Manager $localeManager * @param \Magento\App\RequestInterface $request * @param \Magento\Locale\Validator $localeValidator - * @param string|null $locale + * @param null $locale */ public function __construct( \Magento\Locale\ScopeConfigInterface $scopeConfig, - \Magento\AppInterface $app, + \Magento\App\CacheInterface $cache, \Magento\LocaleFactory $localeFactory, $defaultLocalePath, \Magento\ObjectManager $objectManager, @@ -78,7 +78,7 @@ public function __construct( $this->_localeManager = $localeManager; $this->_request = $request; $this->_localeValidator = $localeValidator; - parent::__construct($scopeConfig, $app, $localeFactory, $defaultLocalePath, $locale); + parent::__construct($scopeConfig, $cache, $localeFactory, $defaultLocalePath, $locale); } /** diff --git a/app/code/Magento/Backend/Model/Observer.php b/app/code/Magento/Backend/Model/Observer.php index 65c34dcf3551c..652bdf5e2b84d 100644 --- a/app/code/Magento/Backend/Model/Observer.php +++ b/app/code/Magento/Backend/Model/Observer.php @@ -36,9 +36,9 @@ class Observer protected $_backendSession; /** - * @var \Magento\Core\Model\App + * @var \Magento\App\CacheInterface */ - protected $_app; + protected $cache; /** * @var \Magento\App\RequestInterface @@ -46,17 +46,17 @@ class Observer protected $_request; /** - * @param \Magento\Backend\Model\Session $backendSession - * @param \Magento\Core\Model\App $app + * @param Session $backendSession + * @param \Magento\App\CacheInterface $cache * @param \Magento\App\RequestInterface $request */ public function __construct( \Magento\Backend\Model\Session $backendSession, - \Magento\Core\Model\App $app, + \Magento\App\CacheInterface $cache, \Magento\App\RequestInterface $request ) { $this->_backendSession = $backendSession; - $this->_app = $app; + $this->cache = $cache; $this->_request = $request; } @@ -88,16 +88,6 @@ public function clearCacheConfigurationFilesAccessLevelVerification() return $this; } - /** - * Backend will always use base class for translation. - * - * @return $this - */ - public function initializeTranslation() - { - return $this; - } - /** * Set url class name for store 'admin' * @@ -115,7 +105,7 @@ public function setUrlClassName(\Magento\Event\Observer $observer) break; } } - $this->_app->removeCache( + $this->cache->remove( \Magento\AdminNotification\Model\System\Message\Security::VERIFICATION_RESULT_CACHE_KEY ); return $this; diff --git a/app/code/Magento/Backend/Model/Translate.php b/app/code/Magento/Backend/Model/Translate.php deleted file mode 100644 index 54ab6a1e87ced..0000000000000 --- a/app/code/Magento/Backend/Model/Translate.php +++ /dev/null @@ -1,43 +0,0 @@ -getConfig(self::CONFIG_KEY_AREA) == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) { - $scope = 'admin'; - } - $this->_translateInline = $this->getInlineObject($initParams)->isAllowed($scope); - return $this; - } -} diff --git a/app/code/Magento/Backend/Model/Url.php b/app/code/Magento/Backend/Model/Url.php index a1709086643c9..26fa44a8f6fd9 100644 --- a/app/code/Magento/Backend/Model/Url.php +++ b/app/code/Magento/Backend/Model/Url.php @@ -219,8 +219,8 @@ public function getUrl($routePath = null, $routeParams = null) return $result; } $routeName = $this->_getRouteName('*'); - $controllerName = $this->_getControllerName($this->_getDefaultControllerName()); - $actionName = $this->_getActionName($this->_getDefaultActionName()); + $controllerName = $this->_getControllerName(self::DEFAULT_CONTROLLER_NAME); + $actionName = $this->_getActionName(self::DEFAULT_ACTION_NAME); if ($cacheSecretKey) { $secret = array(self::SECRET_KEY_PARAM_NAME => "\${$routeName}/{$controllerName}/{$actionName}\$"); } else { diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index 5020afe02eab1..97a4d138a58d9 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -33,18 +33,9 @@ - - - - - - - Magento\Backend\Model\UrlInterface - Magento_Core::translate_inline.phtml - - + Magento\Backend\Helper\Data diff --git a/app/code/Magento/Backend/etc/adminhtml/events.xml b/app/code/Magento/Backend/etc/adminhtml/events.xml index a1cd9739d7069..40b0a29b74ba7 100644 --- a/app/code/Magento/Backend/etc/adminhtml/events.xml +++ b/app/code/Magento/Backend/etc/adminhtml/events.xml @@ -24,9 +24,6 @@ */ --> - - - diff --git a/app/code/Magento/Backend/etc/adminhtml/system.xml b/app/code/Magento/Backend/etc/adminhtml/system.xml index ff850688e90ff..504cd16521331 100644 --- a/app/code/Magento/Backend/etc/adminhtml/system.xml +++ b/app/code/Magento/Backend/etc/adminhtml/system.xml @@ -509,7 +509,7 @@ - + Magento\Backend\Model\Config\Source\Yesno diff --git a/app/code/Magento/Backend/view/adminhtml/page/footer.phtml b/app/code/Magento/Backend/view/adminhtml/page/footer.phtml index d5348c5e73ce6..463dfe4454896 100644 --- a/app/code/Magento/Backend/view/adminhtml/page/footer.phtml +++ b/app/code/Magento/Backend/view/adminhtml/page/footer.phtml @@ -25,4 +25,4 @@ */ ?> getChildHtml('copyright');?> / - + diff --git a/app/code/Magento/Backup/Model/Backup.php b/app/code/Magento/Backup/Model/Backup.php index a036126653966..73fe25448847a 100644 --- a/app/code/Magento/Backup/Model/Backup.php +++ b/app/code/Magento/Backup/Model/Backup.php @@ -241,12 +241,12 @@ public function getType() * * @param string &$content * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setFile(&$content) { if (!$this->hasData('time') || !$this->hasData('type') || !$this->hasData('path')) { - throw new \Magento\Core\Exception(__('Please correct the order of creation for a new backup.')); + throw new \Magento\Model\Exception(__('Please correct the order of creation for a new backup.')); } $this->varDirectory->writeFile($this->_getFilePath(), $content); @@ -257,12 +257,12 @@ public function setFile(&$content) * Return content of backup file * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function &getFile() { if (!$this->exists()) { - throw new \Magento\Core\Exception(__("The backup file does not exist.")); + throw new \Magento\Model\Exception(__("The backup file does not exist.")); } return $this->varDirectory->read($this->_getFilePath()); @@ -272,12 +272,12 @@ public function &getFile() * Delete backup file * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function deleteFile() { if (!$this->exists()) { - throw new \Magento\Core\Exception(__("The backup file does not exist.")); + throw new \Magento\Model\Exception(__("The backup file does not exist.")); } $this->varDirectory->delete($this->_getFilePath()); diff --git a/app/code/Magento/Backup/Model/Config/Backend/Cron.php b/app/code/Magento/Backup/Model/Config/Backend/Cron.php index 5d5470c055b97..091966d59b3f0 100644 --- a/app/code/Magento/Backup/Model/Config/Backend/Cron.php +++ b/app/code/Magento/Backup/Model/Config/Backend/Cron.php @@ -56,7 +56,7 @@ class Cron extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param string $runModelPath * @param array $data @@ -67,7 +67,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, $runModelPath = '', array $data = array() @@ -81,7 +81,7 @@ public function __construct( * Cron settings after save * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _afterSave() { @@ -124,7 +124,7 @@ protected function _afterSave() self::CRON_MODEL_PATH )->save(); } catch (\Exception $e) { - throw new \Magento\Core\Exception(__('We can\'t save the Cron expression.')); + throw new \Magento\Model\Exception(__('We can\'t save the Cron expression.')); } } } diff --git a/app/code/Magento/Backup/Model/Resource/Helper.php b/app/code/Magento/Backup/Model/Resource/Helper.php index 1d1f6eaec5217..515962267f00d 100644 --- a/app/code/Magento/Backup/Model/Resource/Helper.php +++ b/app/code/Magento/Backup/Model/Resource/Helper.php @@ -25,7 +25,7 @@ */ namespace Magento\Backup\Model\Resource; -class Helper extends \Magento\Core\Model\Resource\Helper +class Helper extends \Magento\DB\Helper { /** * Tables foreign key data array @@ -44,13 +44,13 @@ class Helper extends \Magento\Core\Model\Resource\Helper /** * @param \Magento\App\Resource $resource - * @param \Magento\Stdlib\DateTime\DateTime $coreDate * @param string $modulePrefix + * @param \Magento\Stdlib\DateTime\DateTime $coreDate */ public function __construct( \Magento\App\Resource $resource, - \Magento\Stdlib\DateTime\DateTime $coreDate, - $modulePrefix + $modulePrefix, + \Magento\Stdlib\DateTime\DateTime $coreDate ) { parent::__construct($resource, $modulePrefix); $this->_coreDate = $coreDate; diff --git a/app/code/Magento/Backup/etc/di.xml b/app/code/Magento/Backup/etc/di.xml index e89935b6b1c49..39b3fae54cc0b 100644 --- a/app/code/Magento/Backup/etc/di.xml +++ b/app/code/Magento/Backup/etc/di.xml @@ -30,4 +30,9 @@ Magento\Backup\Model\Db + + + backup + + diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php index 681e12acccece..38700b9497ba2 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php @@ -74,17 +74,7 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView protected $_localeFormat; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Stdlib\ArrayUtils $arrayUtils * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\Bundle\Model\Product\PriceFactory $productPrice @@ -93,21 +83,9 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView * @param \Magento\Locale\FormatInterface $localeFormat * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Stdlib\ArrayUtils $arrayUtils, \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Bundle\Model\Product\PriceFactory $productPrice, @@ -124,16 +102,6 @@ public function __construct( $this->_localeFormat = $localeFormat; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $arrayUtils, $data, $priceBlockTypes diff --git a/app/code/Magento/Bundle/Model/Option.php b/app/code/Magento/Bundle/Model/Option.php index 026c53e7d36bc..5464b30536645 100644 --- a/app/code/Magento/Bundle/Model/Option.php +++ b/app/code/Magento/Bundle/Model/Option.php @@ -43,7 +43,7 @@ * @package Magento_Bundle * @author Magento Core Team */ -class Option extends \Magento\Core\Model\AbstractModel +class Option extends \Magento\Model\AbstractModel { /** * Default selection object diff --git a/app/code/Magento/Bundle/Model/Price/Index.php b/app/code/Magento/Bundle/Model/Price/Index.php index 2ecd422d0bd00..7020138f4727b 100644 --- a/app/code/Magento/Bundle/Model/Price/Index.php +++ b/app/code/Magento/Bundle/Model/Price/Index.php @@ -43,7 +43,7 @@ * @package Magento_Bundle * @author Magento Core Team */ -class Index extends \Magento\Core\Model\AbstractModel +class Index extends \Magento\Model\AbstractModel { /** * @var \Magento\Customer\Model\Session @@ -60,7 +60,7 @@ class Index extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -69,7 +69,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php index 074b756499398..fe2da7542303e 100644 --- a/app/code/Magento/Bundle/Model/Product/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Type.php @@ -1062,7 +1062,7 @@ public function getSearchableData($product) * * @param \Magento\Catalog\Model\Product $product * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function checkProductBuyState($product) { @@ -1076,7 +1076,7 @@ public function checkProductBuyState($product) $bundleOption = $buyRequest->getBundleOption(); if (empty($bundleOption)) { - throw new \Magento\Core\Exception($this->getSpecifyOptionMessage()); + throw new \Magento\Model\Exception($this->getSpecifyOptionMessage()); } $skipSaleableCheck = $this->_catalogProduct->getSkipSaleableCheck(); @@ -1084,7 +1084,7 @@ public function checkProductBuyState($product) /* @var $selection \Magento\Bundle\Model\Selection */ $selection = $productSelections->getItemById($selectionId); if (!$selection || !$selection->isSalable() && !$skipSaleableCheck) { - throw new \Magento\Core\Exception(__('The required options you selected are not available.')); + throw new \Magento\Model\Exception(__('The required options you selected are not available.')); } } @@ -1092,7 +1092,7 @@ public function checkProductBuyState($product) $optionsCollection = $this->getOptionsCollection($product); foreach ($optionsCollection->getItems() as $option) { if ($option->getRequired() && empty($bundleOption[$option->getId()])) { - throw new \Magento\Core\Exception(__('Please select all required options.')); + throw new \Magento\Model\Exception(__('Please select all required options.')); } } diff --git a/app/code/Magento/Bundle/Model/Resource/Bundle.php b/app/code/Magento/Bundle/Model/Resource/Bundle.php index 7c2b4576fd599..63ee5c199784b 100644 --- a/app/code/Magento/Bundle/Model/Resource/Bundle.php +++ b/app/code/Magento/Bundle/Model/Resource/Bundle.php @@ -32,7 +32,7 @@ * @package Magento_Bundle * @author Magento Core Team */ -class Bundle extends \Magento\Core\Model\Resource\Db\AbstractDb +class Bundle extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Catalog\Model\Resource\Product\Relation diff --git a/app/code/Magento/Bundle/Model/Resource/Option.php b/app/code/Magento/Bundle/Model/Resource/Option.php index f6f8bb574eed9..3792f0201bf6a 100644 --- a/app/code/Magento/Bundle/Model/Resource/Option.php +++ b/app/code/Magento/Bundle/Model/Resource/Option.php @@ -32,7 +32,7 @@ * @package Magento_Bundle * @author Magento Core Team */ -class Option extends \Magento\Core\Model\Resource\Db\AbstractDb +class Option extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection and define resource @@ -47,10 +47,10 @@ protected function _construct() /** * After save process * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { parent::_afterSave($object); @@ -83,10 +83,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * After delete process * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterDelete(\Magento\Core\Model\AbstractModel $object) + protected function _afterDelete(\Magento\Model\AbstractModel $object) { parent::_afterDelete($object); diff --git a/app/code/Magento/Bundle/Model/Resource/Option/Collection.php b/app/code/Magento/Bundle/Model/Resource/Option/Collection.php index d20c94aed58dc..899f4041136dd 100644 --- a/app/code/Magento/Bundle/Model/Resource/Option/Collection.php +++ b/app/code/Magento/Bundle/Model/Resource/Option/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Bundle * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * All item ids cache diff --git a/app/code/Magento/Bundle/Model/Resource/Price/Index.php b/app/code/Magento/Bundle/Model/Resource/Price/Index.php index 04029a978caf3..52f0c99b3174b 100644 --- a/app/code/Magento/Bundle/Model/Resource/Price/Index.php +++ b/app/code/Magento/Bundle/Model/Resource/Price/Index.php @@ -34,7 +34,7 @@ * @package Magento_Bundle * @author Magento Core Team */ -class Index extends \Magento\Core\Model\Resource\Db\AbstractDb +class Index extends \Magento\Model\Resource\Db\AbstractDb { /** * EAV attributes cache diff --git a/app/code/Magento/Bundle/Model/Resource/Selection.php b/app/code/Magento/Bundle/Model/Resource/Selection.php index 66059fdfaf5ab..255fd649a15c9 100644 --- a/app/code/Magento/Bundle/Model/Resource/Selection.php +++ b/app/code/Magento/Bundle/Model/Resource/Selection.php @@ -32,7 +32,7 @@ * @package Magento_Bundle * @author Magento Core Team */ -class Selection extends \Magento\Core\Model\Resource\Db\AbstractDb +class Selection extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table and id field 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 a42c33d027fc4..63c0394f724d0 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 @@ -44,7 +44,7 @@ class Creditmemo extends AbstractItems * @param \Magento\App\Filesystem $filesystem * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $string - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -55,7 +55,7 @@ public function __construct( \Magento\App\Filesystem $filesystem, \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $string, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 61ddb577cd65e..b90de45336f9e 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 @@ -42,7 +42,7 @@ class Invoice extends AbstractItems * @param \Magento\App\Filesystem $filesystem * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $coreString - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -53,7 +53,7 @@ public function __construct( \Magento\App\Filesystem $filesystem, \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $coreString, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 0c149eb00fafc..cf251864bd01a 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 @@ -42,7 +42,7 @@ class Shipment extends AbstractItems * @param \Magento\App\Filesystem $filesystem * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $string - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -53,7 +53,7 @@ public function __construct( \Magento\App\Filesystem $filesystem, \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $string, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Bundle/Model/Selection.php b/app/code/Magento/Bundle/Model/Selection.php index 7239def712fe7..8bd37643bbe1e 100644 --- a/app/code/Magento/Bundle/Model/Selection.php +++ b/app/code/Magento/Bundle/Model/Selection.php @@ -53,7 +53,7 @@ * @package Magento_Bundle * @author Magento Core Team */ -class Selection extends \Magento\Core\Model\AbstractModel +class Selection extends \Magento\Model\AbstractModel { /** * Catalog data diff --git a/app/code/Magento/Bundle/etc/module.xml b/app/code/Magento/Bundle/etc/module.xml index fe55593090bd6..6970d55280498 100644 --- a/app/code/Magento/Bundle/etc/module.xml +++ b/app/code/Magento/Bundle/etc/module.xml @@ -42,7 +42,6 @@ - diff --git a/app/code/Magento/Captcha/Model/Resource/Log.php b/app/code/Magento/Captcha/Model/Resource/Log.php index e43ca63d13615..b291cf70ec440 100644 --- a/app/code/Magento/Captcha/Model/Resource/Log.php +++ b/app/code/Magento/Captcha/Model/Resource/Log.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Log extends \Magento\Core\Model\Resource\Db\AbstractDb +class Log extends \Magento\Model\Resource\Db\AbstractDb { /** * Type Remote Address diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php index f3fdc8cafb698..23604b12a1c3e 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php @@ -60,9 +60,9 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory protected $_backendSession; /** - * @var \Magento\Core\Model\Resource\HelperPool + * @var \Magento\DB\Helper */ - protected $_helperPool; + protected $_resourceHelper; /** * @var \Magento\Json\EncoderInterface @@ -71,10 +71,10 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Json\EncoderInterface $jsonEncoder * @param \Magento\Catalog\Model\Resource\Category\Tree $categoryTree * @param \Magento\Registry $registry - * @param \Magento\Core\Model\Resource\HelperPool $helperPool + * @param \Magento\Json\EncoderInterface $jsonEncoder + * @param \Magento\DB\Helper $resourceHelper * @param \Magento\Backend\Model\Auth\Session $backendSession * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param array $data @@ -84,13 +84,13 @@ public function __construct( \Magento\Catalog\Model\Resource\Category\Tree $categoryTree, \Magento\Registry $registry, \Magento\Json\EncoderInterface $jsonEncoder, - \Magento\Core\Model\Resource\HelperPool $helperPool, + \Magento\DB\Helper $resourceHelper, \Magento\Backend\Model\Auth\Session $backendSession, \Magento\Catalog\Model\CategoryFactory $categoryFactory, array $data = array() ) { $this->_jsonEncoder = $jsonEncoder; - $this->_helperPool = $helperPool; + $this->_resourceHelper = $resourceHelper; $this->_backendSession = $backendSession; $this->_categoryFactory = $categoryFactory; parent::__construct($context, $categoryTree, $registry, $data); @@ -201,9 +201,7 @@ public function getSuggestedCategoriesJson($namePart) $collection = $this->_categoryFactory->create()->getCollection(); $matchingNamesCollection = clone $collection; - $escapedNamePart = $this->_helperPool->get( - 'Magento_Core' - )->addLikeEscape( + $escapedNamePart = $this->_resourceHelper->addLikeEscape( $namePart, array('position' => 'any') ); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php index 808f8d838b623..8da558b3c95d8 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php @@ -48,25 +48,25 @@ class Search extends \Magento\Backend\Block\Widget protected $_collectionFactory; /** - * @var \Magento\Core\Model\Resource\HelperPool + * @var \Magento\DB\Helper */ - protected $_helperPool; + protected $_resourceHelper; /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Resource\HelperPool $helperPool + * @param \Magento\DB\Helper $resourceHelper * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory * @param \Magento\Registry $registry * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Resource\HelperPool $helperPool, + \Magento\DB\Helper $resourceHelper, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory, \Magento\Registry $registry, array $data = array() ) { - $this->_helperPool = $helperPool; + $this->_resourceHelper = $resourceHelper; $this->_collectionFactory = $collectionFactory; $this->_coreRegistry = $registry; parent::__construct($context, $data); @@ -107,9 +107,7 @@ public function getSelectorOptions() */ public function getSuggestedAttributes($labelPart, $templateId = null) { - $escapedLabelPart = $this->_helperPool->get( - 'Magento_Core' - )->addLikeEscape( + $escapedLabelPart = $this->_resourceHelper->addLikeEscape( $labelPart, array('position' => 'any') ); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group.php index c006116ed81ce..649be1e53949e 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group.php @@ -18,23 +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_Adminhtml * @copyright Copyright (c) 2014 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\Block\Adminhtml\Product\Edit\Tab\Price; +use Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Group\AbstractGroup; /** * Adminhtml group price item renderer - * - * @category Magento - * @package Magento_Catalog - * @author Magento Core Team */ -namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price; - -class Group extends \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Group\AbstractGroup +class Group extends AbstractGroup { /** * @var string diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php index c14dce706c39c..905da4d583e0d 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php @@ -18,23 +18,19 @@ * 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_Adminhtml * @copyright Copyright (c) 2014 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\Block\Adminhtml\Product\Edit\Tab\Price\Group; + +use Magento\Backend\Block\Widget; +use Magento\Customer\Service\V1\CustomerGroupServiceInterface; +use Magento\Data\Form\Element\Renderer\RendererInterface; /** * Adminhtml group price item abstract renderer - * - * @category Magento - * @package Magento_Catalog - * @author Magento Core Team */ -namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Group; - -abstract class AbstractGroup extends \Magento\Backend\Block\Widget implements - \Magento\Data\Form\Element\Renderer\RendererInterface +abstract class AbstractGroup extends Widget implements RendererInterface { /** * Form element instance @@ -77,13 +73,13 @@ abstract class AbstractGroup extends \Magento\Backend\Block\Widget implements protected $_directoryHelper; /** - * @var \Magento\Customer\Model\GroupFactory + * @var CustomerGroupServiceInterface */ - protected $_groupFactory; + protected $_groupService; /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Customer\Model\GroupFactory $groupFactory + * @param CustomerGroupServiceInterface $groupService * @param \Magento\Directory\Helper\Data $directoryHelper * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Registry $registry @@ -91,13 +87,13 @@ abstract class AbstractGroup extends \Magento\Backend\Block\Widget implements */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Customer\Model\GroupFactory $groupFactory, + CustomerGroupServiceInterface $groupService, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Catalog\Helper\Data $catalogData, \Magento\Registry $registry, array $data = array() ) { - $this->_groupFactory = $groupFactory; + $this->_groupService = $groupService; $this->_directoryHelper = $directoryHelper; $this->_catalogData = $catalogData; $this->_coreRegistry = $registry; @@ -194,12 +190,11 @@ public function getCustomerGroups($groupId = null) if (!$this->_catalogData->isModuleEnabled('Magento_Customer')) { return array(); } - $collection = $this->_groupFactory->create()->getCollection(); + $groups = $this->_groupService->getGroups(); $this->_customerGroups = $this->_getInitialCustomerGroups(); - foreach ($collection as $item) { - /** @var $item \Magento\Customer\Model\Group */ - $this->_customerGroups[$item->getId()] = $item->getCustomerGroupCode(); + foreach ($groups as $group) { + $this->_customerGroups[$group->getId()] = $group->getCode(); } } @@ -288,7 +283,7 @@ public function getWebsites() */ public function getDefaultCustomerGroup() { - return \Magento\Customer\Model\Group::CUST_GROUP_ALL; + return CustomerGroupServiceInterface::CUST_GROUP_ALL; } /** diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php index 9187dfbb80636..e5d093d295fef 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php @@ -18,22 +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_Adminhtml * @copyright Copyright (c) 2014 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\Block\Adminhtml\Product\Edit\Tab\Price; + +use Magento\Customer\Service\V1\CustomerGroupServiceInterface; /** * Adminhtml tier price item renderer - * - * @category Magento - * @package Magento_Catalog - * @author Magento Core Team */ -namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price; - -class Tier extends \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Group\AbstractGroup +class Tier extends Group\AbstractGroup { /** * @var string @@ -47,7 +42,7 @@ class Tier extends \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Group */ protected function _getInitialCustomerGroups() { - return array(\Magento\Customer\Model\Group::CUST_GROUP_ALL => __('ALL GROUPS')); + return array(CustomerGroupServiceInterface::CUST_GROUP_ALL => __('ALL GROUPS')); } /** diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php index 2e4b6b0559296..d8f0791bdc5c5 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php @@ -82,15 +82,15 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs protected $_translateInline; /** - * @param \Magento\Module\Manager $moduleManager * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Json\EncoderInterface $jsonEncoder * @param \Magento\Backend\Model\Auth\Session $authSession + * @param \Magento\Module\Manager $moduleManager * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $collectionFactory * @param \Magento\Catalog\Helper\Catalog $helperCatalog * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Registry $registry - * @param \Magento\Translate\InlineInterface $translateInline, + * @param \Magento\Translate\InlineInterface $translateInline * @param array $data */ public function __construct( @@ -264,22 +264,6 @@ protected function _prepareLayout() $this->getChildBlock('product-alerts')->setGroupCode(self::ADVANCED_TAB_GROUP_CODE); } - if ($this->getRequest()->getParam('id')) { - if ($this->_catalogData->isModuleEnabled('Magento_Review')) { - if ($this->_authorization->isAllowed('Magento_Review::reviews_all')) { - $this->addTab( - 'product-reviews', - array( - 'label' => __('Product Reviews'), - 'url' => $this->getUrl('catalog/*/reviews', array('_current' => true)), - 'class' => 'ajax', - 'group_code' => self::ADVANCED_TAB_GROUP_CODE - ) - ); - } - } - } - if (isset($advancedGroups['autosettings'])) { $this->addTab('autosettings', $advancedGroups['autosettings']); unset($advancedGroups['autosettings']); diff --git a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php index 5c21cc6812029..f264d24d8261a 100644 --- a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php +++ b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php @@ -35,7 +35,6 @@ namespace Magento\Catalog\Block\Product; use Magento\View\Element\BlockInterface; -use Magento\View\Element\Template\Helper; abstract class AbstractProduct extends \Magento\View\Element\Template { @@ -73,11 +72,6 @@ abstract class AbstractProduct extends \Magento\View\Element\Template */ protected $_useLinkForAsLowAs = true; - /** - * @var Helper - */ - protected $_reviewsHelperBlock; - /** * Default product amount per row * @@ -158,48 +152,32 @@ abstract class AbstractProduct extends \Magento\View\Element\Template protected $_imageHelper; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @var ReviewRendererInterface + */ + protected $reviewRenderer; + + /** + * @param Context $context * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, array $data = array(), array $priceBlockTypes = array() ) { - $this->_imageHelper = $imageHelper; - $this->_layoutHelper = $layoutHelper; - $this->_compareProduct = $compareProduct; - $this->_wishlistHelper = $wishlistHelper; - $this->_cartHelper = $cartHelper; - $this->_catalogConfig = $catalogConfig; - $this->_coreRegistry = $registry; - $this->_taxData = $taxData; - $this->_catalogData = $catalogData; - $this->_mathRandom = $mathRandom; + $this->_imageHelper = $context->getImageHelper(); + $this->_layoutHelper = $context->getLayoutHelper(); + $this->_compareProduct = $context->getCompareProduct(); + $this->_wishlistHelper = $context->getWishlistHelper(); + $this->_cartHelper = $context->getCartHelper(); + $this->_catalogConfig = $context->getCatalogConfig(); + $this->_coreRegistry = $context->getRegistry(); + $this->_taxData = $context->getTaxData(); + $this->_catalogData = $context->getCatalogHelper(); + $this->_mathRandom = $context->getMathRandom(); $this->_priceBlockTypes = $priceBlockTypes; + $this->reviewRenderer = $context->getReviewRenderer(); parent::__construct($context, $data); } @@ -400,29 +378,7 @@ public function getReviewsSummaryHtml( $templateType = false, $displayIfNoReviews = false ) { - if ($this->_initReviewsHelperBlock()) { - return $this->_reviewsHelperBlock->getSummaryHtml($product, $templateType, $displayIfNoReviews); - } - - return ''; - } - - /** - * Create reviews summary helper block once - * - * @return boolean - */ - protected function _initReviewsHelperBlock() - { - if (!$this->_reviewsHelperBlock) { - if (!$this->_catalogData->isModuleEnabled('Magento_Review')) { - return false; - } else { - $this->_reviewsHelperBlock = $this->getLayout()->createBlock('Magento\Review\Block\Helper'); - } - } - - return true; + return $this->reviewRenderer->getReviewsSummaryHtml($product, $templateType, $displayIfNoReviews); } /** diff --git a/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php b/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php index 35d7d736e705a..2889268e01720 100644 --- a/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php +++ b/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php @@ -105,51 +105,24 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare */ protected $_coreData; - /** - * @var \Magento\Wishlist\Helper\Data - */ - protected $_wishlistHelper; - /** * @var \Magento\Customer\Service\V1\CustomerCurrentService */ protected $currentCustomer; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory - * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility + * @param Product\Visibility $catalogProductVisibility * @param \Magento\Log\Model\Visitor $logVisitor * @param \Magento\App\Http\Context $httpContext * @param \Magento\Customer\Service\V1\CustomerCurrentService $currentCustomer * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Core\Helper\Data $coreData, \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, @@ -159,7 +132,6 @@ public function __construct( array $data = array(), array $priceBlockTypes = array() ) { - $this->_wishlistHelper = $wishlistHelper; $this->_coreData = $coreData; $this->_itemCollectionFactory = $itemCollectionFactory; $this->_catalogProductVisibility = $catalogProductVisibility; @@ -168,16 +140,6 @@ public function __construct( $this->currentCustomer = $currentCustomer; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Catalog/Block/Product/Context.php b/app/code/Magento/Catalog/Block/Product/Context.php new file mode 100644 index 0000000000000..48a9aab045427 --- /dev/null +++ b/app/code/Magento/Catalog/Block/Product/Context.php @@ -0,0 +1,282 @@ +imageHelper = $imageHelper; + $this->layoutHelper = $layoutHelper; + $this->compareProduct = $compareProduct; + $this->wishlistHelper = $wishlistHelper; + $this->cartHelper = $cartHelper; + $this->catalogConfig = $catalogConfig; + $this->registry = $registry; + $this->taxData = $taxHelper; + $this->catalogHelper = $catalogHelper; + $this->mathRandom = $mathRandom; + $this->reviewRenderer = $reviewRenderer; + parent::__construct( + $request, + $layout, + $eventManager, + $urlBuilder, + $translator, + $cache, + $design, + $session, + $sidResolver, + $storeConfig, + $viewUrl, + $viewConfig, + $cacheState, + $logger, + $escaper, + $filterManager, + $localeDate, + $inlineTranslation, + $filesystem, + $viewFileSystem, + $enginePool, + $appState, + $storeManager + ); + } + + /** + * @return \Magento\Checkout\Helper\Cart + */ + public function getCartHelper() + { + return $this->cartHelper; + } + + /** + * @return \Magento\Catalog\Model\Config + */ + public function getCatalogConfig() + { + return $this->catalogConfig; + } + + /** + * @return \Magento\Catalog\Helper\Data + */ + public function getCatalogHelper() + { + return $this->catalogHelper; + } + + /** + * @return \Magento\Catalog\Helper\Product\Compare + */ + public function getCompareProduct() + { + return $this->compareProduct; + } + + /** + * @return \Magento\Catalog\Helper\Image + */ + public function getImageHelper() + { + return $this->imageHelper; + } + + /** + * @return \Magento\Theme\Helper\Layout + */ + public function getLayoutHelper() + { + return $this->layoutHelper; + } + + /** + * @return \Magento\Math\Random + */ + public function getMathRandom() + { + return $this->mathRandom; + } + + /** + * @return \Magento\Registry + */ + public function getRegistry() + { + return $this->registry; + } + + /** + * @return \Magento\Tax\Helper\Data + */ + public function getTaxData() + { + return $this->taxData; + } + + /** + * @return \Magento\Wishlist\Helper\Data + */ + public function getWishlistHelper() + { + return $this->wishlistHelper; + } + + /** + * @return \Magento\Catalog\Block\Product\ReviewRendererInterface + */ + public function getReviewRenderer() + { + return $this->reviewRenderer; + } +} diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php index e37687c57d622..4788cf3208c5b 100644 --- a/app/code/Magento/Catalog/Block/Product/ListProduct.php +++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php @@ -69,36 +69,14 @@ class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct impleme protected $_categoryFactory; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param Context $context * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\Layer $catalogLayer * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Layer $catalogLayer, array $data = array(), @@ -108,16 +86,6 @@ public function __construct( $this->_catalogLayer = $catalogLayer; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Catalog/Block/Product/NewProduct.php b/app/code/Magento/Catalog/Block/Product/NewProduct.php index c7d7b20b35282..af43ca2166faa 100644 --- a/app/code/Magento/Catalog/Block/Product/NewProduct.php +++ b/app/code/Magento/Catalog/Block/Product/NewProduct.php @@ -65,37 +65,15 @@ class NewProduct extends \Magento\Catalog\Block\Product\AbstractProduct implemen protected $_productCollectionFactory; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param Context $context * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility * @param \Magento\App\Http\Context $httpContext * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, \Magento\App\Http\Context $httpContext, @@ -107,16 +85,6 @@ public function __construct( $this->httpContext = $httpContext; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php b/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php index 4ace7da1f430b..7a1691fae5e9f 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php @@ -45,38 +45,16 @@ class Promotion extends \Magento\Catalog\Block\Product\ListProduct protected $_layerFactory; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\Layer\Category $catalogLayer * @param \Magento\Catalog\Model\LayerFactory $layerFactory * @param CollectionFactory $productCollectionFactory * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Layer\Category $catalogLayer, \Magento\Catalog\Model\LayerFactory $layerFactory, @@ -88,16 +66,6 @@ public function __construct( $this->_productCollectionFactory = $productCollectionFactory; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $categoryFactory, $catalogLayer, $data, diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Random.php b/app/code/Magento/Catalog/Block/Product/ProductList/Random.php index da2706510d106..bd6263e11faba 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Random.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Random.php @@ -47,38 +47,16 @@ class Random extends \Magento\Catalog\Block\Product\ListProduct protected $_layerFactory; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\Layer\Category $catalogLayer * @param \Magento\Catalog\Model\LayerFactory $layerFactory * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Layer\Category $catalogLayer, \Magento\Catalog\Model\LayerFactory $layerFactory, @@ -90,16 +68,6 @@ public function __construct( $this->_productCollectionFactory = $productCollectionFactory; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $categoryFactory, $catalogLayer, $data, diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Related.php b/app/code/Magento/Catalog/Block/Product/ProductList/Related.php index fdefb815815ab..76554dbd6e16b 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Related.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Related.php @@ -69,37 +69,15 @@ class Related extends \Magento\Catalog\Block\Product\AbstractProduct implements protected $_checkoutCart; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Checkout\Model\Resource\Cart $checkoutCart * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility * @param \Magento\Checkout\Model\Session $checkoutSession * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Checkout\Model\Resource\Cart $checkoutCart, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, \Magento\Checkout\Model\Session $checkoutSession, @@ -111,16 +89,6 @@ public function __construct( $this->_checkoutSession = $checkoutSession; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php index 29215103a88c8..c0f8ba2117f64 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php @@ -40,7 +40,7 @@ class Toolbar extends \Magento\View\Element\Template /** * Products collection * - * @var \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @var \Magento\Model\Resource\Db\Collection\AbstractCollection */ protected $_collection = null; @@ -231,7 +231,7 @@ public function setCollection($collection) /** * Return products collection instance * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function getCollection() { diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php b/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php index 44fe821c32e76..03551722b766b 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php @@ -84,37 +84,15 @@ class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct implements \ protected $_checkoutCart; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Checkout\Model\Resource\Cart $checkoutCart * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility * @param \Magento\Checkout\Model\Session $checkoutSession * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Checkout\Model\Resource\Cart $checkoutCart, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, \Magento\Checkout\Model\Session $checkoutSession, @@ -126,16 +104,6 @@ public function __construct( $this->_checkoutSession = $checkoutSession; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/lib/Magento/Outbound/MessageInterface.php b/app/code/Magento/Catalog/Block/Product/ReviewRenderer/DefaultProvider.php similarity index 61% rename from lib/Magento/Outbound/MessageInterface.php rename to app/code/Magento/Catalog/Block/Product/ReviewRenderer/DefaultProvider.php index 0e31fdf138569..e115ec10aa4b6 100644 --- a/lib/Magento/Outbound/MessageInterface.php +++ b/app/code/Magento/Catalog/Block/Product/ReviewRenderer/DefaultProvider.php @@ -1,6 +1,6 @@ _customerSession = $customerSession; + $this->_customerView = $customerView; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); @@ -103,7 +73,7 @@ public function __construct( */ public function getUserName() { - return $this->_customerSession->getCustomer()->getName(); + return $this->_customerView->getCustomerName($this->_customerSession->getCustomerDataObject()); } /** @@ -111,7 +81,7 @@ public function getUserName() */ public function getEmail() { - return (string)$this->_customerSession->getCustomer()->getEmail(); + return (string)$this->_customerSession->getCustomerDataObject()->getEmail(); } /** diff --git a/app/code/Magento/Catalog/Block/Product/View.php b/app/code/Magento/Catalog/Block/Product/View.php index de7367847e8f2..32c3b020d4ffb 100644 --- a/app/code/Magento/Catalog/Block/Product/View.php +++ b/app/code/Magento/Catalog/Block/Product/View.php @@ -84,17 +84,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct implements \Ma protected $_localeFormat; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param Context $context * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Json\EncoderInterface $jsonEncoder * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -105,21 +95,9 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct implements \Ma * @param \Magento\Locale\FormatInterface $localeFormat * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Core\Helper\Data $coreData, \Magento\Json\EncoderInterface $jsonEncoder, \Magento\Catalog\Model\ProductFactory $productFactory, @@ -141,16 +119,6 @@ public function __construct( $this->_localeFormat = $localeFormat; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Catalog/Block/Product/View/AbstractView.php b/app/code/Magento/Catalog/Block/Product/View/AbstractView.php index b3995daf0ce62..255fb744a3bad 100644 --- a/app/code/Magento/Catalog/Block/Product/View/AbstractView.php +++ b/app/code/Magento/Catalog/Block/Product/View/AbstractView.php @@ -41,35 +41,13 @@ abstract class AbstractView extends \Magento\Catalog\Block\Product\AbstractProdu protected $arrayUtils; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Stdlib\ArrayUtils $arrayUtils * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Stdlib\ArrayUtils $arrayUtils, array $data = array(), array $priceBlockTypes = array() @@ -77,16 +55,6 @@ public function __construct( $this->arrayUtils = $arrayUtils; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Catalog/Block/Product/Widget/Html/Pager.php b/app/code/Magento/Catalog/Block/Product/Widget/Html/Pager.php index 05ca3bfade618..b906be5da902f 100644 --- a/app/code/Magento/Catalog/Block/Product/Widget/Html/Pager.php +++ b/app/code/Magento/Catalog/Block/Product/Widget/Html/Pager.php @@ -120,7 +120,7 @@ public function getLimit() /** * Connect collection to paging * - * @param \Magento\Core\Model\Resource\Db\Collection\AbstractCollection $collection + * @param \Magento\Model\Resource\Db\Collection\AbstractCollection $collection * @return \Magento\Catalog\Block\Product\Widget\Html\Pager */ public function setCollection($collection) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php index 596e48694c6e0..ca30e9cfa4ff7 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php @@ -377,16 +377,16 @@ public function saveAction() foreach ($validate as $code => $error) { if ($error === true) { $attribute = $category->getResource()->getAttribute($code)->getFrontend()->getLabel(); - throw new \Magento\Core\Exception(__('Attribute "%1" is required.', $attribute)); + throw new \Magento\Model\Exception(__('Attribute "%1" is required.', $attribute)); } else { - throw new \Magento\Core\Exception($error); + throw new \Magento\Model\Exception($error); } } } $category->unsetData('use_post_data_config'); if (isset($data['general']['entity_id'])) { - throw new \Magento\Core\Exception(__('Unable to save the category')); + throw new \Magento\Model\Exception(__('Unable to save the category')); } $category->save(); @@ -468,7 +468,7 @@ public function moveAction() try { $category->move($parentNodeId, $prevNodeId); $this->getResponse()->setBody('SUCCESS'); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->getResponse()->setBody($e->getMessage()); } catch (\Exception $e) { $this->getResponse()->setBody(__('There was a category move error %1', $e)); @@ -493,7 +493,7 @@ public function deleteAction() $category->delete(); $this->messageManager->addSuccess(__('You deleted the category.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->getResponse()->setRedirect($this->getUrl('catalog/*/edit', array('_current' => true))); return; diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product.php index 6b378f5f52abf..438fd69ae97f5 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product.php @@ -477,24 +477,7 @@ public function crosssellGridAction() $this->_view->renderLayout(); } - /** - * Get product reviews grid - * - * @return void - */ - public function reviewsAction() - { - $product = $this->productBuilder->build($this->getRequest()); - $this->_view->loadLayout(); - $this->_view->getLayout()->getBlock( - 'admin.product.reviews' - )->setProductId( - $product->getId() - )->setUseAjax( - true - ); - $this->_view->renderLayout(); - } + /** * Validate product @@ -556,7 +539,7 @@ public function validateAction() $response->setError(true); $response->setAttribute($e->getAttributeCode()); $response->setMessage($e->getMessage()); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $response->setError(true); $response->setMessage($e->getMessage()); } catch (\Exception $e) { @@ -588,7 +571,7 @@ public function saveAction() try { if (isset($data['product'][$product->getIdFieldName()])) { - throw new \Magento\Core\Exception(__('Unable to save product')); + throw new \Magento\Model\Exception(__('Unable to save product')); } $originalSku = $product->getSku(); @@ -634,7 +617,7 @@ public function saveAction() $newProduct = $this->productCopier->copy($product); $this->messageManager->addSuccess(__('You duplicated the product.')); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_session->setProductData($data); $redirectBack = true; @@ -755,7 +738,7 @@ public function massStatusAction() $this->_productPriceIndexerProcessor->reindexList($productIds); } catch (\Magento\Core\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->_getSession()->addException($e, __('Something went wrong while updating the product(s) status.')); @@ -770,13 +753,13 @@ public function massStatusAction() * @param array $productIds * @param int $status * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function _validateMassStatus(array $productIds, $status) { if ($status == \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) { if (!$this->_objectManager->create('Magento\Catalog\Model\Product')->isProductsHasSku($productIds)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Please make sure to define SKU values for all processed products.') ); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php index 146561748d8ab..60f61e5bb5af0 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php @@ -232,7 +232,7 @@ public function saveAction() ) { $this->_productPriceIndexerProcessor->reindexList($this->_helper->getProductIds()); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException( @@ -308,7 +308,7 @@ public function validateAction() $response->setError(true); $response->setAttribute($e->getAttributeCode()); $response->setMessage($e->getMessage()); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $response->setError(true); $response->setMessage($e->getMessage()); } catch (\Exception $e) { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php index 6d40308cccd26..8b02b69107e72 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php @@ -292,7 +292,7 @@ public function saveAction() $attributeSet->save(); $attributeSet->initFromSkeleton($this->getRequest()->getParam('set'))->save(); $isNewAttributeSet = true; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong saving the attribute.')); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php index 3c2cfc4f7823a..53e8c0cd8a655 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php @@ -147,7 +147,7 @@ public function saveAction() $model->load($attributeSetId); } if (!$model->getId()) { - throw new \Magento\Core\Exception(__('This attribute set no longer exists.')); + throw new \Magento\Model\Exception(__('This attribute set no longer exists.')); } $data = $this->_objectManager->get( 'Magento\Core\Helper\Data' @@ -168,7 +168,7 @@ public function saveAction() } $model->save(); $this->messageManager->addSuccess(__('You saved the attribute set.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $hasError = true; } catch (\Exception $e) { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Search.php b/app/code/Magento/Catalog/Controller/Adminhtml/Search.php index 4b7c85657e279..56e1e3eddcd2f 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Search.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Search.php @@ -143,7 +143,7 @@ public function saveAction() $model->setStoreId($storeId); $model->loadByQueryText($queryText); if ($model->getId() && $model->getId() != $queryId) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('You already have an identical search term query.') ); } elseif (!$model->getId() && $queryId) { @@ -156,7 +156,7 @@ public function saveAction() $model->addData($data); $model->setIsProcessed(0); $model->save(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $hasError = true; } catch (\Exception $e) { diff --git a/app/code/Magento/Catalog/Controller/Category.php b/app/code/Magento/Catalog/Controller/Category.php index cbaf5da3a74f3..0a2b3b6aac773 100644 --- a/app/code/Magento/Catalog/Controller/Category.php +++ b/app/code/Magento/Catalog/Controller/Category.php @@ -120,7 +120,7 @@ protected function _initCategory() 'catalog_controller_category_init_after', array('category' => $category, 'controller_action' => $this) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); return false; } diff --git a/app/code/Magento/Catalog/Controller/Product/Compare.php b/app/code/Magento/Catalog/Controller/Product/Compare.php index 47d53b2ec511b..f05238fcac2ce 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare.php @@ -90,13 +90,6 @@ class Compare extends \Magento\App\Action\Action */ protected $_compareItemFactory; - /** - * Customer factory - * - * @var \Magento\Customer\Model\CustomerFactory - */ - protected $_customerFactory; - /** * @var \Magento\Core\Model\StoreManagerInterface */ @@ -109,7 +102,6 @@ class Compare extends \Magento\App\Action\Action /** * @param \Magento\App\Action\Context $context - * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Catalog\Model\Product\Compare\ItemFactory $compareItemFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory @@ -122,7 +114,6 @@ class Compare extends \Magento\App\Action\Action */ public function __construct( \Magento\App\Action\Context $context, - \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Catalog\Model\Product\Compare\ItemFactory $compareItemFactory, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, @@ -134,7 +125,6 @@ public function __construct( FormKeyValidator $formKeyValidator ) { $this->_storeManager = $storeManager; - $this->_customerFactory = $customerFactory; $this->_compareItemFactory = $compareItemFactory; $this->_productFactory = $productFactory; $this->_itemCollectionFactory = $itemCollectionFactory; @@ -222,9 +212,9 @@ public function removeAction() /** @var $item \Magento\Catalog\Model\Product\Compare\Item */ $item = $this->_compareItemFactory->create(); if ($this->_customerSession->isLoggedIn()) { - $item->addCustomerData($this->_customerSession->getCustomer()); + $item->setCustomerId($this->_customerSession->getCustomerId()); } elseif ($this->_customerId) { - $item->addCustomerData($this->_customerFactory->create()->load($this->_customerId)); + $item->setCustomerId($this->_customerId); } else { $item->addVisitorId($this->_logVisitor->getId()); } @@ -274,7 +264,7 @@ public function clearAction() $items->clear(); $this->messageManager->addSuccess(__('You cleared the comparison list.')); $this->_objectManager->get('Magento\Catalog\Helper\Product\Compare')->calculate(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong clearing the comparison list.')); diff --git a/app/code/Magento/Catalog/Helper/Product.php b/app/code/Magento/Catalog/Helper/Product.php index e019261b36949..af5b79588de2e 100644 --- a/app/code/Magento/Catalog/Helper/Product.php +++ b/app/code/Magento/Catalog/Helper/Product.php @@ -494,7 +494,7 @@ public function initProduct($productId, $controller, $params = null) 'catalog_controller_product_init_after', array('product' => $product, 'controller_action' => $controller) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_logger->logException($e); return false; } diff --git a/app/code/Magento/Catalog/Helper/Product/Composite.php b/app/code/Magento/Catalog/Helper/Product/Composite.php old mode 100644 new mode 100755 index 42ba79f3401d0..72558aa362fa4 --- a/app/code/Magento/Catalog/Helper/Product/Composite.php +++ b/app/code/Magento/Catalog/Helper/Product/Composite.php @@ -25,7 +25,14 @@ */ namespace Magento\Catalog\Helper\Product; +use Magento\App\Helper\Context; +use Magento\App\ViewInterface; +use Magento\Catalog\Helper\Product; +use Magento\Catalog\Model\ProductFactory; +use Magento\Core\Model\StoreManagerInterface; use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Model\Converter; +use Magento\Registry; /** * Adminhtml catalog product composite helper @@ -39,61 +46,61 @@ class Composite extends \Magento\App\Helper\AbstractHelper /** * Core registry * - * @var \Magento\Registry + * @var Registry */ protected $_coreRegistry = null; /** * Catalog product * - * @var \Magento\Catalog\Helper\Product + * @var Product */ protected $_catalogProduct = null; /** - * @var \Magento\Core\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** - * @var \Magento\Catalog\Model\ProductFactory + * @var ProductFactory */ protected $_productFactory; /** - * @var \Magento\Customer\Model\CustomerFactory + * @var ViewInterface */ - protected $_customerFactory; + protected $_view; /** - * @var \Magento\App\ViewInterface + * @var Converter */ - protected $_view; + protected $_converter; /** - * @param \Magento\App\Helper\Context $context - * @param \Magento\Customer\Model\CustomerFactory $customerFactory - * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Product $catalogProduct - * @param \Magento\Registry $coreRegistry - * @param \Magento\App\ViewInterface $view + * @param Context $context + * @param ProductFactory $productFactory + * @param StoreManagerInterface $storeManager + * @param Product $catalogProduct + * @param Registry $coreRegistry + * @param ViewInterface $view + * @param Converter $converter */ public function __construct( - \Magento\App\Helper\Context $context, - \Magento\Customer\Model\CustomerFactory $customerFactory, - \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Product $catalogProduct, - \Magento\Registry $coreRegistry, - \Magento\App\ViewInterface $view + Context $context, + ProductFactory $productFactory, + StoreManagerInterface $storeManager, + Product $catalogProduct, + Registry $coreRegistry, + ViewInterface $view, + Converter $converter ) { - $this->_customerFactory = $customerFactory; $this->_productFactory = $productFactory; $this->_storeManager = $storeManager; $this->_coreRegistry = $coreRegistry; $this->_catalogProduct = $catalogProduct; $this->_view = $view; + $this->_converter = $converter; parent::__construct($context); } @@ -157,8 +164,8 @@ protected function _initConfigureResultLayout($isOk, $productType) /** * Prepares and render result of composite product configuration request * - * $configureResult holds either: - * - 'ok' = true, and 'product_id', 'buy_request', 'current_store_id', 'current_customer' or 'current_customer_id' + * The $configureResult variable holds either: + * - 'ok' = true, and 'product_id', 'buy_request', 'current_store_id', 'current_customer_id' * - 'error' = true, and 'message' to show * * @param \Magento\Object $configureResult @@ -168,7 +175,7 @@ public function renderConfigureResult(\Magento\Object $configureResult) { try { if (!$configureResult->getOk()) { - throw new \Magento\Core\Exception($configureResult->getMessage()); + throw new \Magento\Model\Exception($configureResult->getMessage()); } $currentStoreId = (int)$configureResult->getCurrentStoreId(); @@ -182,22 +189,17 @@ public function renderConfigureResult(\Magento\Object $configureResult) $configureResult->getProductId() ); if (!$product->getId()) { - throw new \Magento\Core\Exception(__('The product is not loaded.')); + throw new \Magento\Model\Exception(__('The product is not loaded.')); } $this->_coreRegistry->register('current_product', $product); $this->_coreRegistry->register('product', $product); // Register customer we're working with - $currentCustomer = $configureResult->getCurrentCustomer(); - if (!$currentCustomer) { - $currentCustomerId = (int)$configureResult->getCurrentCustomerId(); - if ($currentCustomerId) { - $currentCustomer = $this->_customerFactory->create()->load($currentCustomerId); - } - } - if ($currentCustomer) { - $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER, $currentCustomer); - } + $customerId = (int)$configureResult->getCurrentCustomerId(); + // TODO: Remove the customer model from the registry once all readers are refactored + $customerModel = $this->_converter->loadCustomerModel($customerId); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER, $customerModel); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId); // Prepare buy request values $buyRequest = $configureResult->getBuyRequest(); diff --git a/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php b/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php index bf515a58c3c7a..a159314fb13c0 100644 --- a/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php +++ b/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php @@ -485,7 +485,7 @@ public function getFlatTableName($storeId) * Retrieve loaded attribute by code * * @param string $attributeCode - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\Eav\Model\Entity\Attribute */ public function getAttribute($attributeCode) @@ -495,7 +495,7 @@ public function getAttribute($attributeCode) $attribute = $this->_attributeFactory->create(); $attribute->loadByCode($this->getEntityTypeId(), $attributeCode); if (!$attribute->getId()) { - throw new \Magento\Core\Exception(__('Invalid attribute %1', $attributeCode)); + throw new \Magento\Model\Exception(__('Invalid attribute %1', $attributeCode)); } $entity = $this->_eavConfig->getEntityType($this->getEntityType())->getEntity(); $attribute->setEntity($entity); diff --git a/app/code/Magento/Catalog/Helper/Product/Price.php b/app/code/Magento/Catalog/Helper/Product/Price.php index bddc90fcde2b6..b47880ae5cc7e 100644 --- a/app/code/Magento/Catalog/Helper/Product/Price.php +++ b/app/code/Magento/Catalog/Helper/Product/Price.php @@ -24,7 +24,7 @@ namespace Magento\Catalog\Helper\Product; use Magento\Catalog\Model\Product; -use Magento\Customer\Model\Customer; +use Magento\Customer\Service\V1\Data\Customer; /** * Collection of tax module calls @@ -99,13 +99,13 @@ public function priceIncludesTax() } /** - * Get customer object + * Get customer data object * - * @return bool|Customer + * @return Customer CustomerDataObject */ public function getCustomer() { - return $this->taxCalculation->getCustomer(); + return $this->taxCalculation->getCustomerData(); } /** @@ -116,7 +116,7 @@ public function getCustomer() */ public function setCustomer(Customer $customer) { - $this->taxCalculation->setCustomer($customer); + $this->taxCalculation->setCustomerData($customer); return $this; } diff --git a/app/code/Magento/Catalog/Helper/Product/View.php b/app/code/Magento/Catalog/Helper/Product/View.php index 3b0b916c7ff33..bf67df6afe088 100644 --- a/app/code/Magento/Catalog/Helper/Product/View.php +++ b/app/code/Magento/Catalog/Helper/Product/View.php @@ -220,7 +220,7 @@ public function initProductLayout($product, $controller, $params = null) * @param null|\Magento\Object $params * * @return \Magento\Catalog\Helper\Product\View - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function prepareAndRender($productId, $controller, $params = null) { @@ -233,7 +233,7 @@ public function prepareAndRender($productId, $controller, $params = null) // Standard algorithm to prepare and render product view page $product = $productHelper->initProduct($productId, $controller, $params); if (!$product) { - throw new \Magento\Core\Exception(__('Product is not loaded'), $this->ERR_NO_PRODUCT_LOADED); + throw new \Magento\Model\Exception(__('Product is not loaded'), $this->ERR_NO_PRODUCT_LOADED); } $buyRequest = $params->getBuyRequest(); @@ -259,7 +259,7 @@ public function prepareAndRender($productId, $controller, $params = null) if ($controller instanceof \Magento\Catalog\Controller\Product\View\ViewInterface) { $this->_view->getLayout()->initMessages($this->messageGroups); } else { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Bad controller interface for showing product'), $this->ERR_BAD_CONTROLLER_INTERFACE ); diff --git a/app/code/Magento/Catalog/Model/AbstractModel.php b/app/code/Magento/Catalog/Model/AbstractModel.php index 1e1859dcef4b8..86ed8240b3372 100644 --- a/app/code/Magento/Catalog/Model/AbstractModel.php +++ b/app/code/Magento/Catalog/Model/AbstractModel.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -abstract class AbstractModel extends \Magento\Core\Model\AbstractModel +abstract class AbstractModel extends \Magento\Model\AbstractModel { /** * Attribute default values @@ -83,7 +83,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -91,7 +91,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Attribute/LockValidatorComposite.php b/app/code/Magento/Catalog/Model/Attribute/LockValidatorComposite.php index 12bf7ad089847..9f86bc6c91146 100644 --- a/app/code/Magento/Catalog/Model/Attribute/LockValidatorComposite.php +++ b/app/code/Magento/Catalog/Model/Attribute/LockValidatorComposite.php @@ -50,13 +50,13 @@ public function __construct(\Magento\ObjectManager $objectManager, array $valida /** * Check attribute lock state * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param null $attributeSet - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * * @return void */ - public function validate(\Magento\Core\Model\AbstractModel $object, $attributeSet = null) + public function validate(\Magento\Model\AbstractModel $object, $attributeSet = null) { foreach ($this->validators as $validator) { $validator->validate($object, $attributeSet); diff --git a/app/code/Magento/Catalog/Model/Attribute/LockValidatorInterface.php b/app/code/Magento/Catalog/Model/Attribute/LockValidatorInterface.php index 8ad8ed9511eb9..9982894594a5e 100644 --- a/app/code/Magento/Catalog/Model/Attribute/LockValidatorInterface.php +++ b/app/code/Magento/Catalog/Model/Attribute/LockValidatorInterface.php @@ -30,11 +30,11 @@ interface LockValidatorInterface /** * Check attribute lock state * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param null $attributeSet - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * * @return void */ - public function validate(\Magento\Core\Model\AbstractModel $object, $attributeSet = null); + public function validate(\Magento\Model\AbstractModel $object, $attributeSet = null); } diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index f1eac57c2e3cd..098d00de30042 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -205,7 +205,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ * @param Indexer\Category\Flat\State $flatState * @param \Magento\Indexer\Model\IndexerInterface $flatIndexer * @param \Magento\Indexer\Model\IndexerInterface $productIndexer - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -226,7 +226,7 @@ public function __construct( Indexer\Category\Flat\State $flatState, \Magento\Indexer\Model\IndexerInterface $flatIndexer, \Magento\Indexer\Model\IndexerInterface $productIndexer, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -337,7 +337,7 @@ public function getTreeModelInstance() * @param int $parentId new parent category id * @param null|int $afterCategoryId category id after which we have put current category * @return $this - * @throws \Magento\Core\Exception|\Exception + * @throws \Magento\Model\Exception|\Exception */ public function move($parentId, $afterCategoryId) { @@ -348,7 +348,7 @@ public function move($parentId, $afterCategoryId) $parent = $this->_categoryFactory->create()->setStoreId($this->getStoreId())->load($parentId); if (!$parent->getId()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Sorry, but we can\'t move the category because we can\'t find the new parent category you selected.' ) @@ -356,11 +356,11 @@ public function move($parentId, $afterCategoryId) } if (!$this->getId()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Sorry, but we can\'t move the category because we can\'t find the new category you selected.') ); } elseif ($parent->getId() == $this->getId()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'We can\'t perform this category move operation because the parent category matches the child category.' ) @@ -862,14 +862,13 @@ public function getName() /** * Before delete process * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ protected function _beforeDelete() { - $this->_protectFromNonAdmin(); if ($this->getResource()->isForbiddenToDelete($this->getId())) { - throw new \Magento\Core\Exception("Can't delete root category."); + throw new \Magento\Model\Exception("Can't delete root category."); } return parent::_beforeDelete(); } @@ -891,12 +890,12 @@ public function getAnchorsAbove() if ($this->_useFlatResource) { $anchors = $this->_getResource()->getAnchorsAbove($path, $this->getStoreId()); } else { - if (!$this->_coreRegistry->registry('_category_is_anchor_attribute')) { + if (!$this->_registry->registry('_category_is_anchor_attribute')) { $model = $this->_getAttribute('is_anchor'); - $this->_coreRegistry->register('_category_is_anchor_attribute', $model); + $this->_registry->register('_category_is_anchor_attribute', $model); } - $isAnchorAttribute = $this->_coreRegistry->registry('_category_is_anchor_attribute'); + $isAnchorAttribute = $this->_registry->registry('_category_is_anchor_attribute'); if ($isAnchorAttribute) { $anchors = $this->getResource()->findWhereAttributeIs($path, $isAnchorAttribute, 1); } @@ -1079,7 +1078,7 @@ public function reindex() /** * Init indexing process after category delete * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _afterDeleteCommit() { diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php index 02b111fe5de10..741fd0705f6c1 100644 --- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php +++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php @@ -58,7 +58,7 @@ public function __construct(\Magento\Logger $logger, \Magento\Core\Model\Store\C * * @param \Magento\Object $object * @return bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validate($object) { @@ -86,7 +86,7 @@ public function validate($object) if ($this->getAttribute()->getIsUnique()) { if (!$this->getAttribute()->getEntity()->checkAttributeUniqueValue($this->getAttribute(), $object)) { $label = $this->getAttribute()->getFrontend()->getLabel(); - throw new \Magento\Core\Exception(__('The value of attribute "%1" must be unique.', $label)); + throw new \Magento\Model\Exception(__('The value of attribute "%1" must be unique.', $label)); } } @@ -104,13 +104,13 @@ public function validate($object) "catalog/frontend/default_sort_by" ); if (!in_array($data, $available)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Default Product Listing Sort by does not exist in Available Product Listing Sort By.') ); } } else { if (!in_array('available_sort_by', $postDataConfig)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Default Product Listing Sort by does not exist in Available Product Listing Sort By.') ); } diff --git a/app/code/Magento/Catalog/Model/Config.php b/app/code/Magento/Catalog/Model/Config.php index 9616618b4fbad..98aabb68c517e 100644 --- a/app/code/Magento/Catalog/Model/Config.php +++ b/app/code/Magento/Catalog/Model/Config.php @@ -133,7 +133,7 @@ class Config extends \Magento\Eav\Model\Config /** * Constructor * - * @param \Magento\Core\Model\App $app + * @param \Magento\App\CacheInterface $cache * @param \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory * @param \Magento\App\Cache\StateInterface $cacheState * @param \Magento\Validator\UniversalFactory $universalFactory @@ -148,7 +148,7 @@ class Config extends \Magento\Eav\Model\Config * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\Core\Model\App $app, + \Magento\App\CacheInterface $cache, \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory, \Magento\App\Cache\StateInterface $cacheState, \Magento\Validator\UniversalFactory $universalFactory, @@ -168,7 +168,7 @@ public function __construct( $this->_storeManager = $storeManager; $this->_eavConfig = $eavConfig; - parent::__construct($app, $entityTypeFactory, $cacheState, $universalFactory); + parent::__construct($cache, $entityTypeFactory, $cacheState, $universalFactory); } /** diff --git a/app/code/Magento/Catalog/Model/Config/Backend/Category.php b/app/code/Magento/Catalog/Model/Config/Backend/Category.php index aa28ab77c4cdc..05b69eb346999 100644 --- a/app/code/Magento/Catalog/Model/Config/Backend/Category.php +++ b/app/code/Magento/Catalog/Model/Config/Backend/Category.php @@ -49,7 +49,7 @@ class Category extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Category $catalogCategory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -59,7 +59,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Category $catalogCategory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 da7b4f442f2cd..9e15babe76e8d 100644 --- a/app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php +++ b/app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php @@ -53,7 +53,7 @@ class Image extends \Magento\Core\Model\Config\Value * @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 + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -64,7 +64,7 @@ public function __construct( \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, \Magento\Eav\Model\Config $eavConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Design.php b/app/code/Magento/Catalog/Model/Design.php index db6c7949d16b7..2300884ce92dc 100644 --- a/app/code/Magento/Catalog/Model/Design.php +++ b/app/code/Magento/Catalog/Model/Design.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Design extends \Magento\Core\Model\AbstractModel +class Design extends \Magento\Model\AbstractModel { const APPLY_FOR_PRODUCT = 1; @@ -55,7 +55,7 @@ class Design extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\View\DesignInterface $design - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -64,7 +64,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\View\DesignInterface $design, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Entity/Attribute.php b/app/code/Magento/Catalog/Model/Entity/Attribute.php index 1e9d1554dc835..8f02f52739636 100644 --- a/app/code/Magento/Catalog/Model/Entity/Attribute.php +++ b/app/code/Magento/Catalog/Model/Entity/Attribute.php @@ -103,7 +103,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute * @param \Magento\Catalog\Model\ProductFactory $catalogProductFactory * @param \Magento\Locale\ResolverInterface $localeResolver * @param LockValidatorInterface $lockValidator - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -120,7 +120,7 @@ public function __construct( \Magento\Catalog\Model\ProductFactory $catalogProductFactory, \Magento\Locale\ResolverInterface $localeResolver, LockValidatorInterface $lockValidator, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -146,14 +146,14 @@ public function __construct( /** * Processing object before save data * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel * @throws \Magento\Eav\Exception */ protected function _beforeSave() { try { $this->attrLockValidator->validate($this); - } catch (\Magento\Core\Exception $exception) { + } catch (\Magento\Model\Exception $exception) { throw new \Magento\Eav\Exception($exception->getMessage()); } @@ -164,7 +164,7 @@ protected function _beforeSave() /** * Processing object after save data * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _afterSave() { diff --git a/app/code/Magento/Catalog/Model/Factory.php b/app/code/Magento/Catalog/Model/Factory.php index 38c2b5947226e..8e5b3c349b973 100644 --- a/app/code/Magento/Catalog/Model/Factory.php +++ b/app/code/Magento/Catalog/Model/Factory.php @@ -51,15 +51,15 @@ public function __construct(\Magento\ObjectManager $objectManager) * * @param string $className * @param array $data - * @return \Magento\Core\Model\AbstractModel - * @throws \Magento\Core\Exception + * @return \Magento\Model\AbstractModel + * @throws \Magento\Model\Exception */ public function create($className, array $data = array()) { $model = $this->_objectManager->create($className, $data); - if (!$model instanceof \Magento\Core\Model\AbstractModel) { - throw new \Magento\Core\Exception($className . ' doesn\'t extends \Magento\Core\Model\AbstractModel'); + if (!$model instanceof \Magento\Model\AbstractModel) { + throw new \Magento\Model\Exception($className . ' doesn\'t extends \Magento\Model\AbstractModel'); } return $model; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php index d181b17427e43..5617130859112 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php @@ -63,26 +63,26 @@ protected function getIndexer() /** * Validate changes for invalidating indexer * - * @param \Magento\Core\Model\AbstractModel $group + * @param \Magento\Model\AbstractModel $group * @return bool */ - protected function validate(\Magento\Core\Model\AbstractModel $group) + protected function validate(\Magento\Model\AbstractModel $group) { return $group->dataHasChangedFor('root_category_id') && !$group->isObjectNew(); } /** - * @param \Magento\Core\Model\Resource\Db\AbstractDb $subject + * @param \Magento\Model\Resource\Db\AbstractDb $subject * @param callable $proceed - * @param \Magento\Core\Model\AbstractModel $group + * @param \Magento\Model\AbstractModel $group * - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @return \Magento\Model\Resource\Db\AbstractDb * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundSave( - \Magento\Core\Model\Resource\Db\AbstractDb $subject, + \Magento\Model\Resource\Db\AbstractDb $subject, \Closure $proceed, - \Magento\Core\Model\AbstractModel $group + \Magento\Model\AbstractModel $group ) { $needInvalidating = $this->validate($group); $objectResource = $proceed($group); diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreView.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreView.php index 991cb873b4f5a..0e204c22fa3a3 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreView.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreView.php @@ -28,10 +28,10 @@ class StoreView extends StoreGroup /** * Validate changes for invalidating indexer * - * @param \Magento\Core\Model\AbstractModel $store + * @param \Magento\Model\AbstractModel $store * @return bool */ - protected function validate(\Magento\Core\Model\AbstractModel $store) + protected function validate(\Magento\Model\AbstractModel $store) { return $store->isObjectNew() || $store->dataHasChangedFor('group_id'); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php index f8276ace12107..ff94adbd78d8a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php @@ -45,7 +45,7 @@ class Mode extends \Magento\Core\Model\Config\Value * @param \Magento\App\ConfigInterface $config * @param \Magento\Indexer\Model\IndexerInterface $flatIndexer * @param \Magento\Indexer\Model\Indexer\State $indexerState - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -56,7 +56,7 @@ public function __construct( \Magento\App\ConfigInterface $config, \Magento\Indexer\Model\IndexerInterface $flatIndexer, \Magento\Indexer\Model\Indexer\State $indexerState, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php index a5011fafa7ca7..d87e26c2ec115 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php @@ -52,15 +52,15 @@ protected function getIndexer() } /** - * @param \Magento\Core\Model\Resource\Db\AbstractDb $subject + * @param \Magento\Model\Resource\Db\AbstractDb $subject * @param callable $proceed - * @param \Magento\Core\Model\AbstractModel $group + * @param \Magento\Model\AbstractModel $group * @return mixed */ public function aroundSave( - \Magento\Core\Model\Resource\Db\AbstractDb $subject, + \Magento\Model\Resource\Db\AbstractDb $subject, \Closure $proceed, - \Magento\Core\Model\AbstractModel $group + \Magento\Model\AbstractModel $group ) { $needInvalidating = $this->validate($group); $objectResource = $proceed($group); @@ -74,10 +74,10 @@ public function aroundSave( /** * Validate changes for invalidating indexer * - * @param \Magento\Core\Model\AbstractModel $group + * @param \Magento\Model\AbstractModel $group * @return bool */ - protected function validate(\Magento\Core\Model\AbstractModel $group) + protected function validate(\Magento\Model\AbstractModel $group) { return ($group->dataHasChangedFor( 'website_id' diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreView.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreView.php index 2e681093fc6a4..e92ef304ea70c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreView.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreView.php @@ -28,10 +28,10 @@ class StoreView extends StoreGroup /** * Validate changes for invalidating indexer * - * @param \Magento\Core\Model\AbstractModel $store + * @param \Magento\Model\AbstractModel $store * @return bool */ - protected function validate(\Magento\Core\Model\AbstractModel $store) + protected function validate(\Magento\Model\AbstractModel $store) { return $store->isObjectNew() || $store->dataHasChangedFor('group_id'); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php index 2ebe0aa2acd56..41fbaf755d9b1 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php @@ -48,7 +48,7 @@ public function execute($ids = null) $this->_reindex($store->getId()); } } catch (\Exception $e) { - throw new \Magento\Core\Exception($e->getMessage(), $e->getCode(), $e); + throw new \Magento\Model\Exception($e->getMessage(), $e->getCode(), $e); } return $this; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php index 48cd61eba63c5..8fa36ac3dbf04 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php @@ -36,12 +36,12 @@ class Row extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction * * @param int|null $id * @return \Magento\Catalog\Model\Indexer\Product\Flat\Action\Row - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function execute($id = null) { if (!isset($id) || empty($id)) { - throw new \Magento\Core\Exception(__('Could not rebuild index for undefined product')); + throw new \Magento\Model\Exception(__('Could not rebuild index for undefined product')); } $ids = array($id); foreach ($this->_storeManager->getStores() as $store) { diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php index e93dfcb5620e9..04b903bb40413 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php @@ -38,12 +38,12 @@ class Rows extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction * @param array $ids * * @return \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function execute($ids) { if (empty($ids)) { - throw new \Magento\Core\Exception(__('Bad value was supplied.')); + throw new \Magento\Model\Exception(__('Bad value was supplied.')); } foreach ($this->_storeManager->getStores() as $store) { $idsBatches = array_chunk($ids, \Magento\Catalog\Helper\Product\Flat\Indexer::BATCH_SIZE); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php index a85036ee81acd..6e13023565146 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php @@ -114,7 +114,7 @@ public function build($storeId, $changedIds, $valueFieldSuffix, $tableDropSuffix * * @param int|string $storeId * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _createTemporaryFlatTable($storeId) { @@ -126,7 +126,7 @@ protected function _createTemporaryFlatTable($storeId) \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction::XML_NODE_MAX_INDEX_COUNT ); if ($maxIndex && count($indexesNeed) > $maxIndex) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( "The Flat Catalog module has a limit of %2\$d filterable and/or sortable attributes." . "Currently there are %1\$d of them." . diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Store.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Store.php index cd238faf195c8..44f440b88e8b3 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Store.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Store.php @@ -46,12 +46,12 @@ public function __construct(\Magento\Catalog\Model\Indexer\Product\Flat\Processo * Before save handler * * @param \Magento\Core\Model\Resource\Store $subject - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeSave(\Magento\Core\Model\Resource\Store $subject, \Magento\Core\Model\AbstractModel $object) + public function beforeSave(\Magento\Core\Model\Resource\Store $subject, \Magento\Model\AbstractModel $object) { if (!$object->getId() || $object->dataHasChangedFor('group_id')) { $this->_productFlatIndexerProcessor->markIndexerAsInvalid(); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroup.php index 35dd2d4f2d30c..af276b43d15b1 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroup.php @@ -46,14 +46,14 @@ public function __construct(\Magento\Catalog\Model\Indexer\Product\Flat\Processo * Before save handler * * @param \Magento\Core\Model\Resource\Store\Group $subject - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeSave( \Magento\Core\Model\Resource\Store\Group $subject, - \Magento\Core\Model\AbstractModel $object + \Magento\Model\AbstractModel $object ) { if (!$object->getId() || $object->dataHasChangedFor('root_category_id')) { $this->_productFlatIndexerProcessor->markIndexerAsInvalid(); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php index a7d2967e3ac50..6cf3b61470880 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php @@ -33,7 +33,7 @@ class Processor const INDEXER_ID = 'catalog_product_flat'; /** - * @var \Magento\Indexer\Model\Indexer + * @var \Magento\Indexer\Model\IndexerInterface */ protected $_indexer; @@ -43,14 +43,14 @@ class Processor protected $_state; /** - * @param \Magento\Indexer\Model\Indexer $indexer + * @param \Magento\Indexer\Model\IndexerFactory $indexerFactory * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $state */ public function __construct( - \Magento\Indexer\Model\Indexer $indexer, + \Magento\Indexer\Model\IndexerFactory $indexerFactory, \Magento\Catalog\Model\Indexer\Product\Flat\State $state ) { - $this->_indexer = $indexer; + $this->_indexer = $indexerFactory->create(); $this->_state = $state; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php index d2dfcd325a381..1b14af3e689ad 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php @@ -45,7 +45,7 @@ class Mode extends \Magento\Core\Model\Config\Value * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param \Magento\Indexer\Model\Indexer\State $indexerState - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -56,7 +56,7 @@ public function __construct( \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, \Magento\Indexer\Model\Indexer\State $indexerState, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRule.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRule.php new file mode 100644 index 0000000000000..24ca0a08bcc97 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRule.php @@ -0,0 +1,110 @@ +_processor = $processor; + } + + /** + * Invalidate price indexer + * + * @param \Magento\CatalogRule\Model\Rule $subject + * + * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterApplyAll(\Magento\CatalogRule\Model\Rule $subject) + { + $this->_processor->markIndexerAsInvalid(); + } + + /** + * Reindex price for affected product + * + * @param \Magento\CatalogRule\Model\Rule $subject + * @param callable $proceed + * @param int|\Magento\Catalog\Model\Product $product + * @param null|array $websiteIds + * + * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundApplyToProduct( + \Magento\CatalogRule\Model\Rule $subject, + \Closure $proceed, + $product, + $websiteIds = null + ) { + $proceed($product, $websiteIds); + $this->_reindexProduct($product); + } + + /** + * Reindex price for affected product + * + * @param \Magento\CatalogRule\Model\Rule $subject + * @param callable $proceed + * @param int|\Magento\Catalog\Model\Product $product + * + * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundApplyAllRulesToProduct( + \Magento\CatalogRule\Model\Rule $subject, + \Closure $proceed, + $product + ) { + $proceed($product); + $this->_reindexProduct($product); + } + + /** + * Reindex product price + * + * @param int|\Magento\Catalog\Model\Product $product + * + * @return void + */ + protected function _reindexProduct($product) + { + $productId = is_numeric($product) ? $product : $product->getId(); + $this->_processor->reindexRow($productId); + } +} diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php index 311b4d3e8bf42..cac8406b51935 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php @@ -23,29 +23,31 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; +use Magento\Customer\Service\V1\CustomerGroupServiceInterface; + class CustomerGroup extends AbstractPlugin { /** - * @param \Magento\Customer\Model\Resource\Group $subject - * @param \Magento\Customer\Model\Resource\Group $result - * @return \Magento\Customer\Model\Resource\Group + * @param CustomerGroupServiceInterface $subject + * @param string $result + * @return string * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterDelete(\Magento\Customer\Model\Resource\Group $subject, $result) + public function afterSaveGroup(CustomerGroupServiceInterface $subject, $result) { $this->invalidateIndexer(); return $result; } /** - * @param \Magento\Customer\Model\Resource\Group $subject - * @param \Magento\Customer\Model\Resource\Group $result - * @return \Magento\Customer\Model\Resource\Group + * @param CustomerGroupServiceInterface $subject + * @param string $result + * @return string * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterSave(\Magento\Customer\Model\Resource\Group $subject, $result) + public function afterDeleteGroup(CustomerGroupServiceInterface $subject, $result) { $this->invalidateIndexer(); return $result; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Processor.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Processor.php index cd9dcddfe9c01..5b62c15e00111 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Processor.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Processor.php @@ -38,11 +38,12 @@ class Processor protected $_indexer; /** - * @param \Magento\Indexer\Model\IndexerInterface $indexer + * @param \Magento\Indexer\Model\IndexerFactory $indexerFactory */ - public function __construct(\Magento\Indexer\Model\IndexerInterface $indexer) - { - $this->_indexer = $indexer; + public function __construct( + \Magento\Indexer\Model\IndexerFactory $indexerFactory + ) { + $this->_indexer = $indexerFactory->create(); } /** diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php index d05003eb8430c..e9c45da962841 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php @@ -39,7 +39,7 @@ class PriceScope extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Indexer\Model\IndexerInterface $indexer - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -49,7 +49,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Indexer\Model\IndexerInterface $indexer, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Indexer/Url.php b/app/code/Magento/Catalog/Model/Indexer/Url.php index baa7ccdfeffc4..251c76ba61191 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Url.php +++ b/app/code/Magento/Catalog/Model/Indexer/Url.php @@ -87,7 +87,7 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer * @param \Magento\Registry $registry * @param \Magento\Catalog\Model\Resource\UrlFactory $catalogResourceUrlFactory * @param \Magento\Catalog\Model\Url $catalogUrl - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -96,7 +96,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Catalog\Model\Resource\UrlFactory $catalogResourceUrlFactory, \Magento\Catalog\Model\Url $catalogUrl, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Layer.php b/app/code/Magento/Catalog/Model/Layer.php index ce9ba6cfccc77..69b1f01098de3 100644 --- a/app/code/Magento/Catalog/Model/Layer.php +++ b/app/code/Magento/Catalog/Model/Layer.php @@ -226,7 +226,7 @@ public function getCurrentCategory() * * @param mixed $category * @return \Magento\Catalog\Model\Layer - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setCurrentCategory($category) { @@ -234,12 +234,12 @@ public function setCurrentCategory($category) $category = $this->_categoryFactory->create()->load($category); } if (!$category instanceof \Magento\Catalog\Model\Category) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The category must be an instance of \Magento\Catalog\Model\Category.') ); } if (!$category->getId()) { - throw new \Magento\Core\Exception(__('Please correct the category.')); + throw new \Magento\Model\Exception(__('Please correct the category.')); } if ($category->getId() != $this->getCurrentCategory()->getId()) { diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php b/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php index 30097a7c89f29..66424e85424d9 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php @@ -276,13 +276,13 @@ public function setAttributeModel($attribute) * Get attribute model associated with filter * * @return \Magento\Catalog\Model\Resource\Eav\Attribute - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getAttributeModel() { $attribute = $this->getData('attribute_model'); if (is_null($attribute)) { - throw new \Magento\Core\Exception(__('The attribute model is not defined.')); + throw new \Magento\Model\Exception(__('The attribute model is not defined.')); } return $attribute; } diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php b/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php index 90935eb20b9fa..6e1fe21ee8638 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php @@ -52,14 +52,14 @@ public function __construct(\Magento\ObjectManager $objectManager) * @param string $className * @param array $data * @return \Magento\Catalog\Model\Layer\Filter\Attribute - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function create($className, array $data = array()) { $filter = $this->_objectManager->create($className, $data); if (!$filter instanceof \Magento\Catalog\Model\Layer\Filter\AbstractFilter) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( $className . ' doesn\'t extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter' ); } diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Item.php b/app/code/Magento/Catalog/Model/Layer/Filter/Item.php index 423a359cbb53b..35cdacd084222 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Item.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Item.php @@ -70,13 +70,13 @@ public function __construct( * Get filter instance * * @return \Magento\Catalog\Model\Layer\Filter\AbstractFilter - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getFilter() { $filter = $this->getData('filter'); if (!is_object($filter)) { - throw new \Magento\Core\Exception(__('The filter must be an object. Please set correct filter.')); + throw new \Magento\Model\Exception(__('The filter must be an object. Please set correct filter.')); } return $filter; } diff --git a/app/code/Magento/Catalog/Model/Layer/State.php b/app/code/Magento/Catalog/Model/Layer/State.php index 446b5e06e5618..0e519dd5b4a8c 100644 --- a/app/code/Magento/Catalog/Model/Layer/State.php +++ b/app/code/Magento/Catalog/Model/Layer/State.php @@ -53,12 +53,12 @@ public function addFilter($filter) * * @param array $filters * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setFilters($filters) { if (!is_array($filters)) { - throw new \Magento\Core\Exception(__('The filters must be an array.')); + throw new \Magento\Model\Exception(__('The filters must be an array.')); } $this->setData('filters', $filters); return $this; diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 6ecea966a81aa..abafa246bb6d8 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -522,7 +522,7 @@ public function getIdBySku($sku) */ public function getCategoryId() { - $category = $this->_coreRegistry->registry('current_category'); + $category = $this->_registry->registry('current_category'); if ($category) { return $category->getId(); } @@ -773,7 +773,6 @@ public function reindex() */ protected function _beforeDelete() { - $this->_protectFromNonAdmin(); $this->cleanCache(); $this->_indexIndexer->logEvent($this, self::ENTITY, \Magento\Index\Model\Event::TYPE_DELETE); return parent::_beforeDelete(); diff --git a/app/code/Magento/Catalog/Model/Product/Action.php b/app/code/Magento/Catalog/Model/Product/Action.php index a62bbfc972050..785b93ececca9 100644 --- a/app/code/Magento/Catalog/Model/Product/Action.php +++ b/app/code/Magento/Catalog/Model/Product/Action.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Action extends \Magento\Core\Model\AbstractModel +class Action extends \Magento\Model\AbstractModel { /** * Index indexer @@ -59,7 +59,7 @@ class Action extends \Magento\Core\Model\AbstractModel * @param \Magento\Catalog\Model\Product\WebsiteFactory $productWebsiteFactory * @param \Magento\Index\Model\Indexer $indexIndexer * @param \Magento\Indexer\Model\IndexerInterface $categoryIndexer - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -69,7 +69,7 @@ public function __construct( \Magento\Catalog\Model\Product\WebsiteFactory $productWebsiteFactory, \Magento\Index\Model\Indexer $indexIndexer, \Magento\Indexer\Model\IndexerInterface $categoryIndexer, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 554c86de98465..d2fdecefd4bdb 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 @@ -18,23 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Catalog * @copyright Copyright (c) 2014 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\Attribute\Backend\Groupprice; +use Magento\Catalog\Model\Product\Attribute\Backend\Price; +use Magento\Customer\Service\V1\CustomerGroupServiceInterface; /** * Catalog product abstract group price backend attribute model - * - * @category Magento - * @package Magento_Catalog - * @author Magento Core Team */ -namespace Magento\Catalog\Model\Product\Attribute\Backend\Groupprice; - -abstract class AbstractGroupprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Price +abstract class AbstractGroupprice extends Price { /** * Website currency codes and rates @@ -147,7 +142,7 @@ protected function _isPriceFixed($priceObject) * Validate group price data * * @param \Magento\Catalog\Model\Product $object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ public function validate($object) @@ -172,7 +167,7 @@ public function validate($object) ) ); if (isset($duplicates[$compare])) { - throw new \Magento\Core\Exception($this->_getDuplicateErrorMessage()); + throw new \Magento\Model\Exception($this->_getDuplicateErrorMessage()); } $duplicates[$compare] = true; } @@ -213,7 +208,7 @@ public function validate($object) $websiteCurrency = $rates[$priceRow['website_id']]['code']; if ($baseCurrency == $websiteCurrency && isset($duplicates[$globalCompare])) { - throw new \Magento\Core\Exception($this->_getDuplicateErrorMessage()); + throw new \Magento\Model\Exception($this->_getDuplicateErrorMessage()); } } @@ -271,7 +266,7 @@ public function afterLoad($object) foreach ($data as $k => $v) { $data[$k]['website_price'] = $v['price']; if ($v['all_groups']) { - $data[$k]['cust_group'] = \Magento\Customer\Model\Group::CUST_GROUP_ALL; + $data[$k]['cust_group'] = CustomerGroupServiceInterface::CUST_GROUP_ALL; } } @@ -356,7 +351,7 @@ public function afterSave($object) array_merge(array($data['website_id'], $data['cust_group']), $this->_getAdditionalUniqueFields($data)) ); - $useForAllGroups = $data['cust_group'] == \Magento\Customer\Model\Group::CUST_GROUP_ALL; + $useForAllGroups = $data['cust_group'] == CustomerGroupServiceInterface::CUST_GROUP_ALL; $customerGroupId = !$useForAllGroups ? $data['cust_group'] : 0; $new[$key] = array_merge( diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php index ff97bab8b937c..f12421e52d67b 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php @@ -33,7 +33,7 @@ */ namespace Magento\Catalog\Model\Product\Attribute\Backend; -use Magento\Core\Exception; +use Magento\Model\Exception; class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { 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 33cd75399db03..eebc0c6fa7ecb 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php @@ -164,7 +164,7 @@ public function afterSave($object) * Validate * * @param \Magento\Catalog\Model\Product $object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ public function validate($object) @@ -175,7 +175,7 @@ public function validate($object) } if (!preg_match('/^\d*(\.|,)?\d{0,4}$/i', $value) || $value < 0) { - throw new \Magento\Core\Exception(__('Please enter a number 0 or greater in this field.')); + throw new \Magento\Model\Exception(__('Please enter a number 0 or greater in this field.')); } return true; diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php index 14c290269dfdf..96092d099307e 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php @@ -65,7 +65,7 @@ public function __construct(\Magento\Logger $logger, \Magento\Stdlib\String $str * Validate SKU * * @param Product $object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ public function validate($object) @@ -77,7 +77,7 @@ public function validate($object) } if ($this->string->strlen($object->getSku()) > self::SKU_MAX_LENGTH) { - throw new \Magento\Core\Exception(__('SKU length should be %1 characters maximum.', self::SKU_MAX_LENGTH)); + throw new \Magento\Model\Exception(__('SKU length should be %1 characters maximum.', self::SKU_MAX_LENGTH)); } return true; } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php index bbef2afae0ce8..4c17cc120ac30 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php @@ -99,7 +99,7 @@ public function beforeSave($object) * Validate * * @param Product $object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ public function validate($object) @@ -107,7 +107,7 @@ public function validate($object) $attrCode = $this->getAttribute()->getAttributeCode(); $value = $object->getData($attrCode); if (!empty($value['qty']) && !preg_match('/^-?\d*(\.|,)?\d{0,4}$/i', $value['qty'])) { - throw new \Magento\Core\Exception(__('Please enter a valid number in this field.')); + throw new \Magento\Model\Exception(__('Please enter a valid number in this field.')); } return true; } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Weight.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Weight.php index c5c6855d2b043..3759b25d60a1e 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Weight.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Weight.php @@ -40,7 +40,7 @@ class Weight extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend * Validate * * @param \Magento\Catalog\Model\Product $object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ public function validate($object) @@ -48,7 +48,7 @@ public function validate($object) $attrCode = $this->getAttribute()->getAttributeCode(); $value = $object->getData($attrCode); if (!empty($value) && !\Zend_Validate::is($value, 'Between', array('min' => 0, 'max' => 99999999.9999))) { - throw new \Magento\Core\Exception(__('Please enter a number 0 or greater in this field.')); + throw new \Magento\Model\Exception(__('Please enter a number 0 or greater in this field.')); } return true; } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Group.php b/app/code/Magento/Catalog/Model/Product/Attribute/Group.php index f42959eb9403a..7d2b37210673a 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Group.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Group.php @@ -39,7 +39,7 @@ class Group extends \Magento\Eav\Model\Entity\Attribute\Group * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -47,7 +47,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Product/Compare/Item.php b/app/code/Magento/Catalog/Model/Product/Compare/Item.php index 26f2482e0b7ae..9a82598ac7fa1 100644 --- a/app/code/Magento/Catalog/Model/Product/Compare/Item.php +++ b/app/code/Magento/Catalog/Model/Product/Compare/Item.php @@ -37,12 +37,8 @@ * @method \Magento\Catalog\Model\Product\Compare\Item setProductId(int $value) * @method int getStoreId() * @method \Magento\Catalog\Model\Product\Compare\Item setStoreId(int $value) - * - * @category Magento - * @package Magento_Catalog - * @author Magento Core Team */ -class Item extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface +class Item extends \Magento\Model\AbstractModel implements \Magento\Object\IdentityInterface { /** * Model cache tag @@ -100,7 +96,7 @@ class Item extends \Magento\Core\Model\AbstractModel implements \Magento\Object\ * @param \Magento\Log\Model\Visitor $logVisitor * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Catalog\Helper\Product\Compare $catalogProductCompare - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -111,7 +107,7 @@ public function __construct( \Magento\Log\Model\Visitor $logVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Catalog\Helper\Product\Compare $catalogProductCompare, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -157,18 +153,6 @@ protected function _beforeSave() return $this; } - /** - * Add customer data from customer object - * - * @param \Magento\Customer\Model\Customer $customer - * @return $this - */ - public function addCustomerData(\Magento\Customer\Model\Customer $customer) - { - $this->setCustomerId($customer->getId()); - return $this; - } - /** * Set visitor * diff --git a/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php b/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php index 2fd77cdb824ed..c5cd7bdb0701e 100644 --- a/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php +++ b/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php @@ -172,7 +172,7 @@ protected function _addVisitorToItem($item) { $item->addVisitorId($this->_logVisitor->getId()); if ($this->_customerSession->isLoggedIn()) { - $item->addCustomerData($this->_customerSession->getCustomer()); + $item->setCustomerId($this->_customerSession->getCustomerId()); } return $this; @@ -187,6 +187,6 @@ protected function _addVisitorToItem($item) */ public function hasItems($customerId, $visitorId) { - return $this->_catalogProductCompareItem->getCount($customerId, $visitorId); + return (bool)$this->_catalogProductCompareItem->getCount($customerId, $visitorId); } } diff --git a/app/code/Magento/Catalog/Model/Product/Image.php b/app/code/Magento/Catalog/Model/Product/Image.php index 4bb7bd5138566..806803108d4fc 100644 --- a/app/code/Magento/Catalog/Model/Product/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Image.php @@ -36,7 +36,7 @@ use Magento\Core\Model\Store; use Magento\Image as MagentoImage; -class Image extends \Magento\Core\Model\AbstractModel +class Image extends \Magento\Model\AbstractModel { /** * @var int @@ -192,7 +192,7 @@ class Image extends \Magento\Core\Model\AbstractModel * @param \Magento\View\Url $viewUrl * @param \Magento\View\FileSystem $viewFileSystem * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -207,7 +207,7 @@ public function __construct( \Magento\View\Url $viewUrl, \Magento\View\FileSystem $viewFileSystem, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Product/Indexer/Eav.php b/app/code/Magento/Catalog/Model/Product/Indexer/Eav.php index 5528e70829055..8a6c47270bb18 100644 --- a/app/code/Magento/Catalog/Model/Product/Indexer/Eav.php +++ b/app/code/Magento/Catalog/Model/Product/Indexer/Eav.php @@ -67,7 +67,7 @@ class Eav extends \Magento\Index\Model\Indexer\AbstractIndexer * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -75,7 +75,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Eav\Model\Config $eavConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Product/Link.php b/app/code/Magento/Catalog/Model/Product/Link.php index d65f0c7be084e..41a1d3d46c693 100644 --- a/app/code/Magento/Catalog/Model/Product/Link.php +++ b/app/code/Magento/Catalog/Model/Product/Link.php @@ -44,7 +44,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Link extends \Magento\Core\Model\AbstractModel +class Link extends \Magento\Model\AbstractModel { const LINK_TYPE_RELATED = 1; @@ -76,7 +76,7 @@ class Link extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Catalog\Model\Resource\Product\Link\CollectionFactory $linkCollectionFactory * @param \Magento\Catalog\Model\Resource\Product\Link\Product\CollectionFactory $productCollectionFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -85,7 +85,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Catalog\Model\Resource\Product\Link\CollectionFactory $linkCollectionFactory, \Magento\Catalog\Model\Resource\Product\Link\Product\CollectionFactory $productCollectionFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php index 45eaf6499a0be..ae31863b036ed 100644 --- a/app/code/Magento/Catalog/Model/Product/Option.php +++ b/app/code/Magento/Catalog/Model/Product/Option.php @@ -27,8 +27,8 @@ use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Resource\Product\Option\Value\Collection; -use Magento\Core\Exception; -use Magento\Core\Model\AbstractModel; +use Magento\Model\Exception; +use Magento\Model\AbstractModel; /** * Catalog product option model @@ -127,7 +127,7 @@ class Option extends AbstractModel * @param Option\Value $productOptionValue * @param \Magento\Catalog\Model\Product\Option\Type\Factory $optionFactory * @param \Magento\Stdlib\String $string - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -137,7 +137,7 @@ public function __construct( Option\Value $productOptionValue, \Magento\Catalog\Model\Product\Option\Type\Factory $optionFactory, \Magento\Stdlib\String $string, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -150,7 +150,7 @@ public function __construct( /** * Get resource instance * - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @return \Magento\Model\Resource\Db\AbstractDb */ protected function _getResource() { diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php index f133ebd4dc25c..8adc72f513368 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php @@ -65,7 +65,7 @@ public function __construct( * * @param array $values All product option values, i.e. array (option_id => mixed, option_id => mixed...) * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validateUserValue($values) { @@ -120,11 +120,11 @@ public function validateUserValue($values) } elseif (!$isValid && $option->getIsRequire() && !$this->getSkipCheckRequiredOption()) { $this->setIsValid(false); if (!$dateValid) { - throw new \Magento\Core\Exception(__('Please specify date required option(s).')); + throw new \Magento\Model\Exception(__('Please specify date required option(s).')); } elseif (!$timeValid) { - throw new \Magento\Core\Exception(__('Please specify time required option(s).')); + throw new \Magento\Model\Exception(__('Please specify time required option(s).')); } else { - throw new \Magento\Core\Exception(__('Please specify the product\'s required option(s).')); + throw new \Magento\Model\Exception(__('Please specify the product\'s required option(s).')); } } else { $this->setUserValue(null); @@ -138,7 +138,7 @@ public function validateUserValue($values) * Prepare option value for cart * * @return string|null Prepared option value - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function prepareForCart() { diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php b/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php index 4976f5f79b96d..15e4700026699 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php @@ -25,7 +25,7 @@ */ namespace Magento\Catalog\Model\Product\Option\Type; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Catalog product option default type diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php index f04f10a391fac..d8bf51a94bcfc 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php @@ -52,14 +52,14 @@ public function __construct(\Magento\ObjectManager $objectManager) * @param string $className * @param array $data * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function create($className, array $data = array()) { $option = $this->_objectManager->create($className, $data); if (!$option instanceof \Magento\Catalog\Model\Product\Option\Type\DefaultType) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( $className . ' doesn\'t extends \Magento\Catalog\Model\Product\Option\Type\DefaultType' ); } diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php index e54d6a2ea223f..e327c3609be72 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php @@ -25,7 +25,7 @@ */ namespace Magento\Catalog\Model\Product\Option\Type; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Catalog product option file type diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php index 9ffbbbca39410..e239ae4acc1da 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php @@ -25,7 +25,7 @@ */ namespace Magento\Catalog\Model\Product\Option\Type; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Catalog product option select type diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Text.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Text.php index f8e14be6e5520..2ef030b0f4608 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/Text.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Text.php @@ -25,7 +25,7 @@ */ namespace Magento\Catalog\Model\Product\Option\Type; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Catalog product option text type diff --git a/app/code/Magento/Catalog/Model/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Product/Option/Value.php index ce11e11dd21cf..3a1992c8c58b1 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Value.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Value.php @@ -42,7 +42,7 @@ * * @SuppressWarnings(PHPMD.LongVariable) */ -class Value extends \Magento\Core\Model\AbstractModel +class Value extends \Magento\Model\AbstractModel { /** * @var array @@ -70,7 +70,7 @@ class Value extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $valueCollectionFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -78,7 +78,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $valueCollectionFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php index d0063929fe90a..1e19df3bfa657 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php +++ b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php @@ -381,7 +381,7 @@ protected function _prepareProduct(\Magento\Object $buyRequest, $product, $proce // try to add custom options try { $options = $this->_prepareOptions($buyRequest, $product, $processMode); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { return $e->getMessage(); } @@ -488,7 +488,7 @@ public function prepareForCart(\Magento\Object $buyRequest, $product) * Process File Queue * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function processFileQueue() { @@ -511,7 +511,7 @@ public function processFileQueue() $rootDir = $this->_filesystem->getDirectoryWrite(\Magento\App\Filesystem::ROOT_DIR); $rootDir->create($rootDir->getRelativePath($path)); } catch (\Magento\Filesystem\FilesystemException $e) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __("We can't create writeable directory \"%1\".", $path) ); } @@ -525,7 +525,7 @@ public function processFileQueue() if (isset($queueOptions['option'])) { $queueOptions['option']->setIsValid(false); } - throw new \Magento\Core\Exception(__("The file upload failed.")); + throw new \Magento\Model\Exception(__("The file upload failed.")); } $this->_fileStorageDb->saveFile($dst); break; @@ -620,7 +620,7 @@ protected function _prepareOptions(\Magento\Object $buyRequest, $product, $proce * * @param \Magento\Catalog\Model\Product $product * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function checkProductBuyState($product) { @@ -630,7 +630,7 @@ public function checkProductBuyState($product) $customOption = $product->getCustomOption(self::OPTION_PREFIX . $option->getId()); if (!$customOption || strlen($customOption->getValue()) == 0) { $product->setSkipCheckRequiredOption(true); - throw new \Magento\Core\Exception(__('The product has required options.')); + throw new \Magento\Model\Exception(__('The product has required options.')); } } } @@ -1045,7 +1045,7 @@ public function checkProductConfiguration($product, $buyRequest) if (is_string($result)) { $errors[] = $result; } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $errors[] = $e->getMessages(); } catch (\Exception $e) { $this->_logger->logException($e); diff --git a/app/code/Magento/Catalog/Model/Product/Type/Pool.php b/app/code/Magento/Catalog/Model/Product/Type/Pool.php index 2b5a6af2f5a85..6b844d3c8d092 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/Pool.php +++ b/app/code/Magento/Catalog/Model/Product/Type/Pool.php @@ -52,14 +52,14 @@ public function __construct(\Magento\ObjectManager $objectManager) * @param string $className * @param array $data * @return \Magento\Catalog\Model\Product\Type\AbstractType - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function get($className, array $data = array()) { $product = $this->_objectManager->get($className, $data); if (!$product instanceof \Magento\Catalog\Model\Product\Type\AbstractType) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( $className . ' doesn\'t extends \Magento\Catalog\Model\Product\Type\AbstractType' ); } diff --git a/app/code/Magento/Catalog/Model/Product/Type/Price.php b/app/code/Magento/Catalog/Model/Product/Type/Price.php old mode 100644 new mode 100755 index b4908c97ac6a5..5965d59c7b417 --- a/app/code/Magento/Catalog/Model/Product/Type/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Type/Price.php @@ -250,7 +250,7 @@ protected function _applyTierPrice($product, $qty, $finalPrice) */ public function getTierPrice($qty, $product) { - $allGroups = \Magento\Customer\Model\Group::CUST_GROUP_ALL; + $allGroups = \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL; $prices = $product->getData('tier_price'); if (is_null($prices)) { diff --git a/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php b/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php index 341760321953c..7bc114f121f09 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php +++ b/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php @@ -52,14 +52,14 @@ public function __construct(\Magento\ObjectManager $objectManager) * @param string $className * @param array $data * @return \Magento\Catalog\Model\Product\Type\Price - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function create($className, array $data = array()) { $price = $this->_objectManager->create($className, $data); if (!$price instanceof \Magento\Catalog\Model\Product\Type\Price) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( $className . ' doesn\'t extends \Magento\Catalog\Model\Product\Type\Price' ); } diff --git a/app/code/Magento/Catalog/Model/Product/Url.php b/app/code/Magento/Catalog/Model/Product/Url.php index 02181f016d2a6..90f2a85d9f2cf 100644 --- a/app/code/Magento/Catalog/Model/Product/Url.php +++ b/app/code/Magento/Catalog/Model/Product/Url.php @@ -191,7 +191,7 @@ public function formatUrlKey($str) * @param \Magento\Catalog\Model\Category $category * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getUrlPath($product, $category = null) { @@ -201,7 +201,7 @@ public function getUrlPath($product, $category = null) /** @todo get default category */ return $path; } elseif (!$category instanceof \Magento\Catalog\Model\Category) { - throw new \Magento\Core\Exception('Invalid category object supplied'); + throw new \Magento\Model\Exception('Invalid category object supplied'); } return $this->_catalogCategory->getCategoryUrlPath($category->getUrlPath()) . '/' . $path; diff --git a/app/code/Magento/Catalog/Model/Product/Website.php b/app/code/Magento/Catalog/Model/Product/Website.php index 36777346b5762..152fa84400035 100644 --- a/app/code/Magento/Catalog/Model/Product/Website.php +++ b/app/code/Magento/Catalog/Model/Product/Website.php @@ -39,7 +39,7 @@ */ namespace Magento\Catalog\Model\Product; -class Website extends \Magento\Core\Model\AbstractModel +class Website extends \Magento\Model\AbstractModel { /** * Initialize resource model @@ -67,14 +67,14 @@ protected function _getResource() * @param array $websiteIds * @param array $productIds * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function removeProducts($websiteIds, $productIds) { try { $this->_getResource()->removeProducts($websiteIds, $productIds); } catch (\Exception $e) { - throw new \Magento\Core\Exception(__('Something went wrong removing products from the websites.')); + throw new \Magento\Model\Exception(__('Something went wrong removing products from the websites.')); } return $this; } @@ -85,14 +85,14 @@ public function removeProducts($websiteIds, $productIds) * @param array $websiteIds * @param array $productIds * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addProducts($websiteIds, $productIds) { try { $this->_getResource()->addProducts($websiteIds, $productIds); } catch (\Exception $e) { - throw new \Magento\Core\Exception(__('Something went wrong adding products to websites.')); + throw new \Magento\Model\Exception(__('Something went wrong adding products to websites.')); } return $this; } diff --git a/app/code/Magento/Catalog/Model/Resource/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Attribute.php index 5ef305ec8e30b..173d6d46c2e7d 100644 --- a/app/code/Magento/Catalog/Model/Resource/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Attribute.php @@ -70,10 +70,10 @@ public function __construct( /** * Perform actions before object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { $applyTo = $object->getApplyTo(); if (is_array($applyTo)) { @@ -85,10 +85,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * Perform actions after object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { $this->_clearUselessAttributeValues($object); return parent::_afterSave($object); @@ -97,10 +97,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Clear useless attribute values * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _clearUselessAttributeValues(\Magento\Core\Model\AbstractModel $object) + protected function _clearUselessAttributeValues(\Magento\Model\AbstractModel $object) { $origData = $object->getOrigData(); @@ -125,11 +125,11 @@ protected function _clearUselessAttributeValues(\Magento\Core\Model\AbstractMode /** * Delete entity * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - public function deleteEntity(\Magento\Core\Model\AbstractModel $object) + public function deleteEntity(\Magento\Model\AbstractModel $object) { if (!$object->getEntityAttributeId()) { return $this; @@ -151,8 +151,8 @@ public function deleteEntity(\Magento\Core\Model\AbstractModel $object) try { $this->attrLockValidator->validate($attribute, $result['attribute_set_id']); - } catch (\Magento\Core\Exception $exception) { - throw new \Magento\Core\Exception( + } catch (\Magento\Model\Exception $exception) { + throw new \Magento\Model\Exception( __("Attribute '%1' is locked. ", $attribute->getAttributeCode()) . $exception->getMessage() ); } diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Collection.php b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Collection.php index a841b9613be4e..7c76bcde49ae6 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Collection.php @@ -48,7 +48,7 @@ class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\Collection * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -57,7 +57,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Eav\Model\EntityFactory $eavEntityFactory, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_eavEntityFactory = $eavEntityFactory; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php b/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php index 47ae821e0b50f..01fffa83ae84e 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Event prefix @@ -69,7 +69,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -78,7 +78,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_storeManager = $storeManager; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Catalog/Model/Resource/Config.php b/app/code/Magento/Catalog/Model/Resource/Config.php index f53bd5d870bb0..d8ebeaf670b97 100644 --- a/app/code/Magento/Catalog/Model/Resource/Config.php +++ b/app/code/Magento/Catalog/Model/Resource/Config.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Config extends \Magento\Core\Model\Resource\Db\AbstractDb +class Config extends \Magento\Model\Resource\Db\AbstractDb { /** * catalog_product entity type id diff --git a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php index bfcad10cf5ff6..69d86627aede4 100644 --- a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php @@ -142,7 +142,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productFlatIndexerHelper * @param LockValidatorInterface $lockValidator - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -162,7 +162,7 @@ public function __construct( \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, \Magento\Catalog\Helper\Product\Flat\Indexer $productFlatIndexerHelper, LockValidatorInterface $lockValidator, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -199,8 +199,8 @@ protected function _construct() /** * Processing object before save data * - * @return \Magento\Core\Model\AbstractModel - * @throws \Magento\Core\Exception + * @return \Magento\Model\AbstractModel + * @throws \Magento\Model\Exception */ protected function _beforeSave() { @@ -212,8 +212,8 @@ protected function _beforeSave() if ($this->_data['is_global'] != $this->_origData['is_global']) { try { $this->attrLockValidator->validate($this); - } catch (\Magento\Core\Exception $exception) { - throw new \Magento\Core\Exception(__('Do not change the scope. ' . $exception->getMessage())); + } catch (\Magento\Model\Exception $exception) { + throw new \Magento\Model\Exception(__('Do not change the scope. ' . $exception->getMessage())); } } } @@ -233,7 +233,7 @@ protected function _beforeSave() /** * Processing object after save data * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _afterSave() { @@ -273,7 +273,7 @@ protected function _afterSave() * Register indexing event before delete catalog eav attribute * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeDelete() { diff --git a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Attribute.php index 5c3b5c04ebd21..ccff61097effc 100644 --- a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Attribute.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb +class Attribute extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection and define main table name diff --git a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Decimal.php b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Decimal.php index e8d635c8914c9..f35a2fa8d4ead 100644 --- a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Decimal.php +++ b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Decimal.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Decimal extends \Magento\Core\Model\Resource\Db\AbstractDb +class Decimal extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection and define main table name diff --git a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php index 481031a9ce92f..5e8196ca77657 100644 --- a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php +++ b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Price extends \Magento\Core\Model\Resource\Db\AbstractDb +class Price extends \Magento\Model\Resource\Db\AbstractDb { /** * Minimal possible price diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php index 15fd3bb9d9d75..68373ad56ad77 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php @@ -34,7 +34,7 @@ */ namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend\Groupprice; -abstract class AbstractGroupprice extends \Magento\Core\Model\Resource\Db\AbstractDb +abstract class AbstractGroupprice extends \Magento\Model\Resource\Db\AbstractDb { /** * Load Tier Prices for product diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Media.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Media.php index 8575bffecbb48..c4f0ea1f3ef12 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Media.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Media.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Media extends \Magento\Core\Model\Resource\Db\AbstractDb +class Media extends \Magento\Model\Resource\Db\AbstractDb { const GALLERY_TABLE = 'catalog_product_entity_media_gallery'; diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Collection.php index d82f3b7901175..80b616fe09594 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Collection.php @@ -48,7 +48,7 @@ class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\Collection * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -57,7 +57,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Eav\Model\EntityFactory $eavEntityFactory, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_eavEntityFactory = $eavEntityFactory; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php index eaae6b81edb21..aa09cb3ea8785 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php @@ -27,6 +27,7 @@ use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus; use Magento\Core\Model\Store; +use Magento\Customer\Service\V1\CustomerGroupServiceInterface; /** * Product collection @@ -513,7 +514,7 @@ public function getNewEmptyItem() */ public function setEntity($entity) { - if ($this->isEnabledFlat() && $entity instanceof \Magento\Core\Model\Resource\Db\AbstractDb) { + if ($this->isEnabledFlat() && $entity instanceof \Magento\Model\Resource\Db\AbstractDb) { $this->_entity = $entity; return $this; } @@ -2075,10 +2076,11 @@ public function addTierPriceData() foreach ($adapter->fetchAll($select) as $row) { $tierPrices[$row['product_id']][] = array( 'website_id' => $row['website_id'], - 'cust_group' => $row['all_groups'] ? \Magento\Customer\Model\Group::CUST_GROUP_ALL : $row['cust_group'], + 'cust_group' => $row['all_groups'] ? CustomerGroupServiceInterface::CUST_GROUP_ALL : $row['cust_group'], 'price_qty' => $row['price_qty'], 'price' => $row['price'], - 'website_price' => $row['price'] + 'website_price' => $row['price'], + ); } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item.php b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item.php index 87d8ea239791e..5fc1b3d9d9a73 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Item extends \Magento\Core\Model\Resource\Db\AbstractDb +class Item extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Flat.php b/app/code/Magento/Catalog/Model/Resource/Product/Flat.php index 5c7bc4f389c57..c6ec3435ecfb9 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Flat.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Flat.php @@ -34,7 +34,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Flat extends \Magento\Core\Model\Resource\Db\AbstractDb +class Flat extends \Magento\Model\Resource\Db\AbstractDb { /** * Store scope Id diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav.php index 5d2a6d39bf9dc..9ce0342ff060b 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav.php @@ -104,13 +104,13 @@ public function getIndexers() * * @param string $type * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\AbstractEav - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getIndexer($type) { $indexers = $this->getIndexers(); if (!isset($indexers[$type])) { - throw new \Magento\Core\Exception(__('We found an unknown EAV indexer type "%1".', $type)); + throw new \Magento\Model\Exception(__('We found an unknown EAV indexer type "%1".', $type)); } return $indexers[$type]; } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Link.php b/app/code/Magento/Catalog/Model/Resource/Product/Link.php index 917ea73a121e3..ef919978887c1 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Link.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Link.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Link extends \Magento\Core\Model\Resource\Db\AbstractDb +class Link extends \Magento\Model\Resource\Db\AbstractDb { /** * Product Link Attributes Table diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Link/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Link/Collection.php index 8dd97a7f373a1..9b8997e84bc1e 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Link/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Link/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Product object diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option.php b/app/code/Magento/Catalog/Model/Resource/Product/Option.php index 63226107ff41d..a43c43a9df61d 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Option extends \Magento\Core\Model\Resource\Db\AbstractDb +class Option extends \Magento\Model\Resource\Db\AbstractDb { /** * Store manager @@ -88,10 +88,10 @@ protected function _construct() /** * Save options store data * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @param \Magento\Model\AbstractModel $object + * @return \Magento\Model\Resource\Db\AbstractDb */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { $this->_saveValuePrices($object); $this->_saveValueTitles($object); @@ -102,10 +102,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Save value prices * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _saveValuePrices(\Magento\Core\Model\AbstractModel $object) + protected function _saveValuePrices(\Magento\Model\AbstractModel $object) { $priceTable = $this->getTable('catalog_product_option_price'); $readAdapter = $this->_getReadAdapter(); @@ -247,10 +247,10 @@ protected function _saveValuePrices(\Magento\Core\Model\AbstractModel $object) /** * Save titles * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return void */ - protected function _saveValueTitles(\Magento\Core\Model\AbstractModel $object) + protected function _saveValueTitles(\Magento\Model\AbstractModel $object) { $readAdapter = $this->_getReadAdapter(); $writeAdapter = $this->_getWriteAdapter(); diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php index 10cd58a012f5d..8662843eed807 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php @@ -30,7 +30,7 @@ * * @SuppressWarnings(PHPMD.LongVariable) */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Store manager @@ -54,7 +54,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $optionValueCollectionFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -64,7 +64,7 @@ public function __construct( \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $optionValueCollectionFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_optionValueCollectionFactory = $optionValueCollectionFactory; $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 bf3c0d2ef687a..fbb6d6b259d61 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Value extends \Magento\Core\Model\Resource\Db\AbstractDb +class Value extends \Magento\Model\Resource\Db\AbstractDb { /** * Store manager @@ -89,10 +89,10 @@ protected function _construct() * Proceed operations after object is saved * Save options store data * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @param \Magento\Model\AbstractModel $object + * @return \Magento\Model\Resource\Db\AbstractDb */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { $this->_saveValuePrices($object); $this->_saveValueTitles($object); @@ -103,10 +103,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Save option value price data * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return void */ - protected function _saveValuePrices(\Magento\Core\Model\AbstractModel $object) + protected function _saveValuePrices(\Magento\Model\AbstractModel $object) { $priceTable = $this->getTable('catalog_product_option_type_price'); @@ -215,10 +215,10 @@ protected function _saveValuePrices(\Magento\Core\Model\AbstractModel $object) /** * Save option value title data * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return void */ - protected function _saveValueTitles(\Magento\Core\Model\AbstractModel $object) + protected function _saveValueTitles(\Magento\Model\AbstractModel $object) { $titleTable = $this->getTable('catalog_product_option_type_title'); diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value/Collection.php index 2d959f27ef22d..a540942437eda 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Relation.php b/app/code/Magento/Catalog/Model/Resource/Product/Relation.php index c0ba908d23752..cb3e915dec7ed 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Relation.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Relation.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Relation extends \Magento\Core\Model\Resource\Db\AbstractDb +class Relation extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize resource model and define main table diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Website.php b/app/code/Magento/Catalog/Model/Resource/Product/Website.php index e8783e99666d3..e126fb05668cb 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Website.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Website.php @@ -26,7 +26,7 @@ /** * Catalog Product Website Resource Model */ -class Website extends \Magento\Core\Model\Resource\Db\AbstractDb +class Website extends \Magento\Model\Resource\Db\AbstractDb { /** * Store manager diff --git a/app/code/Magento/Catalog/Model/Resource/Url.php b/app/code/Magento/Catalog/Model/Resource/Url.php index b967fb03530b9..71b468b41de1f 100644 --- a/app/code/Magento/Catalog/Model/Resource/Url.php +++ b/app/code/Magento/Catalog/Model/Resource/Url.php @@ -32,7 +32,7 @@ * @package Magento_Catalog * @author Magento Core Team */ -class Url extends \Magento\Core\Model\Resource\Db\AbstractDb +class Url extends \Magento\Model\Resource\Db\AbstractDb { /** * Stores configuration array @@ -358,7 +358,7 @@ public function prepareRewrites($storeId, $categoryIds = null, $productIds = nul * @param array $rewriteData * @param int|\Magento\Object $rewrite * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function saveRewrite($rewriteData, $rewrite) { @@ -367,7 +367,7 @@ public function saveRewrite($rewriteData, $rewrite) $adapter->insertOnDuplicate($this->getMainTable(), $rewriteData); } catch (\Exception $e) { $this->_logger->logException($e); - throw new \Magento\Core\Exception(__('Something went wrong saving the URL rewite.')); + throw new \Magento\Model\Exception(__('Something went wrong saving the URL rewite.')); } if ($rewrite && $rewrite->getId()) { 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 f5427e9c804bf..79337d55bed23 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 @@ -44,7 +44,7 @@ class Suffix extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Helper\Url\Rewrite $coreUrlRewrite - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -54,7 +54,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Helper\Url\Rewrite $coreUrlRewrite, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Template/Filter/Factory.php b/app/code/Magento/Catalog/Model/Template/Filter/Factory.php index 4c01c84adaeb0..f77945d01795d 100644 --- a/app/code/Magento/Catalog/Model/Template/Filter/Factory.php +++ b/app/code/Magento/Catalog/Model/Template/Filter/Factory.php @@ -52,14 +52,14 @@ public function __construct(\Magento\ObjectManager $objectManager) * @param string $className * @param array $data * @return \Magento\Filter\Template - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function create($className, array $data = array()) { $filter = $this->_objectManager->create($className, $data); if (!$filter instanceof \Magento\Filter\Template) { - throw new \Magento\Core\Exception($className . ' doesn\'t extends \Magento\Filter\Template'); + throw new \Magento\Model\Exception($className . ' doesn\'t extends \Magento\Filter\Template'); } return $filter; } diff --git a/app/code/Magento/Catalog/Model/Url.php b/app/code/Magento/Catalog/Model/Url.php index b85c3e2831b9e..c489a597cd123 100644 --- a/app/code/Magento/Catalog/Model/Url.php +++ b/app/code/Magento/Catalog/Model/Url.php @@ -902,12 +902,12 @@ public function getProductRequestPath($product, $category) * @param \Magento\Object $category * @param string $parentPath * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function generatePath($type = 'target', $product = null, $category = null, $parentPath = null) { if (!$product && !$category) { - throw new \Magento\Core\Exception(__('Please specify either a category or a product, or both.')); + throw new \Magento\Model\Exception(__('Please specify either a category or a product, or both.')); } // generate id_path @@ -949,7 +949,7 @@ public function generatePath($type = 'target', $product = null, $category = null // for product & category if (!$category) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('A category object is required for determining the product request path.') ); } diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 4038c71c1b20b..f0574227d63e1 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -29,6 +29,7 @@ + @@ -168,7 +169,7 @@ - + @@ -202,15 +203,13 @@ Magento\Indexer\Model\IndexerInterface - - - Magento\Indexer\Model\Indexer - - + + + @@ -312,4 +311,12 @@ + + + + Magento\Catalog\Model\Category + Magento\Catalog\Model\Product + + + diff --git a/app/code/Magento/Catalog/etc/module.xml b/app/code/Magento/Catalog/etc/module.xml index b7a373541de5a..7fd7dcedb6ba1 100644 --- a/app/code/Magento/Catalog/etc/module.xml +++ b/app/code/Magento/Catalog/etc/module.xml @@ -45,7 +45,6 @@ - @@ -56,7 +55,6 @@ - diff --git a/app/code/Magento/Catalog/i18n/de_DE.csv b/app/code/Magento/Catalog/i18n/de_DE.csv index ef810ff0aa76f..1ab046da2d972 100644 --- a/app/code/Magento/Catalog/i18n/de_DE.csv +++ b/app/code/Magento/Catalog/i18n/de_DE.csv @@ -58,7 +58,6 @@ "Amount","Summe" "An error occurred while adding products to websites.","Ein Fehler ist aufgetreten, während Produkte zu Webseiten hinzugefügt wurden." "An error occurred while clearing comparison list.","Beim Löschen der Vergleichsliste ist ein Fehler aufgetreten." -"An error occurred while deleting this review.","Beim Löschen dieser Rezension ist ein Fehler aufgetreten." "An error occurred while removing products from websites.","Ein Fehler ist aufgetreten, während Produkte von Webseiten entfernt wurden." "An error occurred while saving the URL rewrite","Ein Fehler ist beim Speichern der URL-Umschreibung aufgetreten." "An error occurred while saving the attribute set.","Beim Speichern des Eigenschaftensatzes ist ein Fehler aufgetreten." @@ -66,7 +65,6 @@ "An error occurred while saving the product. ","Beim Speichern des Produktes ist ein Fehler aufgetreten." "An error occurred while saving the search query.","Beim Speichern der Suchanfrage ist ein Fehler aufgetreten." "An error occurred while saving this group.","Beim Speichern dieser Gruppe ist ein Fehler aufgetreten." -"An error occurred while saving this review.","Beim Speichern der Rezension ist ein Fehler aufgetreten." "An error occurred while trying to delete the category.","Beim Versuch die Kategorie zu löschen ist ein Fehler aufgetreten." "An error occurred while updating the product(s) attributes.","Beim Aktualisieren der Eigenschaften der/des Produkte(s) ist ein Fehler aufgetreten." "An error occurred while updating the product(s) status.","Bei der Aktualisierung des Status der/des Produkte(s) ist ein Fehler aufgetreten." @@ -211,7 +209,6 @@ "Custom Options","Kundenoptionen" "Custom options","Benutzerdefinierte Optionen" "Customer Group","Kundengruppe" -"Customers Reviews","Berichte der Kunden" "Customers Tagged Product","Produkt vom Kunden markiert" "Data Type for Saving in Database","Datentyp für das Speichern in Datenbank" "Date & Time Custom Options","Benutzerdefinierten Optionen bezüglich Datum und Uhrzeit" @@ -442,7 +439,6 @@ "Page Title Separator","Trennzeichen im Seitentitel" "Parent Category","Überkategorie" "Pending","Ausstehend" -"Pending Reviews RSS","Ausstehende Kundenmeinungen RSS" "Percentage","Prozentsatz" "Please add rows to option.","Bitte Zeilen zur Option hinzufügen." "Please be careful as once you click on the row it will load package data form the selected file and all unsaved form data will be lost.","ACHTUNG: Bei einem Klick auf die Zeile werden die Paketdaten geladen und überschreiben alle ungespeicherten Formulardaten." @@ -499,7 +495,6 @@ "Product Listing Sort by","Verfügbare Produktauflistung sortiert nach" "Product","Produktbezeichnung" "Product Prices","Produktpreise" -"Product Reviews","Produktreviews" "Product Tags","Produkttags" "Product Tier Price API","Produktstaffelpreis API" "Product Type","Produkttyp" @@ -515,7 +510,6 @@ "Products","Produkte" "Products Comparison List","Produkt Vergleichsliste" "Products Information","Produktinformationen" -"Products Reviews","Artikelbewertungen" "Products Sitemap","Sitemap Produkte" "Products only","Nur Produkte" "Products per Page on Grid Allowed Values","Produkte pro Seite (erlaubte Werte für Gitter)" @@ -579,7 +573,6 @@ "Retrieve product types","Produkttypen abrufen" "Retrieve products data","Produktdaten abfragen" "Retrieve products list by filters","Produktliste gemäß Filter abrufen" -"Reviews","Bewertungen" "Roll Over for preview","Darüber scrollen für eine Vorschau" "Root","Root" "SKU","Artikelposition" @@ -678,9 +671,6 @@ "The product has been duplicated.","Das Produkt wurde dupliziert." "The product has been saved.","Das Produkt wurde gespeichert." "The product has required options","Das Produkt hat Pflichtangaben" -"The review has been deleted","Diese Bewertung wurde gelöscht" -"The review has been saved.","Diese Bewertung wrude gespeichert." -"The review was removed by another user or does not exist.","Diese Bewertung wurde von einem anderen Benutzer entfernt oder existiert nicht." "The search was deleted.","Diese Suche wurde gelöscht." "The text is too long","Der Text ist zu lang" "There are no %s available.","Es sind keine %s verfügbar." diff --git a/app/code/Magento/Catalog/i18n/en_US.csv b/app/code/Magento/Catalog/i18n/en_US.csv index a558c4df83231..73557c01ae258 100644 --- a/app/code/Magento/Catalog/i18n/en_US.csv +++ b/app/code/Magento/Catalog/i18n/en_US.csv @@ -58,7 +58,6 @@ "Amount","Amount" "An error occurred while adding products to websites.","An error occurred while adding products to websites." "An error occurred while clearing comparison list.","An error occurred while clearing comparison list." -"An error occurred while deleting this review.","An error occurred while deleting this review." "An error occurred while removing products from websites.","An error occurred while removing products from websites." "An error occurred while saving the URL rewrite","An error occurred while saving the URL rewrite" "An error occurred while saving the attribute set.","An error occurred while saving the attribute set." @@ -66,7 +65,6 @@ "An error occurred while saving the product. ","An error occurred while saving the product. " "An error occurred while saving the search query.","An error occurred while saving the search query." "An error occurred while saving this group.","An error occurred while saving this group." -"An error occurred while saving this review.","An error occurred while saving this review." "An error occurred while trying to delete the category.","An error occurred while trying to delete the category." "An error occurred while updating the product(s) attributes.","An error occurred while updating the product(s) attributes." "An error occurred while updating the product(s) status.","An error occurred while updating the product(s) status." @@ -212,7 +210,6 @@ "Custom Options","Custom Options" "Custom options","Custom options" "Customer Group","Customer Group" -"Customers Reviews","Customers Reviews" "Customers Tagged Product","Customers Tagged Product" "Data Type for Saving in Database","Data Type for Saving in Database" "Date & Time Custom Options","Date & Time Custom Options" @@ -443,7 +440,6 @@ "Page Title Separator","Page Title Separator" "Parent Category","Parent Category" "Pending","Pending" -"Pending Reviews RSS","Pending Reviews RSS" "Percentage","Percentage" "Please add rows to option.","Please add rows to option." "Please be careful as once you click on the row it will load package data form the selected file and all unsaved form data will be lost.","Please be careful as once you click on the row it will load package data form the selected file and all unsaved form data will be lost." @@ -501,7 +497,6 @@ "Product Listing Sort by","Product Listing Sort by" "Product","Product" "Product Prices","Product Prices" -"Product Reviews","Product Reviews" "Product Tags","Product Tags" "Product Tier Price API","Product Tier Price API" "Product Type","Product Type" @@ -517,7 +512,6 @@ "Products","Products" "Products Comparison List","Products Comparison List" "Products Information","Products Information" -"Products Reviews","Products Reviews" "Products Sitemap","Products Sitemap" "Products only","Products only" "Products per Page on Grid Allowed Values","Products per Page on Grid Allowed Values" @@ -581,7 +575,6 @@ "Retrieve product types","Retrieve product types" "Retrieve products data","Retrieve products data" "Retrieve products list by filters","Retrieve products list by filters" -"Reviews","Reviews" "Roll Over for preview","Roll Over for preview" "Root","Root" "SKU","SKU" @@ -680,9 +673,6 @@ "The product has been duplicated.","The product has been duplicated." "The product has been saved.","The product has been saved." "The product has required options","The product has required options" -"The review has been deleted","The review has been deleted" -"The review has been saved.","The review has been saved." -"The review was removed by another user or does not exist.","The review was removed by another user or does not exist." "The search was deleted.","The search was deleted." "The text is too long","The text is too long" "There are no %s available.","There are no %s available." diff --git a/app/code/Magento/Catalog/i18n/es_ES.csv b/app/code/Magento/Catalog/i18n/es_ES.csv index 426fe13571247..9ea8012442dfe 100644 --- a/app/code/Magento/Catalog/i18n/es_ES.csv +++ b/app/code/Magento/Catalog/i18n/es_ES.csv @@ -58,7 +58,6 @@ "Amount","Importe" "An error occurred while adding products to websites.","Se produjo un error mientras se agregaban productos a los sitios web." "An error occurred while clearing comparison list.","Se produjo un error mientras se borraba la lista de comparación." -"An error occurred while deleting this review.","Se produjo un error al eliminar esta revisión." "An error occurred while removing products from websites.","Se produjo un error mientras se eliminaban productos de sitios web." "An error occurred while saving the URL rewrite","Se produjo un error al guardar la URL reescrita" "An error occurred while saving the attribute set.","Se produjo un error mientras se guardaba el conjunto de atributos." @@ -66,7 +65,6 @@ "An error occurred while saving the product. ","Se produjo un error mientras se guardaba el producto." "An error occurred while saving the search query.","Se produjo un error mientras se guardaba el enunciado de búsqueda." "An error occurred while saving this group.","Se produjo un error mientras se guardaba este grupo." -"An error occurred while saving this review.","Se produjo un error al guardar esta revisión." "An error occurred while trying to delete the category.","Se produjo un error mientras se intentaba eliminar la categoría." "An error occurred while updating the product(s) attributes.","Se produjo un error al actualizar los atributos del producto o productos." "An error occurred while updating the product(s) status.","Se produjo un error al actualizar el estado del producto o productos." @@ -211,7 +209,6 @@ "Custom Options","Opciones Personalizadas" "Custom options","Opciones de personalización" "Customer Group","Grupo de Clientes" -"Customers Reviews","Revisiones Personalizadas" "Customers Tagged Product","Producto Etiquetado de Clientes" "Data Type for Saving in Database","Tipo de Datos a Guardar en la Base de Datos" "Date & Time Custom Options","Opciones Personalizadas de Fecha y Hora" @@ -442,7 +439,6 @@ "Page Title Separator","Separador de título de página" "Parent Category","Categoría principal" "Pending","Pendiente" -"Pending Reviews RSS","RSS de reseñas pendientes" "Percentage","Porcentaje" "Please add rows to option.","Por favor, añadir filas a la opción." "Please be careful as once you click on the row it will load package data form the selected file and all unsaved form data will be lost.","Tenga en cuenta que al hacer clic en la fila se cargarán los datos de paquete del archivo seleccionado, y se perderán todos los datos del formulario que no se hayan guardado." @@ -499,7 +495,6 @@ "Product Listing Sort by","Listado de Productos Ordenar Por" "Product","Nombre de Producto" "Product Prices","Precios de Producto" -"Product Reviews","Opiniones de Producto" "Product Tags","Etiqueta de Producto" "Product Tier Price API","API de Precio de Nivel de Producto" "Product Type","Tipo de Producto" @@ -515,7 +510,6 @@ "Products","Productos" "Products Comparison List","Lista de Comparación de Productos" "Products Information","Información de Productos" -"Products Reviews","Opiniones de Productos" "Products Sitemap","Mapa del sitio de productos" "Products only","Sólo productos" "Products per Page on Grid Allowed Values","Productos por Página en Valores Permitidos por la Cuadrícula" @@ -579,7 +573,6 @@ "Retrieve product types","Recuperar tipos de producto" "Retrieve products data","Recuperar datos de productos" "Retrieve products list by filters","Recuperar lista de productos por medio de filtros" -"Reviews","Reseñas" "Roll Over for preview","Desplegar para visualización previa" "Root","Raíz" "SKU","SKU (Número de Referencia)" @@ -678,9 +671,6 @@ "The product has been duplicated.","Se duplicó el producto." "The product has been saved.","Se ha guardado el producto." "The product has required options","El producto tiene opciones obligatorias" -"The review has been deleted","Se eliminó la reseña" -"The review has been saved.","Se guardó la reseña." -"The review was removed by another user or does not exist.","La reseña no existe o fue eliminada por otro usuario." "The search was deleted.","Se eliminó la búsqueda." "The text is too long","El texto es demasiado largo." "There are no %s available.","No hay %s disponibles." diff --git a/app/code/Magento/Catalog/i18n/fr_FR.csv b/app/code/Magento/Catalog/i18n/fr_FR.csv index 88d596b28e6cd..b1eee5ea79157 100644 --- a/app/code/Magento/Catalog/i18n/fr_FR.csv +++ b/app/code/Magento/Catalog/i18n/fr_FR.csv @@ -58,7 +58,6 @@ "Amount","Montant" "An error occurred while adding products to websites.","Une erreur est survenue pendant l'ajout de produits sur les sites Internet." "An error occurred while clearing comparison list.","Une erreur est survenue pendant la suppression de la list de comparaison." -"An error occurred while deleting this review.","Une erreur est survenue en effaçant ce commentaire" "An error occurred while removing products from websites.","Une erreur est survenue pendant le retrait de produits des sites Internet." "An error occurred while saving the URL rewrite","Une erreur est survenue lors de l'enregistrement de la réécriture de l'URL" "An error occurred while saving the attribute set.","Une erreur est survenue pendant la sauvegarde de la série d'attributs." @@ -66,7 +65,6 @@ "An error occurred while saving the product. ","Une erreur est survenue pendant la sauvegarde du produit." "An error occurred while saving the search query.","Une erreur est survenue pendant la sauvegarde de la demande de recherche." "An error occurred while saving this group.","Une erreur est survenue pendant la sauvegarde de ce groupe." -"An error occurred while saving this review.","Une erreur est survenue en enregistrant ce commentaire" "An error occurred while trying to delete the category.","Une erreur est survenue en essayant de supprimer cette catégorie." "An error occurred while updating the product(s) attributes.","Une erreur est survenue pendant la mise à jour des attributs du/des produit(s)." "An error occurred while updating the product(s) status.","Une erreur est survenue pendant la mise à jour du statut du/des produit(s)." @@ -211,7 +209,6 @@ "Custom Options","Personnaliser les options" "Custom options","Options personnalisées" "Customer Group","Groupe du client" -"Customers Reviews","Avis des clients" "Customers Tagged Product","Les acheteurs ont étiqueté le produit" "Data Type for Saving in Database","Type de données pour enregistrement dans la base de données" "Date & Time Custom Options","Options de date et d'heure personnalisées" @@ -442,7 +439,6 @@ "Page Title Separator","Séparateur titre de la page" "Parent Category","Catégorie parent" "Pending","En cours" -"Pending Reviews RSS","RSS des avis en attente" "Percentage","Pourcentage" "Please add rows to option.","Veuillez ajouter des lignes à l'option." "Please be careful as once you click on the row it will load package data form the selected file and all unsaved form data will be lost.","Veuillez faire attention : une fois que vous cliquez sur la ligne, les données du paquet sélectionné se chargeront et toutes les données non-enregistrées seront perdues." @@ -499,7 +495,6 @@ "Product Listing Sort by","Liste des Produits triés par" "Product","Nom du produit" "Product Prices","Prix des Produits" -"Product Reviews","Avis sur le produit" "Product Tags","Étiquettes des produits" "Product Tier Price API","Produit Niveau de Prix API" "Product Type","Type de Produit" @@ -515,7 +510,6 @@ "Products","Produits" "Products Comparison List","Liste de comparaison des produits" "Products Information","Information des produits" -"Products Reviews","Avis sur les produits" "Products Sitemap","Plan du site produits" "Products only","Produits seulement" "Products per Page on Grid Allowed Values","Produits par page sur les valeurs autorisées des lignes" @@ -579,7 +573,6 @@ "Retrieve product types","Extraire les types de produit" "Retrieve products data","Récupérer les données produits" "Retrieve products list by filters","Extraire la liste des produits par filtrage" -"Reviews","Commentaires" "Roll Over for preview","Passez votre souris par-dessus pour la prévisualisation" "Root","Racine" "SKU","UGS" @@ -678,9 +671,6 @@ "The product has been duplicated.","Le produit a été dupliqué." "The product has been saved.","Le produit a été sauvegardé." "The product has required options","Le produit a des options obligatoires." -"The review has been deleted","Le rapport a été supprimé" -"The review has been saved.","Le rapport a été enregistré." -"The review was removed by another user or does not exist.","Le rapport a été supprimé par un autre utilisateur ou n'existe pas." "The search was deleted.","La recherche a été supprimée." "The text is too long","Le texte est trop long" "There are no %s available.","Il n'y a pas de %s disponible." diff --git a/app/code/Magento/Catalog/i18n/nl_NL.csv b/app/code/Magento/Catalog/i18n/nl_NL.csv index 8cd20429f813e..3bba923d85ba6 100644 --- a/app/code/Magento/Catalog/i18n/nl_NL.csv +++ b/app/code/Magento/Catalog/i18n/nl_NL.csv @@ -58,7 +58,6 @@ "Amount","Aantal" "An error occurred while adding products to websites.","Er is een fout opgetreden tijdens het toevoegen van producten aan websites." "An error occurred while clearing comparison list.","Er is een fout opgetreden tijdens het opschonen vergelijkingslijst." -"An error occurred while deleting this review.","Er is een fout opgetreden bij het verwijderen van deze recentie." "An error occurred while removing products from websites.","Er is een fout opgetreden tijdens het verwijderen van producten van websites." "An error occurred while saving the URL rewrite","Er is een fout opgetreden tijdens het opslaan van de URL rewrite" "An error occurred while saving the attribute set.","Er is een fout opgetreden tijdens het opslaan van de attribuut set." @@ -66,7 +65,6 @@ "An error occurred while saving the product. ","Er is een fout opgetreden tijdens het opslaan van het product." "An error occurred while saving the search query.","Er is een fout opgetreden tijdens het opslaan van de zoek query." "An error occurred while saving this group.","Er is een fout opgetreden tijdens het opslaan van deze groep." -"An error occurred while saving this review.","Er is een fout opgetreden bij het opslaan van deze recensie." "An error occurred while trying to delete the category.","Er is een fout opgetreden tijdens het proberen de categorie te verwijderen." "An error occurred while updating the product(s) attributes.","Er is een fout opgetreden tijdens het updaten van de product attributen." "An error occurred while updating the product(s) status.","Er is een fout opgetreden tijdens het updaten van de product status." @@ -211,7 +209,6 @@ "Custom Options","Custom Opties" "Custom options","Aangepaste opties" "Customer Group","Klantgroep" -"Customers Reviews","Klantenrecensies" "Customers Tagged Product","Door Klanten Getagd Product" "Data Type for Saving in Database","Data type om in Database op te slaan" "Date & Time Custom Options","Datum & Tijd Custom Opties" @@ -442,7 +439,6 @@ "Page Title Separator","Pagina Titel Afscheider" "Parent Category","Parent Categorie" "Pending","In afwachting" -"Pending Reviews RSS","In Afwachting van Reviews RSS" "Percentage","Percentage" "Please add rows to option.","Voeg rijen toe aan optie." "Please be careful as once you click on the row it will load package data form the selected file and all unsaved form data will be lost.","Wees voorzichtig aangezien er een pakket data formulier geladen wordt zodra u op de rij klikt en alle niet opgeslagen data zal verloren gaan." @@ -499,7 +495,6 @@ "Product Listing Sort by","Sorteer Product Lijst op" "Product","Productnaam" "Product Prices","Productprijzen" -"Product Reviews","Productbeoordelingen" "Product Tags","Productlabels" "Product Tier Price API","Product niveau prijs API" "Product Type","Product Type" @@ -515,7 +510,6 @@ "Products","Producten" "Products Comparison List","Productvergelijkingslijst" "Products Information","Producteninformatie" -"Products Reviews","Productrecensies" "Products Sitemap","Producten sitemap" "Products only","Producten alleen" "Products per Page on Grid Allowed Values","Producten per pagina op raamwerk toegestane waardes" @@ -579,7 +573,6 @@ "Retrieve product types","Ophalen producttypes" "Retrieve products data","Haal product data op" "Retrieve products list by filters","Ophalen productlijst op filters" -"Reviews","Reviews" "Roll Over for preview","Beweeg uw muis erover heen voor een voorvertoning" "Root","Root" "SKU","SKU" @@ -678,9 +671,6 @@ "The product has been duplicated.","Het product is verdubbeld." "The product has been saved.","Het product is opgeslagen." "The product has required options","Het product heeft verplichte opties" -"The review has been deleted","De beoordeling is verwijderd" -"The review has been saved.","De beoordeling is opgeslagen." -"The review was removed by another user or does not exist.","De beoordeling werd verwijderd door een andere gebruiker of bestaat niet." "The search was deleted.","De zoekactie werd verwijderd." "The text is too long","De tekst is te lang" "There are no %s available.","Er zijn geen %s beschikbaar." diff --git a/app/code/Magento/Catalog/i18n/pt_BR.csv b/app/code/Magento/Catalog/i18n/pt_BR.csv index aacea18485187..ff867c22e0acd 100644 --- a/app/code/Magento/Catalog/i18n/pt_BR.csv +++ b/app/code/Magento/Catalog/i18n/pt_BR.csv @@ -58,7 +58,6 @@ "Amount","Valor" "An error occurred while adding products to websites.","Ocorreu um erro durante a adição de produtos aos websites." "An error occurred while clearing comparison list.","Ocorreu um erro durante a limpeza da lista de comparação." -"An error occurred while deleting this review.","Ocorreu um erro ao excluir essa resenha." "An error occurred while removing products from websites.","Ocorreu um erro durante a retirada de produtos dos sites." "An error occurred while saving the URL rewrite","Ocorreu um erro ao salvar o URL reescrito" "An error occurred while saving the attribute set.","Ocorreu um erro ao salvar o conjunto de atributos." @@ -66,7 +65,6 @@ "An error occurred while saving the product. ","Ocorreu um erro ao salvar o produto." "An error occurred while saving the search query.","Ocorreu um erro ao salvar a consulta de pesquisa." "An error occurred while saving this group.","Ocorreu um erro ao salvar este grupo." -"An error occurred while saving this review.","Ocorreu um erro ao salvar a resenha." "An error occurred while trying to delete the category.","Ocorreu um erro ao tentar eliminar a categoria." "An error occurred while updating the product(s) attributes.","Ocorreu um erro durante a atualização do(s) atributo(s) do(s) produto(s)." "An error occurred while updating the product(s) status.","Ocorreu um erro durante a atualização do status do(s) produto(s)." @@ -211,7 +209,6 @@ "Custom Options","Personalizar Opções" "Custom options","Opções personalizadas" "Customer Group","Grupo de Clientes" -"Customers Reviews","Análises dos clientes" "Customers Tagged Product","Produtos marcados pelos clientes" "Data Type for Saving in Database","Tipo de dado para salvar na base de dados" "Date & Time Custom Options","Opções personalizadas de data e hora" @@ -442,7 +439,6 @@ "Page Title Separator","Separador de Título de Página" "Parent Category","Categoria Pai" "Pending","Pendente" -"Pending Reviews RSS","Comentários RSS Pendentes" "Percentage","Percentagem" "Please add rows to option.","Por favor adicione linhas à opção." "Please be careful as once you click on the row it will load package data form the selected file and all unsaved form data will be lost.","Por favor tome cuidado pois quando você clica na linha ela vai carregar os dados do formulário do pacote, o arquivo selecionado, e todos os dados não guardados do formulário serão perdidos." @@ -499,7 +495,6 @@ "Product Listing Sort by","LIstagem de Produto Ordenada por" "Product","Nome do produto" "Product Prices","Preços de Produto" -"Product Reviews","Comentários sobre Produto" "Product Tags","Etiquetas de Produto" "Product Tier Price API","API para Níveis de Preço do Produto" "Product Type","Tipo de Produto" @@ -515,7 +510,6 @@ "Products","Produtos" "Products Comparison List","Lista de Comparação de Produtos" "Products Information","Informações de Produtos" -"Products Reviews","Comentários sobre Produtos" "Products Sitemap","Sitemap de Produtos" "Products only","Somente produtos" "Products per Page on Grid Allowed Values","Produtos por Página nos Valores Permitidos na Grade" @@ -579,7 +573,6 @@ "Retrieve product types","Recuperar tipos de produto" "Retrieve products data","Recuperar dados de produtos" "Retrieve products list by filters","Recuperar lista de produtos com filtros" -"Reviews","Resenhas" "Roll Over for preview","Passe o mouse para visualizar" "Root","Raiz" "SKU","Unidade de Manutenção de Estoque" @@ -678,9 +671,6 @@ "The product has been duplicated.","O produto foi duplicado." "The product has been saved.","O produto foi salvo." "The product has required options","O produto requer opções" -"The review has been deleted","A análise foi apagada" -"The review has been saved.","A análise foi salva." -"The review was removed by another user or does not exist.","A análise foi removida por outro usuário ou não existe." "The search was deleted.","A pesquisa foi apagada." "The text is too long","O texto é muito longo" "There are no %s available.","Não há %s disponíveis." diff --git a/app/code/Magento/Catalog/i18n/zh_CN.csv b/app/code/Magento/Catalog/i18n/zh_CN.csv index 8669e613a9c2c..79ac27d8357d2 100644 --- a/app/code/Magento/Catalog/i18n/zh_CN.csv +++ b/app/code/Magento/Catalog/i18n/zh_CN.csv @@ -58,7 +58,6 @@ "Amount","数量" "An error occurred while adding products to websites.","添加产品到网站时发生错误。" "An error occurred while clearing comparison list.","清除对照表时发生错误。" -"An error occurred while deleting this review.","删除该评论时出错。" "An error occurred while removing products from websites.","从网站移除产品时发生错误。" "An error occurred while saving the URL rewrite","保存重写的URL时发生错误。" "An error occurred while saving the attribute set.","保存属性集时发生错误。" @@ -66,7 +65,6 @@ "An error occurred while saving the product. ","保存产品时发生错误。" "An error occurred while saving the search query.","保存搜索查询时发生错误。" "An error occurred while saving this group.","保存这个分组时发生错误。" -"An error occurred while saving this review.","保存该评论时出错。" "An error occurred while trying to delete the category.","删除该类别时发生错误。" "An error occurred while updating the product(s) attributes.","更新产品属性时发生错误。" "An error occurred while updating the product(s) status.","更新产品状态时发生错误。" @@ -211,7 +209,6 @@ "Custom Options","自定义选项" "Custom options","自定义选项" "Customer Group","客户组" -"Customers Reviews","客户评测" "Customers Tagged Product","客户标记的产品" "Data Type for Saving in Database","要保存在数据库中的数据类型" "Date & Time Custom Options","日期和时间自定义选项" @@ -442,7 +439,6 @@ "Page Title Separator","页面标题分隔器" "Parent Category","父分类" "Pending","挂起" -"Pending Reviews RSS","挂起评测RSS" "Percentage","百分率" "Please add rows to option.","请添加选项行。" "Please be careful as once you click on the row it will load package data form the selected file and all unsaved form data will be lost.","请小心,一旦您点击这一行,就会从所选文件中加载包裹数据,所有未保存的数据都将丢失。" @@ -499,7 +495,6 @@ "Product Listing Sort by","产品列表排列顺序" "Product","产品名" "Product Prices","产品价格" -"Product Reviews","产品评测" "Product Tags","产品标签" "Product Tier Price API","产品层级价格 API" "Product Type","产品类型" @@ -515,7 +510,6 @@ "Products","产品" "Products Comparison List","产品比较列表" "Products Information","产品信息" -"Products Reviews","产品评论" "Products Sitemap","产品网站地图" "Products only","仅产品" "Products per Page on Grid Allowed Values","网格允许的数值中的每页产品数量" @@ -579,7 +573,6 @@ "Retrieve product types","获取产品类型" "Retrieve products data","获取产品数据" "Retrieve products list by filters","按照筛选器获取产品列表" -"Reviews","评测" "Roll Over for preview","翻转预览" "Root","根" "SKU","SKU" @@ -678,9 +671,6 @@ "The product has been duplicated.","产品已复制。" "The product has been saved.","产品已保存。" "The product has required options","产品包含必需的选项" -"The review has been deleted","评论已被删除" -"The review has been saved.","评论已保存。" -"The review was removed by another user or does not exist.","评论已被另一用户删除,或评论不存在。" "The search was deleted.","搜索被删除。" "The text is too long","文本过长" "There are no %s available.","没有可用的 %s。" diff --git a/app/code/Magento/Catalog/sql/catalog_setup/install-1.6.0.0.php b/app/code/Magento/Catalog/sql/catalog_setup/install-1.6.0.0.0.php similarity index 100% rename from app/code/Magento/Catalog/sql/catalog_setup/install-1.6.0.0.php rename to app/code/Magento/Catalog/sql/catalog_setup/install-1.6.0.0.0.php diff --git a/app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.0-1.6.0.0.1.php b/app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.0.0-1.6.0.0.1.php similarity index 100% rename from app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.0-1.6.0.0.1.php rename to app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.0.0-1.6.0.0.1.php diff --git a/app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.18-1.6.0.0.23.php b/app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.0.18-1.6.0.0.23.php similarity index 100% rename from app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.18-1.6.0.0.23.php rename to app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.0.18-1.6.0.0.23.php diff --git a/app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.24-1.6.0.0.25.php b/app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.0.24-1.6.0.0.25.php similarity index 100% rename from app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.24-1.6.0.0.25.php rename to app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.0.24-1.6.0.0.25.php diff --git a/app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.25-1.6.0.0.26.php b/app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.0.25-1.6.0.0.26.php similarity index 100% rename from app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.25-1.6.0.0.26.php rename to app/code/Magento/Catalog/sql/catalog_setup/upgrade-1.6.0.0.25-1.6.0.0.26.php diff --git a/app/code/Magento/Catalog/view/frontend/product/view/attribute.phtml b/app/code/Magento/Catalog/view/frontend/product/view/attribute.phtml index b4b7691ee78f0..b37162783c041 100644 --- a/app/code/Magento/Catalog/view/frontend/product/view/attribute.phtml +++ b/app/code/Magento/Catalog/view/frontend/product/view/attribute.phtml @@ -27,7 +27,6 @@ * Product view template * * @see \Magento\Catalog\Block\Product\View - * @see \Magento\Review\Block\Product\View */ ?> helper('Magento\Catalog\Helper\Output'); ?> diff --git a/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php b/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php index 97aa77bebf740..53192e05846ea 100644 --- a/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php +++ b/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php @@ -47,7 +47,7 @@ class Managestock extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\CatalogInventory\Model\Stock\Status $stockStatus - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -57,7 +57,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\CatalogInventory\Model\Stock\Status $stockStatus, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php index e1891d1d8a826..41f5052a591e1 100644 --- a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php @@ -93,7 +93,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer * @param \Magento\Registry $registry * @param \Magento\Index\Model\Indexer $indexer * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -102,7 +102,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Index\Model\Indexer $indexer, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php index f40f57674a004..a1b696fe6d467 100644 --- a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php +++ b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php @@ -55,7 +55,7 @@ public function __construct( * @param \Magento\Event\Observer $observer * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validate(\Magento\Event\Observer $observer) { @@ -160,7 +160,7 @@ public function validate(\Magento\Event\Observer $observer) } else { /* @var $stockItem \Magento\CatalogInventory\Model\Stock\Item */ if (!$stockItem instanceof \Magento\CatalogInventory\Model\Stock\Item) { - throw new \Magento\Core\Exception(__('The stock item for Product in option is not valid.')); + throw new \Magento\Model\Exception(__('The stock item for Product in option is not valid.')); } $result = $this->stockItemInitializer->initialize($stockItem, $quoteItem, $qty); diff --git a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/Option.php b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/Option.php index 47059831aa276..d4985a4801081 100644 --- a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/Option.php +++ b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/Option.php @@ -49,7 +49,7 @@ public function __construct(QuoteItemQtyList $quoteItemQtyList) * * @return \Magento\Object * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function initialize( \Magento\Sales\Model\Quote\Item\Option $option, @@ -64,7 +64,7 @@ public function initialize( $stockItem = $option->getProduct()->getStockItem(); if (!$stockItem instanceof \Magento\CatalogInventory\Model\Stock\Item) { - throw new \Magento\Core\Exception(__('The stock item for Product in option is not valid.')); + throw new \Magento\Model\Exception(__('The stock item for Product in option is not valid.')); } /** diff --git a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/StockItem.php b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/StockItem.php index add18bf0a7dc8..c16f1075e8d3c 100644 --- a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/StockItem.php +++ b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/StockItem.php @@ -57,7 +57,7 @@ public function __construct( * @param int $qty * * @return \Magento\Object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function initialize( \Magento\CatalogInventory\Model\Stock\Item $stockItem, diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock.php b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock.php index 628fc65d092a8..d99e97b17d207 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock.php @@ -329,13 +329,13 @@ protected function _getTypeIndexers() * * @param string $productTypeId * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock\StockInterface - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getIndexer($productTypeId) { $types = $this->_getTypeIndexers(); if (!isset($types[$productTypeId])) { - throw new \Magento\Core\Exception(__('Unsupported product type "%1".', $productTypeId)); + throw new \Magento\Model\Exception(__('Unsupported product type "%1".', $productTypeId)); } return $types[$productTypeId]; } diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php index b46486e7c1029..fbbf8f751b4d9 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php @@ -131,12 +131,12 @@ public function setTypeId($typeId) * Retrieve active Product Type Id * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getTypeId() { if (is_null($this->_typeId)) { - throw new \Magento\Core\Exception(__('Undefined product type')); + throw new \Magento\Model\Exception(__('Undefined product type')); } return $this->_typeId; } diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php index 29f51181e5a06..cf1c1c3ab4cd6 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php @@ -61,7 +61,7 @@ public function setTypeId($typeId); * Retrieve Product Type Id for indexer * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getTypeId(); } diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock.php index 0ada75484fcae..a5d61e1468e7a 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock.php @@ -28,7 +28,7 @@ */ namespace Magento\CatalogInventory\Model\Resource; -class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb +class Stock extends \Magento\Model\Resource\Db\AbstractDb { /** * Is initialized configuration flag diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php index 4313364738e67..d973619cae698 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php @@ -34,7 +34,7 @@ */ namespace Magento\CatalogInventory\Model\Resource\Stock; -class Item extends \Magento\Core\Model\Resource\Db\AbstractDb +class Item extends \Magento\Model\Resource\Db\AbstractDb { /** * Core store config diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php index 81999aa72d100..a72939cb30bdd 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php @@ -29,7 +29,7 @@ use Magento\CatalogInventory\Model\Stock; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * @var \Magento\Core\Model\StoreManagerInterface @@ -43,7 +43,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -52,7 +52,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_storeManager = $storeManager; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); @@ -157,13 +157,13 @@ public function addManagedFilter($isStockManagedInConfig) * @param string $comparisonMethod * @param float $qty * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addQtyFilter($comparisonMethod, $qty) { $methods = array('<' => 'lt', '>' => 'gt', '=' => 'eq', '<=' => 'lteq', '>=' => 'gteq', '<>' => 'neq'); if (!isset($methods[$comparisonMethod])) { - throw new \Magento\Core\Exception(__('%1 is not a correct comparison method.', $comparisonMethod)); + throw new \Magento\Model\Exception(__('%1 is not a correct comparison method.', $comparisonMethod)); } return $this->addFieldToFilter('main_table.qty', array($methods[$comparisonMethod] => $qty)); diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php index a879f7a26f535..9b97b0064b4fe 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php @@ -26,7 +26,7 @@ /** * CatalogInventory Stock Status per website Resource Model */ -class Status extends \Magento\Core\Model\Resource\Db\AbstractDb +class Status extends \Magento\Model\Resource\Db\AbstractDb { /** * Store model manager diff --git a/app/code/Magento/CatalogInventory/Model/Stock.php b/app/code/Magento/CatalogInventory/Model/Stock.php index ac38f0b9afbbb..828dd89dc646f 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Stock.php @@ -35,7 +35,7 @@ * @method string getStockName() * @method \Magento\CatalogInventory\Model\Stock setStockName(string $value) */ -class Stock extends \Magento\Core\Model\AbstractModel +class Stock extends \Magento\Model\AbstractModel { const BACKORDERS_NO = 0; @@ -82,7 +82,7 @@ class Stock extends \Magento\Core\Model\AbstractModel * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -93,7 +93,7 @@ public function __construct( \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -187,7 +187,7 @@ protected function _prepareProductQtys($items) * * @param array $items * @return Item[] - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function registerProductsSale($items) { @@ -201,7 +201,7 @@ public function registerProductsSale($items) $item->setData($itemInfo); if (!$item->checkQty($qtys[$item->getProductId()])) { $this->_getResource()->commit(); - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Not all of your products are available in the requested quantity.') ); } @@ -231,7 +231,7 @@ public function revertProductsSale($items) * * @param \Magento\Object $item * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function registerItemSale(\Magento\Object $item) { @@ -249,7 +249,7 @@ public function registerItemSale(\Magento\Object $item) } } } else { - throw new \Magento\Core\Exception(__('We cannot specify a product identifier for the order item.')); + throw new \Magento\Model\Exception(__('We cannot specify a product identifier for the order item.')); } return $this; } diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Stock/Item.php index 07d4fe770af85..39fdaec88c182 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Item.php @@ -70,7 +70,7 @@ * @package Magento_CatalogInventory * @author Magento Core Team */ -class Item extends \Magento\Core\Model\AbstractModel +class Item extends \Magento\Model\AbstractModel { const XML_PATH_GLOBAL = 'cataloginventory/options/'; @@ -216,7 +216,7 @@ class Item extends \Magento\Core\Model\AbstractModel * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Math\Division $mathDivision * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -233,7 +233,7 @@ public function __construct( \Magento\Locale\FormatInterface $localeFormat, \Magento\Math\Division $mathDivision, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -558,7 +558,7 @@ public function getCanBackInStock() * Check quantity * * @param int|float $qty - * @exception \Magento\Core\Exception + * @exception \Magento\Model\Exception * @return bool */ public function checkQty($qty) diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/Stock/Status.php index 311d7ed43199c..a888e599be19e 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Status.php @@ -43,7 +43,7 @@ * @method int getStockStatus() * @method \Magento\CatalogInventory\Model\Stock\Status setStockStatus(int $value) */ -class Status extends \Magento\Core\Model\AbstractModel +class Status extends \Magento\Model\AbstractModel { /**#@+ * Stock Status values @@ -102,7 +102,7 @@ class Status extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param ItemFactory $stockItemFactory * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -114,7 +114,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, ItemFactory $stockItemFactory, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 0980e26b536c7..b9b50f88974f2 100644 --- a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php +++ b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php @@ -45,7 +45,7 @@ class Minsaleqty extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -55,7 +55,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php index 2bc7a3aa08f7b..8610c625b05fe 100644 --- a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php +++ b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php @@ -30,7 +30,7 @@ */ namespace Magento\CatalogInventory\Model\System\Config\Backend; -use Magento\Core\Exception; +use Magento\Model\Exception; class Qtyincrements extends \Magento\Core\Model\Config\Value { diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php index 3716952055755..806b4b43e687e 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php @@ -36,7 +36,7 @@ use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; use Magento\CatalogRule\Model\Rule\Job; -use Magento\Core\Exception; +use Magento\Model\Exception; use Magento\Stdlib\DateTime\Filter\Date; use Magento\Registry; use Magento\Rule\Model\Condition\AbstractCondition; diff --git a/app/code/Magento/CatalogRule/Model/Flag.php b/app/code/Magento/CatalogRule/Model/Flag.php index 4c59433fd0076..dcb4fa20d3dd0 100644 --- a/app/code/Magento/CatalogRule/Model/Flag.php +++ b/app/code/Magento/CatalogRule/Model/Flag.php @@ -33,7 +33,7 @@ */ namespace Magento\CatalogRule\Model; -class Flag extends \Magento\Core\Model\Flag +class Flag extends \Magento\Flag { /** * Flag code diff --git a/app/code/Magento/CatalogRule/Model/Resource/Grid/Collection.php b/app/code/Magento/CatalogRule/Model/Resource/Grid/Collection.php index 9ffeb7c748ae7..5f49e71c4e0cf 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Grid/Collection.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Grid/Collection.php @@ -23,7 +23,7 @@ */ namespace Magento\CatalogRule\Model\Resource\Grid; -use Magento\Core\Model\Resource\Db\Collection\AbstractCollection; +use Magento\Model\Resource\Db\Collection\AbstractCollection; class Collection extends \Magento\CatalogRule\Model\Resource\Rule\Collection { diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule.php b/app/code/Magento/CatalogRule/Model/Resource/Rule.php index e7a4ef798ea67..8cc6be2f14183 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule.php @@ -36,8 +36,8 @@ use Magento\Catalog\Model\Product; use Magento\CatalogRule\Model\Rule as ModelRule; -use Magento\Core\Model\AbstractModel; -use Magento\Core\Model\Resource\Db\AbstractDb; +use Magento\Model\AbstractModel; +use Magento\Model\Resource\Db\AbstractDb; class Rule extends \Magento\Rule\Model\Resource\AbstractResource { diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price.php b/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price.php index aaeb631883103..9119f7f307d1b 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price.php @@ -34,7 +34,7 @@ */ namespace Magento\CatalogRule\Model\Resource\Rule\Product; -class Price extends \Magento\Core\Model\Resource\Db\AbstractDb +class Price extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection and define main table diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php b/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php index 69ff5cff971bc..c94f7c52ccda0 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php @@ -25,7 +25,7 @@ */ namespace Magento\CatalogRule\Model\Resource\Rule\Product\Price; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * @return void diff --git a/app/code/Magento/CatalogRule/Model/Rule.php b/app/code/Magento/CatalogRule/Model/Rule.php index 656f0b35e29a7..fc82c7cd4bbd2 100644 --- a/app/code/Magento/CatalogRule/Model/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Rule.php @@ -122,7 +122,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel protected $_relatedCacheTypes; /** - * @var \Magento\Core\Model\Resource\Iterator + * @var \Magento\Model\Resource\Iterator */ protected $_resourceIterator; @@ -176,13 +176,13 @@ class Rule extends \Magento\Rule\Model\AbstractModel * @param \Magento\CatalogRule\Model\Rule\Condition\CombineFactory $combineFactory * @param \Magento\CatalogRule\Model\Rule\Action\CollectionFactory $actionCollectionFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Core\Model\Resource\Iterator $resourceIterator + * @param \Magento\Model\Resource\Iterator $resourceIterator * @param \Magento\Index\Model\Indexer $indexer * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\CatalogRule\Helper\Data $catalogRuleData * @param \Magento\App\Cache\TypeListInterface $cacheTypesList * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $relatedCacheTypes * @param array $data @@ -197,13 +197,13 @@ public function __construct( \Magento\CatalogRule\Model\Rule\Condition\CombineFactory $combineFactory, \Magento\CatalogRule\Model\Rule\Action\CollectionFactory $actionCollectionFactory, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Core\Model\Resource\Iterator $resourceIterator, + \Magento\Model\Resource\Iterator $resourceIterator, \Magento\Index\Model\Indexer $indexer, \Magento\Customer\Model\Session $customerSession, \Magento\CatalogRule\Helper\Data $catalogRuleData, \Magento\App\Cache\TypeListInterface $cacheTypesList, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $relatedCacheTypes = array(), array $data = array() @@ -372,10 +372,6 @@ public function applyAll() $this->getResourceCollection()->walk(array($this->_getResource(), 'updateRuleProductData')); $this->_getResource()->applyAllRulesForDateRange(); $this->_invalidateCache(); - $indexProcess = $this->_indexer->getProcessByCode('catalog_product_price'); - if ($indexProcess) { - $indexProcess->reindexAll(); - } } /** diff --git a/app/code/Magento/CatalogRule/Model/Rule/Job.php b/app/code/Magento/CatalogRule/Model/Rule/Job.php index 9be011bce2e2e..6666a64c1ee21 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Job.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Job.php @@ -71,7 +71,7 @@ public function applyAll() try { $this->_eventManager->dispatch('catalogrule_apply_all'); $this->setSuccess(__('The rules have been applied.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->setError($e->getMessage()); } return $this; diff --git a/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php b/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php index 5e0681f2177cd..b979b74eeac64 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php @@ -53,7 +53,7 @@ use Magento\DB\Select; -class Price extends \Magento\Core\Model\AbstractModel +class Price extends \Magento\Model\AbstractModel { /** * Initialize resource model diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Result.php b/app/code/Magento/CatalogSearch/Block/Advanced/Result.php index b1af77e895da7..235b613f2e933 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Result.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Result.php @@ -179,7 +179,7 @@ public function getProductListHtml() */ public function getFormUrl() { - return $this->_urlFactory->create()->setQueryParams( + return $this->_urlFactory->create()->addQueryParams( $this->getRequest()->getQuery() )->getUrl( '*/*/', diff --git a/app/code/Magento/CatalogSearch/Controller/Advanced.php b/app/code/Magento/CatalogSearch/Controller/Advanced.php index a4420c2c40515..fa73fa5990163 100644 --- a/app/code/Magento/CatalogSearch/Controller/Advanced.php +++ b/app/code/Magento/CatalogSearch/Controller/Advanced.php @@ -99,9 +99,9 @@ public function resultAction() $this->_view->loadLayout(); try { $this->_catalogSearchAdvanced->addFilters($this->getRequest()->getQuery()); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); - $defaultUrl = $this->_urlFactory->create()->setQueryParams( + $defaultUrl = $this->_urlFactory->create()->addQueryParams( $this->getRequest()->getQuery() )->getUrl( '*/*/' diff --git a/app/code/Magento/CatalogSearch/Model/Advanced.php b/app/code/Magento/CatalogSearch/Model/Advanced.php index 309215655dd00..89f1f2b8bf24c 100644 --- a/app/code/Magento/CatalogSearch/Model/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Advanced.php @@ -62,8 +62,8 @@ use Magento\CatalogSearch\Model\Resource\Advanced\Collection; use Magento\CatalogSearch\Model\Resource\EngineInterface; use Magento\CatalogSearch\Model\Resource\EngineProvider; -use Magento\Core\Exception; -use Magento\Core\Model\AbstractModel; +use Magento\Model\Exception; +use Magento\Model\AbstractModel; use Magento\Model\Context; use Magento\Registry; use Magento\Core\Model\StoreManagerInterface; 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 14a586257096b..c0b1472238131 100644 --- a/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php +++ b/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php @@ -39,7 +39,7 @@ use Magento\Core\Model\Config\Value; use Magento\Model\Context; use Magento\Registry; -use Magento\Core\Model\Resource\AbstractResource; +use Magento\Model\Resource\AbstractResource; use Magento\Core\Model\StoreManagerInterface; use Magento\Data\Collection\Db; diff --git a/app/code/Magento/CatalogSearch/Model/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Fulltext.php index c811e99554562..cde051757589e 100644 --- a/app/code/Magento/CatalogSearch/Model/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Fulltext.php @@ -27,10 +27,10 @@ use Magento\CatalogSearch\Helper\Data; use Magento\CatalogSearch\Model\Query; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; use Magento\Model\Context; use Magento\Registry; -use Magento\Core\Model\Resource\AbstractResource; +use Magento\Model\Resource\AbstractResource; use Magento\Core\Model\Store\Config; use Magento\Data\Collection\Db; diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php index 5da980fc37805..aa7fee2cd3556 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php @@ -40,7 +40,7 @@ use Magento\CatalogSearch\Model\Resource\Indexer\Fulltext as IndexerFulltext; use Magento\Model\Context; use Magento\Registry; -use Magento\Core\Model\Resource\AbstractResource; +use Magento\Model\Resource\AbstractResource; use Magento\Core\Model\Store; use Magento\Core\Model\Store\Group; use Magento\Core\Model\StoreManagerInterface; diff --git a/app/code/Magento/CatalogSearch/Model/Query.php b/app/code/Magento/CatalogSearch/Model/Query.php index cd1459a86c35c..8388de6b683ca 100644 --- a/app/code/Magento/CatalogSearch/Model/Query.php +++ b/app/code/Magento/CatalogSearch/Model/Query.php @@ -29,10 +29,10 @@ use Magento\CatalogSearch\Model\Resource\Query\CollectionFactory as QueryCollectionFactory; use Magento\CatalogSearch\Model\Resource\Search\Collection; use Magento\CatalogSearch\Model\Resource\Search\CollectionFactory; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; use Magento\Model\Context; use Magento\Registry; -use Magento\Core\Model\Resource\AbstractResource; +use Magento\Model\Resource\AbstractResource; use Magento\Core\Model\Store\Config; use Magento\Core\Model\StoreManagerInterface; use Magento\Data\Collection\Db; diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php index d8a06173eae57..0c39976602b3f 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php @@ -32,7 +32,7 @@ * @package Magento_CatalogSearch * @author Magento Core Team */ -class Advanced extends \Magento\Core\Model\Resource\Db\AbstractDb +class Advanced extends \Magento\Model\Resource\Db\AbstractDb { /** * Core event manager proxy diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php index a9de3d49759a4..2889ca3019d92 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php @@ -25,7 +25,7 @@ */ namespace Magento\CatalogSearch\Model\Resource\Advanced; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Collection Advanced diff --git a/app/code/Magento/CatalogSearch/Model/Resource/EngineInterface.php b/app/code/Magento/CatalogSearch/Model/Resource/EngineInterface.php index db6fcf788a7ac..9f02627e83cdd 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/EngineInterface.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/EngineInterface.php @@ -88,7 +88,7 @@ public function prepareEntityIndex($index, $separator = ' '); /** * Return resource model for the full text search * - * @return \Magento\Core\Model\Resource\AbstractResource + * @return \Magento\Model\Resource\AbstractResource */ public function getResource(); diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php index 1df4c1a054ee1..6133ee36f1811 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php @@ -28,7 +28,7 @@ /** * CatalogSearch Fulltext Index resource model */ -class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb +class Fulltext extends \Magento\Model\Resource\Db\AbstractDb { /** * Searchable attributes cache diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Engine.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Engine.php index 58355a682dc12..9b74c9b54f769 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Engine.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Engine.php @@ -32,7 +32,7 @@ * @package Magento_CatalogSearch * @author Magento Core Team */ -class Engine extends \Magento\Core\Model\Resource\Db\AbstractDb implements +class Engine extends \Magento\Model\Resource\Db\AbstractDb implements \Magento\CatalogSearch\Model\Resource\EngineInterface { /** diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Indexer/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Resource/Indexer/Fulltext.php index c13d46af85de8..f172d07f09358 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Indexer/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Indexer/Fulltext.php @@ -32,7 +32,7 @@ * @package Magento_CatalogSearch * @author Magento Core Team */ -class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb +class Fulltext extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection and define catalog product table as main table diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Query.php b/app/code/Magento/CatalogSearch/Model/Resource/Query.php index ea84d7fa39960..e046ff13a9e50 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Query.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Query.php @@ -25,7 +25,7 @@ */ namespace Magento\CatalogSearch\Model\Resource; -use Magento\Core\Model\Resource\Db\AbstractDb; +use Magento\Model\Resource\Db\AbstractDb; /** * Catalog search query resource model @@ -76,11 +76,11 @@ protected function _construct() /** * Custom load model by search query string * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $value * @return $this */ - public function loadByQuery(\Magento\Core\Model\AbstractModel $object, $value) + public function loadByQuery(\Magento\Model\AbstractModel $object, $value) { $select = $this->_getReadAdapter()->select()->from( $this->getMainTable() @@ -107,11 +107,11 @@ public function loadByQuery(\Magento\Core\Model\AbstractModel $object, $value) /** * Custom load model only by query text (skip synonym for) * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $value * @return $this */ - public function loadByQueryText(\Magento\Core\Model\AbstractModel $object, $value) + public function loadByQueryText(\Magento\Model\AbstractModel $object, $value) { $select = $this->_getReadAdapter()->select()->from( $this->getMainTable() @@ -135,12 +135,12 @@ public function loadByQueryText(\Magento\Core\Model\AbstractModel $object, $valu /** * Loading string as a value or regular numeric * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param int|string $value * @param null|string $field * @return $this|AbstractDb */ - public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = null) + public function load(\Magento\Model\AbstractModel $object, $value, $field = null) { if (is_numeric($value)) { return parent::load($object, $value); @@ -151,10 +151,10 @@ public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = } /** - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - public function _beforeSave(\Magento\Core\Model\AbstractModel $object) + public function _beforeSave(\Magento\Model\AbstractModel $object) { $object->setUpdatedAt($this->dateTime->formatDate($this->_date->gmtTimestamp())); return $this; diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php index 494a2418ec1ce..c3999747761df 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php @@ -34,7 +34,7 @@ * @package Magento_CatalogSearch * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Store for filter @@ -65,7 +65,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\CatalogSearch\Model\Resource\Helper $resourceHelper * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -75,7 +75,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\CatalogSearch\Model\Resource\Helper $resourceHelper, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_storeManager = $storeManager; $this->_resourceHelper = $resourceHelper; diff --git a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php b/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php index 286804d618746..fa0fd97dc2151 100644 --- a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php +++ b/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php @@ -69,7 +69,7 @@ public function validatePaymentDataAction() $validator->reset(); $this->_getPayment()->importData($paymentData); $result['authenticationUrl'] = $validator->getAuthenticationStartUrl(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $result['message'] = $e->getMessage(); } catch (\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); diff --git a/app/code/Magento/Centinel/Model/Service.php b/app/code/Magento/Centinel/Model/Service.php index d1186067b1aa3..797de3087f238 100644 --- a/app/code/Magento/Centinel/Model/Service.php +++ b/app/code/Magento/Centinel/Model/Service.php @@ -327,7 +327,7 @@ public function authenticate($data) * * @param \Magento\Object $data * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validate($data) { @@ -350,12 +350,12 @@ public function validate($data) // check whether is authenticated before placing order if ($this->getIsPlaceOrder()) { if ($validationState->getChecksum() != $newChecksum) { - throw new \Magento\Core\Exception(__('Payment information error. Please start over.')); + throw new \Magento\Model\Exception(__('Payment information error. Please start over.')); } if ($validationState->isAuthenticateSuccessful()) { return; } - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Please verify the card with the issuer bank before placing the order.') ); } else { @@ -366,7 +366,7 @@ public function validate($data) if ($validationState->isLookupSuccessful()) { return; } - throw new \Magento\Core\Exception(__('This card has failed validation and cannot be used.')); + throw new \Magento\Model\Exception(__('This card has failed validation and cannot be used.')); } } diff --git a/app/code/Magento/Checkout/Block/Cart.php b/app/code/Magento/Checkout/Block/Cart.php index 50013cc3dd4b7..0dd067767919a 100644 --- a/app/code/Magento/Checkout/Block/Cart.php +++ b/app/code/Magento/Checkout/Block/Cart.php @@ -205,13 +205,13 @@ public function getMethods($alias) * * @param string $name Block name in layout * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getMethodHtml($name) { $block = $this->getLayout()->getBlock($name); if (!$block) { - throw new \Magento\Core\Exception(__('Invalid method: %1', $name)); + throw new \Magento\Model\Exception(__('Invalid method: %1', $name)); } return $block->toHtml(); } diff --git a/app/code/Magento/Checkout/Block/Cart/Crosssell.php b/app/code/Magento/Checkout/Block/Cart/Crosssell.php index 6d2a97eb42d3f..69a01ffb7a363 100644 --- a/app/code/Magento/Checkout/Block/Cart/Crosssell.php +++ b/app/code/Magento/Checkout/Block/Cart/Crosssell.php @@ -89,17 +89,7 @@ class Crosssell extends \Magento\Catalog\Block\Product\AbstractProduct * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\CatalogInventory\Model\Stock $stock, @@ -115,16 +105,6 @@ public function __construct( $this->_itemRelationsList = $itemRelationsList; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Checkout/Controller/Adminhtml/Agreement.php b/app/code/Magento/Checkout/Controller/Adminhtml/Agreement.php index 070b28fa39f73..d361b1e3ed4e4 100644 --- a/app/code/Magento/Checkout/Controller/Adminhtml/Agreement.php +++ b/app/code/Magento/Checkout/Controller/Adminhtml/Agreement.php @@ -124,7 +124,7 @@ public function saveAction() $this->_redirect('checkout/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Something went wrong while saving this condition.')); @@ -153,7 +153,7 @@ public function deleteAction() $this->messageManager->addSuccess(__('The condition has been deleted.')); $this->_redirect('checkout/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Something went wrong while deleting this condition.')); diff --git a/app/code/Magento/Checkout/Controller/Cart.php b/app/code/Magento/Checkout/Controller/Cart.php index 21f802d963f07..546398ee7ae81 100644 --- a/app/code/Magento/Checkout/Controller/Cart.php +++ b/app/code/Magento/Checkout/Controller/Cart.php @@ -250,7 +250,7 @@ public function addAction() } $this->_goBack(); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if ($this->_checkoutSession->getUseNotice(true)) { $this->messageManager->addNotice( $this->_objectManager->get('Magento\Escaper')->escapeHtml($e->getMessage()) @@ -294,7 +294,7 @@ public function addgroupAction() foreach ($itemsCollection as $item) { try { $this->cart->addOrderItem($item, 1); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if ($this->_checkoutSession->getUseNotice(true)) { $this->messageManager->addNotice($e->getMessage()); } else { @@ -376,15 +376,15 @@ public function updateItemOptionsAction() $quoteItem = $this->cart->getQuote()->getItemById($id); if (!$quoteItem) { - throw new \Magento\Core\Exception(__("We can't find the quote item.")); + throw new \Magento\Model\Exception(__("We can't find the quote item.")); } $item = $this->cart->updateItem($id, new \Magento\Object($params)); if (is_string($item)) { - throw new \Magento\Core\Exception($item); + throw new \Magento\Model\Exception($item); } if ($item->getHasError()) { - throw new \Magento\Core\Exception($item->getMessage()); + throw new \Magento\Model\Exception($item->getMessage()); } $related = $this->getRequest()->getParam('related_product'); @@ -410,7 +410,7 @@ public function updateItemOptionsAction() } $this->_goBack(); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if ($this->_checkoutSession->getUseNotice(true)) { $this->messageManager->addNotice($e->getMessage()); } else { @@ -489,7 +489,7 @@ protected function _updateShoppingCart() $this->cart->updateItems($cartData)->save(); } $this->_checkoutSession->setCartWasUpdated(true); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError( $this->_objectManager->get('Magento\Escaper')->escapeHtml($e->getMessage()) ); @@ -509,7 +509,7 @@ protected function _emptyShoppingCart() try { $this->cart->truncate()->save(); $this->_checkoutSession->setCartWasUpdated(true); - } catch (\Magento\Core\Exception $exception) { + } catch (\Magento\Model\Exception $exception) { $this->messageManager->addError($exception->getMessage()); } catch (\Exception $exception) { $this->messageManager->addException($exception, __('We cannot update the shopping cart.')); @@ -631,7 +631,7 @@ public function couponPostAction() } else { $this->messageManager->addSuccess(__('The coupon code was canceled.')); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We cannot apply the coupon code.')); diff --git a/app/code/Magento/Checkout/Controller/Onepage.php b/app/code/Magento/Checkout/Controller/Onepage.php index cac26a84ecdd7..b6e8ad545e79f 100755 --- a/app/code/Magento/Checkout/Controller/Onepage.php +++ b/app/code/Magento/Checkout/Controller/Onepage.php @@ -69,7 +69,7 @@ class Onepage extends Action * @param CustomerAccountService $customerAccountService * @param CustomerMetadataService $customerMetadataService * @param \Magento\Registry $coreRegistry - * @param \Magento\Translate\InlineInterface $translateInline, + * @param \Magento\Translate\InlineInterface $translateInline * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator */ public function __construct( @@ -505,7 +505,7 @@ public function savePaymentAction() $result['fields'] = $e->getFields(); } $result['error'] = $e->getMessage(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $result['error'] = $e->getMessage(); } catch (\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); @@ -617,7 +617,7 @@ public function saveOrderAction() } $result['goto_section'] = 'payment'; $result['update_section'] = array('name' => 'payment-method', 'html' => $this->_getPaymentMethodsHtml()); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); $this->_objectManager->get( 'Magento\Checkout\Helper\Data' diff --git a/app/code/Magento/Checkout/Helper/Data.php b/app/code/Magento/Checkout/Helper/Data.php index 62a66ed98805e..8f8cf1fdd3c92 100644 --- a/app/code/Magento/Checkout/Helper/Data.php +++ b/app/code/Magento/Checkout/Helper/Data.php @@ -77,11 +77,9 @@ class Data extends \Magento\App\Helper\AbstractHelper protected $_transportBuilder; /** - * Translator model - * - * @var \Magento\TranslateInterface + * @var \Magento\Translate\Inline\StateInterface */ - protected $_translator; + protected $inlineTranslation; /** * @param \Magento\App\Helper\Context $context @@ -91,7 +89,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Checkout\Model\Resource\Agreement\CollectionFactory $agreementCollectionFactory * @param \Magento\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\TranslateInterface $translator + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation */ public function __construct( \Magento\App\Helper\Context $context, @@ -101,7 +99,7 @@ public function __construct( \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Checkout\Model\Resource\Agreement\CollectionFactory $agreementCollectionFactory, \Magento\Mail\Template\TransportBuilder $transportBuilder, - \Magento\TranslateInterface $translator + \Magento\Translate\Inline\StateInterface $inlineTranslation ) { $this->_coreStoreConfig = $coreStoreConfig; $this->_storeManager = $storeManager; @@ -109,7 +107,7 @@ public function __construct( $this->_localeDate = $localeDate; $this->_agreementCollectionFactory = $agreementCollectionFactory; $this->_transportBuilder = $transportBuilder; - $this->_translator = $translator; + $this->inlineTranslation = $inlineTranslation; parent::__construct($context); } @@ -246,7 +244,7 @@ public function getBaseSubtotalInclTax($item) */ public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage') { - $this->_translator->setTranslateInline(false); + $this->inlineTranslation->suspend(); $template = $this->_coreStoreConfig->getConfig('checkout/payment_failed/template', $checkout->getStoreId()); @@ -334,7 +332,7 @@ public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'one $transport->sendMessage(); } - $this->_translator->setTranslateInline(true); + $this->inlineTranslation->resume(); return $this; } diff --git a/app/code/Magento/Checkout/Model/Agreement.php b/app/code/Magento/Checkout/Model/Agreement.php index 06c7cb3272971..5f436f67389f7 100644 --- a/app/code/Magento/Checkout/Model/Agreement.php +++ b/app/code/Magento/Checkout/Model/Agreement.php @@ -45,7 +45,7 @@ * @package Magento_Checkout * @author Magento Core Team */ -class Agreement extends \Magento\Core\Model\AbstractModel +class Agreement extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Checkout/Model/Cart.php b/app/code/Magento/Checkout/Model/Cart.php index 0d83b4636360f..174ca475a0b88 100644 --- a/app/code/Magento/Checkout/Model/Cart.php +++ b/app/code/Magento/Checkout/Model/Cart.php @@ -272,7 +272,7 @@ public function addOrderItem($orderItem, $qtyFlag = null) * * @param Product|int|string $productInfo * @return Product - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getProduct($productInfo) { @@ -294,7 +294,7 @@ protected function _getProduct($productInfo) $product->getWebsiteIds() ) ) { - throw new \Magento\Core\Exception(__('We can\'t find the product.')); + throw new \Magento\Model\Exception(__('We can\'t find the product.')); } return $product; } @@ -328,7 +328,7 @@ protected function _getProductRequest($requestInfo) * @param int|Product $productInfo * @param \Magento\Object|int|array $requestInfo * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addProduct($productInfo, $requestInfo = null) { @@ -351,7 +351,7 @@ public function addProduct($productInfo, $requestInfo = null) if ($productId) { try { $result = $this->getQuote()->addProduct($product, $request); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_checkoutSession->setUseNotice(false); $result = $e->getMessage(); } @@ -367,10 +367,10 @@ public function addProduct($productInfo, $requestInfo = null) if ($this->_checkoutSession->getUseNotice() === null) { $this->_checkoutSession->setUseNotice(true); } - throw new \Magento\Core\Exception($result); + throw new \Magento\Model\Exception($result); } } else { - throw new \Magento\Core\Exception(__('The product does not exist.')); + throw new \Magento\Model\Exception(__('The product does not exist.')); } $this->_eventManager->dispatch( @@ -469,7 +469,7 @@ public function suggestItemsQty($data) * * @param array $data * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function updateItems($data) { @@ -494,7 +494,7 @@ public function updateItems($data) $itemInQuote = $this->getQuote()->getItemById($item->getId()); if (!$itemInQuote && $item->getHasError()) { - throw new \Magento\Core\Exception($item->getMessage()); + throw new \Magento\Model\Exception($item->getMessage()); } if (isset($itemInfo['before_suggest_qty']) && $itemInfo['before_suggest_qty'] != $qty) { @@ -644,7 +644,7 @@ public function getItemsQty() * @param int|array|\Magento\Object $requestInfo * @param null|array|\Magento\Object $updatingParams * @return \Magento\Sales\Model\Quote\Item|string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * * @see \Magento\Sales\Model\Quote::updateItem() */ @@ -653,7 +653,7 @@ public function updateItem($itemId, $requestInfo = null, $updatingParams = null) try { $item = $this->getQuote()->getItemById($itemId); if (!$item) { - throw new \Magento\Core\Exception(__('This quote item does not exist.')); + throw new \Magento\Model\Exception(__('This quote item does not exist.')); } $productId = $item->getProduct()->getId(); $product = $this->_getProduct($productId); @@ -672,7 +672,7 @@ public function updateItem($itemId, $requestInfo = null, $updatingParams = null) } $result = $this->getQuote()->updateItem($itemId, $request, $updatingParams); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_checkoutSession->setUseNotice(false); $result = $e->getMessage(); } @@ -684,7 +684,7 @@ public function updateItem($itemId, $requestInfo = null, $updatingParams = null) if ($this->_checkoutSession->getUseNotice() === null) { $this->_checkoutSession->setUseNotice(true); } - throw new \Magento\Core\Exception($result); + throw new \Magento\Model\Exception($result); } $this->_eventManager->dispatch( diff --git a/app/code/Magento/Checkout/Model/Observer.php b/app/code/Magento/Checkout/Model/Observer.php index b76a51080a559..5e4f816462509 100644 --- a/app/code/Magento/Checkout/Model/Observer.php +++ b/app/code/Magento/Checkout/Model/Observer.php @@ -70,7 +70,7 @@ public function loadCustomerQuote() { try { $this->_checkoutSession->loadCustomerQuote(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Load customer quote error')); @@ -78,7 +78,7 @@ public function loadCustomerQuote() } /** - * @param Observer $observer + * @param \Magento\Event\Observer $observer * @return void */ public function salesQuoteSaveAfter($observer) diff --git a/app/code/Magento/Checkout/Model/Resource/Agreement.php b/app/code/Magento/Checkout/Model/Resource/Agreement.php index 1a00d59e00c75..b81de86d77bcd 100644 --- a/app/code/Magento/Checkout/Model/Resource/Agreement.php +++ b/app/code/Magento/Checkout/Model/Resource/Agreement.php @@ -32,7 +32,7 @@ * @package Magento_Checkout * @author Magento Core Team */ -class Agreement extends \Magento\Core\Model\Resource\Db\AbstractDb +class Agreement extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Filter\FilterManager @@ -62,10 +62,10 @@ protected function _construct() /** * Method to run before save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { // format height $height = $object->getContentHeight(); @@ -83,10 +83,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * Method to run after save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { $condition = array('agreement_id = ?' => $object->getId()); $this->_getWriteAdapter()->delete($this->getTable('checkout_agreement_store'), $condition); @@ -104,10 +104,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Method to run after load * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(\Magento\Model\AbstractModel $object) { $select = $this->_getReadAdapter()->select()->from( $this->getTable('checkout_agreement_store'), @@ -128,7 +128,7 @@ protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return \Magento\DB\Select */ protected function _getLoadSelect($field, $value, $object) diff --git a/app/code/Magento/Checkout/Model/Resource/Agreement/Collection.php b/app/code/Magento/Checkout/Model/Resource/Agreement/Collection.php index e30acc0cc6c97..506fa2d9d0d87 100644 --- a/app/code/Magento/Checkout/Model/Resource/Agreement/Collection.php +++ b/app/code/Magento/Checkout/Model/Resource/Agreement/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Checkout * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * @var array diff --git a/app/code/Magento/Checkout/Model/Resource/Cart.php b/app/code/Magento/Checkout/Model/Resource/Cart.php index 5a998769a7f7a..03bac206c72ab 100644 --- a/app/code/Magento/Checkout/Model/Resource/Cart.php +++ b/app/code/Magento/Checkout/Model/Resource/Cart.php @@ -32,7 +32,7 @@ * @package Magento_Checkout * @author Magento Core Team */ -class Cart extends \Magento\Core\Model\Resource\Db\AbstractDb +class Cart extends \Magento\Model\Resource\Db\AbstractDb { /** * Model initialization diff --git a/app/code/Magento/Checkout/Model/Type/AbstractType.php b/app/code/Magento/Checkout/Model/Type/AbstractType.php index 14d23715b74df..beb19d77487b2 100644 --- a/app/code/Magento/Checkout/Model/Type/AbstractType.php +++ b/app/code/Magento/Checkout/Model/Type/AbstractType.php @@ -86,12 +86,7 @@ public function __construct( */ public function getCheckoutSession() { - $checkout = $this->getData('checkout_session'); - if (is_null($checkout)) { - $checkout = $this->_checkoutSession; - $this->setData('checkout_session', $checkout); - } - return $checkout; + return $this->_checkoutSession; } /** diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index 8400919623452..d96ff08318b6d 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -720,18 +720,18 @@ public function savePayment($data) * Validate quote state to be integrated with one page checkout process * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function validate() { $quote = $this->getQuote(); if ($quote->isMultipleShippingAddresses()) { - throw new \Magento\Core\Exception(__('There are more than one shipping address.')); + throw new \Magento\Model\Exception(__('There are more than one shipping address.')); } if ($quote->getCheckoutMethod() == self::METHOD_GUEST && !$this->_helper->isAllowedGuestCheckout($quote)) { - throw new \Magento\Core\Exception(__('Sorry, guest checkout is not enabled.')); + throw new \Magento\Model\Exception(__('Sorry, guest checkout is not enabled.')); } } diff --git a/app/code/Magento/Checkout/etc/module.xml b/app/code/Magento/Checkout/etc/module.xml index 9e017c012420c..7d8b94585ac5e 100644 --- a/app/code/Magento/Checkout/etc/module.xml +++ b/app/code/Magento/Checkout/etc/module.xml @@ -43,7 +43,6 @@ - diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page.php b/app/code/Magento/Cms/Controller/Adminhtml/Page.php index 6c3942777af32..1558c20dfa331 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Page.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page.php @@ -198,7 +198,7 @@ public function saveAction() // go to grid $this->_redirect('*/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong while saving the page.')); diff --git a/app/code/Magento/Cms/Helper/Wysiwyg/Images.php b/app/code/Magento/Cms/Helper/Wysiwyg/Images.php index 1670d97f31748..2277e05a14d32 100644 --- a/app/code/Magento/Cms/Helper/Wysiwyg/Images.php +++ b/app/code/Magento/Cms/Helper/Wysiwyg/Images.php @@ -216,7 +216,7 @@ public function getImageHtmlDeclaration($filename, $renderAsTag = false) * Try to create target directory if it doesn't exist * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getCurrentPath() { @@ -236,7 +236,7 @@ public function getCurrentPath() } } catch (\Magento\Filesystem\FilesystemException $e) { $message = __('The directory %1 is not writable by server.', $currentPath); - throw new \Magento\Core\Exception($message); + throw new \Magento\Model\Exception($message); } $this->_currentPath = $currentPath; } diff --git a/app/code/Magento/Cms/Model/Block.php b/app/code/Magento/Cms/Model/Block.php index 481941f2541e0..e85e19ef652b8 100644 --- a/app/code/Magento/Cms/Model/Block.php +++ b/app/code/Magento/Cms/Model/Block.php @@ -43,7 +43,7 @@ * @method int getIsActive() * @method \Magento\Cms\Model\Block setIsActive(int $value) */ -class Block extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface +class Block extends \Magento\Model\AbstractModel implements \Magento\Object\IdentityInterface { /** * CMS block cache tag @@ -73,8 +73,8 @@ protected function _construct() /** * Prevent blocks recursion * - * @return \Magento\Core\Model\AbstractModel - * @throws \Magento\Core\Exception + * @return \Magento\Model\AbstractModel + * @throws \Magento\Model\Exception */ protected function _beforeSave() { @@ -82,7 +82,7 @@ protected function _beforeSave() if (false == strstr($this->getContent(), $needle)) { return parent::_beforeSave(); } - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Make sure that static block content does not reference the block itself.') ); } diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index 7105114e99287..a0d812747ab3e 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -65,7 +65,7 @@ * @method string getCustomThemeTo() * @method \Magento\Cms\Model\Page setCustomThemeTo(string $value) */ -class Page extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface +class Page extends \Magento\Model\AbstractModel implements \Magento\Object\IdentityInterface { /** * No route page id diff --git a/app/code/Magento/Cms/Model/Page/Urlrewrite.php b/app/code/Magento/Cms/Model/Page/Urlrewrite.php index 926156b483cb1..d1975756b0275 100644 --- a/app/code/Magento/Cms/Model/Page/Urlrewrite.php +++ b/app/code/Magento/Cms/Model/Page/Urlrewrite.php @@ -34,7 +34,7 @@ * @method \Magento\Cms\Model\Page\Urlrewrite setCmsPageId() setCmsPageId(int) * @method \Magento\Cms\Model\Page\Urlrewrite setUrlRewriteId() setUrlRewriteId(int) */ -class Urlrewrite extends \Magento\Core\Model\AbstractModel +class Urlrewrite extends \Magento\Model\AbstractModel { /** * Initialize resource model diff --git a/app/code/Magento/Cms/Model/Resource/Block.php b/app/code/Magento/Cms/Model/Resource/Block.php index 02609aac090bb..6e09e906d4833 100644 --- a/app/code/Magento/Cms/Model/Resource/Block.php +++ b/app/code/Magento/Cms/Model/Resource/Block.php @@ -28,7 +28,7 @@ /** * CMS block model */ -class Block extends \Magento\Core\Model\Resource\Db\AbstractDb +class Block extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Stdlib\DateTime\DateTime @@ -72,10 +72,10 @@ protected function _construct() /** * Process block data before deleting * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return \Magento\Cms\Model\Resource\Page */ - protected function _beforeDelete(\Magento\Core\Model\AbstractModel $object) + protected function _beforeDelete(\Magento\Model\AbstractModel $object) { $condition = array('block_id = ?' => (int)$object->getId()); @@ -87,14 +87,14 @@ protected function _beforeDelete(\Magento\Core\Model\AbstractModel $object) /** * Perform operations before object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { if (!$this->getIsUniqueBlockToStores($object)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('A block identifier with the same properties already exists in the selected store.') ); } @@ -109,10 +109,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * Perform operations after object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { $oldStores = $this->lookupStoreIds($object->getId()); $newStores = (array)$object->getStores(); @@ -143,12 +143,12 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Load an object using 'identifier' field if there's no field specified and value is not numeric * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param mixed $value * @param string $field * @return $this */ - public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = null) + public function load(\Magento\Model\AbstractModel $object, $value, $field = null) { if (!is_numeric($value) && is_null($field)) { $field = 'identifier'; @@ -160,10 +160,10 @@ public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = /** * Perform operations after object load * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(\Magento\Model\AbstractModel $object) { if ($object->getId()) { $stores = $this->lookupStoreIds($object->getId()); @@ -212,10 +212,10 @@ protected function _getLoadSelect($field, $value, $object) /** * Check for unique of identifier of block to selected store(s). * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return bool */ - public function getIsUniqueBlockToStores(\Magento\Core\Model\AbstractModel $object) + public function getIsUniqueBlockToStores(\Magento\Model\AbstractModel $object) { if ($this->_storeManager->hasSingleStore()) { $stores = array(\Magento\Core\Model\Store::DEFAULT_STORE_ID); diff --git a/app/code/Magento/Cms/Model/Resource/Block/Collection.php b/app/code/Magento/Cms/Model/Resource/Block/Collection.php index d8a707580a9a9..6c58d6661827e 100644 --- a/app/code/Magento/Cms/Model/Resource/Block/Collection.php +++ b/app/code/Magento/Cms/Model/Resource/Block/Collection.php @@ -28,7 +28,7 @@ /** * CMS block model */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Define resource model diff --git a/app/code/Magento/Cms/Model/Resource/Page.php b/app/code/Magento/Cms/Model/Resource/Page.php index 8b9b4b4e2669c..ee8cc0a11a99c 100644 --- a/app/code/Magento/Cms/Model/Resource/Page.php +++ b/app/code/Magento/Cms/Model/Resource/Page.php @@ -28,7 +28,7 @@ /** * Cms page mysql resource */ -class Page extends \Magento\Core\Model\Resource\Db\AbstractDb +class Page extends \Magento\Model\Resource\Db\AbstractDb { /** * Store model @@ -95,10 +95,10 @@ protected function _construct() /** * Process page data before deleting * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _beforeDelete(\Magento\Core\Model\AbstractModel $object) + protected function _beforeDelete(\Magento\Model\AbstractModel $object) { $condition = array('page_id = ?' => (int)$object->getId()); @@ -110,11 +110,11 @@ protected function _beforeDelete(\Magento\Core\Model\AbstractModel $object) /** * Process page data before saving * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { /* * For two attributes which represent timestamp data in DB @@ -132,15 +132,15 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) } if (!$this->getIsUniquePageToStores($object)) { - throw new \Magento\Core\Exception(__('A page URL key for specified store already exists.')); + throw new \Magento\Model\Exception(__('A page URL key for specified store already exists.')); } if (!$this->isValidPageIdentifier($object)) { - throw new \Magento\Core\Exception(__('The page URL key contains capital letters or disallowed symbols.')); + throw new \Magento\Model\Exception(__('The page URL key contains capital letters or disallowed symbols.')); } if ($this->isNumericPageIdentifier($object)) { - throw new \Magento\Core\Exception(__('The page URL key cannot be made of only numbers.')); + throw new \Magento\Model\Exception(__('The page URL key cannot be made of only numbers.')); } // modify create / update dates @@ -156,10 +156,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * Assign page to store views * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { $oldStores = $this->lookupStoreIds($object->getId()); $newStores = (array)$object->getStores(); @@ -192,12 +192,12 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Load an object using 'identifier' field if there's no field specified and value is not numeric * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param mixed $value * @param string $field * @return $this */ - public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = null) + public function load(\Magento\Model\AbstractModel $object, $value, $field = null) { if (!is_numeric($value) && is_null($field)) { $field = 'identifier'; @@ -209,10 +209,10 @@ public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = /** * Perform operations after object load * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(\Magento\Model\AbstractModel $object) { if ($object->getId()) { $stores = $this->lookupStoreIds($object->getId()); @@ -291,10 +291,10 @@ protected function _getLoadByIdentifierSelect($identifier, $store, $isActive = n /** * Check for unique of identifier of page to selected store(s). * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return bool */ - public function getIsUniquePageToStores(\Magento\Core\Model\AbstractModel $object) + public function getIsUniquePageToStores(\Magento\Model\AbstractModel $object) { if ($this->_storeManager->hasSingleStore() || !$object->hasStores()) { $stores = array(\Magento\Core\Model\Store::DEFAULT_STORE_ID); @@ -318,10 +318,10 @@ public function getIsUniquePageToStores(\Magento\Core\Model\AbstractModel $objec /** * Check whether page identifier is numeric * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return bool */ - protected function isNumericPageIdentifier(\Magento\Core\Model\AbstractModel $object) + protected function isNumericPageIdentifier(\Magento\Model\AbstractModel $object) { return preg_match('/^[0-9]+$/', $object->getData('identifier')); } @@ -329,10 +329,10 @@ protected function isNumericPageIdentifier(\Magento\Core\Model\AbstractModel $ob /** * Check whether page identifier is valid * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return bool */ - protected function isValidPageIdentifier(\Magento\Core\Model\AbstractModel $object) + protected function isValidPageIdentifier(\Magento\Model\AbstractModel $object) { return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('identifier')); } diff --git a/app/code/Magento/Cms/Model/Resource/Page/Collection.php b/app/code/Magento/Cms/Model/Resource/Page/Collection.php index 4bd37f0b4b1f2..82266142b42f4 100644 --- a/app/code/Magento/Cms/Model/Resource/Page/Collection.php +++ b/app/code/Magento/Cms/Model/Resource/Page/Collection.php @@ -28,7 +28,7 @@ /** * CMS page collection */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Load data for preview flag @@ -51,7 +51,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -60,7 +60,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Cms/Model/Resource/Page/Service.php b/app/code/Magento/Cms/Model/Resource/Page/Service.php index f086a414dc0a2..6abea9a00e391 100644 --- a/app/code/Magento/Cms/Model/Resource/Page/Service.php +++ b/app/code/Magento/Cms/Model/Resource/Page/Service.php @@ -28,7 +28,7 @@ /** * Cms page service resource model */ -class Service extends \Magento\Core\Model\Resource\Db\AbstractDb +class Service extends \Magento\Model\Resource\Db\AbstractDb { /** * Init cms page service model diff --git a/app/code/Magento/Cms/Model/Resource/Page/Urlrewrite.php b/app/code/Magento/Cms/Model/Resource/Page/Urlrewrite.php index c9affbccfb6ec..f859a465cc66c 100644 --- a/app/code/Magento/Cms/Model/Resource/Page/Urlrewrite.php +++ b/app/code/Magento/Cms/Model/Resource/Page/Urlrewrite.php @@ -28,7 +28,7 @@ /** * Cms page url rewrite resource model */ -class Urlrewrite extends \Magento\Core\Model\Resource\Db\AbstractDb +class Urlrewrite extends \Magento\Model\Resource\Db\AbstractDb { /** * Init cms page urlrewrite model diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php index 6fbccb158936f..8f5cad2c4fe10 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php @@ -353,12 +353,12 @@ public function getCollection($path = null) * @param string $name New directory name * @param string $path Parent directory path * @return array New directory info - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function createDirectory($name, $path) { if (!preg_match(self::DIRECTORY_NAME_REGEXP, $name)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Please correct the folder name. Use only letters, numbers, underscores and dashes.') ); } @@ -371,7 +371,7 @@ public function createDirectory($name, $path) $newPath = $path . '/' . $name; $relativeNewPath = $this->_directory->getRelativePath($newPath); if ($this->_directory->isDirectory($relativeNewPath)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We found a directory with the same name. Please try another folder name.') ); } @@ -391,7 +391,7 @@ public function createDirectory($name, $path) ); return $result; } catch (\Magento\Filesystem\FilesystemException $e) { - throw new \Magento\Core\Exception(__('We cannot create a new directory.')); + throw new \Magento\Model\Exception(__('We cannot create a new directory.')); } } @@ -400,7 +400,7 @@ public function createDirectory($name, $path) * * @param string $path Target dir * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function deleteDirectory($path) { @@ -412,7 +412,7 @@ public function deleteDirectory($path) $path = $this->getThumbnailRoot() . $this->_getRelativePathToRoot($path); $this->_deleteByPath($path); } catch (\Magento\Filesystem\FilesystemException $e) { - throw new \Magento\Core\Exception(__('We cannot delete directory %1.', $path)); + throw new \Magento\Model\Exception(__('We cannot delete directory %1.', $path)); } } @@ -462,7 +462,7 @@ public function deleteFile($target) * @param string $targetPath Target directory * @param string $type Type of storage, e.g. image, media etc. * @return array File info Array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function uploadFile($targetPath, $type = null) { @@ -477,7 +477,7 @@ public function uploadFile($targetPath, $type = null) $result = $uploader->save($targetPath); if (!$result) { - throw new \Magento\Core\Exception(__('We cannot upload the file.')); + throw new \Magento\Model\Exception(__('We cannot upload the file.')); } // create thumbnail @@ -699,16 +699,16 @@ public function getCmsWysiwygImages() * * @param string $path * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _validatePath($path) { $root = $this->_sanitizePath($this->_cmsWysiwygImages->getStorageRoot()); if ($root == $path) { - throw new \Magento\Core\Exception(__('We cannot delete root directory %1.', $path)); + throw new \Magento\Model\Exception(__('We cannot delete root directory %1.', $path)); } if (strpos($path, $root) !== 0) { - throw new \Magento\Core\Exception(__('Directory %1 is not under storage root path.', $path)); + throw new \Magento\Model\Exception(__('Directory %1 is not under storage root path.', $path)); } } diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php index a378517648bb2..2d9df1edd2935 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php @@ -27,6 +27,7 @@ use Magento\Catalog\Model\Product\PriceModifierInterface; use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface as CustomerAccountService; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -60,14 +61,14 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView protected $_jsonEncoder; /** - * @var \Magento\Catalog\Helper\Image + * @var \Magento\Catalog\Helper\Product\Price */ - protected $_imageHelper; + protected $priceHelper; /** - * @var \Magento\Catalog\Helper\Product\Price + * @var CustomerAccountService */ - protected $priceHelper; + protected $_customerAccountService; /** * @var \Magento\Catalog\Model\Product\PriceModifierInterface @@ -91,48 +92,30 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\Catalog\Helper\Product\Price $priceHelper * @param \Magento\Catalog\Model\Product\PriceModifierInterface $priceModifier + * @param CustomerAccountService $customerAccountService * @param array $data * @param array $priceBlockTypes * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Stdlib\ArrayUtils $arrayUtils, \Magento\Json\EncoderInterface $jsonEncoder, \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Catalog\Helper\Product\Price $priceHelper, + CustomerAccountService $customerAccountService, PriceModifierInterface $priceModifier, array $data = array(), array $priceBlockTypes = array() ) { - $this->_imageHelper = $imageHelper; $this->_catalogProduct = $catalogProduct; $this->_jsonEncoder = $jsonEncoder; $this->priceHelper = $priceHelper; $this->priceModifier = $priceModifier; + $this->_customerAccountService = $customerAccountService; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $arrayUtils, $data, $priceBlockTypes @@ -321,9 +304,12 @@ public function getJsonConfig() } } - if (!$this->priceHelper->getCustomer() && $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER) + + if (is_null($this->priceHelper->getCustomer()->getId()) + && $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID) ) { - $this->priceHelper->setCustomer($this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER)); + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->priceHelper->setCustomer($this->_customerAccountService->getCustomer($customerId)); } $_request = $this->priceHelper->getRateRequest(false, false, false); diff --git a/app/code/Magento/ConfigurableProduct/Model/Attribute/LockValidator.php b/app/code/Magento/ConfigurableProduct/Model/Attribute/LockValidator.php index 6d6efe9979e91..fcbac59d429a5 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Attribute/LockValidator.php +++ b/app/code/Magento/ConfigurableProduct/Model/Attribute/LockValidator.php @@ -43,13 +43,13 @@ public function __construct(\Magento\App\Resource $resource) /** * Check attribute lock state * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param null $attributeSet - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * * @return void */ - public function validate(\Magento\Core\Model\AbstractModel $object, $attributeSet = null) + public function validate(\Magento\Model\AbstractModel $object, $attributeSet = null) { $adapter = $this->resource->getConnection('read'); $attrTable = $this->resource->getTableName('catalog_product_super_attribute'); @@ -77,7 +77,7 @@ public function validate(\Magento\Core\Model\AbstractModel $object, $attributeSe } if ($adapter->fetchOne($select, $bind)) { - throw new \Magento\Core\Exception(__('This attribute is used in configurable products.')); + throw new \Magento\Model\Exception(__('This attribute is used in configurable products.')); } } } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 66079b7bd7ae4..c11a465980070 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -803,7 +803,7 @@ protected function _prepareProduct(\Magento\Object $buyRequest, $product, $proce * * @param \Magento\Catalog\Model\Product $product * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function checkProductBuyState($product) { @@ -820,7 +820,7 @@ public function checkProductBuyState($product) } } if (empty($attributes)) { - throw new \Magento\Core\Exception($this->getSpecifyOptionMessage()); + throw new \Magento\Model\Exception($this->getSpecifyOptionMessage()); } } return $this; diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php index c1cf918e76cd4..8eb6401706f75 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php @@ -37,7 +37,7 @@ * @method Attribute setProductAttribute(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $value) * @method \Magento\Eav\Model\Entity\Attribute\AbstractAttribute getProductAttribute() */ -class Attribute extends \Magento\Core\Model\AbstractModel +class Attribute extends \Magento\Model\AbstractModel { /** * Initialize resource model diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php index 8b86dfd8b5b46..4eb75a09e5bcd 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php @@ -25,7 +25,7 @@ */ namespace Magento\ConfigurableProduct\Model\Resource\Product\Type; -class Configurable extends \Magento\Core\Model\Resource\Db\AbstractDb +class Configurable extends \Magento\Model\Resource\Db\AbstractDb { /** * Catalog product relation diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php index b72c0c90d08bd..26baad63213b6 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php @@ -25,7 +25,7 @@ */ namespace Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable; -class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb +class Attribute extends \Magento\Model\Resource\Db\AbstractDb { /** * Label table name cache diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php index 073a180ee5ac8..3d77f0eec6be8 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php @@ -28,7 +28,7 @@ /** * @SuppressWarnings(PHPMD.LongVariable) */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Configurable attributes label table name diff --git a/app/code/Magento/ConfigurableProduct/etc/module.xml b/app/code/Magento/ConfigurableProduct/etc/module.xml index ebf21c52ff73d..1536277354743 100644 --- a/app/code/Magento/ConfigurableProduct/etc/module.xml +++ b/app/code/Magento/ConfigurableProduct/etc/module.xml @@ -37,9 +37,7 @@ - - diff --git a/app/code/Magento/Connect/Controller/Adminhtml/Extension/Custom.php b/app/code/Magento/Connect/Controller/Adminhtml/Extension/Custom.php index 22190e370652e..108c7b7de6cdd 100644 --- a/app/code/Magento/Connect/Controller/Adminhtml/Extension/Custom.php +++ b/app/code/Magento/Connect/Controller/Adminhtml/Extension/Custom.php @@ -85,7 +85,7 @@ public function loadAction() try { $data = $this->_objectManager->get('Magento\Connect\Helper\Data')->loadLocalPackage($packageName); if (!$data) { - throw new \Magento\Core\Exception(__('Something went wrong loading the package data.')); + throw new \Magento\Model\Exception(__('Something went wrong loading the package data.')); } $data = array_merge($data, array('file_name' => $packageName)); $session->setCustomExtensionPackageFormData($data); @@ -132,7 +132,7 @@ public function saveAction() } else { $this->_forward('create'); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect('adminhtml/*'); } catch (\Exception $e) { @@ -164,7 +164,7 @@ public function createAction() } } $this->_redirect('adminhtml/*'); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect('adminhtml/*'); } catch (\Exception $e) { diff --git a/app/code/Magento/Connect/Model/Extension.php b/app/code/Magento/Connect/Model/Extension.php index aa63b0a615837..182f244818c9f 100644 --- a/app/code/Magento/Connect/Model/Extension.php +++ b/app/code/Magento/Connect/Model/Extension.php @@ -112,7 +112,7 @@ protected function getPackage() * Set package object * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function generatePackageXml() { @@ -121,7 +121,7 @@ public function generatePackageXml() $this->_setPackage()->_setRelease()->_setAuthors()->_setDependencies()->_setContents(); if (!$this->getPackage()->validate()) { $message = $this->getPackage()->getErrors(); - throw new \Magento\Core\Exception(__($message[0])); + throw new \Magento\Model\Exception(__($message[0])); } $this->setPackageXml($this->getPackage()->getPackageXml()); return $this; diff --git a/app/code/Magento/Contacts/Controller/Index.php b/app/code/Magento/Contacts/Controller/Index.php index 75a1b8a2755e2..3797bee1694e0 100644 --- a/app/code/Magento/Contacts/Controller/Index.php +++ b/app/code/Magento/Contacts/Controller/Index.php @@ -51,16 +51,24 @@ class Index extends \Magento\App\Action\Action */ protected $_transportBuilder; + /** + * @var \Magento\Translate\Inline\StateInterface + */ + protected $inlineTranslation; + /** * @param \Magento\App\Action\Context $context * @param \Magento\Mail\Template\TransportBuilder $transportBuilder + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation */ public function __construct( \Magento\App\Action\Context $context, - \Magento\Mail\Template\TransportBuilder $transportBuilder + \Magento\Mail\Template\TransportBuilder $transportBuilder, + \Magento\Translate\Inline\StateInterface $inlineTranslation ) { parent::__construct($context); $this->_transportBuilder = $transportBuilder; + $this->inlineTranslation = $inlineTranslation; } /** @@ -110,9 +118,7 @@ public function postAction() } $post = $this->getRequest()->getPost(); if ($post) { - $translate = $this->_objectManager->get('Magento\TranslateInterface'); - /* @var $translate \Magento\TranslateInterface */ - $translate->setTranslateInline(false); + $this->inlineTranslation->suspend(); try { $postObject = new \Magento\Object(); $postObject->setData($post); @@ -160,7 +166,7 @@ public function postAction() $transport->sendMessage(); - $translate->setTranslateInline(true); + $this->inlineTranslation->resume(); $this->messageManager->addSuccess( __('Thanks for contacting us with your comments and questions. We\'ll respond to you very soon.') @@ -169,7 +175,7 @@ public function postAction() return; } catch (\Exception $e) { - $translate->setTranslateInline(true); + $this->inlineTranslation->resume(); $this->messageManager->addError( __('We can\'t process your request right now. Sorry, that\'s all we know.') ); diff --git a/app/code/Magento/Core/App/Media.php b/app/code/Magento/Core/App/Media.php index ed02ec0db153d..0e6ee61c19262 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; -use Magento\LauncherInterface; +use Magento\AppInterface; use Magento\ObjectManager; use Magento\Core\Model\File\Storage\Request; use Magento\Core\Model\File\Storage\Response; -class Media implements LauncherInterface +class Media implements AppInterface { /** * @var \Magento\App\State diff --git a/app/code/Magento/Core/Controller/Ajax.php b/app/code/Magento/Core/Controller/Ajax.php deleted file mode 100644 index 655743862ace7..0000000000000 --- a/app/code/Magento/Core/Controller/Ajax.php +++ /dev/null @@ -1,43 +0,0 @@ -getRequest()->getPost('translate'); - $area = $this->getRequest()->getPost('area'); - /** @var \Magento\Core\Helper\Translate $translationHelper */ - $translationHelper = $this->_objectManager->get('Magento\Core\Helper\Translate'); - $response = $translationHelper->apply($translationParams, $area); - $this->getResponse()->setBody($response); - $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); - } -} diff --git a/app/code/Magento/Core/Helper/Data.php b/app/code/Magento/Core/Helper/Data.php index 271d3663afdbf..f057e775345a1 100644 --- a/app/code/Magento/Core/Helper/Data.php +++ b/app/code/Magento/Core/Helper/Data.php @@ -226,11 +226,7 @@ public function getCacheTypes() public function jsonEncode($valueToEncode, $cycleCheck = false, $options = array()) { $json = \Zend_Json::encode($valueToEncode, $cycleCheck, $options); - $translateInline = $this->_inlineFactory->get(); - if ($translateInline->isAllowed()) { - $translateInline->processResponseBody($json, true); - } - + $this->translateInline->processResponseBody($json, true); return $json; } diff --git a/app/code/Magento/Core/Helper/File/Media.php b/app/code/Magento/Core/Helper/File/Media.php index c8508b598b323..ac82cbec2115e 100644 --- a/app/code/Magento/Core/Helper/File/Media.php +++ b/app/code/Magento/Core/Helper/File/Media.php @@ -69,7 +69,7 @@ public function __construct( * @param string $mediaDirectory * @param string $path * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function collectFileInfo($mediaDirectory, $path) { @@ -79,10 +79,10 @@ public function collectFileInfo($mediaDirectory, $path) $dir = $this->filesystem->getDirectoryRead(\Magento\App\Filesystem::MEDIA_DIR); $relativePath = $dir->getRelativePath($fullPath); if (!$dir->isFile($relativePath)) { - throw new \Magento\Core\Exception(__('File %1 does not exist', $fullPath)); + throw new \Magento\Model\Exception(__('File %1 does not exist', $fullPath)); } if (!$dir->isReadable($relativePath)) { - throw new \Magento\Core\Exception(__('File %1 is not readable', $fullPath)); + throw new \Magento\Model\Exception(__('File %1 is not readable', $fullPath)); } $path = str_replace(array('/', '\\'), '/', $path); diff --git a/app/code/Magento/Core/Helper/File/Storage.php b/app/code/Magento/Core/Helper/File/Storage.php index 745f116609c85..fa0fe188804e9 100644 --- a/app/code/Magento/Core/Helper/File/Storage.php +++ b/app/code/Magento/Core/Helper/File/Storage.php @@ -139,7 +139,7 @@ public function isInternalStorage($storage = null) * * @param int|null $storage * @param array $params - * @return \Magento\Core\Model\AbstractModel|bool + * @return \Magento\Model\AbstractModel|bool */ public function getStorageModel($storage = null, $params = array()) { diff --git a/app/code/Magento/Core/Helper/Js.php b/app/code/Magento/Core/Helper/Js.php index 7e94efea9b06e..d5d2c51e8b6a6 100644 --- a/app/code/Magento/Core/Helper/Js.php +++ b/app/code/Magento/Core/Helper/Js.php @@ -36,45 +36,25 @@ class Js extends \Magento\App\Helper\AbstractHelper * * @var array */ - protected $_translateData = null; + protected $_translateData = []; /** * @var \Magento\View\Url */ protected $_viewUrl; - /** - * Core data - * - * @var \Magento\Core\Helper\Data - */ - protected $_coreData = null; - /** * @param \Magento\App\Helper\Context $context - * @param \Magento\Core\Helper\Data $coreData * @param \Magento\View\Url $viewUrl */ public function __construct( \Magento\App\Helper\Context $context, - \Magento\Core\Helper\Data $coreData, \Magento\View\Url $viewUrl ) { - $this->_coreData = $coreData; parent::__construct($context); $this->_viewUrl = $viewUrl; } - /** - * Retrieve JSON of JS sentences translation - * - * @return string - */ - public function getTranslateJson() - { - return $this->_coreData->jsonEncode($this->getTranslateData()); - } - /** * Retrieve JS translator initialization javascript * @@ -82,7 +62,9 @@ public function getTranslateJson() */ public function getTranslatorScript() { - $script = '(function($) {$.mage.translate.add(' . $this->getTranslateJson() . ')})(jQuery);'; + $script = '(function($) {$.mage.translate.add(' + . $this->encode($this->getTranslateData()) + . ')})(jQuery);'; return $this->getScript($script); } @@ -115,8 +97,7 @@ public function includeScript($file) */ public function getTranslateData() { - if ($this->_translateData === null) { - $this->_translateData = array(); + if (!$this->_translateData) { $this->_populateTranslateData(); } return $this->_translateData; @@ -470,4 +451,17 @@ protected function _addTranslation($key, $translatedText) $this->_translateData[$key] = $translatedText; } } + + /** + * Encode the mixed $data into the JSON format. + * + * @param mixed $data + * @return string + */ + public function encode($data) + { + $json = \Zend_Json::encode($data); + $this->translateInline->processResponseBody($json, false); + return $json; + } } diff --git a/app/code/Magento/Core/Helper/Url/Rewrite.php b/app/code/Magento/Core/Helper/Url/Rewrite.php index 3b86260399c17..d6f5b33c8de30 100644 --- a/app/code/Magento/Core/Helper/Url/Rewrite.php +++ b/app/code/Magento/Core/Helper/Url/Rewrite.php @@ -90,7 +90,7 @@ protected function _validateRequestPath($requestPath) * Either returns TRUE (success) or throws error (validation failed) * * @param string $requestPath - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ public function validateRequestPath($requestPath) @@ -98,7 +98,7 @@ public function validateRequestPath($requestPath) try { $this->_validateRequestPath($requestPath); } catch (\Exception $e) { - throw new \Magento\Core\Exception($e->getMessage()); + throw new \Magento\Model\Exception($e->getMessage()); } return true; } @@ -108,7 +108,7 @@ public function validateRequestPath($requestPath) * Either returns TRUE (success) or throws error (validation failed) * * @param string $suffix - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ public function validateSuffix($suffix) @@ -120,11 +120,11 @@ public function validateSuffix($suffix) // Make message saying about suffix, not request path switch ($e->getCode()) { case self::VERR_MANYSLASHES: - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Two and more slashes together are not permitted in url rewrite suffix') ); case self::VERR_ANCHOR: - throw new \Magento\Core\Exception(__('Anchor symbol (#) is not supported in url rewrite suffix')); + throw new \Magento\Model\Exception(__('Anchor symbol (#) is not supported in url rewrite suffix')); } } return true; diff --git a/app/code/Magento/Core/Model/App.php b/app/code/Magento/Core/Model/App.php deleted file mode 100644 index b8c919830afdf..0000000000000 --- a/app/code/Magento/Core/Model/App.php +++ /dev/null @@ -1,479 +0,0 @@ -_config = $config; - $this->_cache = $cache; - $this->_objectManager = $objectManager; - $this->_appState = $appState; - $this->_eventManager = $eventManager; - $this->_configScope = $configScope; - } - - /** - * Throw an exception, if the application has not been installed yet - * - * @return void - * @throws \Magento\Exception - */ - public function requireInstalledInstance() - { - if (false == $this->_appState->isInstalled()) { - throw new \Magento\Exception('Application is not installed yet, please complete the installation first.'); - } - } - - /** - * Retrieve cookie object - * - * @return \Magento\Stdlib\Cookie - */ - public function getCookie() - { - return $this->_objectManager->get('Magento\Stdlib\Cookie'); - } - - /** - * Re-declare custom error handler - * - * @param string $handler - * @return $this - */ - public function setErrorHandler($handler) - { - set_error_handler($handler); - return $this; - } - - /** - * Loading part of area data - * - * @param string $area - * @param string $part - * @return $this - */ - public function loadAreaPart($area, $part) - { - $this->getArea($area)->load($part); - return $this; - } - - /** - * Retrieve application area - * - * @param string $code - * @return \Magento\Core\Model\App\Area - */ - public function getArea($code) - { - if (!isset($this->_areas[$code])) { - $this->_areas[$code] = $this->_objectManager->create( - 'Magento\Core\Model\App\Area', - array('areaCode' => $code) - ); - } - return $this->_areas[$code]; - } - - /** - * Get distro locale code - * - * @return string - */ - public function getDistroLocaleCode() - { - return self::DISTRO_LOCALE_CODE; - } - - /** - * Retrieve layout object - * - * @return \Magento\View\LayoutInterface - */ - public function getLayout() - { - return $this->_objectManager->get('Magento\View\LayoutInterface'); - } - - /** - * Retrieve application base currency code - * - * @return string - */ - public function getBaseCurrencyCode() - { - return $this->_config->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default'); - } - - /** - * Retrieve configuration object - * - * @return \Magento\App\ConfigInterface - */ - public function getConfig() - { - return $this->_config; - } - - /** - * Get core cache model - * - * @return \Magento\App\CacheInterface - */ - public function getCacheInstance() - { - return $this->_cache; - } - - /** - * Retrieve cache object - * - * @return \Magento\Cache\FrontendInterface - */ - public function getCache() - { - return $this->_cache->getFrontend(); - } - - /** - * Loading cache data - * - * @param string $cacheId - * @return string - */ - public function loadCache($cacheId) - { - return $this->_cache->load($cacheId); - } - - /** - * Saving cache data - * - * @param mixed $data - * @param string $cacheId - * @param array $tags - * @param bool $lifeTime - * @return $this - */ - public function saveCache($data, $cacheId, $tags = array(), $lifeTime = false) - { - $this->_cache->save($data, $cacheId, $tags, $lifeTime); - return $this; - } - - /** - * Remove cache - * - * @param string $cacheId - * @return $this - */ - public function removeCache($cacheId) - { - $this->_cache->remove($cacheId); - return $this; - } - - /** - * Cleaning cache - * - * @param array $tags - * @return $this - */ - public function cleanCache($tags = array()) - { - $this->_cache->clean($tags); - return $this; - } - - /** - * Deletes all session files - * - * @return $this - */ - public function cleanAllSessions() - { - if (session_module_name() == 'files') { - /** @var \Magento\App\Filesystem $filesystem */ - $filesystem = $this->_objectManager->create('Magento\App\Filesystem'); - $sessionDirectory = $filesystem->getDirectoryWrite(\Magento\App\Filesystem::SESSION_DIR); - foreach ($sessionDirectory->read() as $path) { - $sessionDirectory->delete($path); - } - } - return $this; - } - - /** - * Retrieve request object - * - * @return \Magento\App\RequestInterface - */ - public function getRequest() - { - if (!$this->_request) { - $this->_request = $this->_objectManager->get('Magento\App\RequestInterface'); - } - return $this->_request; - } - - /** - * Request setter - * - * @param \Magento\App\RequestInterface $request - * @return $this - */ - public function setRequest(\Magento\App\RequestInterface $request) - { - $this->_request = $request; - return $this; - } - - /** - * Retrieve response object - * - * @return \Magento\App\ResponseInterface - */ - public function getResponse() - { - if (!$this->_response) { - $this->_response = $this->_objectManager->get('Magento\App\ResponseInterface'); - $this->_response->setHeader('Content-Type', 'text/html; charset=UTF-8'); - } - return $this->_response; - } - - /** - * Response setter - * - * @param \Magento\App\ResponseInterface $response - * @return $this - */ - public function setResponse(\Magento\App\ResponseInterface $response) - { - $this->_response = $response; - return $this; - } - - /** - * Check if developer mode is enabled - * - * @return bool - */ - public function isDeveloperMode() - { - return $this->_appState->getMode() == \Magento\App\State::MODE_DEVELOPER; - } - - /** - * Get current Magento edition - * - * @static - * @return string - */ - public function getEdition() - { - return $this->_currentEdition; - } - - /** - * Set edition - * - * @param string $edition - * @return void - */ - public function setEdition($edition) - { - $this->_currentEdition = $edition; - } - - /** - * Gets the current Magento version string - * @link http://www.magentocommerce.com/blog/new-community-edition-release-process/ - * - * @return string - */ - public function getVersion() - { - $info = $this->getVersionInfo(); - return trim( - "{$info['major']}.{$info['minor']}.{$info['revision']}" . ($info['patch'] != - '' ? ".{$info['patch']}" : "") . "-{$info['stability']}{$info['number']}", - '.-' - ); - } - - /** - * Gets the detailed Magento version information - * @link http://www.magentocommerce.com/blog/new-community-edition-release-process/ - * - * @return array - */ - public function getVersionInfo() - { - return array( - 'major' => '2', - 'minor' => '0', - 'revision' => '0', - 'patch' => '0', - 'stability' => 'dev', - 'number' => '70', - ); - } -} diff --git a/app/code/Magento/Core/Model/App/Area.php b/app/code/Magento/Core/Model/App/Area.php index 819248628687c..7460dae9e79ce 100644 --- a/app/code/Magento/Core/Model/App/Area.php +++ b/app/code/Magento/Core/Model/App/Area.php @@ -31,19 +31,13 @@ */ namespace Magento\Core\Model\App; -class Area +class Area implements \Magento\App\AreaInterface { const AREA_GLOBAL = 'global'; const AREA_FRONTEND = 'frontend'; - - const AREA_ADMIN = 'admin'; - - const PART_CONFIG = 'config'; - - const PART_TRANSLATE = 'translate'; - - const PART_DESIGN = 'design'; + + const AREA_ADMIN = 'admin'; /** * Area parameter. @@ -277,15 +271,10 @@ protected function _initConfig() */ protected function _initTranslate() { - $dispatchResult = new \Magento\Object(array('inline_type' => null, 'params' => array('area' => $this->_code))); - $eventManager = $this->_objectManager->get('Magento\Event\ManagerInterface'); - $eventManager->dispatch( - 'translate_initialization_before', - array('translate_object' => $this->_translator, 'result' => $dispatchResult) - ); - $this->_translator->init(null, $dispatchResult, false); + $this->_translator->loadData(null, false); \Magento\Phrase::setRenderer($this->_objectManager->get('Magento\Phrase\RendererInterface')); + return $this; } diff --git a/app/code/Magento/Core/Model/App/Emulation.php b/app/code/Magento/Core/Model/App/Emulation.php index d8c1179adb6c2..68341b83b7c1d 100644 --- a/app/code/Magento/Core/Model/App/Emulation.php +++ b/app/code/Magento/Core/Model/App/Emulation.php @@ -46,14 +46,7 @@ class Emulation extends \Magento\Object protected $_translate; /** - * @var \Magento\Core\Helper\Translate - */ - protected $_helperTranslate; - - /** - * Core store config - * - * @var \Magento\Core\Model\Store\Config + * @var \Magento\Core\Model\Store\ConfigInterface */ protected $_coreStoreConfig; @@ -68,18 +61,23 @@ class Emulation extends \Magento\Object protected $_design; /** - * @var \Magento\Translate\Inline\ConfigFactory + * @var \Magento\Translate\Inline\ConfigInterface + */ + protected $inlineConfig; + + /** + * @var \Magento\Translate\Inline\StateInterface */ - protected $_configFactory; + protected $inlineTranslation; /** * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\View\DesignInterface $viewDesign * @param \Magento\Core\Model\Design $design * @param \Magento\TranslateInterface $translate - * @param \Magento\Core\Helper\Translate $helperTranslate - * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Translate\Inline\ConfigFactory $configFactory + * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig + * @param \Magento\Translate\Inline\ConfigInterface $inlineConfig + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ @@ -88,9 +86,9 @@ public function __construct( \Magento\View\DesignInterface $viewDesign, \Magento\Core\Model\Design $design, \Magento\TranslateInterface $translate, - \Magento\Core\Helper\Translate $helperTranslate, - \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Translate\Inline\ConfigFactory $configFactory, + \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, + \Magento\Translate\Inline\ConfigInterface $inlineConfig, + \Magento\Translate\Inline\StateInterface $inlineTranslation, \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { @@ -100,9 +98,9 @@ public function __construct( $this->_viewDesign = $viewDesign; $this->_design = $design; $this->_translate = $translate; - $this->_helperTranslate = $helperTranslate; $this->_coreStoreConfig = $coreStoreConfig; - $this->_configFactory = $configFactory; + $this->inlineConfig = $inlineConfig; + $this->inlineTranslation = $inlineTranslation; } /** @@ -175,10 +173,11 @@ protected function _emulateInlineTranslation($storeId = null) if (is_null($storeId)) { $newTranslateInline = false; } else { - $newTranslateInline = $this->_configFactory->get()->isActive($storeId); + $newTranslateInline = $this->inlineConfig->isActive($storeId); } - $translateInline = $this->_translate->getTranslateInline(); - $this->_translate->setTranslateInline($newTranslateInline); + + $translateInline = $this->inlineTranslation->isEnabled(); + $this->inlineTranslation->suspend($newTranslateInline); return $translateInline; } @@ -223,7 +222,9 @@ protected function _emulateLocale($storeId, $area = \Magento\Core\Model\App\Area $initialLocaleCode = $this->_localeResolver->getLocaleCode(); $newLocaleCode = $this->_coreStoreConfig->getConfig($this->_localeResolver->getDefaultLocalePath(), $storeId); $this->_localeResolver->setLocaleCode($newLocaleCode); - $this->_translate->initLocale($newLocaleCode, $area); + $this->_translate->setLocale($newLocaleCode) + ->loadData($area, true); + return $initialLocaleCode; } @@ -235,7 +236,7 @@ protected function _emulateLocale($storeId, $area = \Magento\Core\Model\App\Area */ protected function _restoreInitialInlineTranslation($initialTranslate) { - $this->_translate->setTranslateInline($initialTranslate); + $this->inlineTranslation->resume($initialTranslate); return $this; } @@ -263,7 +264,9 @@ protected function _restoreInitialLocale( $initialArea = \Magento\Core\Model\App\Area::AREA_ADMIN ) { $this->_localeResolver->setLocaleCode($initialLocaleCode); - $this->_translate->initLocale($initialLocaleCode); + $this->_translate->setLocale($initialLocaleCode) + ->loadData($initialArea, true); + return $this; } } diff --git a/app/code/Magento/Core/Model/Config/Value.php b/app/code/Magento/Core/Model/Config/Value.php index 0fb2f2d32bc98..fd8a6dd9b386a 100644 --- a/app/code/Magento/Core/Model/Config/Value.php +++ b/app/code/Magento/Core/Model/Config/Value.php @@ -41,7 +41,7 @@ * * @SuppressWarnings(PHPMD.NumberOfChildren) */ -class Value extends \Magento\Core\Model\AbstractModel implements \Magento\App\Config\ValueInterface +class Value extends \Magento\Model\AbstractModel implements \Magento\App\Config\ValueInterface { /** * Prefix of model events names @@ -74,7 +74,7 @@ class Value extends \Magento\Core\Model\AbstractModel implements \Magento\App\Co * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -83,7 +83,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Core/Model/Design.php b/app/code/Magento/Core/Model/Design.php index 9582b5d9bd06b..78db14650e9ef 100644 --- a/app/code/Magento/Core/Model/Design.php +++ b/app/code/Magento/Core/Model/Design.php @@ -25,7 +25,8 @@ */ namespace Magento\Core\Model; -use Magento\Core\Model\Resource\AbstractResource; +use Magento\Model\Resource\AbstractResource; +use Magento\Model\AbstractModel; /** * Design settings change model diff --git a/app/code/Magento/Core/Model/Design/Backend/Exceptions.php b/app/code/Magento/Core/Model/Design/Backend/Exceptions.php index a507aa349fa5b..b20dc5c4ae469 100644 --- a/app/code/Magento/Core/Model/Design/Backend/Exceptions.php +++ b/app/code/Magento/Core/Model/Design/Backend/Exceptions.php @@ -40,7 +40,7 @@ class Exceptions extends \Magento\Backend\Model\Config\Backend\Serialized\ArrayS * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\View\DesignInterface $design - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -50,7 +50,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\View\DesignInterface $design, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -62,7 +62,7 @@ public function __construct( * Validate value * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * if there is no field value, search value is empty or regular expression is not valid */ protected function _beforeSave() @@ -78,7 +78,7 @@ protected function _beforeSave() // Validate that all values have come foreach (array('search', 'value') as $fieldName) { if (!isset($row[$fieldName])) { - throw new \Magento\Core\Exception(__("Exception does not contain field '{$fieldName}'")); + throw new \Magento\Model\Exception(__("Exception does not contain field '{$fieldName}'")); } } @@ -104,7 +104,7 @@ protected function _beforeSave() * * @param string $search * @return string - * @throws \Magento\Core\Exception on invalid regular expression + * @throws \Magento\Model\Exception on invalid regular expression */ protected function _composeRegexp($search) { @@ -115,7 +115,7 @@ protected function _composeRegexp($search) // Find out - whether user wanted to enter regexp or normal string. if ($this->_isRegexp($search)) { - throw new \Magento\Core\Exception(__('Invalid regular expression: "%1".', $search)); + throw new \Magento\Model\Exception(__('Invalid regular expression: "%1".', $search)); } return '/' . preg_quote($search, '/') . '/i'; diff --git a/app/code/Magento/Core/Model/Design/Backend/Theme.php b/app/code/Magento/Core/Model/Design/Backend/Theme.php index 3b86a49758dcb..3f0521e866ad6 100644 --- a/app/code/Magento/Core/Model/Design/Backend/Theme.php +++ b/app/code/Magento/Core/Model/Design/Backend/Theme.php @@ -40,7 +40,7 @@ class Theme extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\View\DesignInterface $design - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -50,7 +50,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\View\DesignInterface $design, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Core/Model/Factory.php b/app/code/Magento/Core/Model/Factory.php index 7b03fdd94cfcf..8ea5ffa34089e 100644 --- a/app/code/Magento/Core/Model/Factory.php +++ b/app/code/Magento/Core/Model/Factory.php @@ -49,13 +49,13 @@ public function __construct(\Magento\ObjectManager $objectManager) * @param string $model * @param array $data * @throws \InvalidArgumentException - * @return AbstractModel + * @return \Magento\Model\AbstractModel */ public function create($model, array $data = array()) { $modelInstance = $this->_objectManager->create($model, $data); - if (false == $modelInstance instanceof \Magento\Core\Model\AbstractModel) { - throw new \InvalidArgumentException($model . ' is not instance of \Magento\Core\Model\AbstractModel'); + if (false == $modelInstance instanceof \Magento\Model\AbstractModel) { + throw new \InvalidArgumentException($model . ' is not instance of \Magento\Model\AbstractModel'); } return $modelInstance; } diff --git a/app/code/Magento/Core/Model/File/Storage.php b/app/code/Magento/Core/Model/File/Storage.php index f49eef4bdb224..0702e2fa59380 100644 --- a/app/code/Magento/Core/Model/File/Storage.php +++ b/app/code/Magento/Core/Model/File/Storage.php @@ -26,7 +26,7 @@ namespace Magento\Core\Model\File; use Magento\App\Filesystem; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; /** * Class Storage @@ -113,7 +113,7 @@ class Storage extends AbstractModel * @param \Magento\Core\Model\File\Storage\FileFactory $fileFactory * @param \Magento\Core\Model\File\Storage\DatabaseFactory $databaseFactory * @param \Magento\App\Filesystem $filesystem - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -127,7 +127,7 @@ public function __construct( \Magento\Core\Model\File\Storage\FileFactory $fileFactory, \Magento\Core\Model\File\Storage\DatabaseFactory $databaseFactory, \Magento\App\Filesystem $filesystem, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Core/Model/File/Storage/Database.php b/app/code/Magento/Core/Model/File/Storage/Database.php index 6113bf50106a4..b97f8ba0b04dc 100644 --- a/app/code/Magento/Core/Model/File/Storage/Database.php +++ b/app/code/Magento/Core/Model/File/Storage/Database.php @@ -66,12 +66,12 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas * @param \Magento\Registry $registry * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb * @param \Magento\Stdlib\DateTime\DateTime $dateModel - * @param \Magento\Core\Model\App $app + * @param \Magento\App\ConfigInterface $configuration * @param \Magento\Core\Helper\File\Media $mediaHelper * @param \Magento\Core\Model\Resource\File\Storage\Database $resource - * @param \Magento\Core\Model\File\Storage\Directory\DatabaseFactory $directoryFactory + * @param Directory\DatabaseFactory $directoryFactory * @param \Magento\Data\Collection\Db $resourceCollection - * @param string|null $connectionName + * @param null $connectionName * @param array $data */ public function __construct( @@ -79,7 +79,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb, \Magento\Stdlib\DateTime\DateTime $dateModel, - \Magento\Core\Model\App $app, + \Magento\App\ConfigInterface $configuration, \Magento\Core\Helper\File\Media $mediaHelper, \Magento\Core\Model\Resource\File\Storage\Database $resource, \Magento\Core\Model\File\Storage\Directory\DatabaseFactory $directoryFactory, @@ -94,7 +94,7 @@ public function __construct( $registry, $coreFileStorageDb, $dateModel, - $app, + $configuration, $resource, $resourceCollection, $connectionName, diff --git a/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php b/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php index 8bc9d4878eda1..f96210a33d6fc 100644 --- a/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php +++ b/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php @@ -28,7 +28,7 @@ /** * Class AbstractDatabase */ -abstract class AbstractDatabase extends \Magento\Core\Model\AbstractModel +abstract class AbstractDatabase extends \Magento\Model\AbstractModel { /** * Store media base directory path @@ -52,17 +52,17 @@ abstract class AbstractDatabase extends \Magento\Core\Model\AbstractModel protected $_date; /** - * @var \Magento\Core\Model\App + * @var \Magento\App\ConfigInterface */ - protected $_app; + protected $_configuration; /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb * @param \Magento\Stdlib\DateTime\DateTime $dateModel - * @param \Magento\Core\Model\App $app - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\App\ConfigInterface $configuration + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param string|null $connectionName * @param array $data @@ -72,14 +72,14 @@ public function __construct( \Magento\Registry $registry, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb, \Magento\Stdlib\DateTime\DateTime $dateModel, - \Magento\Core\Model\App $app, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\App\ConfigInterface $configuration, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, $connectionName = null, array $data = array() ) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); - $this->_app = $app; + $this->_configuration = $configuration; $this->_coreFileStorageDb = $coreFileStorageDb; $this->_date = $dateModel; if (!$connectionName) { @@ -95,10 +95,11 @@ public function __construct( */ public function getConfigConnectionName() { - $connectionName = $this->_app->getConfig()->getValue( - \Magento\Core\Model\File\Storage::XML_PATH_STORAGE_MEDIA_DATABASE, - 'default' - ); + $connectionName = $this->_configuration + ->getValue( + \Magento\Core\Model\File\Storage::XML_PATH_STORAGE_MEDIA_DATABASE, + 'default' + ); if (empty($connectionName)) { $connectionName = 'default_setup'; } @@ -108,7 +109,7 @@ public function getConfigConnectionName() /** * Get resource instance * - * @return \Magento\Core\Model\Resource\AbstractResource + * @return \Magento\Model\Resource\AbstractResource */ protected function _getResource() { diff --git a/app/code/Magento/Core/Model/File/Storage/Directory/Database.php b/app/code/Magento/Core/Model/File/Storage/Directory/Database.php index e146f1e772dd5..cae83fec58b23 100644 --- a/app/code/Magento/Core/Model/File/Storage/Directory/Database.php +++ b/app/code/Magento/Core/Model/File/Storage/Directory/Database.php @@ -54,11 +54,11 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas * @param \Magento\Registry $registry * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb * @param \Magento\Stdlib\DateTime\DateTime $dateModel - * @param \Magento\Core\Model\App $app - * @param \Magento\Core\Model\File\Storage\Directory\DatabaseFactory $directoryFactory + * @param \Magento\App\ConfigInterface $configuration + * @param DatabaseFactory $directoryFactory * @param \Magento\Core\Model\Resource\File\Storage\Directory\Database $resource * @param \Magento\Data\Collection\Db $resourceCollection - * @param string|null $connectionName + * @param null $connectionName * @param array $data */ public function __construct( @@ -66,7 +66,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb, \Magento\Stdlib\DateTime\DateTime $dateModel, - \Magento\Core\Model\App $app, + \Magento\App\ConfigInterface $configuration, \Magento\Core\Model\File\Storage\Directory\DatabaseFactory $directoryFactory, \Magento\Core\Model\Resource\File\Storage\Directory\Database $resource, \Magento\Data\Collection\Db $resourceCollection = null, @@ -79,7 +79,7 @@ public function __construct( $registry, $coreFileStorageDb, $dateModel, - $app, + $configuration, $resource, $resourceCollection, $connectionName, @@ -193,7 +193,7 @@ public function exportDirectories($offset = 0, $count = 100) * Import directories to storage * * @param array $dirs - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ public function importDirectories($dirs) @@ -219,7 +219,7 @@ public function importDirectories($dirs) $directory->setUploadTime($dateSingleton->date()); $directory->save(); } else { - throw new \Magento\Core\Exception(__('Parent directory does not exist: %1', $dir['path'])); + throw new \Magento\Model\Exception(__('Parent directory does not exist: %1', $dir['path'])); } } catch (\Exception $e) { $this->_logger->logException($e); diff --git a/app/code/Magento/Core/Model/File/Storage/File.php b/app/code/Magento/Core/Model/File/Storage/File.php index b21cd0e876f0f..7ea324dffb650 100644 --- a/app/code/Magento/Core/Model/File/Storage/File.php +++ b/app/code/Magento/Core/Model/File/Storage/File.php @@ -287,7 +287,7 @@ public function saveDir($dir) * * @param array $file * @param bool $overwrite - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ public function saveFile($file, $overwrite = true) @@ -306,12 +306,12 @@ public function saveFile($file, $overwrite = true) return $this->_fileUtility->saveFile($filename, $file['content'], $overwrite); } catch (\Exception $e) { $this->_logger->logException($e); - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Unable to save file "%1" at "%2"', $file['filename'], $file['directory']) ); } } else { - throw new \Magento\Core\Exception(__('Wrong file info format')); + throw new \Magento\Model\Exception(__('Wrong file info format')); } return false; diff --git a/app/code/Magento/Core/Model/File/Storage/Flag.php b/app/code/Magento/Core/Model/File/Storage/Flag.php index c37fd0923dcac..acab6d1eefe5d 100644 --- a/app/code/Magento/Core/Model/File/Storage/Flag.php +++ b/app/code/Magento/Core/Model/File/Storage/Flag.php @@ -34,7 +34,7 @@ */ namespace Magento\Core\Model\File\Storage; -class Flag extends \Magento\Core\Model\Flag +class Flag extends \Magento\Flag { /** * There was no synchronization diff --git a/app/code/Magento/Core/Model/Layout.php b/app/code/Magento/Core/Model/Layout.php index f14ec78004ccb..23690fd2475b1 100644 --- a/app/code/Magento/Core/Model/Layout.php +++ b/app/code/Magento/Core/Model/Layout.php @@ -1400,7 +1400,7 @@ public function renameElement($oldName, $newName) * * @param string|\Magento\View\Element\AbstractBlock $block * @param array $attributes - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\View\Element\AbstractBlock */ protected function _getBlockInstance($block, array $attributes = array()) @@ -1413,7 +1413,7 @@ protected function _getBlockInstance($block, array $attributes = array()) } } if (!$block instanceof \Magento\View\Element\AbstractBlock) { - throw new \Magento\Core\Exception(__('Invalid block type: %1', $block)); + throw new \Magento\Model\Exception(__('Invalid block type: %1', $block)); } return $block; } @@ -1527,14 +1527,14 @@ public function getMessagesBlock() * Get block singleton * * @param string $type - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\App\Helper\AbstractHelper */ public function getBlockSingleton($type) { if (!isset($this->_helpers[$type])) { if (!$type) { - throw new \Magento\Core\Exception(__('Invalid block type: %1', $type)); + throw new \Magento\Model\Exception(__('Invalid block type: %1', $type)); } $helper = $this->_blockFactory->createBlock($type); diff --git a/app/code/Magento/Core/Model/Layout/Link.php b/app/code/Magento/Core/Model/Layout/Link.php index eb17e56d2fcd8..7fe511be50bb4 100644 --- a/app/code/Magento/Core/Model/Layout/Link.php +++ b/app/code/Magento/Core/Model/Layout/Link.php @@ -35,7 +35,7 @@ * @method \Magento\Core\Model\Layout\Link setThemeId($id) * @method \Magento\Core\Model\Layout\Link setLayoutUpdateId($id) */ -class Link extends \Magento\Core\Model\AbstractModel +class Link extends \Magento\Model\AbstractModel { /** * Layout Update model initialization diff --git a/app/code/Magento/Core/Model/Layout/Update.php b/app/code/Magento/Core/Model/Layout/Update.php index 853270d2bedcf..fc12369c1f329 100644 --- a/app/code/Magento/Core/Model/Layout/Update.php +++ b/app/code/Magento/Core/Model/Layout/Update.php @@ -40,7 +40,7 @@ * @method \Magento\Core\Model\Layout\Update setUpdatedAt() setUpdatedAt(string $updateDateTime) * @method \Magento\Core\Model\Resource\Layout\Update\Collection getCollection() */ -class Update extends \Magento\Core\Model\AbstractModel +class Update extends \Magento\Model\AbstractModel { /** * @var \Magento\Stdlib\DateTime @@ -51,7 +51,7 @@ class Update extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -59,7 +59,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -80,7 +80,7 @@ protected function _construct() /** * Set current updated date * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _beforeSave() { diff --git a/app/code/Magento/Core/Model/Observer.php b/app/code/Magento/Core/Model/Observer.php index 9beb850517f98..71041357b0687 100644 --- a/app/code/Magento/Core/Model/Observer.php +++ b/app/code/Magento/Core/Model/Observer.php @@ -121,7 +121,7 @@ public function themeRegistration(\Magento\Event\Observer $observer) $pathPattern = $observer->getEvent()->getPathPattern(); try { $this->_registration->register($pathPattern); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_logger->logException($e); } return $this; diff --git a/app/code/Magento/Core/Model/Resource/Cache.php b/app/code/Magento/Core/Model/Resource/Cache.php index 49410249f3631..4ec67829de437 100644 --- a/app/code/Magento/Core/Model/Resource/Cache.php +++ b/app/code/Magento/Core/Model/Resource/Cache.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Cache extends \Magento\Core\Model\Resource\Db\AbstractDb implements \Magento\App\Cache\State\OptionsInterface +class Cache extends \Magento\Model\Resource\Db\AbstractDb implements \Magento\App\Cache\State\OptionsInterface { /** * Define main table diff --git a/app/code/Magento/Core/Model/Resource/Config.php b/app/code/Magento/Core/Model/Resource/Config.php index 8894fb300de1e..f82a708d0a3c1 100644 --- a/app/code/Magento/Core/Model/Resource/Config.php +++ b/app/code/Magento/Core/Model/Resource/Config.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Config extends \Magento\Core\Model\Resource\Db\AbstractDb +class Config extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table diff --git a/app/code/Magento/Core/Model/Resource/Config/Data.php b/app/code/Magento/Core/Model/Resource/Config/Data.php index 55eb310737b42..9827293ed222b 100644 --- a/app/code/Magento/Core/Model/Resource/Config/Data.php +++ b/app/code/Magento/Core/Model/Resource/Config/Data.php @@ -34,7 +34,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Data extends \Magento\Core\Model\Resource\Db\AbstractDb +class Data extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table @@ -49,10 +49,10 @@ protected function _construct() /** * Convert array to comma separated value * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { if (!$object->getId()) { $this->_checkUnique($object); @@ -68,10 +68,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) * Validate unique configuration data before save * Set id to object if exists configuration instead of throw exception * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _checkUnique(\Magento\Core\Model\AbstractModel $object) + protected function _checkUnique(\Magento\Model\AbstractModel $object) { $select = $this->_getReadAdapter()->select()->from( $this->getMainTable(), diff --git a/app/code/Magento/Core/Model/Resource/Config/Data/Collection.php b/app/code/Magento/Core/Model/Resource/Config/Data/Collection.php index d31b34bd34a54..9f89d809ab7fe 100644 --- a/app/code/Magento/Core/Model/Resource/Config/Data/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Config/Data/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Define resource model diff --git a/app/code/Magento/Core/Model/Resource/Config/Value/Collection/Scoped.php b/app/code/Magento/Core/Model/Resource/Config/Value/Collection/Scoped.php index b9f1e9ef73121..c98899ec99f77 100644 --- a/app/code/Magento/Core/Model/Resource/Config/Value/Collection/Scoped.php +++ b/app/code/Magento/Core/Model/Resource/Config/Value/Collection/Scoped.php @@ -25,7 +25,7 @@ */ namespace Magento\Core\Model\Resource\Config\Value\Collection; -class Scoped extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Scoped extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Scope to filter by diff --git a/app/code/Magento/Core/Model/Resource/Design.php b/app/code/Magento/Core/Model/Resource/Design.php index 4fac11c843456..d9743f6d3d10e 100644 --- a/app/code/Magento/Core/Model/Resource/Design.php +++ b/app/code/Magento/Core/Model/Resource/Design.php @@ -34,7 +34,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Design extends \Magento\Core\Model\Resource\Db\AbstractDb +class Design extends \Magento\Model\Resource\Db\AbstractDb { /** * @var DateTime @@ -64,11 +64,11 @@ protected function _construct() /** * Perform actions before object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - public function _beforeSave(\Magento\Core\Model\AbstractModel $object) + public function _beforeSave(\Magento\Model\AbstractModel $object) { if ($date = $object->getDateFrom()) { $object->setDateFrom($this->dateTime->formatDate($date)); @@ -92,7 +92,7 @@ public function _beforeSave(\Magento\Core\Model\AbstractModel $object) $object->getDateTo() ) ) { - throw new \Magento\Core\Exception(__('Start date cannot be greater than end date.')); + throw new \Magento\Model\Exception(__('Start date cannot be greater than end date.')); } $check = $this->_checkIntersection( @@ -103,7 +103,7 @@ public function _beforeSave(\Magento\Core\Model\AbstractModel $object) ); if ($check) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Your design change for the specified store intersects with another one, please specify another date range.' ) diff --git a/app/code/Magento/Core/Model/Resource/Design/Collection.php b/app/code/Magento/Core/Model/Resource/Design/Collection.php index 4dd9e74e559ed..fd141975a4eb7 100644 --- a/app/code/Magento/Core/Model/Resource/Design/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Design/Collection.php @@ -28,7 +28,7 @@ /** * Core Design resource collection */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * @var \Magento\Stdlib\DateTime @@ -42,7 +42,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Stdlib\DateTime $dateTime * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -51,7 +51,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Stdlib\DateTime $dateTime, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->dateTime = $dateTime; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Core/Model/Resource/File/Storage/AbstractStorage.php b/app/code/Magento/Core/Model/Resource/File/Storage/AbstractStorage.php index 43bad76577e9d..1540f4f048a61 100644 --- a/app/code/Magento/Core/Model/Resource/File/Storage/AbstractStorage.php +++ b/app/code/Magento/Core/Model/Resource/File/Storage/AbstractStorage.php @@ -28,7 +28,7 @@ /** * Class AbstractStorage */ -abstract class AbstractStorage extends \Magento\Core\Model\Resource\Db\AbstractDb +abstract class AbstractStorage extends \Magento\Model\Resource\Db\AbstractDb { /** * File storage connection name diff --git a/app/code/Magento/Core/Model/Resource/File/Storage/Database.php b/app/code/Magento/Core/Model/Resource/File/Storage/Database.php index 3182c186cbc6d..0093393f18510 100644 --- a/app/code/Magento/Core/Model/Resource/File/Storage/Database.php +++ b/app/code/Magento/Core/Model/Resource/File/Storage/Database.php @@ -31,15 +31,15 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage { /** - * @var \Magento\Core\Model\Resource\Helper + * @var \Magento\DB\Helper */ protected $_resourceHelper; /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Resource\Helper $resourceHelper + * @param \Magento\DB\Helper $resourceHelper */ - public function __construct(\Magento\App\Resource $resource, \Magento\Core\Model\Resource\Helper $resourceHelper) + public function __construct(\Magento\App\Resource $resource, \Magento\DB\Helper $resourceHelper) { parent::__construct($resource); $this->_resourceHelper = $resourceHelper; diff --git a/app/code/Magento/Core/Model/Resource/File/Storage/File.php b/app/code/Magento/Core/Model/Resource/File/Storage/File.php index fa4b725937a82..f697778093631 100644 --- a/app/code/Magento/Core/Model/Resource/File/Storage/File.php +++ b/app/code/Magento/Core/Model/Resource/File/Storage/File.php @@ -103,7 +103,7 @@ public function clear($dir = '') * Save directory to storage * * @param array $dir - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ public function saveDir($dir) @@ -118,7 +118,7 @@ public function saveDir($dir) $this->_filesystem->getDirectoryWrite(\Magento\App\Filesystem::MEDIA_DIR)->create($path); } catch (\Exception $e) { $this->_logger->log($e->getMessage()); - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Unable to create directory: %1', \Magento\App\Filesystem::MEDIA_DIR . '/' . $path) ); } @@ -132,7 +132,7 @@ public function saveDir($dir) * @param string $filePath * @param string $content * @param bool $overwrite - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ public function saveFile($filePath, $content, $overwrite = false) @@ -145,7 +145,7 @@ public function saveFile($filePath, $content, $overwrite = false) } } catch (\Magento\Filesystem\FilesystemException $e) { $this->_logger->log($e->getMessage()); - throw new \Magento\Core\Exception(__('Unable to save file: %1', $filePath)); + throw new \Magento\Model\Exception(__('Unable to save file: %1', $filePath)); } return false; diff --git a/app/code/Magento/Core/Model/Resource/Helper.php b/app/code/Magento/Core/Model/Resource/Helper.php deleted file mode 100644 index 44d6886d7bd9b..0000000000000 --- a/app/code/Magento/Core/Model/Resource/Helper.php +++ /dev/null @@ -1,324 +0,0 @@ -getPart(\Zend_Db_Select::ORDER); - if (!$selectOrders) { - return array(); - } - - $orders = array(); - foreach ($selectOrders as $term) { - if (is_array($term)) { - if (!is_numeric($term[0])) { - $orders[] = sprintf('%s %s', $this->_getReadAdapter()->quoteIdentifier($term[0], true), $term[1]); - } - } else { - if (!is_numeric($term)) { - $orders[] = $this->_getReadAdapter()->quoteIdentifier($term, true); - } - } - } - - if ($autoReset) { - $select->reset(\Zend_Db_Select::ORDER); - } - - return $orders; - } - - /** - * Truncate alias name from field. - * - * Result string depends from second optional argument $reverse - * which can be true if you need the first part of the field. - * Field can be with 'dot' delimiter. - * - * @param string $field - * @param bool $reverse OPTIONAL - * @return string - */ - protected function _truncateAliasName($field, $reverse = false) - { - $string = $field; - if (!is_numeric($field) && strpos($field, '.') !== false) { - $size = strpos($field, '.'); - if ($reverse) { - $string = substr($field, 0, $size); - } else { - $string = substr($field, $size + 1); - } - } - - return $string; - } - - /** - * Returns quoted group by fields - * - * @param \Magento\DB\Select $select - * @param bool $autoReset - * @return array - */ - protected function _prepareGroup(\Magento\DB\Select $select, $autoReset = false) - { - $selectGroups = $select->getPart(\Zend_Db_Select::GROUP); - if (!$selectGroups) { - return array(); - } - - $groups = array(); - foreach ($selectGroups as $term) { - $groups[] = $this->_getReadAdapter()->quoteIdentifier($term, true); - } - - if ($autoReset) { - $select->reset(\Zend_Db_Select::GROUP); - } - - return $groups; - } - - /** - * Prepare and returns having array - * - * @param \Magento\DB\Select $select - * @param bool $autoReset - * @return array - * @throws \Zend_Db_Exception - */ - protected function _prepareHaving(\Magento\DB\Select $select, $autoReset = false) - { - $selectHavings = $select->getPart(\Zend_Db_Select::HAVING); - if (!$selectHavings) { - return array(); - } - - $havings = array(); - $columns = $select->getPart(\Zend_Db_Select::COLUMNS); - foreach ($columns as $columnEntry) { - $correlationName = (string)$columnEntry[1]; - $column = $columnEntry[2]; - foreach ($selectHavings as $having) { - /** - * Looking for column expression in the having clause - */ - if (strpos($having, $correlationName) !== false) { - if (is_string($column)) { - /** - * Replace column expression to column alias in having clause - */ - $havings[] = str_replace($correlationName, $column, $having); - } else { - throw new \Zend_Db_Exception( - sprintf("Can't prepare expression without column alias: '%s'", $correlationName) - ); - } - } - } - } - - if ($autoReset) { - $select->reset(\Zend_Db_Select::HAVING); - } - - return $havings; - } - - /** - * - * @param string $query - * @param int $limitCount - * @param int $limitOffset - * @param array $columnList - * @return string - */ - protected function _assembleLimit($query, $limitCount, $limitOffset, $columnList = array()) - { - if ($limitCount !== null) { - $limitCount = intval($limitCount); - if ($limitCount <= 0) { - //throw new \Exception("LIMIT argument count={$limitCount} is not valid"); - } - - $limitOffset = intval($limitOffset); - if ($limitOffset < 0) { - //throw new \Exception("LIMIT argument offset={$limitOffset} is not valid"); - } - - if ($limitOffset + $limitCount != $limitOffset + 1) { - $columns = array(); - foreach ($columnList as $columnEntry) { - $columns[] = $columnEntry[2] ? $columnEntry[2] : $columnEntry[1]; - } - $query = sprintf('%s LIMIT %s, %s', $query, $limitCount, $limitOffset); - } - } - - return $query; - } - - /** - * Prepare select column list - * - * @param \Magento\DB\Select $select - * @param string|null $groupByCondition OPTIONAL - * @return mixed|array - * @throws \Zend_Db_Exception - */ - public function prepareColumnsList(\Magento\DB\Select $select, $groupByCondition = null) - { - if (!count($select->getPart(\Zend_Db_Select::FROM))) { - return $select->getPart(\Zend_Db_Select::COLUMNS); - } - - $columns = $select->getPart(\Zend_Db_Select::COLUMNS); - $tables = $select->getPart(\Zend_Db_Select::FROM); - $preparedColumns = array(); - - foreach ($columns as $columnEntry) { - list($correlationName, $column, $alias) = $columnEntry; - if ($column instanceof \Zend_Db_Expr) { - if ($alias !== null) { - if (preg_match('/(^|[^a-zA-Z_])^(SELECT)?(SUM|MIN|MAX|AVG|COUNT)\s*\(/i', $column)) { - $column = new \Zend_Db_Expr($column); - } - $preparedColumns[strtoupper($alias)] = array(null, $column, $alias); - } else { - throw new \Zend_Db_Exception("Can't prepare expression without alias"); - } - } else { - if ($column == \Zend_Db_Select::SQL_WILDCARD) { - if ($tables[$correlationName]['tableName'] instanceof \Zend_Db_Expr) { - throw new \Zend_Db_Exception( - "Can't prepare expression when tableName is instance of \Zend_Db_Expr" - ); - } - $tableColumns = $this->_getReadAdapter()->describeTable($tables[$correlationName]['tableName']); - foreach (array_keys($tableColumns) as $col) { - $preparedColumns[strtoupper($col)] = array($correlationName, $col, null); - } - } else { - $columnKey = is_null($alias) ? $column : $alias; - $preparedColumns[strtoupper($columnKey)] = array($correlationName, $column, $alias); - } - } - } - - return $preparedColumns; - } - - /** - * Add prepared column group_concat expression - * - * @param \Magento\DB\Select $select - * @param string $fieldAlias Field alias which will be added with column group_concat expression - * @param string $fields - * @param string $groupConcatDelimiter - * @param string $fieldsDelimiter - * @param string $additionalWhere - * @return \Magento\DB\Select - */ - public function addGroupConcatColumn( - $select, - $fieldAlias, - $fields, - $groupConcatDelimiter = ',', - $fieldsDelimiter = '', - $additionalWhere = '' - ) { - if (is_array($fields)) { - $fieldExpr = $this->_getReadAdapter()->getConcatSql($fields, $fieldsDelimiter); - } else { - $fieldExpr = $fields; - } - if ($additionalWhere) { - $fieldExpr = $this->_getReadAdapter()->getCheckSql($additionalWhere, $fieldExpr, "''"); - } - $separator = ''; - if ($groupConcatDelimiter) { - $separator = sprintf(" SEPARATOR '%s'", $groupConcatDelimiter); - } - $select->columns( - array($fieldAlias => new \Zend_Db_Expr(sprintf('GROUP_CONCAT(%s%s)', $fieldExpr, $separator))) - ); - return $select; - } - - /** - * Returns expression of days passed from $startDate to $endDate - * - * @param string|\Zend_Db_Expr $startDate - * @param string|\Zend_Db_Expr $endDate - * @return \Zend_Db_Expr - */ - public function getDateDiff($startDate, $endDate) - { - $dateDiff = '(TO_DAYS(' . $endDate . ') - TO_DAYS(' . $startDate . '))'; - return new \Zend_Db_Expr($dateDiff); - } - - /** - * Escapes and quotes LIKE value. - * Stating escape symbol in expression is not required, because we use standard MySQL escape symbol. - * For options and escaping see escapeLikeValue(). - * - * @param string $value - * @param array $options - * @return \Zend_Db_Expr - * - * @see escapeLikeValue() - */ - public function addLikeEscape($value, $options = array()) - { - $value = $this->escapeLikeValue($value, $options); - return new \Zend_Db_Expr($this->_getReadAdapter()->quote($value)); - } -} diff --git a/app/code/Magento/Core/Model/Resource/HelperPool.php b/app/code/Magento/Core/Model/Resource/HelperPool.php deleted file mode 100644 index 7c7ce864d3f46..0000000000000 --- a/app/code/Magento/Core/Model/Resource/HelperPool.php +++ /dev/null @@ -1,78 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Get resource helper singleton - * - * @param string $moduleName - * @throws \InvalidArgumentException - * @return \Magento\Core\Model\Resource\Helper\AbstractHelper - */ - public function get($moduleName) - { - $module = str_replace('_', \Magento\Autoload\IncludePath::NS_SEPARATOR, $moduleName); - $helperClassName = $module . '\Model\Resource\Helper'; - $connection = strtolower($moduleName); - if (substr($moduleName, 0, 8) == 'Magento_') { - $connection = substr($connection, 8); - } - - if (!isset($this->_resourceHelpers[$connection])) { - $helper = $this->_objectManager->create($helperClassName, array('modulePrefix' => $connection)); - if (false === $helper instanceof \Magento\Core\Model\Resource\Helper\AbstractHelper) { - throw new \InvalidArgumentException( - $helperClassName . ' doesn\'t extend \Magento\Core\Model\Resource\Helper\AbstractHelper' - ); - } - $this->_resourceHelpers[$connection] = $helper; - } - - return $this->_resourceHelpers[$connection]; - } -} diff --git a/app/code/Magento/Core/Model/Resource/Layout/Link.php b/app/code/Magento/Core/Model/Resource/Layout/Link.php index 1cb3b1b5a5e14..8d681952635d5 100644 --- a/app/code/Magento/Core/Model/Resource/Layout/Link.php +++ b/app/code/Magento/Core/Model/Resource/Layout/Link.php @@ -28,7 +28,7 @@ /** * Layout Link resource model */ -class Link extends \Magento\Core\Model\Resource\Db\AbstractDb +class Link extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table diff --git a/app/code/Magento/Core/Model/Resource/Layout/Link/Collection.php b/app/code/Magento/Core/Model/Resource/Layout/Link/Collection.php index 1ad359d8960ba..a6c6b18ffabb6 100644 --- a/app/code/Magento/Core/Model/Resource/Layout/Link/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Layout/Link/Collection.php @@ -28,7 +28,7 @@ /** * Layout update collection model */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * @var \Magento\Stdlib\DateTime @@ -42,7 +42,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Stdlib\DateTime $dateTime * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -51,7 +51,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Stdlib\DateTime $dateTime, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->dateTime = $dateTime; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Core/Model/Resource/Layout/Update.php b/app/code/Magento/Core/Model/Resource/Layout/Update.php index 993a5b39fa895..7fb8c32062f15 100644 --- a/app/code/Magento/Core/Model/Resource/Layout/Update.php +++ b/app/code/Magento/Core/Model/Resource/Layout/Update.php @@ -28,7 +28,7 @@ /** * Layout update resource model */ -class Update extends \Magento\Core\Model\Resource\Db\AbstractDb +class Update extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Cache\FrontendInterface @@ -117,10 +117,10 @@ protected function _getFetchUpdatesByHandleSelect($loadAllUpdates = false) /** * Update a "layout update link" if relevant data is provided * - * @param \Magento\Core\Model\Layout\Update|\Magento\Core\Model\AbstractModel $object + * @param \Magento\Core\Model\Layout\Update|\Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { $data = $object->getData(); if (isset($data['store_id']) && isset($data['theme_id'])) { diff --git a/app/code/Magento/Core/Model/Resource/Layout/Update/Collection.php b/app/code/Magento/Core/Model/Resource/Layout/Update/Collection.php index ab2271b4c46f3..a066dbe207e72 100644 --- a/app/code/Magento/Core/Model/Resource/Layout/Update/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Layout/Update/Collection.php @@ -28,7 +28,7 @@ /** * Layout update collection model */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Name prefix of events that are dispatched by model @@ -56,7 +56,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Stdlib\DateTime $dateTime * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -65,7 +65,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Stdlib\DateTime $dateTime, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->dateTime = $dateTime; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Core/Model/Resource/Resource.php b/app/code/Magento/Core/Model/Resource/Resource.php index 0c490b648f786..8ce9180fda1d8 100644 --- a/app/code/Magento/Core/Model/Resource/Resource.php +++ b/app/code/Magento/Core/Model/Resource/Resource.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Resource extends \Magento\Core\Model\Resource\Db\AbstractDb +class Resource extends \Magento\Model\Resource\Db\AbstractDb { /** * Database versions diff --git a/app/code/Magento/Core/Model/Resource/Setup.php b/app/code/Magento/Core/Model/Resource/Setup.php index 48b105b9c731f..81e942c86d421 100644 --- a/app/code/Magento/Core/Model/Resource/Setup.php +++ b/app/code/Magento/Core/Model/Resource/Setup.php @@ -540,14 +540,17 @@ protected function _includeFile($fileName) */ protected function _getModifySqlFiles($actionType, $fromVersion, $toVersion, $arrFiles) { - $arrRes = array(); + $arrRes = []; switch ($actionType) { case self::TYPE_DB_INSTALL: case self::TYPE_DATA_INSTALL: uksort($arrFiles, 'version_compare'); foreach ($arrFiles as $version => $file) { if (version_compare($version, $toVersion) !== self::VERSION_COMPARE_GREATER) { - $arrRes[0] = array('toVersion' => $version, 'fileName' => $file); + $arrRes[0] = [ + 'toVersion' => $version, + 'fileName' => $file + ]; } } break; @@ -563,16 +566,16 @@ protected function _getModifySqlFiles($actionType, $fromVersion, $toVersion, $ar break; } $infoFrom = $versionInfo[0]; - $infoTo = $versionInfo[1]; - if (version_compare( - $infoFrom, - $fromVersion - ) !== self::VERSION_COMPARE_LOWER && version_compare( - $infoTo, - $toVersion - ) !== self::VERSION_COMPARE_GREATER + $infoTo = $versionInfo[1]; + if (version_compare($infoFrom, $fromVersion, '>=') + && version_compare($infoTo, $fromVersion, '>') + && version_compare($infoTo, $toVersion, '<=') + && version_compare($infoFrom, $toVersion, '<') ) { - $arrRes[] = array('toVersion' => $infoTo, 'fileName' => $file); + $arrRes[] = [ + 'toVersion' => $infoTo, + 'fileName' => $file + ]; } } break; diff --git a/app/code/Magento/Core/Model/Resource/Store.php b/app/code/Magento/Core/Model/Resource/Store.php index bc2b2b468104d..4249f66164db9 100644 --- a/app/code/Magento/Core/Model/Resource/Store.php +++ b/app/code/Magento/Core/Model/Resource/Store.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Store extends \Magento\Core\Model\Resource\Db\AbstractDb +class Store extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table and primary key @@ -76,10 +76,10 @@ protected function _initUniqueFields() /** * Update Store Group data after save store * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { parent::_afterSave($object); $this->_updateGroupDefaultStore($object->getGroupId(), $object->getId()); @@ -91,10 +91,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Remove core configuration data after delete store * - * @param \Magento\Core\Model\AbstractModel $model + * @param \Magento\Model\AbstractModel $model * @return $this */ - protected function _afterDelete(\Magento\Core\Model\AbstractModel $model) + protected function _afterDelete(\Magento\Model\AbstractModel $model) { $where = array( 'scope = ?' => \Magento\Core\Model\ScopeInterface::SCOPE_STORES, @@ -137,10 +137,10 @@ protected function _updateGroupDefaultStore($groupId, $storeId) /** * Change store group for store * - * @param \Magento\Core\Model\AbstractModel $model + * @param \Magento\Model\AbstractModel $model * @return $this */ - protected function _changeGroup(\Magento\Core\Model\AbstractModel $model) + protected function _changeGroup(\Magento\Model\AbstractModel $model) { if ($model->getOriginalGroupId() && $model->getGroupId() != $model->getOriginalGroupId()) { $adapter = $this->_getReadAdapter(); @@ -166,7 +166,7 @@ protected function _changeGroup(\Magento\Core\Model\AbstractModel $model) * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return \Magento\DB\Select */ protected function _getLoadSelect($field, $value, $object) diff --git a/app/code/Magento/Core/Model/Resource/Store/Collection.php b/app/code/Magento/Core/Model/Resource/Store/Collection.php index e4fcbfcf2286e..121e9d16b4e8b 100644 --- a/app/code/Magento/Core/Model/Resource/Store/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Store/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Name prefix of events that are dispatched by model diff --git a/app/code/Magento/Core/Model/Resource/Store/Group.php b/app/code/Magento/Core/Model/Resource/Store/Group.php index 91f7ecd1676b2..2cf865d2b843d 100644 --- a/app/code/Magento/Core/Model/Resource/Store/Group.php +++ b/app/code/Magento/Core/Model/Resource/Store/Group.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Group extends \Magento\Core\Model\Resource\Db\AbstractDb +class Group extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table @@ -47,10 +47,10 @@ protected function _construct() /** * Update default store group for website * - * @param \Magento\Core\Model\AbstractModel $model + * @param \Magento\Model\AbstractModel $model * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $model) + protected function _afterSave(\Magento\Model\AbstractModel $model) { $this->_updateStoreWebsite($model->getId(), $model->getWebsiteId()); $this->_updateWebsiteDefaultGroup($model->getWebsiteId(), $model->getId()); @@ -87,10 +87,10 @@ protected function _updateWebsiteDefaultGroup($websiteId, $groupId) /** * Change store group website * - * @param \Magento\Core\Model\AbstractModel $model + * @param \Magento\Model\AbstractModel $model * @return $this */ - protected function _changeWebsite(\Magento\Core\Model\AbstractModel $model) + protected function _changeWebsite(\Magento\Model\AbstractModel $model) { if ($model->getOriginalWebsiteId() && $model->getWebsiteId() != $model->getOriginalWebsiteId()) { $select = $this->_getWriteAdapter()->select()->from( diff --git a/app/code/Magento/Core/Model/Resource/Store/Group/Collection.php b/app/code/Magento/Core/Model/Resource/Store/Group/Collection.php index d579c698c6663..cda1e15bf3b40 100644 --- a/app/code/Magento/Core/Model/Resource/Store/Group/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Store/Group/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Define resource model diff --git a/app/code/Magento/Core/Model/Resource/Theme.php b/app/code/Magento/Core/Model/Resource/Theme.php index 40e59163cde00..4729e4311ed48 100644 --- a/app/code/Magento/Core/Model/Resource/Theme.php +++ b/app/code/Magento/Core/Model/Resource/Theme.php @@ -28,7 +28,7 @@ /** * Theme resource model */ -class Theme extends \Magento\Core\Model\Resource\Db\AbstractDb +class Theme extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Core/Model/Resource/Theme/Collection.php b/app/code/Magento/Core/Model/Resource/Theme/Collection.php index 5e8312c2f7e01..1fc3025bb418e 100644 --- a/app/code/Magento/Core/Model/Resource/Theme/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Theme/Collection.php @@ -28,7 +28,7 @@ /** * Theme collection */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection implements +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection implements \Magento\View\Design\Theme\Label\ListInterface, \Magento\View\Design\Theme\ListInterface { diff --git a/app/code/Magento/Core/Model/Resource/Theme/Customization/Update.php b/app/code/Magento/Core/Model/Resource/Theme/Customization/Update.php index d65b1bfdf6601..15d4b1c815c81 100644 --- a/app/code/Magento/Core/Model/Resource/Theme/Customization/Update.php +++ b/app/code/Magento/Core/Model/Resource/Theme/Customization/Update.php @@ -28,7 +28,7 @@ /** * Theme customization link resource model */ -class Update extends \Magento\Core\Model\Resource\Db\AbstractDb +class Update extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Backend/Model/Resource/Translate.php b/app/code/Magento/Core/Model/Resource/Theme/Data/Collection.php similarity index 70% rename from app/code/Magento/Backend/Model/Resource/Translate.php rename to app/code/Magento/Core/Model/Resource/Theme/Data/Collection.php index 1defebb13dad3..312a3cb04a878 100644 --- a/app/code/Magento/Backend/Model/Resource/Translate.php +++ b/app/code/Magento/Core/Model/Resource/Theme/Data/Collection.php @@ -18,26 +18,23 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Backend * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Backend\Model\Resource; +namespace Magento\Core\Model\Resource\Theme\Data; /** - * Backend translate resource model + * Theme data collection */ -class Translate extends \Magento\Core\Model\Resource\Translate +class Collection extends \Magento\Core\Model\Resource\Theme\Collection implements + \Magento\View\Design\Theme\Label\ListInterface, + \Magento\View\Design\Theme\ListInterface { /** - * Get current store id - * Use always default scope for store id - * - * @return int + * @inheritdoc */ - protected function _getStoreId() + protected function _construct() { - return \Magento\Core\Model\Store::DEFAULT_STORE_ID; + $this->_init('Magento\Core\Model\Theme\Data', 'Magento\Core\Model\Resource\Theme'); } } diff --git a/app/code/Magento/Core/Model/Resource/Theme/File.php b/app/code/Magento/Core/Model/Resource/Theme/File.php index 51c821861d282..c28aa571fc155 100644 --- a/app/code/Magento/Core/Model/Resource/Theme/File.php +++ b/app/code/Magento/Core/Model/Resource/Theme/File.php @@ -28,7 +28,7 @@ /** * Theme files resource model */ -class File extends \Magento\Core\Model\Resource\Db\AbstractDb +class File extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Core/Model/Resource/Theme/File/Collection.php b/app/code/Magento/Core/Model/Resource/Theme/File/Collection.php index da3c2d43a1191..4b3130c65f613 100644 --- a/app/code/Magento/Core/Model/Resource/Theme/File/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Theme/File/Collection.php @@ -28,7 +28,7 @@ /** * Theme files collection */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection implements +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection implements \Magento\View\Design\Theme\File\CollectionInterface { /** diff --git a/app/code/Magento/Core/Model/Resource/Url/Rewrite.php b/app/code/Magento/Core/Model/Resource/Url/Rewrite.php index 5aeb8d2073e35..11d17a1f2d57a 100644 --- a/app/code/Magento/Core/Model/Resource/Url/Rewrite.php +++ b/app/code/Magento/Core/Model/Resource/Url/Rewrite.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Rewrite extends \Magento\Core\Model\Resource\Db\AbstractDb +class Rewrite extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table diff --git a/app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php b/app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php index c8e7ebb4e7ec7..dbce2f608f3ab 100644 --- a/app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php @@ -34,7 +34,7 @@ */ namespace Magento\Core\Model\Resource\Url\Rewrite; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Store Manager Model @@ -50,7 +50,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -59,7 +59,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Core/Model/Resource/Variable.php b/app/code/Magento/Core/Model/Resource/Variable.php index 183f142c751b7..fc0b783e6b196 100644 --- a/app/code/Magento/Core/Model/Resource/Variable.php +++ b/app/code/Magento/Core/Model/Resource/Variable.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Variable extends \Magento\Core\Model\Resource\Db\AbstractDb +class Variable extends \Magento\Model\Resource\Db\AbstractDb { /** * Constructor @@ -84,10 +84,10 @@ public function getVariableByCode($code, $withValue = false, $storeId = 0) /** * Perform actions after object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { parent::_afterSave($object); if ($object->getUseDefaultValue()) { @@ -120,7 +120,7 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ protected function _getLoadSelect($field, $value, $object) diff --git a/app/code/Magento/Core/Model/Resource/Variable/Collection.php b/app/code/Magento/Core/Model/Resource/Variable/Collection.php index 122ce77ac3b57..ae2e7b73e5531 100644 --- a/app/code/Magento/Core/Model/Resource/Variable/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Variable/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Store Id diff --git a/app/code/Magento/Core/Model/Resource/Website.php b/app/code/Magento/Core/Model/Resource/Website.php index bd40cc8c9e96a..1a7565e0355d7 100644 --- a/app/code/Magento/Core/Model/Resource/Website.php +++ b/app/code/Magento/Core/Model/Resource/Website.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Website extends \Magento\Core\Model\Resource\Db\AbstractDb +class Website extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table @@ -58,14 +58,14 @@ protected function _initUniqueFields() /** * Validate website code before object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $object->getCode())) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Website code may only contain letters (a-z), numbers (0-9) or underscore(_), the first character must be a letter' ) @@ -78,10 +78,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * Perform actions after object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { if ($object->getIsDefault()) { $this->_getWriteAdapter()->update($this->getMainTable(), array('is_default' => 0)); @@ -94,10 +94,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Remove core configuration data after delete website * - * @param \Magento\Core\Model\AbstractModel $model + * @param \Magento\Model\AbstractModel $model * @return $this */ - protected function _afterDelete(\Magento\Core\Model\AbstractModel $model) + protected function _afterDelete(\Magento\Model\AbstractModel $model) { $where = array( 'scope = ?' => \Magento\Core\Model\ScopeInterface::SCOPE_WEBSITES, diff --git a/app/code/Magento/Core/Model/Resource/Website/Collection.php b/app/code/Magento/Core/Model/Resource/Website/Collection.php index f4211a7e70485..708a67d690d38 100644 --- a/app/code/Magento/Core/Model/Resource/Website/Collection.php +++ b/app/code/Magento/Core/Model/Resource/Website/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Map field to alias diff --git a/app/code/Magento/Core/Model/Store.php b/app/code/Magento/Core/Model/Store.php index 5f1c36bd5c2c5..628de84ddcdcc 100644 --- a/app/code/Magento/Core/Model/Store.php +++ b/app/code/Magento/Core/Model/Store.php @@ -26,6 +26,7 @@ namespace Magento\Core\Model; use Magento\Directory\Model\Currency\Filter; +use Magento\Model\AbstractModel; /** * Store model @@ -328,6 +329,11 @@ class Store extends AbstractModel implements */ protected $_httpContext; + /** + * @var \Magento\App\ConfigInterface + */ + protected $_appConfig; + /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry @@ -344,6 +350,7 @@ class Store extends AbstractModel implements * @param \Magento\Session\SidResolverInterface $sidResolver * @param \Magento\Stdlib\Cookie $cookie * @param \Magento\App\Http\Context $httpContext + * @param \Magento\App\ConfigInterface $appConfig * @param \Magento\Data\Collection\Db $resourceCollection * @param bool $isCustomEntryPoint * @param array $data @@ -364,6 +371,7 @@ public function __construct( \Magento\Session\SidResolverInterface $sidResolver, \Magento\Stdlib\Cookie $cookie, \Magento\App\Http\Context $httpContext, + \Magento\App\ConfigInterface $appConfig, \Magento\Data\Collection\Db $resourceCollection = null, $isCustomEntryPoint = false, array $data = array() @@ -381,6 +389,7 @@ public function __construct( $this->_sidResolver = $sidResolver; $this->_cookie = $cookie; $this->_httpContext = $httpContext; + $this->_appConfig = $appConfig; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -826,7 +835,10 @@ public function getBaseCurrencyCode() { $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(); + return $this->_appConfig->getValue( + \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, + 'default' + ); } else { return $this->getConfig(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE); } @@ -1248,7 +1260,6 @@ public function getName() */ protected function _beforeDelete() { - $this->_protectFromNonAdmin(); \Magento\App\ObjectManager::getInstance()->get( 'Magento\Index\Model\Indexer' )->logEvent( diff --git a/app/code/Magento/Core/Model/Store/Exception.php b/app/code/Magento/Core/Model/Store/Exception.php index a131b1ef246f2..232d1ab6352c0 100644 --- a/app/code/Magento/Core/Model/Store/Exception.php +++ b/app/code/Magento/Core/Model/Store/Exception.php @@ -34,6 +34,7 @@ */ namespace Magento\Core\Model\Store; -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { + } diff --git a/app/code/Magento/Core/Model/Store/Group.php b/app/code/Magento/Core/Model/Store/Group.php index b15d7b7d13eb7..39925dc331271 100644 --- a/app/code/Magento/Core/Model/Store/Group.php +++ b/app/code/Magento/Core/Model/Store/Group.php @@ -40,7 +40,7 @@ use Magento\Core\Model\Website; -class Group extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface +class Group extends \Magento\Model\AbstractModel implements \Magento\Object\IdentityInterface { const ENTITY = 'store_group'; @@ -122,7 +122,7 @@ class Group extends \Magento\Core\Model\AbstractModel implements \Magento\Object * @param \Magento\Core\Model\Resource\Config\Data $configDataResource * @param \Magento\Core\Model\Store $store * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -132,7 +132,7 @@ public function __construct( \Magento\Core\Model\Resource\Config\Data $configDataResource, \Magento\Core\Model\Store $store, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -376,7 +376,6 @@ public function getWebsiteId() */ protected function _beforeDelete() { - $this->_protectFromNonAdmin(); $this->_configDataResource->clearStoreData($this->getStoreIds()); return parent::_beforeDelete(); } diff --git a/app/code/Magento/Core/Model/Store/ListInterface.php b/app/code/Magento/Core/Model/Store/ListInterface.php index 27692aebffdf9..aa21e58c39dfc 100644 --- a/app/code/Magento/Core/Model/Store/ListInterface.php +++ b/app/code/Magento/Core/Model/Store/ListInterface.php @@ -63,7 +63,7 @@ public function getStores($withDefault = false, $codeKey = false); * * @param null|bool|int|string|\Magento\Core\Model\Website $websiteId * @return \Magento\Core\Model\Website - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getWebsite($websiteId = null); @@ -95,7 +95,7 @@ public function getDefaultStoreView(); * * @param null|\Magento\Core\Model\Store\Group|string $groupId * @return \Magento\Core\Model\Store\Group - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getGroup($groupId = null); diff --git a/app/code/Magento/Core/Model/Store/Storage/Db.php b/app/code/Magento/Core/Model/Store/Storage/Db.php index a9a84685763e1..fbca3a5bad7d5 100644 --- a/app/code/Magento/Core/Model/Store/Storage/Db.php +++ b/app/code/Magento/Core/Model/Store/Storage/Db.php @@ -25,7 +25,7 @@ */ namespace Magento\Core\Model\Store\Storage; -use Magento\Core\Exception; +use Magento\Model\Exception; use Magento\App\State; use Magento\Core\Model\Store; use Magento\Core\Model\Store\StorageInterface; diff --git a/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php b/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php index ec7a190e3493d..0f42a18013051 100644 --- a/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php +++ b/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php @@ -125,7 +125,7 @@ public function getStores($withDefault = false, $codeKey = false) * * @param null|bool|int|string|\Magento\Core\Model\Website $websiteId * @return \Magento\Core\Model\Website - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getWebsite($websiteId = null) { @@ -160,7 +160,7 @@ public function getWebsites($withDefault = false, $codeKey = false) * * @param null|\Magento\Core\Model\Store\Group|string $groupId * @return \Magento\Core\Model\Store\Group - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getGroup($groupId = null) { diff --git a/app/code/Magento/Core/Model/StoreManager.php b/app/code/Magento/Core/Model/StoreManager.php index 1f2c3d85eda66..28a898e562fca 100644 --- a/app/code/Magento/Core/Model/StoreManager.php +++ b/app/code/Magento/Core/Model/StoreManager.php @@ -25,6 +25,14 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface { + /** + * Application run code + */ + const PARAM_RUN_CODE = 'MAGE_RUN_CODE'; + /** + * Application run type (store|website) + */ + const PARAM_RUN_TYPE = 'MAGE_RUN_TYPE'; /** * Store storage factory model * @@ -120,7 +128,7 @@ protected function _getStorage() * Retrieve application store object without Store_Exception * * @param string|int|Store $storeId - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return Store */ public function getSafeStore($storeId = null) @@ -133,7 +141,7 @@ public function getSafeStore($storeId = null) return new \Magento\Object(); } - throw new \Magento\Core\Exception(__('Requested invalid store "%1"', $storeId)); + throw new \Magento\Model\Exception(__('Requested invalid store "%1"', $storeId)); } } @@ -219,7 +227,7 @@ public function getStores($withDefault = false, $codeKey = false) * * @param null|bool|int|string|Website $websiteId * @return Website - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getWebsite($websiteId = null) { @@ -263,7 +271,7 @@ public function getDefaultStoreView() * * @param null|\Magento\Core\Model\Store\Group|string $groupId * @return \Magento\Core\Model\Store\Group - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getGroup($groupId = null) { diff --git a/app/code/Magento/Core/Model/Template.php b/app/code/Magento/Core/Model/Template.php index fbdf59a8491f8..d350ffc83bb4a 100644 --- a/app/code/Magento/Core/Model/Template.php +++ b/app/code/Magento/Core/Model/Template.php @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -abstract class Template extends \Magento\Core\Model\AbstractModel implements \Magento\App\TemplateTypesInterface +abstract class Template extends \Magento\Model\AbstractModel implements \Magento\App\TemplateTypesInterface { /** * Default design area for emulation diff --git a/app/code/Magento/Core/Model/Theme.php b/app/code/Magento/Core/Model/Theme.php index ebae55b422ea5..79d175b6b0638 100644 --- a/app/code/Magento/Core/Model/Theme.php +++ b/app/code/Magento/Core/Model/Theme.php @@ -26,6 +26,7 @@ namespace Magento\Core\Model; use Magento\View\Design\ThemeInterface; +use Magento\Model\AbstractModel; /** * Theme model class @@ -343,13 +344,13 @@ public function getDomainModel($type = null) * Validate theme data * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _validate() { if (!$this->_validator->validate($this)) { $messages = $this->_validator->getErrorMessages(); - throw new \Magento\Core\Exception(implode(PHP_EOL, reset($messages))); + throw new \Magento\Model\Exception(implode(PHP_EOL, reset($messages))); } return $this; } diff --git a/app/code/Magento/Backup/Model/Resource/HelperFactory.php b/app/code/Magento/Core/Model/Theme/Data/Collection.php similarity index 76% rename from app/code/Magento/Backup/Model/Resource/HelperFactory.php rename to app/code/Magento/Core/Model/Theme/Data/Collection.php index cdd97781a96a6..1cc81121ff374 100644 --- a/app/code/Magento/Backup/Model/Resource/HelperFactory.php +++ b/app/code/Magento/Core/Model/Theme/Data/Collection.php @@ -1,7 +1,5 @@ _collectionFactory = $collectionFactory; @@ -161,7 +161,7 @@ protected function _savePreviewImage(ThemeInterface $theme) if (!$theme->getPreviewImage() || !$themeDirectory) { return $this; } - $imagePath = $this->directoryRead->getAbsolutePath($themeDirectory . '/' . $theme->getPreviewImage()); + $imagePath = $themeDirectory . '/' . $theme->getPreviewImage(); if (0 === strpos($imagePath, $themeDirectory)) { $theme->getThemeImage()->createPreviewImage($imagePath); } diff --git a/app/code/Magento/Core/Model/Url/Rewrite.php b/app/code/Magento/Core/Model/Url/Rewrite.php index 64712657ff1e6..1dbf71fbce773 100644 --- a/app/code/Magento/Core/Model/Url/Rewrite.php +++ b/app/code/Magento/Core/Model/Url/Rewrite.php @@ -54,7 +54,7 @@ */ namespace Magento\Core\Model\Url; -class Rewrite extends \Magento\Core\Model\AbstractModel +class Rewrite extends \Magento\Model\AbstractModel { const TYPE_CATEGORY = 1; @@ -77,9 +77,9 @@ class Rewrite extends \Magento\Core\Model\AbstractModel protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\App + * @var \Magento\Stdlib\Cookie */ - protected $_app; + protected $_cookie; /** * @var \Magento\Core\Model\StoreManagerInterface @@ -95,10 +95,10 @@ class Rewrite extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\App $app + * @param \Magento\Stdlib\Cookie $cookie * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\Http\Context $httpContext - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -106,15 +106,15 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\App $app, + \Magento\Stdlib\Cookie $cookie, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\Http\Context $httpContext, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->_coreStoreConfig = $coreStoreConfig; - $this->_app = $app; + $this->_cookie = $cookie; $this->_storeManager = $storeManager; $this->_httpContext = $httpContext; parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -323,7 +323,7 @@ public function rewrite(\Magento\App\RequestInterface $request = null) $currentStore = $this->_storeManager->getStore(); $this->setStoreId($currentStore->getId())->loadByIdPath($this->getIdPath()); - $this->_app->getCookie()->set(\Magento\Core\Model\Store::COOKIE_NAME, $currentStore->getCode(), true); + $this->_cookie->set(\Magento\Core\Model\Store::COOKIE_NAME, $currentStore->getCode(), true); $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath(); $this->_sendRedirectHeaders($targetUrl, true); @@ -339,8 +339,7 @@ public function rewrite(\Magento\App\RequestInterface $request = null) $isPermanentRedirectOption = $this->hasOption('RP'); if ($external === 'http:/' || $external === 'https:') { $destinationStoreCode = $this->_storeManager->getStore($this->getStoreId())->getCode(); - $this->_app->getCookie()->set(\Magento\Core\Model\Store::COOKIE_NAME, $destinationStoreCode, true); - + $this->_cookie->set(\Magento\Core\Model\Store::COOKIE_NAME, $destinationStoreCode, true); $this->_sendRedirectHeaders($this->getTargetPath(), $isPermanentRedirectOption); } else { $targetUrl = $request->getBaseUrl() . '/' . $this->getTargetPath(); diff --git a/app/code/Magento/Core/Model/Validator/Factory.php b/app/code/Magento/Core/Model/Validator/Factory.php index d637298bb1d70..37954bba67195 100644 --- a/app/code/Magento/Core/Model/Validator/Factory.php +++ b/app/code/Magento/Core/Model/Validator/Factory.php @@ -32,11 +32,6 @@ class Factory */ protected $_objectManager; - /** - * @var \Magento\TranslateInterface - */ - protected $_translator; - /** * Validator config files * @@ -49,16 +44,12 @@ class Factory * * @param \Magento\ObjectManager $objectManager * @param \Magento\Module\Dir\Reader $moduleReader - * @param \Magento\TranslateInterface $translator */ public function __construct( \Magento\ObjectManager $objectManager, - \Magento\Module\Dir\Reader $moduleReader, - \Magento\TranslateInterface $translator + \Magento\Module\Dir\Reader $moduleReader ) { $this->_objectManager = $objectManager; - $this->_translator = $translator; - $this->_configFiles = $moduleReader->getConfigurationFiles('validation.xml'); $this->_initializeDefaultTranslator(); } @@ -70,12 +61,10 @@ public function __construct( */ protected function _initializeDefaultTranslator() { - $translateAdapter = $this->_translator; - $objectManager = $this->_objectManager; // Pass translations to \Magento\TranslateInterface from validators - $translatorCallback = function () use ($translateAdapter, $objectManager) { - /** @var \Magento\TranslateInterface $translateAdapter */ - return $translateAdapter->translate(func_get_args()); + $translatorCallback = function () { + $argc = func_get_args(); + return (string)new \Magento\Phrase(array_shift($argc), $argc); }; /** @var \Magento\Translate\Adapter $translator */ $translator = $this->_objectManager->create('Magento\Translate\Adapter'); diff --git a/app/code/Magento/Core/Model/Variable.php b/app/code/Magento/Core/Model/Variable.php index 79dd3e745de77..643ee7d791c2b 100644 --- a/app/code/Magento/Core/Model/Variable.php +++ b/app/code/Magento/Core/Model/Variable.php @@ -39,7 +39,7 @@ * @package Magento_Core * @author Magento Core Team */ -class Variable extends \Magento\Core\Model\AbstractModel +class Variable extends \Magento\Model\AbstractModel { const TYPE_TEXT = 'text'; diff --git a/app/code/Magento/Core/Model/Website.php b/app/code/Magento/Core/Model/Website.php index 9c250b09f8922..051e7b9947d15 100644 --- a/app/code/Magento/Core/Model/Website.php +++ b/app/code/Magento/Core/Model/Website.php @@ -45,7 +45,7 @@ * @method int getIsDefault() * @method \Magento\Core\Model\Website setIsDefault(int $value) */ -class Website extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface +class Website extends \Magento\Model\AbstractModel implements \Magento\Object\IdentityInterface { const ENTITY = 'core_website'; @@ -173,11 +173,6 @@ class Website extends \Magento\Core\Model\AbstractModel implements \Magento\Obje */ protected $_storeManager; - /** - * @var App - */ - protected $_app; - /** * @var \Magento\Directory\Model\CurrencyFactory */ @@ -186,15 +181,14 @@ class Website extends \Magento\Core\Model\AbstractModel implements \Magento\Obje /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\Resource\Config\Data $configDataResource + * @param Resource\Config\Data $configDataResource * @param \Magento\App\ConfigInterface $coreConfig - * @param \Magento\Core\Model\StoreFactory $storeFactory - * @param \Magento\Core\Model\Store\GroupFactory $storeGroupFactory - * @param \Magento\Core\Model\WebsiteFactory $websiteFactory - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\App $app + * @param StoreFactory $storeFactory + * @param Store\GroupFactory $storeGroupFactory + * @param WebsiteFactory $websiteFactory + * @param StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -207,9 +201,8 @@ public function __construct( \Magento\Core\Model\Store\GroupFactory $storeGroupFactory, \Magento\Core\Model\WebsiteFactory $websiteFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\App $app, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -220,7 +213,6 @@ public function __construct( $this->_storeGroupFactory = $storeGroupFactory; $this->_websiteFactory = $websiteFactory; $this->_storeManager = $storeManager; - $this->_app = $app; $this->_currencyFactory = $currencyFactory; } @@ -525,7 +517,6 @@ public function getCode() */ protected function _beforeDelete() { - $this->_protectFromNonAdmin(); $this->_configDataResource->clearWebsiteData($this); return parent::_beforeDelete(); } @@ -553,10 +544,14 @@ public function getBaseCurrencyCode() \Magento\Core\Model\Store::XML_PATH_PRICE_SCOPE ) == \Magento\Core\Model\Store::PRICE_SCOPE_GLOBAL ) { - return $this->_app->getBaseCurrencyCode(); + $currencyCode = $this->_coreConfig + ->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default'); + } else { - return $this->getConfig(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE); + $currencyCode = $this->getConfig(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE); } + + return $currencyCode; } /** diff --git a/app/code/Magento/Core/etc/cache.xml b/app/code/Magento/Core/etc/cache.xml index 12ace8c612cf6..33231b882fb84 100644 --- a/app/code/Magento/Core/etc/cache.xml +++ b/app/code/Magento/Core/etc/cache.xml @@ -36,10 +36,6 @@ Page blocks HTML. - - - Translation files. - Collection data files. diff --git a/app/code/Magento/Core/etc/config.xml b/app/code/Magento/Core/etc/config.xml index d824ed91c6881..11793f11b492a 100644 --- a/app/code/Magento/Core/etc/config.xml +++ b/app/code/Magento/Core/etc/config.xml @@ -40,13 +40,6 @@ 0 - - 0 - 0 - - - - 0 system.log diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml index 8364d687284fb..5bc0bd73fdca1 100644 --- a/app/code/Magento/Core/etc/di.xml +++ b/app/code/Magento/Core/etc/di.xml @@ -25,6 +25,7 @@ --> + @@ -36,12 +37,8 @@ - - - - @@ -53,12 +50,8 @@ - - - - @@ -68,13 +61,10 @@ - - - @@ -85,13 +75,6 @@ - - - Magento_Core::translate_inline.phtml - core/ajax/translate - Magento\View\LayoutInterface\Proxy - - @@ -242,23 +225,6 @@ Magento\View\Design\Theme\Image\Uploader\Proxy - - - - Magento\Phrase\Renderer\Translate - - - - - - Magento\Translate - - - - - Magento\Filter\Input\MaliciousCode - - Magento\App\Cache\Type\Config @@ -379,7 +345,7 @@ Magento\Locale\Hierarchy\Config\Reader - + core @@ -564,6 +530,15 @@ general/locale/code + + + + Magento\Core\Model\Store + Magento\Core\Model\Website + Magento\Core\Model\Store\Group + + + 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 deleted file mode 100644 index 0de15057781a4..0000000000000 --- a/app/code/Magento/Core/sql/core_setup/upgrade-1.6.0.15-1.6.0.16.php +++ /dev/null @@ -1,84 +0,0 @@ -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/js/require-cookie.js b/app/code/Magento/Core/view/frontend/js/require-cookie.js index bc1fa19f288df..3b50cae5410a2 100644 --- a/app/code/Magento/Core/view/frontend/js/require-cookie.js +++ b/app/code/Magento/Core/view/frontend/js/require-cookie.js @@ -56,13 +56,11 @@ * @private */ _checkCookie: function(event) { - $.cookie("test", 1); - if ($.cookie("test")) { - $.cookie("test", null); - } else { - event.preventDefault(); - window.location = this.options.noCookieUrl; + if (navigator.cookieEnabled) { + return; } + event.preventDefault(); + window.location = this.options.noCookieUrl; } }); })(jQuery); diff --git a/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php b/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php index 8b3e19d942a8c..5e4b8665cd175 100644 --- a/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php +++ b/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php @@ -25,14 +25,14 @@ */ namespace Magento\Cron\App\Cron\Plugin; -use Magento\AppInterface; +use \Magento\App\State; class ApplicationInitializer { /** - * @var \Magento\AppInterface + * @var State */ - protected $_application; + protected $_appState; /** * @var \Magento\Session\SidResolverInterface @@ -40,12 +40,12 @@ class ApplicationInitializer protected $_sidResolver; /** - * @param AppInterface $application + * @param State $appState * @param \Magento\Session\SidResolverInterface $sidResolver */ - public function __construct(AppInterface $application, \Magento\Session\SidResolverInterface $sidResolver) + public function __construct(State $appState, \Magento\Session\SidResolverInterface $sidResolver) { - $this->_application = $application; + $this->_appState = $appState; $this->_sidResolver = $sidResolver; } @@ -56,10 +56,13 @@ public function __construct(AppInterface $application, \Magento\Session\SidResol * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @throws \Magento\Exception */ public function beforeLaunch(\Magento\App\Cron $subject) { $this->_sidResolver->setUseSessionInUrl(false); - $this->_application->requireInstalledInstance(); + if (false == $this->_appState->isInstalled()) { + throw new \Magento\Exception('Application is not installed yet, please complete the installation first.'); + } } } diff --git a/app/code/Magento/Cron/Exception.php b/app/code/Magento/Cron/Exception.php index c2a848f5037d3..3bc47b481b114 100644 --- a/app/code/Magento/Cron/Exception.php +++ b/app/code/Magento/Cron/Exception.php @@ -33,6 +33,6 @@ */ namespace Magento\Cron; -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { } 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 204ec1d7fd6a4..316e7ffc89178 100644 --- a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php +++ b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php @@ -61,7 +61,7 @@ class Alert extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param string $runModelPath * @param array $data @@ -72,7 +72,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, $runModelPath = '', array $data = array() diff --git a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php index d8ed8bc0c5502..ffed40eed62d3 100644 --- a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php +++ b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php @@ -61,7 +61,7 @@ class Sitemap extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param string $runModelPath * @param array $data @@ -72,7 +72,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, $runModelPath = '', array $data = array() diff --git a/app/code/Magento/Cron/Model/Observer.php b/app/code/Magento/Cron/Model/Observer.php index 53e75916dc0e8..e19a27fcafb21 100644 --- a/app/code/Magento/Cron/Model/Observer.php +++ b/app/code/Magento/Cron/Model/Observer.php @@ -78,9 +78,9 @@ class Observer protected $_objectManager; /** - * @var \Magento\Core\Model\App + * @var \Magento\App\CacheInterface */ - protected $_app; + protected $_cache; /** * @var \Magento\Core\Model\Store\Config @@ -105,7 +105,7 @@ class Observer /** * @param \Magento\ObjectManager $objectManager * @param ScheduleFactory $scheduleFactory - * @param \Magento\AppInterface $app + * @param \Magento\App\CacheInterface $cache * @param ConfigInterface $config * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\App\Console\Request $request @@ -114,7 +114,7 @@ class Observer public function __construct( \Magento\ObjectManager $objectManager, \Magento\Cron\Model\ScheduleFactory $scheduleFactory, - \Magento\AppInterface $app, + \Magento\App\CacheInterface $cache, \Magento\Cron\Model\ConfigInterface $config, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\App\Console\Request $request, @@ -122,7 +122,7 @@ public function __construct( ) { $this->_objectManager = $objectManager; $this->_scheduleFactory = $scheduleFactory; - $this->_app = $app; + $this->_cache = $cache; $this->_config = $config; $this->_coreStoreConfig = $coreStoreConfig; $this->_request = $request; @@ -264,7 +264,7 @@ protected function _generate($groupId) /** * check if schedule generation is needed */ - $lastRun = (int)$this->_app->loadCache(self::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT); + $lastRun = (int)$this->_cache->load(self::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT); $rawSchedulePeriod = (int)$this->_coreStoreConfig->getConfig( 'system/cron/' . $groupId . '/' . self::XML_PATH_SCHEDULE_GENERATE_EVERY ); @@ -289,7 +289,7 @@ protected function _generate($groupId) /** * save time schedules generation was ran with no expiration */ - $this->_app->saveCache(time(), self::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, array('crontab'), null); + $this->_cache->save(time(), self::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, array('crontab'), null); return $this; } @@ -354,7 +354,7 @@ protected function _generateJobs($jobs, $exists, $groupId) protected function _cleanup($groupId) { // check if history cleanup is needed - $lastCleanup = (int)$this->_app->loadCache(self::CACHE_KEY_LAST_HISTORY_CLEANUP_AT); + $lastCleanup = (int)$this->_cache->load(self::CACHE_KEY_LAST_HISTORY_CLEANUP_AT); $historyCleanUp = (int)$this->_coreStoreConfig->getConfig( 'system/cron/' . $groupId . '/' . self::XML_PATH_HISTORY_CLEANUP_EVERY ); @@ -391,7 +391,7 @@ protected function _cleanup($groupId) } // save time history cleanup was ran with no expiration - $this->_app->saveCache(time(), self::CACHE_KEY_LAST_HISTORY_CLEANUP_AT, array('crontab'), null); + $this->_cache->save(time(), self::CACHE_KEY_LAST_HISTORY_CLEANUP_AT, array('crontab'), null); return $this; } diff --git a/app/code/Magento/Cron/Model/Resource/Schedule.php b/app/code/Magento/Cron/Model/Resource/Schedule.php index 62a4b0bab39ad..671919a16dd74 100644 --- a/app/code/Magento/Cron/Model/Resource/Schedule.php +++ b/app/code/Magento/Cron/Model/Resource/Schedule.php @@ -32,7 +32,7 @@ * @package Magento_Cron * @author Magento Core Team */ -class Schedule extends \Magento\Core\Model\Resource\Db\AbstractDb +class Schedule extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize resource diff --git a/app/code/Magento/Cron/Model/Resource/Schedule/Collection.php b/app/code/Magento/Cron/Model/Resource/Schedule/Collection.php index 5096e7540e548..361212c921dbc 100644 --- a/app/code/Magento/Cron/Model/Resource/Schedule/Collection.php +++ b/app/code/Magento/Cron/Model/Resource/Schedule/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Cron * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize resource collection diff --git a/app/code/Magento/Cron/Model/Schedule.php b/app/code/Magento/Cron/Model/Schedule.php index 3276cb83686ec..bc1e280b7716b 100644 --- a/app/code/Magento/Cron/Model/Schedule.php +++ b/app/code/Magento/Cron/Model/Schedule.php @@ -52,7 +52,7 @@ use Magento\Cron\Exception; -class Schedule extends \Magento\Core\Model\AbstractModel +class Schedule extends \Magento\Model\AbstractModel { const STATUS_PENDING = 'pending'; @@ -73,7 +73,7 @@ class Schedule extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Stdlib\DateTime\DateTime $date - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -81,7 +81,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Stdlib\DateTime\DateTime $date, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php index aa3d13cd6a439..ad6dc4c273d9e 100644 --- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php +++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php @@ -87,7 +87,7 @@ public function indexAction() * Fetch rates action * * @return void - * @throws \Exception|\Magento\Core\Exception + * @throws \Exception|\Magento\Model\Exception */ public function fetchRatesAction() { @@ -107,7 +107,7 @@ public function fetchRatesAction() $service ); } catch (\Exception $e) { - throw new \Magento\Core\Exception(__('We can\'t initialize the import model.')); + throw new \Magento\Model\Exception(__('We can\'t initialize the import model.')); } $rates = $importModel->fetchRates(); $errors = $importModel->getMessages(); diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Sidebar.php b/app/code/Magento/Customer/Block/Account/Dashboard/Sidebar.php index f04ae5c22d90c..31ab041353170 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Sidebar.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Sidebar.php @@ -136,7 +136,7 @@ public function getCartItemsCount() public function getWishlist() { if (!$this->_wishlist) { - $this->_wishlist = $this->_createWishList()->loadByCustomer($this->_customerSession->getCustomer()); + $this->_wishlist = $this->_createWishList()->loadByCustomerId($this->_customerSession->getId()); $this->_wishlist->getItemCollection()->addAttributeToSelect( 'name' )->addAttributeToSelect( diff --git a/app/code/Magento/Customer/Block/Adminhtml/Grid/Filter/Country.php b/app/code/Magento/Customer/Block/Adminhtml/Grid/Filter/Country.php index 7abfe300ead7a..f1a4c93bdfefc 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Grid/Filter/Country.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Grid/Filter/Country.php @@ -41,13 +41,13 @@ class Country extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Core\Model\Resource\Helper $resourceHelper + * @param \Magento\DB\Helper $resourceHelper * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Core\Model\Resource\Helper $resourceHelper, + \Magento\DB\Helper $resourceHelper, \Magento\Directory\Model\Resource\Country\CollectionFactory $collectionFactory, array $data = array() ) { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php index b3a0dad9f7557..843982e380cae 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php @@ -25,7 +25,7 @@ */ namespace Magento\Customer\Controller\Adminhtml\Cart\Product\Composite; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Catalog composite product configuration controller @@ -61,13 +61,13 @@ class Cart extends \Magento\Backend\App\Action * Loads customer, quote and quote item by request params * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _initData() { $this->_customerId = (int)$this->getRequest()->getParam('customer_id'); if (!$this->_customerId) { - throw new \Magento\Core\Exception(__('No customer ID defined.')); + throw new \Magento\Model\Exception(__('No customer ID defined.')); } $quoteItemId = (int)$this->getRequest()->getParam('id'); @@ -113,7 +113,7 @@ public function configureAction() $configureResult->setProductId($quoteItem->getProductId()); $configureResult->setBuyRequest($quoteItem->getBuyRequest()); $configureResult->setCurrentStoreId($quoteItem->getStoreId()); - $configureResult->setCustomerId($this->_customerId); + $configureResult->setCurrentCustomerId($this->_customerId); } catch (\Exception $e) { $configureResult->setError(true); $configureResult->setMessage($e->getMessage()); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index.php b/app/code/Magento/Customer/Controller/Adminhtml/Index.php index dd3988132d15b..9e1337b3c2c50 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index.php @@ -447,7 +447,7 @@ public function saveAction() $this->_addSessionErrorMessages($exception->getMessages()); $this->_getSession()->setCustomerData($originalRequestData); $returnToEdit = true; - } catch (\Magento\Core\Exception $exception) { + } catch (\Magento\Model\Exception $exception) { $messages = $exception->getMessages(\Magento\Message\MessageInterface::TYPE_ERROR); if (!count($messages)) { $messages = $exception->getMessage(); @@ -499,7 +499,7 @@ public function resetPasswordAction() $this->messageManager->addSuccess(__('Customer will receive an email with a link to reset password.')); } catch (NoSuchEntityException $exception) { return $this->_redirect('customer/index'); - } catch (\Magento\Core\Exception $exception) { + } catch (\Magento\Model\Exception $exception) { $messages = $exception->getMessages(\Magento\Message\MessageInterface::TYPE_ERROR); if (!count($messages)) { $messages = $exception->getMessage(); @@ -866,7 +866,7 @@ protected function _validateCustomer($response) $customer = $this->_customerBuilder->populateWithArray($data)->create(); $errors = $this->_customerAccountService->validateCustomerData($customer); - } catch (\Magento\Core\Exception $exception) { + } catch (\Magento\Model\Exception $exception) { /* @var $error Error */ foreach ($exception->getMessages(\Magento\Message\MessageInterface::TYPE_ERROR) as $error) { $errors[] = $error->getText(); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php b/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php index 2fbc9f05d51a1..b9cfe4b208461 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php @@ -26,7 +26,7 @@ namespace Magento\Customer\Controller\Adminhtml\Wishlist\Product\Composite; use Exception; -use Magento\Core\Exception as CoreException; +use Magento\Model\Exception as CoreException; /** * Catalog composite product configuration controller diff --git a/app/code/Magento/Customer/Exception.php b/app/code/Magento/Customer/Exception.php index 8b84e3a5f56fc..ed41bcbe793ea 100644 --- a/app/code/Magento/Customer/Exception.php +++ b/app/code/Magento/Customer/Exception.php @@ -25,6 +25,6 @@ */ namespace Magento\Customer; -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { } diff --git a/app/code/Magento/Customer/Helper/Data.php b/app/code/Magento/Customer/Helper/Data.php index 69d2be5b4785c..a02b517057a47 100644 --- a/app/code/Magento/Customer/Helper/Data.php +++ b/app/code/Magento/Customer/Helper/Data.php @@ -625,7 +625,7 @@ public function checkVatNumber($countryCode, $vatNumber, $requesterCountryCode = ); if (!extension_loaded('soap')) { - $this->_logger->logException(new \Magento\Core\Exception(__('PHP SOAP extension is required.'))); + $this->_logger->logException(new \Magento\Model\Exception(__('PHP SOAP extension is required.'))); return $gatewayResponse; } diff --git a/app/code/Magento/Customer/Model/Address.php b/app/code/Magento/Customer/Model/Address.php index d7da6853e8beb..35393abbabf30 100644 --- a/app/code/Magento/Customer/Model/Address.php +++ b/app/code/Magento/Customer/Model/Address.php @@ -54,7 +54,7 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory * @param CustomerFactory $customerFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -67,7 +67,7 @@ public function __construct( \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Directory\Model\CountryFactory $countryFactory, CustomerFactory $customerFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index 7494dd43864b8..89b932e87bf89 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -39,7 +39,7 @@ * @method string getPostcode() * @method bool getShouldIgnoreValidation() */ -class AbstractAddress extends \Magento\Core\Model\AbstractModel +class AbstractAddress extends \Magento\Model\AbstractModel { /** * Possible customer address types @@ -111,7 +111,7 @@ class AbstractAddress extends \Magento\Core\Model\AbstractModel * @param Config $addressConfig * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -123,7 +123,7 @@ public function __construct( Config $addressConfig, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Directory\Model\CountryFactory $countryFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 61a2a5e8a9cc8..45ceee4f1c16a 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php @@ -43,7 +43,7 @@ class Street extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -53,7 +53,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Eav\Model\Config $eavConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -91,7 +91,7 @@ protected function _afterSave() /** * Processing object after delete data * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _afterDelete() { 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 04e72ebb6f615..7c10a970c40ae 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php @@ -47,7 +47,7 @@ class Customer extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -57,7 +57,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Eav\Model\Config $eavConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -132,7 +132,7 @@ protected function _afterSave() /** * Processing object after delete data * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _afterDelete() { diff --git a/app/code/Magento/Customer/Model/Config/Share.php b/app/code/Magento/Customer/Model/Config/Share.php index 97027cef12468..8b87015f59d02 100644 --- a/app/code/Magento/Customer/Model/Config/Share.php +++ b/app/code/Magento/Customer/Model/Config/Share.php @@ -69,7 +69,7 @@ class Share extends \Magento\Core\Model\Config\Value implements \Magento\Option\ * @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 + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -80,7 +80,7 @@ public function __construct( \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Customer\Model\Resource\Customer $customerResource, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -123,7 +123,7 @@ public function toOptionArray() * Check for email duplicates before saving customers sharing options * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function _beforeSave() { @@ -131,7 +131,7 @@ public function _beforeSave() if ($value == self::SHARE_GLOBAL) { if ($this->_customerResource->findEmailDuplicates()) { //@codingStandardsIgnoreStart - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Cannot share customer accounts globally because some customer accounts with the same emails exist on multiple websites and cannot be merged.' ) diff --git a/app/code/Magento/Customer/Model/Converter.php b/app/code/Magento/Customer/Model/Converter.php index f767f012c43b3..cf1650eddec17 100644 --- a/app/code/Magento/Customer/Model/Converter.php +++ b/app/code/Magento/Customer/Model/Converter.php @@ -90,6 +90,17 @@ public function getCustomerModel($customerId) } } + /** + * Retrieve customer model by his ID if possible, or return an empty model otherwise. + * + * @param int $customerId + * @return Customer + */ + public function loadCustomerModel($customerId) + { + return $this->_customerFactory->create()->load($customerId); + } + /** * Retrieve customer model by his email. * diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index 67280ec72f7d5..390288b6ab8b5 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -44,7 +44,7 @@ * @method \Magento\Customer\Model\Customer setDefaultBilling($value) * @method \Magento\Customer\Model\Customer setDefaultShipping($value) */ -class Customer extends \Magento\Core\Model\AbstractModel +class Customer extends \Magento\Model\AbstractModel { /** * Configuration paths for email templates and identities @@ -292,19 +292,19 @@ public function getSharingConfig() * @param string $login * @param string $password * @return bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function authenticate($login, $password) { $this->loadByEmail($login); if ($this->getConfirmation() && $this->isConfirmationRequired()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('This account is not confirmed.'), self::EXCEPTION_EMAIL_NOT_CONFIRMED ); } if (!$this->validatePassword($password)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Invalid login or password.'), self::EXCEPTION_INVALID_EMAIL_OR_PASSWORD ); @@ -710,7 +710,7 @@ public function isAddressPrimary(Address $address) * @param string $backUrl * @param string $storeId * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0') { @@ -725,7 +725,7 @@ public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeI 'confirmation' => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE ); if (!isset($types[$type])) { - throw new \Magento\Core\Exception(__('Wrong transactional account email type')); + throw new \Magento\Model\Exception(__('Wrong transactional account email type')); } if (!$storeId) { @@ -1072,7 +1072,6 @@ public function resetErrors() protected function _beforeDelete() { //TODO : Revisit and figure handling permissions in MAGETWO-11084 Implementation: Service Context Provider - //$this->_protectFromNonAdmin(); return parent::_beforeDelete(); } @@ -1162,7 +1161,7 @@ public function canSkipConfirmation() /* If an email was used to start the registration process and it is the same email as the one used to register, then this can skip confirmation. */ - $skipConfirmationIfEmail = $this->_coreRegistry->registry("skip_confirmation_if_email"); + $skipConfirmationIfEmail = $this->_registry->registry("skip_confirmation_if_email"); if (!$skipConfirmationIfEmail) { return false; } @@ -1235,12 +1234,12 @@ protected function _getWebsiteStoreId($defaultStoreId = null) * * @param string $passwordLinkToken * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function changeResetPasswordLinkToken($passwordLinkToken) { if (!is_string($passwordLinkToken) || empty($passwordLinkToken)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Invalid password reset token.'), self::EXCEPTION_INVALID_RESET_PASSWORD_LINK_TOKEN ); diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php index 0fd7f93accf73..dd3ed177a3004 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php @@ -25,7 +25,7 @@ */ namespace Magento\Customer\Model\Customer\Attribute\Backend; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Customer password attribute backend diff --git a/app/code/Magento/Customer/Model/Group.php b/app/code/Magento/Customer/Model/Group.php index 07ef668833e8a..dff1b59c1ef3d 100644 --- a/app/code/Magento/Customer/Model/Group.php +++ b/app/code/Magento/Customer/Model/Group.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_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) */ @@ -33,12 +31,8 @@ * @method string getCustomerGroupCode() * @method \Magento\Customer\Model\Group setCustomerGroupCode(string $value) * @method \Magento\Customer\Model\Group setTaxClassId(int $value) - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team */ -class Group extends \Magento\Core\Model\AbstractModel +class Group extends \Magento\Model\AbstractModel { /** * Xml config path for create account default group @@ -91,7 +85,7 @@ class Group extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Core\Model\Store\Config $storeConfig * @param \Magento\Index\Model\Indexer $indexer - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -100,7 +94,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Core\Model\Store\Config $storeConfig, \Magento\Index\Model\Indexer $indexer, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -139,7 +133,9 @@ public function getCode() } /** - * @param int|null $groupId + * Get the tax class id for the specified group or this group if the groupId is null + * + * @param int|null $groupId The id of the group whose tax class id is being sought * @return int */ public function getTaxClassId($groupId = null) @@ -155,6 +151,8 @@ public function getTaxClassId($groupId = null) } /** + * Determine if this group is used as the create account default group + * * @return bool */ public function usesAsDefault() diff --git a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php index 85f3d3fc2bfb2..34b773df49e0b 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php @@ -124,12 +124,12 @@ public function __construct( * Return Attribute instance * * @return \Magento\Customer\Service\V1\Data\Eav\AttributeMetadata - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getAttribute() { if (!$this->_attribute) { - throw new \Magento\Core\Exception(__('Attribute object is undefined')); + throw new \Magento\Model\Exception(__('Attribute object is undefined')); } return $this->_attribute; } @@ -506,7 +506,7 @@ abstract public function extractValue(\Magento\App\RequestInterface $request); * * @param array|string|null $value * @return array|bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ abstract public function validateValue($value); diff --git a/app/code/Magento/Customer/Model/Observer.php b/app/code/Magento/Customer/Model/Observer.php index 98d07664f5e92..ee00bb5fc3bc1 100644 --- a/app/code/Magento/Customer/Model/Observer.php +++ b/app/code/Magento/Customer/Model/Observer.php @@ -218,27 +218,4 @@ public function afterAddressSave($observer) $this->_coreRegistry->register(self::VIV_PROCESSED_FLAG, false, true); } } - - /** - * Revert emulated customer group_id - * - * @param \Magento\Event\Observer $observer - * @return void - */ - public function quoteSubmitAfter($observer) - { - /** @var $customer Customer */ - $customer = $observer->getQuote()->getCustomer(); - - if (!$this->_customerAddress->isVatValidationEnabled($customer->getStore())) { - return; - } - - if (!$customer->getId()) { - return; - } - - $customer->setGroupId((int)$customer->getOrigData('group_id')); - $customer->save(); - } } diff --git a/app/code/Magento/Customer/Model/Resource/Customer.php b/app/code/Magento/Customer/Model/Resource/Customer.php index 0c7068515f2b6..d904f9b976b1c 100644 --- a/app/code/Magento/Customer/Model/Resource/Customer.php +++ b/app/code/Magento/Customer/Model/Resource/Customer.php @@ -109,7 +109,7 @@ protected function _getDefaultAttributes() * @param \Magento\Object $customer * @return $this * @throws \Magento\Customer\Exception - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeSave(\Magento\Object $customer) { @@ -266,7 +266,7 @@ protected function _getLoadRowSelect($object, $rowId) * @param \Magento\Customer\Model\Customer $customer * @param string $email * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function loadByEmail(\Magento\Customer\Model\Customer $customer, $email) { @@ -281,7 +281,7 @@ public function loadByEmail(\Magento\Customer\Model\Customer $customer, $email) if ($customer->getSharingConfig()->isWebsiteScope()) { if (!$customer->hasData('website_id')) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Customer website ID must be specified when using the website scope') ); } diff --git a/app/code/Magento/Customer/Model/Resource/Group.php b/app/code/Magento/Customer/Model/Resource/Group.php index 7d21b16af7775..61e6fe27b0cf9 100644 --- a/app/code/Magento/Customer/Model/Resource/Group.php +++ b/app/code/Magento/Customer/Model/Resource/Group.php @@ -32,7 +32,7 @@ * @package Magento_Customer * @author Magento Core Team */ -class Group extends \Magento\Core\Model\Resource\Db\AbstractDb +class Group extends \Magento\Model\Resource\Db\AbstractDb { /** * Customer data @@ -86,14 +86,14 @@ protected function _initUniqueFields() /** * Check if group uses as default * - * @param \Magento\Core\Model\AbstractModel $group + * @param \Magento\Model\AbstractModel $group * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - protected function _beforeDelete(\Magento\Core\Model\AbstractModel $group) + protected function _beforeDelete(\Magento\Model\AbstractModel $group) { if ($group->usesAsDefault()) { - throw new \Magento\Core\Exception(__('The group "%1" cannot be deleted', $group->getCode())); + throw new \Magento\Model\Exception(__('The group "%1" cannot be deleted', $group->getCode())); } return parent::_beforeDelete($group); } @@ -101,10 +101,10 @@ protected function _beforeDelete(\Magento\Core\Model\AbstractModel $group) /** * Method set default group id to the customers collection * - * @param \Magento\Core\Model\AbstractModel $group + * @param \Magento\Model\AbstractModel $group * @return $this */ - protected function _afterDelete(\Magento\Core\Model\AbstractModel $group) + protected function _afterDelete(\Magento\Model\AbstractModel $group) { $customerCollection = $this->_createCustomersCollection()->addAttributeToFilter( 'group_id', diff --git a/app/code/Magento/Customer/Model/Resource/Group/Collection.php b/app/code/Magento/Customer/Model/Resource/Group/Collection.php index 57dbc29bd6ce8..811859079be69 100644 --- a/app/code/Magento/Customer/Model/Resource/Group/Collection.php +++ b/app/code/Magento/Customer/Model/Resource/Group/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Customer * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php index 3046433d139f6..ff23fc03068b7 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php @@ -34,8 +34,10 @@ use Magento\Exception\AuthenticationException; use Magento\Exception\NoSuchEntityException; use Magento\Exception\StateException; +use Magento\Mail\Exception as MailException; use Magento\Math\Random; use Magento\UrlInterface; +use Magento\Logger; /** * Handle various customer account actions @@ -100,6 +102,11 @@ class CustomerAccountService implements CustomerAccountServiceInterface */ private $_url; + /** + * @var Logger + */ + protected $_logger; + /** * Constructor * @@ -115,6 +122,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface * @param CustomerAddressServiceInterface $customerAddressService * @param CustomerMetadataServiceInterface $customerMetadataService * @param UrlInterface $url + * @param Logger $logger * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -130,7 +138,8 @@ public function __construct( Data\SearchResultsBuilder $searchResultsBuilder, CustomerAddressServiceInterface $customerAddressService, CustomerMetadataServiceInterface $customerMetadataService, - UrlInterface $url + UrlInterface $url, + Logger $logger ) { $this->_customerFactory = $customerFactory; $this->_eventManager = $eventManager; @@ -144,6 +153,7 @@ public function __construct( $this->_customerAddressService = $customerAddressService; $this->_customerMetadataService = $customerMetadataService; $this->_url = $url; + $this->_logger = $logger; } /** @@ -157,11 +167,16 @@ public function resendConfirmation($email, $websiteId, $redirectUrl = '') throw (new NoSuchEntityException('email', $email))->addField('websiteId', $websiteId); } if ($customer->getConfirmation()) { - $customer->sendNewAccountEmail( - self::NEW_ACCOUNT_EMAIL_CONFIRMATION, - $redirectUrl, - $this->_storeManager->getStore()->getId() - ); + try { + $customer->sendNewAccountEmail( + self::NEW_ACCOUNT_EMAIL_CONFIRMATION, + $redirectUrl, + $this->_storeManager->getStore()->getId() + ); + } catch (MailException $e) { + // If we are not able to send a new account email, this should be ignored + $this->_logger->logException($e); + } } else { throw new StateException('No confirmation needed.', StateException::INVALID_STATE); } @@ -200,7 +215,7 @@ public function authenticate($username, $password) $customerModel->setWebsiteId($this->_storeManager->getStore()->getWebsiteId()); try { $customerModel->authenticate($username, $password); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { switch ($e->getCode()) { case CustomerModel::EXCEPTION_EMAIL_NOT_CONFIRMED: $code = AuthenticationException::EMAIL_NOT_CONFIRMED; @@ -248,15 +263,20 @@ public function initiatePasswordReset($email, $websiteId, $template) ); $customer->setResetPasswordUrl($resetUrl); - switch ($template) { - case CustomerAccountServiceInterface::EMAIL_REMINDER: - $customer->sendPasswordReminderEmail(); - break; - case CustomerAccountServiceInterface::EMAIL_RESET: - $customer->sendPasswordResetConfirmationEmail(); - break; - default: - throw new InputException(__('Invalid email type.'), InputException::INVALID_FIELD_VALUE); + try { + switch ($template) { + case CustomerAccountServiceInterface::EMAIL_REMINDER: + $customer->sendPasswordReminderEmail(); + break; + case CustomerAccountServiceInterface::EMAIL_RESET: + $customer->sendPasswordResetConfirmationEmail(); + break; + default: + throw new InputException(__('Invalid email type.'), InputException::INVALID_FIELD_VALUE); + } + } catch (MailException $e) { + // If we are not able to send a reset password email, this should be ignored + $this->_logger->logException($e); } } @@ -331,18 +351,23 @@ public function createAccount(Data\CustomerDetails $customerDetails, $password = $newLinkToken = $this->_mathRandom->getUniqueHash(); $customerModel->changeResetPasswordLinkToken($newLinkToken); - if ($customerModel->isConfirmationRequired()) { - $customerModel->sendNewAccountEmail( - self::NEW_ACCOUNT_EMAIL_CONFIRMATION, - $redirectUrl, - $customer->getStoreId() - ); - } else { - $customerModel->sendNewAccountEmail( - self::NEW_ACCOUNT_EMAIL_REGISTERED, - $redirectUrl, - $customer->getStoreId() - ); + try { + if ($customerModel->isConfirmationRequired()) { + $customerModel->sendNewAccountEmail( + self::NEW_ACCOUNT_EMAIL_CONFIRMATION, + $redirectUrl, + $customer->getStoreId() + ); + } else { + $customerModel->sendNewAccountEmail( + self::NEW_ACCOUNT_EMAIL_REGISTERED, + $redirectUrl, + $customer->getStoreId() + ); + } + } catch (MailException $e) { + // If we are not able to send a new account email, this should be ignored + $this->_logger->logException($e); } return $this->_converter->createCustomerFromModel($customerModel); } diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 3f0e19c184d6a..06620c2e64fcf 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -89,4 +89,11 @@ Magento\Url + + + + Magento\Customer\Model\Customer + + + diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php index 94c5fc6addc7c..17c9ffe23c47b 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php @@ -99,7 +99,7 @@ protected function _addElementTypes() * Get component of 'checkbox' type (actually 'tile') * * @return \Magento\Data\Form\Element\Checkbox - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getCheckboxElement() { @@ -112,7 +112,7 @@ public function getCheckboxElement() } } - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Element "%1" is not found in "%2".', $checkboxId, $this->getData('name')) ); } @@ -121,7 +121,7 @@ public function getCheckboxElement() * Get component of 'image-uploader' type * * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\ImageUploader - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getImageUploaderElement() { @@ -132,7 +132,7 @@ public function getImageUploaderElement() return $e; } } - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Element "%1" is not found in "%2".', $imageUploaderId, $this->getData('name')) ); } diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php index f938aec0b0ca6..0aeaf326b9f54 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php @@ -100,12 +100,12 @@ public function setRendererFactory($factory) /** * @return \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Form\Renderer\Factory - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getRendererFactory() { if (!$this->_rendererFactory) { - throw new \Magento\Core\Exception('Renderer factory was not set'); + throw new \Magento\Model\Exception('Renderer factory was not set'); } return $this->_rendererFactory; } @@ -122,12 +122,12 @@ public function setElementsFactory($factory) /** * @return \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Form\Element\Factory - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getElementsFactory() { if (!$this->_elementsFactory) { - throw new \Magento\Core\Exception('Form elements factory was not set'); + throw new \Magento\Model\Exception('Form elements factory was not set'); } return $this->_elementsFactory; } diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php index c5239097b1ca0..c8c83faf1dd55 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php @@ -129,7 +129,7 @@ public function addField($elementId, $type, $config, $after = false, $isAdvanced $layoutName = $element->getId() . '-renderer'; try { $renderer = $this->_rendererFactory->create($className, $layoutName); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $renderer = null; } if ($renderer) { @@ -145,14 +145,14 @@ public function addField($elementId, $type, $config, $after = false, $isAdvanced * @param string $type * @param string|null $subtype * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getComponent($type, $subtype = null) { $components = $this->getComponents(); $componentId = $this->getComponentId($type); if (!isset($components[$componentId])) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Component of the type "%1" is not found between elements of "%2"', $type, $this->getData('name')) ); } diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/AbstractTab.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/AbstractTab.php index 29d46acd263d6..034fa038f3a51 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/AbstractTab.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/AbstractTab.php @@ -81,12 +81,12 @@ public function __construct( * Create a form element with necessary controls * * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\QuickStyles\Header - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _prepareForm() { if (!$this->_formId || !$this->_tab) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We found an invalid block of class "%1". Please define the required properties.', get_class($this)) ); } diff --git a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor.php b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor.php index 40f0e44042cc2..10db01f3f2a73 100644 --- a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor.php +++ b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor.php @@ -26,7 +26,7 @@ namespace Magento\DesignEditor\Controller\Adminhtml\System\Design; use Magento\Core\Model\Store; -use Magento\Core\Exception as CoreException; +use Magento\Model\Exception as CoreException; use Magento\View\Design\ThemeInterface; /** 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 a6b4ec621478d..de1b8b348bda3 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 @@ -25,7 +25,7 @@ */ namespace Magento\DesignEditor\Controller\Adminhtml\System\Design\Editor; -use Magento\Core\Exception as CoreException; +use Magento\Model\Exception as CoreException; /** * Backend controller for the design editor diff --git a/app/code/Magento/DesignEditor/Helper/Data.php b/app/code/Magento/DesignEditor/Helper/Data.php index 7c48ab4b000f4..6443819f42766 100644 --- a/app/code/Magento/DesignEditor/Helper/Data.php +++ b/app/code/Magento/DesignEditor/Helper/Data.php @@ -33,6 +33,11 @@ */ class Data extends \Magento\App\Helper\AbstractHelper { + /** + * Parameter to indicate the translation mode (null, text, script, or alt). + */ + const TRANSLATION_MODE = "translation_mode"; + /** * XML path to VDE front name setting * @@ -47,16 +52,6 @@ class Data extends \Magento\App\Helper\AbstractHelper */ protected $_disabledCacheTypes; - /** - * Parameter to indicate the translation mode (null, text, script, or alt). - */ - const TRANSLATION_MODE = "translation_mode"; - - /** - * @var bool - */ - protected $_isVdeRequest = false; - /** * @var string */ @@ -94,41 +89,6 @@ public function getDisabledCacheTypes() return $this->_disabledCacheTypes; } - /** - * This method returns an indicator of whether or not the current request is for vde - * - * @param RequestInterface $request - * @return bool - */ - public function isVdeRequest(RequestInterface $request = null) - { - if (null !== $request) { - $result = false; - $splitPath = explode('/', trim($request->getOriginalPathInfo(), '/')); - if (count($splitPath) >= 3) { - list($frontName, $currentMode, $themeId) = $splitPath; - $result = $frontName === $this->getFrontName() && in_array( - $currentMode, - $this->getAvailableModes() - ) && is_numeric( - $themeId - ); - } - $this->_isVdeRequest = $result; - } - return $this->_isVdeRequest; - } - - /** - * Get available modes for Design Editor - * - * @return string[] - */ - public function getAvailableModes() - { - return array(\Magento\DesignEditor\Model\State::MODE_NAVIGATION); - } - /** * Returns the translation mode the current request is in (null, text, script, or alt). * @@ -160,4 +120,28 @@ public function isAllowed() { return $this->_translationMode !== null; } + + /** + * This method returns an indicator of whether or not the current request is for vde + * + * @param RequestInterface $request + * @return bool + */ + public function isVdeRequest(RequestInterface $request = null) + { + $result = false; + if (null !== $request) { + $splitPath = explode('/', trim($request->getOriginalPathInfo(), '/')); + if (count($splitPath) >= 3) { + list($frontName, $currentMode, $themeId) = $splitPath; + $result = $frontName === $this->_frontName && in_array( + $currentMode, + [\Magento\DesignEditor\Model\State::MODE_NAVIGATION] + ) && is_numeric( + $themeId + ); + } + } + return $result; + } } diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php index b21ebe955ee61..82cc86befef5b 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php @@ -207,12 +207,12 @@ public function getAllControlsData() * * @param string $controlName * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getControlData($controlName) { if (!isset($this->_controlList[$controlName])) { - throw new \Magento\Core\Exception("Unknown control: \"{$controlName}\""); + throw new \Magento\Model\Exception("Unknown control: \"{$controlName}\""); } return $this->_controlList[$controlName]; } diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php index 48f5a09792714..b0e2a24ba578e 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php @@ -83,12 +83,12 @@ public function __construct(\Magento\View\LayoutInterface $layout) * @param string $elementClassName * @param string $rendererName * @return RendererInterface - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function create($elementClassName, $rendererName) { if (!isset($this->_rendererByElement[$elementClassName])) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( sprintf('No renderer registered for elements of class "%s"', $elementClassName) ); } diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php index cc0eb21173654..34d0068a7abbc 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php @@ -136,7 +136,7 @@ public function uploadFile($key) if (!$uploader->save($this->getStoragePath())) { /** @todo add translator */ - throw new \Magento\Core\Exception('Cannot upload file.'); + throw new \Magento\Model\Exception('Cannot upload file.'); } $result['css_path'] = implode( '/', diff --git a/app/code/Magento/DesignEditor/Model/Observer.php b/app/code/Magento/DesignEditor/Model/Observer.php index c829aa4224113..8bd15c177820b 100644 --- a/app/code/Magento/DesignEditor/Model/Observer.php +++ b/app/code/Magento/DesignEditor/Model/Observer.php @@ -135,19 +135,4 @@ public function saveChangeTime($event) $change->save(); } } - - /** - * Determine if the vde specific translation class should be used. - * - * @param EventObserver $observer - * @return $this - */ - public function initializeTranslation(EventObserver $observer) - { - if ($this->_helper->isVdeRequest()) { - // Request is for vde. Override the translation class. - $observer->getResult()->setInlineType('Magento\DesignEditor\Model\Translate\InlineVde'); - } - return $this; - } } diff --git a/app/code/Magento/DesignEditor/Model/State.php b/app/code/Magento/DesignEditor/Model/State.php index 9d30e30183c60..f7c6f503ae7da 100644 --- a/app/code/Magento/DesignEditor/Model/State.php +++ b/app/code/Magento/DesignEditor/Model/State.php @@ -82,9 +82,9 @@ class State protected $_objectManager; /** - * @var \Magento\Core\Model\App + * @var \Magento\App\ConfigInterface */ - protected $_application; + protected $_configuration; /** * Store list manager @@ -96,12 +96,12 @@ class State /** * @param \Magento\Backend\Model\Session $backendSession * @param AreaEmulator $areaEmulator - * @param \Magento\DesignEditor\Model\Url\Factory $urlModelFactory + * @param Url\Factory $urlModelFactory * @param \Magento\App\Cache\StateInterface $cacheState * @param \Magento\DesignEditor\Helper\Data $dataHelper * @param \Magento\ObjectManager $objectManager - * @param \Magento\Core\Model\App $application - * @param \Magento\DesignEditor\Model\Theme\Context $themeContext + * @param \Magento\App\ConfigInterface $configuration + * @param Theme\Context $themeContext * @param \Magento\Core\Model\StoreManagerInterface $storeManager */ public function __construct( @@ -111,7 +111,7 @@ public function __construct( \Magento\App\Cache\StateInterface $cacheState, \Magento\DesignEditor\Helper\Data $dataHelper, \Magento\ObjectManager $objectManager, - \Magento\Core\Model\App $application, + \Magento\App\ConfigInterface $configuration, \Magento\DesignEditor\Model\Theme\Context $themeContext, \Magento\Core\Model\StoreManagerInterface $storeManager ) { @@ -121,7 +121,7 @@ public function __construct( $this->_cacheState = $cacheState; $this->_dataHelper = $dataHelper; $this->_objectManager = $objectManager; - $this->_application = $application; + $this->_configuration = $configuration; $this->_themeContext = $themeContext; $this->_storeManager = $storeManager; } @@ -203,7 +203,7 @@ protected function _setTheme() if ($this->_themeContext->getEditableTheme()) { $themeId = $this->_themeContext->getVisibleTheme()->getId(); $this->_storeManager->getStore()->setConfig(\Magento\View\DesignInterface::XML_PATH_THEME_ID, $themeId); - $this->_application->getConfig()->setValue(\Magento\View\DesignInterface::XML_PATH_THEME_ID, $themeId); + $this->_configuration->setValue(\Magento\View\DesignInterface::XML_PATH_THEME_ID, $themeId); } } diff --git a/app/code/Magento/DesignEditor/Model/Theme/Change.php b/app/code/Magento/DesignEditor/Model/Theme/Change.php index 030e5e6fda4fe..616cffd7d2208 100644 --- a/app/code/Magento/DesignEditor/Model/Theme/Change.php +++ b/app/code/Magento/DesignEditor/Model/Theme/Change.php @@ -28,7 +28,7 @@ /** * Design editor theme change */ -class Change extends \Magento\Core\Model\AbstractModel +class Change extends \Magento\Model\AbstractModel { /** * Theme model initialization diff --git a/app/code/Magento/DesignEditor/Model/Theme/Context.php b/app/code/Magento/DesignEditor/Model/Theme/Context.php index 8d8732671f1d1..2e41b1971aa88 100644 --- a/app/code/Magento/DesignEditor/Model/Theme/Context.php +++ b/app/code/Magento/DesignEditor/Model/Theme/Context.php @@ -25,7 +25,7 @@ */ namespace Magento\DesignEditor\Model\Theme; -use Magento\Core\Exception as CoreException; +use Magento\Model\Exception as CoreException; /** * Design editor theme context diff --git a/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php b/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php index 06244e7dd1d7c..2b325ac2e3307 100644 --- a/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php +++ b/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php @@ -28,7 +28,7 @@ /** * Theme change resource model */ -class Change extends \Magento\Core\Model\Resource\Db\AbstractDb +class Change extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Stdlib\DateTime @@ -59,10 +59,10 @@ protected function _construct() /** * {@inheritdoc} * - * @param \Magento\Core\Model\AbstractModel $change + * @param \Magento\Model\AbstractModel $change * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $change) + protected function _beforeSave(\Magento\Model\AbstractModel $change) { if (!$change->getChangeTime()) { $change->setChangeTime($this->dateTime->formatDate(true)); diff --git a/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php b/app/code/Magento/DesignEditor/Model/Translate/Inline.php similarity index 68% rename from app/code/Magento/DesignEditor/Model/Translate/InlineVde.php rename to app/code/Magento/DesignEditor/Model/Translate/Inline.php index c1b4381e1f81f..0ff98a882a028 100644 --- a/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php +++ b/app/code/Magento/DesignEditor/Model/Translate/Inline.php @@ -28,37 +28,27 @@ /** * Inline translation specific to Vde. */ -class InlineVde implements \Magento\Translate\InlineInterface +class Inline implements \Magento\Translate\InlineInterface { /** * data-translate-mode attribute name */ const TRANSLATE_MODE = 'data-translate-mode'; - /** - * text translate mode + /**#@+ + * Translate modes */ const MODE_TEXT = 'text'; - - /** - * img element name - */ - const ELEMENT_IMG = 'img'; - - /** - * alt translate mode - */ const MODE_ALT = 'alt'; - - /** - * script translate mode - */ const MODE_SCRIPT = 'script'; + /**#@-*/ - /** - * script element name + /**#@+ + * Html tags */ - const ELEMENT_SCRIPT = self::MODE_SCRIPT; + const TAG_IMG = 'img'; + const TAG_SCRIPT = 'script'; + /**#@-*/ /** * @var \Magento\DesignEditor\Helper\Data @@ -70,6 +60,11 @@ class InlineVde implements \Magento\Translate\InlineInterface */ protected $_parser; + /** + * @var \Magento\Translate\Inline\ParserFactory + */ + protected $parserFactory; + /** * @var \Magento\UrlInterface */ @@ -117,13 +112,15 @@ public function __construct( ) { $this->_design = $design; $this->_scopeResolver = $scopeResolver; - $this->_parser = $parserFactory->create(array('translateInline' => $this)); + $this->parserFactory = $parserFactory; $this->_helper = $helper; $this->_url = $url; $this->_objectManager = $objectManager; } /** + * Check if Inline Translates is allowed + * * Translation within the vde will be enabled by the client when the 'Edit' button is enabled. * * @return bool @@ -133,6 +130,19 @@ public function isAllowed() return $this->_helper->isAllowed(); } + /** + * Retrieve Inline Parser instance + * + * @return \Magento\Translate\Inline\ParserInterface + */ + public function getParser() + { + if (!$this->_parser) { + $this->_parser = $this->parserFactory->create(['translateInline' => $this]); + } + return $this->_parser; + } + /** * Replace VDE specific translation templates with HTML fragments * @@ -142,15 +152,24 @@ public function isAllowed() */ public function processResponseBody(&$body, $isJson = false) { + if (!$this->isAllowed()) { + return $this; + } + + $this->getParser()->setIsJson($isJson); + if (is_array($body)) { foreach ($body as &$part) { $this->processResponseBody($part, $isJson); } } elseif (is_string($body)) { - $content = $this->_parser->processResponseBodyString($body, $this); - $this->_insertInlineScriptsHtml($content); - $body = $this->_parser->getContent(); + $this->getParser()->processResponseBodyString($body); + $this->addInlineScript(); + $body = $this->getParser()->getContent(); } + + $this->getParser()->setIsJson(false); + return $this; } @@ -167,41 +186,63 @@ public function getAdditionalHtmlAttribute($tagName = null) } /** - * Create block to render script and html with added inline translation content specific for vde. + * Add inline script code + * + * Insert script and html with + * added inline translation content specific for vde. * - * @param string $content * @return void */ - private function _insertInlineScriptsHtml($content) + protected function addInlineScript() { - if ($this->_isScriptInserted || stripos($content, '') === false) { + $content = $this->getParser()->getContent(); + if (stripos($content, '') === false) { return; } + if (!$this->_isScriptInserted) { + $this->getParser()->setContent(str_ireplace('', $this->getInlineScript() . '', $content)); + $this->_isScriptInserted = true; + } + } - $scope = $this->_scopeResolver->getScope(); - $ajaxUrl = $this->_url->getUrl( - 'core/ajax/translate', - array( - '_secure' => $scope->isCurrentlySecure(), - \Magento\DesignEditor\Helper\Data::TRANSLATION_MODE => $this->_helper->getTranslationMode() - ) - ); - + /** + * Retrieve inline script code + * + * Create block to render script and html with + * added inline translation content specific for vde. + * + * @return string + */ + protected function getInlineScript() + { /** @var $block \Magento\View\Element\Template */ $block = $this->_objectManager->create('Magento\View\Element\Template'); $block->setArea($this->_design->getArea()); - $block->setAjaxUrl($ajaxUrl); - + $block->setAjaxUrl($this->_getAjaxUrl()); $block->setFrameUrl($this->_getFrameUrl()); $block->setRefreshCanvas($this->isAllowed()); $block->setTemplate('Magento_DesignEditor::translate_inline.phtml'); $block->setTranslateMode($this->_helper->getTranslationMode()); - $this->_parser->setContent(str_ireplace('', $block->toHtml() . '', $content)); + return $block->toHtml(); + } - $this->_isScriptInserted = true; + /** + * Return URL for ajax requests + * + * @return string + */ + protected function _getAjaxUrl() + { + return $this->_url->getUrl( + 'translation/ajax/index', + [ + '_secure' => $this->_scopeResolver->getScope()->isCurrentlySecure(), + \Magento\DesignEditor\Helper\Data::TRANSLATION_MODE => $this->_helper->getTranslationMode() + ] + ); } /** @@ -224,17 +265,21 @@ protected function _getFrameUrl() /** * Get inline vde translate mode * - * @param string $tagName + * @param string $tagName * @return string */ private function _getTranslateMode($tagName) { - $mode = self::MODE_TEXT; - if (self::ELEMENT_SCRIPT == $tagName) { - $mode = self::MODE_SCRIPT; - } elseif (self::ELEMENT_IMG == $tagName) { - $mode = self::MODE_ALT; + switch ($tagName) { + case self::TAG_SCRIPT: + $result = self::MODE_SCRIPT; + break; + case self::TAG_IMG: + $result = self::MODE_ALT; + break; + default: + $result = self::MODE_TEXT; } - return $mode; + return $result; } } diff --git a/app/code/Magento/DesignEditor/Model/Translate/Inline/Provider.php b/app/code/Magento/DesignEditor/Model/Translate/Inline/Provider.php new file mode 100644 index 0000000000000..c1f91d58c96bd --- /dev/null +++ b/app/code/Magento/DesignEditor/Model/Translate/Inline/Provider.php @@ -0,0 +1,78 @@ +vdeInlineTranslate = $vdeInlineTranslate; + $this->inlineTranslate = $inlineTranslate; + $this->request = $request; + $this->helper = $helper; + } + + /** + * Return instance of inline translate class + * + * @return \Magento\Translate\InlineInterface + */ + public function get() + { + return $this->helper->isVdeRequest($this->request) + ? $this->vdeInlineTranslate + : $this->inlineTranslate; + } +} diff --git a/app/code/Magento/DesignEditor/etc/di.xml b/app/code/Magento/DesignEditor/etc/di.xml index a236388a02952..5814b1421a914 100644 --- a/app/code/Magento/DesignEditor/etc/di.xml +++ b/app/code/Magento/DesignEditor/etc/di.xml @@ -41,4 +41,15 @@ + + + Magento\DesignEditor\Model\Translate\Inline\Proxy + \Magento\Translate\Inline\Proxy + + + + + Magento\DesignEditor\Model\Translate\Inline\Provider + + diff --git a/app/code/Magento/DesignEditor/etc/vde/events.xml b/app/code/Magento/DesignEditor/etc/vde/events.xml index 66e41c5a70306..b047255c2cedd 100644 --- a/app/code/Magento/DesignEditor/etc/vde/events.xml +++ b/app/code/Magento/DesignEditor/etc/vde/events.xml @@ -27,7 +27,4 @@ - - - diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 1e9246217d9c8..24643cd1709e7 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -515,7 +515,7 @@ public function setRequest(\Magento\Object $request) * Get allowed shipping methods * * @return string[] - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getAllowedMethods() { @@ -535,7 +535,7 @@ public function getAllowedMethods() $allowedMethods = explode(',', $this->getConfigData('nondoc_methods')); break; default: - throw new \Magento\Core\Exception(__('Wrong Content Type')); + throw new \Magento\Model\Exception(__('Wrong Content Type')); } } $methods = array(); @@ -913,7 +913,7 @@ protected function _addDimension($nodePiece) /** * Get shipping quotes * - * @return \Magento\Core\Model\AbstractModel|Result + * @return \Magento\Model\AbstractModel|Result */ protected function _getQuotes() { @@ -1047,7 +1047,7 @@ protected function _setQuotesRequestXmlDate(\SimpleXMLElement $requestXml, $date * * @param string $response * @return bool|\Magento\Object|Result|Error - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _parseResponse($response) { @@ -1080,7 +1080,7 @@ protected function _parseResponse($response) break; } } - throw new \Magento\Core\Exception(__('Error #%1 : %2', trim($code), trim($data))); + throw new \Magento\Model\Exception(__('Error #%1 : %2', trim($code), trim($data))); } $code = isset($nodeCondition->ConditionCode) ? (string)$nodeCondition->ConditionCode : 0; @@ -1123,7 +1123,7 @@ protected function _parseResponse($response) } } else if (!empty($this->_errors)) { if ($this->_isShippingLabelFlag) { - throw new \Magento\Core\Exception($responseError); + throw new \Magento\Model\Exception($responseError); } return $this->_showError(); } @@ -1215,14 +1215,14 @@ protected function _addRate(\SimpleXMLElement $shipmentDetails) * Returns dimension unit (cm or inch) * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getDimensionUnit() { $countryId = $this->_rawRequest->getOrigCountryId(); $measureUnit = $this->getCountryParams($countryId)->getMeasureUnit(); if (empty($measureUnit)) { - throw new \Magento\Core\Exception(__("Cannot identify measure unit for %1", $countryId)); + throw new \Magento\Model\Exception(__("Cannot identify measure unit for %1", $countryId)); } return $measureUnit; } @@ -1231,14 +1231,14 @@ protected function _getDimensionUnit() * Returns weight unit (kg or pound) * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getWeightUnit() { $countryId = $this->_rawRequest->getOrigCountryId(); $weightUnit = $this->getCountryParams($countryId)->getWeightUnit(); if (empty($weightUnit)) { - throw new \Magento\Core\Exception(__("Cannot identify weight unit for %1", $countryId)); + throw new \Magento\Model\Exception(__("Cannot identify weight unit for %1", $countryId)); } return $weightUnit; } @@ -1348,7 +1348,7 @@ public function getContainerTypes(\Magento\Object $params = null) * * @param \Magento\Object $request * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _mapRequestToShipment(\Magento\Object $request) { @@ -1363,7 +1363,7 @@ protected function _mapRequestToShipment(\Magento\Object $request) $minValue = $this->_getMinDimension($params['dimension_units']); if ($params['width'] < $minValue || $params['length'] < $minValue || $params['height'] < $minValue) { $message = __('Height, width and length should be equal or greater than %1', $minValue); - throw new \Magento\Core\Exception($message); + throw new \Magento\Model\Exception($message); } } @@ -1409,7 +1409,7 @@ protected function _getMinDimension($dimensionUnit) * Do rate request and handle errors * * @return Result|\Magento\Object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _doRequest() { @@ -1420,7 +1420,7 @@ protected function _doRequest() )->getRegion(); if (!$originRegion) { - throw new \Magento\Core\Exception(__('Wrong Region')); + throw new \Magento\Model\Exception(__('Wrong Region')); } if ($originRegion == 'AM') { @@ -1902,13 +1902,13 @@ protected function _getPerpackagePrice($cost, $handlingType, $handlingFee) * * @param \Magento\Shipping\Model\Shipment\Request $request * @return array|\Magento\Object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function requestToShipment($request) { $packages = $request->getPackages(); if (!is_array($packages) || !$packages) { - throw new \Magento\Core\Exception(__('No packages for request')); + throw new \Magento\Model\Exception(__('No packages for request')); } $result = $this->_doShipmentRequest($request); @@ -1955,20 +1955,20 @@ protected function _checkDomesticStatus($origCountryCode, $destCountryCode) * * @param \SimpleXMLElement $xml * @return \Magento\Object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _prepareShippingLabelContent(\SimpleXMLElement $xml) { $result = new \Magento\Object(); try { if (!isset($xml->AirwayBillNumber) || !isset($xml->LabelImage->OutputImage)) { - throw new \Magento\Core\Exception('Unable to retrieve shipping label'); + throw new \Magento\Model\Exception('Unable to retrieve shipping label'); } $result->setTrackingNumber((string)$xml->AirwayBillNumber); $labelContent = (string)$xml->LabelImage->OutputImage; $result->setShippingLabelContent(base64_decode($labelContent)); } catch (\Exception $e) { - throw new \Magento\Core\Exception(__($e->getMessage())); + throw new \Magento\Model\Exception(__($e->getMessage())); } return $result; } diff --git a/app/code/Magento/Directory/Exception.php b/app/code/Magento/Directory/Exception.php index 3e2e94309bace..8bb1b304b1e3a 100644 --- a/app/code/Magento/Directory/Exception.php +++ b/app/code/Magento/Directory/Exception.php @@ -25,6 +25,6 @@ */ namespace Magento\Directory; -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { } diff --git a/app/code/Magento/Directory/Model/Country.php b/app/code/Magento/Directory/Model/Country.php index dde57c633c3f1..0f1f6fbaa7124 100644 --- a/app/code/Magento/Directory/Model/Country.php +++ b/app/code/Magento/Directory/Model/Country.php @@ -38,7 +38,7 @@ */ namespace Magento\Directory\Model; -class Country extends \Magento\Core\Model\AbstractModel +class Country extends \Magento\Model\AbstractModel { /** * @var array @@ -66,7 +66,7 @@ class Country extends \Magento\Core\Model\AbstractModel * @param \Magento\Locale\ListsInterface $localeLists * @param Country\FormatFactory $formatFactory * @param Resource\Region\CollectionFactory $regionCollectionFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -76,7 +76,7 @@ public function __construct( \Magento\Locale\ListsInterface $localeLists, \Magento\Directory\Model\Country\FormatFactory $formatFactory, \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Directory/Model/Country/Format.php b/app/code/Magento/Directory/Model/Country/Format.php index a9568368e26d8..6fe18d3d7efec 100644 --- a/app/code/Magento/Directory/Model/Country/Format.php +++ b/app/code/Magento/Directory/Model/Country/Format.php @@ -41,7 +41,7 @@ * @package Magento_Directory * @author Magento Core Team */ -class Format extends \Magento\Core\Model\AbstractModel +class Format extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Directory/Model/Currency.php b/app/code/Magento/Directory/Model/Currency.php index ab7a40dbf707c..11ef48b227bc2 100644 --- a/app/code/Magento/Directory/Model/Currency.php +++ b/app/code/Magento/Directory/Model/Currency.php @@ -36,7 +36,7 @@ use Magento\Directory\Exception; use Magento\Directory\Model\Currency\Filter; -class Currency extends \Magento\Core\Model\AbstractModel +class Currency extends \Magento\Model\AbstractModel { /** * CONFIG path constants @@ -92,7 +92,7 @@ class Currency extends \Magento\Core\Model\AbstractModel * @param \Magento\Directory\Helper\Data $directoryHelper * @param Currency\FilterFactory $currencyFilterFactory * @param \Magento\Locale\CurrencyInterface $localeCurrency - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -104,7 +104,7 @@ public function __construct( \Magento\Directory\Helper\Data $directoryHelper, \Magento\Directory\Model\Currency\FilterFactory $currencyFilterFactory, \Magento\Locale\CurrencyInterface $localeCurrency, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Directory/Model/Currency/DefaultLocator.php b/app/code/Magento/Directory/Model/Currency/DefaultLocator.php index 56c770f1e281f..2bdb02440fb11 100644 --- a/app/code/Magento/Directory/Model/Currency/DefaultLocator.php +++ b/app/code/Magento/Directory/Model/Currency/DefaultLocator.php @@ -28,11 +28,11 @@ class DefaultLocator { /** - * Application object + * Config object * - * @var \Magento\Core\Model\App + * @var \Magento\App\ConfigInterface */ - protected $_app; + protected $_configuration; /** * Store manager @@ -42,14 +42,14 @@ class DefaultLocator protected $_storeManager; /** - * Constructor - * - * @param \Magento\Core\Model\App $app + * @param \Magento\App\ConfigInterface $configuration * @param \Magento\Core\Model\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Core\Model\App $app, \Magento\Core\Model\StoreManagerInterface $storeManager) - { - $this->_app = $app; + public function __construct( + \Magento\App\ConfigInterface $configuration, + \Magento\Core\Model\StoreManagerInterface $storeManager + ) { + $this->_configuration = $configuration; $this->_storeManager = $storeManager; } @@ -71,7 +71,10 @@ public function getDefaultCurrency(\Magento\App\RequestInterface $request) $group = $request->getParam('group'); $currencyCode = $this->_storeManager->getGroup($group)->getWebsite()->getBaseCurrencyCode(); } else { - $currencyCode = $this->_app->getBaseCurrencyCode(); + $currencyCode = $this->_configuration->getValue( + \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, + 'default' + ); } return $currencyCode; diff --git a/app/code/Magento/Directory/Model/Observer.php b/app/code/Magento/Directory/Model/Observer.php index a98f388014fb0..2218d73c62302 100644 --- a/app/code/Magento/Directory/Model/Observer.php +++ b/app/code/Magento/Directory/Model/Observer.php @@ -57,11 +57,6 @@ class Observer */ protected $_coreStoreConfig; - /** - * @var \Magento\TranslateInterface - */ - protected $_translate; - /** * @var \Magento\Mail\Template\TransportBuilder */ @@ -77,28 +72,33 @@ class Observer */ protected $_currencyFactory; + /** + * @var \Magento\Translate\Inline\StateInterface + */ + protected $inlineTranslation; + /** * @param \Magento\Directory\Model\Currency\Import\Factory $importFactory * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\TranslateInterface $translate * @param \Magento\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation */ public function __construct( \Magento\Directory\Model\Currency\Import\Factory $importFactory, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\TranslateInterface $translate, \Magento\Mail\Template\TransportBuilder $transportBuilder, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Directory\Model\CurrencyFactory $currencyFactory + \Magento\Directory\Model\CurrencyFactory $currencyFactory, + \Magento\Translate\Inline\StateInterface $inlineTranslation ) { $this->_importFactory = $importFactory; $this->_coreStoreConfig = $coreStoreConfig; - $this->_translate = $translate; $this->_transportBuilder = $transportBuilder; $this->_storeManager = $storeManager; $this->_currencyFactory = $currencyFactory; + $this->inlineTranslation = $inlineTranslation; } /** @@ -141,8 +141,7 @@ public function scheduledUpdateCurrencyRates($schedule) if (sizeof($importWarnings) == 0) { $this->_currencyFactory->create()->saveRates($rates); } else { - $translate = $this->_translate->getTranslateInline(); - $this->_translate->setTranslateInline(false); + $this->inlineTranslation->suspend(); $this->_transportBuilder->setTemplateIdentifier( $this->_coreStoreConfig->getConfig(self::XML_PATH_ERROR_TEMPLATE) @@ -161,7 +160,7 @@ public function scheduledUpdateCurrencyRates($schedule) $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); - $this->_translate->setTranslateInline($translate); + $this->inlineTranslation->resume(); } } } diff --git a/app/code/Magento/Directory/Model/Region.php b/app/code/Magento/Directory/Model/Region.php index e02e1b0ea0cb6..ecd63e3090b7c 100644 --- a/app/code/Magento/Directory/Model/Region.php +++ b/app/code/Magento/Directory/Model/Region.php @@ -43,7 +43,7 @@ */ namespace Magento\Directory\Model; -class Region extends \Magento\Core\Model\AbstractModel +class Region extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Directory/Model/Resource/Country.php b/app/code/Magento/Directory/Model/Resource/Country.php index a7a1d94c49b56..4f41606069df6 100644 --- a/app/code/Magento/Directory/Model/Resource/Country.php +++ b/app/code/Magento/Directory/Model/Resource/Country.php @@ -28,7 +28,7 @@ /** * Directory Country Resource Model */ -class Country extends \Magento\Core\Model\Resource\Db\AbstractDb +class Country extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization @@ -46,7 +46,7 @@ protected function _construct() * @param \Magento\Directory\Model\Country $country * @param string $code * @return \Magento\Directory\Model\Resource\Country - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function loadByCode(\Magento\Directory\Model\Country $country, $code) { @@ -60,7 +60,7 @@ public function loadByCode(\Magento\Directory\Model\Country $country, $code) break; default: - throw new \Magento\Core\Exception(__('Please correct the country code: %1.', $code)); + throw new \Magento\Model\Exception(__('Please correct the country code: %1.', $code)); } return $this->load($country, $code, $field); diff --git a/app/code/Magento/Directory/Model/Resource/Country/Collection.php b/app/code/Magento/Directory/Model/Resource/Country/Collection.php index cb0f3cca3c8b2..f096afc3f55c5 100644 --- a/app/code/Magento/Directory/Model/Resource/Country/Collection.php +++ b/app/code/Magento/Directory/Model/Resource/Country/Collection.php @@ -29,7 +29,7 @@ */ namespace Magento\Directory\Model\Resource\Country; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Locale model @@ -73,7 +73,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Stdlib\ArrayUtils $arrayUtils * @param \Magento\Locale\ResolverInterface $localeResolver * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -86,7 +86,7 @@ public function __construct( \Magento\Stdlib\ArrayUtils $arrayUtils, \Magento\Locale\ResolverInterface $localeResolver, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_coreStoreConfig = $coreStoreConfig; diff --git a/app/code/Magento/Directory/Model/Resource/Country/Format.php b/app/code/Magento/Directory/Model/Resource/Country/Format.php index d093b93042e49..4e07fadbe3ffd 100644 --- a/app/code/Magento/Directory/Model/Resource/Country/Format.php +++ b/app/code/Magento/Directory/Model/Resource/Country/Format.php @@ -32,7 +32,7 @@ * @package Magento_Directory * @author Magento Core Team */ -class Format extends \Magento\Core\Model\Resource\Db\AbstractDb +class Format extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Directory/Model/Resource/Country/Format/Collection.php b/app/code/Magento/Directory/Model/Resource/Country/Format/Collection.php index d7a5d88b98c74..cd466f263eba2 100644 --- a/app/code/Magento/Directory/Model/Resource/Country/Format/Collection.php +++ b/app/code/Magento/Directory/Model/Resource/Country/Format/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Directory * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Define main table diff --git a/app/code/Magento/Directory/Model/Resource/Currency.php b/app/code/Magento/Directory/Model/Resource/Currency.php index 098ef5fd3dc8c..4c8eb49d6b3d4 100644 --- a/app/code/Magento/Directory/Model/Resource/Currency.php +++ b/app/code/Magento/Directory/Model/Resource/Currency.php @@ -29,7 +29,7 @@ */ namespace Magento\Directory\Model\Resource; -class Currency extends \Magento\Core\Model\Resource\Db\AbstractDb +class Currency extends \Magento\Model\Resource\Db\AbstractDb { /** * Currency rate table @@ -151,7 +151,7 @@ public function getAnyRate($currencyFrom, $currencyTo) * * @param array $rates * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function saveRates($rates) { @@ -171,7 +171,7 @@ public function saveRates($rates) $adapter->insertOnDuplicate($this->_currencyRateTable, $data, array('rate')); } } else { - throw new \Magento\Core\Exception(__('Please correct the rates received')); + throw new \Magento\Model\Exception(__('Please correct the rates received')); } } diff --git a/app/code/Magento/Directory/Model/Resource/Region.php b/app/code/Magento/Directory/Model/Resource/Region.php index d8a6ffb53a846..22c131b6df08b 100644 --- a/app/code/Magento/Directory/Model/Resource/Region.php +++ b/app/code/Magento/Directory/Model/Resource/Region.php @@ -29,7 +29,7 @@ */ namespace Magento\Directory\Model\Resource; -class Region extends \Magento\Core\Model\Resource\Db\AbstractDb +class Region extends \Magento\Model\Resource\Db\AbstractDb { /** * Table with localized region names @@ -69,7 +69,7 @@ protected function _construct() * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return \Magento\DB\Select */ protected function _getLoadSelect($field, $value, $object) @@ -78,7 +78,7 @@ protected function _getLoadSelect($field, $value, $object) $adapter = $this->_getReadAdapter(); $locale = $this->_localeResolver->getLocaleCode(); - $systemLocale = \Magento\Core\Model\App::DISTRO_LOCALE_CODE; + $systemLocale = \Magento\AppInterface::DISTRO_LOCALE_CODE; $regionField = $adapter->quoteIdentifier($this->getMainTable() . '.' . $this->getIdFieldName()); @@ -107,7 +107,7 @@ protected function _getLoadSelect($field, $value, $object) /** * Load object by country id and code or default name * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param int $countryId * @param string $value * @param string $field diff --git a/app/code/Magento/Directory/Model/Resource/Region/Collection.php b/app/code/Magento/Directory/Model/Resource/Region/Collection.php index 34f0e55a8a9ed..4177bc8b0855a 100644 --- a/app/code/Magento/Directory/Model/Resource/Region/Collection.php +++ b/app/code/Magento/Directory/Model/Resource/Region/Collection.php @@ -29,7 +29,7 @@ */ namespace Magento\Directory\Model\Resource\Region; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Locale region name table name @@ -57,7 +57,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Locale\ResolverInterface $localeResolver * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -66,7 +66,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Locale\ResolverInterface $localeResolver, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_localeResolver = $localeResolver; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Downloadable/Block/Catalog/Product/Links.php b/app/code/Magento/Downloadable/Block/Catalog/Product/Links.php index 2687716f6cc7f..704c036245db5 100644 --- a/app/code/Magento/Downloadable/Block/Catalog/Product/Links.php +++ b/app/code/Magento/Downloadable/Block/Catalog/Product/Links.php @@ -26,20 +26,18 @@ namespace Magento\Downloadable\Block\Catalog\Product; use Magento\Downloadable\Model\Link; +use Magento\Customer\Controller\RegistryConstants; /** * Downloadable Product Links part block * - * @category Magento - * @package Magento_Downloadable - * @author Magento Core Team */ class Links extends \Magento\Catalog\Block\Product\AbstractProduct { /** * @var \Magento\Tax\Model\Calculation */ - protected $_calculationModel; + protected $calculationModel; /** * @var \Magento\Json\EncoderInterface @@ -52,58 +50,34 @@ class Links extends \Magento\Catalog\Block\Product\AbstractProduct protected $coreData; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $accountService; + + /** + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Tax\Model\Calculation $calculationModel * @param \Magento\Json\EncoderInterface $jsonEncoder * @param \Magento\Core\Helper\Data $coreData + * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $accountService * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Tax\Model\Calculation $calculationModel, \Magento\Json\EncoderInterface $jsonEncoder, \Magento\Core\Helper\Data $coreData, + \Magento\Customer\Service\V1\CustomerAccountServiceInterface $accountService, array $data = array(), array $priceBlockTypes = array() ) { - $this->_calculationModel = $calculationModel; + $this->calculationModel = $calculationModel; $this->jsonEncoder = $jsonEncoder; $this->coreData = $coreData; + $this->accountService = $accountService; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); @@ -157,9 +131,11 @@ public function getFormattedLinkPrice($link) return ''; } - $taxCalculation = $this->_calculationModel; - if (!$taxCalculation->getCustomer() && $this->_coreRegistry->registry('current_customer')) { - $taxCalculation->setCustomer($this->_coreRegistry->registry('current_customer')); + if (!$this->calculationModel->getCustomerData()->getId() + && $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)) { + $customer = $this->accountService + ->getCustomer($this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)); + $this->calculationModel->setCustomerData($customer); } $taxHelper = $this->_taxData; diff --git a/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit.php b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit.php index 500a46fb0cb33..1aac56c5aa6e3 100644 --- a/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit.php +++ b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit.php @@ -122,7 +122,7 @@ public function linkAction() } try { $this->_processDownload($resource, $resourceType); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError(__('Something went wrong while getting the requested content.')); } } diff --git a/app/code/Magento/Downloadable/Controller/Download.php b/app/code/Magento/Downloadable/Controller/Download.php index 816415cb07139..2cf998fe9fd1a 100644 --- a/app/code/Magento/Downloadable/Controller/Download.php +++ b/app/code/Magento/Downloadable/Controller/Download.php @@ -25,7 +25,7 @@ use Magento\App\ResponseInterface; use Magento\Downloadable\Helper\Download as DownloadHelper; -use Magento\Core\Exception as CoreException; +use Magento\Model\Exception as CoreException; use Magento\Downloadable\Model\Link\Purchased\Item as PurchasedLink; /** diff --git a/app/code/Magento/Downloadable/Helper/Download.php b/app/code/Magento/Downloadable/Helper/Download.php index 95860aa67ff86..aef39f99912dc 100644 --- a/app/code/Magento/Downloadable/Helper/Download.php +++ b/app/code/Magento/Downloadable/Helper/Download.php @@ -24,7 +24,7 @@ namespace Magento\Downloadable\Helper; use Magento\App\Filesystem; -use Magento\Core\Exception as CoreException; +use Magento\Model\Exception as CoreException; /** * Downloadable Products Download Helper diff --git a/app/code/Magento/Downloadable/Helper/File.php b/app/code/Magento/Downloadable/Helper/File.php index f032af149330c..b1f1a6cdc96a0 100644 --- a/app/code/Magento/Downloadable/Helper/File.php +++ b/app/code/Magento/Downloadable/Helper/File.php @@ -100,7 +100,7 @@ public function uploadFromTmp($tmpPath, \Magento\Core\Model\File\Uploader $uploa * @param string $basePath * @param string $file * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function moveFileFromTmp($baseTmpPath, $basePath, $file) { @@ -110,7 +110,7 @@ public function moveFileFromTmp($baseTmpPath, $basePath, $file) try { $fileName = $this->_moveFileFromTmp($baseTmpPath, $basePath, $file[0]['file']); } catch (\Exception $e) { - throw new \Magento\Core\Exception(__('Something went wrong while saving the file(s).')); + throw new \Magento\Model\Exception(__('Something went wrong while saving the file(s).')); } } return $fileName; diff --git a/app/code/Magento/Downloadable/Model/Link.php b/app/code/Magento/Downloadable/Model/Link.php index 6028733757310..1c7b27236b155 100644 --- a/app/code/Magento/Downloadable/Model/Link.php +++ b/app/code/Magento/Downloadable/Model/Link.php @@ -55,7 +55,7 @@ * * @author Magento Core Team */ -class Link extends \Magento\Core\Model\AbstractModel +class Link extends \Magento\Model\AbstractModel { const XML_PATH_LINKS_TITLE = 'catalog/downloadable/links_title'; @@ -74,14 +74,14 @@ class Link extends \Magento\Core\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Downloadable/Model/Link/Purchased.php b/app/code/Magento/Downloadable/Model/Link/Purchased.php index 45e981f4e8b70..09fb4f69e1ad8 100644 --- a/app/code/Magento/Downloadable/Model/Link/Purchased.php +++ b/app/code/Magento/Downloadable/Model/Link/Purchased.php @@ -53,7 +53,7 @@ * @package Magento_Downloadable * @author Magento Core Team */ -class Purchased extends \Magento\Core\Model\AbstractModel +class Purchased extends \Magento\Model\AbstractModel { /** * Enter description here... diff --git a/app/code/Magento/Downloadable/Model/Link/Purchased/Item.php b/app/code/Magento/Downloadable/Model/Link/Purchased/Item.php index e1a989bd50503..ca4d40f9ebd5a 100644 --- a/app/code/Magento/Downloadable/Model/Link/Purchased/Item.php +++ b/app/code/Magento/Downloadable/Model/Link/Purchased/Item.php @@ -65,7 +65,7 @@ * * @author Magento Core Team */ -class Item extends \Magento\Core\Model\AbstractModel +class Item extends \Magento\Model\AbstractModel { const XML_PATH_ORDER_ITEM_STATUS = 'catalog/downloadable/order_item_status'; diff --git a/app/code/Magento/Downloadable/Model/Product/Type.php b/app/code/Magento/Downloadable/Model/Product/Type.php index 789ff373c4064..bb8e5216ed5af 100644 --- a/app/code/Magento/Downloadable/Model/Product/Type.php +++ b/app/code/Magento/Downloadable/Model/Product/Type.php @@ -389,7 +389,7 @@ public function save($product) * * @param \Magento\Catalog\Model\Product $product * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function checkProductBuyState($product) { @@ -403,7 +403,7 @@ public function checkProductBuyState($product) $buyRequest->setLinks($allLinksIds); $product->addCustomOption('info_buyRequest', serialize($buyRequest->getData())); } else { - throw new \Magento\Core\Exception(__('Please specify product link(s).')); + throw new \Magento\Model\Exception(__('Please specify product link(s).')); } } } diff --git a/app/code/Magento/Downloadable/Model/Resource/Link.php b/app/code/Magento/Downloadable/Model/Resource/Link.php index 35751abdee032..c68d1d544b797 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Link.php +++ b/app/code/Magento/Downloadable/Model/Resource/Link.php @@ -32,7 +32,7 @@ * @package Magento_Downloadable * @author Magento Core Team */ -class Link extends \Magento\Core\Model\Resource\Db\AbstractDb +class Link extends \Magento\Model\Resource\Db\AbstractDb { /** * Catalog data @@ -42,9 +42,9 @@ class Link extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_catalogData; /** - * @var \Magento\Core\Model\App + * @var \Magento\App\ConfigInterface */ - protected $_app; + protected $_configuration; /** * @var \Magento\Directory\Model\CurrencyFactory @@ -59,19 +59,19 @@ class Link extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Core\Model\App $app + * @param \Magento\App\ConfigInterface $configuration * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\App\Resource $resource, \Magento\Catalog\Helper\Data $catalogData, - \Magento\Core\Model\App $app, + \Magento\App\ConfigInterface $configuration, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Model\StoreManagerInterface $storeManager ) { $this->_catalogData = $catalogData; - $this->_app = $app; + $this->_configuration = $configuration; $this->_currencyFactory = $currencyFactory; $this->_storeManager = $storeManager; parent::__construct($resource); @@ -152,7 +152,10 @@ public function saveItemTitleAndPrice($linkObject) if ($linkObject->getWebsiteId() == 0 && $_isNew && !$this->_catalogData->isPriceGlobal()) { $websiteIds = $linkObject->getProductWebsiteIds(); foreach ($websiteIds as $websiteId) { - $baseCurrency = $this->_app->getBaseCurrencyCode(); + $baseCurrency = $this->_configuration->getValue( + \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, + 'default' + ); $websiteCurrency = $this->_storeManager->getWebsite($websiteId)->getBaseCurrencyCode(); if ($websiteCurrency == $baseCurrency) { continue; diff --git a/app/code/Magento/Downloadable/Model/Resource/Link/Collection.php b/app/code/Magento/Downloadable/Model/Resource/Link/Collection.php index 6ad42bd161a34..ff2672fd8a03d 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Link/Collection.php +++ b/app/code/Magento/Downloadable/Model/Resource/Link/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Downloadable * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Init resource model diff --git a/app/code/Magento/Downloadable/Model/Resource/Link/Purchased.php b/app/code/Magento/Downloadable/Model/Resource/Link/Purchased.php index f380e5fc0969b..6a9d20e9817b6 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Link/Purchased.php +++ b/app/code/Magento/Downloadable/Model/Resource/Link/Purchased.php @@ -32,7 +32,7 @@ * @package Magento_Downloadable * @author Magento Core Team */ -class Purchased extends \Magento\Core\Model\Resource\Db\AbstractDb +class Purchased extends \Magento\Model\Resource\Db\AbstractDb { /** * Magento class constructor diff --git a/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Collection.php b/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Collection.php index a62219e7437f4..30c91dfbd24a5 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Collection.php +++ b/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Downloadable * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Init resource model diff --git a/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Item.php b/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Item.php index a1853f60e01bd..4827cdb789d5b 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Item.php +++ b/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Item.php @@ -32,7 +32,7 @@ * @package Magento_Downloadable * @author Magento Core Team */ -class Item extends \Magento\Core\Model\Resource\Db\AbstractDb +class Item extends \Magento\Model\Resource\Db\AbstractDb { /** * Magento class constructor diff --git a/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Item/Collection.php b/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Item/Collection.php index 8ec08268fe5a0..b59ab4e70063a 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Item/Collection.php +++ b/app/code/Magento/Downloadable/Model/Resource/Link/Purchased/Item/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Downloadable * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Init resource model diff --git a/app/code/Magento/Downloadable/Model/Resource/Sample.php b/app/code/Magento/Downloadable/Model/Resource/Sample.php index 7e9812663f9db..edb3a46050694 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Sample.php +++ b/app/code/Magento/Downloadable/Model/Resource/Sample.php @@ -32,7 +32,7 @@ * @package Magento_Downloadable * @author Magento Core Team */ -class Sample extends \Magento\Core\Model\Resource\Db\AbstractDb +class Sample extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection diff --git a/app/code/Magento/Downloadable/Model/Resource/Sample/Collection.php b/app/code/Magento/Downloadable/Model/Resource/Sample/Collection.php index 1da9fee74990f..8eec8c13f6cae 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Sample/Collection.php +++ b/app/code/Magento/Downloadable/Model/Resource/Sample/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Downloadable * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Init resource model 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 c0559e7b9b5df..1f980c823f1c5 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 @@ -63,7 +63,7 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory * @param \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -76,7 +76,7 @@ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory, \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 10e2226f5f298..ac12183be2437 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 @@ -45,7 +45,7 @@ class Creditmemo extends \Magento\Downloadable\Model\Sales\Order\Pdf\Items\Abstr * @param \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory * @param \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory * @param \Magento\Stdlib\String $string - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -59,7 +59,7 @@ public function __construct( \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory, \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory, \Magento\Stdlib\String $string, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 248e29b73ff71..c8afa1865e3e1 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 @@ -45,7 +45,7 @@ class Invoice extends \Magento\Downloadable\Model\Sales\Order\Pdf\Items\Abstract * @param \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory * @param \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory * @param \Magento\Stdlib\String $string - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -59,7 +59,7 @@ public function __construct( \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory, \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory, \Magento\Stdlib\String $string, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Downloadable/Model/Sample.php b/app/code/Magento/Downloadable/Model/Sample.php index 334729ccd5d93..31227c5171742 100644 --- a/app/code/Magento/Downloadable/Model/Sample.php +++ b/app/code/Magento/Downloadable/Model/Sample.php @@ -43,21 +43,21 @@ * * @author Magento Core Team */ -class Sample extends \Magento\Core\Model\AbstractModel +class Sample extends \Magento\Model\AbstractModel { const XML_PATH_SAMPLES_TITLE = 'catalog/downloadable/samples_title'; /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Eav/Exception.php b/app/code/Magento/Eav/Exception.php index 0d5aeeac203ee..d74503dfa174b 100644 --- a/app/code/Magento/Eav/Exception.php +++ b/app/code/Magento/Eav/Exception.php @@ -25,6 +25,6 @@ */ namespace Magento\Eav; -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { } diff --git a/app/code/Magento/Eav/Helper/Data.php b/app/code/Magento/Eav/Helper/Data.php index a06ccabbf5ce5..b0ecc07fb72d6 100644 --- a/app/code/Magento/Eav/Helper/Data.php +++ b/app/code/Magento/Eav/Helper/Data.php @@ -158,6 +158,7 @@ public function getInputTypesValidatorData() * 'entity_type_id' => $entityTypeId, * 'attribute_id' => $attributeId, * 'attribute_table' => $attributeTable + * 'backend_type' => $backendType * ] */ public function getAttributeMetadata($entityTypeCode, $attributeCode) @@ -166,7 +167,8 @@ public function getAttributeMetadata($entityTypeCode, $attributeCode) return array( 'entity_type_id' => $attribute->getEntityTypeId(), 'attribute_id' => $attribute->getAttributeId(), - 'attribute_table' => $attribute->getBackend()->getTable() + 'attribute_table' => $attribute->getBackend()->getTable(), + 'backend_type' => $attribute->getBackendType() ); } } diff --git a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php index 3658d046c2870..922d02a50d290 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php @@ -26,7 +26,7 @@ namespace Magento\Eav\Model\Attribute\Data; use Magento\App\RequestInterface; -use Magento\Core\Exception as CoreException; +use Magento\Model\Exception as CoreException; /** * EAV Attribute Abstract Data Model @@ -47,7 +47,7 @@ abstract class AbstractData /** * Entity instance * - * @var \Magento\Core\Model\AbstractModel + * @var \Magento\Model\AbstractModel */ protected $_entity; @@ -171,10 +171,10 @@ public function setRequestScopeOnly($flag) /** * Set entity instance * - * @param \Magento\Core\Model\AbstractModel $entity + * @param \Magento\Model\AbstractModel $entity * @return $this */ - public function setEntity(\Magento\Core\Model\AbstractModel $entity) + public function setEntity(\Magento\Model\AbstractModel $entity) { $this->_entity = $entity; return $this; @@ -183,7 +183,7 @@ public function setEntity(\Magento\Core\Model\AbstractModel $entity) /** * Returns entity instance * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ public function getEntity() { diff --git a/app/code/Magento/Eav/Model/AttributeDataFactory.php b/app/code/Magento/Eav/Model/AttributeDataFactory.php index 8215b84734a03..c215478c18fc5 100644 --- a/app/code/Magento/Eav/Model/AttributeDataFactory.php +++ b/app/code/Magento/Eav/Model/AttributeDataFactory.php @@ -80,10 +80,10 @@ public function __construct(\Magento\ObjectManager $objectManager, \Magento\Stdl * Set entity to data model (need for work) * * @param \Magento\Eav\Model\Attribute $attribute - * @param \Magento\Core\Model\AbstractModel $entity + * @param \Magento\Model\AbstractModel $entity * @return \Magento\Eav\Model\Attribute\Data\AbstractData */ - public function create(\Magento\Eav\Model\Attribute $attribute, \Magento\Core\Model\AbstractModel $entity) + public function create(\Magento\Eav\Model\Attribute $attribute, \Magento\Model\AbstractModel $entity) { /* @var $dataModel \Magento\Eav\Model\Attribute\Data\AbstractData */ $dataModelClass = $attribute->getDataModel(); diff --git a/app/code/Magento/Eav/Model/Config.php b/app/code/Magento/Eav/Model/Config.php index 5ed2a3bde425b..03c172d0dd45b 100644 --- a/app/code/Magento/Eav/Model/Config.php +++ b/app/code/Magento/Eav/Model/Config.php @@ -104,9 +104,9 @@ class Config protected $_collectionAttributes = array(); /** - * @var \Magento\Core\Model\App + * @var \Magento\App\CacheInterface */ - protected $_app; + protected $_cache; /** * @var \Magento\Eav\Model\Entity\TypeFactory @@ -119,18 +119,18 @@ class Config protected $_universalFactory; /** - * @param \Magento\Core\Model\App $app - * @param \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory + * @param \Magento\App\CacheInterface $cache + * @param Entity\TypeFactory $entityTypeFactory * @param \Magento\App\Cache\StateInterface $cacheState * @param \Magento\Validator\UniversalFactory $universalFactory */ public function __construct( - \Magento\Core\Model\App $app, + \Magento\App\CacheInterface $cache, \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory, \Magento\App\Cache\StateInterface $cacheState, \Magento\Validator\UniversalFactory $universalFactory ) { - $this->_app = $app; + $this->_cache = $cache; $this->_entityTypeFactory = $entityTypeFactory; $this->_cacheState = $cacheState; $this->_universalFactory = $universalFactory; @@ -281,8 +281,7 @@ protected function _initEntityTypes() /** * try load information about entity types from cache */ - if ($this->_isCacheEnabled() && ($cache = $this->_app->loadCache(self::ENTITIES_CACHE_ID))) { - + if ($this->_isCacheEnabled() && ($cache = $this->_cache->load(self::ENTITIES_CACHE_ID))) { $this->_entityData = unserialize($cache); foreach ($this->_entityData as $typeCode => $data) { $typeId = $data['entity_type_id']; @@ -313,10 +312,13 @@ protected function _initEntityTypes() $this->_entityData = $types; if ($this->_isCacheEnabled()) { - $this->_app->saveCache( + $this->_cache->save( serialize($this->_entityData), self::ENTITIES_CACHE_ID, - array(\Magento\Eav\Model\Cache\Type::CACHE_TAG, \Magento\Eav\Model\Entity\Attribute::CACHE_TAG) + array( + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG + ) ); } \Magento\Profiler::stop('EAV: ' . __METHOD__); @@ -328,7 +330,7 @@ protected function _initEntityTypes() * * @param int|string $code * @return Type - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getEntityType($code) { @@ -363,7 +365,7 @@ public function getEntityType($code) } if (!$entityType->getId()) { - throw new \Magento\Core\Exception(__('Invalid entity_type specified: %1', $code)); + throw new \Magento\Model\Exception(__('Invalid entity_type specified: %1', $code)); } } $this->_addEntityTypeReference($entityType->getId(), $entityType->getEntityTypeCode()); diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php index 38d97534e5696..e4b613ece117f 100644 --- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php @@ -27,9 +27,9 @@ use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Eav\Model\Entity\Type; -use Magento\Core\Exception; +use Magento\Model\Exception; use Magento\Core\Model\Config\Element; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend; use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend; use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource; @@ -41,7 +41,7 @@ * @package Magento_Eav * @author Magento Core Team */ -abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResource implements EntityInterface +abstract class AbstractEntity extends \Magento\Model\Resource\AbstractResource implements EntityInterface { /** * Read connection diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php index 5421b2ba08c7d..0e09cdf90e385 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute.php @@ -91,7 +91,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Catalog\Model\ProductFactory $catalogProductFactory * @param \Magento\Locale\ResolverInterface $localeResolver - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -107,7 +107,7 @@ public function __construct( \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Catalog\Model\ProductFactory $catalogProductFactory, \Magento\Locale\ResolverInterface $localeResolver, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php index ae235f7071767..90f966215b61a 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php @@ -32,8 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -abstract class AbstractAttribute extends \Magento\Core\Model\AbstractModel implements - \Magento\Eav\Model\Entity\Attribute\AttributeInterface +abstract class AbstractAttribute extends \Magento\Model\AbstractModel implements AttributeInterface { const TYPE_STATIC = 'static'; @@ -127,7 +126,7 @@ abstract class AbstractAttribute extends \Magento\Core\Model\AbstractModel imple * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -140,7 +139,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -439,7 +438,7 @@ public function getEntityIdField() * Retrieve backend instance * * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getBackend() { @@ -478,7 +477,7 @@ public function getFrontend() * Retrieve source instance * * @return \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getSource() { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php index b3f4c159d507a..af9844b2ba548 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php @@ -45,7 +45,7 @@ * @method string getTabGroupCode() * @method \Magento\Eav\Model\Entity\Attribute\Group setTabGroupCode(string $value) */ -class Group extends \Magento\Core\Model\AbstractModel +class Group extends \Magento\Model\AbstractModel { /** * Resource initialization diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/Entity/Attribute/Option.php index 4c08812c31cad..5379372d8a14a 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Option.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Option.php @@ -39,7 +39,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Option extends \Magento\Core\Model\AbstractModel +class Option extends \Magento\Model\AbstractModel { /** * Resource initialization diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Entity/Attribute/Set.php index 706e123773336..d848a31aa181d 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Set.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Set.php @@ -44,7 +44,7 @@ use Magento\Eav\Model\Entity\Type; -class Set extends \Magento\Core\Model\AbstractModel +class Set extends \Magento\Model\AbstractModel { /** * Resource instance @@ -86,7 +86,7 @@ class Set extends \Magento\Core\Model\AbstractModel * @param \Magento\Eav\Model\Entity\Attribute\GroupFactory $attrGroupFactory * @param \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute $resourceAttribute - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -97,7 +97,7 @@ public function __construct( \Magento\Eav\Model\Entity\Attribute\GroupFactory $attrGroupFactory, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, \Magento\Eav\Model\Resource\Entity\Attribute $resourceAttribute, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -340,7 +340,7 @@ public function getDefaultGroupId($setId = null) /** * Get resource instance * - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @return \Magento\Model\Resource\Db\AbstractDb */ protected function _getResource() { diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index 4f641f2f8bec5..478ca1212df3f 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -270,7 +270,7 @@ public function getEntity() /** * Get resource instance * - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @return \Magento\Model\Resource\Db\AbstractDb */ public function getResource() { @@ -336,7 +336,7 @@ public function getAttribute($attributeCode) * @param null|string|array $condition * @param string $joinType * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * * @see self::_getConditionSql for $condition */ @@ -369,7 +369,7 @@ public function addAttributeToFilter($attribute, $condition = null, $joinType = if (!empty($conditionSql)) { $this->getSelect()->where($conditionSql, null, \Magento\DB\Select::TYPE_CONDITION); } else { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Invalid attribute identifier for filter (%1)', get_class($attribute)) ); } diff --git a/app/code/Magento/Eav/Model/Entity/Setup.php b/app/code/Magento/Eav/Model/Entity/Setup.php index f4f08ec51c7ac..7e9f01044561c 100644 --- a/app/code/Magento/Eav/Model/Entity/Setup.php +++ b/app/code/Magento/Eav/Model/Entity/Setup.php @@ -796,7 +796,7 @@ public function addAttribute($entityTypeId, $code, array $attr) * * @param array $option * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addAttributeOption($option) { @@ -830,7 +830,7 @@ public function addAttributeOption($option) // Default value if (!isset($values[0])) { - throw new \Magento\Core\Exception(__('Default option value is not defined')); + throw new \Magento\Model\Exception(__('Default option value is not defined')); } $condition = array('option_id =?' => $intOptionId); $this->_connection->delete($optionValueTable, $condition); diff --git a/app/code/Magento/Eav/Model/Entity/Store.php b/app/code/Magento/Eav/Model/Entity/Store.php index e45bc6b4e9828..6dd21ec323cc1 100644 --- a/app/code/Magento/Eav/Model/Entity/Store.php +++ b/app/code/Magento/Eav/Model/Entity/Store.php @@ -41,7 +41,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Store extends \Magento\Core\Model\AbstractModel +class Store extends \Magento\Model\AbstractModel { /** * Resource initialization diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php index 08e71bc4bd5ec..5551ebd7202e8 100644 --- a/app/code/Magento/Eav/Model/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Entity/Type.php @@ -58,7 +58,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Type extends \Magento\Core\Model\AbstractModel +class Type extends \Magento\Model\AbstractModel { /** * Collection of attributes @@ -108,7 +108,7 @@ class Type extends \Magento\Core\Model\AbstractModel * @param \Magento\Eav\Model\Entity\Attribute\SetFactory $attSetFactory * @param \Magento\Eav\Model\Entity\StoreFactory $storeFactory * @param \Magento\Validator\UniversalFactory $universalFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -119,7 +119,7 @@ public function __construct( \Magento\Eav\Model\Entity\Attribute\SetFactory $attSetFactory, \Magento\Eav\Model\Entity\StoreFactory $storeFactory, \Magento\Validator\UniversalFactory $universalFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -388,7 +388,7 @@ public function getAttributeModel() /** * Retrieve resource entity object * - * @return \Magento\Core\Model\Resource\AbstractResource + * @return \Magento\Model\Resource\AbstractResource */ public function getEntity() { diff --git a/app/code/Magento/Eav/Model/Form.php b/app/code/Magento/Eav/Model/Form.php index fb2913fdffbcd..2ca49c90555db 100644 --- a/app/code/Magento/Eav/Model/Form.php +++ b/app/code/Magento/Eav/Model/Form.php @@ -67,7 +67,7 @@ abstract class Form /** * Current entity instance * - * @var \Magento\Core\Model\AbstractModel + * @var \Magento\Model\AbstractModel */ protected $_entity; @@ -169,7 +169,7 @@ abstract class Form * @param RequestInterface $httpRequest * @param \Magento\Validator\ConfigFactory $validatorConfigFactory * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -181,10 +181,10 @@ public function __construct( \Magento\Validator\ConfigFactory $validatorConfigFactory ) { if (empty($this->_moduleName)) { - throw new \Magento\Core\Exception(__('Current module pathname is undefined')); + throw new \Magento\Model\Exception(__('Current module pathname is undefined')); } if (empty($this->_entityTypeCode)) { - throw new \Magento\Core\Exception(__('Current module EAV entity is undefined')); + throw new \Magento\Model\Exception(__('Current module EAV entity is undefined')); } $this->_storeManager = $storeManager; $this->_eavConfig = $eavConfig; @@ -238,10 +238,10 @@ public function setStore($store) /** * Set entity instance * - * @param \Magento\Core\Model\AbstractModel $entity + * @param \Magento\Model\AbstractModel $entity * @return $this */ - public function setEntity(\Magento\Core\Model\AbstractModel $entity) + public function setEntity(\Magento\Model\AbstractModel $entity) { $this->_entity = $entity; if ($entity->getEntityTypeId()) { @@ -290,13 +290,13 @@ public function getStore() /** * Return current form code * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return string */ public function getFormCode() { if (empty($this->_formCode)) { - throw new \Magento\Core\Exception(__('Form code is not defined')); + throw new \Magento\Model\Exception(__('Form code is not defined')); } return $this->_formCode; } @@ -318,13 +318,13 @@ public function getEntityType() /** * Return current entity instance * - * @throws \Magento\Core\Exception - * @return \Magento\Core\Model\AbstractModel + * @throws \Magento\Model\Exception + * @return \Magento\Model\AbstractModel */ public function getEntity() { if (is_null($this->_entity)) { - throw new \Magento\Core\Exception(__('Entity instance is not defined')); + throw new \Magento\Model\Exception(__('Entity instance is not defined')); } return $this->_entity; } diff --git a/app/code/Magento/Eav/Model/Form/Element.php b/app/code/Magento/Eav/Model/Form/Element.php index ea60b5c88d6ea..cf86631afa1c6 100644 --- a/app/code/Magento/Eav/Model/Form/Element.php +++ b/app/code/Magento/Eav/Model/Form/Element.php @@ -25,7 +25,7 @@ */ namespace Magento\Eav\Model\Form; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Eav Form Element Model @@ -44,7 +44,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Element extends \Magento\Core\Model\AbstractModel +class Element extends \Magento\Model\AbstractModel { /** * Prefix of model events names @@ -62,7 +62,7 @@ class Element extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -70,7 +70,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Eav\Model\Config $eavConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Eav/Model/Form/Fieldset.php b/app/code/Magento/Eav/Model/Form/Fieldset.php index c2577394a6dee..61175e140c31d 100644 --- a/app/code/Magento/Eav/Model/Form/Fieldset.php +++ b/app/code/Magento/Eav/Model/Form/Fieldset.php @@ -40,7 +40,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Fieldset extends \Magento\Core\Model\AbstractModel +class Fieldset extends \Magento\Model\AbstractModel { /** * Prefix of model events names @@ -58,7 +58,7 @@ class Fieldset extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -66,7 +66,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -107,13 +107,13 @@ public function getCollection() /** * Validate data before save data * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ protected function _beforeSave() { if (!$this->getTypeId()) { - throw new \Magento\Core\Exception(__('Invalid form type.')); + throw new \Magento\Model\Exception(__('Invalid form type.')); } if (!$this->getStoreId() && $this->getLabel()) { $this->setStoreLabel($this->getStoreId(), $this->getLabel()); diff --git a/app/code/Magento/Eav/Model/Form/Type.php b/app/code/Magento/Eav/Model/Form/Type.php index 17e7efd5f998f..a4837028e398a 100644 --- a/app/code/Magento/Eav/Model/Form/Type.php +++ b/app/code/Magento/Eav/Model/Form/Type.php @@ -44,7 +44,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Type extends \Magento\Core\Model\AbstractModel +class Type extends \Magento\Model\AbstractModel { /** * Prefix of model events names @@ -68,7 +68,7 @@ class Type extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Eav\Model\Form\FieldsetFactory $fieldsetFactory * @param \Magento\Eav\Model\Form\ElementFactory $elementFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -77,7 +77,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Eav\Model\Form\FieldsetFactory $fieldsetFactory, \Magento\Eav\Model\Form\ElementFactory $elementFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Eav/Model/Resource/Attribute.php b/app/code/Magento/Eav/Model/Resource/Attribute.php index 2ae9f4ce9680e..179fc3efc56bd 100644 --- a/app/code/Magento/Eav/Model/Resource/Attribute.php +++ b/app/code/Magento/Eav/Model/Resource/Attribute.php @@ -34,7 +34,7 @@ */ namespace Magento\Eav\Model\Resource; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; use Magento\DB\Select; abstract class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute diff --git a/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php index ff1b652997476..a0c60e77ab569 100644 --- a/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php @@ -73,7 +73,7 @@ abstract class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\C * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -83,7 +83,7 @@ public function __construct( \Magento\Eav\Model\Config $eavConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_storeManager = $storeManager; $this->_eavConfig = $eavConfig; diff --git a/app/code/Magento/Eav/Model/Resource/Config.php b/app/code/Magento/Eav/Model/Resource/Config.php index 28f4d09b52a01..d4b5fcb27869c 100644 --- a/app/code/Magento/Eav/Model/Resource/Config.php +++ b/app/code/Magento/Eav/Model/Resource/Config.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Config extends \Magento\Core\Model\Resource\Db\AbstractDb +class Config extends \Magento\Model\Resource\Db\AbstractDb { /** * Array of entity types diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php index 35eb396c874ec..d78e459d12df8 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php @@ -25,7 +25,7 @@ */ namespace Magento\Eav\Model\Resource\Entity; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; use Magento\Eav\Model\Entity\Attribute as EntityAttribute; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\DB\Select; @@ -37,7 +37,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb +class Attribute extends \Magento\Model\Resource\Db\AbstractDb { /** * Eav Entity attributes cache @@ -46,13 +46,6 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb */ protected static $_entityAttributes = array(); - /** - * Application instance - * - * @var \Magento\Core\Model\App - */ - protected $_application; - /** * @var \Magento\Core\Model\StoreManagerInterface */ @@ -201,14 +194,14 @@ public function deleteEntity(AbstractModel $object) * * @param EntityAttribute|AbstractModel $object * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeSave(AbstractModel $object) { $frontendLabel = $object->getFrontendLabel(); if (is_array($frontendLabel)) { if (!isset($frontendLabel[0]) || is_null($frontendLabel[0]) || $frontendLabel[0] == '') { - throw new \Magento\Core\Exception(__('Frontend label is not defined')); + throw new \Magento\Model\Exception(__('Frontend label is not defined')); } $object->setFrontendLabel($frontendLabel[0])->setStoreLabels($frontendLabel); } @@ -389,12 +382,12 @@ protected function _processAttributeOptions($object, $option) * * @param array $values * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _checkDefaultOptionValue($values) { if (!isset($values[0])) { - throw new \Magento\Core\Exception(__('Default option value is not defined')); + throw new \Magento\Model\Exception(__('Default option value is not defined')); } } diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php index 5ff036c4ae6d6..a93fc9ecad916 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php @@ -34,7 +34,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Add attribute set info flag @@ -379,7 +379,7 @@ protected function _addSetInfo() /** * Ad information about attribute sets to collection result data * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ protected function _afterLoadData() { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php index 76fd59d47a9da..5821638bcf129 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php @@ -25,7 +25,7 @@ */ namespace Magento\Eav\Model\Resource\Entity\Attribute\Grid; -use Magento\Core\Model\Resource\Db\Collection\AbstractCollection; +use Magento\Model\Resource\Db\Collection\AbstractCollection; /** * Eav Resource Attribute Set Collection @@ -48,7 +48,7 @@ class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collec * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Registry $registryManager * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -57,7 +57,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Registry $registryManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_registryManager = $registryManager; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php index 8fcdc767d8d6d..8533ed7ed95fc 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Group extends \Magento\Core\Model\Resource\Db\AbstractDb +class Group extends \Magento\Model\Resource\Db\AbstractDb { /** * Constants for attribute group codes @@ -78,10 +78,10 @@ public function itemExists($object) /** * Perform actions before object save * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @param \Magento\Model\AbstractModel $object + * @return \Magento\Model\Resource\Db\AbstractDb */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { if (!$object->getSortOrder()) { $object->setSortOrder($this->_getMaxSortOrder($object) + 1); @@ -92,10 +92,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * Perform actions after object save * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @param \Magento\Model\AbstractModel $object + * @return \Magento\Model\Resource\Db\AbstractDb */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { if ($object->getAttributes()) { foreach ($object->getAttributes() as $attribute) { @@ -110,7 +110,7 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Retrieve max sort order * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return int */ protected function _getMaxSortOrder($object) diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php index 259dcb412f4cd..1eeeb3050d41d 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Init resource model for collection diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php index d9716b5603214..22777268d1b28 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Option extends \Magento\Core\Model\Resource\Db\AbstractDb +class Option extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php index 5f1b719a75905..415d49834bf52 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Option value table @@ -59,7 +59,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\App\Resource $coreResource * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -69,7 +69,7 @@ public function __construct( \Magento\App\Resource $coreResource, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_storeManager = $storeManager; $this->_coreResource = $coreResource; diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php index f9033d9b997f4..f7c9d7608a6c7 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Set extends \Magento\Core\Model\Resource\Db\AbstractDb +class Set extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Eav\Model\Resource\Entity\Attribute\GroupFactory @@ -64,10 +64,10 @@ protected function _construct() /** * Perform actions after object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { if ($object->getGroups()) { /* @var $group \Magento\Eav\Model\Entity\Attribute\Group */ diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php index 8a47097f54aeb..28156238fb60e 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Store.php b/app/code/Magento/Eav/Model/Resource/Entity/Store.php index 614b9aff8d9de..02ed7d1ebff18 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Store.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Store.php @@ -25,7 +25,7 @@ */ namespace Magento\Eav\Model\Resource\Entity; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; use Magento\Object; /** @@ -35,7 +35,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Store extends \Magento\Core\Model\Resource\Db\AbstractDb +class Store extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Type.php b/app/code/Magento/Eav/Model/Resource/Entity/Type.php index 8c2ecec698aac..543023a4ac43d 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Type.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Type extends \Magento\Core\Model\Resource\Db\AbstractDb +class Type extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization @@ -47,7 +47,7 @@ protected function _construct() /** * Load Entity Type by Code * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $code * @return $this */ diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php index 5aa5a39dad093..90251c8172787 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Eav/Model/Resource/Form/Attribute.php b/app/code/Magento/Eav/Model/Resource/Form/Attribute.php index 86040f1807343..bef72498c9aa8 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Attribute.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Attribute.php @@ -34,7 +34,7 @@ */ namespace Magento\Eav\Model\Resource\Form; -abstract class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb +abstract class Attribute extends \Magento\Model\Resource\Db\AbstractDb { /** * Return form attribute IDs by form code diff --git a/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php index 22d4b7660df41..c877b8cdea0f2 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Current module pathname @@ -80,7 +80,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -90,7 +90,7 @@ public function __construct( \Magento\Eav\Model\Config $eavConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_storeManager = $storeManager; $this->_eavConfig = $eavConfig; @@ -101,15 +101,15 @@ public function __construct( * Resource initialization * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _construct() { if (empty($this->_moduleName)) { - throw new \Magento\Core\Exception(__('Current module pathname is undefined')); + throw new \Magento\Model\Exception(__('Current module pathname is undefined')); } if (empty($this->_entityTypeCode)) { - throw new \Magento\Core\Exception(__('Current module EAV entity is undefined')); + throw new \Magento\Model\Exception(__('Current module EAV entity is undefined')); } } diff --git a/app/code/Magento/Eav/Model/Resource/Form/Element.php b/app/code/Magento/Eav/Model/Resource/Form/Element.php index 2a60ee19e92a8..5eeac8a51a748 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Element.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Element.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Element extends \Magento\Core\Model\Resource\Db\AbstractDb +class Element extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection and define main table diff --git a/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php index 139b94794ac88..18d39e56eec2c 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize collection model diff --git a/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php b/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php index fe63e9e71d190..51b78898af2f7 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php @@ -25,7 +25,7 @@ */ namespace Magento\Eav\Model\Resource\Form; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; use Magento\Eav\Model\Form\Fieldset as FormFieldset; use Magento\DB\Select; @@ -36,7 +36,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Fieldset extends \Magento\Core\Model\Resource\Db\AbstractDb +class Fieldset extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection and define main table diff --git a/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php index a9944840ea711..192e3ebd30f89 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php @@ -36,7 +36,7 @@ use Magento\Eav\Model\Form\Type; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Store scope ID @@ -57,7 +57,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -66,7 +66,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_storeManager = $storeManager; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Eav/Model/Resource/Form/Type.php b/app/code/Magento/Eav/Model/Resource/Form/Type.php index 9bf216d771451..c7003f41c1a1b 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Type.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Type.php @@ -26,7 +26,7 @@ namespace Magento\Eav\Model\Resource\Form; use Magento\Eav\Model\Form\Type as FormType; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; /** * Eav Form Type Resource Model @@ -35,7 +35,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Type extends \Magento\Core\Model\Resource\Db\AbstractDb +class Type extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection and define main table @@ -93,7 +93,7 @@ public function getEntityTypes($object) /** * Save entity types after save form type * - * @see \Magento\Core\Model\Resource\Db\AbstractDb#_afterSave($object) + * @see \Magento\Model\Resource\Db\AbstractDb#_afterSave($object) * * @param FormType|AbstractModel $object * @return $this diff --git a/app/code/Magento/Eav/Model/Resource/Form/Type/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Type/Collection.php index 7190125885cc8..024d5c18f7c41 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Type/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Type/Collection.php @@ -36,7 +36,7 @@ use Magento\Eav\Model\Entity\Type; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize collection model diff --git a/app/code/Magento/Eav/Model/Resource/Helper.php b/app/code/Magento/Eav/Model/Resource/Helper.php index c78e87d1a962b..602fd034db695 100644 --- a/app/code/Magento/Eav/Model/Resource/Helper.php +++ b/app/code/Magento/Eav/Model/Resource/Helper.php @@ -32,7 +32,7 @@ * @package Magento_Eav * @author Magento Core Team */ -class Helper extends \Magento\Core\Model\Resource\Helper +class Helper extends \Magento\DB\Helper { /** * Construct diff --git a/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php b/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php index 6af08c2c72107..c0df967660720 100644 --- a/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php +++ b/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php @@ -37,15 +37,15 @@ class Backend extends \Magento\Validator\AbstractValidator /** * Returns true if and only if $value meets the validation requirements. * - * @param \Magento\Core\Model\AbstractModel $entity + * @param \Magento\Model\AbstractModel $entity * @return bool * @throws \InvalidArgumentException */ public function isValid($entity) { $this->_messages = array(); - if (!$entity instanceof \Magento\Core\Model\AbstractModel) { - throw new \InvalidArgumentException('Model must be extended from \Magento\Core\Model\AbstractModel'); + if (!$entity instanceof \Magento\Model\AbstractModel) { + throw new \InvalidArgumentException('Model must be extended from \Magento\Model\AbstractModel'); } /** @var \Magento\Eav\Model\Entity\AbstractEntity $resource */ $resource = $entity->getResource(); @@ -72,7 +72,7 @@ public function isValid($entity) } elseif (is_string($result)) { $this->_messages[$attribute->getAttributeCode()][] = $result; } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_messages[$attribute->getAttributeCode()][] = $e->getMessage(); } } diff --git a/app/code/Magento/Eav/Model/Validator/Attribute/Data.php b/app/code/Magento/Eav/Model/Validator/Attribute/Data.php index ab6efff5c83ed..cba4be41f43b8 100644 --- a/app/code/Magento/Eav/Model/Validator/Attribute/Data.php +++ b/app/code/Magento/Eav/Model/Validator/Attribute/Data.php @@ -125,7 +125,7 @@ public function setData(array $data) /** * Validate EAV model attributes with data models * - * @param \Magento\Core\Model\AbstractModel $entity + * @param \Magento\Model\AbstractModel $entity * @return bool */ public function isValid($entity) @@ -174,10 +174,9 @@ protected function _getAttributes($entity) if ($this->_attributes) { $attributes = $this->_attributes; - } elseif ($entity instanceof \Magento\Core\Model\AbstractModel && + } elseif ($entity instanceof \Magento\Model\AbstractModel && $entity->getResource() instanceof \Magento\Eav\Model\Entity\AbstractEntity - ) { - // $entity is EAV-model + ) { // $entity is EAV-model $attributes = $entity->getEntityType()->getAttributeCollection()->getItems(); } diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php index 0ecef8a001aae..77d4bb165cfd6 100644 --- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php +++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php @@ -198,7 +198,7 @@ public function deleteAction() // go to grid $this->_redirect('adminhtml/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError( diff --git a/app/code/Magento/Email/Model/Resource/Template.php b/app/code/Magento/Email/Model/Resource/Template.php index fc58c04f8ca00..f555bf9db92b8 100644 --- a/app/code/Magento/Email/Model/Resource/Template.php +++ b/app/code/Magento/Email/Model/Resource/Template.php @@ -25,7 +25,7 @@ */ namespace Magento\Email\Model\Resource; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; /** * Template db resource @@ -34,7 +34,7 @@ * @package Magento_Email * @author Magento Core Team */ -class Template extends \Magento\Core\Model\Resource\Db\AbstractDb +class Template extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Stdlib\DateTime diff --git a/app/code/Magento/Email/Model/Resource/Template/Collection.php b/app/code/Magento/Email/Model/Resource/Template/Collection.php index a8b5d5aad0a50..238e077f0335c 100644 --- a/app/code/Magento/Email/Model/Resource/Template/Collection.php +++ b/app/code/Magento/Email/Model/Resource/Template/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Email * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Template table name diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php index f2ed3964882e6..b5ea656352fa5 100644 --- a/app/code/Magento/Email/Model/Template.php +++ b/app/code/Magento/Email/Model/Template.php @@ -25,7 +25,7 @@ */ namespace Magento\Email\Model; -use Magento\Core\Exception; +use Magento\Model\Exception; use Magento\Email\Model\Template\Filter; use Magento\Filter\Template as FilterTemplate; diff --git a/app/code/Magento/GiftMessage/Model/Message.php b/app/code/Magento/GiftMessage/Model/Message.php index f106b8ae7e4ca..f5c3c1dd47506 100644 --- a/app/code/Magento/GiftMessage/Model/Message.php +++ b/app/code/Magento/GiftMessage/Model/Message.php @@ -43,7 +43,7 @@ * @package Magento_GiftMessage * @author Magento Core Team */ -class Message extends \Magento\Core\Model\AbstractModel +class Message extends \Magento\Model\AbstractModel { /** * @var \Magento\GiftMessage\Model\TypeFactory diff --git a/app/code/Magento/GiftMessage/Model/Resource/Message.php b/app/code/Magento/GiftMessage/Model/Resource/Message.php index dabebf2623b6b..7d792ebb4c644 100644 --- a/app/code/Magento/GiftMessage/Model/Resource/Message.php +++ b/app/code/Magento/GiftMessage/Model/Resource/Message.php @@ -32,7 +32,7 @@ * @package Magento_GiftMessage * @author Magento Core Team */ -class Message extends \Magento\Core\Model\Resource\Db\AbstractDb +class Message extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table diff --git a/app/code/Magento/GiftMessage/Model/Resource/Message/Collection.php b/app/code/Magento/GiftMessage/Model/Resource/Message/Collection.php index ae476f41227da..e92f31e304f6d 100644 --- a/app/code/Magento/GiftMessage/Model/Resource/Message/Collection.php +++ b/app/code/Magento/GiftMessage/Model/Resource/Message/Collection.php @@ -32,7 +32,7 @@ * @package Magento_GiftMessage * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize resource model diff --git a/app/code/Magento/GiftMessage/Model/TypeFactory.php b/app/code/Magento/GiftMessage/Model/TypeFactory.php index 3dd95710ca5ec..8ef8d20bf8b25 100644 --- a/app/code/Magento/GiftMessage/Model/TypeFactory.php +++ b/app/code/Magento/GiftMessage/Model/TypeFactory.php @@ -65,13 +65,13 @@ public function __construct(\Magento\ObjectManager $objectManager) * * @param string $eavType * @return mixed - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function createType($eavType) { $types = $this->_allowedEntityTypes; if (!isset($types[$eavType])) { - throw new \Magento\Core\Exception(__('Unknown entity type')); + throw new \Magento\Model\Exception(__('Unknown entity type')); } return $this->_objectManager->create($types[$eavType]); } diff --git a/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php b/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php index b49e659952780..6d4c08c95fe83 100644 --- a/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php +++ b/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php @@ -47,7 +47,7 @@ abstract class AbstractConversion extends \Magento\Core\Model\Config\Value * @param \Magento\App\ConfigInterface $config * @param \Magento\Validator\ObjectFactory $validatorCompositeFactory * @param \Magento\GoogleAdwords\Model\Validator\Factory $validatorFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -58,7 +58,7 @@ public function __construct( \Magento\App\ConfigInterface $config, \Magento\Validator\ObjectFactory $validatorCompositeFactory, \Magento\GoogleAdwords\Model\Validator\Factory $validatorFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/GoogleOptimizer/Helper/Code.php b/app/code/Magento/GoogleOptimizer/Helper/Code.php index bdc1b5e8ade78..96a311a268734 100644 --- a/app/code/Magento/GoogleOptimizer/Helper/Code.php +++ b/app/code/Magento/GoogleOptimizer/Helper/Code.php @@ -33,7 +33,7 @@ class Code protected $_codeModel; /** - * @var \Magento\Core\Model\AbstractModel + * @var \Magento\Model\AbstractModel */ protected $_entity; @@ -48,10 +48,10 @@ public function __construct(\Magento\GoogleOptimizer\Model\Code $code) /** * Get loaded Code object by Entity * - * @param \Magento\Core\Model\AbstractModel $entity + * @param \Magento\Model\AbstractModel $entity * @return \Magento\GoogleOptimizer\Model\Code */ - public function getCodeObjectByEntity(\Magento\Core\Model\AbstractModel $entity) + public function getCodeObjectByEntity(\Magento\Model\AbstractModel $entity) { $this->_entity = $entity; diff --git a/app/code/Magento/GoogleOptimizer/Model/Code.php b/app/code/Magento/GoogleOptimizer/Model/Code.php index 4ce03f74624b5..6da6a135d29b0 100644 --- a/app/code/Magento/GoogleOptimizer/Model/Code.php +++ b/app/code/Magento/GoogleOptimizer/Model/Code.php @@ -35,7 +35,7 @@ * @method \Magento\GoogleOptimizer\Model\Code setExperimentScript(int $value) * @method string getExperimentScript() */ -class Code extends \Magento\Core\Model\AbstractModel +class Code extends \Magento\Model\AbstractModel { /**#@+ * Entity types diff --git a/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php b/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php index fa49252f88dde..ccac9852e1023 100644 --- a/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php +++ b/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php @@ -25,7 +25,7 @@ */ namespace Magento\GoogleOptimizer\Model\Resource; -class Code extends \Magento\Core\Model\Resource\Db\AbstractDb +class Code extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php index 52417f9252b8d..44dd4de0209e8 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php @@ -396,7 +396,7 @@ protected function _redirectToCaptcha($e) * Get store object, basing on request * * @return \Magento\Core\Model\Store - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function _getStore() { @@ -406,7 +406,7 @@ public function _getStore() (int)$this->getRequest()->getParam('store', 0) ); if (!$store || 0 == $store->getId()) { - throw new \Magento\Core\Exception(__('Unable to select a Store View')); + throw new \Magento\Model\Exception(__('Unable to select a Store View')); } return $store; } diff --git a/app/code/Magento/GoogleShopping/Model/Attribute.php b/app/code/Magento/GoogleShopping/Model/Attribute.php index 122ffae96ddc6..4cfbf952a2623 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute.php @@ -32,7 +32,7 @@ * @package Magento_GoogleShopping * @author Magento Core Team */ -class Attribute extends \Magento\Core\Model\AbstractModel +class Attribute extends \Magento\Model\AbstractModel { /** * Default ignored attribute codes diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/DefaultAttribute.php b/app/code/Magento/GoogleShopping/Model/Attribute/DefaultAttribute.php index 7440c490440bd..1668b45c271d7 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/DefaultAttribute.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/DefaultAttribute.php @@ -131,7 +131,7 @@ public function getGcontentAttributeType($attribute) protected function _setAttribute($entry, $name, $type = self::ATTRIBUTE_TYPE_TEXT, $value = '', $unit = null) { if (is_object($value) || (string)$value != $value) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Please correct the attribute "%1" type for Google Shopping. The product with this attribute hasn\'t been updated in Google Content.', $name diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php index 1f18aefa16661..61b1657f2fb3f 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php @@ -116,7 +116,7 @@ public function convertAttribute($product, $entry) $regions = $this->_parseRegions($rate['state'], $rate['postcode']); $ratesTotal += count($regions); if ($ratesTotal > self::RATES_MAX) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __("Google shopping only supports %1 tax rates per product", self::RATES_MAX) ); } diff --git a/app/code/Magento/GoogleShopping/Model/Flag.php b/app/code/Magento/GoogleShopping/Model/Flag.php index 6fd3f467ef921..bf04d912d714a 100644 --- a/app/code/Magento/GoogleShopping/Model/Flag.php +++ b/app/code/Magento/GoogleShopping/Model/Flag.php @@ -32,7 +32,7 @@ * @package Magento_GoogleShopping * @author Magento Core Team */ -class Flag extends \Magento\Core\Model\Flag +class Flag extends \Magento\Flag { /** * Flag time to live in seconds diff --git a/app/code/Magento/GoogleShopping/Model/Item.php b/app/code/Magento/GoogleShopping/Model/Item.php index 9e84bf4fd3411..592d56705b727 100644 --- a/app/code/Magento/GoogleShopping/Model/Item.php +++ b/app/code/Magento/GoogleShopping/Model/Item.php @@ -34,7 +34,7 @@ * @package Magento_GoogleShopping * @author Magento Core Team */ -class Item extends \Magento\Core\Model\AbstractModel +class Item extends \Magento\Model\AbstractModel { /** * Registry keys for caching attributes and types @@ -213,7 +213,7 @@ public function getType() $attributeSetId = $this->getProduct()->getAttributeSetId(); $targetCountry = $this->getTargetCountry(); - $registry = $this->_coreRegistry->registry(self::TYPES_REGISTRY_KEY); + $registry = $this->_registry->registry(self::TYPES_REGISTRY_KEY); if (is_array($registry) && isset($registry[$attributeSetId][$targetCountry])) { return $registry[$attributeSetId][$targetCountry]; } @@ -221,8 +221,8 @@ public function getType() $type = $this->_typeFactory->create()->loadByAttributeSetId($attributeSetId, $targetCountry); $registry[$attributeSetId][$targetCountry] = $type; - $this->_coreRegistry->unregister(self::TYPES_REGISTRY_KEY); - $this->_coreRegistry->register(self::TYPES_REGISTRY_KEY, $registry); + $this->_registry->unregister(self::TYPES_REGISTRY_KEY); + $this->_registry->register(self::TYPES_REGISTRY_KEY, $registry); return $type; } diff --git a/app/code/Magento/GoogleShopping/Model/MassOperations.php b/app/code/Magento/GoogleShopping/Model/MassOperations.php index ba530fe736435..e51919f471b28 100644 --- a/app/code/Magento/GoogleShopping/Model/MassOperations.php +++ b/app/code/Magento/GoogleShopping/Model/MassOperations.php @@ -25,7 +25,7 @@ */ namespace Magento\GoogleShopping\Model; -use Magento\Core\Exception as CoreException; +use Magento\Model\Exception as CoreException; use Magento\GoogleShopping\Model\Resource\Item\Collection as ItemCollection; /** diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Attribute.php b/app/code/Magento/GoogleShopping/Model/Resource/Attribute.php index 777744e3f13a3..08332663a55cd 100644 --- a/app/code/Magento/GoogleShopping/Model/Resource/Attribute.php +++ b/app/code/Magento/GoogleShopping/Model/Resource/Attribute.php @@ -33,7 +33,7 @@ */ namespace Magento\GoogleShopping\Model\Resource; -class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb +class Attribute extends \Magento\Model\Resource\Db\AbstractDb { /** * @return void diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Attribute/Collection.php b/app/code/Magento/GoogleShopping/Model/Resource/Attribute/Collection.php index 3f31195f4c6a6..d1b59f391d21f 100644 --- a/app/code/Magento/GoogleShopping/Model/Resource/Attribute/Collection.php +++ b/app/code/Magento/GoogleShopping/Model/Resource/Attribute/Collection.php @@ -32,7 +32,7 @@ * @package Magento_GoogleShopping * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Whether to join attribute_set_id to attributes or not diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Item.php b/app/code/Magento/GoogleShopping/Model/Resource/Item.php index bd9dc1ec8e072..b9574ee0bdf5f 100644 --- a/app/code/Magento/GoogleShopping/Model/Resource/Item.php +++ b/app/code/Magento/GoogleShopping/Model/Resource/Item.php @@ -33,7 +33,7 @@ */ namespace Magento\GoogleShopping\Model\Resource; -class Item extends \Magento\Core\Model\Resource\Db\AbstractDb +class Item extends \Magento\Model\Resource\Db\AbstractDb { /** * @return void diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php b/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php index 2aecfe06a7c1c..3cc5fb12e2187 100644 --- a/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php +++ b/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php @@ -32,7 +32,7 @@ * @package Magento_GoogleShopping * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Config @@ -44,7 +44,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Resource helper * - * @var \Magento\Core\Model\Resource\Helper + * @var \Magento\DB\Helper */ protected $_resourceHelper; @@ -53,20 +53,20 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\Resource\Helper $resourceHelper + * @param \Magento\DB\Helper $resourceHelper * @param \Magento\Eav\Model\Config $config * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\Resource\Helper $resourceHelper, + \Magento\DB\Helper $resourceHelper, \Magento\Eav\Model\Config $config, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_resourceHelper = $resourceHelper; $this->_eavConfig = $config; diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Type.php b/app/code/Magento/GoogleShopping/Model/Resource/Type.php index 96390f919cb11..9d9c327ba8bdb 100644 --- a/app/code/Magento/GoogleShopping/Model/Resource/Type.php +++ b/app/code/Magento/GoogleShopping/Model/Resource/Type.php @@ -32,7 +32,7 @@ * @package Magento_GoogleShopping * @author Magento Core Team */ -class Type extends \Magento\Core\Model\Resource\Db\AbstractDb +class Type extends \Magento\Model\Resource\Db\AbstractDb { /** * @return void diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Type/Collection.php b/app/code/Magento/GoogleShopping/Model/Resource/Type/Collection.php index 86fb1fd529b33..16289de6bebbf 100644 --- a/app/code/Magento/GoogleShopping/Model/Resource/Type/Collection.php +++ b/app/code/Magento/GoogleShopping/Model/Resource/Type/Collection.php @@ -32,7 +32,7 @@ * @package Magento_GoogleShopping * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * @return void diff --git a/app/code/Magento/GoogleShopping/Model/Service.php b/app/code/Magento/GoogleShopping/Model/Service.php index e7aad0225a7ea..5c1c1f88c3b47 100644 --- a/app/code/Magento/GoogleShopping/Model/Service.php +++ b/app/code/Magento/GoogleShopping/Model/Service.php @@ -106,7 +106,7 @@ public function __construct( * @param int $storeId * @param string $loginToken * @param string $loginCaptcha - * @throws \Magento\Core\Exception On http connection failure + * @throws \Magento\Model\Exception On http connection failure * @return \Zend_Http_Client */ public function getClient($storeId = null, $loginToken = null, $loginCaptcha = null) @@ -139,9 +139,9 @@ public function getClient($storeId = null, $loginToken = null, $loginCaptcha = n } catch (\Zend_Gdata_App_CaptchaRequiredException $e) { throw $e; } catch (\Zend_Gdata_App_HttpException $e) { - throw new \Magento\Core\Exception($errorMsg . __('Error: %1', $e->getMessage())); + throw new \Magento\Model\Exception($errorMsg . __('Error: %1', $e->getMessage())); } catch (\Zend_Gdata_App_AuthException $e) { - throw new \Magento\Core\Exception($errorMsg . __('Error: %1', $e->getMessage())); + throw new \Magento\Model\Exception($errorMsg . __('Error: %1', $e->getMessage())); } return $this->_coreRegistry->registry($this->_clientRegistryId); diff --git a/app/code/Magento/GoogleShopping/Model/Type.php b/app/code/Magento/GoogleShopping/Model/Type.php index 5e99728b64b64..0600c79307b6b 100644 --- a/app/code/Magento/GoogleShopping/Model/Type.php +++ b/app/code/Magento/GoogleShopping/Model/Type.php @@ -35,7 +35,7 @@ * @package Magento_GoogleShopping * @author Magento Core Team */ -class Type extends \Magento\Core\Model\AbstractModel +class Type extends \Magento\Model\AbstractModel { /** * Mapping attributes collection diff --git a/app/code/Magento/GoogleShopping/etc/di.xml b/app/code/Magento/GoogleShopping/etc/di.xml index 2489566795b47..2f8482ad857c2 100644 --- a/app/code/Magento/GoogleShopping/etc/di.xml +++ b/app/code/Magento/GoogleShopping/etc/di.xml @@ -24,7 +24,7 @@ */ --> - + Core diff --git a/app/code/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/Grouped.php b/app/code/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/Grouped.php index 5ccf7b3182904..4d0a48ba49b7d 100644 --- a/app/code/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/Grouped.php @@ -29,6 +29,9 @@ */ namespace Magento\GroupedProduct\Block\Adminhtml\Product\Composite\Fieldset; +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface as CustomerAccountService; + /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ @@ -50,57 +53,33 @@ class Grouped extends \Magento\GroupedProduct\Block\Product\View\Type\Grouped protected $_coreHelper; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @var CustomerAccountService + */ + protected $_customerAccountService; + + /** + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Stdlib\ArrayUtils $arrayUtils * @param \Magento\Catalog\Helper\Product\Price $priceHelper * @param \Magento\Core\Helper\Data $coreHelper + * @param CustomerAccountService $customerAccountService * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Stdlib\ArrayUtils $arrayUtils, \Magento\Catalog\Helper\Product\Price $priceHelper, \Magento\Core\Helper\Data $coreHelper, + CustomerAccountService $customerAccountService, array $data = array(), array $priceBlockTypes = array() ) { + $this->_customerAccountService = $customerAccountService; $this->_coreHelper = $coreHelper; $this->priceHelper = $priceHelper; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $arrayUtils, $data, $priceBlockTypes @@ -120,8 +99,11 @@ protected function _construct() $this->_block = 'Magento\Catalog\Block\Adminhtml\Product\Price'; $this->_useLinkForAsLowAs = false; - if (!$this->priceHelper->getCustomer() && $this->_coreRegistry->registry('current_customer')) { - $this->priceHelper->setCustomer($this->_coreRegistry->registry('current_customer')); + if (is_null($this->priceHelper->getCustomer()->getId()) + && $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID) + ) { + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->priceHelper->setCustomer($this->_customerAccountService->getCustomer($customerId)); } } diff --git a/app/code/Magento/GroupedProduct/etc/module.xml b/app/code/Magento/GroupedProduct/etc/module.xml index bf60b8e7d9ff1..c49b99b70a445 100644 --- a/app/code/Magento/GroupedProduct/etc/module.xml +++ b/app/code/Magento/GroupedProduct/etc/module.xml @@ -37,7 +37,6 @@ - diff --git a/app/code/Magento/ImportExport/Block/Adminhtml/Form/After.php b/app/code/Magento/ImportExport/Block/Adminhtml/Form/After.php index 0913db1759bae..8242604f2473f 100644 --- a/app/code/Magento/ImportExport/Block/Adminhtml/Form/After.php +++ b/app/code/Magento/ImportExport/Block/Adminhtml/Form/After.php @@ -53,7 +53,7 @@ public function __construct( /** * Get current operation * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ public function getOperation() { diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Export.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Export.php index 8f003dac2e25b..50fab90781264 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Export.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Export.php @@ -95,7 +95,7 @@ public function exportAction() \Magento\App\Filesystem::VAR_DIR, $model->getContentType() ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); diff --git a/app/code/Magento/ImportExport/Model/Export.php b/app/code/Magento/ImportExport/Model/Export.php index 502cba40281f6..3b78be5360463 100644 --- a/app/code/Magento/ImportExport/Model/Export.php +++ b/app/code/Magento/ImportExport/Model/Export.php @@ -106,7 +106,7 @@ public function __construct( * Create instance of entity adapter and return it * * @return \Magento\ImportExport\Model\Export\Entity\AbstractEntity|\Magento\ImportExport\Model\Export\AbstractEntity - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getEntityAdapter() { @@ -118,12 +118,12 @@ protected function _getEntityAdapter() $this->_entityAdapter = $this->_entityFactory->create($entities[$this->getEntity()]['model']); } catch (\Exception $e) { $this->_logger->logException($e); - throw new \Magento\Core\Exception(__('Please enter a correct entity model')); + throw new \Magento\Model\Exception(__('Please enter a correct entity model')); } if (!$this->_entityAdapter instanceof \Magento\ImportExport\Model\Export\Entity\AbstractEntity && !$this->_entityAdapter instanceof \Magento\ImportExport\Model\Export\AbstractEntity ) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Entity adapter object must be an instance of %1 or %2', 'Magento\ImportExport\Model\Export\Entity\AbstractEntity', @@ -134,12 +134,12 @@ protected function _getEntityAdapter() // check for entity codes integrity if ($this->getEntity() != $this->_entityAdapter->getEntityTypeCode()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The input entity code is not equal to entity adapter code.') ); } } else { - throw new \Magento\Core\Exception(__('Please enter a correct entity.')); + throw new \Magento\Model\Exception(__('Please enter a correct entity.')); } $this->_entityAdapter->setParameters($this->getData()); } @@ -150,7 +150,7 @@ protected function _getEntityAdapter() * Get writer object. * * @return \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getWriter() { @@ -162,10 +162,10 @@ protected function _getWriter() $this->_writer = $this->_exportAdapterFac->create($fileFormats[$this->getFileFormat()]['model']); } catch (\Exception $e) { $this->_logger->logException($e); - throw new \Magento\Core\Exception(__('Please enter a correct entity model')); + throw new \Magento\Model\Exception(__('Please enter a correct entity model')); } if (!$this->_writer instanceof \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Adapter object must be an instance of %1', 'Magento\ImportExport\Model\Export\Adapter\AbstractAdapter' @@ -173,7 +173,7 @@ protected function _getWriter() ); } } else { - throw new \Magento\Core\Exception(__('Please correct the file format.')); + throw new \Magento\Model\Exception(__('Please correct the file format.')); } } return $this->_writer; @@ -183,7 +183,7 @@ protected function _getWriter() * Export data. * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function export() { @@ -192,14 +192,14 @@ public function export() $result = $this->_getEntityAdapter()->setWriter($this->_getWriter())->export(); $countRows = substr_count(trim($result), "\n"); if (!$countRows) { - throw new \Magento\Core\Exception(__('There is no data for export')); + throw new \Magento\Model\Exception(__('There is no data for export')); } if ($result) { $this->addLogComment(array(__('Exported %1 rows.', $countRows), __('Export has been done.'))); } return $result; } else { - throw new \Magento\Core\Exception(__('Please provide filter data.')); + throw new \Magento\Model\Exception(__('Please provide filter data.')); } } @@ -220,7 +220,7 @@ public function filterAttributeCollection(\Magento\Data\Collection $collection) * @static * @param \Magento\Eav\Model\Entity\Attribute $attribute * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public static function getAttributeFilterType(\Magento\Eav\Model\Entity\Attribute $attribute) { @@ -236,7 +236,7 @@ public static function getAttributeFilterType(\Magento\Eav\Model\Entity\Attribut ) { return self::FILTER_TYPE_INPUT; } else { - throw new \Magento\Core\Exception(__('Cannot determine attribute filter type')); + throw new \Magento\Model\Exception(__('Cannot determine attribute filter type')); } } @@ -254,12 +254,12 @@ public function getContentType() * Override standard entity getter. * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getEntity() { if (empty($this->_data['entity'])) { - throw new \Magento\Core\Exception(__('Entity is unknown')); + throw new \Magento\Model\Exception(__('Entity is unknown')); } return $this->_data['entity']; } @@ -278,12 +278,12 @@ public function getEntityAttributeCollection() * Override standard entity getter. * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getFileFormat() { if (empty($this->_data['file_format'])) { - throw new \Magento\Core\Exception(__('File format is unknown')); + throw new \Magento\Model\Exception(__('File format is unknown')); } return $this->_data['file_format']; } diff --git a/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php index a8e130a3f7aad..3acf4db71bdfb 100644 --- a/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php @@ -281,7 +281,7 @@ abstract public function export(); /** * Export one item * - * @param \Magento\Core\Model\AbstractModel $item + * @param \Magento\Model\AbstractModel $item * @return void */ abstract public function exportItem($item); @@ -415,12 +415,12 @@ public function getProcessedRowsCount() * Inner writer object getter * * @return AbstractAdapter - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getWriter() { if (!$this->_writer) { - throw new \Magento\Core\Exception(__('Please specify writer.')); + throw new \Magento\Model\Exception(__('Please specify writer.')); } return $this->_writer; diff --git a/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php b/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php index 27b06401a0021..eb636f0f1cb0e 100644 --- a/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php +++ b/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php @@ -58,7 +58,7 @@ abstract class AbstractAdapter * * @param \Magento\App\Filesystem $filesystem * @param string|null $destination - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function __construct(\Magento\App\Filesystem $filesystem, $destination = null) { @@ -68,14 +68,14 @@ public function __construct(\Magento\App\Filesystem $filesystem, $destination = $this->_directoryHandle->touch($destination); } if (!is_string($destination)) { - throw new \Magento\Core\Exception(__('Destination file path must be a string')); + throw new \Magento\Model\Exception(__('Destination file path must be a string')); } if (!$this->_directoryHandle->isWritable()) { - throw new \Magento\Core\Exception(__('Destination directory is not writable')); + throw new \Magento\Model\Exception(__('Destination directory is not writable')); } if ($this->_directoryHandle->isFile($destination) && !$this->_directoryHandle->isWritable($destination)) { - throw new \Magento\Core\Exception(__('Destination file is not writable')); + throw new \Magento\Model\Exception(__('Destination file is not writable')); } $this->_destination = $destination; diff --git a/app/code/Magento/ImportExport/Model/Export/Adapter/Csv.php b/app/code/Magento/ImportExport/Model/Export/Adapter/Csv.php index ffa460a98cc0f..3a87715065a96 100644 --- a/app/code/Magento/ImportExport/Model/Export/Adapter/Csv.php +++ b/app/code/Magento/ImportExport/Model/Export/Adapter/Csv.php @@ -106,7 +106,7 @@ public function getFileExtension() public function setHeaderCols(array $headerColumns) { if (null !== $this->_headerCols) { - throw new \Magento\Core\Exception(__('Header column names already set')); + throw new \Magento\Model\Exception(__('Header column names already set')); } if ($headerColumns) { foreach ($headerColumns as $columnName) { diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php index 154838a549f38..51ea13eb7d92c 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php @@ -299,11 +299,11 @@ public function getEntityTypeId() /** * Fill row with attributes values * - * @param \Magento\Core\Model\AbstractModel $item export entity + * @param \Magento\Model\AbstractModel $item export entity * @param array $row data row * @return array */ - protected function _addAttributeValuesToRow(\Magento\Core\Model\AbstractModel $item, array $row = array()) + protected function _addAttributeValuesToRow(\Magento\Model\AbstractModel $item, array $row = array()) { $validAttributeCodes = $this->_getExportAttributeCodes(); // go through all valid attribute codes diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php index 77040a05f760f..0f103225a7210 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php @@ -512,12 +512,12 @@ public function getProcessedRowsCount() * Inner writer object getter. * * @return AbstractAdapter - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getWriter() { if (!$this->_writer) { - throw new \Magento\Core\Exception(__('Please specify writer.')); + throw new \Magento\Model\Exception(__('Please specify writer.')); } return $this->_writer; } diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/Product.php b/app/code/Magento/ImportExport/Model/Export/Entity/Product.php index 18c83105ef635..da7d74da6467e 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/Product.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/Product.php @@ -319,7 +319,7 @@ protected function _initCategories() /** * Initialize product type models. * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ protected function _initTypeModels() @@ -327,10 +327,10 @@ protected function _initTypeModels() $productTypes = $this->_exportConfig->getProductTypes(); foreach ($productTypes as $productTypeName => $productTypeConfig) { if (!($model = $this->_typeFactory->create($productTypeConfig['model']))) { - throw new \Magento\Core\Exception("Entity type model '{$productTypeConfig['model']}' is not found"); + throw new \Magento\Model\Exception("Entity type model '{$productTypeConfig['model']}' is not found"); } if (!$model instanceof \Magento\ImportExport\Model\Export\Entity\Product\Type\AbstractType) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Entity type model must be an instance of \Magento\ImportExport\Model\Export\Entity\Product\Type\AbstractType' ) @@ -346,7 +346,7 @@ protected function _initTypeModels() } } if (!$this->_productTypeModels) { - throw new \Magento\Core\Exception(__('There are no product types available for export')); + throw new \Magento\Model\Exception(__('There are no product types available for export')); } $this->_disabledAttrs = array_unique($this->_disabledAttrs); diff --git a/app/code/Magento/ImportExport/Model/Import.php b/app/code/Magento/ImportExport/Model/Import.php index c3b00de009695..6767d3b2bf116 100644 --- a/app/code/Magento/ImportExport/Model/Import.php +++ b/app/code/Magento/ImportExport/Model/Import.php @@ -189,7 +189,7 @@ public function __construct( /** * Create instance of entity adapter and return it * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\ImportExport\Model\Import\Entity\AbstractEntity|\Magento\ImportExport\Model\Import\AbstractEntity */ protected function _getEntityAdapter() @@ -202,12 +202,12 @@ protected function _getEntityAdapter() $this->_entityAdapter = $this->_entityFactory->create($entities[$this->getEntity()]['model']); } catch (\Exception $e) { $this->_logger->logException($e); - throw new \Magento\Core\Exception(__('Please enter a correct entity model')); + throw new \Magento\Model\Exception(__('Please enter a correct entity model')); } if (!$this->_entityAdapter instanceof \Magento\ImportExport\Model\Import\Entity\AbstractEntity && !$this->_entityAdapter instanceof \Magento\ImportExport\Model\Import\AbstractEntity ) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Entity adapter object must be an instance of %1 or %2', 'Magento\ImportExport\Model\Import\Entity\AbstractEntity', @@ -218,12 +218,12 @@ protected function _getEntityAdapter() // check for entity codes integrity if ($this->getEntity() != $this->_entityAdapter->getEntityTypeCode()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The input entity code is not equal to entity adapter code.') ); } } else { - throw new \Magento\Core\Exception(__('Please enter a correct entity.')); + throw new \Magento\Model\Exception(__('Please enter a correct entity.')); } $this->_entityAdapter->setParameters($this->getData()); } @@ -339,13 +339,13 @@ public static function getDefaultBehavior() /** * Override standard entity getter. * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return string */ public function getEntity() { if (empty($this->_data['entity'])) { - throw new \Magento\Core\Exception(__('Entity is unknown')); + throw new \Magento\Model\Exception(__('Entity is unknown')); } return $this->_data['entity']; } @@ -537,7 +537,7 @@ public function expandSource() /** * Move uploaded file and create source adapter instance. * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return string Source file path */ public function uploadSource() @@ -551,7 +551,7 @@ public function uploadSource() } else { $errorMessage = __('File was not uploaded.'); } - throw new \Magento\Core\Exception($errorMessage); + throw new \Magento\Model\Exception($errorMessage); } $entity = $this->getEntity(); @@ -564,7 +564,7 @@ public function uploadSource() $uploadedFile = $result['path'] . $result['file']; if (!$extension) { $this->_varDirectory->delete($uploadedFile); - throw new \Magento\Core\Exception(__('Uploaded file has no extension')); + throw new \Magento\Model\Exception(__('Uploaded file has no extension')); } $sourceFile = $this->getWorkingDir() . $entity; @@ -582,7 +582,7 @@ public function uploadSource() $sourceFileRelative ); } catch (\Magento\Filesystem\FilesystemException $e) { - throw new \Magento\Core\Exception(__('Source file moving failed')); + throw new \Magento\Model\Exception(__('Source file moving failed')); } } $this->_removeBom($sourceFile); @@ -591,7 +591,7 @@ public function uploadSource() $this->_getSourceAdapter($sourceFile); } catch (\Exception $e) { $this->_varDirectory->delete($sourceFileRelative); - throw new \Magento\Core\Exception($e->getMessage()); + throw new \Magento\Model\Exception($e->getMessage()); } return $sourceFile; } @@ -665,7 +665,7 @@ public function invalidateIndex() * ) * * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getEntityBehaviors() { @@ -681,7 +681,7 @@ public function getEntityBehaviors() 'code' => $behavior->getCode() . '_behavior' ); } else { - throw new \Magento\Core\Exception(__('Invalid behavior token for %1', $entityCode)); + throw new \Magento\Model\Exception(__('Invalid behavior token for %1', $entityCode)); } } return $behaviourData; diff --git a/app/code/Magento/ImportExport/Model/Import/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Import/AbstractEntity.php index 3b83d05fd6363..774ec251dc3d7 100644 --- a/app/code/Magento/ImportExport/Model/Import/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Import/AbstractEntity.php @@ -546,12 +546,12 @@ public function getProcessedRowsCount() * Source object getter * * @return AbstractSource - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getSource() { if (!$this->_source) { - throw new \Magento\Core\Exception(__('Source is not set')); + throw new \Magento\Model\Exception(__('Source is not set')); } return $this->_source; } @@ -702,7 +702,7 @@ public function setSource(AbstractSource $source) * Validate data * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validateData() { @@ -710,7 +710,7 @@ public function validateData() // do all permanent columns exist? $absentColumns = array_diff($this->_permanentAttributes, $this->getSource()->getColNames()); if ($absentColumns) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Cannot find required columns: %1', implode(', ', $absentColumns)) ); } @@ -731,12 +731,12 @@ public function validateData() } if ($emptyHeaderColumns) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Columns number: "%1" have empty headers', implode('", "', $emptyHeaderColumns)) ); } if ($invalidColumns) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Column names: "%1" are invalid', implode('", "', $invalidColumns)) ); } diff --git a/app/code/Magento/ImportExport/Model/Import/Adapter.php b/app/code/Magento/ImportExport/Model/Import/Adapter.php index 03728dd63518c..13d9ed65a45e4 100644 --- a/app/code/Magento/ImportExport/Model/Import/Adapter.php +++ b/app/code/Magento/ImportExport/Model/Import/Adapter.php @@ -44,22 +44,22 @@ class Adapter * @param Write $directory * @param mixed $options OPTIONAL Adapter constructor options * @return AbstractSource - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public static function factory($type, $directory, $options = null) { if (!is_string($type) || !$type) { - throw new \Magento\Core\Exception(__('The adapter type must be a non empty string.')); + throw new \Magento\Model\Exception(__('The adapter type must be a non empty string.')); } $adapterClass = 'Magento\ImportExport\Model\Import\Source\\' . ucfirst(strtolower($type)); if (!class_exists($adapterClass)) { - throw new \Magento\Core\Exception("'{$type}' file extension is not supported"); + throw new \Magento\Model\Exception("'{$type}' file extension is not supported"); } $adapter = new $adapterClass($options, $directory); if (!$adapter instanceof AbstractSource) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Adapter must be an instance of \Magento\ImportExport\Model\Import\AbstractSource') ); } diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php index 8e5d3b7257603..fc8575ebce07a 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php @@ -254,12 +254,12 @@ public function __construct( * Inner source object getter. * * @return AbstractSource - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getSource() { if (!$this->_source) { - throw new \Magento\Core\Exception(__('Please specify a source.')); + throw new \Magento\Model\Exception(__('Please specify a source.')); } return $this->_source; } @@ -555,12 +555,12 @@ public function getProcessedRowsCount() * Source object getter. * * @return AbstractSource - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getSource() { if (!$this->_source) { - throw new \Magento\Core\Exception(__('Source is not set')); + throw new \Magento\Model\Exception(__('Source is not set')); } return $this->_source; } @@ -711,14 +711,14 @@ public function setSource(AbstractSource $source) * Validate data. * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validateData() { if (!$this->_dataValidated) { // do all permanent columns exist? if ($absentColumns = array_diff($this->_permanentAttributes, $this->getSource()->getColNames())) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Cannot find required columns: %1', implode(', ', $absentColumns)) ); } @@ -739,12 +739,12 @@ public function validateData() } if ($emptyHeaderColumns) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Columns number: "%1" have empty headers', implode('", "', $emptyHeaderColumns)) ); } if ($invalidColumns) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Column names: "%1" are invalid', implode('", "', $invalidColumns)) ); } diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/Product.php b/app/code/Magento/ImportExport/Model/Import/Entity/Product.php index d254446443aa8..d2b158a320356 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/Product.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/Product.php @@ -731,7 +731,7 @@ protected function _initStores() * Initialize product type models. * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _initTypeModels() { @@ -740,12 +740,12 @@ protected function _initTypeModels() $params = array($this, $productTypeName); if (!($model = $this->_productTypeFactory->create($productTypeConfig['model'], array('params' => $params))) ) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( sprintf("Entity type model '%s' is not found", $productTypeConfig['model']) ); } if (!$model instanceof \Magento\ImportExport\Model\Import\Entity\Product\Type\AbstractType) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Entity type model must be an instance of ' . 'Magento\ImportExport\Model\Import\Entity\Product\Type\AbstractType' @@ -1549,7 +1549,7 @@ protected function _saveProductGroupPrices(array $groupPriceData) * Returns an object for upload a media files * * @return \Magento\ImportExport\Model\Import\Uploader - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getUploader() { @@ -1560,14 +1560,14 @@ protected function _getUploader() $tmpPath = $this->_mediaDirectory->getAbsolutePath('import'); if (!$this->_fileUploader->setTmpDir($tmpPath)) { - throw new \Magento\Core\Exception(sprintf("File directory '%s' is not readable.", $tmpPath)); + throw new \Magento\Model\Exception(sprintf("File directory '%s' is not readable.", $tmpPath)); } $destinationDir = "catalog/product"; $destinationPath = $this->_mediaDirectory->getAbsolutePath($destinationDir); $this->_mediaDirectory->create($destinationDir); if (!$this->_fileUploader->setDestDir($destinationPath)) { - throw new \Magento\Core\Exception(sprintf("File directory '%s' is not writable.", $destinationPath)); + throw new \Magento\Model\Exception(sprintf("File directory '%s' is not writable.", $destinationPath)); } } return $this->_fileUploader; diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/Product/Option.php b/app/code/Magento/ImportExport/Model/Import/Entity/Product/Option.php index c07e16d10820e..a46cb75973f9c 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/Product/Option.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/Product/Option.php @@ -472,7 +472,7 @@ protected function _initStores(array $data) * * @param array $data * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _initSourceEntities(array $data) { @@ -492,7 +492,7 @@ protected function _initSourceEntities(array $data) if (isset($data['product_entity'])) { $this->_productEntity = $data['product_entity']; } else { - throw new \Magento\Core\Exception(__('Option entity must have a parent product entity.')); + throw new \Magento\Model\Exception(__('Option entity must have a parent product entity.')); } if (isset($data['collection_by_pages_iterator'])) { $this->_byPagesIterator = $data['collection_by_pages_iterator']; diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/AbstractType.php b/app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/AbstractType.php index c083d3eb83f35..b279c770afa13 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/AbstractType.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/AbstractType.php @@ -107,7 +107,7 @@ abstract class AbstractType * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $attrSetColFac * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $prodAttrColFac * @param array $params - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function __construct( \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $attrSetColFac, @@ -126,7 +126,7 @@ public function __construct( $params[0] ) || !$params[0] instanceof \Magento\ImportExport\Model\Import\Entity\Product ) { - throw new \Magento\Core\Exception(__('Please correct the parameters.')); + throw new \Magento\Model\Exception(__('Please correct the parameters.')); } $this->_entityModel = $params[0]; $this->_type = $params[1]; diff --git a/app/code/Magento/ImportExport/Model/Import/Uploader.php b/app/code/Magento/ImportExport/Model/Import/Uploader.php index 5263fd0b8cb4b..a0951fa404370 100644 --- a/app/code/Magento/ImportExport/Model/Import/Uploader.php +++ b/app/code/Magento/ImportExport/Model/Import/Uploader.php @@ -128,12 +128,12 @@ public function move($fileName) * * @param string $filePath * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _setUploadFile($filePath) { if (!$this->_directory->isReadable($filePath)) { - throw new \Magento\Core\Exception("File '{$filePath}' was not found or has read restriction."); + throw new \Magento\Model\Exception("File '{$filePath}' was not found or has read restriction."); } $this->_file = $this->_readFileInfo($filePath); diff --git a/app/code/Magento/ImportExport/Model/Resource/Helper.php b/app/code/Magento/ImportExport/Model/Resource/Helper.php index e836725cd6341..a3c804b1e68f4 100644 --- a/app/code/Magento/ImportExport/Model/Resource/Helper.php +++ b/app/code/Magento/ImportExport/Model/Resource/Helper.php @@ -34,7 +34,7 @@ */ namespace Magento\ImportExport\Model\Resource; -class Helper extends \Magento\Core\Model\Resource\Helper +class Helper extends \Magento\DB\Helper { /** * Constants to be used for DB @@ -79,7 +79,7 @@ public function getNextAutoincrement($tableName) $entityStatus = $adapter->showTableStatus($tableName); if (empty($entityStatus['Auto_increment'])) { - throw new \Magento\Core\Exception(__('Cannot get autoincrement value')); + throw new \Magento\Model\Exception(__('Cannot get autoincrement value')); } return $entityStatus['Auto_increment']; } diff --git a/app/code/Magento/ImportExport/Model/Resource/Import/Data.php b/app/code/Magento/ImportExport/Model/Resource/Import/Data.php index 2e87cbb22c8ca..0975525687090 100644 --- a/app/code/Magento/ImportExport/Model/Resource/Import/Data.php +++ b/app/code/Magento/ImportExport/Model/Resource/Import/Data.php @@ -32,7 +32,7 @@ * @package Magento_ImportExport * @author Magento Core Team */ -class Data extends \Magento\Core\Model\Resource\Db\AbstractDb implements \IteratorAggregate +class Data extends \Magento\Model\Resource\Db\AbstractDb implements \IteratorAggregate { /** * @var \Iterator @@ -130,7 +130,7 @@ public function getEntityTypeCode() * * @param string $code parameter name * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getUniqueColumnData($code) { @@ -138,7 +138,7 @@ public function getUniqueColumnData($code) $values = array_unique($adapter->fetchCol($adapter->select()->from($this->getMainTable(), array($code)))); if (count($values) != 1) { - throw new \Magento\Core\Exception(__('Error in data structure: %1 values are mixed', $code)); + throw new \Magento\Model\Exception(__('Error in data structure: %1 values are mixed', $code)); } return $values[0]; } diff --git a/app/code/Magento/Index/App/Indexer.php b/app/code/Magento/Index/App/Indexer.php index 3597eb70f77be..eba378764910d 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\LauncherInterface; +use Magento\AppInterface; -class Indexer implements LauncherInterface +class Indexer implements AppInterface { /** * Report directory diff --git a/app/code/Magento/Index/App/Shell.php b/app/code/Magento/Index/App/Shell.php index 7d0bf5960b76d..a7af2049c500e 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\LauncherInterface; +use Magento\AppInterface; -class Shell implements LauncherInterface +class Shell implements AppInterface { /** * Filename of the entry point script diff --git a/app/code/Magento/Index/Controller/Adminhtml/Process.php b/app/code/Magento/Index/Controller/Adminhtml/Process.php index 1886c02cc029b..df84c78c7c5bf 100644 --- a/app/code/Magento/Index/Controller/Adminhtml/Process.php +++ b/app/code/Magento/Index/Controller/Adminhtml/Process.php @@ -138,7 +138,7 @@ public function saveAction() try { $process->save(); $this->messageManager->addSuccess(__('The index has been saved.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('There was a problem with saving process.')); @@ -166,7 +166,7 @@ public function reindexProcessAction() $process->reindexEverything(); \Magento\Profiler::stop('__INDEX_PROCESS_REINDEX_ALL__'); $this->messageManager->addSuccess(__('%1 index was rebuilt.', $process->getIndexer()->getName())); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('There was a problem with reindexing process.')); @@ -218,7 +218,7 @@ public function massReindexAction() } } $this->messageManager->addSuccess(__('Total of %1 index(es) have reindexed data.', $counter)); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Cannot initialize the indexer process.')); @@ -251,7 +251,7 @@ public function massChangeModeAction() } } $this->messageManager->addSuccess(__('Total of %1 index(es) have changed index mode.', $counter)); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Cannot initialize the indexer process.')); diff --git a/app/code/Magento/Index/Model/Event.php b/app/code/Magento/Index/Model/Event.php index f41acf63b8b42..ca6b1f48aece1 100644 --- a/app/code/Magento/Index/Model/Event.php +++ b/app/code/Magento/Index/Model/Event.php @@ -44,7 +44,7 @@ * @package Magento_Index * @author Magento Core Team */ -class Event extends \Magento\Core\Model\AbstractModel +class Event extends \Magento\Model\AbstractModel { /** * Predefined event types @@ -92,7 +92,7 @@ class Event extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param Indexer $indexer * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -101,7 +101,7 @@ public function __construct( \Magento\Registry $registry, Indexer $indexer, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Index/Model/Indexer/AbstractIndexer.php b/app/code/Magento/Index/Model/Indexer/AbstractIndexer.php index af64bfdda5720..9f7f40c85ec21 100644 --- a/app/code/Magento/Index/Model/Indexer/AbstractIndexer.php +++ b/app/code/Magento/Index/Model/Indexer/AbstractIndexer.php @@ -33,7 +33,7 @@ use Magento\Index\Model\Event; use Magento\Index\Model\IndexerInterface; -abstract class AbstractIndexer extends \Magento\Core\Model\AbstractModel implements IndexerInterface +abstract class AbstractIndexer extends \Magento\Model\AbstractModel implements IndexerInterface { /** * @var array diff --git a/app/code/Magento/Index/Model/Process.php b/app/code/Magento/Index/Model/Process.php index e1e801538f2b8..cb3eeacc14ddc 100644 --- a/app/code/Magento/Index/Model/Process.php +++ b/app/code/Magento/Index/Model/Process.php @@ -45,7 +45,7 @@ * @package Magento_Index * @author Magento Core Team */ -class Process extends \Magento\Core\Model\AbstractModel +class Process extends \Magento\Model\AbstractModel { /** * Process statuses @@ -132,7 +132,7 @@ class Process extends \Magento\Core\Model\AbstractModel * @param \Magento\Index\Model\Indexer\ConfigInterface $indexerConfig * @param \Magento\Index\Model\Lock\Storage $lockStorage * @param \Magento\Index\Model\EventRepository $eventRepository - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -145,7 +145,7 @@ public function __construct( \Magento\Index\Model\Indexer\ConfigInterface $indexerConfig, \Magento\Index\Model\Lock\Storage $lockStorage, \Magento\Index\Model\EventRepository $eventRepository, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -245,13 +245,13 @@ public function matchEntityAndType($entity, $type) * Reindex all data what this process responsible is * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @throws \Exception */ public function reindexAll() { if ($this->isLocked()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( '%1 Index process is not working now. Please try running this process later.', $this->getIndexer()->getName() @@ -364,7 +364,7 @@ public function processEvent(Event $event) /** * Get Indexer strategy object * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\Index\Model\IndexerInterface */ public function getIndexer() @@ -372,17 +372,17 @@ public function getIndexer() if ($this->_currentIndexer === null) { $name = $this->_getData('indexer_code'); if (!$name) { - throw new \Magento\Core\Exception(__('Indexer name is not defined.')); + throw new \Magento\Model\Exception(__('Indexer name is not defined.')); } $indexerConfiguration = $this->_indexerConfig->getIndexer($name); if (!$indexerConfiguration || empty($indexerConfiguration['instance'])) { - throw new \Magento\Core\Exception(__('Indexer model is not defined.')); + throw new \Magento\Model\Exception(__('Indexer model is not defined.')); } $indexerModel = $this->_indexerFactory->create($indexerConfiguration['instance']); if ($indexerModel instanceof \Magento\Index\Model\Indexer\AbstractIndexer) { $this->_currentIndexer = $indexerModel; } else { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Indexer model should extend \Magento\Index\Model\Indexer\Abstract.') ); } diff --git a/app/code/Magento/Index/Model/Resource/AbstractResource.php b/app/code/Magento/Index/Model/Resource/AbstractResource.php index 79c5c0ed16e7b..b51c309dbe69d 100644 --- a/app/code/Magento/Index/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Index/Model/Resource/AbstractResource.php @@ -36,7 +36,7 @@ use Magento\DB\Adapter\AdapterInterface; use Magento\DB\Select; -abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\AbstractDb +abstract class AbstractResource extends \Magento\Model\Resource\Db\AbstractDb { const IDX_SUFFIX = '_idx'; diff --git a/app/code/Magento/Index/Model/Resource/Event.php b/app/code/Magento/Index/Model/Resource/Event.php index 4a66010141408..76b1419196ce6 100644 --- a/app/code/Magento/Index/Model/Resource/Event.php +++ b/app/code/Magento/Index/Model/Resource/Event.php @@ -25,7 +25,7 @@ */ namespace Magento\Index\Model\Resource; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; use Magento\Index\Model\Process as ProcessModel; /** @@ -35,7 +35,7 @@ * @package Magento_Index * @author Magento Core Team */ -class Event extends \Magento\Core\Model\Resource\Db\AbstractDb +class Event extends \Magento\Model\Resource\Db\AbstractDb { /** * @return void diff --git a/app/code/Magento/Index/Model/Resource/Event/Collection.php b/app/code/Magento/Index/Model/Resource/Event/Collection.php index 0976be726e891..5beacc73851bd 100644 --- a/app/code/Magento/Index/Model/Resource/Event/Collection.php +++ b/app/code/Magento/Index/Model/Resource/Event/Collection.php @@ -34,7 +34,7 @@ * @package Magento_Index * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize resource diff --git a/app/code/Magento/Index/Model/Resource/Process.php b/app/code/Magento/Index/Model/Resource/Process.php index 3f97553e5f88a..d3c9033b172a7 100644 --- a/app/code/Magento/Index/Model/Resource/Process.php +++ b/app/code/Magento/Index/Model/Resource/Process.php @@ -34,7 +34,7 @@ * @package Magento_Index * @author Magento Core Team */ -class Process extends \Magento\Core\Model\Resource\Db\AbstractDb +class Process extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Stdlib\DateTime diff --git a/app/code/Magento/Index/Model/Resource/Process/Collection.php b/app/code/Magento/Index/Model/Resource/Process/Collection.php index f75bc4e7f7c7e..c78e3acb31c0f 100644 --- a/app/code/Magento/Index/Model/Resource/Process/Collection.php +++ b/app/code/Magento/Index/Model/Resource/Process/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Index * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize resource diff --git a/app/code/Magento/Index/Model/Shell.php b/app/code/Magento/Index/Model/Shell.php index 6c4940e6b386a..b7e42e46e1c4e 100644 --- a/app/code/Magento/Index/Model/Shell.php +++ b/app/code/Magento/Index/Model/Shell.php @@ -164,7 +164,7 @@ protected function _runSetMode() try { $process->setMode($mode)->save(); echo $process->getIndexer()->getName() . " index was successfully changed index mode\n"; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { echo $e->getMessage() . "\n"; $this->_hasErrors = true; } catch (\Exception $e) { @@ -194,7 +194,7 @@ protected function _runReindex() try { $process->reindexEverything(); echo $process->getIndexer()->getName() . " index was rebuilt successfully\n"; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { echo $e->getMessage() . "\n"; $this->_hasErrors = true; } catch (\Exception $e) { diff --git a/app/code/Magento/Indexer/App/Indexer.php b/app/code/Magento/Indexer/App/Indexer.php index d09eb6dac8d8b..2822af37707ef 100644 --- a/app/code/Magento/Indexer/App/Indexer.php +++ b/app/code/Magento/Indexer/App/Indexer.php @@ -23,7 +23,7 @@ */ namespace Magento\Indexer\App; -class Indexer implements \Magento\LauncherInterface +class Indexer implements \Magento\AppInterface { /** * Report directory diff --git a/app/code/Magento/Indexer/App/Shell.php b/app/code/Magento/Indexer/App/Shell.php index 6ff464fd60d9f..9d31630ece195 100644 --- a/app/code/Magento/Indexer/App/Shell.php +++ b/app/code/Magento/Indexer/App/Shell.php @@ -23,7 +23,7 @@ */ namespace Magento\Indexer\App; -class Shell implements \Magento\LauncherInterface +class Shell implements \Magento\AppInterface { /** * Filename of the entry point script diff --git a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.php b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.php index 5c9c4cac45ef4..1d954fa9f24ad 100644 --- a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.php +++ b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.php @@ -65,7 +65,7 @@ public function massOnTheFlyAction() $this->messageManager->addSuccess( __('A total of %1 indexer(s) have been turned Update on Save mode on.', count($indexerIds)) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException( @@ -101,7 +101,7 @@ public function massChangelogAction() $this->messageManager->addSuccess( __('A total of %1 indexer(s) have been turned Update by Schedule mode on.', count($indexerIds)) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException( diff --git a/app/code/Magento/Indexer/Model/Indexer/State.php b/app/code/Magento/Indexer/Model/Indexer/State.php index 2952ff9d1be61..df2366e939d84 100644 --- a/app/code/Magento/Indexer/Model/Indexer/State.php +++ b/app/code/Magento/Indexer/Model/Indexer/State.php @@ -30,7 +30,7 @@ * @method string getUpdated() * @method \Magento\Indexer\Model\Indexer\State setUpdated($value) */ -class State extends \Magento\Core\Model\AbstractModel +class State extends \Magento\Model\AbstractModel { /** * Indexer statuses diff --git a/app/code/Magento/Core/Model/Mview/View/State.php b/app/code/Magento/Indexer/Model/Mview/View/State.php similarity index 89% rename from app/code/Magento/Core/Model/Mview/View/State.php rename to app/code/Magento/Indexer/Model/Mview/View/State.php index 8efde77087840..51504fa158e1c 100644 --- a/app/code/Magento/Core/Model/Mview/View/State.php +++ b/app/code/Magento/Indexer/Model/Mview/View/State.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Mview\View; +namespace Magento\Indexer\Model\Mview\View; /** * @method \Magento\Indexer\Model\Indexer\State setViewId(string $value) */ -class State extends \Magento\Core\Model\AbstractModel implements \Magento\Mview\View\StateInterface +class State extends \Magento\Model\AbstractModel implements \Magento\Mview\View\StateInterface { /** * Prefix of model events names @@ -45,15 +45,15 @@ class State extends \Magento\Core\Model\AbstractModel implements \Magento\Mview\ /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\Resource\Mview\View\State $resource - * @param \Magento\Core\Model\Resource\Mview\View\State\Collection $resourceCollection + * @param \Magento\Indexer\Model\Resource\Mview\View\State $resource + * @param \Magento\Indexer\Model\Resource\Mview\View\State\Collection $resourceCollection * @param array $data */ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\Resource\Mview\View\State $resource, - \Magento\Core\Model\Resource\Mview\View\State\Collection $resourceCollection, + \Magento\Indexer\Model\Resource\Mview\View\State $resource, + \Magento\Indexer\Model\Resource\Mview\View\State\Collection $resourceCollection, array $data = array() ) { if (!isset($data['mode'])) { diff --git a/app/code/Magento/Indexer/Model/Resource/Indexer/State.php b/app/code/Magento/Indexer/Model/Resource/Indexer/State.php index 301c5e5210d99..79533f29d1c1a 100644 --- a/app/code/Magento/Indexer/Model/Resource/Indexer/State.php +++ b/app/code/Magento/Indexer/Model/Resource/Indexer/State.php @@ -23,7 +23,7 @@ */ namespace Magento\Indexer\Model\Resource\Indexer; -class State extends \Magento\Core\Model\Resource\Db\AbstractDb +class State extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Indexer/Model/Resource/Indexer/State/Collection.php b/app/code/Magento/Indexer/Model/Resource/Indexer/State/Collection.php index 4783571bf5aaa..fc10b1ba75f1e 100644 --- a/app/code/Magento/Indexer/Model/Resource/Indexer/State/Collection.php +++ b/app/code/Magento/Indexer/Model/Resource/Indexer/State/Collection.php @@ -23,7 +23,7 @@ */ namespace Magento\Indexer\Model\Resource\Indexer\State; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Collection initialization diff --git a/app/code/Magento/Core/Model/Resource/Mview/View/State.php b/app/code/Magento/Indexer/Model/Resource/Mview/View/State.php similarity index 91% rename from app/code/Magento/Core/Model/Resource/Mview/View/State.php rename to app/code/Magento/Indexer/Model/Resource/Mview/View/State.php index 78ba4d6f183a8..fb915655685fa 100644 --- a/app/code/Magento/Core/Model/Resource/Mview/View/State.php +++ b/app/code/Magento/Indexer/Model/Resource/Mview/View/State.php @@ -21,9 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Mview\View; +namespace Magento\Indexer\Model\Resource\Mview\View; -class State extends \Magento\Core\Model\Resource\Db\AbstractDb +class State extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Core/Model/Resource/Mview/View/State/Collection.php b/app/code/Magento/Indexer/Model/Resource/Mview/View/State/Collection.php similarity index 80% rename from app/code/Magento/Core/Model/Resource/Mview/View/State/Collection.php rename to app/code/Magento/Indexer/Model/Resource/Mview/View/State/Collection.php index e7bbdca52cb23..da97e537f0f61 100644 --- a/app/code/Magento/Core/Model/Resource/Mview/View/State/Collection.php +++ b/app/code/Magento/Indexer/Model/Resource/Mview/View/State/Collection.php @@ -21,9 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Mview\View\State; +namespace Magento\Indexer\Model\Resource\Mview\View\State; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection implements +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection implements \Magento\Mview\View\State\CollectionInterface { /** @@ -33,6 +33,6 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl */ protected function _construct() { - $this->_init('Magento\Core\Model\Mview\View\State', 'Magento\Core\Model\Resource\Mview\View\State'); + $this->_init('Magento\Indexer\Model\Mview\View\State', 'Magento\Indexer\Model\Resource\Mview\View\State'); } } diff --git a/app/code/Magento/Indexer/Model/Shell.php b/app/code/Magento/Indexer/Model/Shell.php index 88a58b47ceb93..fe5ee2cb764dc 100644 --- a/app/code/Magento/Indexer/Model/Shell.php +++ b/app/code/Magento/Indexer/Model/Shell.php @@ -156,7 +156,7 @@ protected function runSetMode() try { $indexer->{$method}(); echo $indexer->getTitle() . " indexer was successfully changed index mode" . PHP_EOL; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { echo $e->getMessage() . PHP_EOL; $this->hasErrors = true; } catch (\Exception $e) { @@ -186,7 +186,7 @@ protected function runReindex() try { $indexer->reindexAll(); echo $indexer->getTitle() . " index has been rebuilt successfully" . PHP_EOL; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { echo $e->getMessage() . PHP_EOL; $this->hasErrors = true; } catch (\Exception $e) { diff --git a/app/code/Magento/Indexer/etc/di.xml b/app/code/Magento/Indexer/etc/di.xml index 691840ef43f52..94d2719dffb9a 100644 --- a/app/code/Magento/Indexer/etc/di.xml +++ b/app/code/Magento/Indexer/etc/di.xml @@ -24,6 +24,8 @@ */ --> + + @@ -41,6 +43,11 @@ Magento\Indexer\Model\Resource\Indexer\State\Collection + + + Magento\Mview\View\CollectionInterface + + diff --git a/app/code/Magento/Indexer/etc/module.xml b/app/code/Magento/Indexer/etc/module.xml index 70cd4db611f3f..cd1fced8c23fb 100644 --- a/app/code/Magento/Indexer/etc/module.xml +++ b/app/code/Magento/Indexer/etc/module.xml @@ -25,11 +25,7 @@ --> - - - - 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 index bba07d6a219ef..2a94037505cda 100644 --- 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 @@ -64,4 +64,60 @@ ); $installer->getConnection()->createTable($table); +/** + * 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/Install/App/Action/Plugin/Design.php b/app/code/Magento/Install/App/Action/Plugin/Design.php index 459fb8ecba87a..840d7a6709e38 100644 --- a/app/code/Magento/Install/App/Action/Plugin/Design.php +++ b/app/code/Magento/Install/App/Action/Plugin/Design.php @@ -33,9 +33,9 @@ class Design protected $_request; /** - * @var \Magento\Core\Model\App + * @var \Magento\App\AreaList */ - protected $_app; + protected $_areaList; /** * @var \Magento\View\LayoutInterface @@ -53,15 +53,15 @@ class Design protected $_viewDesign; /** - * @param \Magento\App\RequestInterface $request - * @param \Magento\Core\Model\App $app + * @param RequestInterface $request + * @param \Magento\App\AreaList $areaList * @param \Magento\View\LayoutInterface $layout * @param \Magento\View\DesignInterface $viewDesign * @param \Magento\View\Design\Theme\ListInterface $themeList */ public function __construct( \Magento\App\RequestInterface $request, - \Magento\Core\Model\App $app, + \Magento\App\AreaList $areaList, \Magento\View\LayoutInterface $layout, \Magento\View\DesignInterface $viewDesign, \Magento\View\Design\Theme\ListInterface $themeList @@ -69,7 +69,7 @@ public function __construct( $this->_viewDesign = $viewDesign; $this->_themeList = $themeList; $this->_request = $request; - $this->_app = $app; + $this->_areaList = $areaList; $this->_layout = $layout; } @@ -85,7 +85,7 @@ public function __construct( public function beforeDispatch(\Magento\Install\Controller\Action $subject, RequestInterface $request) { $areaCode = $this->_layout->getArea(); - $area = $this->_app->getArea($areaCode); + $area = $this->_areaList->getArea($areaCode); $area->load(\Magento\Core\Model\App\Area::PART_CONFIG); $themePath = $this->_viewDesign->getConfigurationDesignTheme($areaCode); diff --git a/app/code/Magento/Install/App/Console.php b/app/code/Magento/Install/App/Console.php index ab8a04f95b978..806e11ef9f666 100644 --- a/app/code/Magento/Install/App/Console.php +++ b/app/code/Magento/Install/App/Console.php @@ -27,7 +27,7 @@ use Magento\App\Console\Response; -class Console implements \Magento\LauncherInterface +class Console implements \Magento\AppInterface { /** * @var \Magento\Install\Model\Installer\ConsoleFactory diff --git a/app/code/Magento/Install/Controller/Wizard.php b/app/code/Magento/Install/Controller/Wizard.php index 1f37447a0e9f5..27bdd680bc54f 100644 --- a/app/code/Magento/Install/Controller/Wizard.php +++ b/app/code/Magento/Install/Controller/Wizard.php @@ -514,7 +514,7 @@ public function administratorPostAction() $this->getResponse()->setRedirect($step->getNextUrl()); } catch (\Exception $e) { $this->_session->setAdminData($adminData); - if ($e instanceof \Magento\Core\Exception) { + if ($e instanceof \Magento\Model\Exception) { $this->messageManager->addMessages($e->getMessages()); } else { $this->messageManager->addError($e->getMessage()); diff --git a/app/code/Magento/Install/Model/Installer.php b/app/code/Magento/Install/Model/Installer.php index 12534ca065681..aa80892b7a5d0 100644 --- a/app/code/Magento/Install/Model/Installer.php +++ b/app/code/Magento/Install/Model/Installer.php @@ -95,11 +95,11 @@ class Installer extends \Magento\Object protected $_filesystem; /** - * Application + * Area list * - * @var \Magento\Core\Model\App + * @var \Magento\App\AreaList */ - protected $_app; + protected $_areaList; /** * Application @@ -198,7 +198,7 @@ class Installer extends \Magento\Object * @param \Magento\App\Cache\StateInterface $cacheState * @param \Magento\Module\Updater\SetupFactory $setupFactory * @param \Magento\App\Arguments $arguments - * @param \Magento\Core\Model\App $app + * @param \Magento\App\AreaList $areaList * @param \Magento\App\State $appState * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\User\Model\UserFactory $userModelFactory @@ -225,7 +225,7 @@ public function __construct( \Magento\App\Cache\StateInterface $cacheState, \Magento\Module\Updater\SetupFactory $setupFactory, \Magento\App\Arguments $arguments, - \Magento\Core\Model\App $app, + \Magento\App\AreaList $areaList, \Magento\App\State $appState, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\User\Model\UserFactory $userModelFactory, @@ -253,7 +253,7 @@ public function __construct( $this->_encryptor = $encryptor; $this->mathRandom = $mathRandom; $this->_arguments = $arguments; - $this->_app = $app; + $this->_areaList = $areaList; $this->_appState = $appState; $this->_storeManager = $storeManager; $this->_userModelFactory = $userModelFactory; @@ -503,10 +503,9 @@ protected function _setOrderIncrementPrefix(\Magento\Core\Model\Resource\Setup $ public function createAdministrator($data) { // \Magento\User\Model\User belongs to adminhtml area - $this->_app->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG - ); + $this->_areaList + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\App\AreaInterface::PART_CONFIG); /** @var $user \Magento\User\Model\User */ $user = $this->_userModelFactory->create(); diff --git a/app/code/Magento/Install/Model/Installer/Config.php b/app/code/Magento/Install/Model/Installer/Config.php index e4d8c80c57778..f24e7773bb410 100644 --- a/app/code/Magento/Install/Model/Installer/Config.php +++ b/app/code/Magento/Install/Model/Installer/Config.php @@ -222,7 +222,7 @@ public function getFormData() * * @param string $baseUrl * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @throws \Exception */ protected function _checkUrl($baseUrl) @@ -240,7 +240,7 @@ protected function _checkUrl($baseUrl) } if ($response->getStatus() != 200) { $this->messageManager->addError(__('The URL "%1" is invalid.', $baseUrl)); - throw new \Magento\Core\Exception(__('Response from the server is invalid.')); + throw new \Magento\Model\Exception(__('Response from the server is invalid.')); } } diff --git a/app/code/Magento/Install/Model/Installer/Console.php b/app/code/Magento/Install/Model/Installer/Console.php index 317610602e5d5..f4e35e4c68e00 100644 --- a/app/code/Magento/Install/Model/Installer/Console.php +++ b/app/code/Magento/Install/Model/Installer/Console.php @@ -388,7 +388,7 @@ public function install(array $options) return $encryptionKey; } catch (\Exception $e) { - if ($e instanceof \Magento\Core\Exception) { + if ($e instanceof \Magento\Model\Exception) { foreach ($e->getMessages(\Magento\Message\MessageInterface::TYPE_ERROR) as $errorMessage) { $this->addError($errorMessage); } diff --git a/app/code/Magento/Install/Model/Installer/Db.php b/app/code/Magento/Install/Model/Installer/Db.php index 7d478760f2fd6..f492ec6778067 100644 --- a/app/code/Magento/Install/Model/Installer/Db.php +++ b/app/code/Magento/Install/Model/Installer/Db.php @@ -81,7 +81,7 @@ public function __construct( * * @param array $data * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function checkDbConnectionData($data) { @@ -101,7 +101,7 @@ public function checkDbConnectionData($data) } } if (!empty($absenteeExtensions)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('PHP Extensions "%1" must be loaded.', implode(',', $absenteeExtensions)) ); } @@ -113,7 +113,7 @@ public function checkDbConnectionData($data) // check DB server version if (version_compare($version, $requiredVersion) == -1) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'The database server version doesn\'t match system requirements (required: %1, actual: %2).', $requiredVersion, @@ -124,16 +124,16 @@ public function checkDbConnectionData($data) // check InnoDB support if (!$resource->supportEngine()) { - throw new \Magento\Core\Exception(__('Database server does not support the InnoDB storage engine.')); + throw new \Magento\Model\Exception(__('Database server does not support the InnoDB storage engine.')); } // TODO: check user roles - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_logger->logException($e); - throw new \Magento\Core\Exception(__($e->getMessage())); + throw new \Magento\Model\Exception(__($e->getMessage())); } catch (\Exception $e) { $this->_logger->logException($e); - throw new \Magento\Core\Exception(__('Something went wrong while connecting to the database.')); + throw new \Magento\Model\Exception(__('Something went wrong while connecting to the database.')); } return $data; @@ -148,7 +148,7 @@ public function checkDbConnectionData($data) protected function _getCheckedData($data) { if (!isset($data['db_name']) || empty($data['db_name'])) { - throw new \Magento\Core\Exception(__('The Database Name field cannot be empty.')); + throw new \Magento\Model\Exception(__('The Database Name field cannot be empty.')); } //make all table prefix to lower letter if ($data['db_prefix'] != '') { @@ -157,7 +157,7 @@ protected function _getCheckedData($data) //check table prefix if ($data['db_prefix'] != '') { if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $data['db_prefix'])) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'The table prefix should contain only letters (a-z), numbers (0-9) or underscores (_); the first character should be a letter.' ) @@ -187,7 +187,7 @@ protected function _getCheckedData($data) * Retrieve the database resource * * @return \Magento\Install\Model\Installer\Db\AbstractDb - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getDbResource() { diff --git a/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php b/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php index 96c78dd4a2333..ed42f76312069 100644 --- a/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php +++ b/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php @@ -38,7 +38,7 @@ abstract class AbstractDb /** * Resource connection adapter factory * - * @var \Magento\Core\Model\Resource\Type\Db\Pdo\MysqlFactory + * @var \Magento\Model\Resource\Type\Db\Pdo\MysqlFactory */ protected $_adapterFactory; @@ -78,12 +78,12 @@ abstract class AbstractDb protected $_arguments; /** - * @param \Magento\Core\Model\Resource\Type\Db\Pdo\MysqlFactory $adapterFactory + * @param \Magento\Model\Resource\Type\Db\Pdo\MysqlFactory $adapterFactory * @param \Magento\App\Arguments $arguments * @param array $dbExtensions */ public function __construct( - \Magento\Core\Model\Resource\Type\Db\Pdo\MysqlFactory $adapterFactory, + \Magento\Model\Resource\Type\Db\Pdo\MysqlFactory $adapterFactory, \Magento\App\Arguments $arguments, array $dbExtensions = array() ) { diff --git a/app/code/Magento/Install/view/install/config.phtml b/app/code/Magento/Install/view/install/config.phtml index 58228d0644ac0..fdc41575654ff 100644 --- a/app/code/Magento/Install/view/install/config.phtml +++ b/app/code/Magento/Install/view/install/config.phtml @@ -90,7 +90,7 @@

- +
mod_rewrite is enabled in Apache configuration.') ?>
diff --git a/app/code/Magento/Install/view/install/page.phtml b/app/code/Magento/Install/view/install/page.phtml index 60bd43b8308e7..cc55f4f7d62bf 100644 --- a/app/code/Magento/Install/view/install/page.phtml +++ b/app/code/Magento/Install/view/install/page.phtml @@ -112,7 +112,7 @@

- + target="varien_external">
getChildHtml('copyright');?>

diff --git a/app/code/Magento/Integration/Controller/Adminhtml/Integration.php b/app/code/Magento/Integration/Controller/Adminhtml/Integration.php index f4417ed178358..cf2978003b173 100644 --- a/app/code/Magento/Integration/Controller/Adminhtml/Integration.php +++ b/app/code/Magento/Integration/Controller/Adminhtml/Integration.php @@ -268,7 +268,7 @@ public function saveAction() $this->messageManager->addError($this->escaper->escapeHtml($e->getMessage())); $this->_getSession()->setIntegrationData($integrationData); $this->_redirectOnSaveError(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($this->escaper->escapeHtml($e->getMessage())); $this->_redirectOnSaveError(); } catch (\Exception $e) { @@ -387,7 +387,7 @@ public function tokensDialogAction() self::REGISTRY_KEY_CURRENT_INTEGRATION, $this->_integrationService->get($integrationId)->getData() ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect('*/*'); return; @@ -434,7 +434,7 @@ public function tokensExchangeAction() 'popup_content' => $popupContent ); $this->getResponse()->setBody($this->_coreHelper->jsonEncode($result)); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect('*/*'); return; diff --git a/app/code/Magento/Integration/Exception.php b/app/code/Magento/Integration/Exception.php index b2f00f950e4df..ecf8af15b415e 100644 --- a/app/code/Magento/Integration/Exception.php +++ b/app/code/Magento/Integration/Exception.php @@ -25,6 +25,6 @@ */ namespace Magento\Integration; -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { } diff --git a/app/code/Magento/Integration/Model/Integration.php b/app/code/Magento/Integration/Model/Integration.php index a4b43b4ec16c9..316adc6ca6c6b 100644 --- a/app/code/Magento/Integration/Model/Integration.php +++ b/app/code/Magento/Integration/Model/Integration.php @@ -44,7 +44,7 @@ * @method \string getUpdatedAt() * @method Integration setUpdatedAt(\string $createdAt) */ -class Integration extends \Magento\Core\Model\AbstractModel +class Integration extends \Magento\Model\AbstractModel { /**#@+ * Integration Status values @@ -94,7 +94,7 @@ class Integration extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -102,7 +102,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Integration/Model/Oauth/Consumer.php b/app/code/Magento/Integration/Model/Oauth/Consumer.php index 12ad275feb004..59095603be409 100644 --- a/app/code/Magento/Integration/Model/Oauth/Consumer.php +++ b/app/code/Magento/Integration/Model/Oauth/Consumer.php @@ -44,7 +44,7 @@ * @method string getRejectedCallbackUrl() * @method Consumer setRejectedCallbackUrl() setRejectedCallbackUrl(string $rejectedCallbackUrl) */ -class Consumer extends \Magento\Core\Model\AbstractModel implements ConsumerInterface +class Consumer extends \Magento\Model\AbstractModel implements ConsumerInterface { /** * @var \Magento\Url\Validator @@ -61,7 +61,7 @@ class Consumer extends \Magento\Core\Model\AbstractModel implements ConsumerInte * @param \Magento\Registry $registry * @param \Magento\Integration\Model\Oauth\Consumer\Validator\KeyLengthFactory $keyLengthFactory * @param \Magento\Url\Validator $urlValidator - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -70,7 +70,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Integration\Model\Oauth\Consumer\Validator\KeyLengthFactory $keyLengthFactory, \Magento\Url\Validator $urlValidator, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -115,10 +115,10 @@ public function validate() $this->setRejectedCallbackUrl(trim($this->getRejectedCallbackUrl())); if ($this->getCallbackUrl() && !$this->_urlValidator->isValid($this->getCallbackUrl())) { - throw new \Magento\Core\Exception(__('Invalid Callback URL')); + throw new \Magento\Model\Exception(__('Invalid Callback URL')); } if ($this->getRejectedCallbackUrl() && !$this->_urlValidator->isValid($this->getRejectedCallbackUrl())) { - throw new \Magento\Core\Exception(__('Invalid Rejected Callback URL')); + throw new \Magento\Model\Exception(__('Invalid Rejected Callback URL')); } } @@ -130,14 +130,14 @@ public function validate() $validatorLength->setName('Consumer Key'); if (!$validatorLength->isValid($this->getKey())) { $messages = $validatorLength->getMessages(); - throw new \Magento\Core\Exception(array_shift($messages)); + throw new \Magento\Model\Exception(array_shift($messages)); } $validatorLength->setLength(\Magento\Oauth\Helper\Oauth::LENGTH_CONSUMER_SECRET); $validatorLength->setName('Consumer Secret'); if (!$validatorLength->isValid($this->getSecret())) { $messages = $validatorLength->getMessages(); - throw new \Magento\Core\Exception(array_shift($messages)); + throw new \Magento\Model\Exception(array_shift($messages)); } return true; } diff --git a/app/code/Magento/Integration/Model/Oauth/Nonce.php b/app/code/Magento/Integration/Model/Oauth/Nonce.php index d6109360d5a9c..14e02893a44c3 100644 --- a/app/code/Magento/Integration/Model/Oauth/Nonce.php +++ b/app/code/Magento/Integration/Model/Oauth/Nonce.php @@ -35,7 +35,7 @@ * @method \Magento\Integration\Model\Resource\Oauth\Nonce getResource() * @method \Magento\Integration\Model\Resource\Oauth\Nonce _getResource() */ -class Nonce extends \Magento\Core\Model\AbstractModel +class Nonce extends \Magento\Model\AbstractModel { /** * Oauth data @@ -48,7 +48,7 @@ class Nonce extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Integration\Helper\Oauth\Data $oauthData - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -56,7 +56,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Integration\Helper\Oauth\Data $oauthData, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Integration/Model/Oauth/Token.php b/app/code/Magento/Integration/Model/Oauth/Token.php index ce203eb2d496f..297c747d69b0e 100644 --- a/app/code/Magento/Integration/Model/Oauth/Token.php +++ b/app/code/Magento/Integration/Model/Oauth/Token.php @@ -57,7 +57,7 @@ * @method Token setAuthorized() setAuthorized(int $authorized) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Token extends \Magento\Core\Model\AbstractModel +class Token extends \Magento\Model\AbstractModel { /**#@+ * Token types @@ -120,7 +120,7 @@ class Token extends \Magento\Core\Model\AbstractModel * @param \Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory * @param \Magento\Integration\Helper\Oauth\Data $oauthData * @param OauthHelper $oauthHelper - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -134,7 +134,7 @@ public function __construct( \Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory, \Magento\Integration\Helper\Oauth\Data $oauthData, OauthHelper $oauthHelper, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Integration/Model/Resource/Integration.php b/app/code/Magento/Integration/Model/Resource/Integration.php index fdd2563ca796a..6a302dc675783 100644 --- a/app/code/Magento/Integration/Model/Resource/Integration.php +++ b/app/code/Magento/Integration/Model/Resource/Integration.php @@ -26,7 +26,7 @@ /** * Integration resource model */ -class Integration extends \Magento\Core\Model\Resource\Db\AbstractDb +class Integration extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize resource model diff --git a/app/code/Magento/Integration/Model/Resource/Integration/Collection.php b/app/code/Magento/Integration/Model/Resource/Integration/Collection.php index fce8300e2f9cd..c22f6dd25fd82 100644 --- a/app/code/Magento/Integration/Model/Resource/Integration/Collection.php +++ b/app/code/Magento/Integration/Model/Resource/Integration/Collection.php @@ -26,7 +26,7 @@ /** * Integrations collection. */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource collection initialization. diff --git a/app/code/Magento/Integration/Model/Resource/Oauth/Consumer.php b/app/code/Magento/Integration/Model/Resource/Oauth/Consumer.php index 3ea3130308d35..f8f12fc2a4157 100644 --- a/app/code/Magento/Integration/Model/Resource/Oauth/Consumer.php +++ b/app/code/Magento/Integration/Model/Resource/Oauth/Consumer.php @@ -23,7 +23,7 @@ */ namespace Magento\Integration\Model\Resource\Oauth; -class Consumer extends \Magento\Core\Model\Resource\Db\AbstractDb +class Consumer extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Stdlib\DateTime @@ -53,10 +53,10 @@ protected function _construct() /** * Set updated_at automatically before saving * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - public function _beforeSave(\Magento\Core\Model\AbstractModel $object) + public function _beforeSave(\Magento\Model\AbstractModel $object) { $object->setUpdatedAt($this->_dateTime->formatDate(time())); return parent::_beforeSave($object); @@ -65,10 +65,10 @@ public function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * Delete all Nonce entries associated with the consumer * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - public function _afterDelete(\Magento\Core\Model\AbstractModel $object) + public function _afterDelete(\Magento\Model\AbstractModel $object) { $adapter = $this->_getWriteAdapter(); $adapter->delete($this->getTable('oauth_nonce'), array('consumer_id' => $object->getId())); diff --git a/app/code/Magento/Integration/Model/Resource/Oauth/Consumer/Collection.php b/app/code/Magento/Integration/Model/Resource/Oauth/Consumer/Collection.php index c1b681528671d..d99e21f05726b 100644 --- a/app/code/Magento/Integration/Model/Resource/Oauth/Consumer/Collection.php +++ b/app/code/Magento/Integration/Model/Resource/Oauth/Consumer/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Oauth * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize collection model diff --git a/app/code/Magento/Integration/Model/Resource/Oauth/Nonce.php b/app/code/Magento/Integration/Model/Resource/Oauth/Nonce.php index 81859acc0c850..9f2772e216777 100644 --- a/app/code/Magento/Integration/Model/Resource/Oauth/Nonce.php +++ b/app/code/Magento/Integration/Model/Resource/Oauth/Nonce.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Nonce extends \Magento\Core\Model\Resource\Db\AbstractDb +class Nonce extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize resource model diff --git a/app/code/Magento/Integration/Model/Resource/Oauth/Nonce/Collection.php b/app/code/Magento/Integration/Model/Resource/Oauth/Nonce/Collection.php index 028c66ae0517b..a42f2c70256ff 100644 --- a/app/code/Magento/Integration/Model/Resource/Oauth/Nonce/Collection.php +++ b/app/code/Magento/Integration/Model/Resource/Oauth/Nonce/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Oauth * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize collection model diff --git a/app/code/Magento/Integration/Model/Resource/Oauth/Token.php b/app/code/Magento/Integration/Model/Resource/Oauth/Token.php index 2a83cc4466db5..97c600e34feef 100644 --- a/app/code/Magento/Integration/Model/Resource/Oauth/Token.php +++ b/app/code/Magento/Integration/Model/Resource/Oauth/Token.php @@ -28,7 +28,7 @@ /** * OAuth token resource model */ -class Token extends \Magento\Core\Model\Resource\Db\AbstractDb +class Token extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Stdlib\DateTime @@ -59,13 +59,13 @@ protected function _construct() * Clean up old authorized tokens for specified consumer-user pairs * * @param \Magento\Integration\Model\Oauth\Token $exceptToken Token just created to exclude from delete - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return int The number of affected rows */ public function cleanOldAuthorizedTokensExcept(\Magento\Integration\Model\Oauth\Token $exceptToken) { if (!$exceptToken->getId() || !$exceptToken->getAuthorized()) { - throw new \Magento\Core\Exception('Invalid token to except'); + throw new \Magento\Model\Exception('Invalid token to except'); } $adapter = $this->_getWriteAdapter(); $where = $adapter->quoteInto( @@ -80,7 +80,7 @@ public function cleanOldAuthorizedTokensExcept(\Magento\Integration\Model\Oauth\ } elseif ($exceptToken->getAdminId()) { $where .= $adapter->quoteInto(' AND admin_id = ?', $exceptToken->getAdminId(), \Zend_Db::INT_TYPE); } else { - throw new \Magento\Core\Exception('Invalid token to except'); + throw new \Magento\Model\Exception('Invalid token to except'); } return $adapter->delete($this->getMainTable(), $where); } diff --git a/app/code/Magento/Integration/Model/Resource/Oauth/Token/Collection.php b/app/code/Magento/Integration/Model/Resource/Oauth/Token/Collection.php index a7ce3f76f1050..f9133ec5a0c78 100644 --- a/app/code/Magento/Integration/Model/Resource/Oauth/Token/Collection.php +++ b/app/code/Magento/Integration/Model/Resource/Oauth/Token/Collection.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize collection model diff --git a/app/code/Magento/Integration/Service/OauthV1.php b/app/code/Magento/Integration/Service/OauthV1.php index 812f505509001..7f88cfdf9f78a 100644 --- a/app/code/Magento/Integration/Service/OauthV1.php +++ b/app/code/Magento/Integration/Service/OauthV1.php @@ -123,7 +123,7 @@ public function createConsumer($consumerData) $consumer = $this->_consumerFactory->create($consumerData); $consumer->save(); return $consumer; - } catch (\Magento\Core\Exception $exception) { + } catch (\Magento\Model\Exception $exception) { throw $exception; } catch (\Exception $exception) { throw new \Magento\Oauth\Exception(__('Unexpected error. Unable to create oAuth consumer account.')); @@ -178,7 +178,7 @@ public function loadConsumer($consumerId) { try { return $this->_consumerFactory->create()->load($consumerId); - } catch (\Magento\Core\Exception $exception) { + } catch (\Magento\Model\Exception $exception) { throw $exception; } catch (\Exception $exception) { throw new \Magento\Oauth\Exception(__('Unexpected error. Unable to load oAuth consumer account.')); @@ -192,7 +192,7 @@ public function loadConsumerByKey($key) { try { return $this->_consumerFactory->create()->load($key, 'key'); - } catch (\Magento\Core\Exception $exception) { + } catch (\Magento\Model\Exception $exception) { throw $exception; } catch (\Exception $exception) { throw new \Magento\Oauth\Exception(__('Unexpected error. Unable to load oAuth consumer account.')); @@ -229,7 +229,7 @@ public function postToConsumer($consumerId, $endpointUrl) $this->_httpClient->setConfig(array('maxredirects' => $maxredirects, 'timeout' => $timeout)); $this->_httpClient->request(\Magento\HTTP\ZendClient::POST); return $verifier->getVerifier(); - } catch (\Magento\Core\Exception $exception) { + } catch (\Magento\Model\Exception $exception) { throw $exception; } catch (\Magento\Oauth\Exception $exception) { throw $exception; diff --git a/app/code/Magento/Integration/Service/OauthV1Interface.php b/app/code/Magento/Integration/Service/OauthV1Interface.php index 330ba6af66198..763dfd87125f6 100644 --- a/app/code/Magento/Integration/Service/OauthV1Interface.php +++ b/app/code/Magento/Integration/Service/OauthV1Interface.php @@ -41,7 +41,7 @@ interface OauthV1Interface * ) * * @return \Magento\Integration\Model\Oauth\Consumer - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @throws \Magento\Oauth\Exception */ public function createConsumer($consumerData); @@ -69,7 +69,7 @@ public function getAccessToken($consumerId); * @param int $consumerId * @return \Magento\Integration\Model\Oauth\Consumer * @throws \Magento\Oauth\Exception - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function loadConsumer($consumerId); @@ -79,7 +79,7 @@ public function loadConsumer($consumerId); * @param string $key * @return \Magento\Integration\Model\Oauth\Consumer * @throws \Magento\Oauth\Exception - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function loadConsumerByKey($key); @@ -89,7 +89,7 @@ public function loadConsumerByKey($key); * @param int $consumerId - The consumer Id. * @param string $endpointUrl - The integration endpoint Url (for HTTP Post) * @return string - The oauth_verifier. - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @throws \Magento\Oauth\Exception */ public function postToConsumer($consumerId, $endpointUrl); diff --git a/app/code/Magento/Log/App/Shell.php b/app/code/Magento/Log/App/Shell.php index 469aa8f4e863f..1cd2bfee5f8bc 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\LauncherInterface; +use Magento\AppInterface; -class Shell implements LauncherInterface +class Shell implements AppInterface { /** * Filename of the entry point script diff --git a/app/code/Magento/Log/Model/Aggregation.php b/app/code/Magento/Log/Model/Aggregation.php index 1d1045e9fcb4c..30e8fa28c313c 100644 --- a/app/code/Magento/Log/Model/Aggregation.php +++ b/app/code/Magento/Log/Model/Aggregation.php @@ -35,7 +35,7 @@ * @package Magento_Log * @author Magento Core Team */ -class Aggregation extends \Magento\Core\Model\AbstractModel +class Aggregation extends \Magento\Model\AbstractModel { /** * Last record data @@ -53,7 +53,7 @@ class Aggregation extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -61,7 +61,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Log/Model/Cron.php b/app/code/Magento/Log/Model/Cron.php index f83f6c946e9e1..70d35de7b6af6 100644 --- a/app/code/Magento/Log/Model/Cron.php +++ b/app/code/Magento/Log/Model/Cron.php @@ -34,7 +34,7 @@ */ namespace Magento\Log\Model; -class Cron extends \Magento\Core\Model\AbstractModel +class Cron extends \Magento\Model\AbstractModel { const XML_PATH_EMAIL_LOG_CLEAN_TEMPLATE = 'system/log/error_email_template'; @@ -58,11 +58,6 @@ class Cron extends \Magento\Core\Model\AbstractModel */ protected $_coreStoreConfig; - /** - * @var \Magento\TranslateInterface - */ - protected $_translate; - /** * @var \Magento\Core\Model\StoreManagerInterface */ @@ -78,15 +73,20 @@ class Cron extends \Magento\Core\Model\AbstractModel */ protected $_transportBuilder; + /** + * @var \Magento\Translate\Inline\StateInterface + */ + protected $inlineTranslation; + /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Log\Model\Log $log + * @param Log $log * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\TranslateInterface $translate * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -96,17 +96,17 @@ public function __construct( \Magento\Mail\Template\TransportBuilder $transportBuilder, \Magento\Log\Model\Log $log, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\TranslateInterface $translate, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Translate\Inline\StateInterface $inlineTranslation, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->_transportBuilder = $transportBuilder; $this->_log = $log; $this->_storeManager = $storeManager; - $this->_translate = $translate; $this->_coreStoreConfig = $coreStoreConfig; + $this->inlineTranslation = $inlineTranslation; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -124,7 +124,7 @@ protected function _sendLogCleanEmail() return $this; } - $this->_translate->setTranslateInline(false); + $this->inlineTranslation->suspend(); $transport = $this->_transportBuilder->setTemplateIdentifier( $this->_coreStoreConfig->getConfig(self::XML_PATH_EMAIL_LOG_CLEAN_TEMPLATE) @@ -143,7 +143,8 @@ protected function _sendLogCleanEmail() $transport->sendMessage(); - $this->_translate->setTranslateInline(true); + $this->inlineTranslation->resume(); + return $this; } diff --git a/app/code/Magento/Log/Model/Customer.php b/app/code/Magento/Log/Model/Customer.php index 10e696e194338..ea6b708d270a8 100644 --- a/app/code/Magento/Log/Model/Customer.php +++ b/app/code/Magento/Log/Model/Customer.php @@ -45,7 +45,7 @@ * @package Magento_Log * @author Magento Core Team */ -class Customer extends \Magento\Core\Model\AbstractModel +class Customer extends \Magento\Model\AbstractModel { /** * @var \Magento\Stdlib\DateTime @@ -56,7 +56,7 @@ class Customer extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -64,7 +64,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -86,16 +86,12 @@ protected function _construct() /** * Load last log by customer id * - * @param \Magento\Customer\Model\Customer|int $customer - * @return $this + * @param int $customerId + * @return \Magento\Log\Model\Customer */ - public function loadByCustomer($customer) + public function loadByCustomer($customerId) { - if ($customer instanceof \Magento\Customer\Model\Customer) { - $customer = $customer->getId(); - } - - return $this->load($customer, 'customer_id'); + return $this->load($customerId, 'customer_id'); } /** diff --git a/app/code/Magento/Log/Model/Log.php b/app/code/Magento/Log/Model/Log.php index fe636fd634160..a523909587293 100644 --- a/app/code/Magento/Log/Model/Log.php +++ b/app/code/Magento/Log/Model/Log.php @@ -45,7 +45,7 @@ * @package Magento_Log * @author Magento Core Team */ -class Log extends \Magento\Core\Model\AbstractModel +class Log extends \Magento\Model\AbstractModel { const XML_LOG_CLEAN_DAYS = 'system/log/clean_after_day'; @@ -60,7 +60,7 @@ class Log extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -68,7 +68,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Log/Model/Resource/Aggregation.php b/app/code/Magento/Log/Model/Resource/Aggregation.php index fe2f10ae40ef7..c7adfb74fcf35 100644 --- a/app/code/Magento/Log/Model/Resource/Aggregation.php +++ b/app/code/Magento/Log/Model/Resource/Aggregation.php @@ -32,7 +32,7 @@ * @package Magento_Log * @author Magento Core Team */ -class Aggregation extends \Magento\Core\Model\Resource\Db\AbstractDb +class Aggregation extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Log/Model/Resource/Customer.php b/app/code/Magento/Log/Model/Resource/Customer.php index da432d4a137fa..d4139cf304333 100644 --- a/app/code/Magento/Log/Model/Resource/Customer.php +++ b/app/code/Magento/Log/Model/Resource/Customer.php @@ -32,7 +32,7 @@ * @package Magento_Log * @author Magento Core Team */ -class Customer extends \Magento\Core\Model\Resource\Db\AbstractDb +class Customer extends \Magento\Model\Resource\Db\AbstractDb { /** * Visitor data table name diff --git a/app/code/Magento/Log/Model/Resource/Helper.php b/app/code/Magento/Log/Model/Resource/Helper.php index b562e5a13a340..7fa5ce2d0a0e9 100644 --- a/app/code/Magento/Log/Model/Resource/Helper.php +++ b/app/code/Magento/Log/Model/Resource/Helper.php @@ -33,7 +33,7 @@ */ namespace Magento\Log\Model\Resource; -class Helper extends \Magento\Core\Model\Resource\Helper +class Helper extends \Magento\DB\Helper { /** * Returns information about table in DB diff --git a/app/code/Magento/Log/Model/Resource/Log.php b/app/code/Magento/Log/Model/Resource/Log.php index 771b2e8af7100..218a5bc0bc040 100644 --- a/app/code/Magento/Log/Model/Resource/Log.php +++ b/app/code/Magento/Log/Model/Resource/Log.php @@ -32,7 +32,7 @@ * @package Magento_Log * @author Magento Core Team */ -class Log extends \Magento\Core\Model\Resource\Db\AbstractDb +class Log extends \Magento\Model\Resource\Db\AbstractDb { /** * Core event manager proxy diff --git a/app/code/Magento/Log/Model/Resource/Shell.php b/app/code/Magento/Log/Model/Resource/Shell.php index 8789b4f57ddc1..4ca3dba3f5f32 100644 --- a/app/code/Magento/Log/Model/Resource/Shell.php +++ b/app/code/Magento/Log/Model/Resource/Shell.php @@ -41,17 +41,19 @@ class Shell protected $_resource; /** - * @var \Magento\Core\Model\Resource\HelperFactory + * @var \Magento\Log\Model\Resource\Helper */ - protected $_helperPool; + protected $_resourceHelper; /** - * @param \Magento\Core\Model\Resource\HelperPool $helperPool + * @param \Magento\Log\Model\Resource\Helper $resourceHelper * @param \Magento\App\Resource $resource */ - public function __construct(\Magento\Core\Model\Resource\HelperPool $helperPool, \Magento\App\Resource $resource) - { - $this->_helperPool = $helperPool; + public function __construct( + \Magento\Log\Model\Resource\Helper $resourceHelper, + \Magento\App\Resource $resource + ) { + $this->_resourceHelper = $resourceHelper; $this->_resource = $resource; } @@ -75,10 +77,9 @@ public function getTablesInfo() 'catalog_compare_item' ); - $resHelper = $this->_helperPool->get('Magento_Log'); $result = array(); foreach ($tables as $table) { - $info = $resHelper->getTableInfo($this->_resource->getTableName($table)); + $info = $this->_resourceHelper->getTableInfo($this->_resource->getTableName($table)); if (!$info) { continue; } diff --git a/app/code/Magento/Log/Model/Resource/Visitor.php b/app/code/Magento/Log/Model/Resource/Visitor.php index 1cbcb931e0585..fa093a98afaed 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor.php +++ b/app/code/Magento/Log/Model/Resource/Visitor.php @@ -28,7 +28,7 @@ /** * Visitor log resource */ -class Visitor extends \Magento\Core\Model\Resource\Db\AbstractDb +class Visitor extends \Magento\Model\Resource\Db\AbstractDb { /** * Magento string lib @@ -78,10 +78,10 @@ protected function _construct() /** * Prepare data for save * - * @param \Magento\Core\Model\AbstractModel $visitor + * @param \Magento\Model\AbstractModel $visitor * @return array */ - protected function _prepareDataForSave(\Magento\Core\Model\AbstractModel $visitor) + protected function _prepareDataForSave(\Magento\Model\AbstractModel $visitor) { return array( 'session_id' => $visitor->getSessionId(), @@ -119,10 +119,10 @@ protected function _saveUrlInfo($visitor) /** * Save url info before save * - * @param \Magento\Core\Model\AbstractModel $visitor + * @param \Magento\Model\AbstractModel $visitor * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $visitor) + protected function _beforeSave(\Magento\Model\AbstractModel $visitor) { if (!$visitor->getIsNewVisitor()) { $this->_saveUrlInfo($visitor); @@ -133,10 +133,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $visitor) /** * Actions after save * - * @param \Magento\Core\Model\AbstractModel $visitor + * @param \Magento\Model\AbstractModel $visitor * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $visitor) + protected function _afterSave(\Magento\Model\AbstractModel $visitor) { if ($visitor->getIsNewVisitor()) { $this->_saveVisitorInfo($visitor); @@ -156,10 +156,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $visitor) /** * Perform actions after object load * - * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @param \Magento\Model\AbstractModel|\Magento\Object $object + * @return \Magento\Model\Resource\Db\AbstractDb */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(\Magento\Model\AbstractModel $object) { parent::_afterLoad($object); // Add information about quote to visitor diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Collection.php b/app/code/Magento/Log/Model/Resource/Visitor/Collection.php index 6971c61d61dd9..ea1aae1a30ec3 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Collection.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Log * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Visitor data table name @@ -180,7 +180,7 @@ protected function _getFieldMap($fieldName) * * @param boolean $printQuery * @param boolean $logQuery - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function load($printQuery = false, $logQuery = false) { diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Online.php b/app/code/Magento/Log/Model/Resource/Visitor/Online.php index edfb4485262da..c5102b3499cff 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Online.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Online.php @@ -32,7 +32,7 @@ * @package Magento_Log * @author Magento Core Team */ -class Online extends \Magento\Core\Model\Resource\Db\AbstractDb +class Online extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Stdlib\DateTime\DateTime 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 50eb8e56f6e9c..440793e197449 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Online/Collection.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Online/Collection.php @@ -25,6 +25,8 @@ */ namespace Magento\Log\Model\Resource\Visitor\Online; +use Magento\Customer\Service\V1\CustomerMetadataServiceInterface; + /** * Log Online visitors collection * @@ -32,7 +34,7 @@ * @package Magento_Log * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Joined fields array @@ -42,29 +44,29 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl protected $_fields = array(); /** - * @var \Magento\Customer\Model\CustomerFactory + * @var \Magento\Eav\Helper\Data */ - protected $_customerFactory; + protected $_eavHelper; /** * @param \Magento\Core\Model\EntityFactory $entityFactory * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * @param \Magento\Eav\Helper\Data $eavHelper * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Customer\Model\CustomerFactory $customerFactory, + \Magento\Eav\Helper\Data $eavHelper, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { - $this->_customerFactory = $customerFactory; + $this->_eavHelper = $eavHelper; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); } @@ -85,7 +87,6 @@ protected function _construct() */ public function addCustomerData() { - $customer = $this->_customerFactory->create(); // alias => attribute_code $attributes = array( 'customer_lastname' => 'lastname', @@ -94,37 +95,34 @@ public function addCustomerData() ); foreach ($attributes as $alias => $attributeCode) { - $attribute = $customer->getAttribute($attributeCode); - /* @var $attribute \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */ - if ($attribute->getBackendType() == 'static') { - $tableAlias = 'customer_' . $attribute->getAttributeCode(); + $attribute = $this->_eavHelper->getAttributeMetadata( + CustomerMetadataServiceInterface::ENTITY_TYPE_CUSTOMER, + $attributeCode + ); + + $tableAlias = 'customer_' . $attributeCode; + if ($attribute['backend_type'] == 'static') { $this->getSelect()->joinLeft( - array($tableAlias => $attribute->getBackend()->getTable()), + array($tableAlias => $attribute['attribute_table']), sprintf('%s.entity_id=main_table.customer_id', $tableAlias), - array($alias => $attribute->getAttributeCode()) + array($alias => $attributeCode) ); - - $this->_fields[$alias] = sprintf('%s.%s', $tableAlias, $attribute->getAttributeCode()); + $this->_fields[$alias] = sprintf('%s.%s', $tableAlias, $attributeCode); } else { - $tableAlias = 'customer_' . $attribute->getAttributeCode(); - - $joinConds = array( + $joinConds = array( sprintf('%s.entity_id=main_table.customer_id', $tableAlias), - $this->getConnection()->quoteInto($tableAlias . '.attribute_id=?', $attribute->getAttributeId()) + $this->getConnection()->quoteInto($tableAlias . '.attribute_id=?', $attribute['attribute_id']) ); - $this->getSelect()->joinLeft( - array($tableAlias => $attribute->getBackend()->getTable()), + array($tableAlias => $attribute['attribute_table']), join(' AND ', $joinConds), array($alias => 'value') ); - $this->_fields[$alias] = sprintf('%s.value', $tableAlias); } } - $this->setFlag('has_customer_data', true); return $this; } 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 6c9e676e225c0..60e26ee91a811 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 @@ -37,20 +37,20 @@ class Collection extends \Magento\Log\Model\Resource\Visitor\Online\Collection * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * @param \Magento\Eav\Helper\Data $eavHelper * @param \Magento\Log\Model\Visitor\OnlineFactory $onlineFactory * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Customer\Model\CustomerFactory $customerFactory, + \Magento\Eav\Helper\Data $eavHelper, \Magento\Log\Model\Visitor\OnlineFactory $onlineFactory, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_onlineFactory = $onlineFactory; parent::__construct( @@ -58,7 +58,7 @@ public function __construct( $logger, $fetchStrategy, $eventManager, - $customerFactory, + $eavHelper, $connection, $resource ); diff --git a/app/code/Magento/Log/Model/Visitor.php b/app/code/Magento/Log/Model/Visitor.php index 4797e58b3154c..428fd2b2bde60 100644 --- a/app/code/Magento/Log/Model/Visitor.php +++ b/app/code/Magento/Log/Model/Visitor.php @@ -37,7 +37,7 @@ * @method int getStoreId() * @method \Magento\Log\Model\Visitor setStoreId(int $value) */ -class Visitor extends \Magento\Core\Model\AbstractModel +class Visitor extends \Magento\Model\AbstractModel { const DEFAULT_ONLINE_MINUTES_INTERVAL = 15; @@ -89,11 +89,6 @@ class Visitor extends \Magento\Core\Model\AbstractModel */ protected $_quoteFactory; - /** - * @var \Magento\Customer\Model\CustomerFactory - */ - protected $_customerFactory; - /** * @var \Magento\HTTP\Header */ @@ -118,7 +113,6 @@ class Visitor extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Session\SessionManagerInterface $session * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -127,7 +121,8 @@ class Visitor extends \Magento\Core\Model\AbstractModel * @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\Module\Manager $moduleManager + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $ignoredUserAgents * @param array $ignores @@ -137,7 +132,6 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Session\SessionManagerInterface $session, \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -146,14 +140,14 @@ public function __construct( \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress, \Magento\HTTP\PhpEnvironment\ServerAddress $serverAddress, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Module\Manager $moduleManager, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $ignoredUserAgents = array(), array $ignores = array(), array $data = array() ) { $this->_coreStoreConfig = $coreStoreConfig; - $this->_customerFactory = $customerFactory; $this->_quoteFactory = $quoteFactory; $this->_session = $session; $this->_storeManager = $storeManager; @@ -409,28 +403,6 @@ public function addIpData($data) return $this; } - /** - * Load customer data into $data - * - * @param object $data - * @return $this - */ - public function addCustomerData($data) - { - $customerId = $data->getCustomerId(); - if (intval($customerId) <= 0) { - return $this; - } - $customerData = $this->_customerFactory->create()->load($customerId); - $newCustomerData = array(); - foreach ($customerData->getData() as $propName => $propValue) { - $newCustomerData['customer_' . $propName] = $propValue; - } - - $data->addData($newCustomerData); - return $this; - } - /** * Load quote data into $data * diff --git a/app/code/Magento/Log/Model/Visitor/Online.php b/app/code/Magento/Log/Model/Visitor/Online.php index c1342b8fb7265..d625224e73bb7 100644 --- a/app/code/Magento/Log/Model/Visitor/Online.php +++ b/app/code/Magento/Log/Model/Visitor/Online.php @@ -46,7 +46,7 @@ * @package Magento_Log * @author Magento Core Team */ -class Online extends \Magento\Core\Model\AbstractModel +class Online extends \Magento\Model\AbstractModel { const XML_PATH_ONLINE_INTERVAL = 'customer/online_customers/online_minutes_interval'; @@ -63,7 +63,7 @@ class Online extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -71,7 +71,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Log/etc/module.xml b/app/code/Magento/Log/etc/module.xml index 04ec2fc0a420d..280e757c07579 100644 --- a/app/code/Magento/Log/etc/module.xml +++ b/app/code/Magento/Log/etc/module.xml @@ -32,6 +32,7 @@ + diff --git a/app/code/Magento/Multishipping/Controller/Checkout.php b/app/code/Magento/Multishipping/Controller/Checkout.php index 0046d9c7cadc2..de025198e8bd4 100755 --- a/app/code/Magento/Multishipping/Controller/Checkout.php +++ b/app/code/Magento/Multishipping/Controller/Checkout.php @@ -280,7 +280,7 @@ public function addressesPostAction() if ($shipToInfo = $this->getRequest()->getPost('ship')) { $this->_getCheckout()->setShippingItemsInformation($shipToInfo); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect('*/*/addresses'); } catch (\Exception $e) { @@ -462,7 +462,7 @@ public function overviewAction() $this->_view->loadLayout(); $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect('*/*/billing'); } catch (\Exception $e) { @@ -530,7 +530,7 @@ public function overviewPostAction() $this->_getCheckout()->getCheckoutSession()->clearQuote(); $this->messageManager->addError($e->getMessage()); $this->_redirect('*/cart'); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_objectManager->get( 'Magento\Checkout\Helper\Data' )->sendPaymentFailedEmail( diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index a742d2c8645d6..01e9dc342a04a 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -283,7 +283,7 @@ public function removeAddressItem($addressId, $itemId) * * @param array $info * @return \Magento\Multishipping\Model\Checkout\Type\Multishipping - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setShippingItemsInformation($info) { @@ -299,7 +299,7 @@ public function setShippingItemsInformation($info) $maxQty = $this->helper->getMaximumQty(); if ($allQty > $maxQty) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Maximum qty allowed for Shipping to multiple addresses is %1', $maxQty) ); } @@ -460,7 +460,7 @@ public function setQuoteCustomerBillingAddress($addressId) * * @param array $methods * @return \Magento\Multishipping\Model\Checkout\Type\Multishipping - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setShippingMethods($methods) { @@ -469,7 +469,7 @@ public function setShippingMethods($methods) if (isset($methods[$address->getId()])) { $address->setShippingMethod($methods[$address->getId()]); } elseif (!$address->getShippingMethod()) { - throw new \Magento\Core\Exception(__('Please select shipping methods for all addresses.')); + throw new \Magento\Model\Exception(__('Please select shipping methods for all addresses.')); } } $this->save(); @@ -481,15 +481,15 @@ public function setShippingMethods($methods) * * @param array $payment * @return \Magento\Multishipping\Model\Checkout\Type\Multishipping - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setPaymentMethod($payment) { if (!isset($payment['method'])) { - throw new \Magento\Core\Exception(__('Payment method is not defined')); + throw new \Magento\Model\Exception(__('Payment method is not defined')); } if (!$this->paymentSpecification->isSatisfiedBy($payment['method'])) { - throw new \Magento\Core\Exception(__('The requested Payment Method is not available for multishipping.')); + throw new \Magento\Model\Exception(__('The requested Payment Method is not available for multishipping.')); } $quote = $this->getQuote(); $quote->getPayment()->importData($payment); @@ -555,7 +555,7 @@ protected function _prepareOrder(\Magento\Sales\Model\Quote\Address $address) * Validate quote data * * @return \Magento\Multishipping\Model\Checkout\Type\Multishipping - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _validate() { @@ -564,24 +564,24 @@ protected function _validate() /** @var $paymentMethod \Magento\Payment\Model\Method\AbstractMethod */ $paymentMethod = $quote->getPayment()->getMethodInstance(); if (!empty($paymentMethod) && !$paymentMethod->isAvailable($quote)) { - throw new \Magento\Core\Exception(__('Please specify a payment method.')); + throw new \Magento\Model\Exception(__('Please specify a payment method.')); } $addresses = $quote->getAllShippingAddresses(); foreach ($addresses as $address) { $addressValidation = $address->validate(); if ($addressValidation !== true) { - throw new \Magento\Core\Exception(__('Please check shipping addresses information.')); + throw new \Magento\Model\Exception(__('Please check shipping addresses information.')); } $method = $address->getShippingMethod(); $rate = $address->getShippingRateByCode($method); if (!$method || !$rate) { - throw new \Magento\Core\Exception(__('Please specify shipping methods for all addresses.')); + throw new \Magento\Model\Exception(__('Please specify shipping methods for all addresses.')); } } $addressValidation = $quote->getBillingAddress()->validate(); if ($addressValidation !== true) { - throw new \Magento\Core\Exception(__('Please check billing address information.')); + throw new \Magento\Model\Exception(__('Please check billing address information.')); } return $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 ffe8f7ea7a995..fe7d0f8b4ad8d 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 @@ -59,7 +59,7 @@ class Website extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Core\Model\Resource\Helper $resourceHelper + * @param \Magento\DB\Helper $resourceHelper * @param \Magento\Core\Model\Resource\Website\CollectionFactory $websitesFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Registry $registry @@ -67,7 +67,7 @@ class Website extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Core\Model\Resource\Helper $resourceHelper, + \Magento\DB\Helper $resourceHelper, \Magento\Core\Model\Resource\Website\CollectionFactory $websitesFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Registry $registry, diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php index 2403b4819e915..796aca675add8 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php @@ -282,7 +282,7 @@ public function editAction() /** * Save Newsletter queue * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return void */ public function saveAction() @@ -297,7 +297,7 @@ public function saveAction() $template = $this->_objectManager->create('Magento\Newsletter\Model\Template')->load($templateId); if (!$template->getId() || $template->getIsSystem()) { - throw new \Magento\Core\Exception(__('Please correct the newsletter template and try again.')); + throw new \Magento\Model\Exception(__('Please correct the newsletter template and try again.')); } $queue->setTemplateId( @@ -351,7 +351,7 @@ public function saveAction() $this->_getSession()->setFormData(false); $this->_redirect('*/*'); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $id = $this->getRequest()->getParam('id'); if ($id) { diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php index a6a439f06f6a8..95924c54debaa 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php @@ -227,7 +227,7 @@ public function saveAction() $this->_redirect('*/template'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError(nl2br($e->getMessage())); $this->_getSession()->setData('newsletter_template_form_data', $this->getRequest()->getParams()); } catch (\Exception $e) { @@ -255,7 +255,7 @@ public function deleteAction() $template->delete(); $this->messageManager->addSuccess(__('The newsletter template has been deleted.')); $this->_getSession()->setFormData(false); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('An error occurred while deleting this template.')); diff --git a/app/code/Magento/Newsletter/Controller/Subscriber.php b/app/code/Magento/Newsletter/Controller/Subscriber.php index 074a2777f4075..1392bf2dfca2a 100644 --- a/app/code/Magento/Newsletter/Controller/Subscriber.php +++ b/app/code/Magento/Newsletter/Controller/Subscriber.php @@ -95,7 +95,7 @@ public function __construct( /** * New subscription action * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return void */ public function newAction() @@ -105,7 +105,7 @@ public function newAction() try { if (!\Zend_Validate::is($email, 'EmailAddress')) { - throw new \Magento\Core\Exception(__('Please enter a valid email address.')); + throw new \Magento\Model\Exception(__('Please enter a valid email address.')); } if ($this->_objectManager->get( @@ -114,7 +114,7 @@ public function newAction() \Magento\Newsletter\Model\Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG ) != 1 && !$this->_customerSession->isLoggedIn() ) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Sorry, but the administrator denied subscription for guests. ' . 'Please register.', @@ -129,7 +129,7 @@ public function newAction() $email )->getId(); if ($ownerId !== null && $ownerId != $this->_customerSession->getId()) { - throw new \Magento\Core\Exception(__('This email address is already assigned to another user.')); + throw new \Magento\Model\Exception(__('This email address is already assigned to another user.')); } $status = $this->_subscriberFactory->create()->subscribe($email); @@ -138,7 +138,7 @@ public function newAction() } else { $this->messageManager->addSuccess(__('Thank you for your subscription.')); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addException( $e, __('There was a problem with the subscription: %1', $e->getMessage()) @@ -190,7 +190,7 @@ public function unsubscribeAction() try { $this->_subscriberFactory->create()->load($id)->setCheckCode($code)->unsubscribe(); $this->messageManager->addSuccess(__('You have been unsubscribed.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addException($e, $e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong with the un-subscription.')); diff --git a/app/code/Magento/Newsletter/Model/Problem.php b/app/code/Magento/Newsletter/Model/Problem.php index d6f3d4cd470b9..afe21d0abf453 100644 --- a/app/code/Magento/Newsletter/Model/Problem.php +++ b/app/code/Magento/Newsletter/Model/Problem.php @@ -43,7 +43,7 @@ * @package Magento_Newsletter * @author Magento Core Team */ -class Problem extends \Magento\Core\Model\AbstractModel +class Problem extends \Magento\Model\AbstractModel { /** * Current Subscriber @@ -65,7 +65,7 @@ class Problem extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -73,7 +73,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Newsletter/Model/Resource/Grid/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Grid/Collection.php index 09f8820d6e5ad..8fd107795ebf2 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Grid/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Grid/Collection.php @@ -39,7 +39,7 @@ class Collection extends \Magento\Newsletter\Model\Resource\Problem\Collection /** * Adds queue info to grid * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection|\Magento\Newsletter\Model\Resource\Grid\Collection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection|\Magento\Newsletter\Model\Resource\Grid\Collection */ protected function _initSelect() { diff --git a/app/code/Magento/Newsletter/Model/Resource/Problem.php b/app/code/Magento/Newsletter/Model/Resource/Problem.php index b52a02d6a442b..4372fe715b93e 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Problem.php +++ b/app/code/Magento/Newsletter/Model/Resource/Problem.php @@ -32,7 +32,7 @@ * @package Magento_Newsletter * @author Magento Core Team */ -class Problem extends \Magento\Core\Model\Resource\Db\AbstractDb +class Problem extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table diff --git a/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php index 5f73363936453..8f2a95f631ab0 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php @@ -30,7 +30,7 @@ * * @SuppressWarnings(PHPMD.LongVariable) */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * True when subscribers info joined @@ -60,7 +60,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerCollectionFactory * @param null|\Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -69,7 +69,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerCollectionFactory, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_customerCollectionFactory = $customerCollectionFactory; diff --git a/app/code/Magento/Newsletter/Model/Resource/Queue.php b/app/code/Magento/Newsletter/Model/Resource/Queue.php index 2b4dda041da49..025d08b3f5f46 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Queue.php +++ b/app/code/Magento/Newsletter/Model/Resource/Queue.php @@ -26,7 +26,7 @@ namespace Magento\Newsletter\Model\Resource; use Magento\Newsletter\Model\Queue as ModelQueue; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; /** * Newsletter queue resource model @@ -35,7 +35,7 @@ * @package Magento_Newsletter * @author Magento Core Team */ -class Queue extends \Magento\Core\Model\Resource\Db\AbstractDb +class Queue extends \Magento\Model\Resource\Db\AbstractDb { /** * Subscriber collection @@ -74,16 +74,16 @@ protected function _construct() * @param ModelQueue $queue * @param array $subscriberIds * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addSubscribersToQueue(ModelQueue $queue, array $subscriberIds) { if (count($subscriberIds) == 0) { - throw new \Magento\Core\Exception(__('There are no subscribers selected.')); + throw new \Magento\Model\Exception(__('There are no subscribers selected.')); } if (!$queue->getId() && $queue->getQueueStatus() != Magento_Newsletter_Model_Queue::STATUS_NEVER) { - throw new \Magento\Core\Exception(__('You selected an invalid queue.')); + throw new \Magento\Model\Exception(__('You selected an invalid queue.')); } $adapter = $this->_getWriteAdapter(); diff --git a/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php index 4d8c89c6ccf15..879ff3bca7f36 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Newsletter * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * True when subscribers info joined @@ -62,7 +62,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Stdlib\DateTime\DateTime $date * @param null|\Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -71,7 +71,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Stdlib\DateTime\DateTime $date, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_date = $date; diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php index 78e89e550dcd7..3c82cf898f847 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php @@ -32,7 +32,7 @@ * @package Magento_Newsletter * @author Magento Core Team */ -class Subscriber extends \Magento\Core\Model\Resource\Db\AbstractDb +class Subscriber extends \Magento\Model\Resource\Db\AbstractDb { /** * DB read connection @@ -178,7 +178,7 @@ protected function _generateRandomCode() * @param \Magento\Newsletter\Model\Subscriber $subscriber * @param \Magento\Newsletter\Model\Queue $queue * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function received(\Magento\Newsletter\Model\Subscriber $subscriber, \Magento\Newsletter\Model\Queue $queue) { @@ -193,7 +193,7 @@ public function received(\Magento\Newsletter\Model\Subscriber $subscriber, \Mage $this->_write->commit(); } catch (\Exception $e) { $this->_write->rollBack(); - throw new \Magento\Core\Exception(__('We cannot mark as received subscriber.')); + throw new \Magento\Model\Exception(__('We cannot mark as received subscriber.')); } return $this; } diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php index 8e0647f0f2072..0788cf15b8f4e 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php @@ -34,7 +34,7 @@ * @package Magento_Newsletter * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Queue link table name @@ -85,7 +85,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param null|\Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -94,7 +94,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Customer\Model\CustomerFactory $customerFactory, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { // _customerFactory is used in parent class constructor $this->_customerFactory = $customerFactory; diff --git a/app/code/Magento/Newsletter/Model/Resource/Template.php b/app/code/Magento/Newsletter/Model/Resource/Template.php index 2c8d4d843acde..08eaf75852feb 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Template.php +++ b/app/code/Magento/Newsletter/Model/Resource/Template.php @@ -32,7 +32,7 @@ * @package Magento_Newsletter * @author Magento Core Team */ -class Template extends \Magento\Core\Model\Resource\Db\AbstractDb +class Template extends \Magento\Model\Resource\Db\AbstractDb { /** * Date @@ -153,14 +153,14 @@ public function checkCodeUsage(\Magento\Newsletter\Model\Template $template) /** * Perform actions before object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { if ($this->checkCodeUsage($object)) { - throw new \Magento\Core\Exception(__('Duplicate template code')); + throw new \Magento\Model\Exception(__('Duplicate template code')); } if (!$object->hasTemplateActual()) { diff --git a/app/code/Magento/Newsletter/Model/Resource/Template/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Template/Collection.php index 54415b79ced59..f6a6ed7723eb0 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Template/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Template/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Newsletter * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Define resource model and model diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index 9fadd61505885..d3b6d0b91f911 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -43,7 +43,7 @@ * @method int getSubscriberId() * @method Subscriber setSubscriberId(int $value) */ -class Subscriber extends \Magento\Core\Model\AbstractModel +class Subscriber extends \Magento\Model\AbstractModel { const STATUS_SUBSCRIBED = 1; @@ -113,13 +113,6 @@ class Subscriber extends \Magento\Core\Model\AbstractModel */ protected $_customerSession; - /** - * Translate - * - * @var \Magento\TranslateInterface - */ - protected $_translate; - /** * Store manager * @@ -140,8 +133,11 @@ class Subscriber extends \Magento\Core\Model\AbstractModel protected $_transportBuilder; /** - * Construct - * + * @var \Magento\Translate\Inline\StateInterface + */ + protected $inlineTranslation; + + /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Newsletter\Helper\Data $newsletterData @@ -149,9 +145,9 @@ class Subscriber extends \Magento\Core\Model\AbstractModel * @param \Magento\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\TranslateInterface $translate * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -163,20 +159,20 @@ public function __construct( \Magento\Mail\Template\TransportBuilder $transportBuilder, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\TranslateInterface $translate, \Magento\Customer\Model\Session $customerSession, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Translate\Inline\StateInterface $inlineTranslation, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->_newsletterData = $newsletterData; $this->_coreStoreConfig = $coreStoreConfig; $this->_transportBuilder = $transportBuilder; $this->_customerFactory = $customerFactory; $this->_storeManager = $storeManager; - $this->_translate = $translate; $this->_customerSession = $customerSession; + $this->inlineTranslation = $inlineTranslation; + parent::__construct($context, $registry, $resource, $resourceCollection, $data); } /** @@ -467,13 +463,13 @@ public function subscribe($email) /** * Unsubscribes loaded subscription * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ public function unsubscribe() { if ($this->hasCheckCode() && $this->getCode() != $this->getCheckCode()) { - throw new \Magento\Core\Exception(__('This is an invalid subscription confirmation code.')); + throw new \Magento\Model\Exception(__('This is an invalid subscription confirmation code.')); } $this->setSubscriberStatus(self::STATUS_UNSUBSCRIBED)->save(); @@ -625,8 +621,7 @@ public function sendConfirmationRequestEmail() return $this; } - $translate = $this->_translate->getTranslateInline(); - $this->_translate->setTranslateInline(false); + $this->inlineTranslation->suspend(); $this->_transportBuilder->setTemplateIdentifier( $this->_coreStoreConfig->getConfig(self::XML_PATH_CONFIRM_EMAIL_TEMPLATE) @@ -646,7 +641,8 @@ public function sendConfirmationRequestEmail() $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); - $this->_translate->setTranslateInline($translate); + $this->inlineTranslation->resume(); + return $this; } @@ -670,8 +666,7 @@ public function sendConfirmationSuccessEmail() return $this; } - $translate = $this->_translate->getTranslateInline(); - $this->_translate->setTranslateInline(false); + $this->inlineTranslation->suspend(); $this->_transportBuilder->setTemplateIdentifier( $this->_coreStoreConfig->getConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE) @@ -691,7 +686,8 @@ public function sendConfirmationSuccessEmail() $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); - $this->_translate->setTranslateInline($translate); + $this->inlineTranslation->resume(); + return $this; } @@ -714,8 +710,7 @@ public function sendUnsubscriptionEmail() return $this; } - $translate = $this->_translate->getTranslateInline(); - $this->_translate->setTranslateInline(false); + $this->inlineTranslation->suspend(); $this->_transportBuilder->setTemplateIdentifier( $this->_coreStoreConfig->getConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE) @@ -735,7 +730,8 @@ public function sendUnsubscriptionEmail() $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); - $this->_translate->setTranslateInline($translate); + $this->inlineTranslation->resume(); + return $this; } diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php index d539fe7c35550..d89072784581a 100644 --- a/app/code/Magento/Newsletter/Model/Template.php +++ b/app/code/Magento/Newsletter/Model/Template.php @@ -160,7 +160,7 @@ protected function _construct() * Validate Newsletter template * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validate() { @@ -188,7 +188,7 @@ public function validate() } } - throw new \Magento\Core\Exception(join("\n", $errorMessages)); + throw new \Magento\Model\Exception(join("\n", $errorMessages)); } } diff --git a/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php index 00a4105295d8d..0195e5200f22c 100644 --- a/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php @@ -23,7 +23,7 @@ */ namespace Magento\OfflineShipping\Model\Config\Backend; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; /** * Backend model for shipping table rates CSV importing @@ -43,7 +43,7 @@ class Tablerate extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\OfflineShipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -53,7 +53,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\OfflineShipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php index 9bdbdfb47e2d7..dcc235bacf7ec 100644 --- a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php @@ -31,7 +31,7 @@ */ namespace Magento\OfflineShipping\Model\Resource\Carrier; -class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb +class Tablerate extends \Magento\Model\Resource\Db\AbstractDb { /** * Import table rates website ID @@ -254,7 +254,7 @@ public function getRate(\Magento\Sales\Model\Quote\Address\RateRequest $request) * Upload table rate file and import data from it * * @param \Magento\Object $object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate * @todo: this method should be refactored as soon as updated design will be provided * @see https://wiki.corp.x.com/display/MCOMS/Magento+Filesystem+Decisions @@ -281,7 +281,7 @@ public function uploadAndImport(\Magento\Object $object) $headers = $stream->readCsv(); if ($headers === false || count($headers) < 5) { $stream->close(); - throw new \Magento\Core\Exception(__('Please correct Table Rates File Format.')); + throw new \Magento\Model\Exception(__('Please correct Table Rates File Format.')); } if ($object->getData('groups/tablerate/fields/condition_name/inherit') == '1') { @@ -327,15 +327,15 @@ public function uploadAndImport(\Magento\Object $object) } $this->_saveImportData($importData); $stream->close(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $adapter->rollback(); $stream->close(); - throw new \Magento\Core\Exception($e->getMessage()); + throw new \Magento\Model\Exception($e->getMessage()); } catch (\Exception $e) { $adapter->rollback(); $stream->close(); $this->_logger->logException($e); - throw new \Magento\Core\Exception(__('Something went wrong while importing table rates.')); + throw new \Magento\Model\Exception(__('Something went wrong while importing table rates.')); } $adapter->commit(); @@ -345,7 +345,7 @@ public function uploadAndImport(\Magento\Object $object) 'We couldn\'t import this file because of these errors: %1', implode(" \n", $this->_importErrors) ); - throw new \Magento\Core\Exception($error); + throw new \Magento\Model\Exception($error); } return $this; diff --git a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate/Collection.php b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate/Collection.php index d22f6d015f645..a854a890e3e72 100644 --- a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate/Collection.php +++ b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate/Collection.php @@ -28,7 +28,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Directory/country table name diff --git a/app/code/Magento/Ogone/Controller/Api.php b/app/code/Magento/Ogone/Controller/Api.php index 1f34dbf0b9d94..05695d9952b0e 100644 --- a/app/code/Magento/Ogone/Controller/Api.php +++ b/app/code/Magento/Ogone/Controller/Api.php @@ -45,18 +45,18 @@ class Api extends \Magento\App\Action\Action protected $_salesOrderFactory; /** - * @var \Magento\Core\Model\Resource\TransactionFactory + * @var \Magento\DB\TransactionFactory */ protected $_transactionFactory; /** * @param \Magento\App\Action\Context $context - * @param \Magento\Core\Model\Resource\TransactionFactory $transactionFactory + * @param \Magento\DB\TransactionFactory $transactionFactory * @param \Magento\Sales\Model\OrderFactory $salesOrderFactory */ public function __construct( \Magento\App\Action\Context $context, - \Magento\Core\Model\Resource\TransactionFactory $transactionFactory, + \Magento\DB\TransactionFactory $transactionFactory, \Magento\Sales\Model\OrderFactory $salesOrderFactory ) { parent::__construct($context); diff --git a/app/code/Magento/PageCache/Model/System/Config/Backend/Ttl.php b/app/code/Magento/PageCache/Model/System/Config/Backend/Ttl.php index daf7ed6a83e61..f4c1fadeafc10 100644 --- a/app/code/Magento/PageCache/Model/System/Config/Backend/Ttl.php +++ b/app/code/Magento/PageCache/Model/System/Config/Backend/Ttl.php @@ -35,14 +35,14 @@ class Ttl extends \Magento\Core\Model\Config\Value /** * Throw exception if Ttl data is invalid or empty * - * @return $this|\Magento\Core\Model\AbstractModel - * @throws \Magento\Core\Exception + * @return $this + * @throws \Magento\Model\Exception */ protected function _beforeSave() { $value = $this->getValue(); if ($value < 0 || !preg_match('/^[0-9]+$/', $value)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Ttl value "%1" is not valid. Please use only numbers equal or greater than zero.', $value) ); } diff --git a/app/code/Magento/PageCache/Model/System/Config/Backend/Varnish.php b/app/code/Magento/PageCache/Model/System/Config/Backend/Varnish.php index c42748f82ecd5..33574f73886e3 100644 --- a/app/code/Magento/PageCache/Model/System/Config/Backend/Varnish.php +++ b/app/code/Magento/PageCache/Model/System/Config/Backend/Varnish.php @@ -39,8 +39,8 @@ class Varnish extends \Magento\Core\Model\Config\Value /** * Set default data if empty fields have been left * - * @return $this|\Magento\Core\Model\AbstractModel - * @throws \Magento\Core\Exception + * @return $this|\Magento\Model\AbstractModel + * @throws \Magento\Model\Exception */ protected function _beforeSave() { @@ -69,7 +69,7 @@ protected function _getDefaultValues() /** * If fields are empty fill them with default data * - * @return $this|\Magento\Core\Model\AbstractModel + * @return $this|\Magento\Model\AbstractModel */ protected function _afterLoad() { diff --git a/app/code/Magento/PayPalRecurringPayment/Model/Api/Nvp.php b/app/code/Magento/PayPalRecurringPayment/Model/Api/Nvp.php index 2c2c438a8cca0..89eb59b78e93d 100644 --- a/app/code/Magento/PayPalRecurringPayment/Model/Api/Nvp.php +++ b/app/code/Magento/PayPalRecurringPayment/Model/Api/Nvp.php @@ -125,7 +125,7 @@ public function __construct( * SetExpressCheckout call * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout * TODO: put together style and giropay settings */ @@ -156,7 +156,7 @@ public function callSetExpressCheckout() foreach ($payments as $payment) { $payment->setMethodCode(\Magento\Paypal\Model\Config::METHOD_WPP_EXPRESS); if (!$payment->isValid()) { - throw new \Magento\Core\Exception($payment->getValidationErrors()); + throw new \Magento\Model\Exception($payment->getValidationErrors()); } $request["L_BILLINGTYPE{$i}"] = 'RecurringPayments'; $request["L_BILLINGAGREEMENTDESCRIPTION{$i}"] = $payment->getScheduleDescription(); @@ -223,7 +223,7 @@ public function callCreateRecurringPayment() * ManageRecurringPaymentStatus call * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function callManageRecurringPaymentStatus() { @@ -233,7 +233,7 @@ public function callManageRecurringPaymentStatus() } try { $this->call('ManageRecurringPaymentsProfileStatus', $request); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if (in_array( 11556, $this->_callErrors @@ -245,7 +245,7 @@ public function callManageRecurringPaymentStatus() $this->_callErrors ) && 'Reactivate' === $request['ACTION'] ) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We can\'t change the status because the current status doesn\'t match the real status.') ); } diff --git a/app/code/Magento/PayPalRecurringPayment/Model/Express.php b/app/code/Magento/PayPalRecurringPayment/Model/Express.php index 21eab4d0d021f..319f97d30791f 100644 --- a/app/code/Magento/PayPalRecurringPayment/Model/Express.php +++ b/app/code/Magento/PayPalRecurringPayment/Model/Express.php @@ -59,7 +59,7 @@ public function getPaymentMethodCode() * * @param RecurringPayment $payment * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validate(RecurringPayment $payment) { @@ -81,7 +81,7 @@ public function validate(RecurringPayment $payment) $errors[] = __('The schedule description is too long.'); } if ($errors) { - throw new \Magento\Core\Exception(implode(' ', $errors)); + throw new \Magento\Model\Exception(implode(' ', $errors)); } } diff --git a/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php b/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php index aa0648f4c1589..b032a058c3ab3 100644 --- a/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php +++ b/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php @@ -120,7 +120,7 @@ protected function _getRecurringPayment() * Process notification from recurring payments * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @throws Exception */ protected function _processRecurringPayment() @@ -173,7 +173,7 @@ protected function _processRecurringPayment() $message = __('You notified customer about invoice #%1.', $invoice->getIncrementId()); $order->sendNewOrderEmail()->addStatusHistoryComment($message)->setIsCustomerNotified(true)->save(); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $comment = $this->_createIpnComment(__('Note: %1', $e->getMessage()), true); //TODO: add to payment comments //$comment->save(); diff --git a/app/code/Magento/PayPalRecurringPayment/etc/module.xml b/app/code/Magento/PayPalRecurringPayment/etc/module.xml index 8c212ec8acfe5..d95906ac37aff 100644 --- a/app/code/Magento/PayPalRecurringPayment/etc/module.xml +++ b/app/code/Magento/PayPalRecurringPayment/etc/module.xml @@ -26,7 +26,6 @@ - diff --git a/app/code/Magento/Payment/Block/Form.php b/app/code/Magento/Payment/Block/Form.php index ef032ff6a7664..5e5ec4f5145f5 100644 --- a/app/code/Magento/Payment/Block/Form.php +++ b/app/code/Magento/Payment/Block/Form.php @@ -34,14 +34,14 @@ class Form extends \Magento\View\Element\Template * Retrieve payment method model * * @return \Magento\Payment\Model\MethodInterface - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getMethod() { $method = $this->getData('method'); if (!$method instanceof \Magento\Payment\Model\MethodInterface) { - throw new \Magento\Core\Exception(__('We cannot retrieve the payment method model object.')); + throw new \Magento\Model\Exception(__('We cannot retrieve the payment method model object.')); } return $method; } diff --git a/app/code/Magento/Payment/Block/Info.php b/app/code/Magento/Payment/Block/Info.php index ac47b24540286..07f8dfec54d55 100644 --- a/app/code/Magento/Payment/Block/Info.php +++ b/app/code/Magento/Payment/Block/Info.php @@ -46,13 +46,13 @@ class Info extends \Magento\View\Element\Template * Retrieve info model * * @return \Magento\Payment\Model\Info - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getInfo() { $info = $this->getData('info'); if (!$info instanceof \Magento\Payment\Model\Info) { - throw new \Magento\Core\Exception(__('We cannot retrieve the payment info model object.')); + throw new \Magento\Model\Exception(__('We cannot retrieve the payment info model object.')); } return $info; } diff --git a/app/code/Magento/Payment/Model/Checks/SpecificationFactory.php b/app/code/Magento/Payment/Model/Checks/SpecificationFactory.php index a429864e17eba..58511c276b43a 100644 --- a/app/code/Magento/Payment/Model/Checks/SpecificationFactory.php +++ b/app/code/Magento/Payment/Model/Checks/SpecificationFactory.php @@ -55,7 +55,7 @@ public function __construct(\Magento\ObjectManager $objectManager, array $mappin * * @param array $data * @return SpecificationInterface - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function create($data) { diff --git a/app/code/Magento/Payment/Model/Info.php b/app/code/Magento/Payment/Model/Info.php index c6d42e88bd02d..260c3f183bfdf 100644 --- a/app/code/Magento/Payment/Model/Info.php +++ b/app/code/Magento/Payment/Model/Info.php @@ -28,7 +28,7 @@ /** * Payment information model */ -class Info extends \Magento\Core\Model\AbstractModel +class Info extends \Magento\Model\AbstractModel { /** * Additional information container @@ -54,7 +54,7 @@ class Info extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Encryption\EncryptorInterface $encryptor - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -63,7 +63,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Payment\Helper\Data $paymentData, \Magento\Encryption\EncryptorInterface $encryptor, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -98,7 +98,7 @@ public function getData($key = '', $index = null) * Retrieve payment method model object * * @return \Magento\Payment\Model\MethodInterface - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getMethodInstance() { @@ -111,7 +111,7 @@ public function getMethodInstance() return $instance; } } - throw new \Magento\Core\Exception(__('The payment method you requested is not available.')); + throw new \Magento\Model\Exception(__('The payment method you requested is not available.')); } return $this->_getData('method_instance'); @@ -153,12 +153,12 @@ public function decrypt($data) * @param string|array $key * @param mixed $value * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setAdditionalInformation($key, $value = null) { if (is_object($value)) { - throw new \Magento\Core\Exception(__('The payment disallows storing objects.')); + throw new \Magento\Model\Exception(__('The payment disallows storing objects.')); } $this->_initAdditionalInformation(); if (is_array($key) && is_null($value)) { diff --git a/app/code/Magento/Payment/Model/Info/Exception.php b/app/code/Magento/Payment/Model/Info/Exception.php index ff92ffae48a73..b127a3ca54cd8 100644 --- a/app/code/Magento/Payment/Model/Info/Exception.php +++ b/app/code/Magento/Payment/Model/Info/Exception.php @@ -34,6 +34,6 @@ * @package Magento_Payment * @author Magento Core Team */ -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { } diff --git a/app/code/Magento/Payment/Model/Method/AbstractMethod.php b/app/code/Magento/Payment/Model/Method/AbstractMethod.php index 9e660f6c569dc..59eef7598d3a9 100644 --- a/app/code/Magento/Payment/Model/Method/AbstractMethod.php +++ b/app/code/Magento/Payment/Model/Method/AbstractMethod.php @@ -414,12 +414,12 @@ public function canUseForCurrency($currencyCode) * Retrieve payment method code * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getCode() { if (empty($this->_code)) { - throw new \Magento\Core\Exception(__('We cannot retrieve the payment method code.')); + throw new \Magento\Model\Exception(__('We cannot retrieve the payment method code.')); } return $this->_code; } @@ -448,13 +448,13 @@ public function getInfoBlockType() * Retrieve payment iformation model object * * @return \Magento\Payment\Model\Info - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getInfoInstance() { $instance = $this->getData('info_instance'); if (!$instance instanceof \Magento\Payment\Model\Info) { - throw new \Magento\Core\Exception(__('We cannot retrieve the payment information object instance.')); + throw new \Magento\Model\Exception(__('We cannot retrieve the payment information object instance.')); } return $instance; } @@ -463,7 +463,7 @@ public function getInfoInstance() * Validate payment method information object * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validate() { @@ -477,7 +477,7 @@ public function validate() $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId(); } if (!$this->canUseForCountry($billingCountry)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('You can\'t use the payment type you selected to make payments to the billing country.') ); } @@ -491,12 +491,12 @@ public function validate() * @param float $amount * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function order(\Magento\Object $payment, $amount) { if (!$this->canOrder()) { - throw new \Magento\Core\Exception(__('The order action is not available.')); + throw new \Magento\Model\Exception(__('The order action is not available.')); } return $this; } @@ -508,12 +508,12 @@ public function order(\Magento\Object $payment, $amount) * @param float $amount * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function authorize(\Magento\Object $payment, $amount) { if (!$this->canAuthorize()) { - throw new \Magento\Core\Exception(__('The authorize action is not available.')); + throw new \Magento\Model\Exception(__('The authorize action is not available.')); } return $this; } @@ -525,12 +525,12 @@ public function authorize(\Magento\Object $payment, $amount) * @param float $amount * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function capture(\Magento\Object $payment, $amount) { if (!$this->canCapture()) { - throw new \Magento\Core\Exception(__('The capture action is not available.')); + throw new \Magento\Model\Exception(__('The capture action is not available.')); } return $this; @@ -572,12 +572,12 @@ public function processBeforeRefund($invoice, $payment) * @param \Magento\Object $payment * @param float $amount * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function refund(\Magento\Object $payment, $amount) { if (!$this->canRefund()) { - throw new \Magento\Core\Exception(__('The refund action is not available.')); + throw new \Magento\Model\Exception(__('The refund action is not available.')); } return $this; } @@ -611,12 +611,12 @@ public function cancel(\Magento\Object $payment) * * @param \Magento\Object $payment * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function void(\Magento\Object $payment) { if (!$this->canVoid($payment)) { - throw new \Magento\Core\Exception(__('Void action is not available.')); + throw new \Magento\Model\Exception(__('Void action is not available.')); } return $this; } @@ -637,12 +637,12 @@ public function canReviewPayment(\Magento\Payment\Model\Info $payment) * * @param \Magento\Payment\Model\Info $payment * @return false - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function acceptPayment(\Magento\Payment\Model\Info $payment) { if (!$this->canReviewPayment($payment)) { - throw new \Magento\Core\Exception(__('The payment review action is unavailable.')); + throw new \Magento\Model\Exception(__('The payment review action is unavailable.')); } return false; } @@ -652,12 +652,12 @@ public function acceptPayment(\Magento\Payment\Model\Info $payment) * * @param \Magento\Payment\Model\Info $payment * @return false - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function denyPayment(\Magento\Payment\Model\Info $payment) { if (!$this->canReviewPayment($payment)) { - throw new \Magento\Core\Exception(__('The payment review action is unavailable.')); + throw new \Magento\Model\Exception(__('The payment review action is unavailable.')); } return false; } diff --git a/app/code/Magento/Payment/Model/Method/Cc.php b/app/code/Magento/Payment/Model/Method/Cc.php index dc7077efb4e5c..4304f2ef94b07 100644 --- a/app/code/Magento/Payment/Model/Method/Cc.php +++ b/app/code/Magento/Payment/Model/Method/Cc.php @@ -151,7 +151,7 @@ public function prepareSave() * Validate payment method information object * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ @@ -245,7 +245,7 @@ public function validate() } if ($errorMsg) { - throw new \Magento\Core\Exception($errorMsg); + throw new \Magento\Model\Exception($errorMsg); } //This must be after all validation conditions diff --git a/app/code/Magento/Payment/Model/Method/Factory.php b/app/code/Magento/Payment/Model/Method/Factory.php index 1134b9ea9d534..a8c90fa1012a5 100644 --- a/app/code/Magento/Payment/Model/Method/Factory.php +++ b/app/code/Magento/Payment/Model/Method/Factory.php @@ -51,13 +51,13 @@ public function __construct(\Magento\ObjectManager $objectManager) * @param string $className * @param array $data * @return \Magento\Payment\Model\MethodInterface - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function create($className, $data = array()) { $method = $this->_objectManager->create($className, $data); if (!$method instanceof \Magento\Payment\Model\MethodInterface) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( sprintf("%s class doesn't implement \Magento\Payment\Model\MethodInterface", $className) ); } diff --git a/app/code/Magento/Paypal/Block/Iframe.php b/app/code/Magento/Paypal/Block/Iframe.php index 22751df758d2e..d4852ca0fd774 100644 --- a/app/code/Magento/Paypal/Block/Iframe.php +++ b/app/code/Magento/Paypal/Block/Iframe.php @@ -127,7 +127,7 @@ protected function _construct() * Get current block instance * * @return \Magento\Payment\Block\Form - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getBlock() { @@ -140,7 +140,7 @@ protected function _getBlock() ) . '\\Iframe' ); if (!$this->_block instanceof \Magento\Paypal\Block\Iframe) { - throw new \Magento\Core\Exception('Invalid block type'); + throw new \Magento\Model\Exception('Invalid block type'); } } diff --git a/app/code/Magento/Paypal/Block/Payflow/Advanced/Iframe.php b/app/code/Magento/Paypal/Block/Payflow/Advanced/Iframe.php index 8e40c6a6c7da0..0a26728043432 100644 --- a/app/code/Magento/Paypal/Block/Payflow/Advanced/Iframe.php +++ b/app/code/Magento/Paypal/Block/Payflow/Advanced/Iframe.php @@ -34,6 +34,26 @@ */ class Iframe extends \Magento\Paypal\Block\Payflow\Link\Iframe { + /** + * @param \Magento\View\Element\Template\Context $context + * @param \Magento\Sales\Model\OrderFactory $orderFactory + * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Paypal\Helper\Hss $hssHelper + * @param \Magento\Payment\Helper\Data $paymentData + * @param array $data + */ + public function __construct( + \Magento\View\Element\Template\Context $context, + \Magento\Sales\Model\OrderFactory $orderFactory, + \Magento\Checkout\Model\Session $checkoutSession, + \Magento\Paypal\Helper\Hss $hssHelper, + \Magento\Payment\Helper\Data $paymentData, + array $data = array() + ) { + parent::__construct($context, $orderFactory, $checkoutSession, $hssHelper, $paymentData, $data); + $this->_isScopePrivate = false; + } + /** * Set payment method code * diff --git a/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php b/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php index 971cd2c437d32..28cc38ec82723 100644 --- a/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php +++ b/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php @@ -132,7 +132,7 @@ public function cancelAction() $this->messageManager->addSuccess(__('You canceled the billing agreement.')); $this->_redirect('paypal/*/view', array('_current' => true)); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We could not cancel the billing agreement.')); @@ -158,7 +158,7 @@ public function deleteAction() $this->messageManager->addSuccess(__('You deleted the billing agreement.')); $this->_redirect('paypal/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We could not delete the billing agreement.')); diff --git a/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports.php b/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports.php index dd97af9373767..d4a1a96f74251 100644 --- a/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports.php +++ b/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports.php @@ -124,7 +124,7 @@ public function detailsAction() * Forced fetch reports action * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function fetchAction() { @@ -133,7 +133,7 @@ public function fetchAction() /* @var $reports \Magento\Paypal\Model\Report\Settlement */ $credentials = $reports->getSftpCredentials(); if (empty($credentials)) { - throw new \Magento\Core\Exception(__('We found nothing to fetch because of an empty configuration.')); + throw new \Magento\Model\Exception(__('We found nothing to fetch because of an empty configuration.')); } foreach ($credentials as $config) { try { @@ -155,7 +155,7 @@ public function fetchAction() $this->_logger->logException($e); } } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->_logger->logException($e); diff --git a/app/code/Magento/Paypal/Controller/Billing/Agreement.php b/app/code/Magento/Paypal/Controller/Billing/Agreement.php index 9e07594cb1c27..10fbd747956c7 100644 --- a/app/code/Magento/Paypal/Controller/Billing/Agreement.php +++ b/app/code/Magento/Paypal/Controller/Billing/Agreement.php @@ -140,7 +140,7 @@ public function startWizardAction() ); return $this->getResponse()->setRedirect($agreement->initToken()); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); @@ -176,7 +176,7 @@ public function returnWizardAction() ); $this->_redirect('*/*/view', array('agreement' => $agreement->getId())); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); @@ -214,7 +214,7 @@ public function cancelAction() $this->messageManager->addNotice( __('The billing agreement "%1" has been canceled.', $agreement->getReferenceId()) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); diff --git a/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php b/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php index 7e980e813e59c..5faab9ef7fdc6 100644 --- a/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php +++ b/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php @@ -197,7 +197,7 @@ public function startAction() $this->getResponse()->setRedirect($url); return; } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t start Express Checkout.')); @@ -249,7 +249,7 @@ public function cancelAction() } else { $this->messageManager->addSuccess(__('Express Checkout has been canceled.')); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Unable to cancel Express Checkout')); @@ -271,7 +271,7 @@ public function returnAction() $this->_checkout->returnFromPaypal($this->_initToken()); $this->_redirect('*/*/review'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t process Express Checkout approval.')); @@ -300,7 +300,7 @@ public function reviewAction() } $this->_view->renderLayout(); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t initialize Express Checkout review.')); @@ -318,7 +318,7 @@ public function editAction() { try { $this->getResponse()->setRedirect($this->_config->getExpressCheckoutEditUrl($this->_initToken())); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect('*/*/review'); } @@ -342,7 +342,7 @@ public function saveShippingMethodAction() ); return; } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t update shipping method.')); @@ -379,7 +379,7 @@ public function updateShippingMethodsAction() )->toHtml() ); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t update Order data.')); @@ -408,7 +408,7 @@ public function updateOrderAction() ); return; } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t update Order data.')); @@ -429,7 +429,7 @@ public function updateOrderAction() * Submit the order * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function placeOrderAction() { @@ -440,7 +440,7 @@ public function placeOrderAction() if ($requiredAgreements) { $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array())); if (array_diff($requiredAgreements, $postedAgreements)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Please agree to all the terms and conditions before placing the order.') ); } @@ -481,7 +481,7 @@ public function placeOrderAction() // no need in token anymore $this->_redirect('checkout/onepage/success'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t place the order.')); @@ -494,14 +494,14 @@ public function placeOrderAction() * Instantiate quote and checkout * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ private function _initCheckout() { $quote = $this->_getQuote(); if (!$quote->hasItems() || $quote->getHasError()) { $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden'); - throw new \Magento\Core\Exception(__('We can\'t initialize Express Checkout.')); + throw new \Magento\Model\Exception(__('We can\'t initialize Express Checkout.')); } if (!isset($this->_checkoutTypes[$this->_checkoutType])) { $parameters = array('params' => array('quote' => $quote, 'config' => $this->_config)); @@ -519,7 +519,7 @@ private function _initCheckout() * * @param string|null $setToken * @return \Magento\Paypal\Controller\Express|string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _initToken($setToken = null) { @@ -527,7 +527,7 @@ protected function _initToken($setToken = null) if (false === $setToken) { // security measure for avoid unsetting token twice if (!$this->_getSession()->getExpressCheckoutToken()) { - throw new \Magento\Core\Exception(__('PayPal Express Checkout Token does not exist.')); + throw new \Magento\Model\Exception(__('PayPal Express Checkout Token does not exist.')); } $this->_getSession()->unsExpressCheckoutToken(); } else { @@ -538,7 +538,7 @@ protected function _initToken($setToken = null) $setToken = $this->getRequest()->getParam('token'); if ($setToken) { if ($setToken !== $this->_getSession()->getExpressCheckoutToken()) { - throw new \Magento\Core\Exception(__('A wrong PayPal Express Checkout Token is specified.')); + throw new \Magento\Model\Exception(__('A wrong PayPal Express Checkout Token is specified.')); } } else { $setToken = $this->_getSession()->getExpressCheckoutToken(); diff --git a/app/code/Magento/Paypal/Exception.php b/app/code/Magento/Paypal/Exception.php index deb9c148aff89..026ecf539ba5d 100644 --- a/app/code/Magento/Paypal/Exception.php +++ b/app/code/Magento/Paypal/Exception.php @@ -25,6 +25,6 @@ */ namespace Magento\Paypal; -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { } diff --git a/app/code/Magento/Paypal/Model/Api/Nvp.php b/app/code/Magento/Paypal/Model/Api/Nvp.php index 1befeea7187c2..80287448be65f 100644 --- a/app/code/Magento/Paypal/Model/Api/Nvp.php +++ b/app/code/Magento/Paypal/Model/Api/Nvp.php @@ -1080,7 +1080,7 @@ public function callUpdateBillingAgreement() $request = $this->_exportToRequest($this->_updateBillingAgreementRequest); try { $response = $this->call('BillAgreementUpdate', $request); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if (in_array(10201, $this->_callErrors)) { $this->setIsBillingAgreementAlreadyCancelled(true); } @@ -1159,7 +1159,7 @@ protected function _postProcessResponse($response) * @param string $methodName * @param array $request * @return array - * @throws \Magento\Core\Exception|\Exception + * @throws \Magento\Model\Exception|\Exception */ public function call($methodName, array $request) { @@ -1216,7 +1216,7 @@ public function call($methodName, array $request) ); $http->close(); - throw new \Magento\Core\Exception(__('We can\'t contact the PayPal gateway.')); + throw new \Magento\Model\Exception(__('We can\'t contact the PayPal gateway.')); } // cUrl resource must be closed after checking it for errors @@ -1224,7 +1224,7 @@ public function call($methodName, array $request) if (!$this->_validateResponse($methodName, $response)) { $this->_logger->logException(new \Exception(__("PayPal response hasn't required fields."))); - throw new \Magento\Core\Exception(__('Something went wrong while processing your order.')); + throw new \Magento\Model\Exception(__('Something went wrong while processing your order.')); } $this->_callErrors = array(); @@ -1255,7 +1255,7 @@ public function setRawResponseNeeded($flag) * * @param array $response * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _handleCallErrors($response) { @@ -1283,7 +1283,7 @@ protected function _handleCallErrors($response) } if ($errors) { $errors = implode(' ', $errors); - $e = new \Magento\Core\Exception( + $e = new \Magento\Model\Exception( sprintf( 'PayPal NVP gateway errors: %s Correlation ID: %s. Version: %s.', $errors, diff --git a/app/code/Magento/Paypal/Model/Api/PayflowNvp.php b/app/code/Magento/Paypal/Model/Api/PayflowNvp.php index f94c4486e88d5..7114a088aba1b 100644 --- a/app/code/Magento/Paypal/Model/Api/PayflowNvp.php +++ b/app/code/Magento/Paypal/Model/Api/PayflowNvp.php @@ -632,7 +632,7 @@ protected function _isCallSuccessful($response) * * @param array $response * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _handleCallErrors($response) { @@ -640,7 +640,7 @@ protected function _handleCallErrors($response) $message = $response['RESPMSG']; $e = new \Exception(sprintf('PayPal gateway errors: %s.', $message)); $this->_logger->logException($e); - throw new \Magento\Core\Exception(__('PayPal gateway rejected the request. %1', $message)); + throw new \Magento\Model\Exception(__('PayPal gateway rejected the request. %1', $message)); } } diff --git a/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php b/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php index 86c010bbd22af..02c42adf3cdb8 100644 --- a/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php +++ b/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php @@ -26,7 +26,7 @@ /** * Billing Agreement abstaract class */ -abstract class AbstractAgreement extends \Magento\Core\Model\AbstractModel +abstract class AbstractAgreement extends \Magento\Model\AbstractModel { /** * Payment method instance @@ -81,7 +81,7 @@ abstract public function cancel(); * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -89,7 +89,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Payment\Helper\Data $paymentData, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -133,8 +133,8 @@ public function isValid() /** * Before save, it's overridden just to make data validation on before save event * - * @throws \Magento\Core\Exception - * @return \Magento\Core\Model\AbstractModel + * @throws \Magento\Model\Exception + * @return \Magento\Model\AbstractModel */ protected function _beforeSave() { @@ -142,6 +142,6 @@ protected function _beforeSave() return parent::_beforeSave(); } array_unshift($this->_errors, __('Unable to save Billing Agreement:')); - throw new \Magento\Core\Exception(implode(' ', $this->_errors)); + throw new \Magento\Model\Exception(implode(' ', $this->_errors)); } } diff --git a/app/code/Magento/Paypal/Model/Billing/Agreement.php b/app/code/Magento/Paypal/Model/Billing/Agreement.php index 52145362df8dc..1685646f7a866 100644 --- a/app/code/Magento/Paypal/Model/Billing/Agreement.php +++ b/app/code/Magento/Paypal/Model/Billing/Agreement.php @@ -76,7 +76,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\AbstractAgreement * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementFactory * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -86,7 +86,7 @@ public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementFactory, \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -108,7 +108,7 @@ protected function _construct() /** * Set created_at parameter * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _beforeSave() { @@ -124,7 +124,7 @@ protected function _beforeSave() /** * Save agreement order relations * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _afterSave() { diff --git a/app/code/Magento/Paypal/Model/Cert.php b/app/code/Magento/Paypal/Model/Cert.php index ab4edd8acc5a3..16caa27201204 100644 --- a/app/code/Magento/Paypal/Model/Cert.php +++ b/app/code/Magento/Paypal/Model/Cert.php @@ -30,7 +30,7 @@ /** * PayPal specific model for certificate based authentication */ -class Cert extends \Magento\Core\Model\AbstractModel +class Cert extends \Magento\Model\AbstractModel { /** * Certificate base path @@ -52,7 +52,7 @@ class Cert extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\App\Filesystem $filesystem * @param \Magento\Encryption\EncryptorInterface $encryptor - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -61,7 +61,7 @@ public function __construct( \Magento\Registry $registry, \Magento\App\Filesystem $filesystem, \Magento\Encryption\EncryptorInterface $encryptor, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -98,12 +98,12 @@ public function loadByWebsite($websiteId, $strictLoad = true) * Get path to PayPal certificate file, if file does not exist try to create it * * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getCertPath() { if (!$this->getContent()) { - throw new \Magento\Core\Exception(__('The PayPal certificate does not exist.')); + throw new \Magento\Model\Exception(__('The PayPal certificate does not exist.')); } $certFileName = sprintf('cert_%s_%s.pem', $this->getWebsiteId(), strtotime($this->getUpdatedAt())); diff --git a/app/code/Magento/Paypal/Model/Direct.php b/app/code/Magento/Paypal/Model/Direct.php index 88b8c491a73e6..ddb2d1b082e50 100644 --- a/app/code/Magento/Paypal/Model/Direct.php +++ b/app/code/Magento/Paypal/Model/Direct.php @@ -503,7 +503,7 @@ protected function _placeOrder(Payment $payment, $amount) try { $api->callGetTransactionDetails(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { // if we receive errors, but DoDirectPayment response is Success, then set Pending status for transaction $payment->setIsTransactionPending(true); } diff --git a/app/code/Magento/Paypal/Model/Express.php b/app/code/Magento/Paypal/Model/Express.php index afaea5b11cba3..6c0b2c3bfdfe9 100644 --- a/app/code/Magento/Paypal/Model/Express.php +++ b/app/code/Magento/Paypal/Model/Express.php @@ -403,7 +403,7 @@ public function void(\Magento\Object $payment) * * @param \Magento\Object|Payment $payment * @param float $amount - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ public function capture(\Magento\Object $payment, $amount) @@ -438,7 +438,7 @@ public function capture(\Magento\Object $payment, $amount) if ($authorizationTransaction->getIsClosed() || $voided) { if ($payment->getAdditionalInformation($this->_authorizationCountKey) > $maxAuthorizationNumber - 1) { - throw new \Magento\Core\Exception(__('The maximum number of child authorizations is reached.')); + throw new \Magento\Model\Exception(__('The maximum number of child authorizations is reached.')); } $api = $this->_callDoAuthorize($amount, $payment, $authorizationTransaction->getParentTxnId()); diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index c97eefb1a2851..3fdb92932afd4 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -414,14 +414,14 @@ public function setCustomerWithAddressChange($customer, $billingAddress = null, * @param string $returnUrl * @param string $cancelUrl * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function start($returnUrl, $cancelUrl) { $this->_quote->collectTotals(); if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'PayPal can\'t process orders with a zero balance due. ' . 'To finish your purchase, please go through the standard checkout process.' @@ -593,13 +593,13 @@ public function returnFromPaypal($token) * * @param string|null $token * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function prepareOrderReview($token = null) { $payment = $this->_quote->getPayment(); if (!$payment || !$payment->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID)) { - throw new \Magento\Core\Exception(__('Payer is not identified.')); + throw new \Magento\Model\Exception(__('Payer is not identified.')); } $this->_quote->setMayEditShippingAddress( 1 != $this->_quote->getPayment()->getAdditionalInformation( diff --git a/app/code/Magento/Paypal/Model/Hostedpro.php b/app/code/Magento/Paypal/Model/Hostedpro.php index a396242047040..a5d536224ca45 100644 --- a/app/code/Magento/Paypal/Model/Hostedpro.php +++ b/app/code/Magento/Paypal/Model/Hostedpro.php @@ -209,7 +209,7 @@ public function initialize($paymentAction, $stateObject) * * @param \Magento\Payment\Model\Info $payment * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _setPaymentFormUrl(\Magento\Payment\Model\Info $payment) { @@ -218,7 +218,7 @@ protected function _setPaymentFormUrl(\Magento\Payment\Model\Info $payment) if ($response) { $payment->setAdditionalInformation('secure_form_url', $response); } else { - throw new \Magento\Core\Exception('Cannot get secure form URL from PayPal'); + throw new \Magento\Model\Exception('Cannot get secure form URL from PayPal'); } } diff --git a/app/code/Magento/Paypal/Model/Ipn.php b/app/code/Magento/Paypal/Model/Ipn.php index 90b79b88aecd3..3f97ead9a72f2 100644 --- a/app/code/Magento/Paypal/Model/Ipn.php +++ b/app/code/Magento/Paypal/Model/Ipn.php @@ -143,7 +143,7 @@ protected function _getOrder() * Admin will be notified on errors. * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _processOrder() { @@ -165,7 +165,7 @@ protected function _processOrder() $this->_registerTransaction(); break; } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $comment = $this->_createIpnComment(__('Note: %1', $e->getMessage()), true); $comment->save(); throw $e; @@ -218,7 +218,7 @@ protected function _registerAdjustment() * Process regular IPN notifications * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @throws Exception */ protected function _registerTransaction() @@ -264,7 +264,7 @@ protected function _registerTransaction() default: throw new Exception("Cannot handle payment status '{$paymentStatus}'."); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $comment = $this->_createIpnComment(__('Note: %1', $e->getMessage()), true); $comment->save(); throw $e; diff --git a/app/code/Magento/Paypal/Model/Method/Agreement.php b/app/code/Magento/Paypal/Model/Method/Agreement.php index c03e6e103c490..c7ee0a0f13276 100644 --- a/app/code/Magento/Paypal/Model/Method/Agreement.php +++ b/app/code/Magento/Paypal/Model/Method/Agreement.php @@ -257,7 +257,7 @@ public function placeBillingAgreement(\Magento\Paypal\Model\Billing\AbstractAgre * * @param \Magento\Paypal\Model\Billing\AbstractAgreement $agreement * @return $this - * @throws \Exception|\Magento\Core\Exception + * @throws \Exception|\Magento\Model\Exception */ public function updateBillingAgreementStatus(\Magento\Paypal\Model\Billing\AbstractAgreement $agreement) { @@ -269,7 +269,7 @@ public function updateBillingAgreementStatus(\Magento\Paypal\Model\Billing\Abstr ); try { $api->callUpdateBillingAgreement(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { // when BA was already canceled, just pretend that the operation succeeded if (!(\Magento\Paypal\Model\Billing\Agreement::STATUS_CANCELED == $targetStatus && $api->getIsBillingAgreementAlreadyCancelled()) diff --git a/app/code/Magento/Paypal/Model/Payflow/Pro.php b/app/code/Magento/Paypal/Model/Payflow/Pro.php index 79c6b25ee7f4c..de930d102b723 100644 --- a/app/code/Magento/Paypal/Model/Payflow/Pro.php +++ b/app/code/Magento/Paypal/Model/Payflow/Pro.php @@ -120,12 +120,12 @@ protected function _importCaptureResultToPayment($api, $payment) * * @param \Magento\Payment\Model\Info $payment * @param string $transactionId - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return void */ public function fetchTransactionInfo(\Magento\Payment\Model\Info $payment, $transactionId) { - throw new \Magento\Core\Exception(__('Fetch transaction details method does not exists in Payflow')); + throw new \Magento\Model\Exception(__('Fetch transaction details method does not exists in Payflow')); } /** diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index dfd71ca7c2f7f..d797e3b7d72d7 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -324,7 +324,7 @@ public function setResponseData(array $postData) * * @param array $responseData * @return void - * @throws \Magento\Core\Exception In case of validation error or order creation error + * @throws \Magento\Model\Exception In case of validation error or order creation error */ public function process($responseData) { @@ -343,7 +343,7 @@ public function process($responseData) * * @param \Magento\Sales\Model\Order $order * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _processOrder(\Magento\Sales\Model\Order $order) { @@ -392,7 +392,7 @@ protected function _processOrder(\Magento\Sales\Model\Order $order) } $this->_quoteFactory->create()->load($order->getQuoteId())->setIsActive(false)->save(); } catch (\Exception $e) { - throw new \Magento\Core\Exception(__('We cannot send the new order email.')); + throw new \Magento\Model\Exception(__('We cannot send the new order email.')); } } @@ -416,7 +416,7 @@ protected function _getFraudMessage() * Check response from Payflow gateway. * * @return false|\Magento\Sales\Model\Order in case of validation passed - * @throws \Magento\Core\Exception In other cases + * @throws \Magento\Model\Exception In other cases */ protected function _getOrderFromResponse() { @@ -437,7 +437,7 @@ protected function _getOrderFromResponse() if ($order->getState() != \Magento\Sales\Model\Order::STATE_CANCELED) { $order->registerCancellation($response->getRespmsg())->save(); } - throw new \Magento\Core\Exception($response->getRespmsg()); + throw new \Magento\Model\Exception($response->getRespmsg()); } $amountCompared = $response->getAmt() == $order->getPayment()->getBaseAmountAuthorized() ? true : false; @@ -445,12 +445,12 @@ protected function _getOrderFromResponse() $order->getState() != \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT || !$amountCompared ) { - throw new \Magento\Core\Exception($this->_formatStr(self::RESPONSE_ERROR_MSG, 'Order')); + throw new \Magento\Model\Exception($this->_formatStr(self::RESPONSE_ERROR_MSG, 'Order')); } $fetchData = $this->fetchTransactionInfo($order->getPayment(), $response->getPnref()); if (!isset($fetchData['custref']) || $fetchData['custref'] != $order->getIncrementId()) { - throw new \Magento\Core\Exception($this->_formatStr(self::RESPONSE_ERROR_MSG, 'Transaction')); + throw new \Magento\Model\Exception($this->_formatStr(self::RESPONSE_ERROR_MSG, 'Transaction')); } return $order; @@ -651,7 +651,7 @@ protected function _formatStr($format, $string) * @param \Magento\Object $response * @param \Magento\Sales\Model\Order\Payment $payment * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _processTokenErrors($response, $payment) { @@ -659,7 +659,7 @@ protected function _processTokenErrors($response, $payment) $response->getResult() != self::RESPONSE_CODE_APPROVED && $response->getResult() != self::RESPONSE_CODE_FRAUDSERVICE_FILTER ) { - throw new \Magento\Core\Exception($response->getRespmsg()); + throw new \Magento\Model\Exception($response->getRespmsg()); } else { $payment->setAdditionalInformation( 'secure_token_id', @@ -726,7 +726,7 @@ protected function _initialize(\Magento\Object $payment, $amount) * @deprecated since 1.6.2.0 * @param mixed|null $token * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function prepareOrderReview($token = null) { @@ -776,7 +776,7 @@ protected function _checkTransaction($transaction, $amount) * * @deprecated since 1.6.2.0 * @return \Magento\Sales\Model\AbstractModel in case of validation passed - * @throws \Magento\Core\Exception In other cases + * @throws \Magento\Model\Exception In other cases */ protected function _getDocumentFromResponse() { diff --git a/app/code/Magento/Paypal/Model/Payflowpro.php b/app/code/Magento/Paypal/Model/Payflowpro.php index 36dd46ae6eb0c..b6f8f3cae7c7d 100644 --- a/app/code/Magento/Paypal/Model/Payflowpro.php +++ b/app/code/Magento/Paypal/Model/Payflowpro.php @@ -719,7 +719,7 @@ protected function _generateRequestId() * * @param \Magento\Object $response * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _processErrors(\Magento\Object $response) { @@ -728,7 +728,7 @@ protected function _processErrors(\Magento\Object $response) } elseif ($response->getResultCode() != self::RESPONSE_CODE_APPROVED && $response->getResultCode() != self::RESPONSE_CODE_FRAUDSERVICE_FILTER ) { - throw new \Magento\Core\Exception($response->getRespmsg()); + throw new \Magento\Model\Exception($response->getRespmsg()); } } diff --git a/app/code/Magento/Paypal/Model/Payment/Transaction.php b/app/code/Magento/Paypal/Model/Payment/Transaction.php index 8643452d177f0..ad10383fff0b3 100644 --- a/app/code/Magento/Paypal/Model/Payment/Transaction.php +++ b/app/code/Magento/Paypal/Model/Payment/Transaction.php @@ -33,7 +33,7 @@ * @method string getCreatedAt() * @method \Magento\Paypal\Model\Payment\Transaction setCreatedAt(string $value) */ -class Transaction extends \Magento\Core\Model\AbstractModel +class Transaction extends \Magento\Model\AbstractModel { /** * Whether to throw exceptions on different operations @@ -74,7 +74,7 @@ class Transaction extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -82,7 +82,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -161,12 +161,12 @@ protected function _afterLoadByTxnId() * @param string $key * @param mixed $value * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setAdditionalInformation($key, $value) { if (is_object($value)) { - throw new \Magento\Core\Exception(__('Payment transactions disallow storing objects.')); + throw new \Magento\Model\Exception(__('Payment transactions disallow storing objects.')); } $info = $this->_getData('additional_information'); if (!$info) { @@ -232,7 +232,7 @@ public function isFailsafe($setFailsafe = null) * Verify data required for saving * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeSave() { @@ -247,12 +247,12 @@ protected function _beforeSave() * * @param string $txnId * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _verifyTxnId($txnId) { if (null !== $txnId && 0 == strlen($txnId)) { - throw new \Magento\Core\Exception(__('You need to enter a transaction ID.')); + throw new \Magento\Model\Exception(__('You need to enter a transaction ID.')); } } @@ -262,12 +262,12 @@ protected function _verifyTxnId($txnId) * TODO for more restriction we can check for data consistency * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _verifyThisTransactionExists() { if (!$this->getId()) { - throw new \Magento\Core\Exception(__('This operation requires an existing transaction object.')); + throw new \Magento\Model\Exception(__('This operation requires an existing transaction object.')); } } } diff --git a/app/code/Magento/Paypal/Model/Pro.php b/app/code/Magento/Paypal/Model/Pro.php index be79b7460d408..b13e3e7f2003f 100644 --- a/app/code/Magento/Paypal/Model/Pro.php +++ b/app/code/Magento/Paypal/Model/Pro.php @@ -233,7 +233,7 @@ public function importPaymentInfo(\Magento\Object $from, \Magento\Payment\Model\ * * @param \Magento\Object $payment * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function void(\Magento\Object $payment) { @@ -243,7 +243,7 @@ public function void(\Magento\Object $payment) $api->setPayment($payment)->setAuthorizationId($authTransactionId)->callDoVoid(); $this->importPaymentInfo($api, $payment); } else { - throw new \Magento\Core\Exception(__('You need an authorization transaction to void.')); + throw new \Magento\Model\Exception(__('You need an authorization transaction to void.')); } } @@ -284,7 +284,7 @@ public function capture(\Magento\Object $payment, $amount) * @param \Magento\Object $payment * @param float $amount * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function refund(\Magento\Object $payment, $amount) { @@ -310,7 +310,7 @@ public function refund(\Magento\Object $payment, $amount) $api->callRefundTransaction(); $this->_importRefundResultToPayment($api, $payment, $canRefundMore); } else { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We can\'t issue a refund transaction because there is no capture transaction.') ); } diff --git a/app/code/Magento/Paypal/Model/Report/Settlement.php b/app/code/Magento/Paypal/Model/Report/Settlement.php index 3849e0bb03b43..b7c37113cd60a 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement.php @@ -42,7 +42,7 @@ * @method string getLastModified() * @method \Magento\Paypal\Model\Report\Settlement setLastModified(string $value) */ -class Settlement extends \Magento\Core\Model\AbstractModel +class Settlement extends \Magento\Model\AbstractModel { /** * Default PayPal SFTP host @@ -173,7 +173,7 @@ class Settlement extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\App\Filesystem $filesystem * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -182,7 +182,7 @@ public function __construct( \Magento\Registry $registry, \Magento\App\Filesystem $filesystem, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -204,7 +204,7 @@ protected function _construct() /** * Stop saving process if file with same report date, account ID and last modified date was already ferched * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _beforeSave() { @@ -224,7 +224,7 @@ protected function _beforeSave() * * @param \Magento\Io\Sftp $connection * @return int Number of report rows that were fetched and saved successfully - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function fetchAndSave(\Magento\Io\Sftp $connection) { @@ -235,7 +235,7 @@ public function fetchAndSave(\Magento\Io\Sftp $connection) $localCsv = 'PayPal_STL_' . uniqid(mt_rand()) . time() . '.csv'; if ($connection->read($filename, $this->_tmpDirectory->getAbsolutePath($localCsv))) { if (!$this->_tmpDirectory->isWritable($localCsv)) { - throw new \Magento\Core\Exception(__('We cannot create a target file for reading reports.')); + throw new \Magento\Model\Exception(__('We cannot create a target file for reading reports.')); } $encoded = $this->_tmpDirectory->readFile($localCsv); diff --git a/app/code/Magento/Paypal/Model/Report/Settlement/Row.php b/app/code/Magento/Paypal/Model/Report/Settlement/Row.php index 25bb61dd7d055..37b23bcab1fcf 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement/Row.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement/Row.php @@ -68,7 +68,7 @@ * @package Magento_Paypal * @author Magento Core Team */ -class Row extends \Magento\Core\Model\AbstractModel +class Row extends \Magento\Model\AbstractModel { /** * Assoc array event code => label diff --git a/app/code/Magento/Paypal/Model/Resource/Billing/Agreement.php b/app/code/Magento/Paypal/Model/Resource/Billing/Agreement.php index 30f8d37e7e1d4..1ea6bae7230ea 100644 --- a/app/code/Magento/Paypal/Model/Resource/Billing/Agreement.php +++ b/app/code/Magento/Paypal/Model/Resource/Billing/Agreement.php @@ -26,7 +26,7 @@ /** * Billing agreement resource model */ -class Agreement extends \Magento\Core\Model\Resource\Db\AbstractDb +class Agreement extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Paypal/Model/Resource/Billing/Agreement/Collection.php b/app/code/Magento/Paypal/Model/Resource/Billing/Agreement/Collection.php index d7edbc57f299d..74ea4c85eca0c 100644 --- a/app/code/Magento/Paypal/Model/Resource/Billing/Agreement/Collection.php +++ b/app/code/Magento/Paypal/Model/Resource/Billing/Agreement/Collection.php @@ -28,7 +28,7 @@ /** * Billing agreements resource collection */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Mapping for fields @@ -63,7 +63,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Customer\Model\Resource\Customer $customerResource * @param \Magento\Eav\Helper\Data $eavHelper * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -73,7 +73,7 @@ public function __construct( \Magento\Customer\Model\Resource\Customer $customerResource, \Magento\Eav\Helper\Data $eavHelper, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_eavHelper = $eavHelper; diff --git a/app/code/Magento/Paypal/Model/Resource/Cert.php b/app/code/Magento/Paypal/Model/Resource/Cert.php index afceb8a749c17..32886a68f6e8c 100644 --- a/app/code/Magento/Paypal/Model/Resource/Cert.php +++ b/app/code/Magento/Paypal/Model/Resource/Cert.php @@ -28,7 +28,7 @@ /** * PayPal resource model for certificate based authentication */ -class Cert extends \Magento\Core\Model\Resource\Db\AbstractDb +class Cert extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Stdlib\DateTime\DateTime @@ -68,10 +68,10 @@ protected function _construct() /** * Set date of last update * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @param \Magento\Model\AbstractModel $object + * @return \Magento\Model\Resource\Db\AbstractDb */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { $object->setUpdatedAt($this->dateTime->formatDate($this->_coreDate->gmtDate())); return parent::_beforeSave($object); diff --git a/app/code/Magento/Paypal/Model/Resource/Payment/Transaction.php b/app/code/Magento/Paypal/Model/Resource/Payment/Transaction.php index a0507a2a9a111..0e4db5f91e7e9 100644 --- a/app/code/Magento/Paypal/Model/Resource/Payment/Transaction.php +++ b/app/code/Magento/Paypal/Model/Resource/Payment/Transaction.php @@ -33,7 +33,7 @@ * @package Magento_Paypal * @author Magento Core Team */ -class Transaction extends \Magento\Core\Model\Resource\Db\AbstractDb +class Transaction extends \Magento\Model\Resource\Db\AbstractDb { /** * Serializeable field: additional_information @@ -71,11 +71,11 @@ public function loadObjectByTxnId(\Magento\Paypal\Model\Payment\Transaction $tra /** * Serialize additional information, if any * - * @param \Magento\Core\Model\AbstractModel $transaction + * @param \Magento\Model\AbstractModel $transaction * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $transaction) + protected function _beforeSave(\Magento\Model\AbstractModel $transaction) { $txnId = $transaction->getData('txn_id'); $idFieldName = $this->getIdFieldName(); diff --git a/app/code/Magento/Paypal/Model/Resource/Payment/Transaction/Collection.php b/app/code/Magento/Paypal/Model/Resource/Payment/Transaction/Collection.php index d7881e077c413..21699d562eae7 100644 --- a/app/code/Magento/Paypal/Model/Resource/Payment/Transaction/Collection.php +++ b/app/code/Magento/Paypal/Model/Resource/Payment/Transaction/Collection.php @@ -33,7 +33,7 @@ * @package Magento_Paypal * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Created Before filter diff --git a/app/code/Magento/Paypal/Model/Resource/Report/Settlement.php b/app/code/Magento/Paypal/Model/Resource/Report/Settlement.php index 65ed5deef9f74..216f62e5ba264 100644 --- a/app/code/Magento/Paypal/Model/Resource/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Resource/Report/Settlement.php @@ -28,7 +28,7 @@ /** * Report settlement resource model */ -class Settlement extends \Magento\Core\Model\Resource\Db\AbstractDb +class Settlement extends \Magento\Model\Resource\Db\AbstractDb { /** * Table name @@ -66,10 +66,10 @@ protected function _construct() /** * Save report rows collected in settlement model * - * @param \Magento\Core\Model\AbstractModel|\Magento\Paypal\Model\Report\Settlement $object + * @param \Magento\Model\AbstractModel|\Magento\Paypal\Model\Report\Settlement $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { $rows = $object->getRows(); if (is_array($rows)) { diff --git a/app/code/Magento/Paypal/Model/Resource/Report/Settlement/Row.php b/app/code/Magento/Paypal/Model/Resource/Report/Settlement/Row.php index 73de8f5017e29..667d4f9dc0898 100644 --- a/app/code/Magento/Paypal/Model/Resource/Report/Settlement/Row.php +++ b/app/code/Magento/Paypal/Model/Resource/Report/Settlement/Row.php @@ -32,7 +32,7 @@ * @package Magento_Paypal * @author Magento Core Team */ -class Row extends \Magento\Core\Model\Resource\Db\AbstractDb +class Row extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource model initialization. diff --git a/app/code/Magento/Paypal/Model/Resource/Report/Settlement/Row/Collection.php b/app/code/Magento/Paypal/Model/Resource/Report/Settlement/Row/Collection.php index 5027ae2b817fe..59a1a1527e641 100644 --- a/app/code/Magento/Paypal/Model/Resource/Report/Settlement/Row/Collection.php +++ b/app/code/Magento/Paypal/Model/Resource/Report/Settlement/Row/Collection.php @@ -34,7 +34,7 @@ */ namespace Magento\Paypal\Model\Resource\Report\Settlement\Row; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initializing 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 9ab6440ed68ce..bca063327161d 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php @@ -53,7 +53,7 @@ class Cert extends \Magento\Core\Model\Config\Value * @param \Magento\Paypal\Model\CertFactory $certFactory * @param \Magento\Encryption\EncryptorInterface $encryptor * @param \Magento\App\Filesystem $filesystem - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -65,7 +65,7 @@ public function __construct( \Magento\Paypal\Model\CertFactory $certFactory, \Magento\Encryption\EncryptorInterface $encryptor, \Magento\App\Filesystem $filesystem, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -79,7 +79,7 @@ public function __construct( * Process additional data before save config * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeSave() { @@ -97,7 +97,7 @@ protected function _beforeSave() ); if ($tmpPath && $this->_tmpDirectory->isExist($tmpPath)) { if (!$this->_tmpDirectory->stat($tmpPath)['size']) { - throw new \Magento\Core\Exception(__('The PayPal certificate file is empty.')); + throw new \Magento\Model\Exception(__('The PayPal certificate file is empty.')); } $this->setValue($_FILES['groups']['name'][$this->getGroupId()]['fields'][$this->getField()]['value']); $content = $this->_encryptor->encrypt($this->_tmpDirectory->readFile($tmpPath)); 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 0db219bc0d7a6..42112746d7be8 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php @@ -42,7 +42,7 @@ class Cron extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -52,7 +52,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 440b778b0a1c4..de2a6c6a8fc04 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php @@ -43,7 +43,7 @@ class MerchantCountry extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Helper\Data $coreData - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -53,7 +53,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Helper\Data $coreData, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_cancelpayment.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_cancelpayment.xml index 2588666802b18..bd5d78e2c6142 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_cancelpayment.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_cancelpayment.xml @@ -25,5 +25,5 @@ --> + template="payflowadvanced/redirect.phtml" cacheable="false"/> diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_form.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_form.xml index 98c418cb3cd03..141092800b9f2 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_form.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_form.xml @@ -25,5 +25,5 @@ --> + template="payflowadvanced/form.phtml" cacheable="false"/> diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_returnurl.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_returnurl.xml index 2588666802b18..bd5d78e2c6142 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_returnurl.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowadvanced_returnurl.xml @@ -25,5 +25,5 @@ --> + template="payflowadvanced/redirect.phtml" cacheable="false"/> diff --git a/app/code/Magento/Persistent/Model/Persistent/Config.php b/app/code/Magento/Persistent/Model/Persistent/Config.php index d7553869bf50d..27b91bb55113d 100644 --- a/app/code/Magento/Persistent/Model/Persistent/Config.php +++ b/app/code/Magento/Persistent/Model/Persistent/Config.php @@ -120,7 +120,7 @@ public function setConfigFilePath($path) * Get persistent XML config xpath * * @return \DOMXPath - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getConfigDomXPath() { @@ -129,7 +129,7 @@ protected function _getConfigDomXPath() $isFile = $this->_modulesDirectory->isFile($filePath); $isReadable = $this->_modulesDirectory->isReadable($filePath); if (!$isFile || !$isReadable) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We cannot load the configuration from file %1.', $this->_configFilePath) ); } @@ -230,7 +230,7 @@ public function fire() * @param array $info * @param bool $instance * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function fireOne($info, $instance = false) { @@ -250,7 +250,7 @@ public function fireOne($info, $instance = false) if (method_exists($object, $method)) { $object->{$method}($instance); } elseif ($this->_appState->getMode() == \Magento\App\State::MODE_DEVELOPER) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( 'Method "' . $method . '" is not defined in "' . get_class($object) . '"' ); } diff --git a/app/code/Magento/Persistent/Model/Resource/Session.php b/app/code/Magento/Persistent/Model/Resource/Session.php index 4535ba7b927f5..8ef15f607081f 100644 --- a/app/code/Magento/Persistent/Model/Resource/Session.php +++ b/app/code/Magento/Persistent/Model/Resource/Session.php @@ -28,7 +28,7 @@ /** * Persistent Session Resource Model */ -class Session extends \Magento\Core\Model\Resource\Db\AbstractDb +class Session extends \Magento\Model\Resource\Db\AbstractDb { /** * Use is object new method for object saving diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php index 419b6a4818bfe..0c4acc9c16153 100644 --- a/app/code/Magento/Persistent/Model/Session.php +++ b/app/code/Magento/Persistent/Model/Session.php @@ -28,7 +28,7 @@ /** * Persistent Session Model */ -class Session extends \Magento\Core\Model\AbstractModel +class Session extends \Magento\Model\AbstractModel { /** * Persistent cookie key length @@ -116,7 +116,7 @@ class Session extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Math\Random $mathRandom * @param \Magento\Session\Config\ConfigInterface $sessionConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -130,7 +130,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Math\Random $mathRandom, \Magento\Session\Config\ConfigInterface $sessionConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/ProductAlert/Helper/Data.php b/app/code/Magento/ProductAlert/Helper/Data.php index 04309d241f516..fe488b07fce46 100644 --- a/app/code/Magento/ProductAlert/Helper/Data.php +++ b/app/code/Magento/ProductAlert/Helper/Data.php @@ -152,7 +152,7 @@ public function getSaveUrl($type) * * @param string|\Magento\View\Element\AbstractBlock $block * @return \Magento\View\Element\AbstractBlock - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function createBlock($block) { @@ -162,7 +162,7 @@ public function createBlock($block) } } if (!$block instanceof \Magento\View\Element\AbstractBlock) { - throw new \Magento\Core\Exception(__('Invalid block type: %1', $block)); + throw new \Magento\Model\Exception(__('Invalid block type: %1', $block)); } return $block; } diff --git a/app/code/Magento/ProductAlert/Model/Email.php b/app/code/Magento/ProductAlert/Model/Email.php index 335b8cb7f8919..e2a0b89352c17 100644 --- a/app/code/Magento/ProductAlert/Model/Email.php +++ b/app/code/Magento/ProductAlert/Model/Email.php @@ -32,7 +32,7 @@ * @package Magento_ProductAlert * @author Magento Core Team */ -class Email extends \Magento\Core\Model\AbstractModel +class Email extends \Magento\Model\AbstractModel { const XML_PATH_EMAIL_PRICE_TEMPLATE = 'catalog/productalert/email_price_template'; @@ -132,7 +132,7 @@ class Email extends \Magento\Core\Model\AbstractModel * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Core\Model\App\Emulation $appEmulation * @param \Magento\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -145,7 +145,7 @@ public function __construct( \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Core\Model\App\Emulation $appEmulation, \Magento\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/ProductAlert/Model/Observer.php b/app/code/Magento/ProductAlert/Model/Observer.php index 64bffd48e2cf3..88ecc5bf527e8 100644 --- a/app/code/Magento/ProductAlert/Model/Observer.php +++ b/app/code/Magento/ProductAlert/Model/Observer.php @@ -119,11 +119,6 @@ class Observer */ protected $_stockColFactory; - /** - * @var \Magento\TranslateInterface - */ - protected $_translate; - /** * @var \Magento\Mail\Template\TransportBuilder */ @@ -134,6 +129,11 @@ class Observer */ protected $_emailFactory; + /** + * @var \Magento\Translate\Inline\StateInterface + */ + protected $inlineTranslation; + /** * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\Core\Model\Store\Config $coreStoreConfig @@ -143,9 +143,9 @@ class Observer * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory * @param \Magento\ProductAlert\Model\Resource\Stock\CollectionFactory $stockColFactory - * @param \Magento\TranslateInterface $translate * @param \Magento\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\ProductAlert\Model\EmailFactory $emailFactory + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation */ public function __construct( \Magento\Tax\Helper\Data $taxData, @@ -156,9 +156,9 @@ public function __construct( \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, \Magento\ProductAlert\Model\Resource\Stock\CollectionFactory $stockColFactory, - \Magento\TranslateInterface $translate, \Magento\Mail\Template\TransportBuilder $transportBuilder, - \Magento\ProductAlert\Model\EmailFactory $emailFactory + \Magento\ProductAlert\Model\EmailFactory $emailFactory, + \Magento\Translate\Inline\StateInterface $inlineTranslation ) { $this->_taxData = $taxData; $this->_coreStoreConfig = $coreStoreConfig; @@ -168,9 +168,9 @@ public function __construct( $this->_productFactory = $productFactory; $this->_dateFactory = $dateFactory; $this->_stockColFactory = $stockColFactory; - $this->_translate = $translate; $this->_transportBuilder = $transportBuilder; $this->_emailFactory = $emailFactory; + $this->inlineTranslation = $inlineTranslation; } /** @@ -378,7 +378,7 @@ protected function _sendErrorEmail() return $this; } - $this->_translate->setTranslateInline(false); + $this->inlineTranslation->suspend(); $transport = $this->_transportBuilder->setTemplateIdentifier( $this->_coreStoreConfig->getConfig(self::XML_PATH_ERROR_TEMPLATE) @@ -397,7 +397,7 @@ protected function _sendErrorEmail() $transport->sendMessage(); - $this->_translate->setTranslateInline(true); + $this->inlineTranslation->resume(); $this->_errors[] = array(); } return $this; diff --git a/app/code/Magento/ProductAlert/Model/Price.php b/app/code/Magento/ProductAlert/Model/Price.php index e330666e80dca..6582d6ecf1a4c 100644 --- a/app/code/Magento/ProductAlert/Model/Price.php +++ b/app/code/Magento/ProductAlert/Model/Price.php @@ -53,7 +53,7 @@ * @package Magento_ProductAlert * @author Magento Core Team */ -class Price extends \Magento\Core\Model\AbstractModel +class Price extends \Magento\Model\AbstractModel { /** * @var \Magento\ProductAlert\Model\Resource\Price\Customer\CollectionFactory @@ -64,7 +64,7 @@ class Price extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\ProductAlert\Model\Resource\Price\Customer\CollectionFactory $customerColFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -72,7 +72,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\ProductAlert\Model\Resource\Price\Customer\CollectionFactory $customerColFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/ProductAlert/Model/Resource/AbstractResource.php b/app/code/Magento/ProductAlert/Model/Resource/AbstractResource.php index a2b4380e28cb3..75c9c649a8ab3 100644 --- a/app/code/Magento/ProductAlert/Model/Resource/AbstractResource.php +++ b/app/code/Magento/ProductAlert/Model/Resource/AbstractResource.php @@ -32,15 +32,15 @@ * @package Magento_ProductAlert * @author Magento Core Team */ -abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\AbstractDb +abstract class AbstractResource extends \Magento\Model\Resource\Db\AbstractDb { /** * Retrieve alert row by object parameters * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return array|false */ - protected function _getAlertRow(\Magento\Core\Model\AbstractModel $object) + protected function _getAlertRow(\Magento\Model\AbstractModel $object) { $adapter = $this->_getReadAdapter(); if ($object->getCustomerId() && $object->getProductId() && $object->getWebsiteId()) { @@ -66,10 +66,10 @@ protected function _getAlertRow(\Magento\Core\Model\AbstractModel $object) /** * Load object data by parameters * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - public function loadByParam(\Magento\Core\Model\AbstractModel $object) + public function loadByParam(\Magento\Model\AbstractModel $object) { $row = $this->_getAlertRow($object); if ($row) { @@ -81,12 +81,12 @@ public function loadByParam(\Magento\Core\Model\AbstractModel $object) /** * Delete all customer alerts on website * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param int $customerId * @param int $websiteId * @return $this */ - public function deleteCustomer(\Magento\Core\Model\AbstractModel $object, $customerId, $websiteId = null) + public function deleteCustomer(\Magento\Model\AbstractModel $object, $customerId, $websiteId = null) { $adapter = $this->_getWriteAdapter(); $where = array(); diff --git a/app/code/Magento/ProductAlert/Model/Resource/Price.php b/app/code/Magento/ProductAlert/Model/Resource/Price.php index 64678c44e32c0..165949255c901 100644 --- a/app/code/Magento/ProductAlert/Model/Resource/Price.php +++ b/app/code/Magento/ProductAlert/Model/Resource/Price.php @@ -58,10 +58,10 @@ protected function _construct() /** * Before save process, check exists the same alert * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { if (is_null($object->getId()) && $object->getCustomerId() && $object->getProductId() && $object->getWebsiteId() ) { diff --git a/app/code/Magento/ProductAlert/Model/Resource/Price/Collection.php b/app/code/Magento/ProductAlert/Model/Resource/Price/Collection.php index 87ae940cc543a..726efb6163284 100644 --- a/app/code/Magento/ProductAlert/Model/Resource/Price/Collection.php +++ b/app/code/Magento/ProductAlert/Model/Resource/Price/Collection.php @@ -32,7 +32,7 @@ * @package Magento_ProductAlert * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Define price collection diff --git a/app/code/Magento/ProductAlert/Model/Resource/Stock.php b/app/code/Magento/ProductAlert/Model/Resource/Stock.php index 421f7bc7efb30..7dea67151e288 100644 --- a/app/code/Magento/ProductAlert/Model/Resource/Stock.php +++ b/app/code/Magento/ProductAlert/Model/Resource/Stock.php @@ -58,10 +58,10 @@ protected function _construct() /** * Before save action * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { if (is_null($object->getId()) && $object->getCustomerId() && $object->getProductId() && $object->getWebsiteId() ) { diff --git a/app/code/Magento/ProductAlert/Model/Resource/Stock/Collection.php b/app/code/Magento/ProductAlert/Model/Resource/Stock/Collection.php index 1d48138fb5c97..fc8bc4166333c 100644 --- a/app/code/Magento/ProductAlert/Model/Resource/Stock/Collection.php +++ b/app/code/Magento/ProductAlert/Model/Resource/Stock/Collection.php @@ -32,7 +32,7 @@ * @package Magento_ProductAlert * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Define stock collection diff --git a/app/code/Magento/ProductAlert/Model/Stock.php b/app/code/Magento/ProductAlert/Model/Stock.php index d21faef6f4816..eabf55c333227 100644 --- a/app/code/Magento/ProductAlert/Model/Stock.php +++ b/app/code/Magento/ProductAlert/Model/Stock.php @@ -51,7 +51,7 @@ * @package Magento_ProductAlert * @author Magento Core Team */ -class Stock extends \Magento\Core\Model\AbstractModel +class Stock extends \Magento\Model\AbstractModel { /** * @var \Magento\ProductAlert\Model\Resource\Stock\Customer\CollectionFactory @@ -62,7 +62,7 @@ class Stock extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\ProductAlert\Model\Resource\Stock\Customer\CollectionFactory $customerColFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -70,7 +70,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\ProductAlert\Model\Resource\Stock\Customer\CollectionFactory $customerColFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Rating/Model/Rating.php b/app/code/Magento/Rating/Model/Rating.php index 6dd429fbe7703..b1263291b3429 100644 --- a/app/code/Magento/Rating/Model/Rating.php +++ b/app/code/Magento/Rating/Model/Rating.php @@ -40,7 +40,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Rating extends \Magento\Core\Model\AbstractModel +class Rating extends \Magento\Model\AbstractModel { /** * rating entity codes @@ -66,7 +66,7 @@ class Rating extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Rating\Model\Rating\OptionFactory $ratingOptionFactory * @param \Magento\Rating\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -75,7 +75,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Rating\Model\Rating\OptionFactory $ratingOptionFactory, \Magento\Rating\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Rating/Model/Rating/Entity.php b/app/code/Magento/Rating/Model/Rating/Entity.php index 0dbdd83441941..1fdfd8be8307e 100644 --- a/app/code/Magento/Rating/Model/Rating/Entity.php +++ b/app/code/Magento/Rating/Model/Rating/Entity.php @@ -37,7 +37,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Entity extends \Magento\Core\Model\AbstractModel +class Entity extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Rating/Model/Rating/Option.php b/app/code/Magento/Rating/Model/Rating/Option.php index dbe44a9515467..d9011e622a630 100644 --- a/app/code/Magento/Rating/Model/Rating/Option.php +++ b/app/code/Magento/Rating/Model/Rating/Option.php @@ -43,7 +43,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Option extends \Magento\Core\Model\AbstractModel +class Option extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Rating/Model/Rating/Option/Vote.php b/app/code/Magento/Rating/Model/Rating/Option/Vote.php index 0b74a01b6b99d..823a655a25726 100644 --- a/app/code/Magento/Rating/Model/Rating/Option/Vote.php +++ b/app/code/Magento/Rating/Model/Rating/Option/Vote.php @@ -32,7 +32,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Vote extends \Magento\Core\Model\AbstractModel +class Vote extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Rating/Model/Resource/Rating.php b/app/code/Magento/Rating/Model/Resource/Rating.php index 2e79ae98c5e9f..2e8911c20cf79 100644 --- a/app/code/Magento/Rating/Model/Resource/Rating.php +++ b/app/code/Magento/Rating/Model/Resource/Rating.php @@ -32,7 +32,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Rating extends \Magento\Core\Model\Resource\Db\AbstractDb +class Rating extends \Magento\Model\Resource\Db\AbstractDb { const RATING_STATUS_APPROVED = 'Approved'; @@ -131,10 +131,10 @@ protected function _getLoadSelect($field, $value, $object) /** * Actions after load * - * @param \Magento\Core\Model\AbstractModel|\Magento\Rating\Model\Rating $object + * @param \Magento\Model\AbstractModel|\Magento\Rating\Model\Rating $object * @return $this */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(\Magento\Model\AbstractModel $object) { parent::_afterLoad($object); @@ -184,10 +184,10 @@ public function getStores($ratingId) /** * Actions after save * - * @param \Magento\Core\Model\AbstractModel|\Magento\Rating\Model\Rating $object + * @param \Magento\Model\AbstractModel|\Magento\Rating\Model\Rating $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { parent::_afterSave($object); @@ -273,10 +273,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) * Perform actions after object delete * Prepare rating data for reaggregate all data for reviews * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterDelete(\Magento\Core\Model\AbstractModel $object) + protected function _afterDelete(\Magento\Model\AbstractModel $object) { parent::_afterDelete($object); if (!$this->_ratingData->isModuleEnabled('Magento_Review')) { diff --git a/app/code/Magento/Rating/Model/Resource/Rating/Collection.php b/app/code/Magento/Rating/Model/Resource/Rating/Collection.php index d3a83dd6ecdb5..4d987a1940880 100644 --- a/app/code/Magento/Rating/Model/Resource/Rating/Collection.php +++ b/app/code/Magento/Rating/Model/Resource/Rating/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * @var \Magento\Core\Model\StoreManagerInterface @@ -58,7 +58,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Rating\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -68,7 +68,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Rating\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_storeManager = $storeManager; $this->_ratingCollectionF = $ratingCollectionF; diff --git a/app/code/Magento/Rating/Model/Resource/Rating/Entity.php b/app/code/Magento/Rating/Model/Resource/Rating/Entity.php index 6776ce46048d6..a20d688c1d75b 100644 --- a/app/code/Magento/Rating/Model/Resource/Rating/Entity.php +++ b/app/code/Magento/Rating/Model/Resource/Rating/Entity.php @@ -32,7 +32,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Entity extends \Magento\Core\Model\Resource\Db\AbstractDb +class Entity extends \Magento\Model\Resource\Db\AbstractDb { /** * Rating entity resource initialization diff --git a/app/code/Magento/Rating/Model/Resource/Rating/Grid/Collection.php b/app/code/Magento/Rating/Model/Resource/Rating/Grid/Collection.php index 0896a9dd4a26f..83e37040cfcd1 100644 --- a/app/code/Magento/Rating/Model/Resource/Rating/Grid/Collection.php +++ b/app/code/Magento/Rating/Model/Resource/Rating/Grid/Collection.php @@ -50,7 +50,7 @@ class Collection extends \Magento\Rating\Model\Resource\Rating\Collection * @param \Magento\Rating\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF * @param \Magento\Registry $coreRegistry * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -61,7 +61,7 @@ public function __construct( \Magento\Rating\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF, \Magento\Registry $coreRegistry, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_coreRegistry = $coreRegistry; parent::__construct( diff --git a/app/code/Magento/Rating/Model/Resource/Rating/Option.php b/app/code/Magento/Rating/Model/Resource/Rating/Option.php index 9369bbf48e5d7..b1f8172851ba5 100644 --- a/app/code/Magento/Rating/Model/Resource/Rating/Option.php +++ b/app/code/Magento/Rating/Model/Resource/Rating/Option.php @@ -32,7 +32,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Option extends \Magento\Core\Model\Resource\Db\AbstractDb +class Option extends \Magento\Model\Resource\Db\AbstractDb { /** * Review table diff --git a/app/code/Magento/Rating/Model/Resource/Rating/Option/Collection.php b/app/code/Magento/Rating/Model/Resource/Rating/Option/Collection.php index 59273ca55a5e8..d0be239875288 100644 --- a/app/code/Magento/Rating/Model/Resource/Rating/Option/Collection.php +++ b/app/code/Magento/Rating/Model/Resource/Rating/Option/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Rating votes table diff --git a/app/code/Magento/Rating/Model/Resource/Rating/Option/Vote.php b/app/code/Magento/Rating/Model/Resource/Rating/Option/Vote.php index adb62a50f33cc..9612a6ecbc357 100644 --- a/app/code/Magento/Rating/Model/Resource/Rating/Option/Vote.php +++ b/app/code/Magento/Rating/Model/Resource/Rating/Option/Vote.php @@ -32,7 +32,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Vote extends \Magento\Core\Model\Resource\Db\AbstractDb +class Vote extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Rating/Model/Resource/Rating/Option/Vote/Collection.php b/app/code/Magento/Rating/Model/Resource/Rating/Option/Vote/Collection.php index 1d6ce8582b366..179fb83076ee6 100644 --- a/app/code/Magento/Rating/Model/Resource/Rating/Option/Vote/Collection.php +++ b/app/code/Magento/Rating/Model/Resource/Rating/Option/Vote/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Rating * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Store list manager @@ -54,7 +54,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Rating\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -64,7 +64,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Rating\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_storeManager = $storeManager; $this->_ratingCollectionF = $ratingCollectionF; diff --git a/app/code/Magento/RecurringPayment/Block/Adminhtml/Payment/View/Items.php b/app/code/Magento/RecurringPayment/Block/Adminhtml/Payment/View/Items.php index 698813ef857d7..dcce70c581009 100644 --- a/app/code/Magento/RecurringPayment/Block/Adminhtml/Payment/View/Items.php +++ b/app/code/Magento/RecurringPayment/Block/Adminhtml/Payment/View/Items.php @@ -40,7 +40,7 @@ class Items extends \Magento\Sales\Block\Adminhtml\Items\AbstractItems protected function _beforeToHtml() { if (!$this->getParentBlock()) { - throw new \Magento\Core\Exception(__('Invalid parent block for this block')); + throw new \Magento\Model\Exception(__('Invalid parent block for this block')); } parent::_beforeToHtml(); } diff --git a/app/code/Magento/RecurringPayment/Controller/Adminhtml/RecurringPayment.php b/app/code/Magento/RecurringPayment/Controller/Adminhtml/RecurringPayment.php index 975f0d11b1c4f..1a68efb3b7c34 100644 --- a/app/code/Magento/RecurringPayment/Controller/Adminhtml/RecurringPayment.php +++ b/app/code/Magento/RecurringPayment/Controller/Adminhtml/RecurringPayment.php @@ -24,7 +24,7 @@ namespace Magento\RecurringPayment\Controller\Adminhtml; use Magento\App\Action\NotFoundException; -use Magento\Core\Exception as CoreException; +use Magento\Model\Exception as CoreException; use Magento\Customer\Controller\RegistryConstants; /** @@ -244,7 +244,7 @@ public function customerGridAction() * Load/set payment * * @return \Magento\RecurringPayment\Model\Payment - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _initPayment() { diff --git a/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php b/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php index 7161394f7fe2b..0ab0ef6b0bf69 100644 --- a/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php +++ b/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php @@ -28,6 +28,7 @@ namespace Magento\RecurringPayment\Controller; use Magento\App\RequestInterface; +use Magento\Customer\Controller\RegistryConstants; class RecurringPayment extends \Magento\App\Action\Action { @@ -79,7 +80,9 @@ public function dispatch(RequestInterface $request) if (!$this->_session->authenticate($this)) { $this->_actionFlag->set('', 'no-dispatch', true); } - $this->_coreRegistry->register('current_customer', $this->_session->getCustomer()); + $customer = $this->_session->getCustomer(); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER, $customer); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId()); return parent::dispatch($request); } @@ -141,7 +144,7 @@ public function updateStateAction() break; } $this->messageManager->addSuccess(__('The payment state has been updated.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We couldn\'t update the payment.')); @@ -171,7 +174,7 @@ public function updatePaymentAction() } else { $this->messageManager->addNotice(__('The payment has no changes.')); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We couldn\'t update the payment.')); @@ -199,7 +202,7 @@ protected function _viewAction() $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); @@ -211,7 +214,7 @@ protected function _viewAction() * Instantiate current payment and put it into registry * * @return \Magento\RecurringPayment\Model\Payment - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _initPayment() { @@ -221,7 +224,7 @@ protected function _initPayment() $this->getRequest()->getParam('payment') ); if (!$payment->getId()) { - throw new \Magento\Core\Exception(__('We can\'t find the payment you specified.')); + throw new \Magento\Model\Exception(__('We can\'t find the payment you specified.')); } $this->_coreRegistry->register('current_recurring_payment', $payment); return $payment; diff --git a/app/code/Magento/RecurringPayment/Model/ManagerInterface.php b/app/code/Magento/RecurringPayment/Model/ManagerInterface.php index 54fbe75207e64..3bf7d6cec466e 100644 --- a/app/code/Magento/RecurringPayment/Model/ManagerInterface.php +++ b/app/code/Magento/RecurringPayment/Model/ManagerInterface.php @@ -36,7 +36,7 @@ interface ManagerInterface * * @param RecurringPayment $payment * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validate(RecurringPayment $payment); diff --git a/app/code/Magento/RecurringPayment/Model/Observer/CheckoutManagerObserver.php b/app/code/Magento/RecurringPayment/Model/Observer/CheckoutManagerObserver.php index e014a908df700..5493e87436e16 100644 --- a/app/code/Magento/RecurringPayment/Model/Observer/CheckoutManagerObserver.php +++ b/app/code/Magento/RecurringPayment/Model/Observer/CheckoutManagerObserver.php @@ -57,14 +57,14 @@ public function __construct( * * @param \Magento\Event\Observer $observer * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function submitRecurringPayments($observer) { $this->_recurringPayments = $this->_quoteImporter->import($observer->getEvent()->getQuote()); foreach ($this->_recurringPayments as $payment) { if (!$payment->isValid()) { - throw new \Magento\Core\Exception($payment->getValidationErrors()); + throw new \Magento\Model\Exception($payment->getValidationErrors()); } $payment->submit(); } diff --git a/app/code/Magento/RecurringPayment/Model/Payment.php b/app/code/Magento/RecurringPayment/Model/Payment.php index f5c09e84e07a3..ab76d3cc60529 100644 --- a/app/code/Magento/RecurringPayment/Model/Payment.php +++ b/app/code/Magento/RecurringPayment/Model/Payment.php @@ -141,7 +141,7 @@ class Payment extends \Magento\RecurringPayment\Model\RecurringPayment * @param \Magento\Sales\Model\Order\ItemFactory $orderItemFactory * @param \Magento\Math\Random $mathRandom * @param States $states - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -162,7 +162,7 @@ public function __construct( \Magento\Sales\Model\Order\ItemFactory $orderItemFactory, \Magento\Math\Random $mathRandom, States $states, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -625,7 +625,7 @@ protected function _initWorkflow() * @param string $againstState * @param bool $soft * @return bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _checkWorkflow($againstState, $soft = true) { @@ -633,7 +633,7 @@ protected function _checkWorkflow($againstState, $soft = true) $state = $this->getState(); $result = !empty($this->_workflow[$state]) && in_array($againstState, $this->_workflow[$state]); if (!$soft && !$result) { - throw new \Magento\Core\Exception(__('This payment state cannot be changed to "%1".', $againstState)); + throw new \Magento\Model\Exception(__('This payment state cannot be changed to "%1".', $againstState)); } return $result; } diff --git a/app/code/Magento/RecurringPayment/Model/RecurringPayment.php b/app/code/Magento/RecurringPayment/Model/RecurringPayment.php index 2d06560a92aa9..7bb51257c5627 100644 --- a/app/code/Magento/RecurringPayment/Model/RecurringPayment.php +++ b/app/code/Magento/RecurringPayment/Model/RecurringPayment.php @@ -38,7 +38,7 @@ * @method RecurringPayment setToken() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RecurringPayment extends \Magento\Core\Model\AbstractModel +class RecurringPayment extends \Magento\Model\AbstractModel { /** * Constants for passing data through catalog @@ -117,7 +117,7 @@ class RecurringPayment extends \Magento\Core\Model\AbstractModel * @param ManagerInterfaceFactory $managerFactory * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Locale\ResolverInterface $localeResolver - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data * @@ -132,7 +132,7 @@ public function __construct( ManagerInterfaceFactory $managerFactory, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Locale\ResolverInterface $localeResolver, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -223,7 +223,7 @@ public function isValid() if ($this->_manager) { try { $this->_manager->validate($this); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_errors['payment_method'][] = $e->getMessage(); } } @@ -235,7 +235,7 @@ public function isValid() * Getter for errors that may appear after validation * * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getValidationErrors() { @@ -244,7 +244,7 @@ public function getValidationErrors() foreach ($this->_errors as $row) { $result[] = implode(' ', $row); } - throw new \Magento\Core\Exception(__("The payment is invalid:\n%1.", implode("\n", $result))); + throw new \Magento\Model\Exception(__("The payment is invalid:\n%1.", implode("\n", $result))); } return $this->_errors; } @@ -268,7 +268,7 @@ public function setManager(ManagerInterface $object) * * @param \Magento\Object $buyRequest * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @throws \Exception */ public function importBuyRequest(\Magento\Object $buyRequest) @@ -283,7 +283,7 @@ public function importBuyRequest(\Magento\Object $buyRequest) ); $localeCode = $this->_localeResolver->getLocaleCode(); if (!\Zend_Date::isDate($startDate, $dateFormat, $localeCode)) { - throw new \Magento\Core\Exception(__('The recurring payment start date has invalid format.')); + throw new \Magento\Model\Exception(__('The recurring payment start date has invalid format.')); } $utcTime = $this->_localeDate->utcDate( $this->_store, @@ -525,15 +525,15 @@ protected function _validatePeriodFrequency($unitKey, $frequencyKey) * Perform full validation before saving * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _validateBeforeSave() { if (!$this->isValid()) { - throw new \Magento\Core\Exception($this->getValidationErrors()); + throw new \Magento\Model\Exception($this->getValidationErrors()); } if (!$this->getInternalReferenceId()) { - throw new \Magento\Core\Exception(__('An internal reference ID is required to save the payment.')); + throw new \Magento\Model\Exception(__('An internal reference ID is required to save the payment.')); } } diff --git a/app/code/Magento/RecurringPayment/Model/Resource/Order/CollectionFilter.php b/app/code/Magento/RecurringPayment/Model/Resource/Order/CollectionFilter.php index b82f7ceecf53c..6194b8f4f25fb 100644 --- a/app/code/Magento/RecurringPayment/Model/Resource/Order/CollectionFilter.php +++ b/app/code/Magento/RecurringPayment/Model/Resource/Order/CollectionFilter.php @@ -33,7 +33,7 @@ class CollectionFilter /** * Add filter by specified recurring payment id(s) * - * @param \Magento\Core\Model\Resource\Db\Collection\AbstractCollection $collection + * @param \Magento\Model\Resource\Db\Collection\AbstractCollection $collection * @param array|int $ids * @return \Magento\Sales\Model\Resource\Order\Collection */ diff --git a/app/code/Magento/RecurringPayment/Model/Resource/Payment/Collection.php b/app/code/Magento/RecurringPayment/Model/Resource/Payment/Collection.php index ece00325143e5..b8b326a00f046 100644 --- a/app/code/Magento/RecurringPayment/Model/Resource/Payment/Collection.php +++ b/app/code/Magento/RecurringPayment/Model/Resource/Payment/Collection.php @@ -26,7 +26,7 @@ /** * Recurring payment collection */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Event prefix diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Customer.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Customer.php index f0260c9fe6444..5e238032539f9 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Customer.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Customer.php @@ -48,7 +48,7 @@ public function render(\Magento\Object $row) return sprintf( '%s', - $this->getUrl('catalog/product_review/', array('customerId' => $id)), + $this->getUrl('review/product/', array('customerId' => $id)), __('Show Reviews') ); } diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Product.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Product.php index a40e633e4a3ba..3cceacd6c6289 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Product.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Product.php @@ -44,7 +44,7 @@ public function render(\Magento\Object $row) return sprintf( '%s', - $this->getUrl('catalog/product_review/', array('productId' => $id)), + $this->getUrl('review/product/', array('productId' => $id)), __('Show Reviews') ); } diff --git a/app/code/Magento/Reports/Block/Product/AbstractProduct.php b/app/code/Magento/Reports/Block/Product/AbstractProduct.php index e863d23add409..f1c231cd009aa 100644 --- a/app/code/Magento/Reports/Block/Product/AbstractProduct.php +++ b/app/code/Magento/Reports/Block/Product/AbstractProduct.php @@ -57,36 +57,14 @@ abstract class AbstractProduct extends \Magento\Catalog\Block\Product\AbstractPr protected $_indexFactory; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\Reports\Model\Product\Index\Factory $indexFactory * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Reports\Model\Product\Index\Factory $indexFactory, array $data = array(), @@ -94,16 +72,6 @@ public function __construct( ) { parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); @@ -145,7 +113,7 @@ protected function _getModel() try { $model = $this->_indexFactory->get($this->_indexType); } catch (\InvalidArgumentException $e) { - new \Magento\Core\Exception(__('Index type is not valid')); + new \Magento\Model\Exception(__('Index type is not valid')); } return $model; diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php index 35995f9b16ed1..6a5a28d0fa647 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php @@ -169,7 +169,7 @@ public function refreshRecentAction() $this->_objectManager->create($collectionName)->aggregate($date); } $this->messageManager->addSuccess(__('Recent statistics have been updated.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t refresh recent statistics.')); @@ -196,7 +196,7 @@ public function refreshLifetimeAction() $this->_objectManager->create($collectionName)->aggregate(); } $this->messageManager->addSuccess(__('We updated lifetime statistics.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t refresh lifetime statistics.')); diff --git a/app/code/Magento/Reports/Model/Event.php b/app/code/Magento/Reports/Model/Event.php index 96c79b4470676..a1a7b2edb0b47 100644 --- a/app/code/Magento/Reports/Model/Event.php +++ b/app/code/Magento/Reports/Model/Event.php @@ -47,7 +47,7 @@ * @package Magento_Reports * @author Magento Core Team */ -class Event extends \Magento\Core\Model\AbstractModel +class Event extends \Magento\Model\AbstractModel { const EVENT_PRODUCT_VIEW = 1; @@ -76,7 +76,7 @@ class Event extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory * @param \Magento\Reports\Model\Event\TypeFactory $eventTypeFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -85,7 +85,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, \Magento\Reports\Model\Event\TypeFactory $eventTypeFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Reports/Model/Event/Type.php b/app/code/Magento/Reports/Model/Event/Type.php index 1459460b87859..f5f9b55bfbc71 100644 --- a/app/code/Magento/Reports/Model/Event/Type.php +++ b/app/code/Magento/Reports/Model/Event/Type.php @@ -39,7 +39,7 @@ * @package Magento_Reports * @author Magento Core Team */ -class Type extends \Magento\Core\Model\AbstractModel +class Type extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Reports/Model/Flag.php b/app/code/Magento/Reports/Model/Flag.php index 1e72f008e48a6..77effab7f1293 100644 --- a/app/code/Magento/Reports/Model/Flag.php +++ b/app/code/Magento/Reports/Model/Flag.php @@ -32,7 +32,7 @@ * @package Magento_Reports * @author Magento Core Team */ -class Flag extends \Magento\Core\Model\Flag +class Flag extends \Magento\Flag { const REPORT_ORDER_FLAG_CODE = 'report_order_aggregated'; diff --git a/app/code/Magento/Reports/Model/Grouped/Collection.php b/app/code/Magento/Reports/Model/Grouped/Collection.php index c3155074e3f8f..5c90c6b3229c8 100644 --- a/app/code/Magento/Reports/Model/Grouped/Collection.php +++ b/app/code/Magento/Reports/Model/Grouped/Collection.php @@ -27,7 +27,7 @@ use Magento\Data\Collection\Db; -class Collection extends \Magento\Data\Collection //\Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Data\Collection { /** * Column name for group by clause @@ -39,7 +39,7 @@ class Collection extends \Magento\Data\Collection //\Magento\Core\Model\Resource /** * Collection resource * - * @var \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @var \Magento\Model\Resource\Db\Collection\AbstractCollection */ protected $_resourceCollection = null; diff --git a/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php b/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php index 34193fb31e554..a8da191901554 100644 --- a/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php +++ b/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php @@ -28,7 +28,7 @@ /** * Reports Product Index Abstract Model */ -abstract class AbstractIndex extends \Magento\Core\Model\AbstractModel +abstract class AbstractIndex extends \Magento\Model\AbstractModel { /** * Cache key name for Count of product index @@ -76,7 +76,7 @@ abstract class AbstractIndex extends \Magento\Core\Model\AbstractModel * @param \Magento\Session\Generic $reportSession * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -89,7 +89,7 @@ public function __construct( \Magento\Session\Generic $reportSession, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Reports/Model/Product/Index/Compared.php b/app/code/Magento/Reports/Model/Product/Index/Compared.php index d30844c34f35e..3994a86183fe9 100644 --- a/app/code/Magento/Reports/Model/Product/Index/Compared.php +++ b/app/code/Magento/Reports/Model/Product/Index/Compared.php @@ -68,7 +68,7 @@ class Compared extends \Magento\Reports\Model\Product\Index\AbstractIndex * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Catalog\Helper\Product\Compare $productCompare - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -82,7 +82,7 @@ public function __construct( \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Stdlib\DateTime $dateTime, \Magento\Catalog\Helper\Product\Compare $productCompare, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -126,8 +126,8 @@ public function getExcludeProductIds() } } - if ($this->_coreRegistry->registry('current_product')) { - $productIds[] = $this->_coreRegistry->registry('current_product')->getId(); + if ($this->_registry->registry('current_product')) { + $productIds[] = $this->_registry->registry('current_product')->getId(); } return array_unique($productIds); diff --git a/app/code/Magento/Reports/Model/Product/Index/Viewed.php b/app/code/Magento/Reports/Model/Product/Index/Viewed.php index 2188535875a5a..93c32b37bfc45 100644 --- a/app/code/Magento/Reports/Model/Product/Index/Viewed.php +++ b/app/code/Magento/Reports/Model/Product/Index/Viewed.php @@ -70,8 +70,8 @@ public function getExcludeProductIds() { $productIds = array(); - if ($this->_coreRegistry->registry('current_product')) { - $productIds[] = $this->_coreRegistry->registry('current_product')->getId(); + if ($this->_registry->registry('current_product')) { + $productIds[] = $this->_registry->registry('current_product')->getId(); } return $productIds; diff --git a/app/code/Magento/Reports/Model/Resource/Event.php b/app/code/Magento/Reports/Model/Resource/Event.php index dc68e78332b9f..423ae58eb5df2 100644 --- a/app/code/Magento/Reports/Model/Resource/Event.php +++ b/app/code/Magento/Reports/Model/Resource/Event.php @@ -34,7 +34,7 @@ */ namespace Magento\Reports\Model\Resource; -class Event extends \Magento\Core\Model\Resource\Db\AbstractDb +class Event extends \Magento\Model\Resource\Db\AbstractDb { /** * Core store config diff --git a/app/code/Magento/Reports/Model/Resource/Event/Collection.php b/app/code/Magento/Reports/Model/Resource/Event/Collection.php index f0ed8c74f9ea7..542c82c0a1e31 100644 --- a/app/code/Magento/Reports/Model/Resource/Event/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Event/Collection.php @@ -34,7 +34,7 @@ */ namespace Magento\Reports\Model\Resource\Event; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Store Ids diff --git a/app/code/Magento/Reports/Model/Resource/Event/Type.php b/app/code/Magento/Reports/Model/Resource/Event/Type.php index 7ec67e7afc4e9..30fb1d00cfa79 100644 --- a/app/code/Magento/Reports/Model/Resource/Event/Type.php +++ b/app/code/Magento/Reports/Model/Resource/Event/Type.php @@ -34,7 +34,7 @@ */ namespace Magento\Reports\Model\Resource\Event; -class Type extends \Magento\Core\Model\Resource\Db\AbstractDb +class Type extends \Magento\Model\Resource\Db\AbstractDb { /** * Main table initialization diff --git a/app/code/Magento/Reports/Model/Resource/Event/Type/Collection.php b/app/code/Magento/Reports/Model/Resource/Event/Type/Collection.php index 524ca542b15f5..fdb69772690a9 100644 --- a/app/code/Magento/Reports/Model/Resource/Event/Type/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Event/Type/Collection.php @@ -34,7 +34,7 @@ */ namespace Magento\Reports\Model\Resource\Event\Type; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Reports/Model/Resource/Helper.php b/app/code/Magento/Reports/Model/Resource/Helper.php index 489e6f42d0ce4..499c52e287940 100644 --- a/app/code/Magento/Reports/Model/Resource/Helper.php +++ b/app/code/Magento/Reports/Model/Resource/Helper.php @@ -34,7 +34,7 @@ */ namespace Magento\Reports\Model\Resource; -class Helper extends \Magento\Core\Model\Resource\Helper implements \Magento\Reports\Model\Resource\HelperInterface +class Helper extends \Magento\DB\Helper implements \Magento\Reports\Model\Resource\HelperInterface { /** * @param \Magento\App\Resource $resource diff --git a/app/code/Magento/Reports/Model/Resource/HelperInterface.php b/app/code/Magento/Reports/Model/Resource/HelperInterface.php index d48f3168591c5..5431e877231c2 100644 --- a/app/code/Magento/Reports/Model/Resource/HelperInterface.php +++ b/app/code/Magento/Reports/Model/Resource/HelperInterface.php @@ -48,7 +48,7 @@ public function mergeVisitorProductIndex($mainTable, $data, $matchFields); * @param string $column * @param string $mainTable * @param string $aggregationTable - * @return \Magento\Core\Model\Resource\Helper\AbstractHelper + * @return \Magento\DB\Helper\AbstractHelper */ public function updateReportRatingPos($type, $column, $mainTable, $aggregationTable); } diff --git a/app/code/Magento/Reports/Model/Resource/Order/Collection.php b/app/code/Magento/Reports/Model/Resource/Order/Collection.php index 6e25ebdaa266f..bd94f6612a611 100644 --- a/app/code/Magento/Reports/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Order/Collection.php @@ -80,15 +80,15 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\Resource\Helper $coreResourceHelper + * @param \Magento\DB\Helper $coreResourceHelper * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Sales\Model\Order\Config $orderConfig * @param \Magento\Sales\Model\Resource\Report\OrderFactory $reportOrderFactory * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource - * + * @param \Magento\Model\Resource\Db\AbstractDb $resource + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -96,14 +96,14 @@ public function __construct( \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\Resource\Helper $coreResourceHelper, + \Magento\DB\Helper $coreResourceHelper, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Sales\Model\Resource\Report\OrderFactory $reportOrderFactory, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct( $entityFactory, diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php b/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php index 9d7e4affb42e3..fd3aefaaa4f8e 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php @@ -28,7 +28,7 @@ /** * Reports Product Index Abstract Resource Model */ -abstract class AbstractIndex extends \Magento\Core\Model\Resource\Db\AbstractDb +abstract class AbstractIndex extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Stdlib\DateTime @@ -36,22 +36,22 @@ abstract class AbstractIndex extends \Magento\Core\Model\Resource\Db\AbstractDb protected $dateTime; /** - * @var \Magento\Reports\Model\Resource\HelperFactory + * @var \Magento\Reports\Model\Resource\Helper */ - protected $_helperFactory; + protected $_resourceHelper; /** * @param \Magento\App\Resource $resource - * @param \Magento\Reports\Model\Resource\HelperFactory $helperFactory + * @param \Magento\Reports\Model\Resource\Helper $resourceHelper * @param \Magento\Stdlib\DateTime $dateTime */ public function __construct( \Magento\App\Resource $resource, - \Magento\Reports\Model\Resource\HelperFactory $helperFactory, + \Magento\Reports\Model\Resource\Helper $resourceHelper, \Magento\Stdlib\DateTime $dateTime ) { parent::__construct($resource); - $this->_helperFactory = $helperFactory; + $this->_resourceHelper = $resourceHelper; $this->dateTime = $dateTime; } @@ -141,10 +141,10 @@ public function purgeVisitorByCustomer(\Magento\Reports\Model\Product\Index\Abst /** * Save Product Index data (forced save) * - * @param \Magento\Core\Model\AbstractModel $object - * @return $this|\Magento\Core\Model\Resource\Db\AbstractDb + * @param \Magento\Model\AbstractModel $object + * @return $this|\Magento\Model\Resource\Db\AbstractDb */ - public function save(\Magento\Core\Model\AbstractModel $object) + public function save(\Magento\Model\AbstractModel $object) { if ($object->isDeleted()) { return $this->delete($object); @@ -159,8 +159,7 @@ public function save(\Magento\Core\Model\AbstractModel $object) $matchFields = array('product_id', 'store_id'); - $this->_helperFactory->create()->mergeVisitorProductIndex($this->getMainTable(), $data, $matchFields); - + $this->_resourceHelper->mergeVisitorProductIndex($this->getMainTable(), $data, $matchFields); $this->unserializeFields($object); $this->_afterSave($object); @@ -233,7 +232,7 @@ public function registerIds(\Magento\Object $object, $productIds) $matchFields = array('product_id', 'store_id'); foreach ($data as $row) { - $this->_helperFactory->create()->mergeVisitorProductIndex($this->getMainTable(), $row, $matchFields); + $this->_resourceHelper->mergeVisitorProductIndex($this->getMainTable(), $row, $matchFields); } return $this; } diff --git a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php index 8869328b5bd68..7df5ea0568a5b 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php @@ -256,7 +256,7 @@ public function joinInventoryItem($fields = array()) public function filterByProductType($typeFilter) { if (!is_string($typeFilter) && !is_array($typeFilter)) { - new \Magento\Core\Exception(__('The product type filter specified is incorrect.')); + new \Magento\Model\Exception(__('The product type filter specified is incorrect.')); } $this->addAttributeToFilter('type_id', $typeFilter); return $this; diff --git a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php index 1abcf7617a798..63050477abb0b 100644 --- a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php @@ -75,7 +75,7 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection * @param \Magento\Catalog\Model\Resource\Product\Collection $productResource * @param \Magento\Customer\Model\Resource\Customer $customerResource * @param null $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -85,7 +85,7 @@ public function __construct( \Magento\Catalog\Model\Resource\Product\Collection $productResource, \Magento\Customer\Model\Resource\Customer $customerResource, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_productResource = $productResource; diff --git a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php index a980e3d946eb4..7ba5d1c5fdc6b 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php +++ b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php @@ -34,7 +34,7 @@ */ namespace Magento\Reports\Model\Resource\Report; -abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb +abstract class AbstractReport extends \Magento\Model\Resource\Db\AbstractDb { /** * Flag object diff --git a/app/code/Magento/Reports/Model/Resource/Report/Collection.php b/app/code/Magento/Reports/Model/Resource/Report/Collection.php index f0ca912b42f1b..2da872666f30e 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Collection.php @@ -356,7 +356,7 @@ public function getPageSize() * * @param int $fromDate * @param int $toDate - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ protected function _getReport($fromDate, $toDate) { diff --git a/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php index beceb075268ad..c97674cbe12d4 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php @@ -34,7 +34,7 @@ */ namespace Magento\Reports\Model\Resource\Report\Collection; -class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class AbstractCollection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * From date diff --git a/app/code/Magento/Reports/Model/Resource/Report/Collection/Factory.php b/app/code/Magento/Reports/Model/Resource/Report/Collection/Factory.php index aea1fd6e50424..e448cef0649e0 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Collection/Factory.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Collection/Factory.php @@ -43,7 +43,7 @@ public function __construct(\Magento\ObjectManager $objectManager) * * @param string $className * @param array $arguments - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function create($className, array $arguments = array()) { diff --git a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php index bc2e6b3420bfa..131a567eec21b 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php @@ -57,9 +57,9 @@ class Viewed extends \Magento\Sales\Model\Resource\Report\AbstractReport protected $_productResource; /** - * @var \Magento\Reports\Model\Resource\HelperFactory + * @var \Magento\Reports\Model\Resource\Helper */ - protected $_helperFactory; + protected $_resourceHelper; /** * @param \Magento\App\Resource $resource @@ -69,7 +69,7 @@ class Viewed extends \Magento\Sales\Model\Resource\Report\AbstractReport * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator * @param \Magento\Catalog\Model\Resource\Product $productResource - * @param \Magento\Reports\Model\Resource\HelperFactory $helperFactory + * @param \Magento\Reports\Model\Resource\Helper $resourceHelper */ public function __construct( \Magento\App\Resource $resource, @@ -79,11 +79,11 @@ public function __construct( \Magento\Stdlib\DateTime $dateTime, \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator, \Magento\Catalog\Model\Resource\Product $productResource, - \Magento\Reports\Model\Resource\HelperFactory $helperFactory + \Magento\Reports\Model\Resource\Helper $resourceHelper ) { parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator); $this->_productResource = $productResource; - $this->_helperFactory = $helperFactory; + $this->_resourceHelper = $resourceHelper; } /** @@ -234,10 +234,9 @@ public function aggregate($from = null, $to = null) $insertQuery = $select->insertFromSelect($this->getMainTable(), array_keys($columns)); $adapter->query($insertQuery); - $helper = $this->_helperFactory->create(); - $helper->updateReportRatingPos('day', 'views_num', $mainTable, $this->getTable(self::AGGREGATION_DAILY)); - $helper->updateReportRatingPos('month', 'views_num', $mainTable, $this->getTable(self::AGGREGATION_MONTHLY)); - $helper->updateReportRatingPos('year', 'views_num', $mainTable, $this->getTable(self::AGGREGATION_YEARLY)); + $this->_resourceHelper->updateReportRatingPos('day', 'views_num', $mainTable, $this->getTable(self::AGGREGATION_DAILY)); + $this->_resourceHelper->updateReportRatingPos('month', 'views_num', $mainTable, $this->getTable(self::AGGREGATION_MONTHLY)); + $this->_resourceHelper->updateReportRatingPos('year', 'views_num', $mainTable, $this->getTable(self::AGGREGATION_YEARLY)); $this->_setFlagData(\Magento\Reports\Model\Flag::REPORT_PRODUCT_VIEWED_FLAG_CODE); diff --git a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php index b0a4dfcb80a99..490c5aa0cb4d9 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php @@ -239,7 +239,7 @@ public function addStoreRestrictions($storeIds) * Re-declare parent method for applying filters after parent method, but before adding unions and calculating * totals * - * @return $this|\Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return $this|\Magento\Model\Resource\Db\Collection\AbstractCollection */ protected function _beforeLoad() { diff --git a/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php b/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php index c7ac843caa055..77fdb60fc71a9 100644 --- a/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php @@ -51,7 +51,7 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Resource\Customer $customerResource * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -63,7 +63,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Customer\Model\Resource\Customer $customerResource, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_customerResource = $customerResource; parent::__construct( diff --git a/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php b/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php index bb8f81e783c22..8b1c46d309b7e 100644 --- a/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php @@ -34,7 +34,7 @@ */ namespace Magento\Reports\Model\Resource\Wishlist; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Wishlist table name @@ -55,7 +55,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerResFactory * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -64,7 +64,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerResFactory, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_customerResFactory = $customerResFactory; diff --git a/app/code/Magento/Reports/etc/di.xml b/app/code/Magento/Reports/etc/di.xml index 1304c822160ce..03ef739d0363d 100644 --- a/app/code/Magento/Reports/etc/di.xml +++ b/app/code/Magento/Reports/etc/di.xml @@ -49,4 +49,9 @@ Magento\Reports\Model\Session
+ + + reports + +
diff --git a/app/code/Magento/Reports/etc/module.xml b/app/code/Magento/Reports/etc/module.xml index e14249a2f8a68..ac2e3e0d98770 100644 --- a/app/code/Magento/Reports/etc/module.xml +++ b/app/code/Magento/Reports/etc/module.xml @@ -49,8 +49,6 @@ - -
diff --git a/app/code/Magento/Reports/view/adminhtml/layout/reports_report_review_customer_grid.xml b/app/code/Magento/Reports/view/adminhtml/layout/reports_report_review_customer_grid.xml index dc9c86ad939c0..71ab3265bad8f 100644 --- a/app/code/Magento/Reports/view/adminhtml/layout/reports_report_review_customer_grid.xml +++ b/app/code/Magento/Reports/view/adminhtml/layout/reports_report_review_customer_grid.xml @@ -51,7 +51,7 @@ 0 customers_grid - catalog/product_review + review/product getCustomerId diff --git a/app/code/Magento/Reports/view/adminhtml/layout/reports_report_review_product_grid.xml b/app/code/Magento/Reports/view/adminhtml/layout/reports_report_review_product_grid.xml index 7f6e77c489004..ed9530aa909ce 100644 --- a/app/code/Magento/Reports/view/adminhtml/layout/reports_report_review_product_grid.xml +++ b/app/code/Magento/Reports/view/adminhtml/layout/reports_report_review_product_grid.xml @@ -51,7 +51,7 @@ 0 gridProducts - catalog/product_review + review/product getId diff --git a/app/code/Magento/Review/Block/Adminhtml/Add.php b/app/code/Magento/Review/Block/Adminhtml/Add.php index 1051f83fa413d..760f4ba67f0f5 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Add.php +++ b/app/code/Magento/Review/Block/Adminhtml/Add.php @@ -97,7 +97,7 @@ protected function _construct() } new Ajax.Updater("rating_detail", "' . $this->getUrl( - 'catalog/*/ratingItems' + 'review/product/ratingItems' ) . '", {parameters:params, evalScripts: true, onComplete:function(){ $(\'save_button\').disabled = false; } }); }, @@ -106,7 +106,7 @@ protected function _construct() var response = Ext.util.JSON.decode(o.responseText); if( response.error ) { alert(response.message); - } elseif( response.id ){ + } else if( response.id ){ $("product_id").value = response.id; $("product_name").innerHTML = \'\' + response.name + \'\'; - } elseif ( response.message ) { + } else if ( response.message ) { alert(response.message); } } diff --git a/app/code/Magento/Review/Block/Adminhtml/Add/Form.php b/app/code/Magento/Review/Block/Adminhtml/Add/Form.php index 2adb9f1312a97..22c5586b5dcb5 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Add/Form.php +++ b/app/code/Magento/Review/Block/Adminhtml/Add/Form.php @@ -172,7 +172,7 @@ protected function _prepareForm() $form->setMethod('post'); $form->setUseContainer(true); $form->setId('edit_form'); - $form->setAction($this->getUrl('catalog/*/post')); + $form->setAction($this->getUrl('review/product/post')); $this->setForm($form); } diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit.php b/app/code/Magento/Review/Block/Adminhtml/Edit.php index 9bdd984bd8a57..ad021f2590993 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Edit.php +++ b/app/code/Magento/Review/Block/Adminhtml/Edit.php @@ -96,7 +96,7 @@ protected function _construct() 'previous', array( 'label' => __('Previous'), - 'onclick' => 'setLocation(\'' . $this->getUrl('catalog/*/*', array('id' => $prevId)) . '\')' + 'onclick' => 'setLocation(\'' . $this->getUrl('review/*/*', array('id' => $prevId)) . '\')' ), 3, 10 @@ -145,7 +145,7 @@ protected function _construct() 'next', array( 'label' => __('Next'), - 'onclick' => 'setLocation(\'' . $this->getUrl('catalog/*/*', array('id' => $nextId)) . '\')' + 'onclick' => 'setLocation(\'' . $this->getUrl('review/*/*', array('id' => $nextId)) . '\')' ), 3, 105 @@ -209,7 +209,7 @@ protected function _construct() "rating_detail", "' . $this->getUrl( - 'catalog/*/ratingItems', + 'review/*/ratingItems', array('_current' => true) ) . '", diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php index a3362e1d111e7..58407479827fc 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php +++ b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php @@ -39,11 +39,9 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic protected $_reviewData = null; /** - * Customer model factory - * - * @var \Magento\Customer\Model\CustomerFactory + * @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface */ - protected $_customerFactory; + protected $customerAccount; /** * Catalog product factory @@ -64,7 +62,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory * @param \Magento\Core\Model\System\Store $systemStore - * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccount * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Review\Helper\Data $reviewData * @param array $data @@ -74,13 +72,13 @@ public function __construct( \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, \Magento\Core\Model\System\Store $systemStore, - \Magento\Customer\Model\CustomerFactory $customerFactory, + \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccount, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Review\Helper\Data $reviewData, array $data = array() ) { $this->_reviewData = $reviewData; - $this->_customerFactory = $customerFactory; + $this->customerAccount = $customerAccount; $this->_productFactory = $productFactory; $this->_systemStore = $systemStore; parent::__construct($context, $registry, $formFactory, $data); @@ -95,7 +93,6 @@ protected function _prepareForm() { $review = $this->_coreRegistry->registry('review_data'); $product = $this->_productFactory->create()->load($review->getEntityPkValue()); - $customer = $this->_customerFactory->create()->load($review->getCustomerId()); /** @var \Magento\Data\Form $form */ $form = $this->_formFactory->create( @@ -103,7 +100,7 @@ protected function _prepareForm() 'data' => array( 'id' => 'edit_form', 'action' => $this->getUrl( - 'catalog/*/save', + 'review/*/save', array( 'id' => $this->getRequest()->getParam('id'), 'ret' => $this->_coreRegistry->registry('ret') @@ -133,18 +130,18 @@ protected function _prepareForm() ) ); - if ($customer->getId()) { + try { + $customer = $this->customerAccount->getCustomer($review->getCustomerId()); $customerText = __( '%2 %3 (%4)', - $this->getUrl('customer/index/edit', array('id' => $customer->getId(), 'active_tab' => 'review')), + $this->getUrl('customer/index/edit', array('id' => $customer->getId(), 'active_tab'=>'review')), $this->escapeHtml($customer->getFirstname()), $this->escapeHtml($customer->getLastname()), $this->escapeHtml($customer->getEmail()) ); - } elseif ($review->getStoreId() == \Magento\Core\Model\Store::DEFAULT_STORE_ID) { - $customerText = __('Administrator'); - } else { - $customerText = __('Guest'); + } catch (\Magento\Exception\NoSuchEntityException $e) { + $customerText = ($review->getStoreId() == \Magento\Core\Model\Store::DEFAULT_STORE_ID) + ? __('Administrator') : __('Guest'); } $fieldset->addField('customer', 'note', array('label' => __('Posted By'), 'text' => $customerText)); diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Grid.php index c0f65919ad057..29415b7ba615d 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Review/Block/Adminhtml/Grid.php @@ -307,7 +307,7 @@ protected function _prepareColumns() array( 'caption' => __('Edit'), 'url' => array( - 'base' => 'catalog/product_review/edit', + 'base' => 'review/product/edit', 'params' => array( 'productId' => $this->getProductId(), 'customerId' => $this->getCustomerId(), @@ -383,7 +383,7 @@ protected function _prepareMassaction() public function getRowUrl($row) { return $this->getUrl( - 'catalog/product_review/edit', + 'review/product/edit', array( 'id' => $row->getReviewId(), 'productId' => $this->getProductId(), @@ -402,7 +402,7 @@ public function getGridUrl() { if ($this->getProductId() || $this->getCustomerId()) { return $this->getUrl( - 'catalog/product_review/' . ($this->_coreRegistry->registry('usePendingFilter') ? 'pending' : ''), + 'review/product' . ($this->_coreRegistry->registry('usePendingFilter') ? 'pending' : ''), array('productId' => $this->getProductId(), 'customerId' => $this->getCustomerId()) ); } else { diff --git a/app/code/Magento/Review/Block/Adminhtml/Main.php b/app/code/Magento/Review/Block/Adminhtml/Main.php index 855cdcd4b1fe5..1e2e8e248b083 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Main.php +++ b/app/code/Magento/Review/Block/Adminhtml/Main.php @@ -39,11 +39,9 @@ class Main extends \Magento\Backend\Block\Widget\Grid\Container protected $_coreRegistry = null; /** - * Customer model factory - * - * @var \Magento\Customer\Model\CustomerFactory + * @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface */ - protected $_customerFactory; + protected $customerAccount; /** * Catalog product model factory @@ -54,20 +52,20 @@ class Main extends \Magento\Backend\Block\Widget\Grid\Container /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccount * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Registry $registry * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Customer\Model\CustomerFactory $customerFactory, + \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccount, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Registry $registry, array $data = array() ) { $this->_coreRegistry = $registry; - $this->_customerFactory = $customerFactory; + $this->customerAccount = $customerAccount; $this->_productFactory = $productFactory; parent::__construct($context, $data); } @@ -89,7 +87,7 @@ protected function _construct() $customerId = $this->getRequest()->getParam('customerId', false); $customerName = ''; if ($customerId) { - $customer = $this->_customerFactory->create()->load($customerId); + $customer = $this->customerAccount->getCustomer($customerId); $customerName = $customer->getFirstname() . ' ' . $customer->getLastname(); $customerName = $this->escapeHtml($customerName); } diff --git a/app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php b/app/code/Magento/Review/Block/Adminhtml/Product/Edit/Tab.php similarity index 63% rename from app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php rename to app/code/Magento/Review/Block/Adminhtml/Product/Edit/Tab.php index 41ea96b99747e..b77ee104c0d22 100644 --- a/app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php +++ b/app/code/Magento/Review/Block/Adminhtml/Product/Edit/Tab.php @@ -18,25 +18,25 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Backend * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Backend\Model\Translate\Inline; +namespace Magento\Review\Block\Adminhtml\Product\Edit; -/** - * Backend Inline Translation config factory - */ -class ConfigFactory extends \Magento\Translate\Inline\ConfigFactory +class Tab extends \Magento\Backend\Block\Widget\Tab { /** - * Get instance of inline translate config - * - * @return \Magento\Translate\Inline\ConfigFactory + * @param \Magento\Backend\Block\Template\Context $context + * @param array $data */ - public function get() - { - return $this->_objectManager->get('Magento\Backend\Model\Translate\Inline\Config'); + public function __construct( + \Magento\Backend\Block\Template\Context $context, + array $data = array() + ) { + parent::__construct($context, $data); + + if (!$this->_request->getParam('id') || !$this->_authorization->isAllowed('Magento_Review::reviews_all')) { + $this->setCanShow(false); + } } } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Reviews.php b/app/code/Magento/Review/Block/Adminhtml/Product/Edit/Tab/Reviews.php similarity index 74% rename from app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Reviews.php rename to app/code/Magento/Review/Block/Adminhtml/Product/Edit/Tab/Reviews.php index 2c94e414e3560..825a5a3bf5768 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Reviews.php +++ b/app/code/Magento/Review/Block/Adminhtml/Product/Edit/Tab/Reviews.php @@ -1,5 +1,7 @@ - */ -namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab; +namespace Magento\Review\Block\Adminhtml\Product\Edit\Tab; class Reviews extends \Magento\Review\Block\Adminhtml\Grid { /** * Hide grid mass action elements * - * @return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Reviews + * @return $this */ protected function _prepareMassaction() { @@ -52,6 +44,6 @@ protected function _prepareMassaction() */ public function getGridUrl() { - return $this->getUrl('catalog/*/reviews', array('_current' => true)); + return $this->getUrl('review/product_reviews/grid', array('_current' => true)); } } diff --git a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php index ae63934c0c16d..91e3d9e2266ff 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php @@ -155,7 +155,7 @@ protected function _prepareColumns() */ public function getGridUrl() { - return $this->getUrl('catalog/*/productGrid', array('_current' => true)); + return $this->getUrl('catalog/product/productGrid', array('_current' => true)); } /** @@ -166,7 +166,7 @@ public function getGridUrl() */ public function getRowUrl($row) { - return $this->getUrl('catalog/*/jsonProductInfo', array('id' => $row->getId())); + return $this->getUrl('review/product/jsonProductInfo', array('id' => $row->getId())); } /** diff --git a/app/code/Magento/Review/Block/Customer/View.php b/app/code/Magento/Review/Block/Customer/View.php index 28980596699a3..125bd917c0e38 100644 --- a/app/code/Magento/Review/Block/Customer/View.php +++ b/app/code/Magento/Review/Block/Customer/View.php @@ -79,17 +79,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct protected $currentCustomer; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Review\Model\ReviewFactory $reviewFactory * @param \Magento\Rating\Model\Rating\Option\VoteFactory $voteFactory @@ -97,21 +87,9 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct * @param \Magento\Customer\Service\V1\CustomerCurrentService $currentCustomer * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Review\Model\ReviewFactory $reviewFactory, \Magento\Rating\Model\Rating\Option\VoteFactory $voteFactory, @@ -128,16 +106,6 @@ public function __construct( parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Review/Block/Form.php b/app/code/Magento/Review/Block/Form.php index 4b3e116a6216f..21434fda40b75 100644 --- a/app/code/Magento/Review/Block/Form.php +++ b/app/code/Magento/Review/Block/Form.php @@ -141,7 +141,7 @@ protected function _construct() // add logged in customer name as nickname if (!$data->getNickname()) { - $customer = $this->_customerSession->getCustomer(); + $customer = $this->_customerSession->getCustomerDataObject(); if ($customer && $customer->getId()) { $data->setNickname($customer->getFirstname()); } diff --git a/app/code/Magento/Review/Block/Helper.php b/app/code/Magento/Review/Block/Product/ReviewRenderer.php similarity index 79% rename from app/code/Magento/Review/Block/Helper.php rename to app/code/Magento/Review/Block/Product/ReviewRenderer.php index 46613c506addc..722f5e507dd77 100644 --- a/app/code/Magento/Review/Block/Helper.php +++ b/app/code/Magento/Review/Block/Product/ReviewRenderer.php @@ -1,5 +1,7 @@ - */ -class Helper extends \Magento\View\Element\Template +class ReviewRenderer extends \Magento\View\Element\Template implements ReviewRendererInterface { /** * Array of available template name @@ -42,8 +36,8 @@ class Helper extends \Magento\View\Element\Template * @var array */ protected $_availableTemplates = array( - 'default' => 'helper/summary.phtml', - 'short' => 'helper/summary_short.phtml' + self::DEFAULT_REVIEW => 'helper/summary.phtml', + self::SHORT_REVIEW => 'helper/summary_short.phtml' ); /** @@ -73,13 +67,17 @@ public function __construct( * @param Product $product * @param string $templateType * @param bool $displayIfNoReviews + * * @return string */ - public function getSummaryHtml($product, $templateType, $displayIfNoReviews) - { + public function getReviewsSummaryHtml( + \Magento\Catalog\Model\Product $product, + $templateType = self::DEFAULT_REVIEW, + $displayIfNoReviews = false + ) { // pick template among available if (empty($this->_availableTemplates[$templateType])) { - $templateType = 'default'; + $templateType = self::DEFAULT_REVIEW; } $this->setTemplate($this->_availableTemplates[$templateType]); @@ -125,18 +123,4 @@ public function getReviewsUrl() array('id' => $this->getProduct()->getId(), 'category' => $this->getProduct()->getCategoryId()) ); } - - /** - * Add an available template by type - * - * It should be called before getSummaryHtml() - * - * @param string $type - * @param string $template - * @return void - */ - public function addTemplate($type, $template) - { - $this->_availableTemplates[$type] = $template; - } } diff --git a/app/code/Magento/Review/Block/Product/View.php b/app/code/Magento/Review/Block/Product/View.php index 9ae2a5c2dab43..300b0de852dcd 100644 --- a/app/code/Magento/Review/Block/Product/View.php +++ b/app/code/Magento/Review/Block/Product/View.php @@ -51,17 +51,7 @@ class View extends \Magento\Catalog\Block\Product\View protected $_reviewsColFactory; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Json\EncoderInterface $jsonEncoder * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -73,21 +63,9 @@ class View extends \Magento\Catalog\Block\Product\View * @param \Magento\Review\Model\Resource\Review\CollectionFactory $collectionFactory * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Core\Helper\Data $coreData, \Magento\Json\EncoderInterface $jsonEncoder, \Magento\Catalog\Model\ProductFactory $productFactory, @@ -103,16 +81,6 @@ public function __construct( $this->_reviewsColFactory = $collectionFactory; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $coreData, $jsonEncoder, $productFactory, diff --git a/app/code/Magento/Review/Block/View.php b/app/code/Magento/Review/Block/View.php index f41d4dfc59b49..09c5f44cd002d 100644 --- a/app/code/Magento/Review/Block/View.php +++ b/app/code/Magento/Review/Block/View.php @@ -61,37 +61,15 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct protected $_reviewFactory; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Rating\Model\Rating\Option\VoteFactory $voteFactory * @param \Magento\Rating\Model\RatingFactory $ratingFactory * @param \Magento\Review\Model\ReviewFactory $reviewFactory * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\Rating\Model\Rating\Option\VoteFactory $voteFactory, \Magento\Rating\Model\RatingFactory $ratingFactory, \Magento\Review\Model\ReviewFactory $reviewFactory, @@ -103,16 +81,6 @@ public function __construct( parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Review.php b/app/code/Magento/Review/Controller/Adminhtml/Product.php similarity index 93% rename from app/code/Magento/Catalog/Controller/Adminhtml/Product/Review.php rename to app/code/Magento/Review/Controller/Adminhtml/Product.php index 247ed05130257..233b1fb9121ea 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Review.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product.php @@ -19,16 +19,16 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Adminhtml + * @package Magento_Review * @copyright Copyright (c) 2014 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\Controller\Adminhtml\Product; +namespace Magento\Review\Controller\Adminhtml; /** * Reviews admin controller */ -class Review extends \Magento\Backend\App\Action +class Product extends \Magento\Backend\App\Action { /** * Array of actions which can be processed without secret key validation @@ -181,7 +181,7 @@ public function saveAction() $review->aggregate(); $this->messageManager->addSuccess(__('You saved the review.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong while saving this review.')); @@ -191,11 +191,11 @@ public function saveAction() $nextId = (int)$this->getRequest()->getParam('next_item'); $url = $this->getUrl($this->getRequest()->getParam('ret') == 'pending' ? '*/*/pending' : '*/*/'); if ($nextId) { - $url = $this->getUrl('catalog/*/edit', array('id' => $nextId)); + $url = $this->getUrl('review/*/edit', array('id' => $nextId)); } return $this->getResponse()->setRedirect($url); } - $this->_redirect('catalog/*/'); + $this->_redirect('review/*/'); } /** @@ -209,18 +209,18 @@ public function deleteAction() $this->messageManager->addSuccess(__('The review has been deleted.')); if ($this->getRequest()->getParam('ret') == 'pending') { - $this->getResponse()->setRedirect($this->getUrl('catalog/*/pending')); + $this->getResponse()->setRedirect($this->getUrl('review/*/pending')); } else { - $this->getResponse()->setRedirect($this->getUrl('catalog/*/')); + $this->getResponse()->setRedirect($this->getUrl('review/*/')); } return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong deleting this review.')); } - $this->_redirect('catalog/*/edit/', array('id' => $reviewId)); + $this->_redirect('review/*/edit/', array('id' => $reviewId)); } /** @@ -241,14 +241,14 @@ public function massDeleteAction() $this->messageManager->addSuccess( __('A total of %1 record(s) have been deleted.', count($reviewsIds)) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('An error occurred while deleting record(s).')); } } - $this->_redirect('catalog/*/' . $this->getRequest()->getParam('ret', 'index')); + $this->_redirect('review/*/' . $this->getRequest()->getParam('ret', 'index')); } /** @@ -269,7 +269,7 @@ public function massUpdateStatusAction() $this->messageManager->addSuccess( __('A total of %1 record(s) have been updated.', count($reviewsIds)) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException( @@ -279,7 +279,7 @@ public function massUpdateStatusAction() } } - $this->_redirect('catalog/*/' . $this->getRequest()->getParam('ret', 'index')); + $this->_redirect('review/*/' . $this->getRequest()->getParam('ret', 'index')); } /** @@ -302,7 +302,7 @@ public function massVisibleInAction() $this->messageManager->addSuccess( __('A total of %1 record(s) have been updated.', count($reviewsIds)) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException( @@ -312,7 +312,7 @@ public function massVisibleInAction() } } - $this->_redirect('catalog/*/pending'); + $this->_redirect('review/*/pending'); } /** @@ -401,19 +401,19 @@ public function postAction() $this->messageManager->addSuccess(__('You saved the review.')); if ($this->getRequest()->getParam('ret') == 'pending') { - $this->getResponse()->setRedirect($this->getUrl('catalog/*/pending')); + $this->getResponse()->setRedirect($this->getUrl('review/*/pending')); } else { - $this->getResponse()->setRedirect($this->getUrl('catalog/*/')); + $this->getResponse()->setRedirect($this->getUrl('review/*/')); } return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('An error occurred while saving review.')); } } - $this->getResponse()->setRedirect($this->getUrl('catalog/*/')); + $this->getResponse()->setRedirect($this->getUrl('review/*/')); return; } diff --git a/app/code/Magento/Core/Model/Resource/HelperFactory.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Reviews.php similarity index 51% rename from app/code/Magento/Core/Model/Resource/HelperFactory.php rename to app/code/Magento/Review/Controller/Adminhtml/Product/Reviews.php index beda5d8900694..ace0dc0a0dc32 100644 --- a/app/code/Magento/Core/Model/Resource/HelperFactory.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Reviews.php @@ -1,7 +1,5 @@ _helperPool = $helperPool; + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder + ) { + $this->productBuilder = $productBuilder; + parent::__construct($context); } /** - * Create resource helper instance + * Get product reviews grid * * @return void */ - public function create() + public function gridAction() { - return $this->_helperPool->get($this->_moduleName); + $product = $this->productBuilder->build($this->getRequest()); + $this->_view->loadLayout(); + $this->_view->getLayout()->getBlock('admin.product.reviews') + ->setProductId($product->getId()) + ->setUseAjax(true); + $this->_view->renderLayout(); } } diff --git a/app/code/Magento/Review/Controller/Product.php b/app/code/Magento/Review/Controller/Product.php index 538c1fa334127..75e113fe84a11 100644 --- a/app/code/Magento/Review/Controller/Product.php +++ b/app/code/Magento/Review/Controller/Product.php @@ -224,7 +224,7 @@ protected function _initProduct() 'review_controller_product_init_after', array('product' => $product, 'controller_action' => $this) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_logger->logException($e); return false; } diff --git a/app/code/Magento/Review/Helper/Action/Pager.php b/app/code/Magento/Review/Helper/Action/Pager.php index b38c60ba2bd88..6509a1e97616e 100644 --- a/app/code/Magento/Review/Helper/Action/Pager.php +++ b/app/code/Magento/Review/Helper/Action/Pager.php @@ -25,7 +25,7 @@ */ namespace Magento\Review\Helper\Action; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Action pager helper for iterating over search results diff --git a/app/code/Magento/Review/Model/Resource/Review.php b/app/code/Magento/Review/Model/Resource/Review.php index 52b10def3d5c3..adbd31a2d64a2 100644 --- a/app/code/Magento/Review/Model/Resource/Review.php +++ b/app/code/Magento/Review/Model/Resource/Review.php @@ -25,7 +25,7 @@ */ namespace Magento\Review\Model\Resource; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; /** * Review resource model @@ -34,7 +34,7 @@ * @package Magento_Review * @author Magento Core Team */ -class Review extends \Magento\Core\Model\Resource\Db\AbstractDb +class Review extends \Magento\Model\Resource\Db\AbstractDb { /** * Review table diff --git a/app/code/Magento/Review/Model/Resource/Review/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Collection.php index a33565ef8bab4..450e0955d3770 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Review/Collection.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Review table @@ -103,7 +103,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Rating\Model\Rating\Option\VoteFactory $voteFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -114,7 +114,7 @@ public function __construct( \Magento\Rating\Model\Rating\Option\VoteFactory $voteFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_reviewData = $reviewData; $this->_voteFactory = $voteFactory; diff --git a/app/code/Magento/Review/Model/Resource/Review/Status.php b/app/code/Magento/Review/Model/Resource/Review/Status.php index 5b3d62b4c69f2..9b2340e206253 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Status.php +++ b/app/code/Magento/Review/Model/Resource/Review/Status.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Status extends \Magento\Core\Model\Resource\Db\AbstractDb +class Status extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource status model initialization diff --git a/app/code/Magento/Review/Model/Resource/Review/Status/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Status/Collection.php index e75373a565af3..12a2724fac157 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Status/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Review/Status/Collection.php @@ -33,7 +33,7 @@ */ namespace Magento\Review\Model\Resource\Review\Status; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Review status table diff --git a/app/code/Magento/Review/Model/Resource/Review/Summary.php b/app/code/Magento/Review/Model/Resource/Review/Summary.php index 747af7ea0809b..63a0b3aa92f36 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Summary.php +++ b/app/code/Magento/Review/Model/Resource/Review/Summary.php @@ -25,14 +25,14 @@ */ namespace Magento\Review\Model\Resource\Review; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; /** * Review summary resource model * * @author Magento Core Team */ -class Summary extends \Magento\Core\Model\Resource\Db\AbstractDb +class Summary extends \Magento\Model\Resource\Db\AbstractDb { /** * Define module diff --git a/app/code/Magento/Review/Model/Review.php b/app/code/Magento/Review/Model/Review.php index 0111e1f34a6ac..7df4187ffa780 100644 --- a/app/code/Magento/Review/Model/Review.php +++ b/app/code/Magento/Review/Model/Review.php @@ -46,7 +46,7 @@ * @package Magento_Review * @author Magento Core Team */ -class Review extends \Magento\Core\Model\AbstractModel +class Review extends \Magento\Model\AbstractModel { /** * Event prefix for observer @@ -129,7 +129,7 @@ class Review extends \Magento\Core\Model\AbstractModel * @param \Magento\Review\Model\Review\Summary $reviewSummary * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\UrlInterface $urlModel - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -143,7 +143,7 @@ public function __construct( \Magento\Review\Model\Review\Summary $reviewSummary, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\UrlInterface $urlModel, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -276,7 +276,7 @@ public function validate() /** * Perform actions after object delete * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _afterDeleteCommit() { @@ -325,7 +325,6 @@ public function appendSummary($collection) */ protected function _beforeDelete() { - $this->_protectFromNonAdmin(); return parent::_beforeDelete(); } diff --git a/app/code/Magento/Review/Model/Review/Status.php b/app/code/Magento/Review/Model/Review/Status.php index d4d8fcf1291b5..bda94ce1c46ea 100644 --- a/app/code/Magento/Review/Model/Review/Status.php +++ b/app/code/Magento/Review/Model/Review/Status.php @@ -33,19 +33,19 @@ */ namespace Magento\Review\Model\Review; -class Status extends \Magento\Core\Model\AbstractModel +class Status extends \Magento\Model\AbstractModel { /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Review/Model/Review/Summary.php b/app/code/Magento/Review/Model/Review/Summary.php index 6414fcdb2398f..fb0d5f4ed1e27 100644 --- a/app/code/Magento/Review/Model/Review/Summary.php +++ b/app/code/Magento/Review/Model/Review/Summary.php @@ -28,7 +28,7 @@ /** * Review summary */ -class Summary extends \Magento\Core\Model\AbstractModel +class Summary extends \Magento\Model\AbstractModel { /** * @param \Magento\Model\Context $context diff --git a/app/code/Magento/Review/etc/adminhtml/menu.xml b/app/code/Magento/Review/etc/adminhtml/menu.xml index ebff77dc91f4f..a31a6e7f83f86 100644 --- a/app/code/Magento/Review/etc/adminhtml/menu.xml +++ b/app/code/Magento/Review/etc/adminhtml/menu.xml @@ -28,7 +28,7 @@ - + diff --git a/app/code/Magento/Customer/etc/frontend/events.xml b/app/code/Magento/Review/etc/adminhtml/routes.xml similarity index 78% rename from app/code/Magento/Customer/etc/frontend/events.xml rename to app/code/Magento/Review/etc/adminhtml/routes.xml index 0c456c5fdf2b5..859cc6b8208e1 100644 --- a/app/code/Magento/Customer/etc/frontend/events.xml +++ b/app/code/Magento/Review/etc/adminhtml/routes.xml @@ -23,8 +23,10 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - - - - + + + + + + diff --git a/app/code/Magento/Review/etc/di.xml b/app/code/Magento/Review/etc/di.xml new file mode 100644 index 0000000000000..639abe1f71105 --- /dev/null +++ b/app/code/Magento/Review/etc/di.xml @@ -0,0 +1,35 @@ + + + + + + + + Magento\Review\Model\Review + + + + diff --git a/app/code/Magento/Review/etc/module.xml b/app/code/Magento/Review/etc/module.xml index 9f86ed7ff62d2..27e24a63542e1 100644 --- a/app/code/Magento/Review/etc/module.xml +++ b/app/code/Magento/Review/etc/module.xml @@ -39,8 +39,6 @@ - - diff --git a/app/code/Magento/Review/i18n/de_DE.csv b/app/code/Magento/Review/i18n/de_DE.csv index fd00ded0e34c4..a211543d41ee9 100644 --- a/app/code/Magento/Review/i18n/de_DE.csv +++ b/app/code/Magento/Review/i18n/de_DE.csv @@ -91,3 +91,13 @@ "Your Rating:","Ihre Bewertung:" "Your Review (submitted on %s):","Ihr Review (von % hinzugefügt)" "Your review has been accepted for moderation.","Ihr Review wurde für Moderation akzeptiert." +"An error occurred while deleting this review.","Beim Löschen dieser Rezension ist ein Fehler aufgetreten." +"An error occurred while saving this review.","Beim Speichern der Rezension ist ein Fehler aufgetreten." +"Product Reviews","Produktreviews" +"The review has been deleted","Diese Bewertung wurde gelöscht" +"The review has been saved.","Diese Bewertung wrude gespeichert." +"The review was removed by another user or does not exist.","Diese Bewertung wurde von einem anderen Benutzer entfernt oder existiert nicht." +"Pending Reviews RSS","Ausstehende Kundenmeinungen RSS" +"Products Reviews","Artikelbewertungen" +"Reviews","Bewertungen" +"Customers Reviews","Berichte der Kunden" diff --git a/app/code/Magento/Review/i18n/en_US.csv b/app/code/Magento/Review/i18n/en_US.csv index 367ef415570b3..bcd62bf78c70c 100644 --- a/app/code/Magento/Review/i18n/en_US.csv +++ b/app/code/Magento/Review/i18n/en_US.csv @@ -92,3 +92,13 @@ "Your Rating:","Your Rating:" "Your Review (submitted on %s):","Your Review (submitted on %s):" "Your review has been accepted for moderation.","Your review has been accepted for moderation." +"An error occurred while deleting this review.","An error occurred while deleting this review." +"An error occurred while saving this review.","An error occurred while saving this review." +"The review has been deleted","The review has been deleted" +"The review has been saved.","The review has been saved." +"The review was removed by another user or does not exist.","The review was removed by another user or does not exist." +"Customers Reviews","Customers Reviews" +"Pending Reviews RSS","Pending Reviews RSS" +"Product Reviews","Product Reviews" +"Products Reviews","Products Reviews" +"Reviews","Reviews" diff --git a/app/code/Magento/Review/i18n/es_ES.csv b/app/code/Magento/Review/i18n/es_ES.csv index bbd0019f5c98f..5c28b9230aecb 100644 --- a/app/code/Magento/Review/i18n/es_ES.csv +++ b/app/code/Magento/Review/i18n/es_ES.csv @@ -91,3 +91,13 @@ "Your Rating:","Tu Valoración:" "Your Review (submitted on %s):","Tu Revisión (enviada en %s):" "Your review has been accepted for moderation.","Tu revisión se ha aceptado para ser moderada." +"An error occurred while deleting this review.","Se produjo un error al eliminar esta revisión." +"An error occurred while saving this review.","Se produjo un error al guardar esta revisión." +"The review has been deleted","Se eliminó la reseña" +"The review has been saved.","Se guardó la reseña." +"The review was removed by another user or does not exist.","La reseña no existe o fue eliminada por otro usuario." +"Customers Reviews","Revisiones Personalizadas" +"Pending Reviews RSS","RSS de reseñas pendientes" +"Product Reviews","Opiniones de Producto" +"Products Reviews","Opiniones de Productos" +"Reviews","Reseñas" diff --git a/app/code/Magento/Review/i18n/fr_FR.csv b/app/code/Magento/Review/i18n/fr_FR.csv index be523f8a1039f..ba54b3f394334 100644 --- a/app/code/Magento/Review/i18n/fr_FR.csv +++ b/app/code/Magento/Review/i18n/fr_FR.csv @@ -91,3 +91,13 @@ "Your Rating:","Votre évaluation :" "Your Review (submitted on %s):","Votre avis (envoyé le %s) :" "Your review has been accepted for moderation.","Votre avis a été accepté pour la modération." +"An error occurred while deleting this review.","Une erreur est survenue en effaçant ce commentaire" +"An error occurred while saving this review.","Une erreur est survenue en enregistrant ce commentaire" +"The review has been deleted","Le rapport a été supprimé" +"The review has been saved.","Le rapport a été enregistré." +"The review was removed by another user or does not exist.","Le rapport a été supprimé par un autre utilisateur ou n'existe pas." +"Customers Reviews","Avis des clients" +"Pending Reviews RSS","RSS des avis en attente" +"Product Reviews","Avis sur le produit" +"Products Reviews","Avis sur les produits" +"Reviews","Commentaires" diff --git a/app/code/Magento/Review/i18n/nl_NL.csv b/app/code/Magento/Review/i18n/nl_NL.csv index 9da9f411908a0..44dadffa9f05b 100644 --- a/app/code/Magento/Review/i18n/nl_NL.csv +++ b/app/code/Magento/Review/i18n/nl_NL.csv @@ -91,3 +91,13 @@ "Your Rating:","Uw beoordeling:" "Your Review (submitted on %s):","Uw recensie (verzonden op %s):" "Your review has been accepted for moderation.","Uw beoordeling is geaccepteerd voor evaluatie." +"An error occurred while deleting this review.","Er is een fout opgetreden bij het verwijderen van deze recentie." +"An error occurred while saving this review.","Er is een fout opgetreden bij het opslaan van deze recensie." +"The review has been deleted","De beoordeling is verwijderd" +"The review has been saved.","De beoordeling is opgeslagen." +"The review was removed by another user or does not exist.","De beoordeling werd verwijderd door een andere gebruiker of bestaat niet." +"Customers Reviews","Klantenrecensies" +"Pending Reviews RSS","In Afwachting van Reviews RSS" +"Product Reviews","Productbeoordelingen" +"Products Reviews","Productrecensies" +"Reviews","Reviews" diff --git a/app/code/Magento/Review/i18n/pt_BR.csv b/app/code/Magento/Review/i18n/pt_BR.csv index ea1bf5212acb4..f9714f20faa94 100644 --- a/app/code/Magento/Review/i18n/pt_BR.csv +++ b/app/code/Magento/Review/i18n/pt_BR.csv @@ -91,3 +91,13 @@ "Your Rating:","Sua avaliação:" "Your Review (submitted on %s):","Sua revisão (enviada em %s):" "Your review has been accepted for moderation.","Sua avaliação foi aceita para moderação." +"An error occurred while deleting this review.","Ocorreu um erro ao excluir essa resenha." +"An error occurred while saving this review.","Ocorreu um erro ao salvar a resenha." +"The review has been deleted","A análise foi apagada" +"The review has been saved.","A análise foi salva." +"The review was removed by another user or does not exist.","A análise foi removida por outro usuário ou não existe." +"Customers Reviews","Análises dos clientes" +"Pending Reviews RSS","Comentários RSS Pendentes" +"Product Reviews","Comentários sobre Produto" +"Products Reviews","Comentários sobre Produtos" +"Reviews","Resenhas" diff --git a/app/code/Magento/Review/i18n/zh_CN.csv b/app/code/Magento/Review/i18n/zh_CN.csv index 57907575727fa..b42851ad102d3 100644 --- a/app/code/Magento/Review/i18n/zh_CN.csv +++ b/app/code/Magento/Review/i18n/zh_CN.csv @@ -91,3 +91,13 @@ "Your Rating:","您的评分:" "Your Review (submitted on %s):","您的评测(提交于 %s):" "Your review has been accepted for moderation.","您的评测已被管理员批准。" +"An error occurred while deleting this review.","删除该评论时出错。" +"An error occurred while saving this review.","保存该评论时出错。" +"The review has been deleted","评论已被删除" +"The review has been saved.","评论已保存。" +"The review was removed by another user or does not exist.","评论已被另一用户删除,或评论不存在。" +"Customers Reviews","客户评测" +"Pending Reviews RSS","挂起评测RSS" +"Product Reviews","产品评测" +"Products Reviews","产品评论" +"Reviews","评测" diff --git a/app/code/Magento/Review/view/adminhtml/layout/catalog_product_new.xml b/app/code/Magento/Review/view/adminhtml/layout/catalog_product_new.xml new file mode 100644 index 0000000000000..860ec5d436e25 --- /dev/null +++ b/app/code/Magento/Review/view/adminhtml/layout/catalog_product_new.xml @@ -0,0 +1,43 @@ + + + + + + + Product Reviews + + 1 + + ajax + advanced + + + + product-reviews + product.reviews + + + diff --git a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_review_edit.xml b/app/code/Magento/Review/view/adminhtml/layout/review_product_edit.xml similarity index 95% rename from app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_review_edit.xml rename to app/code/Magento/Review/view/adminhtml/layout/review_product_edit.xml index 302f3a241b86f..bb5469701a503 100644 --- a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_review_edit.xml +++ b/app/code/Magento/Review/view/adminhtml/layout/review_product_edit.xml @@ -24,5 +24,5 @@ */ --> - + diff --git a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_review_new.xml b/app/code/Magento/Review/view/adminhtml/layout/review_product_new.xml similarity index 100% rename from app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_review_new.xml rename to app/code/Magento/Review/view/adminhtml/layout/review_product_new.xml diff --git a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_reviews.xml b/app/code/Magento/Review/view/adminhtml/layout/review_product_reviews_grid.xml similarity index 91% rename from app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_reviews.xml rename to app/code/Magento/Review/view/adminhtml/layout/review_product_reviews_grid.xml index ef4fbea621efd..3ddc307e0874c 100644 --- a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_reviews.xml +++ b/app/code/Magento/Review/view/adminhtml/layout/review_product_reviews_grid.xml @@ -25,6 +25,6 @@ --> - + diff --git a/app/code/Magento/Rss/Block/Catalog/NewCatalog.php b/app/code/Magento/Rss/Block/Catalog/NewCatalog.php index fed6b85d02517..3215e9cc64e31 100644 --- a/app/code/Magento/Rss/Block/Catalog/NewCatalog.php +++ b/app/code/Magento/Rss/Block/Catalog/NewCatalog.php @@ -46,7 +46,7 @@ class NewCatalog extends \Magento\Rss\Block\Catalog\AbstractCatalog protected $_visibility; /** - * @var \Magento\Core\Model\Resource\Iterator + * @var \Magento\Model\Resource\Iterator */ protected $_resourceIterator; @@ -62,7 +62,7 @@ class NewCatalog extends \Magento\Rss\Block\Catalog\AbstractCatalog * @param \Magento\Rss\Model\RssFactory $rssFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Product\Visibility $visibility - * @param \Magento\Core\Model\Resource\Iterator $resourceIterator + * @param \Magento\Model\Resource\Iterator $resourceIterator * @param \Magento\Catalog\Helper\Image $imageHelper * @param array $data */ @@ -73,7 +73,7 @@ public function __construct( \Magento\Rss\Model\RssFactory $rssFactory, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Product\Visibility $visibility, - \Magento\Core\Model\Resource\Iterator $resourceIterator, + \Magento\Model\Resource\Iterator $resourceIterator, \Magento\Catalog\Helper\Image $imageHelper, array $data = array() ) { diff --git a/app/code/Magento/Rss/Block/Catalog/NotifyStock.php b/app/code/Magento/Rss/Block/Catalog/NotifyStock.php index f55d7a3a3bfcd..3f1fa556ab22f 100644 --- a/app/code/Magento/Rss/Block/Catalog/NotifyStock.php +++ b/app/code/Magento/Rss/Block/Catalog/NotifyStock.php @@ -51,7 +51,7 @@ class NotifyStock extends \Magento\Backend\Block\AbstractBlock protected $_productStatus; /** - * @var \Magento\Core\Model\Resource\Iterator + * @var \Magento\Model\Resource\Iterator */ protected $_resourceIterator; @@ -61,7 +61,7 @@ class NotifyStock extends \Magento\Backend\Block\AbstractBlock * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\CatalogInventory\Model\Resource\StockFactory $stockFactory * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $productStatus - * @param \Magento\Core\Model\Resource\Iterator $resourceIterator + * @param \Magento\Model\Resource\Iterator $resourceIterator * @param array $data */ public function __construct( @@ -70,7 +70,7 @@ public function __construct( \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\CatalogInventory\Model\Resource\StockFactory $stockFactory, \Magento\Catalog\Model\Product\Attribute\Source\Status $productStatus, - \Magento\Core\Model\Resource\Iterator $resourceIterator, + \Magento\Model\Resource\Iterator $resourceIterator, array $data = array() ) { $this->_rssFactory = $rssFactory; diff --git a/app/code/Magento/Rss/Block/Catalog/Review.php b/app/code/Magento/Rss/Block/Catalog/Review.php index 2565215203266..6cfe4d18b440e 100644 --- a/app/code/Magento/Rss/Block/Catalog/Review.php +++ b/app/code/Magento/Rss/Block/Catalog/Review.php @@ -36,7 +36,7 @@ class Review extends \Magento\Backend\Block\AbstractBlock protected $_rssFactory; /** - * @var \Magento\Core\Model\Resource\Iterator + * @var \Magento\Model\Resource\Iterator */ protected $_resourceIterator; @@ -53,7 +53,7 @@ class Review extends \Magento\Backend\Block\AbstractBlock /** * @param \Magento\Backend\Block\Context $context * @param \Magento\Rss\Model\RssFactory $rssFactory - * @param \Magento\Core\Model\Resource\Iterator $resourceIterator + * @param \Magento\Model\Resource\Iterator $resourceIterator * @param \Magento\Review\Model\ReviewFactory $reviewFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param array $data @@ -61,7 +61,7 @@ class Review extends \Magento\Backend\Block\AbstractBlock public function __construct( \Magento\Backend\Block\Context $context, \Magento\Rss\Model\RssFactory $rssFactory, - \Magento\Core\Model\Resource\Iterator $resourceIterator, + \Magento\Model\Resource\Iterator $resourceIterator, \Magento\Review\Model\ReviewFactory $reviewFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, array $data = array() @@ -127,7 +127,7 @@ public function addReviewItemXmlCallback($args) array('id' => $row['entity_id']) ); $reviewUrl = $this->getUrl( - 'catalog/product_review/edit/', + 'review/product/edit/', array('id' => $row['review_id'], '_secure' => true, '_nosecret' => true) ); $storeName = $this->_storeManager->getStore($row['store_id'])->getName(); diff --git a/app/code/Magento/Rss/Block/Catalog/Special.php b/app/code/Magento/Rss/Block/Catalog/Special.php index 14dddb1885652..fcd0c1671a743 100644 --- a/app/code/Magento/Rss/Block/Catalog/Special.php +++ b/app/code/Magento/Rss/Block/Catalog/Special.php @@ -48,7 +48,7 @@ class Special extends \Magento\Rss\Block\Catalog\AbstractCatalog protected $_rssFactory; /** - * @var \Magento\Core\Model\Resource\Iterator + * @var \Magento\Model\Resource\Iterator */ protected $_resourceIterator; @@ -74,7 +74,7 @@ class Special extends \Magento\Rss\Block\Catalog\AbstractCatalog * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Rss\Model\RssFactory $rssFactory - * @param \Magento\Core\Model\Resource\Iterator $resourceIterator + * @param \Magento\Model\Resource\Iterator $resourceIterator * @param \Magento\Catalog\Helper\Image $imageHelper * @param \Magento\Catalog\Helper\Output $outputHelper * @param array $data @@ -86,7 +86,7 @@ public function __construct( \Magento\Core\Helper\Data $coreData, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Rss\Model\RssFactory $rssFactory, - \Magento\Core\Model\Resource\Iterator $resourceIterator, + \Magento\Model\Resource\Iterator $resourceIterator, \Magento\Catalog\Helper\Image $imageHelper, \Magento\Catalog\Helper\Output $outputHelper, array $data = array() diff --git a/app/code/Magento/Rss/Block/Order/NewOrder.php b/app/code/Magento/Rss/Block/Order/NewOrder.php index 9b5ccdc4720e2..934626212803f 100644 --- a/app/code/Magento/Rss/Block/Order/NewOrder.php +++ b/app/code/Magento/Rss/Block/Order/NewOrder.php @@ -41,7 +41,7 @@ class NewOrder extends \Magento\Backend\Block\AbstractBlock protected $_orderFactory; /** - * @var \Magento\Core\Model\Resource\Iterator + * @var \Magento\Model\Resource\Iterator */ protected $_resourceIterator; @@ -54,7 +54,7 @@ class NewOrder extends \Magento\Backend\Block\AbstractBlock * @param \Magento\Backend\Block\Context $context * @param \Magento\Rss\Model\RssFactory $rssFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Core\Model\Resource\Iterator $resourceIterator + * @param \Magento\Model\Resource\Iterator $resourceIterator * @param \Magento\Stdlib\DateTime $dateTime * @param array $data */ @@ -62,7 +62,7 @@ public function __construct( \Magento\Backend\Block\Context $context, \Magento\Rss\Model\RssFactory $rssFactory, \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Core\Model\Resource\Iterator $resourceIterator, + \Magento\Model\Resource\Iterator $resourceIterator, \Magento\Stdlib\DateTime $dateTime, array $data = array() ) { diff --git a/app/code/Magento/Rss/Block/Wishlist.php b/app/code/Magento/Rss/Block/Wishlist.php index c423881132f20..e9111f755bebb 100644 --- a/app/code/Magento/Rss/Block/Wishlist.php +++ b/app/code/Magento/Rss/Block/Wishlist.php @@ -34,13 +34,6 @@ */ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock { - /** - * Customer instance - * - * @var \Magento\Customer\Model\Customer - */ - protected $_customer; - /** * Default MAP renderer type * @@ -53,11 +46,6 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock */ protected $_wishlistFactory; - /** - * @var \Magento\Customer\Model\CustomerFactory - */ - protected $_customerFactory; - /** * @var \Magento\Rss\Model\RssFactory */ @@ -74,46 +62,22 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock protected $_outputHelper; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\App\Http\Context $httpContext * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Wishlist\Model\WishlistFactory $wishlistFactory - * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Rss\Model\RssFactory $rssFactory * @param \Magento\Catalog\Helper\Output $outputHelper * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\App\Http\Context $httpContext, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Core\Helper\Data $coreData, \Magento\Wishlist\Model\WishlistFactory $wishlistFactory, - \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Rss\Model\RssFactory $rssFactory, \Magento\Catalog\Helper\Output $outputHelper, array $data = array(), @@ -122,20 +86,9 @@ public function __construct( $this->_outputHelper = $outputHelper; $this->_coreData = $coreData; $this->_wishlistFactory = $wishlistFactory; - $this->_customerFactory = $customerFactory; $this->_rssFactory = $rssFactory; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $httpContext, $productFactory, $data, @@ -151,41 +104,13 @@ public function __construct( protected function _getWishlist() { if (is_null($this->_wishlist)) { - $this->_wishlist = $this->_wishlistFactory->create(); - $wishlistId = $this->getRequest()->getParam('wishlist_id'); - if ($wishlistId) { - $this->_wishlist->load($wishlistId); - if ($this->_wishlist->getCustomerId() != $this->_getCustomer()->getId()) { - $this->_wishlist->unsetData(); - } - } else { - if ($this->_getCustomer()->getId()) { - $this->_wishlist->loadByCustomer($this->_getCustomer()); - } + $this->_wishlist = parent::_getWishlist(); + if ($this->_wishlist->getCustomerId() != $this->_getHelper()->getCustomer()->getId()) { + $this->_wishlist->unsetData(); } } - return $this->_wishlist; - } - - /** - * Retrieve Customer instance - * - * @return \Magento\Customer\Model\Customer - */ - protected function _getCustomer() - { - if (is_null($this->_customer)) { - $this->_customer = $this->_customerFactory->create(); - $params = $this->_coreData->urlDecode($this->getRequest()->getParam('data')); - $data = explode(',', $params); - $cId = abs(intval($data[0])); - if ($cId && ($cId == $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH))) { - $this->_customer->load($cId); - } - } - - return $this->_customer; + return $this->_wishlist; } /** @@ -195,7 +120,7 @@ protected function _getCustomer() */ protected function _getTitle() { - return __('%1\'s Wishlist', $this->_getCustomer()->getName()); + return __('%1\'s Wishlist', $this->_getHelper()->getCustomerName()); } /** diff --git a/app/code/Magento/Rss/Controller/Index.php b/app/code/Magento/Rss/Controller/Index.php index 8cc7819786d49..6192cdb4c84b1 100644 --- a/app/code/Magento/Rss/Controller/Index.php +++ b/app/code/Magento/Rss/Controller/Index.php @@ -30,31 +30,35 @@ class Index extends \Magento\App\Action\Action { /** - * Current wishlist - * - * @var \Magento\Wishlist\Model\Wishlist + * @var \Magento\Core\Model\Store\Config */ - protected $_wishlist; + protected $_storeConfig; /** - * Current customer - * - * @var \Magento\Customer\Model\Customer + * @var \Magento\Rss\Helper\WishlistRss */ - protected $_customer; + protected $_wishlistHelper; /** - * @var \Magento\Core\Model\Store\Config + * @var \Magento\Customer\Model\Session */ - protected $_storeConfig; + protected $_customerSession; /** * @param \Magento\App\Action\Context $context * @param \Magento\Core\Model\Store\Config $storeConfig + * @param \Magento\Rss\Helper\WishlistRss $wishlistHelper + * @param \Magento\Customer\Model\Session $customerSession */ - public function __construct(\Magento\App\Action\Context $context, \Magento\Core\Model\Store\Config $storeConfig) - { + public function __construct( + \Magento\App\Action\Context $context, + \Magento\Core\Model\Store\Config $storeConfig, + \Magento\Rss\Helper\WishlistRss $wishlistHelper, + \Magento\Customer\Model\Session $customerSession + ) { $this->_storeConfig = $storeConfig; + $this->_wishlistHelper = $wishlistHelper; + $this->_customerSession = $customerSession; parent::__construct($context); } @@ -104,12 +108,10 @@ public function nofeedAction() public function wishlistAction() { if ($this->_storeConfig->getConfig('rss/wishlist/active')) { - $wishlist = $this->_getWishlist(); - if ($wishlist && ($wishlist->getVisibility() || $this->_objectManager->get( - 'Magento\Customer\Model\Session' - )->authenticate( - $this - ) && $wishlist->getCustomerId() == $this->_getCustomer()->getId()) + $wishlist = $this->_wishlistHelper->getWishlist(); + if ($wishlist && ($wishlist->getVisibility() + || $this->_customerSession->authenticate($this) + && $wishlist->getCustomerId() == $this->_wishlistHelper->getCustomer()->getId()) ) { $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=UTF-8'); $this->_view->loadLayout(false); @@ -119,51 +121,4 @@ public function wishlistAction() } $this->nofeedAction(); } - - /** - * Retrieve Wishlist model - * - * @return \Magento\Wishlist\Model\Wishlist - */ - protected function _getWishlist() - { - if (is_null($this->_wishlist)) { - $this->_wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist'); - $wishlistId = $this->getRequest()->getParam('wishlist_id'); - if ($wishlistId) { - $this->_wishlist->load($wishlistId); - } else { - if ($this->_getCustomer()->getId()) { - $this->_wishlist->loadByCustomer($this->_getCustomer()); - } - } - } - return $this->_wishlist; - } - - /** - * Retrieve Customer instance - * - * @return \Magento\Customer\Model\Customer - */ - protected function _getCustomer() - { - if (is_null($this->_customer)) { - $this->_customer = $this->_objectManager->create('Magento\Customer\Model\Customer'); - $params = $this->_objectManager->get( - 'Magento\Core\Helper\Data' - )->urlDecode( - $this->getRequest()->getParam('data') - ); - $data = explode(',', $params); - $customerId = abs(intval($data[0])); - if ($customerId && $customerId == $this->_objectManager->get( - 'Magento\Customer\Model\Session' - )->getCustomerId() - ) { - $this->_customer->load($customerId); - } - } - return $this->_customer; - } } diff --git a/app/code/Magento/Rss/Helper/WishlistRss.php b/app/code/Magento/Rss/Helper/WishlistRss.php new file mode 100644 index 0000000000000..e1482ca9db8a7 --- /dev/null +++ b/app/code/Magento/Rss/Helper/WishlistRss.php @@ -0,0 +1,158 @@ +_customerViewHelper = $customerViewHelper; + $this->_customerBuilder = $customerBuilder; + $this->_customerAccountService = $customerAccountService; + + parent::__construct( + $context, + $coreData, + $coreRegistry, + $coreStoreConfig, + $customerSession, + $wishlistFactory, + $storeManager, + $postDataHelper + ); + } + + /** + * Retrieve Wishlist model + * + * @return \Magento\Wishlist\Model\Wishlist + */ + public function getWishlist() + { + if (is_null($this->_wishlist)) { + $this->_wishlist = $this->_wishlistFactory->create(); + + $wishlistId = $this->_getRequest()->getParam('wishlist_id'); + if ($wishlistId) { + $this->_wishlist->load($wishlistId); + } else { + if ($this->getCustomer()->getId()) { + $this->_wishlist->loadByCustomerId($this->getCustomer()->getId()); + } + } + } + return $this->_wishlist; + } + + /** + * Retrieve Customer instance + * + * @return \Magento\Customer\Service\V1\Data\Customer + */ + public function getCustomer() + { + if (is_null($this->_customer)) { + $this->_customer = $this->_customerBuilder->create(); + + $params = $this->_coreData->urlDecode($this->_getRequest()->getParam('data')); + $data = explode(',', $params); + $cId = abs(intval($data[0])); + if ($cId && ($cId == $this->_customerSession->getCustomerId())) { + $this->_customer = $this->_customerSession->getCustomerDataObject(); + } + } + + return $this->_customer; + } + + /** + * Set current customer + * + * @param \Magento\Customer\Model\Customer $customer + * @return void + */ + public function setCustomer(\Magento\Customer\Model\Customer $customer) + { + /* TODO this method must be eliminated after refactoring of Magento\Wishlist\Helper\Data */ + $this->_customer = $this->_customerAccountService->getCustomer($customer->getId()); + } + + /** + * Retrieve customer name + * + * @return string|void + */ + public function getCustomerName() + { + /* TODO this method must be eliminated after refactoring of Magento\Wishlist\Helper\Data */ + return $this->getCustomer() + ? $this->_customerViewHelper->getCustomerName($this->getCustomer()) + : null; + } +} 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 17aa62d2a903d..ae9e2fe2b5211 100644 --- a/app/code/Magento/Rss/Model/System/Config/Backend/Links.php +++ b/app/code/Magento/Rss/Model/System/Config/Backend/Links.php @@ -42,7 +42,7 @@ class Links extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\App\Cache\TypeListInterface $cacheTypeList - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -52,7 +52,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\App\Cache\TypeListInterface $cacheTypeList, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Rss/etc/di.xml b/app/code/Magento/Rss/etc/di.xml new file mode 100644 index 0000000000000..02f7ed6ff5b88 --- /dev/null +++ b/app/code/Magento/Rss/etc/di.xml @@ -0,0 +1,37 @@ + + + + + + Magento\Rss\Helper\WishlistRss + + + + + Magento\Rss\Block\Context + + + diff --git a/app/code/Magento/Rss/etc/module.xml b/app/code/Magento/Rss/etc/module.xml index b9e2def7231b8..774ccf502fc9a 100644 --- a/app/code/Magento/Rss/etc/module.xml +++ b/app/code/Magento/Rss/etc/module.xml @@ -36,7 +36,6 @@ - @@ -46,8 +45,6 @@ - - diff --git a/app/code/Magento/Rule/Block/Editable.php b/app/code/Magento/Rule/Block/Editable.php index a8483602bfcac..c7bc0ec4c6653 100644 --- a/app/code/Magento/Rule/Block/Editable.php +++ b/app/code/Magento/Rule/Block/Editable.php @@ -30,6 +30,25 @@ class Editable extends AbstractBlock implements RendererInterface { + /** + * @var \Magento\Translate\InlineInterface + */ + protected $inlineTranslate; + + /** + * @param \Magento\View\Element\Context $context + * @param \Magento\Translate\InlineInterface $inlineTranslate + * @param array $data + */ + public function __construct( + \Magento\View\Element\Context $context, + \Magento\Translate\InlineInterface $inlineTranslate, + array $data = array() + ) { + $this->inlineTranslate = $inlineTranslate; + parent::__construct($context, $data); + } + /** * Render element * @@ -66,7 +85,7 @@ public function render(\Magento\Data\Form\Element\AbstractElement $element) '>' . ''; - if ($this->_translator->isAllowed()) { + if ($this->inlineTranslate->isAllowed()) { $html .= $this->escapeHtml($valueName); } else { $html .= $this->escapeHtml( diff --git a/app/code/Magento/Rule/Model/AbstractModel.php b/app/code/Magento/Rule/Model/AbstractModel.php index 7f1c63d3eb7e3..9bc2dfc83ea09 100644 --- a/app/code/Magento/Rule/Model/AbstractModel.php +++ b/app/code/Magento/Rule/Model/AbstractModel.php @@ -29,9 +29,9 @@ */ namespace Magento\Rule\Model; -use Magento\Core\Exception; +use Magento\Model\Exception; -abstract class AbstractModel extends \Magento\Core\Model\AbstractModel +abstract class AbstractModel extends \Magento\Model\AbstractModel { /** * Store rule combine conditions model @@ -97,7 +97,7 @@ abstract public function getActionsInstance(); * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -106,7 +106,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Rule/Model/Resource/AbstractResource.php b/app/code/Magento/Rule/Model/Resource/AbstractResource.php index ed4a7ecdb8b73..4f40d7c80017c 100644 --- a/app/code/Magento/Rule/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Rule/Model/Resource/AbstractResource.php @@ -33,7 +33,7 @@ */ namespace Magento\Rule\Model\Resource; -abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\AbstractDb +abstract class AbstractResource extends \Magento\Model\Resource\Db\AbstractDb { /** * Store associated with rule entities information map @@ -60,10 +60,10 @@ abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\Abstract /** * Prepare rule's active "from" and "to" dates * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - public function _beforeSave(\Magento\Core\Model\AbstractModel $object) + public function _beforeSave(\Magento\Model\AbstractModel $object) { $fromDate = $object->getFromDate(); if ($fromDate instanceof \Zend_Date) { @@ -241,7 +241,7 @@ public function getCustomerGroupIds($ruleId) * * @param string $entityType * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getAssociatedEntityInfo($entityType) { @@ -249,7 +249,7 @@ protected function _getAssociatedEntityInfo($entityType) return $this->_associatedEntitiesMap[$entityType]; } - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('There is no information about associated entity type "%1".', $entityType), 0 ); diff --git a/app/code/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollection.php b/app/code/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollection.php index eb35698a09ca3..d084d1e7fac67 100644 --- a/app/code/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollection.php +++ b/app/code/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollection.php @@ -33,7 +33,7 @@ */ namespace Magento\Rule\Model\Resource\Rule\Collection; -abstract class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +abstract class AbstractCollection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Store associated with rule entities information map @@ -165,7 +165,7 @@ public function addIsActiveFilter($isActive = 1) * * @param string $entityType * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return array */ protected function _getAssociatedEntityInfo($entityType) @@ -174,7 +174,7 @@ protected function _getAssociatedEntityInfo($entityType) return $this->_associatedEntitiesMap[$entityType]; } - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('There is no information about associated entity type "%1".', $entityType), 0 ); diff --git a/app/code/Magento/Rule/Model/Rule.php b/app/code/Magento/Rule/Model/Rule.php index e6b521573f09f..5f481782b72ff 100644 --- a/app/code/Magento/Rule/Model/Rule.php +++ b/app/code/Magento/Rule/Model/Rule.php @@ -54,7 +54,7 @@ class Rule extends AbstractModel * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Rule\Model\Condition\CombineFactory $conditionsFactory * @param \Magento\Rule\Model\Action\CollectionFactory $actionsFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -65,7 +65,7 @@ public function __construct( \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Rule\Model\Condition\CombineFactory $conditionsFactory, \Magento\Rule\Model\Action\CollectionFactory $actionsFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Block/Adminhtml/Items/AbstractItems.php b/app/code/Magento/Sales/Block/Adminhtml/Items/AbstractItems.php index 965c94c12ba23..3bff3d51549bf 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Items/AbstractItems.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Items/AbstractItems.php @@ -215,7 +215,7 @@ public function getCreditmemo() /** * Retrieve available order * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return Order */ public function getOrder() @@ -239,7 +239,7 @@ public function getOrder() return $this->getItem()->getOrder(); } - throw new \Magento\Core\Exception(__('We cannot get the order instance.')); + throw new \Magento\Model\Exception(__('We cannot get the order instance.')); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/AbstractOrder.php b/app/code/Magento/Sales/Block/Adminhtml/Order/AbstractOrder.php index 8f2d9ae6c6e9b..e466a42338430 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/AbstractOrder.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/AbstractOrder.php @@ -71,7 +71,7 @@ public function __construct( * Retrieve available order * * @return Order - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getOrder() { @@ -84,7 +84,7 @@ public function getOrder() if ($this->_coreRegistry->registry('order')) { return $this->_coreRegistry->registry('order'); } - throw new \Magento\Core\Exception(__('We cannot get the order instance.')); + throw new \Magento\Model\Exception(__('We cannot get the order instance.')); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Comments/View.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Comments/View.php index 14d45c7a377d9..6dde7fa2bc1f8 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Comments/View.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Comments/View.php @@ -59,12 +59,12 @@ public function __construct( * Retrieve required options from parent * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeToHtml() { if (!$this->getParentBlock()) { - throw new \Magento\Core\Exception(__('Please correct the parent block for this block.')); + throw new \Magento\Model\Exception(__('Please correct the parent block for this block.')); } $this->setEntity($this->getParentBlock()->getSource()); parent::_beforeToHtml(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Payment.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Payment.php index 9f04c0b77760c..5bf0e5b9506e5 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Payment.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Payment.php @@ -61,12 +61,12 @@ public function __construct( * Retrieve required options from parent * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeToHtml() { if (!$this->getParentBlock()) { - throw new \Magento\Core\Exception(__('Invalid parent block for this block')); + throw new \Magento\Model\Exception(__('Invalid parent block for this block')); } $this->setPayment($this->getParentBlock()->getOrder()->getPayment()); parent::_beforeToHtml(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Totalbar.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Totalbar.php index c0c0a375b6e5f..1c0d0cb5ee6cf 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Totalbar.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Totalbar.php @@ -45,12 +45,12 @@ class Totalbar extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder * Retrieve required options from parent * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeToHtml() { if (!$this->getParentBlock()) { - throw new \Magento\Core\Exception(__('Please correct the parent block for this block.')); + throw new \Magento\Model\Exception(__('Please correct the parent block for this block.')); } $this->setOrder($this->getParentBlock()->getOrder()); $this->setSource($this->getParentBlock()->getSource()); 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 00025662678f8..b77f9d95a7bee 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php @@ -84,7 +84,7 @@ public function __construct( protected function _beforeToHtml() { if (!$this->getParentBlock()) { - throw new \Magento\Core\Exception(__('Please correct the parent block for this block.')); + throw new \Magento\Model\Exception(__('Please correct the parent block for this block.')); } $this->setOrder($this->getParentBlock()->getOrder()); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Items.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Items.php index fbae50084030e..546cae95121f4 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Items.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Items.php @@ -40,12 +40,12 @@ class Items extends \Magento\Sales\Block\Adminhtml\Items\AbstractItems * Retrieve required options from parent * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeToHtml() { if (!$this->getParentBlock()) { - throw new \Magento\Core\Exception(__('Invalid parent block for this block')); + throw new \Magento\Model\Exception(__('Invalid parent block for this block')); } $this->setOrder($this->getParentBlock()->getOrder()); parent::_beforeToHtml(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tabs.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tabs.php index f4e120ad35b24..50e1d91b0ddb7 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tabs.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tabs.php @@ -59,7 +59,7 @@ public function __construct( * Retrieve available order * * @return \Magento\Sales\Model\Order - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getOrder() { @@ -72,7 +72,7 @@ public function getOrder() if ($this->_coreRegistry->registry('order')) { return $this->_coreRegistry->registry('order'); } - throw new \Magento\Core\Exception(__('We cannot get the order instance.')); + throw new \Magento\Model\Exception(__('We cannot get the order instance.')); } /** diff --git a/app/code/Magento/Sales/Block/Order/Comments.php b/app/code/Magento/Sales/Block/Order/Comments.php index 9b2de31ac6d16..e0758c0f67846 100644 --- a/app/code/Magento/Sales/Block/Order/Comments.php +++ b/app/code/Magento/Sales/Block/Order/Comments.php @@ -104,7 +104,7 @@ public function getEntity() * Initialize model comments and return comment collection * * @return \Magento\Sales\Model\Resource\Order\Comment\Collection\AbstractCollection - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getComments() { @@ -117,7 +117,7 @@ public function getComments() } else if ($entity instanceof \Magento\Sales\Model\Order\Shipment) { $this->_commentCollection = $this->_shipmentCollectionFactory->create(); } else { - throw new \Magento\Core\Exception(__('We found an invalid entity model.')); + throw new \Magento\Model\Exception(__('We found an invalid entity model.')); } $this->_commentCollection->setParentFilter($entity)->setCreatedAtOrder()->addVisibleOnFrontFilter(); diff --git a/app/code/Magento/Sales/Controller/AbstractController.php b/app/code/Magento/Sales/Controller/AbstractController.php index 9ab3515718b75..414c185b3f58d 100644 --- a/app/code/Magento/Sales/Controller/AbstractController.php +++ b/app/code/Magento/Sales/Controller/AbstractController.php @@ -174,7 +174,7 @@ public function reorderAction() foreach ($items as $item) { try { $cart->addOrderItem($item); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if ($this->_objectManager->get('Magento\Checkout\Model\Session')->getUseNotice(true)) { $this->messageManager->addNotice($e->getMessage()); } else { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order.php b/app/code/Magento/Sales/Controller/Adminhtml/Order.php index 6e3b72af35af3..d6d3ef3eff4ea 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order.php @@ -193,7 +193,7 @@ public function emailAction() $historyItem->save(); } $this->messageManager->addSuccess(__('You sent the order email.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We couldn\'t send the email order.')); @@ -215,7 +215,7 @@ public function cancelAction() try { $order->cancel()->save(); $this->messageManager->addSuccess(__('You canceled the order.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('You have not canceled the item.')); @@ -237,7 +237,7 @@ public function holdAction() try { $order->hold()->save(); $this->messageManager->addSuccess(__('You put the order on hold.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('You have not put the order on hold.')); @@ -258,7 +258,7 @@ public function unholdAction() try { $order->unhold()->save(); $this->messageManager->addSuccess(__('You released the order from holding status.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('The order was not on hold.')); @@ -303,7 +303,7 @@ public function reviewPaymentAction() } $order->save(); $this->messageManager->addSuccess($message); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We couldn\'t update the payment.')); @@ -325,7 +325,7 @@ public function addCommentAction() $response = false; $data = $this->getRequest()->getPost('history'); if (empty($data['comment']) && $data['status'] == $order->getDataByKey('status')) { - throw new \Magento\Core\Exception(__('Comment text cannot be empty.')); + throw new \Magento\Model\Exception(__('Comment text cannot be empty.')); } $notify = isset($data['is_customer_notified']) ? $data['is_customer_notified'] : false; @@ -343,7 +343,7 @@ public function addCommentAction() $this->_view->loadLayout('empty'); $this->_view->renderLayout(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $response = array('error' => true, 'message' => $e->getMessage()); } catch (\Exception $e) { $response = array('error' => true, 'message' => __('We cannot add order history.')); @@ -404,12 +404,13 @@ public function creditmemosAction() public function commentsHistoryAction() { $this->_initOrder(); + $html = $this->_view->getLayout()->createBlock( 'Magento\Sales\Block\Adminhtml\Order\View\Tab\History' )->toHtml(); - if ($this->_translateInline->isAllowed()) { - $this->_translateInline->processResponseBody($html); - } + + $this->_translateInline->processResponseBody($html); + $this->getResponse()->setBody($html); } @@ -806,7 +807,7 @@ public function voidPaymentAction() $order->getPayment()->void(new \Magento\Object()); // workaround for backwards compatibility $order->save(); $this->messageManager->addSuccess(__('The payment has been voided.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We couldn\'t void the payment.')); @@ -944,7 +945,7 @@ public function addressSaveAction() $this->messageManager->addSuccess(__('You updated the order address.')); $this->_redirect('sales/*/view', array('order_id' => $address->getParentId())); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong updating the order address.')); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php index 72cc8b8e9e01a..21a9e334b123a 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php @@ -391,7 +391,7 @@ public function loadBlockAction() $request = $this->getRequest(); try { $this->_initSession()->_processData(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_reloadQuote(); $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { @@ -530,7 +530,7 @@ public function saveAction() $this->messageManager->addError($message); } $this->_redirect('sales/*/'); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $message = $e->getMessage(); if (!empty($message)) { $this->messageManager->addError($message); @@ -618,12 +618,12 @@ public function configureQuoteItemsAction() try { $quoteItemId = (int)$this->getRequest()->getParam('id'); if (!$quoteItemId) { - throw new \Magento\Core\Exception(__('Quote item id is not received.')); + throw new \Magento\Model\Exception(__('Quote item id is not received.')); } $quoteItem = $this->_objectManager->create('Magento\Sales\Model\Quote\Item')->load($quoteItemId); if (!$quoteItem->getId()) { - throw new \Magento\Core\Exception(__('Quote item is not loaded.')); + throw new \Magento\Model\Exception(__('Quote item is not loaded.')); } $configureResult->setOk(true); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo.php index 5a38afab99705..853b135d7d9bc 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo.php @@ -189,7 +189,7 @@ protected function _initCreditmemo($update = false) protected function _saveCreditmemo($creditmemo) { $transactionSave = $this->_objectManager->create( - 'Magento\Core\Model\Resource\Transaction' + 'Magento\DB\Transaction' )->addObject( $creditmemo )->addObject( @@ -281,7 +281,7 @@ public function updateQtyAction() $creditmemo = $this->_initCreditmemo(true); $this->_view->loadLayout(); $response = $this->_view->getLayout()->getBlock('order_items')->toHtml(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $response = array('error' => true, 'message' => $e->getMessage()); $response = $this->_objectManager->get('Magento\Core\Helper\Data')->jsonEncode($response); } catch (\Exception $e) { @@ -307,7 +307,7 @@ public function saveAction() $creditmemo = $this->_initCreditmemo(); if ($creditmemo) { if ($creditmemo->getGrandTotal() <= 0 && !$creditmemo->getAllowZeroGrandTotal()) { - throw new \Magento\Core\Exception(__('Credit memo\'s total must be positive.')); + throw new \Magento\Model\Exception(__('Credit memo\'s total must be positive.')); } $comment = ''; @@ -328,7 +328,7 @@ public function saveAction() if (isset($data['do_offline'])) { //do not allow online refund for Refund to Store Credit if (!$data['do_offline'] && !empty($data['refund_customerbalance_return_enable'])) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Cannot create online refund for Refund to Store Credit.') ); } @@ -351,7 +351,7 @@ public function saveAction() $this->_forward('noroute'); return; } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_getSession()->setFormData($data); } catch (\Exception $e) { @@ -374,7 +374,7 @@ public function cancelAction() $creditmemo->cancel(); $this->_saveCreditmemo($creditmemo); $this->messageManager->addSuccess(__('The credit memo has been canceled.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('You canceled the credit memo.')); @@ -398,7 +398,7 @@ public function voidAction() $creditmemo->void(); $this->_saveCreditmemo($creditmemo); $this->messageManager->addSuccess(__('You voided the credit memo.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t void the credit memo.')); @@ -420,7 +420,7 @@ public function addCommentAction() $this->getRequest()->setParam('creditmemo_id', $this->getRequest()->getParam('id')); $data = $this->getRequest()->getPost('comment'); if (empty($data['comment'])) { - throw new \Magento\Core\Exception(__('The Comment Text field cannot be empty.')); + throw new \Magento\Model\Exception(__('The Comment Text field cannot be empty.')); } $creditmemo = $this->_initCreditmemo(); $comment = $creditmemo->addComment( @@ -433,7 +433,7 @@ public function addCommentAction() $this->_view->loadLayout(); $response = $this->_view->getLayout()->getBlock('creditmemo_comments')->toHtml(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $response = array('error' => true, 'message' => $e->getMessage()); $response = $this->_objectManager->get('Magento\Core\Helper\Data')->jsonEncode($response); } catch (\Exception $e) { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Edit.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Edit.php index e8e75d824710d..7dade411b172f 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Edit.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Edit.php @@ -53,7 +53,7 @@ public function startAction() } else { $this->_redirect('sales/order/'); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect('sales/order/view', array('order_id' => $orderId)); } catch (\Exception $e) { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice.php index cafabffeb0188..ad7039a40c6ee 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice.php @@ -25,7 +25,7 @@ */ namespace Magento\Sales\Controller\Adminhtml\Order; -use Magento\Core\Exception; +use Magento\Model\Exception; use Magento\App\ResponseInterface; /** @@ -141,7 +141,7 @@ protected function _saveInvoice($invoice) { $invoice->getOrder()->setIsInProcess(true); $this->_objectManager->create( - 'Magento\Core\Model\Resource\Transaction' + 'Magento\DB\Transaction' )->addObject( $invoice )->addObject( @@ -311,7 +311,7 @@ public function saveAction() $invoice->getOrder()->setIsInProcess(true); $transactionSave = $this->_objectManager->create( - 'Magento\Core\Model\Resource\Transaction' + 'Magento\DB\Transaction' )->addObject( $invoice )->addObject( diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status.php index 05f35dca12f0b..388e532cf3c6c 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status.php @@ -160,7 +160,7 @@ public function saveAction() $this->messageManager->addSuccess(__('You have saved the order status.')); $this->_redirect('sales/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException( @@ -211,7 +211,7 @@ public function assignPostAction() $this->messageManager->addSuccess(__('You have assigned the order status.')); $this->_redirect('sales/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException( @@ -239,7 +239,7 @@ public function unassignAction() try { $status->unassignState($state); $this->messageManager->addSuccess(__('You have unassigned the order status.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException( diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/View/Giftmessage.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/View/Giftmessage.php index 77628119757a5..6866b1c135d53 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/View/Giftmessage.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/View/Giftmessage.php @@ -43,7 +43,7 @@ public function saveAction() $this->_getGiftmessageSaveModel()->setGiftmessages( $this->getRequest()->getParam('giftmessage') )->saveAllInOrder(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Something went wrong while saving the gift message.')); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Transactions.php b/app/code/Magento/Sales/Controller/Adminhtml/Transactions.php index e747db34f6a17..8f7853a633296 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Transactions.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Transactions.php @@ -136,7 +136,7 @@ public function fetchAction() $txn->getOrderPaymentObject()->setOrder($txn->getOrder())->importTransactionInfo($txn); $txn->save(); $this->messageManager->addSuccess(__('The transaction details have been updated.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t update the transaction details.')); diff --git a/app/code/Magento/Sales/Helper/Admin.php b/app/code/Magento/Sales/Helper/Admin.php index 234283fb91763..116b145a9150e 100644 --- a/app/code/Magento/Sales/Helper/Admin.php +++ b/app/code/Magento/Sales/Helper/Admin.php @@ -113,8 +113,8 @@ public function displayPrices($dataObject, $basePrice, $price, $strong = false, /** * Filter collection by removing not available product types * - * @param \Magento\Core\Model\Resource\Db\Collection\AbstractCollection $collection - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @param \Magento\Model\Resource\Db\Collection\AbstractCollection $collection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function applySalableProductTypesFilter($collection) { diff --git a/app/code/Magento/Sales/Model/AbstractModel.php b/app/code/Magento/Sales/Model/AbstractModel.php index 7b51ce6f07566..16c30c276efe1 100644 --- a/app/code/Magento/Sales/Model/AbstractModel.php +++ b/app/code/Magento/Sales/Model/AbstractModel.php @@ -29,7 +29,7 @@ * Sales abstract model * Provide date processing functionality */ -abstract class AbstractModel extends \Magento\Core\Model\AbstractModel +abstract class AbstractModel extends \Magento\Model\AbstractModel { /** * @var \Magento\Stdlib\DateTime\TimezoneInterface @@ -46,7 +46,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -55,7 +55,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 3d1309109dcb3..913e4599f73f5 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -383,7 +383,7 @@ public function setQuote(\Magento\Sales\Model\Quote $quote) * * @param \Magento\Sales\Model\Order $order * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function initFromOrder(\Magento\Sales\Model\Order $order) { @@ -407,7 +407,7 @@ public function initFromOrder(\Magento\Sales\Model\Order $order) if ($qty > 0) { $item = $this->initFromOrderItem($orderItem, $qty); if (is_string($item)) { - throw new \Magento\Core\Exception($item); + throw new \Magento\Model\Exception($item); } } } @@ -583,7 +583,7 @@ public function getCustomerWishlist($cacheReload = false) $customerId = (int)$this->getSession()->getCustomerId(); if ($customerId) { $this->_wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist'); - $this->_wishlist->loadByCustomer($customerId, true); + $this->_wishlist->loadByCustomerId($customerId, true); $this->_wishlist->setStore( $this->getSession()->getStore() )->setSharedStoreIds( @@ -662,7 +662,7 @@ public function getCustomerGroupId() * @param string $moveTo * @param int $qty * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function moveQuoteItem($item, $moveTo, $qty) { @@ -687,7 +687,7 @@ public function moveQuoteItem($item, $moveTo, $qty) $newItem = $this->getQuote()->addProduct($product, $info); if (is_string($newItem)) { - throw new \Magento\Core\Exception($newItem); + throw new \Magento\Model\Exception($newItem); } $product->unsSkipCheckRequiredOption(); $newItem->checkData(); @@ -722,7 +722,7 @@ public function moveQuoteItem($item, $moveTo, $qty) $cartItem = $cart->addProduct($product, $info); if (is_string($cartItem)) { - throw new \Magento\Core\Exception($cartItem); + throw new \Magento\Model\Exception($cartItem); } $cartItem->setPrice($item->getProduct()->getPrice()); $this->_needCollectCart = true; @@ -734,7 +734,7 @@ public function moveQuoteItem($item, $moveTo, $qty) if (!isset($moveTo[1])) { $wishlist = $this->_objectManager->create( 'Magento\Wishlist\Model\Wishlist' - )->loadByCustomer( + )->loadByCustomerId( $this->getSession()->getCustomerId(), true ); @@ -746,7 +746,7 @@ public function moveQuoteItem($item, $moveTo, $qty) } } if (!$wishlist) { - throw new \Magento\Core\Exception(__('We couldn\'t find this wish list.')); + throw new \Magento\Model\Exception(__('We couldn\'t find this wish list.')); } $wishlist->setStore( $this->getSession()->getStore() @@ -786,7 +786,7 @@ public function moveQuoteItem($item, $moveTo, $qty) * * @param array $data * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function applySidebarData($data) { @@ -796,7 +796,7 @@ public function applySidebarData($data) $orderItem = $this->_objectManager->create('Magento\Sales\Model\Order\Item')->load($orderItemId); $item = $this->initFromOrderItem($orderItem); if (is_string($item)) { - throw new \Magento\Core\Exception($item); + throw new \Magento\Model\Exception($item); } } } @@ -893,7 +893,7 @@ public function removeQuoteItem($item) * @param int|\Magento\Catalog\Model\Product $product * @param array|float|int|\Magento\Object $config * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addProduct($product, $config = 1) { @@ -914,7 +914,7 @@ public function addProduct($product, $config = 1) $product ); if (!$product->getId()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We could not add a product to cart by the ID "%1".', $productId) ); } @@ -923,7 +923,7 @@ public function addProduct($product, $config = 1) $item = $this->quoteInitializer->init($this->getQuote(), $product, $config); if (is_string($item)) { - throw new \Magento\Core\Exception($item); + throw new \Magento\Model\Exception($item); } $item->checkData(); @@ -943,7 +943,7 @@ public function addProducts(array $products) $config['qty'] = isset($config['qty']) ? (double)$config['qty'] : 1; try { $this->addProduct($productId, $config); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { return $e; @@ -957,7 +957,7 @@ public function addProducts(array $products) * * @param array $data * @return $this - * @throws \Exception|\Magento\Core\Exception + * @throws \Exception|\Magento\Model\Exception */ public function updateQuoteItems($data) { @@ -1002,7 +1002,7 @@ public function updateQuoteItems($data) } } } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->recollectCart(); throw $e; } catch (\Exception $e) { @@ -1019,7 +1019,7 @@ public function updateQuoteItems($data) * @param \Magento\Sales\Model\Quote\Item $item * @param string $additionalOptions * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _parseOptions(\Magento\Sales\Model\Quote\Item $item, $additionalOptions) { @@ -1036,11 +1036,11 @@ protected function _parseOptions(\Magento\Sales\Model\Quote\Item $item, $additio if (strlen(trim($_additionalOption))) { try { if (strpos($_additionalOption, ':') === false) { - throw new \Magento\Core\Exception(__('There is an error in one of the option rows.')); + throw new \Magento\Model\Exception(__('There is an error in one of the option rows.')); } list($label, $value) = explode(':', $_additionalOption, 2); } catch (\Exception $e) { - throw new \Magento\Core\Exception(__('There is an error in one of the option rows.')); + throw new \Magento\Model\Exception(__('There is an error in one of the option rows.')); } $label = trim($label); $value = trim($value); @@ -1804,17 +1804,17 @@ public function createOrder() * Validate quote data before order creation * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _validate() { $customerId = $this->getSession()->getCustomerId(); if (is_null($customerId)) { - throw new \Magento\Core\Exception(__('Please select a customer.')); + throw new \Magento\Model\Exception(__('Please select a customer.')); } if (!$this->getSession()->getStore()->getId()) { - throw new \Magento\Core\Exception(__('Please select a store.')); + throw new \Magento\Model\Exception(__('Please select a store.')); } $items = $this->getQuote()->getAllItems(); @@ -1847,7 +1847,7 @@ protected function _validate() } else { try { $method->validate(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_errors[] = $e->getMessage(); } } @@ -1857,7 +1857,7 @@ protected function _validate() foreach ($this->_errors as $error) { $this->messageManager->addError($error); } - throw new \Magento\Core\Exception(''); + throw new \Magento\Model\Exception(''); } return $this; } diff --git a/app/code/Magento/Sales/Model/Config/Ordered.php b/app/code/Magento/Sales/Model/Config/Ordered.php index 57876cde80f95..15085604d78d6 100644 --- a/app/code/Magento/Sales/Model/Config/Ordered.php +++ b/app/code/Magento/Sales/Model/Config/Ordered.php @@ -153,17 +153,38 @@ protected function _prepareConfigArray($code, $totalConfig) /** * Aggregate before/after information from all items and sort totals based on this data + * Invoke simple sorting if the first element contains the "sort_order" key * * @param array $config * @return array */ - protected function _getSortedCollectorCodes(array $config) + private function _getSortedCollectorCodes(array $config) { - // invoke simple sorting if the first element contains the "sort_order" key reset($config); $element = current($config); if (isset($element['sort_order'])) { - uasort($config, array($this, '_compareSortOrder')); + uasort( + $config, + // @codingStandardsIgnoreStart + /** + * @param array $a + * @param array $b + * @return int + */ + // @codingStandardsIgnoreEnd + function ($a, $b) { + if (!isset($a['sort_order']) || !isset($b['sort_order'])) { + return 0; + } + if ($a['sort_order'] > $b['sort_order']) { + return 1; + } elseif ($a['sort_order'] < $b['sort_order']) { + return -1; + } else { + return 0; + } + } + ); } $result = array_keys($config); return $result; @@ -192,26 +213,4 @@ protected function _initCollectors() return $this; } - - /** - * Callback that uses sort_order for comparison - * - * @param array $a - * @param array $b - * @return int - */ - protected function _compareSortOrder($a, $b) - { - if (!isset($a['sort_order']) || !isset($b['sort_order'])) { - return 0; - } - if ($a['sort_order'] > $b['sort_order']) { - $res = 1; - } elseif ($a['sort_order'] < $b['sort_order']) { - $res = -1; - } else { - $res = 0; - } - return $res; - } } diff --git a/app/code/Magento/Sales/Model/Config/Source/Order/Status.php b/app/code/Magento/Sales/Model/Config/Source/Order/Status.php index fcf884cfe283d..3dbbf6751742f 100644 --- a/app/code/Magento/Sales/Model/Config/Source/Order/Status.php +++ b/app/code/Magento/Sales/Model/Config/Source/Order/Status.php @@ -31,9 +31,10 @@ class Status implements \Magento\Option\ArrayInterface { - // set null to enable all possible + const UNDEFINED_OPTION_LABEL = '-- Please Select --'; + /** - * @var array + * @var string[] */ protected $_stateStatuses = array( \Magento\Sales\Model\Order::STATE_NEW, @@ -62,15 +63,13 @@ public function __construct(\Magento\Sales\Model\Order\Config $orderConfig) */ public function toOptionArray() { - if ($this->_stateStatuses) { - $statuses = $this->_orderConfig->getStateStatuses($this->_stateStatuses); - } else { - $statuses = $this->_orderConfig->getStatuses(); - } - $options = array(); - $options[] = array('value' => '', 'label' => __('-- Please Select --')); + $statuses = $this->_stateStatuses + ? $this->_orderConfig->getStateStatuses($this->_stateStatuses) + : $this->_orderConfig->getStatuses(); + + $options = [['value' => '', 'label' => __(self::UNDEFINED_OPTION_LABEL)]]; foreach ($statuses as $code => $label) { - $options[] = array('value' => $code, 'label' => $label); + $options[] = ['value' => $code, 'label' => $label]; } return $options; } diff --git a/app/code/Magento/Sales/Model/ConverterInterface.php b/app/code/Magento/Sales/Model/ConverterInterface.php index 3bf8d21ef1c88..334aa991aa6e2 100644 --- a/app/code/Magento/Sales/Model/ConverterInterface.php +++ b/app/code/Magento/Sales/Model/ConverterInterface.php @@ -39,18 +39,18 @@ interface ConverterInterface /** * Decode data * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $filedName * @return mixed */ - public function decode(\Magento\Core\Model\AbstractModel $object, $filedName); + public function decode(\Magento\Model\AbstractModel $object, $filedName); /** * Encode data * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $filedName * @return mixed */ - public function encode(\Magento\Core\Model\AbstractModel $object, $filedName); + public function encode(\Magento\Model\AbstractModel $object, $filedName); } diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index e2ee876d4e460..e7a52eaec6b94 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -632,7 +632,7 @@ class Order extends \Magento\Sales\Model\AbstractModel * @param Resource\Order\Shipment\CollectionFactory $shipmentCollectionFactory * @param Resource\Order\Creditmemo\CollectionFactory $memoCollectionFactory * @param Resource\Order\Shipment\Track\CollectionFactory $trackCollectionFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -663,7 +663,7 @@ public function __construct( \Magento\Sales\Model\Resource\Order\Shipment\CollectionFactory $shipmentCollectionFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\CollectionFactory $memoCollectionFactory, \Magento\Sales\Model\Resource\Order\Shipment\Track\CollectionFactory $trackCollectionFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -1268,7 +1268,7 @@ public function setState($state, $status = false, $comment = '', $isCustomerNoti * @param bool $isCustomerNotified * @param bool $shouldProtectState * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _setState( $state, @@ -1280,7 +1280,7 @@ protected function _setState( // attempt to set the specified state if ($shouldProtectState) { if ($this->isStateProtected($state)) { - throw new \Magento\Core\Exception(__('The Order State "%1" must not be set manually.', $state)); + throw new \Magento\Model\Exception(__('The Order State "%1" must not be set manually.', $state)); } } $this->setData('state', $state); @@ -1389,12 +1389,12 @@ public function place() /** * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function hold() { if (!$this->canHold()) { - throw new \Magento\Core\Exception(__('A hold action is not available.')); + throw new \Magento\Model\Exception(__('A hold action is not available.')); } $this->setHoldBeforeState($this->getState()); $this->setHoldBeforeStatus($this->getStatus()); @@ -1406,12 +1406,12 @@ public function hold() * Attempt to unhold the order * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function unhold() { if (!$this->canUnhold()) { - throw new \Magento\Core\Exception(__('You cannot remove the hold.')); + throw new \Magento\Model\Exception(__('You cannot remove the hold.')); } $this->setState($this->getHoldBeforeState(), $this->getHoldBeforeStatus()); $this->setHoldBeforeState(null); @@ -1441,7 +1441,7 @@ public function cancel() * @param string $comment * @param bool $graceful * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function registerCancellation($comment = '', $graceful = true) { @@ -1475,7 +1475,7 @@ public function registerCancellation($comment = '', $graceful = true) $this->_setState($cancelState, true, $comment); } elseif (!$graceful) { - throw new \Magento\Core\Exception(__('We cannot cancel this order.')); + throw new \Magento\Model\Exception(__('We cannot cancel this order.')); } return $this; } @@ -2341,10 +2341,10 @@ public function getCustomerName() /** * Add New object to related array * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - public function addRelatedObject(\Magento\Core\Model\AbstractModel $object) + public function addRelatedObject(\Magento\Model\AbstractModel $object) { $this->_relatedObjects[] = $object; return $this; @@ -2599,7 +2599,6 @@ public function isCanceled() */ protected function _beforeDelete() { - $this->_protectFromNonAdmin(); return parent::_beforeDelete(); } } diff --git a/app/code/Magento/Sales/Model/Order/Address.php b/app/code/Magento/Sales/Model/Order/Address.php index 4973938f7b9a7..77466aa02b38e 100644 --- a/app/code/Magento/Sales/Model/Order/Address.php +++ b/app/code/Magento/Sales/Model/Order/Address.php @@ -98,7 +98,7 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -111,7 +111,7 @@ public function __construct( \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Directory\Model\CountryFactory $countryFactory, \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index a17e0c364c76e..51b0e516bc428 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -25,7 +25,7 @@ */ namespace Magento\Sales\Model\Order; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Order creditmemo model @@ -277,7 +277,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel * @param Creditmemo\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory * @param \Magento\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -297,7 +297,7 @@ public function __construct( \Magento\Sales\Model\Order\Creditmemo\CommentFactory $commentFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory, \Magento\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -1063,11 +1063,10 @@ protected function _getEmails($configPath) } /** - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _beforeDelete() { - $this->_protectFromNonAdmin(); return parent::_beforeDelete(); } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php index 1d5d7c335d878..8f7aa96a43a41 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php @@ -59,7 +59,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -69,7 +69,7 @@ public function __construct( \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php index f8b5761bb00c6..90bc82ac4e7f2 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php @@ -92,7 +92,7 @@ * @method float getBaseHiddenTaxAmount() * @method \Magento\Sales\Model\Order\Creditmemo\Item setBaseHiddenTaxAmount(float $value) */ -class Item extends \Magento\Core\Model\AbstractModel +class Item extends \Magento\Model\AbstractModel { /** * @var string @@ -123,7 +123,7 @@ class Item extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Sales\Model\Order\ItemFactory $orderItemFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -131,7 +131,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Sales\Model\Order\ItemFactory $orderItemFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -206,7 +206,7 @@ public function getOrderItem() * * @param float $qty * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setQty($qty) { @@ -222,7 +222,7 @@ public function setQty($qty) if ($qty <= $this->getOrderItem()->getQtyToRefund() || $this->getOrderItem()->isDummy()) { $this->setData('qty', $qty); } else { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We found an invalid quantity to refund item "%1".', $this->getName()) ); } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php index ed3c865aaf7f1..159a1fbe67041 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php @@ -58,7 +58,7 @@ public function __construct( /** * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo) { @@ -108,7 +108,7 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo) } } else { $baseAllowedAmount = $order->getBaseCurrency()->format($baseAllowedAmount, null, false); - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Maximum shipping amount allowed to refund is: %1', $baseAllowedAmount) ); } diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index f14e00140ef33..0a75ed42cdb21 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -287,7 +287,7 @@ class Invoice extends \Magento\Sales\Model\AbstractModel * @param Invoice\CommentFactory $invoiceCommentFactory * @param \Magento\Sales\Model\Resource\Order\Invoice\Comment\CollectionFactory $commentCollectionFactory * @param \Magento\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -307,7 +307,7 @@ public function __construct( \Magento\Sales\Model\Order\Invoice\CommentFactory $invoiceCommentFactory, \Magento\Sales\Model\Resource\Order\Invoice\Comment\CollectionFactory $commentCollectionFactory, \Magento\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -739,12 +739,12 @@ public function getStateName($stateId = null) * Apply to order, order items etc. * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function register() { if ($this->getId()) { - throw new \Magento\Core\Exception(__('We cannot register an existing invoice')); + throw new \Magento\Model\Exception(__('We cannot register an existing invoice')); } foreach ($this->getAllItems() as $item) { @@ -1073,11 +1073,10 @@ protected function _getEmails($configPath) } /** - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _beforeDelete() { - $this->_protectFromNonAdmin(); return parent::_beforeDelete(); } diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php index 7cd47248a1813..40b03529fd8a0 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php @@ -59,7 +59,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -69,7 +69,7 @@ public function __construct( \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Item.php b/app/code/Magento/Sales/Model/Order/Invoice/Item.php index bb200ef3936e3..135bc399de0a1 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Item.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Item.php @@ -92,7 +92,7 @@ * @method float getBaseHiddenTaxAmount() * @method \Magento\Sales\Model\Order\Invoice\Item setBaseHiddenTaxAmount(float $value) */ -class Item extends \Magento\Core\Model\AbstractModel +class Item extends \Magento\Model\AbstractModel { /** * @var string @@ -123,7 +123,7 @@ class Item extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Sales\Model\Order\ItemFactory $orderItemFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -131,7 +131,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Sales\Model\Order\ItemFactory $orderItemFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -206,7 +206,7 @@ public function getOrderItem() * * @param float $qty * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setQty($qty) { @@ -224,7 +224,7 @@ public function setQty($qty) if ($qty <= $qtyToInvoice || $this->getOrderItem()->isDummy()) { $this->setData('qty', $qty); } else { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We found an invalid quantity to invoice item "%1".', $this->getName()) ); } diff --git a/app/code/Magento/Sales/Model/Order/Item.php b/app/code/Magento/Sales/Model/Order/Item.php index 502a845198a8e..860c3d07a23cb 100644 --- a/app/code/Magento/Sales/Model/Order/Item.php +++ b/app/code/Magento/Sales/Model/Order/Item.php @@ -188,7 +188,7 @@ * @method float getBaseDiscountRefunded() * @method \Magento\Sales\Model\Order\Item setBaseDiscountRefunded(float $value) */ -class Item extends \Magento\Core\Model\AbstractModel +class Item extends \Magento\Model\AbstractModel { const STATUS_PENDING = 1; @@ -266,7 +266,7 @@ class Item extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -275,7 +275,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index fb6a556ef20c7..3828a0eb5f27c 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -215,7 +215,7 @@ class Payment extends \Magento\Payment\Model\Info * @param \Magento\Sales\Model\Order\Payment\TransactionFactory $transactionFactory * @param \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $transactionCollectionFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -228,7 +228,7 @@ public function __construct( \Magento\Sales\Model\Order\Payment\TransactionFactory $transactionFactory, \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $transactionCollectionFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -415,7 +415,7 @@ public function place() * TODO: eliminate logic duplication with registerCaptureNotification() * * @param null|Invoice $invoice - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ public function capture($invoice) @@ -495,7 +495,7 @@ public function capture($invoice) $this->getMethodInstance()->processInvoice($invoice, $this); return $this; } - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The transaction "%1" cannot be captured yet.', $invoice->getTransactionId()) ); } @@ -708,7 +708,7 @@ public function registerVoidNotification($amount = null) * @param Creditmemo $creditmemo * @return $this * @throws \Exception - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function refund($creditmemo) { @@ -745,7 +745,7 @@ public function refund($creditmemo) $creditmemo, $this ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if (!$captureTxn) { $e->setMessage( ' ' . __('If the invoice was created offline, try creating an offline credit memo.'), diff --git a/app/code/Magento/Sales/Model/Order/Payment/Transaction.php b/app/code/Magento/Sales/Model/Order/Payment/Transaction.php index 1abf5f66a3940..5272ffd24debb 100644 --- a/app/code/Magento/Sales/Model/Order/Payment/Transaction.php +++ b/app/code/Magento/Sales/Model/Order/Payment/Transaction.php @@ -49,7 +49,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Transaction extends \Magento\Core\Model\AbstractModel +class Transaction extends \Magento\Model\AbstractModel { /**#@+ * Supported transaction types @@ -175,7 +175,7 @@ class Transaction extends \Magento\Core\Model\AbstractModel * @param \Magento\Sales\Model\Order\PaymentFactory $paymentFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -185,7 +185,7 @@ public function __construct( \Magento\Sales\Model\Order\PaymentFactory $paymentFactory, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -238,14 +238,14 @@ public function setTxnId($txnId) * @param string $parentTxnId * @param string $txnId * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setParentTxnId($parentTxnId, $txnId = null) { $this->_verifyTxnId($parentTxnId); if (empty($txnId)) { if ('' == $this->getTxnId()) { - throw new \Magento\Core\Exception(__('The parent transaction ID must have a transaction ID.')); + throw new \Magento\Model\Exception(__('The parent transaction ID must have a transaction ID.')); } } else { $this->setTxnId($txnId); @@ -439,7 +439,7 @@ public function canVoidAuthorizationCompletely() return false; } return true; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { // jam all logical exceptions, fallback to false } return false; @@ -515,12 +515,12 @@ protected function _afterLoadByTxnId() * @param string $key * @param mixed $value * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setAdditionalInformation($key, $value) { if (is_object($value)) { - throw new \Magento\Core\Exception(__('Payment transactions disallow storing objects.')); + throw new \Magento\Model\Exception(__('Payment transactions disallow storing objects.')); } $info = $this->_getData('additional_information'); if (!$info) { @@ -572,7 +572,7 @@ public function unsAdditionalInformation($key = null) * * @param bool $shouldSave * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @throws \Exception */ public function close($shouldSave = true) @@ -581,7 +581,7 @@ public function close($shouldSave = true) $this->_verifyThisTransactionExists(); } if (1 == $this->getIsClosed() && $this->_isFailsafe) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The transaction "%1" (%2) is already closed.', $this->getTxnId(), $this->getTxnType()) ); } @@ -666,7 +666,7 @@ public function getOrder() * * @param \Magento\Sales\Model\Order|null|boolean $order * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setOrder($order = null) { @@ -681,7 +681,7 @@ public function setOrder($order = null) } elseif (!$this->getId() || $this->getOrderId() == $order->getId()) { $this->_order = $order; } else { - throw new \Magento\Core\Exception(__('Set order for existing transactions not allowed')); + throw new \Magento\Model\Exception(__('Set order for existing transactions not allowed')); } return $this; @@ -730,7 +730,7 @@ protected function _beforeSave() * Load child transactions * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _loadChildren() { @@ -743,7 +743,7 @@ protected function _loadChildren() $payment = $this->_verifyPaymentObject(true); $paymentId = $payment ? $payment->getId() : $this->_getData('payment_id'); if (!$paymentId) { - throw new \Magento\Core\Exception(__('At minimum, you need to set a payment ID.')); + throw new \Magento\Model\Exception(__('At minimum, you need to set a payment ID.')); } $this->setOrder(true); @@ -841,7 +841,7 @@ public function getOrderWebsiteId() * * @param string $txnType * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _verifyTxnType($txnType = null) { @@ -857,7 +857,7 @@ protected function _verifyTxnType($txnType = null) case self::TYPE_REFUND: break; default: - throw new \Magento\Core\Exception(__('We found an unsupported transaction type "%1".', $txnType)); + throw new \Magento\Model\Exception(__('We found an unsupported transaction type "%1".', $txnType)); } } @@ -867,13 +867,13 @@ protected function _verifyTxnType($txnType = null) * * @param bool $dryRun * @return \Magento\Sales\Model\Order\Payment|null|false - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _verifyPaymentObject($dryRun = false) { if (!$this->_paymentObject || !$this->getOrderId()) { if (!$dryRun) { - throw new \Magento\Core\Exception(__('Please set a proper payment object.')); + throw new \Magento\Model\Exception(__('Please set a proper payment object.')); } } return $this->_paymentObject; @@ -884,12 +884,12 @@ protected function _verifyPaymentObject($dryRun = false) * * @param string $txnId * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _verifyTxnId($txnId) { if (null !== $txnId && 0 == strlen($txnId)) { - throw new \Magento\Core\Exception(__('The Transaction ID field cannot be empty.')); + throw new \Magento\Model\Exception(__('The Transaction ID field cannot be empty.')); } } @@ -898,12 +898,12 @@ protected function _verifyTxnId($txnId) * TODO for more restriction we can check for data consistency * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _verifyThisTransactionExists() { if (!$this->getId()) { - throw new \Magento\Core\Exception(__('You can\'t do this without a transaction object.')); + throw new \Magento\Model\Exception(__('You can\'t do this without a transaction object.')); } $this->_verifyTxnType(); } diff --git a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php index 7fa65d8b3d98b..496d0641f9383 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php @@ -93,11 +93,6 @@ abstract public function getPdf(); */ protected $_coreStoreConfig; - /** - * @var \Magento\TranslateInterface - */ - protected $_translate; - /** * @var \Magento\Filesystem\Directory\WriteInterface */ @@ -123,16 +118,21 @@ abstract public function getPdf(); */ protected $_pdfItemsFactory; + /** + * @var \Magento\Translate\Inline\StateInterface + */ + protected $inlineTranslation; + /** * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\TranslateInterface $translate * @param \Magento\App\Filesystem $filesystem * @param Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -141,24 +141,24 @@ public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Stdlib\String $string, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\TranslateInterface $translate, \Magento\App\Filesystem $filesystem, Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Translate\Inline\StateInterface $inlineTranslation, array $data = array() ) { $this->_paymentData = $paymentData; $this->_localeDate = $localeDate; $this->string = $string; $this->_coreStoreConfig = $coreStoreConfig; - $this->_translate = $translate; $this->_mediaDirectory = $filesystem->getDirectoryWrite(\Magento\App\Filesystem::MEDIA_DIR); $this->_rootDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::ROOT_DIR); $this->_pdfConfig = $pdfConfig; $this->_pdfTotalFactory = $pdfTotalFactory; $this->_pdfItemsFactory = $pdfItemsFactory; + $this->inlineTranslation = $inlineTranslation; parent::__construct($data); } @@ -709,7 +709,7 @@ protected function _parseItemDescription($item) */ protected function _beforeGetPdf() { - $this->_translate->setTranslateInline(false); + $this->inlineTranslation->suspend(); } /** @@ -719,7 +719,7 @@ protected function _beforeGetPdf() */ protected function _afterGetPdf() { - $this->_translate->setTranslateInline(true); + $this->inlineTranslation->resume(); } /** @@ -767,7 +767,7 @@ protected function _initRenderer($type) * * @param string $type * @return \Magento\Sales\Model\Order\Pdf\Items\AbstractItems - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getRenderer($type) { @@ -776,7 +776,7 @@ protected function _getRenderer($type) } if (!isset($this->_renderers[$type])) { - throw new \Magento\Core\Exception(__('We found an invalid renderer model.')); + throw new \Magento\Model\Exception(__('We found an invalid renderer model.')); } if (is_null($this->_renderers[$type]['renderer'])) { @@ -885,13 +885,13 @@ protected function _setPdf(\Zend_Pdf $pdf) /** * Retrieve PDF object * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Zend_Pdf */ protected function _getPdf() { if (!$this->_pdf instanceof \Zend_Pdf) { - throw new \Magento\Core\Exception(__('Please define the PDF object before using.')); + throw new \Magento\Model\Exception(__('Please define the PDF object before using.')); } return $this->_pdf; @@ -935,14 +935,14 @@ public function newPage(array $settings = array()) * @param \Zend_Pdf_Page $page * @param array $draw * @param array $pageSettings - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Zend_Pdf_Page */ public function drawLineBlocks(\Zend_Pdf_Page $page, array $draw, array $pageSettings = array()) { foreach ($draw as $itemsProp) { if (!isset($itemsProp['lines']) || !is_array($itemsProp['lines'])) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We don\'t recognize the draw line data. Please define the "lines" array.') ); } diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php index 10b8cdd952df3..8fd9fad05c964 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php @@ -60,12 +60,12 @@ public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Stdlib\String $string, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\TranslateInterface $translate, \Magento\App\Filesystem $filesystem, Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Translate\Inline\StateInterface $inlineTranslation, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Locale\ResolverInterface $localeResolver, array $data = array() @@ -76,12 +76,12 @@ public function __construct( $paymentData, $string, $coreStoreConfig, - $translate, $filesystem, $pdfConfig, $pdfTotalFactory, $pdfItemsFactory, $localeDate, + $inlineTranslation, $data ); } diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php index ae09f3ef9eaaf..e3755c7e5fde3 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php @@ -44,12 +44,12 @@ class Invoice extends AbstractPdf * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\TranslateInterface $translate * @param \Magento\App\Filesystem $filesystem * @param Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data @@ -60,12 +60,12 @@ public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Stdlib\String $string, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\TranslateInterface $translate, \Magento\App\Filesystem $filesystem, Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Translate\Inline\StateInterface $inlineTranslation, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Locale\ResolverInterface $localeResolver, array $data = array() @@ -76,12 +76,12 @@ public function __construct( $paymentData, $string, $coreStoreConfig, - $translate, $filesystem, $pdfConfig, $pdfTotalFactory, $pdfItemsFactory, $localeDate, + $inlineTranslation, $data ); } 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 59d6acbc25198..b91a0832f48ae 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php @@ -28,7 +28,7 @@ /** * Sales Order Pdf Items renderer Abstract */ -abstract class AbstractItems extends \Magento\Core\Model\AbstractModel +abstract class AbstractItems extends \Magento\Model\AbstractModel { /** * Order model @@ -40,7 +40,7 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel /** * Source model (invoice, shipment, creditmemo) * - * @var \Magento\Core\Model\AbstractModel + * @var \Magento\Model\AbstractModel */ protected $_source; @@ -88,7 +88,7 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\App\Filesystem $filesystem , * @param \Magento\Filter\FilterManager $filterManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -98,7 +98,7 @@ public function __construct( \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, \Magento\Filter\FilterManager $filterManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -123,10 +123,10 @@ public function setOrder(\Magento\Sales\Model\Order $order) /** * Set Source model * - * @param \Magento\Core\Model\AbstractModel $source + * @param \Magento\Model\AbstractModel $source * @return $this */ - public function setSource(\Magento\Core\Model\AbstractModel $source) + public function setSource(\Magento\Model\AbstractModel $source) { $this->_source = $source; return $this; @@ -171,13 +171,13 @@ public function setPage(\Zend_Pdf_Page $page) /** * Retrieve order object * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\Sales\Model\Order */ public function getOrder() { if (null === $this->_order) { - throw new \Magento\Core\Exception(__('The order object is not specified.')); + throw new \Magento\Model\Exception(__('The order object is not specified.')); } return $this->_order; } @@ -185,13 +185,13 @@ public function getOrder() /** * Retrieve source object * - * @throws \Magento\Core\Exception - * @return \Magento\Core\Model\AbstractModel + * @throws \Magento\Model\Exception + * @return \Magento\Model\AbstractModel */ public function getSource() { if (null === $this->_source) { - throw new \Magento\Core\Exception(__('The source object is not specified.')); + throw new \Magento\Model\Exception(__('The source object is not specified.')); } return $this->_source; } @@ -199,13 +199,13 @@ public function getSource() /** * Retrieve item object * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\Object */ public function getItem() { if (null === $this->_item) { - throw new \Magento\Core\Exception(__('An item object is not specified.')); + throw new \Magento\Model\Exception(__('An item object is not specified.')); } return $this->_item; } @@ -213,13 +213,13 @@ public function getItem() /** * Retrieve Pdf model * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\Sales\Model\Order\Pdf\AbstractPdf */ public function getPdf() { if (null === $this->_pdf) { - throw new \Magento\Core\Exception(__('A PDF object is not specified.')); + throw new \Magento\Model\Exception(__('A PDF object is not specified.')); } return $this->_pdf; } @@ -227,13 +227,13 @@ public function getPdf() /** * Retrieve Pdf page object * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Zend_Pdf_Page */ public function getPage() { if (null === $this->_pdfPage) { - throw new \Magento\Core\Exception(__('A PDF page object is not specified.')); + throw new \Magento\Model\Exception(__('A PDF page object is not specified.')); } return $this->_pdfPage; } 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 bdf64655d3c8b..ec21d8430da3b 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 @@ -44,7 +44,7 @@ class DefaultCreditmemo extends \Magento\Sales\Model\Order\Pdf\Items\AbstractIte * @param \Magento\App\Filesystem $filesystem * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $string - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -55,7 +55,7 @@ public function __construct( \Magento\App\Filesystem $filesystem, \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $string, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 efed464d8825c..b25083fdca258 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 @@ -44,7 +44,7 @@ class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems * @param \Magento\App\Filesystem $filesystem * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $string - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -55,7 +55,7 @@ public function __construct( \Magento\App\Filesystem $filesystem, \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $string, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { 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 78305852952c2..b1b52f57b278e 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 @@ -44,7 +44,7 @@ class DefaultShipment extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems * @param \Magento\App\Filesystem $filesystem * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $string - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -55,7 +55,7 @@ public function __construct( \Magento\App\Filesystem $filesystem, \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $string, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php index 8b704cc57de50..3cbba9b75d978 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php @@ -44,12 +44,12 @@ class Shipment extends AbstractPdf * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\TranslateInterface $translate * @param \Magento\App\Filesystem $filesystem * @param Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data @@ -60,12 +60,12 @@ public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Stdlib\String $string, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\TranslateInterface $translate, \Magento\App\Filesystem $filesystem, Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Translate\Inline\StateInterface $inlineTranslation, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Locale\ResolverInterface $localeResolver, array $data = array() @@ -76,12 +76,12 @@ public function __construct( $paymentData, $string, $coreStoreConfig, - $translate, $filesystem, $pdfConfig, $pdfTotalFactory, $pdfItemsFactory, $localeDate, + $inlineTranslation, $data ); } diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php b/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php index 1efb105b6faea..7d982bdf7593f 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php @@ -51,13 +51,13 @@ public function __construct(\Magento\ObjectManager $objectManager) * @param string|null $class * @param array $arguments * @return \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function create($class = null, $arguments = array()) { $class = $class ?: $this->_defaultTotalModel; if (!is_a($class, 'Magento\Sales\Model\Order\Pdf\Total\DefaultTotal', true)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( "The PDF total model {$class} must be or extend " . "\\Magento\\Sales\\Model\\Order\\Pdf\\Total\\DefaultTotal." diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php index 8b6671395c80b..e06df0dca3759 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment.php @@ -202,7 +202,7 @@ class Shipment extends \Magento\Sales\Model\AbstractModel * @param Shipment\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory * @param \Magento\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -220,7 +220,7 @@ public function __construct( \Magento\Sales\Model\Order\Shipment\CommentFactory $commentFactory, \Magento\Sales\Model\Resource\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory, \Magento\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -325,12 +325,12 @@ public function getShippingAddress() * Apply to order, order items etc. * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function register() { if ($this->getId()) { - throw new \Magento\Core\Exception(__('We cannot register an existing shipment')); + throw new \Magento\Model\Exception(__('We cannot register an existing shipment')); } $totalQty = 0; @@ -475,7 +475,7 @@ public function addTrack(\Magento\Sales\Model\Order\Shipment\Track $track) /** * Track saving is implemented in _afterSave() - * This enforces \Magento\Core\Model\AbstractModel::save() not to skip _afterSave() + * This enforces \Magento\Model\AbstractModel::save() not to skip _afterSave() */ $this->_hasDataChanges = true; @@ -738,12 +738,12 @@ protected function _getEmails($configPath) * Before object save * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeSave() { if ((!$this->getId() || null !== $this->_items) && !count($this->getAllItems())) { - throw new \Magento\Core\Exception(__('We cannot create an empty shipment.')); + throw new \Magento\Model\Exception(__('We cannot create an empty shipment.')); } if (!$this->getOrderId() && $this->getOrder()) { @@ -755,11 +755,10 @@ protected function _beforeSave() } /** - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _beforeDelete() { - $this->_protectFromNonAdmin(); return parent::_beforeDelete(); } diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php index a9d5f6bc14b97..7d3ec25edc348 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php @@ -59,7 +59,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -69,7 +69,7 @@ public function __construct( \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Item.php b/app/code/Magento/Sales/Model/Order/Shipment/Item.php index 8650f73e8ecc2..15667539a0acd 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Item.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Item.php @@ -50,7 +50,7 @@ * @method string getSku() * @method \Magento\Sales\Model\Order\Shipment\Item setSku(string $value) */ -class Item extends \Magento\Core\Model\AbstractModel +class Item extends \Magento\Model\AbstractModel { /** * @var string @@ -81,7 +81,7 @@ class Item extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Sales\Model\Order\ItemFactory $orderItemFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -89,7 +89,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Sales\Model\Order\ItemFactory $orderItemFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -164,7 +164,7 @@ public function getOrderItem() * * @param float $qty * @return \Magento\Sales\Model\Order\Invoice\Item - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setQty($qty) { @@ -180,7 +180,7 @@ public function setQty($qty) if ($qty <= $this->getOrderItem()->getQtyToShip() || $this->getOrderItem()->isDummy(true)) { $this->setData('qty', $qty); } else { - throw new \Magento\Core\Exception(__('We found an invalid qty to ship for item "%1".', $this->getName())); + throw new \Magento\Model\Exception(__('We found an invalid qty to ship for item "%1".', $this->getName())); } return $this; } diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Order/Shipment/Track.php index ef835c901d4a9..71f30fccef1e1 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Track.php @@ -90,7 +90,7 @@ class Track extends \Magento\Sales\Model\AbstractModel * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -101,7 +101,7 @@ public function __construct( \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Status.php b/app/code/Magento/Sales/Model/Order/Status.php index 228e55859722b..dccf30e00444c 100644 --- a/app/code/Magento/Sales/Model/Order/Status.php +++ b/app/code/Magento/Sales/Model/Order/Status.php @@ -25,7 +25,7 @@ */ namespace Magento\Sales\Model\Order; -class Status extends \Magento\Core\Model\AbstractModel +class Status extends \Magento\Model\AbstractModel { /** * @var \Magento\Core\Model\StoreManagerInterface @@ -36,7 +36,7 @@ class Status extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -44,7 +44,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Status/History.php b/app/code/Magento/Sales/Model/Order/Status/History.php index 1bf6d3112bea3..754ead6f62d81 100644 --- a/app/code/Magento/Sales/Model/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Order/Status/History.php @@ -74,7 +74,7 @@ class History extends \Magento\Sales\Model\AbstractModel * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -84,7 +84,7 @@ public function __construct( \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Tax.php b/app/code/Magento/Sales/Model/Order/Tax.php index 4b6566f538aa2..fd356b42ed492 100644 --- a/app/code/Magento/Sales/Model/Order/Tax.php +++ b/app/code/Magento/Sales/Model/Order/Tax.php @@ -56,7 +56,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Tax extends \Magento\Core\Model\AbstractModel +class Tax extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Sales/Model/Order/Total/Config/Base.php b/app/code/Magento/Sales/Model/Order/Total/Config/Base.php index bd88a70b83a81..cb33393baf0c5 100644 --- a/app/code/Magento/Sales/Model/Order/Total/Config/Base.php +++ b/app/code/Magento/Sales/Model/Order/Total/Config/Base.php @@ -81,13 +81,13 @@ public function __construct( * @param string $totalCode * @param array $totalConfig * @return \Magento\Sales\Model\Order\Total\AbstractTotal - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _initModelInstance($class, $totalCode, $totalConfig) { $model = $this->_orderTotalFactory->create($class); if (!$model instanceof \Magento\Sales\Model\Order\Total\AbstractTotal) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The total model should be extended from \Magento\Sales\Model\Order\Total\AbstractTotal.') ); } diff --git a/app/code/Magento/Sales/Model/Payment/Method/Converter.php b/app/code/Magento/Sales/Model/Payment/Method/Converter.php index 0b2afd9fdaefd..029aa55efc481 100644 --- a/app/code/Magento/Sales/Model/Payment/Method/Converter.php +++ b/app/code/Magento/Sales/Model/Payment/Method/Converter.php @@ -62,11 +62,11 @@ public function __construct(\Magento\Encryption\EncryptorInterface $encryptor) /** * Check if specified field is encrypted * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $filedName * @return bool */ - protected function _shouldBeEncrypted(\Magento\Core\Model\AbstractModel $object, $filedName) + protected function _shouldBeEncrypted(\Magento\Model\AbstractModel $object, $filedName) { $method = $object->getData('method'); return isset($this->_encryptFields[$method][$filedName]) && $this->_encryptFields[$method][$filedName]; @@ -75,11 +75,11 @@ protected function _shouldBeEncrypted(\Magento\Core\Model\AbstractModel $object, /** * Decode data * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $filedName * @return mixed */ - public function decode(\Magento\Core\Model\AbstractModel $object, $filedName) + public function decode(\Magento\Model\AbstractModel $object, $filedName) { $value = $object->getData($filedName); @@ -93,11 +93,11 @@ public function decode(\Magento\Core\Model\AbstractModel $object, $filedName) /** * Encode data * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $filedName * @return mixed */ - public function encode(\Magento\Core\Model\AbstractModel $object, $filedName) + public function encode(\Magento\Model\AbstractModel $object, $filedName) { $value = $object->getData($filedName); diff --git a/app/code/Magento/Sales/Model/Quote.php b/app/code/Magento/Sales/Model/Quote.php index 9ac153386b669..c8ef7835159d1 100644 --- a/app/code/Magento/Sales/Model/Quote.php +++ b/app/code/Magento/Sales/Model/Quote.php @@ -134,7 +134,7 @@ * @method bool|null getIsPersistent() * @method Quote setIsPersistent(bool $value) */ -class Quote extends \Magento\Core\Model\AbstractModel +class Quote extends \Magento\Model\AbstractModel { /** * Checkout login method key @@ -321,7 +321,7 @@ class Quote extends \Magento\Core\Model\AbstractModel * @param \Magento\Customer\Model\Converter $converter * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService * @param \Magento\Customer\Model\Address\Converter $addressConverter - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -347,7 +347,7 @@ public function __construct( \Magento\Customer\Model\Converter $converter, \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, \Magento\Customer\Model\Address\Converter $addressConverter, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -1234,7 +1234,7 @@ public function removeAllItems() * * @param \Magento\Sales\Model\Quote\Item $item * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addItem(\Magento\Sales\Model\Quote\Item $item) { @@ -1247,7 +1247,7 @@ public function addItem(\Magento\Sales\Model\Quote\Item $item) * Proper solution is to submit items one by one with customer confirmation each time. */ if ($item->isNominal() && $this->hasItems() || $this->hasNominalItems()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Sorry, but items with payment agreements must be ordered one at a time To continue, please remove or buy the other items in your cart, then order this item by itself.' ) @@ -1270,7 +1270,7 @@ public function addItem(\Magento\Sales\Model\Quote\Item $item) * @param null|float|\Magento\Object $request * @param null|string $processMode * @return \Magento\Sales\Model\Quote\Item|string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addProductAdvanced(\Magento\Catalog\Model\Product $product, $request = null, $processMode = null) { @@ -1281,7 +1281,7 @@ public function addProductAdvanced(\Magento\Catalog\Model\Product $product, $req $request = new \Magento\Object(array('qty' => $request)); } if (!$request instanceof \Magento\Object) { - throw new \Magento\Core\Exception(__('We found an invalid request for adding product to quote.')); + throw new \Magento\Model\Exception(__('We found an invalid request for adding product to quote.')); } $cartCandidates = $product->getTypeInstance()->prepareForCartAdvanced($request, $product, $processMode); @@ -1338,7 +1338,7 @@ public function addProductAdvanced(\Magento\Catalog\Model\Product $product, $req } } if (!empty($errors)) { - throw new \Magento\Core\Exception(implode("\n", $errors)); + throw new \Magento\Model\Exception(implode("\n", $errors)); } $this->_eventManager->dispatch('sales_quote_product_add_after', array('items' => $items)); @@ -1421,7 +1421,7 @@ protected function _addCatalogProduct(\Magento\Catalog\Model\Product $product, $ * @param \Magento\Object $buyRequest * @param null|array|\Magento\Object $params * @return \Magento\Sales\Model\Quote\Item - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * * @see \Magento\Catalog\Helper\Product::addParamsToBuyRequest() */ @@ -1429,7 +1429,7 @@ public function updateItem($itemId, $buyRequest, $params = null) { $item = $this->getItemById($itemId); if (!$item) { - throw new \Magento\Core\Exception(__('This is the wrong quote item id to update configuration.')); + throw new \Magento\Model\Exception(__('This is the wrong quote item id to update configuration.')); } $productId = $item->getProduct()->getId(); @@ -1449,7 +1449,7 @@ public function updateItem($itemId, $buyRequest, $params = null) $resultItem = $this->addProduct($product, $buyRequest); if (is_string($resultItem)) { - throw new \Magento\Core\Exception($resultItem); + throw new \Magento\Model\Exception($resultItem); } if ($resultItem->getParentItem()) { diff --git a/app/code/Magento/Sales/Model/Quote/Address.php b/app/code/Magento/Sales/Model/Quote/Address.php index fd6b34559927e..2aab04ed40734 100644 --- a/app/code/Magento/Sales/Model/Quote/Address.php +++ b/app/code/Magento/Sales/Model/Quote/Address.php @@ -285,7 +285,7 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress * @param CustomerAddressBuilder $customerAddressBuilder * @param CustomerAddressServiceInterface $customerAddressService * @param \Magento\Customer\Model\Address\Converter $addressConverter - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -312,7 +312,7 @@ public function __construct( CustomerAddressBuilder $customerAddressBuilder, CustomerAddressServiceInterface $customerAddressService, \Magento\Customer\Model\Address\Converter $addressConverter, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Quote/Address/AbstractCarrierInterface.php b/app/code/Magento/Sales/Model/Quote/Address/AbstractCarrierInterface.php index 49138e4820039..2815479a3021c 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/AbstractCarrierInterface.php +++ b/app/code/Magento/Sales/Model/Quote/Address/AbstractCarrierInterface.php @@ -84,7 +84,7 @@ public function getDeliveryConfirmationTypes(\Magento\Object $params = null); /** * @param \Magento\Sales\Model\Quote\Address\RateRequest $request - * @return $this|bool|false|\Magento\Core\Model\AbstractModel + * @return $this|bool|false|\Magento\Model\AbstractModel */ public function checkAvailableShipCountries(\Magento\Sales\Model\Quote\Address\RateRequest $request); diff --git a/app/code/Magento/Sales/Model/Quote/Address/Rate.php b/app/code/Magento/Sales/Model/Quote/Address/Rate.php index 4af3bb36d0a40..ccba4d040b961 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Rate.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Rate.php @@ -25,7 +25,7 @@ */ namespace Magento\Sales\Model\Quote\Address; -use Magento\Core\Model\AbstractModel; +use \Magento\Model\AbstractModel; /** * @method \Magento\Sales\Model\Resource\Quote\Address\Rate _getResource() diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/AbstractTotal.php b/app/code/Magento/Sales/Model/Quote/Address/Total/AbstractTotal.php index 5fe47831ef82a..55409acdc2904 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/AbstractTotal.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Total/AbstractTotal.php @@ -140,12 +140,12 @@ protected function _setAddress(\Magento\Sales\Model\Quote\Address $address) * Get quote address object * * @return \Magento\Sales\Model\Quote\Address - * @throws \Magento\Core\Exception if address not declared + * @throws \Magento\Model\Exception if address not declared */ protected function _getAddress() { if ($this->_address === null) { - throw new \Magento\Core\Exception(__('The address model is not defined.')); + throw new \Magento\Model\Exception(__('The address model is not defined.')); } return $this->_address; } diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php index 3c16844ae6eac..401dc1339b64c 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php @@ -134,13 +134,13 @@ public function getRetrievers() * @param string $totalCode * @param array $totalConfig * @return \Magento\Sales\Model\Quote\Address\Total\AbstractTotal - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _initModelInstance($class, $totalCode, $totalConfig) { $model = $this->_totalFactory->create($class); if (!$model instanceof \Magento\Sales\Model\Quote\Address\Total\AbstractTotal) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'The address total model should be extended from \Magento\Sales\Model\Quote\Address\Total\AbstractTotal.' ) @@ -159,7 +159,7 @@ protected function _initModelInstance($class, $totalCode, $totalConfig) * * @return $this */ - protected function _initRetrievers() + private function _initRetrievers() { $sorts = $this->_coreStoreConfig->getConfig(self::XML_PATH_SALES_TOTALS_SORT, $this->_store); foreach ($sorts as $code => $sortOrder) { diff --git a/app/code/Magento/Sales/Model/Quote/Item.php b/app/code/Magento/Sales/Model/Quote/Item.php index fbef7894563a1..9c9b552bba1c5 100644 --- a/app/code/Magento/Sales/Model/Quote/Item.php +++ b/app/code/Magento/Sales/Model/Quote/Item.php @@ -206,7 +206,7 @@ class Item extends \Magento\Sales\Model\Quote\Item\AbstractItem * @param \Magento\Sales\Model\Status\ListFactory $statusListFactory * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Sales\Model\Quote\Item\OptionFactory $itemOptionFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data * @@ -219,7 +219,7 @@ public function __construct( \Magento\Sales\Model\Status\ListFactory $statusListFactory, \Magento\Locale\FormatInterface $localeFormat, \Magento\Sales\Model\Quote\Item\OptionFactory $itemOptionFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -632,7 +632,7 @@ public function getOptionsByCode() * * @param \Magento\Sales\Model\Quote\Item\Option|\Magento\Object $option * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addOption($option) { @@ -649,7 +649,7 @@ public function addOption($option) } elseif ($option instanceof \Magento\Sales\Model\Quote\Item\Option) { $option->setItem($this); } else { - throw new \Magento\Core\Exception(__('We found an invalid item option format.')); + throw new \Magento\Model\Exception(__('We found an invalid item option format.')); } $exOption = $this->getOptionByCode($option->getCode()); @@ -710,14 +710,14 @@ public function removeOption($code) * * @param \Magento\Sales\Model\Quote\Item\Option $option * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _addOptionCode($option) { if (!isset($this->_optionsByCode[$option->getCode()])) { $this->_optionsByCode[$option->getCode()] = $option; } else { - throw new \Magento\Core\Exception(__('An item option with code %1 already exists.', $option->getCode())); + throw new \Magento\Model\Exception(__('An item option with code %1 already exists.', $option->getCode())); } return $this; } diff --git a/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php b/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php index dad68dc86743a..9235a6e313676 100644 --- a/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php +++ b/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php @@ -54,7 +54,7 @@ * @method int[] getAppliedRuleIds() * @method \Magento\Sales\Model\Quote\Item\AbstractItem setAppliedRuleIds(array $ruleIds) */ -abstract class AbstractItem extends \Magento\Core\Model\AbstractModel implements +abstract class AbstractItem extends \Magento\Model\AbstractModel implements \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface { /** @@ -88,7 +88,7 @@ abstract class AbstractItem extends \Magento\Core\Model\AbstractModel implements * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -96,7 +96,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -318,7 +318,7 @@ public function checkData() try { $this->setQty($qty); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->setHasError(true); $this->setMessage($e->getMessage()); } catch (\Exception $e) { @@ -328,7 +328,7 @@ public function checkData() try { $this->getProduct()->getTypeInstance()->checkProductBuyState($this->getProduct()); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->setHasError(true)->setMessage($e->getMessage()); $this->getQuote()->setHasError( true diff --git a/app/code/Magento/Sales/Model/Quote/Item/Option.php b/app/code/Magento/Sales/Model/Quote/Item/Option.php index aa32403114493..8fb48d48884c6 100644 --- a/app/code/Magento/Sales/Model/Quote/Item/Option.php +++ b/app/code/Magento/Sales/Model/Quote/Item/Option.php @@ -38,7 +38,7 @@ * @method \Magento\Sales\Model\Quote\Item\Option setCode(string $value) * @method \Magento\Sales\Model\Quote\Item\Option setValue(string $value) */ -class Option extends \Magento\Core\Model\AbstractModel implements +class Option extends \Magento\Model\AbstractModel implements \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface { /** diff --git a/app/code/Magento/Sales/Model/Quote/Payment.php b/app/code/Magento/Sales/Model/Quote/Payment.php index 1e163a5be9b05..4d0a13f29e969 100644 --- a/app/code/Magento/Sales/Model/Quote/Payment.php +++ b/app/code/Magento/Sales/Model/Quote/Payment.php @@ -93,7 +93,7 @@ class Payment extends \Magento\Payment\Model\Info * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Encryption\EncryptorInterface $encryptor * @param \Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -103,7 +103,7 @@ public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Encryption\EncryptorInterface $encryptor, \Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -151,7 +151,7 @@ public function getQuote() * * @param array $data * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function importData(array $data) { @@ -179,7 +179,7 @@ public function importData(array $data) $this->getQuote() ) ) { - throw new \Magento\Core\Exception(__('The requested Payment Method is not available.')); + throw new \Magento\Model\Exception(__('The requested Payment Method is not available.')); } $method->assignData($data); @@ -202,7 +202,7 @@ protected function _beforeSave() } try { $method = $this->getMethodInstance(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { return parent::_beforeSave(); } $method->prepareSave(); diff --git a/app/code/Magento/Sales/Model/Resource/AbstractResource.php b/app/code/Magento/Sales/Model/Resource/AbstractResource.php index d0fa595d64768..22dd41d55b335 100644 --- a/app/code/Magento/Sales/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Sales/Model/Resource/AbstractResource.php @@ -32,7 +32,7 @@ * @package Magento_Sales * @author Magento Core Team */ -abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\AbstractDb +abstract class AbstractResource extends \Magento\Model\Resource\Db\AbstractDb { /** * Data converter object @@ -59,10 +59,10 @@ public function __construct(\Magento\App\Resource $resource, \Magento\Stdlib\Dat /** * Prepare data for save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return array */ - protected function _prepareDataForSave(\Magento\Core\Model\AbstractModel $object) + protected function _prepareDataForSave(\Magento\Model\AbstractModel $object) { $currentTime = $this->dateTime->now(); if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) { @@ -86,10 +86,10 @@ protected function _shouldBeConverted() /** * Perform actions before object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { parent::_beforeSave($object); @@ -104,10 +104,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * Perform actions after object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { if (true == $this->_shouldBeConverted()) { foreach ($object->getData() as $fieldName => $fieldValue) { @@ -120,10 +120,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Perform actions after object load * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(\Magento\Model\AbstractModel $object) { if (true == $this->_shouldBeConverted()) { foreach ($object->getData() as $fieldName => $fieldValue) { diff --git a/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php b/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php index 875a681eff33f..5336327dfc25c 100644 --- a/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php +++ b/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php @@ -32,14 +32,14 @@ * @package Magento_Sales * @author Magento Core Team */ -abstract class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +abstract class AbstractCollection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Check if $attribute is \Magento\Eav\Model\Entity\Attribute and convert to string field name * * @param string|\Magento\Eav\Model\Entity\Attribute $attribute * @return string - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _attributeToField($attribute) { @@ -50,7 +50,7 @@ protected function _attributeToField($attribute) $field = $attribute->getAttributeCode(); } if (!$field) { - throw new \Magento\Core\Exception(__('We cannot determine the field name.')); + throw new \Magento\Model\Exception(__('We cannot determine the field name.')); } return $field; } diff --git a/app/code/Magento/Sales/Model/Resource/Helper.php b/app/code/Magento/Sales/Model/Resource/Helper.php index 371caba1fe51d..503f30206f1be 100644 --- a/app/code/Magento/Sales/Model/Resource/Helper.php +++ b/app/code/Magento/Sales/Model/Resource/Helper.php @@ -28,7 +28,7 @@ /** * Sales Mysql resource helper model */ -class Helper extends \Magento\Core\Model\Resource\Helper implements HelperInterface +class Helper extends \Magento\DB\Helper implements HelperInterface { /** * @var \Magento\Reports\Model\Resource\Helper diff --git a/app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php b/app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php index 811160d32987a..88ee734ab871f 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php +++ b/app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php @@ -123,14 +123,14 @@ public function __construct( * @param array $joinCondition * @param string $column * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addVirtualGridColumn($alias, $table, $joinCondition, $column) { $table = $this->getTable($table); if (!in_array($alias, $this->getGridColumns())) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Please specify a valid grid column alias name that exists in the grid table.') ); } @@ -304,11 +304,11 @@ public function getGridTable() /** * Before save object attribute * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $attribute * @return $this */ - protected function _beforeSaveAttribute(\Magento\Core\Model\AbstractModel $object, $attribute) + protected function _beforeSaveAttribute(\Magento\Model\AbstractModel $object, $attribute) { if ($this->_eventObject && $this->_eventPrefix) { $this->_eventManager->dispatch( @@ -322,11 +322,11 @@ protected function _beforeSaveAttribute(\Magento\Core\Model\AbstractModel $objec /** * After save object attribute * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $attribute * @return $this */ - protected function _afterSaveAttribute(\Magento\Core\Model\AbstractModel $object, $attribute) + protected function _afterSaveAttribute(\Magento\Model\AbstractModel $object, $attribute) { if ($this->_eventObject && $this->_eventPrefix) { $this->_eventManager->dispatch( @@ -340,12 +340,12 @@ protected function _afterSaveAttribute(\Magento\Core\Model\AbstractModel $object /** * Perform actions after object save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $attribute * @return $this * @throws \Exception */ - public function saveAttribute(\Magento\Core\Model\AbstractModel $object, $attribute) + public function saveAttribute(\Magento\Model\AbstractModel $object, $attribute) { if ($attribute instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute) { $attribute = $attribute->getAttributeCode(); @@ -386,10 +386,10 @@ public function saveAttribute(\Magento\Core\Model\AbstractModel $object, $attrib /** * Perform actions before object save * - * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object + * @param \Magento\Model\AbstractModel|\Magento\Object $object * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { if ($this->_useIncrementId && !$object->getIncrementId()) { /* @var $entityType \Magento\Eav\Model\Entity\Type */ @@ -403,7 +403,7 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * Update field in table if model have been already saved * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param array $data * @return $this */ @@ -437,10 +437,10 @@ public function setMainTable($table) /** * Save object data * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - public function save(\Magento\Core\Model\AbstractModel $object) + public function save(\Magento\Model\AbstractModel $object) { if (!$object->getForceObjectSave()) { parent::save($object); diff --git a/app/code/Magento/Sales/Model/Resource/Order/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Address.php index f2f0fede4ee18..a577d1dceb3b4 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Address.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Address.php @@ -96,10 +96,10 @@ public function getAllAttributes() /** * Update related grid table after object save * - * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @param \Magento\Model\AbstractModel|\Magento\Object $object + * @return \Magento\Model\Resource\Db\AbstractDb */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { $resource = parent::_afterSave($object); if ($object->hasDataChanges() && $object->getOrder()) { diff --git a/app/code/Magento/Sales/Model/Resource/Order/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Collection.php index 3cfffd5282349..fdd1d301e762f 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Collection.php @@ -49,7 +49,7 @@ class Collection extends \Magento\Sales\Model\Resource\Collection\AbstractCollec protected $_eventObject = 'order_collection'; /** - * @var \Magento\Core\Model\Resource\Helper + * @var \Magento\DB\Helper */ protected $_coreResourceHelper; @@ -58,18 +58,18 @@ class Collection extends \Magento\Sales\Model\Resource\Collection\AbstractCollec * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\Resource\Helper $coreResourceHelper + * @param \Magento\DB\Helper $coreResourceHelper * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\Resource\Helper $coreResourceHelper, + \Magento\DB\Helper $coreResourceHelper, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_coreResourceHelper = $coreResourceHelper; diff --git a/app/code/Magento/Sales/Model/Resource/Order/Comment/Collection/AbstractCollection.php b/app/code/Magento/Sales/Model/Resource/Order/Comment/Collection/AbstractCollection.php index f6ebf20e23b60..2da874e2bed96 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Comment/Collection/AbstractCollection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Comment/Collection/AbstractCollection.php @@ -37,12 +37,12 @@ abstract class AbstractCollection extends \Magento\Sales\Model\Resource\Collecti /** * Set filter on comments by their parent item * - * @param \Magento\Core\Model\AbstractModel|int $parent + * @param \Magento\Model\AbstractModel|int $parent * @return $this */ public function setParentFilter($parent) { - if ($parent instanceof \Magento\Core\Model\AbstractModel) { + if ($parent instanceof \Magento\Model\AbstractModel) { $parent = $parent->getId(); } return $this->addFieldToFilter('parent_id', $parent); diff --git a/app/code/Magento/Sales/Model/Resource/Order/Payment/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Payment/Collection.php index 85c9d89013921..88aabc7198182 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Payment/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Payment/Collection.php @@ -56,7 +56,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection\Abstract * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Sales\Model\Payment\Method\Converter $converter * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -65,7 +65,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Sales\Model\Payment\Method\Converter $converter, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_converter = $converter; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php b/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php index eed4b27bf0332..6b8b37a381aae 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php @@ -149,9 +149,9 @@ public function getOrderWebsiteId($orderId) * * @param \Magento\Sales\Model\Order\Payment\Transaction $transaction * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $transaction) + protected function _beforeSave(\Magento\Model\AbstractModel $transaction) { $parentTxnId = $transaction->getData('parent_txn_id'); $txnId = $transaction->getData('txn_id'); @@ -161,7 +161,7 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $transaction) if ($parentTxnId) { if (!$txnId || !$orderId || !$paymentId) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We don\'t have enough information to save the parent transaction ID.') ); } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status.php b/app/code/Magento/Sales/Model/Resource/Order/Status.php index ed588e9e6457e..6d91bcbc42576 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status.php @@ -25,7 +25,7 @@ */ namespace Magento\Sales\Model\Resource\Order; -use Magento\Core\Exception; +use Magento\Model\Exception; /** * Order status resource model @@ -34,7 +34,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Status extends \Magento\Core\Model\Resource\Db\AbstractDb +class Status extends \Magento\Model\Resource\Db\AbstractDb { /** * Status labels table @@ -68,7 +68,7 @@ protected function _construct() * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return \Zend_Db_Select */ protected function _getLoadSelect($field, $value, $object) @@ -98,10 +98,10 @@ protected function _getLoadSelect($field, $value, $object) /** * Store labels getter * - * @param \Magento\Core\Model\AbstractModel $status + * @param \Magento\Model\AbstractModel $status * @return array */ - public function getStoreLabels(\Magento\Core\Model\AbstractModel $status) + public function getStoreLabels(\Magento\Model\AbstractModel $status) { $select = $this->_getWriteAdapter()->select()->from( $this->_labelsTable, @@ -116,10 +116,10 @@ public function getStoreLabels(\Magento\Core\Model\AbstractModel $status) /** * Save status labels per store * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { if ($object->hasStoreLabels()) { $labels = $object->getStoreLabels(); diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Status/Collection.php index 3281a01646509..7dfdb45f46505 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Internal constructor diff --git a/app/code/Magento/Sales/Model/Resource/Order/Tax.php b/app/code/Magento/Sales/Model/Resource/Order/Tax.php index 2621bdc0042c8..5dfb389887865 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Tax.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Tax.php @@ -32,7 +32,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Tax extends \Magento\Core\Model\Resource\Db\AbstractDb +class Tax extends \Magento\Model\Resource\Db\AbstractDb { /** * Model initialization diff --git a/app/code/Magento/Sales/Model/Resource/Order/Tax/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Tax/Collection.php index 0ec4a83d374a6..a0b8b62b2d06b 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Tax/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Tax/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Model initialization diff --git a/app/code/Magento/Sales/Model/Resource/Quote.php b/app/code/Magento/Sales/Model/Resource/Quote.php index 86315534a03fa..f91148fa76fca 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote.php +++ b/app/code/Magento/Sales/Model/Resource/Quote.php @@ -64,7 +64,7 @@ protected function _construct() * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return \Magento\DB\Select */ protected function _getLoadSelect($field, $value, $object) diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Address/Collection.php b/app/code/Magento/Sales/Model/Resource/Quote/Address/Collection.php index c8ac0bec8a40f..ab6add06a2cf7 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Address/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Address/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Event prefix diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Address/Item/Collection.php b/app/code/Magento/Sales/Model/Resource/Quote/Address/Item/Collection.php index 5a2b2865b1c92..97c29adde616b 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Address/Item/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Address/Item/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Address/Rate/Collection.php b/app/code/Magento/Sales/Model/Resource/Quote/Address/Rate/Collection.php index 33bcf0b1b407e..0c443ff57f9ef 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Address/Rate/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Address/Rate/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Whether to load fixed items only @@ -48,7 +48,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Sales\Model\Quote\Address\CarrierFactoryInterface $carrierFactory * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -57,7 +57,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Sales\Model\Quote\Address\CarrierFactoryInterface $carrierFactory, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_carrierFactory = $carrierFactory; diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Collection.php b/app/code/Magento/Sales/Model/Resource/Quote/Collection.php index 1dd818e1f4f5d..6dbf74fda590e 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Item/Collection.php b/app/code/Magento/Sales/Model/Resource/Quote/Item/Collection.php index 4dc759dd3997d..c1104e0d42d3e 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Item/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Item/Collection.php @@ -28,7 +28,7 @@ /** * Quote item resource collection */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Collection quote instance @@ -68,7 +68,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory * @param \Magento\Sales\Model\Quote\Config $quoteConfig * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -79,7 +79,7 @@ public function __construct( \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory, \Magento\Sales\Model\Quote\Config $quoteConfig, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_itemOptionCollectionFactory = $itemOptionCollectionFactory; diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Item/Option.php b/app/code/Magento/Sales/Model/Resource/Quote/Item/Option.php index 0c86a58a15a8b..16bf507e9ec14 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Item/Option.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Item/Option.php @@ -32,7 +32,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Option extends \Magento\Core\Model\Resource\Db\AbstractDb +class Option extends \Magento\Model\Resource\Db\AbstractDb { /** * Main table and field initialization diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Item/Option/Collection.php b/app/code/Magento/Sales/Model/Resource/Quote/Item/Option/Collection.php index fec5db123f8ea..12317cf9273ec 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Item/Option/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Item/Option/Collection.php @@ -34,7 +34,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Array of option ids grouped by item id diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Payment/Collection.php b/app/code/Magento/Sales/Model/Resource/Quote/Payment/Collection.php index a263d08cade01..d51b24729236f 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Payment/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Payment/Collection.php @@ -28,7 +28,7 @@ /** * Quote payments collection */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * @var \Magento\Sales\Model\Payment\Method\Converter @@ -42,7 +42,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Sales\Model\Payment\Method\Converter $converter * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -51,7 +51,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Sales\Model\Payment\Method\Converter $converter, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_converter = $converter; diff --git a/app/code/Magento/Sales/Model/Resource/Report.php b/app/code/Magento/Sales/Model/Resource/Report.php index bffc8c5a144f5..b2161eae0d3f2 100644 --- a/app/code/Magento/Sales/Model/Resource/Report.php +++ b/app/code/Magento/Sales/Model/Resource/Report.php @@ -32,7 +32,7 @@ * @package Magento_Sales * @author Magento Core Team */ -class Report extends \Magento\Core\Model\Resource\Db\AbstractDb +class Report extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Sales/Model/Service/Quote.php b/app/code/Magento/Sales/Model/Service/Quote.php index 88fa030eaa6fe..fd453a22aab81 100755 --- a/app/code/Magento/Sales/Model/Service/Quote.php +++ b/app/code/Magento/Sales/Model/Service/Quote.php @@ -82,7 +82,7 @@ class Quote protected $_customerSession; /** - * @var \Magento\Core\Model\Resource\TransactionFactory + * @var \Magento\DB\TransactionFactory */ protected $_transactionFactory; @@ -118,7 +118,7 @@ class Quote * @param \Magento\Sales\Model\Quote $quote * @param \Magento\Sales\Model\Convert\QuoteFactory $convertQuoteFactory * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Core\Model\Resource\TransactionFactory $transactionFactory + * @param \Magento\DB\TransactionFactory $transactionFactory * @param CustomerAccountServiceInterface $customerAccountService * @param CustomerAddressServiceInterface $customerAddressService * @param AddressBuilder $customerAddressBuilder @@ -130,7 +130,7 @@ public function __construct( \Magento\Sales\Model\Quote $quote, \Magento\Sales\Model\Convert\QuoteFactory $convertQuoteFactory, \Magento\Customer\Model\Session $customerSession, - \Magento\Core\Model\Resource\TransactionFactory $transactionFactory, + \Magento\DB\TransactionFactory $transactionFactory, CustomerAccountServiceInterface $customerAccountService, CustomerAddressServiceInterface $customerAddressService, AddressBuilder $customerAddressBuilder, @@ -410,10 +410,6 @@ public function submitOrderWithDataObject() ); throw $e; } - $this->_eventManager->dispatch( - 'sales_model_service_quote_submit_after', - array('order' => $order, 'quote' => $quote) - ); $this->_order = $order; return $order; } @@ -516,7 +512,7 @@ protected function _inactivateQuote() * Validate quote data before converting to order * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _validate() { @@ -524,26 +520,26 @@ protected function _validate() $address = $this->getQuote()->getShippingAddress(); $addressValidation = $address->validate(); if ($addressValidation !== true) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Please check the shipping address information. %1', implode(' ', $addressValidation)) ); } $method = $address->getShippingMethod(); $rate = $address->getShippingRateByCode($method); if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) { - throw new \Magento\Core\Exception(__('Please specify a shipping method.')); + throw new \Magento\Model\Exception(__('Please specify a shipping method.')); } } $addressValidation = $this->getQuote()->getBillingAddress()->validate(); if ($addressValidation !== true) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Please check the billing address information. %1', implode(' ', $addressValidation)) ); } if (!$this->getQuote()->getPayment()->getMethod()) { - throw new \Magento\Core\Exception(__('Please select a valid payment method.')); + throw new \Magento\Model\Exception(__('Please select a valid payment method.')); } return $this; diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index c0c1b5e76afe4..e6599110d7537 100644 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -69,4 +69,14 @@ + + + + Magento\Sales\Model\Order + Magento\Sales\Model\Order\Creditmemo + Magento\Sales\Model\Order\Invoice + Magento\Sales\Model\Order\Shipment + + + diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote.php index 9c83226309c56..6e9b76239cd40 100644 --- a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote.php +++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote.php @@ -186,7 +186,7 @@ public function saveAction() if ($id) { $model->load($id); if ($id != $model->getId()) { - throw new \Magento\Core\Exception(__('The wrong rule is specified.')); + throw new \Magento\Model\Exception(__('The wrong rule is specified.')); } } @@ -233,7 +233,7 @@ public function saveAction() } $this->_redirect('sales_rule/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $id = (int)$this->getRequest()->getParam('rule_id'); if (!empty($id)) { @@ -271,7 +271,7 @@ public function deleteAction() $this->messageManager->addSuccess(__('The rule has been deleted.')); $this->_redirect('sales_rule/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError( @@ -492,7 +492,7 @@ public function generateAction() $this->_view->getLayout()->initMessages(); $result['messages'] = $this->_view->getLayout()->getMessagesBlock()->getGroupedHtml(); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $result['error'] = $e->getMessage(); } catch (\Exception $e) { $result['error'] = __( diff --git a/app/code/Magento/SalesRule/Model/Coupon.php b/app/code/Magento/SalesRule/Model/Coupon.php index 23cf86b4a1296..5f89e4d5c9028 100644 --- a/app/code/Magento/SalesRule/Model/Coupon.php +++ b/app/code/Magento/SalesRule/Model/Coupon.php @@ -47,7 +47,7 @@ * @method int getType() * @method \Magento\SalesRule\Model\Coupon setType(int $value) */ -class Coupon extends \Magento\Core\Model\AbstractModel +class Coupon extends \Magento\Model\AbstractModel { /** * Coupon's owner rule instance diff --git a/app/code/Magento/SalesRule/Model/Coupon/Massgenerator.php b/app/code/Magento/SalesRule/Model/Coupon/Massgenerator.php index 23273b387bc41..001f9d6ba9c3c 100644 --- a/app/code/Magento/SalesRule/Model/Coupon/Massgenerator.php +++ b/app/code/Magento/SalesRule/Model/Coupon/Massgenerator.php @@ -34,7 +34,7 @@ * @package Magento_SalesRule * @author Magento Core Team */ -class Massgenerator extends \Magento\Core\Model\AbstractModel implements +class Massgenerator extends \Magento\Model\AbstractModel implements \Magento\SalesRule\Model\Coupon\CodegeneratorInterface { /** @@ -79,7 +79,7 @@ class Massgenerator extends \Magento\Core\Model\AbstractModel implements * @param \Magento\SalesRule\Model\CouponFactory $couponFactory * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -90,7 +90,7 @@ public function __construct( \Magento\SalesRule\Model\CouponFactory $couponFactory, \Magento\Stdlib\DateTime\DateTime $date, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -161,7 +161,7 @@ public function getDelimiter() /** * Generate Coupons Pool * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ public function generatePool() @@ -195,7 +195,7 @@ public function generatePool() $attempt = 0; do { if ($attempt >= $maxAttempts) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('We cannot create the requested Coupon Qty. Please check your settings and try again.') ); } diff --git a/app/code/Magento/SalesRule/Model/Resource/Coupon.php b/app/code/Magento/SalesRule/Model/Resource/Coupon.php index e41c343bdeb39..9bbf7e3559f2c 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Coupon.php +++ b/app/code/Magento/SalesRule/Model/Resource/Coupon.php @@ -25,7 +25,7 @@ */ namespace Magento\SalesRule\Model\Resource; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; /** * SalesRule Resource Coupon @@ -34,7 +34,7 @@ * @package Magento_SalesRule * @author Magento Core Team */ -class Coupon extends \Magento\Core\Model\Resource\Db\AbstractDb +class Coupon extends \Magento\Model\Resource\Db\AbstractDb { /** * Constructor adds unique fields diff --git a/app/code/Magento/SalesRule/Model/Resource/Coupon/Collection.php b/app/code/Magento/SalesRule/Model/Resource/Coupon/Collection.php index 866b2b5395be8..0a7c5125bda1a 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Coupon/Collection.php +++ b/app/code/Magento/SalesRule/Model/Resource/Coupon/Collection.php @@ -25,7 +25,7 @@ */ namespace Magento\SalesRule\Model\Resource\Coupon; -use Magento\Core\Model\Resource\Db\Collection\AbstractCollection; +use Magento\Model\Resource\Db\Collection\AbstractCollection; use Magento\Backend\Block\Widget\Grid\Column; use Magento\SalesRule\Model\Rule; diff --git a/app/code/Magento/SalesRule/Model/Resource/Coupon/Usage.php b/app/code/Magento/SalesRule/Model/Resource/Coupon/Usage.php index dabbf0a0fcf41..18f8dc6cc57ba 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Coupon/Usage.php +++ b/app/code/Magento/SalesRule/Model/Resource/Coupon/Usage.php @@ -32,7 +32,7 @@ * @package Magento_SalesRule * @author Magento Core Team */ -class Usage extends \Magento\Core\Model\Resource\Db\AbstractDb +class Usage extends \Magento\Model\Resource\Db\AbstractDb { /** * Constructor @@ -104,7 +104,7 @@ public function loadByCustomerCoupon(\Magento\Object $object, $customerId, $coup $object->setData($data); } } - if ($object instanceof \Magento\Core\Model\AbstractModel) { + if ($object instanceof \Magento\Model\AbstractModel) { $this->_afterLoad($object); } return $this; diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule.php b/app/code/Magento/SalesRule/Model/Resource/Rule.php index 852115887b80a..c864da287b325 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Rule.php +++ b/app/code/Magento/SalesRule/Model/Resource/Rule.php @@ -25,7 +25,7 @@ */ namespace Magento\SalesRule\Model\Resource; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; /** * Sales Rule resource model diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php b/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php index 911a75799c22d..bf38d356c0322 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php +++ b/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php @@ -64,7 +64,7 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Stdlib\DateTime\DateTime $date * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -73,7 +73,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Stdlib\DateTime\DateTime $date, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_date = $date; diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule/Customer.php b/app/code/Magento/SalesRule/Model/Resource/Rule/Customer.php index 50f387a1ee87b..ee72b972dac2a 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Rule/Customer.php +++ b/app/code/Magento/SalesRule/Model/Resource/Rule/Customer.php @@ -32,7 +32,7 @@ * @package Magento_SalesRule * @author Magento Core Team */ -class Customer extends \Magento\Core\Model\Resource\Db\AbstractDb +class Customer extends \Magento\Model\Resource\Db\AbstractDb { /** * Constructor diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule/Customer/Collection.php b/app/code/Magento/SalesRule/Model/Resource/Rule/Customer/Collection.php index b56263f4905ec..264ec080061aa 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Rule/Customer/Collection.php +++ b/app/code/Magento/SalesRule/Model/Resource/Rule/Customer/Collection.php @@ -32,7 +32,7 @@ * @package Magento_SalesRule * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Collection constructor diff --git a/app/code/Magento/SalesRule/Model/Rule.php b/app/code/Magento/SalesRule/Model/Rule.php index f5124c4aeb09d..bc164513f1cc0 100644 --- a/app/code/Magento/SalesRule/Model/Rule.php +++ b/app/code/Magento/SalesRule/Model/Rule.php @@ -210,7 +210,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * @param \Magento\SalesRule\Model\Rule\Condition\Product\CombineFactory $condProdCombineF * @param \Magento\SalesRule\Model\Resource\Coupon\Collection $couponCollection * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -225,7 +225,7 @@ public function __construct( \Magento\SalesRule\Model\Rule\Condition\Product\CombineFactory $condProdCombineF, \Magento\SalesRule\Model\Resource\Coupon\Collection $couponCollection, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -463,7 +463,7 @@ public function getCouponTypes() * @param bool $saveNewlyCreated Whether or not to save newly created coupon * @param int $saveAttemptCount Number of attempts to save newly created coupon * @return \Magento\SalesRule\Model\Coupon|null - * @throws \Exception|\Magento\Core\Exception + * @throws \Exception|\Magento\Model\Exception */ public function acquireCoupon($saveNewlyCreated = true, $saveAttemptCount = 10) { @@ -498,7 +498,7 @@ public function acquireCoupon($saveNewlyCreated = true, $saveAttemptCount = 10) try { $coupon->save(); } catch (\Exception $e) { - if ($e instanceof \Magento\Core\Exception || $coupon->getId()) { + if ($e instanceof \Magento\Model\Exception || $coupon->getId()) { throw $e; } $coupon->setCode( @@ -511,7 +511,7 @@ public function acquireCoupon($saveNewlyCreated = true, $saveAttemptCount = 10) } } if (!$ok) { - throw new \Magento\Core\Exception(__('Can\'t acquire coupon.')); + throw new \Magento\Model\Exception(__('Can\'t acquire coupon.')); } return $coupon; diff --git a/app/code/Magento/SalesRule/Model/Rule/Customer.php b/app/code/Magento/SalesRule/Model/Rule/Customer.php index c518d47ec5ec3..fb9a3b7a48270 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Customer.php +++ b/app/code/Magento/SalesRule/Model/Rule/Customer.php @@ -41,7 +41,7 @@ * @package Magento_SalesRule * @author Magento Core Team */ -class Customer extends \Magento\Core\Model\AbstractModel +class Customer extends \Magento\Model\AbstractModel { /** * Constructor diff --git a/app/code/Magento/SalesRule/Model/Validator.php b/app/code/Magento/SalesRule/Model/Validator.php index 5e3fc61af08f8..8a82a78ec3766 100644 --- a/app/code/Magento/SalesRule/Model/Validator.php +++ b/app/code/Magento/SalesRule/Model/Validator.php @@ -40,7 +40,7 @@ * @method mixed getCustomerGroupId() * @method \Magento\SalesRule\Model\Validator setCustomerGroupId($id) */ -class Validator extends \Magento\Core\Model\AbstractModel +class Validator extends \Magento\Model\AbstractModel { /** * Rule source collection @@ -129,7 +129,7 @@ class Validator extends \Magento\Core\Model\AbstractModel * @param \Magento\SalesRule\Model\CouponFactory $couponFactory * @param \Magento\SalesRule\Model\Rule\CustomerFactory $customerFactory * @param \Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory $calculatorFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -142,7 +142,7 @@ public function __construct( \Magento\SalesRule\Model\CouponFactory $couponFactory, \Magento\SalesRule\Model\Rule\CustomerFactory $customerFactory, \Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory $calculatorFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -773,12 +773,12 @@ protected function minFix( /** * @param int $key * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getRuleItemTotalsInfo($key) { if (empty($this->_rulesItemTotals[$key])) { - throw new \Magento\Core\Exception(__('Item totals are not set for the rule.')); + throw new \Magento\Model\Exception(__('Item totals are not set for the rule.')); } return $this->_rulesItemTotals[$key]; diff --git a/app/code/Magento/Sendfriend/Controller/Product.php b/app/code/Magento/Sendfriend/Controller/Product.php index b3f8e65303640..722509b8813f8 100644 --- a/app/code/Magento/Sendfriend/Controller/Product.php +++ b/app/code/Magento/Sendfriend/Controller/Product.php @@ -240,7 +240,7 @@ public function sendmailAction() $this->messageManager->addError(__('We found some problems with the data.')); } } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Some emails were not sent.')); diff --git a/app/code/Magento/Sendfriend/Model/Resource/Sendfriend.php b/app/code/Magento/Sendfriend/Model/Resource/Sendfriend.php index 1d4eb4028e877..5c470a58e6d08 100644 --- a/app/code/Magento/Sendfriend/Model/Resource/Sendfriend.php +++ b/app/code/Magento/Sendfriend/Model/Resource/Sendfriend.php @@ -32,7 +32,7 @@ * @package Magento_Sendfriend * @author Magento Core Team */ -class Sendfriend extends \Magento\Core\Model\Resource\Db\AbstractDb +class Sendfriend extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection and table diff --git a/app/code/Magento/Sendfriend/Model/Resource/Sendfriend/Collection.php b/app/code/Magento/Sendfriend/Model/Resource/Sendfriend/Collection.php index 23b1bae0a5ee3..91f3ae54fbe2c 100644 --- a/app/code/Magento/Sendfriend/Model/Resource/Sendfriend/Collection.php +++ b/app/code/Magento/Sendfriend/Model/Resource/Sendfriend/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Sendfriend * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Init resource collection diff --git a/app/code/Magento/Sendfriend/Model/Sendfriend.php b/app/code/Magento/Sendfriend/Model/Sendfriend.php index d41f8db64d54e..da257a10f5a50 100644 --- a/app/code/Magento/Sendfriend/Model/Sendfriend.php +++ b/app/code/Magento/Sendfriend/Model/Sendfriend.php @@ -25,7 +25,7 @@ */ namespace Magento\Sendfriend\Model; -use Magento\Core\Exception as CoreException; +use Magento\Model\Exception as CoreException; /** * SendFriend Log @@ -41,7 +41,7 @@ * @package Magento_Sendfriend * @author Magento Core Team */ -class Sendfriend extends \Magento\Core\Model\AbstractModel +class Sendfriend extends \Magento\Model\AbstractModel { /** * Recipient Names @@ -114,16 +114,21 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel */ protected $_escaper; + /** + * @var \Magento\Translate\Inline\StateInterface + */ + protected $inlineTranslation; + /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\TranslateInterface $translate * @param \Magento\Catalog\Helper\Image $catalogImage * @param \Magento\Sendfriend\Helper\Data $sendfriendData * @param \Magento\Escaper $escaper - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -132,20 +137,20 @@ public function __construct( \Magento\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Mail\Template\TransportBuilder $transportBuilder, - \Magento\TranslateInterface $translate, \Magento\Catalog\Helper\Image $catalogImage, \Magento\Sendfriend\Helper\Data $sendfriendData, \Magento\Escaper $escaper, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Translate\Inline\StateInterface $inlineTranslation, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->_storeManager = $storeManager; $this->_transportBuilder = $transportBuilder; - $this->_translate = $translate; $this->_catalogImage = $catalogImage; $this->_sendfriendData = $sendfriendData; $this->_escaper = $escaper; + $this->inlineTranslation = $inlineTranslation; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -166,13 +171,12 @@ protected function _construct() public function send() { if ($this->isExceedLimit()) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('You\'ve met your limit of %1 sends in an hour.', $this->getMaxSendsToFriend()) ); } - $translate = $this->_translate->getTranslateInline(); - $this->_translate->setTranslateInline(false); + $this->inlineTranslation->suspend(); $message = nl2br(htmlspecialchars($this->getSender()->getMessage())); $sender = array( @@ -209,7 +213,9 @@ public function send() $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); } - $this->_translate->setTranslateInline($translate); + + $this->inlineTranslation->resume(); + $this->_incrementSentCount(); return $this; @@ -277,14 +283,14 @@ public function setCookie($cookie) /** * Retrieve Cookie instance * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\Stdlib\Cookie */ public function getCookie() { $cookie = $this->_getData('_cookie'); if (!$cookie instanceof \Magento\Stdlib\Cookie) { - throw new \Magento\Core\Exception(__('Please define a correct Cookie instance.')); + throw new \Magento\Model\Exception(__('Please define a correct Cookie instance.')); } return $cookie; } @@ -402,14 +408,14 @@ public function setProduct($product) /** * Retrieve Product instance * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\Catalog\Model\Product */ public function getProduct() { $product = $this->_getData('_product'); if (!$product instanceof \Magento\Catalog\Model\Product) { - throw new \Magento\Core\Exception(__('Please define a correct Product instance.')); + throw new \Magento\Model\Exception(__('Please define a correct Product instance.')); } return $product; } @@ -432,14 +438,14 @@ public function setSender($sender) /** * Retrieve Sender Information Object * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\Object */ public function getSender() { $sender = $this->_getData('_sender'); if (!$sender instanceof \Magento\Object) { - throw new \Magento\Core\Exception(__('Please define the correct Sender information.')); + throw new \Magento\Model\Exception(__('Please define the correct Sender information.')); } return $sender; } @@ -590,8 +596,8 @@ protected function _sentCountByIp($increment = false) */ public function register() { - if (!$this->_coreRegistry->registry('send_to_friend_model')) { - $this->_coreRegistry->register('send_to_friend_model', $this); + if (!$this->_registry->registry('send_to_friend_model')) { + $this->_registry->register('send_to_friend_model', $this); } return $this; } diff --git a/app/code/Magento/Service/Exception.php b/app/code/Magento/Service/Exception.php index 3fc43d9f34041..9173ba42eac47 100644 --- a/app/code/Magento/Service/Exception.php +++ b/app/code/Magento/Service/Exception.php @@ -25,7 +25,7 @@ */ namespace Magento\Service; -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { /** @var array */ protected $_parameters; diff --git a/app/code/Magento/Service/etc/module.xml b/app/code/Magento/Service/etc/module.xml index 128941add1d60..38cd40bff9e57 100644 --- a/app/code/Magento/Service/etc/module.xml +++ b/app/code/Magento/Service/etc/module.xml @@ -24,12 +24,5 @@ */ --> - - - - - - - - + diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment.php index 28e4d7ad1d9d9..674845c9ff856 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment.php @@ -88,7 +88,7 @@ protected function _getItemQtys() /** * Initialize shipment model instance * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\Sales\Model\Order\Shipment|bool */ protected function _initShipment() @@ -136,7 +136,7 @@ protected function _initShipment() if ($tracks) { foreach ($tracks as $data) { if (empty($data['number'])) { - throw new \Magento\Core\Exception(__('Please enter a tracking number.')); + throw new \Magento\Model\Exception(__('Please enter a tracking number.')); } $track = $this->_objectManager->create('Magento\Sales\Model\Order\Shipment\Track')->addData($data); $shipment->addTrack($track); @@ -158,7 +158,7 @@ protected function _saveShipment($shipment) { $shipment->getOrder()->setIsInProcess(true); $transactionSave = $this->_objectManager->create( - 'Magento\Core\Model\Resource\Transaction' + 'Magento\DB\Transaction' )->addObject( $shipment )->addObject( @@ -284,7 +284,7 @@ public function saveAction() $isNeedCreateLabel ? $shipmentCreatedMessage . ' ' . $labelCreatedMessage : $shipmentCreatedMessage ); $this->_objectManager->get('Magento\Backend\Model\Session')->getCommentText(true); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if ($isNeedCreateLabel) { $responseAjax->setError(true); $responseAjax->setMessage($e->getMessage()); @@ -332,7 +332,7 @@ public function emailAction() } $this->messageManager->addSuccess(__('You sent the shipment.')); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Cannot send shipment information.')); @@ -344,7 +344,7 @@ public function emailAction() * Add new tracking number action * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addTrackAction() { @@ -353,10 +353,10 @@ public function addTrackAction() $number = $this->getRequest()->getPost('number'); $title = $this->getRequest()->getPost('title'); if (empty($carrier)) { - throw new \Magento\Core\Exception(__('Please specify a carrier.')); + throw new \Magento\Model\Exception(__('Please specify a carrier.')); } if (empty($number)) { - throw new \Magento\Core\Exception(__('Please enter a tracking number.')); + throw new \Magento\Model\Exception(__('Please enter a tracking number.')); } $shipment = $this->_initShipment(); if ($shipment) { @@ -379,7 +379,7 @@ public function addTrackAction() 'message' => __('Cannot initialize shipment for adding tracking number.') ); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $response = array('error' => true, 'message' => $e->getMessage()); } catch (\Exception $e) { $response = array('error' => true, 'message' => __('Cannot add tracking number.')); @@ -435,7 +435,7 @@ public function addCommentAction() $this->getRequest()->setParam('shipment_id', $this->getRequest()->getParam('id')); $data = $this->getRequest()->getPost('comment'); if (empty($data['comment'])) { - throw new \Magento\Core\Exception(__("The comment text field cannot be empty.")); + throw new \Magento\Model\Exception(__("The comment text field cannot be empty.")); } $shipment = $this->_initShipment(); $shipment->addComment( @@ -448,7 +448,7 @@ public function addCommentAction() $this->_view->loadLayout(false); $response = $this->_view->getLayout()->getBlock('shipment_comments')->toHtml(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $response = array('error' => true, 'message' => $e->getMessage()); $response = $this->_objectManager->get('Magento\Core\Helper\Data')->jsonEncode($response); } catch (\Exception $e) { @@ -462,7 +462,7 @@ public function addCommentAction() * Create shipping label for specific shipment with validation. * * @param \Magento\Sales\Model\Order\Shipment $shipment - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return bool */ protected function _createShippingLabel(\Magento\Sales\Model\Order\Shipment $shipment) @@ -482,7 +482,7 @@ protected function _createShippingLabel(\Magento\Sales\Model\Order\Shipment $shi $shipment ); if ($response->hasErrors()) { - throw new \Magento\Core\Exception($response->getErrors()); + throw new \Magento\Model\Exception($response->getErrors()); } if (!$response->hasInfo()) { return false; @@ -537,7 +537,7 @@ public function createLabelAction() $this->messageManager->addSuccess(__('You created the shipping label.')); $response->setOk(true); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $response->setError(true); $response->setMessage($e->getMessage()); } catch (\Exception $e) { @@ -585,7 +585,7 @@ public function printLabelAction() 'application/pdf' ); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->_objectManager->get('Magento\Logger')->logException($e); diff --git a/app/code/Magento/Shipping/Model/Carrier/AbstractCarrier.php b/app/code/Magento/Shipping/Model/Carrier/AbstractCarrier.php index 4b05ad7bd5a9f..0917ea8b89095 100644 --- a/app/code/Magento/Shipping/Model/Carrier/AbstractCarrier.php +++ b/app/code/Magento/Shipping/Model/Carrier/AbstractCarrier.php @@ -275,7 +275,7 @@ public function getDeliveryConfirmationTypes(\Magento\Object $params = null) /** * @param \Magento\Sales\Model\Quote\Address\RateRequest $request - * @return $this|bool|false|\Magento\Core\Model\AbstractModel + * @return $this|bool|false|\Magento\Model\AbstractModel */ public function checkAvailableShipCountries(\Magento\Sales\Model\Quote\Address\RateRequest $request) { diff --git a/app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php b/app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php index ba94ee15e5336..9d9cdd0634cb2 100644 --- a/app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php +++ b/app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php @@ -23,7 +23,7 @@ */ namespace Magento\Shipping\Model\Carrier; -use Magento\Core\Exception; +use Magento\Model\Exception; use Magento\Sales\Model\Quote\Address\RateRequest; use Magento\Sales\Model\Quote\Address\RateResult\Error; use Magento\Shipping\Model\Shipment\Request; diff --git a/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php b/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php index e02d2e73a810a..37234cbc20696 100644 --- a/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php +++ b/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php @@ -53,12 +53,12 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\TranslateInterface $translate * @param \Magento\App\Filesystem $filesystem * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Shipping\Helper\Carrier $carrierHelper * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\View\LayoutInterface $layout @@ -71,12 +71,12 @@ public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Stdlib\String $string, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\TranslateInterface $translate, \Magento\App\Filesystem $filesystem, \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Translate\Inline\StateInterface $inlineTranslation, Carrier $carrierHelper, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\View\LayoutInterface $layout, @@ -92,12 +92,12 @@ public function __construct( $paymentData, $string, $coreStoreConfig, - $translate, $filesystem, $pdfConfig, $pdfTotalFactory, $pdfItemsFactory, $localeDate, + $inlineTranslation, $data ); } diff --git a/app/code/Magento/Shipping/Model/Order/Track.php b/app/code/Magento/Shipping/Model/Order/Track.php index 158d3c6c2a0e9..3ae690d75a9db 100644 --- a/app/code/Magento/Shipping/Model/Order/Track.php +++ b/app/code/Magento/Shipping/Model/Order/Track.php @@ -62,7 +62,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory * @param \Magento\Shipping\Model\CarrierFactory $carrierFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data * @@ -76,7 +76,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory, \Magento\Shipping\Model\CarrierFactory $carrierFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Shipping/Model/Shipping/Labels.php b/app/code/Magento/Shipping/Model/Shipping/Labels.php index 2daf195de2036..a3d2e77ca165f 100644 --- a/app/code/Magento/Shipping/Model/Shipping/Labels.php +++ b/app/code/Magento/Shipping/Model/Shipping/Labels.php @@ -85,7 +85,7 @@ public function __construct( * * @param Shipment $orderShipment * @return \Magento\Object - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function requestToShipment(Shipment $orderShipment) { @@ -97,7 +97,7 @@ public function requestToShipment(Shipment $orderShipment) $shipmentCarrier = $this->_carrierFactory->create($order->getShippingMethod(true)->getCarrierCode()); $baseCurrencyCode = $this->_storeManager->getStore($shipmentStoreId)->getBaseCurrencyCode(); if (!$shipmentCarrier) { - throw new \Magento\Core\Exception('Invalid carrier: ' . $shippingMethod->getCarrierCode()); + throw new \Magento\Model\Exception('Invalid carrier: ' . $shippingMethod->getCarrierCode()); } $shipperRegionCode = $this->_coreStoreConfig->getConfig(Shipment::XML_PATH_STORE_REGION_ID, $shipmentStoreId); if (is_numeric($shipperRegionCode)) { @@ -129,7 +129,7 @@ public function requestToShipment(Shipment $orderShipment) $shipmentStoreId ) ) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'We don\'t have enough information to create shipping labels. Please make sure your store information and settings are complete.' ) diff --git a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap.php b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap.php index 698b03a3f5725..5c1c4b9f560e7 100644 --- a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap.php +++ b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap.php @@ -301,7 +301,7 @@ public function generateAction() $this->messageManager->addSuccess( __('The sitemap "%1" has been generated.', $sitemap->getSitemapFilename()) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong generating the sitemap.')); diff --git a/app/code/Magento/Sitemap/Model/Observer.php b/app/code/Magento/Sitemap/Model/Observer.php index 368300de98e21..ee0a80569fe1e 100644 --- a/app/code/Magento/Sitemap/Model/Observer.php +++ b/app/code/Magento/Sitemap/Model/Observer.php @@ -75,34 +75,34 @@ class Observer protected $_transportBuilder; /** - * @var \Magento\TranslateInterface + * @var \Magento\Core\Model\StoreManagerInterface */ - protected $_translateModel; + protected $_storeManager; /** - * @var \Magento\Core\Model\StoreManagerInterface + * @var \Magento\Translate\Inline\StateInterface */ - protected $_storeManager; + protected $inlineTranslation; /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param Resource\Sitemap\CollectionFactory $collectionFactory - * @param \Magento\TranslateInterface $translateModel * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Mail\Template\TransportBuilder $transportBuilder + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Sitemap\Model\Resource\Sitemap\CollectionFactory $collectionFactory, - \Magento\TranslateInterface $translateModel, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Mail\Template\TransportBuilder $transportBuilder + \Magento\Mail\Template\TransportBuilder $transportBuilder, + \Magento\Translate\Inline\StateInterface $inlineTranslation ) { $this->_coreStoreConfig = $coreStoreConfig; $this->_collectionFactory = $collectionFactory; - $this->_translateModel = $translateModel; $this->_storeManager = $storeManager; $this->_transportBuilder = $transportBuilder; + $this->inlineTranslation = $inlineTranslation; } /** @@ -133,8 +133,7 @@ public function scheduledGenerateSitemaps($schedule) } if ($errors && $this->_coreStoreConfig->getConfig(self::XML_PATH_ERROR_RECIPIENT)) { - $translate = $this->_translateModel->getTranslateInline(); - $this->_translateModel->setTranslateInline(false); + $this->inlineTranslation->suspend(); $this->_transportBuilder->setTemplateIdentifier( $this->_coreStoreConfig->getConfig(self::XML_PATH_ERROR_TEMPLATE) @@ -153,7 +152,7 @@ public function scheduledGenerateSitemaps($schedule) $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); - $this->_translateModel->setTranslateInline($translate); + $this->inlineTranslation->resume(); } } } diff --git a/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php b/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php index 2ed955eddecf3..c2abe1e58f99a 100644 --- a/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php +++ b/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Category extends \Magento\Core\Model\Resource\Db\AbstractDb +class Category extends \Magento\Model\Resource\Db\AbstractDb { /** * Collection Zend Db select diff --git a/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php b/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php index d93916921a112..14b7f774cf5fa 100644 --- a/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php +++ b/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Product extends \Magento\Core\Model\Resource\Db\AbstractDb +class Product extends \Magento\Model\Resource\Db\AbstractDb { const NOT_SELECTED_IMAGE = 'no_selection'; diff --git a/app/code/Magento/Sitemap/Model/Resource/Cms/Page.php b/app/code/Magento/Sitemap/Model/Resource/Cms/Page.php index 9bbddafa25e0e..d5bd7e03aadd3 100644 --- a/app/code/Magento/Sitemap/Model/Resource/Cms/Page.php +++ b/app/code/Magento/Sitemap/Model/Resource/Cms/Page.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Page extends \Magento\Core\Model\Resource\Db\AbstractDb +class Page extends \Magento\Model\Resource\Db\AbstractDb { /** * Init resource model (catalog/category) diff --git a/app/code/Magento/Sitemap/Model/Resource/Sitemap.php b/app/code/Magento/Sitemap/Model/Resource/Sitemap.php index 8ca469b82197f..ada1a609e6b20 100644 --- a/app/code/Magento/Sitemap/Model/Resource/Sitemap.php +++ b/app/code/Magento/Sitemap/Model/Resource/Sitemap.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Sitemap extends \Magento\Core\Model\Resource\Db\AbstractDb +class Sitemap extends \Magento\Model\Resource\Db\AbstractDb { /** * Init resource model diff --git a/app/code/Magento/Sitemap/Model/Resource/Sitemap/Collection.php b/app/code/Magento/Sitemap/Model/Resource/Sitemap/Collection.php index 1f420341a7836..998e10cad9ff8 100644 --- a/app/code/Magento/Sitemap/Model/Resource/Sitemap/Collection.php +++ b/app/code/Magento/Sitemap/Model/Resource/Sitemap/Collection.php @@ -30,7 +30,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Init collection diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php index 070d1e091d292..84870f3c64f35 100644 --- a/app/code/Magento/Sitemap/Model/Sitemap.php +++ b/app/code/Magento/Sitemap/Model/Sitemap.php @@ -41,7 +41,7 @@ * @method int getStoreId() * @method \Magento\Sitemap\Model\Sitemap setStoreId(int $value) */ -class Sitemap extends \Magento\Core\Model\AbstractModel +class Sitemap extends \Magento\Model\AbstractModel { const OPEN_TAG_KEY = 'start'; @@ -172,7 +172,7 @@ class Sitemap extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\RequestInterface $request * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -189,7 +189,7 @@ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\RequestInterface $request, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -220,14 +220,14 @@ protected function _construct() * Get file handler * * @return \Magento\Filesystem\File\WriteInterface - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getStream() { if ($this->_stream) { return $this->_stream; } else { - throw new \Magento\Core\Exception(__('File handler unreachable')); + throw new \Magento\Model\Exception(__('File handler unreachable')); } } @@ -289,8 +289,8 @@ protected function _initSitemapItems() /** * Check sitemap file location and permissions * - * @return \Magento\Core\Model\AbstractModel - * @throws \Magento\Core\Exception + * @return \Magento\Model\AbstractModel + * @throws \Magento\Model\Exception */ protected function _beforeSave() { @@ -300,13 +300,13 @@ protected function _beforeSave() * Check path is allow */ if ($path && preg_match('#\.\.[\\\/]#', $path)) { - throw new \Magento\Core\Exception(__('Please define a correct path.')); + throw new \Magento\Model\Exception(__('Please define a correct path.')); } /** * Check exists and writable path */ if (!$this->_directory->isExist($path)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Please create the specified folder "%1" before saving the sitemap.', $this->_escaper->escapeHtml($this->getSitemapPath()) @@ -315,7 +315,7 @@ protected function _beforeSave() } if (!$this->_directory->isWritable($path)) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('Please make sure that "%1" is writable by the web-server.', $this->getSitemapPath()) ); } @@ -323,7 +323,7 @@ protected function _beforeSave() * Check allow filename */ if (!preg_match('#^[a-zA-Z0-9_\.]+$#', $this->getSitemapFilename())) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'Please use only letters (a-z or A-Z), numbers (0-9) or underscores (_) in the filename. No spaces or other characters are allowed.' ) @@ -523,7 +523,7 @@ protected function _getSitemapIndexRow($sitemapFilename, $lastmod = null) * @param null|string $fileName * @param string $type * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _createSitemap($fileName = null, $type = self::TYPE_URL) { diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate.php index 0243046c5d2cd..c44192a20cbd1 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate.php +++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate.php @@ -132,7 +132,7 @@ public function saveAction() $this->messageManager->addSuccess(__('The tax rate has been saved.')); $this->getResponse()->setRedirect($this->getUrl("*/*/")); return true; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->_objectManager->get('Magento\Backend\Model\Session')->setFormData($ratePost); $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { @@ -166,7 +166,7 @@ public function ajaxSaveAction() 'code' => $rate->getCode() ) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $responseContent = $this->_objectManager->get( 'Magento\Core\Helper\Data' )->jsonEncode( @@ -275,7 +275,7 @@ public function deleteAction() $this->messageManager->addSuccess(__('The tax rate has been deleted.')); $this->getResponse()->setRedirect($this->getUrl("*/*/")); return true; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Something went wrong deleting this rate.')); @@ -312,7 +312,7 @@ public function ajaxDeleteAction() )->jsonEncode( array('success' => true, 'error_message' => '') ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $responseContent = $this->_objectManager->get( 'Magento\Core\Helper\Data' )->jsonEncode( @@ -408,7 +408,7 @@ public function importPostAction() $importHandler->importFromCsvFile($this->getRequest()->getFiles('import_rates_file')); $this->messageManager->addSuccess(__('The tax rate has been imported.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Invalid file upload attempt')); diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule.php index daab190806e43..1d39bb8b3f90c 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rule.php +++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule.php @@ -132,7 +132,7 @@ public function saveAction() $this->_redirect('tax/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Something went wrong saving this tax rule.')); @@ -165,7 +165,7 @@ public function deleteAction() $this->_redirect('tax/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Something went wrong deleting this tax rule.')); diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Tax.php b/app/code/Magento/Tax/Controller/Adminhtml/Tax.php index aff2295fb2e5d..59a670231ee7b 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Tax.php +++ b/app/code/Magento/Tax/Controller/Adminhtml/Tax.php @@ -60,7 +60,7 @@ public function ajaxSaveAction() 'class_name' => $class->getClassName() ) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $responseContent = $this->_objectManager->get( 'Magento\Core\Helper\Data' )->jsonEncode( @@ -99,7 +99,7 @@ public function ajaxDeleteAction() )->jsonEncode( array('success' => true, 'error_message' => '') ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $responseContent = $this->_objectManager->get( 'Magento\Core\Helper\Data' )->jsonEncode( @@ -120,7 +120,7 @@ public function ajaxDeleteAction() * * @param string $classType * @return string processed class type - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _processClassType($classType) { @@ -129,7 +129,7 @@ protected function _processClassType($classType) \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT ); if (!in_array($classType, $validClassTypes)) { - throw new \Magento\Core\Exception(__('Invalid type of tax class specified.')); + throw new \Magento\Model\Exception(__('Invalid type of tax class specified.')); } return $classType; } @@ -139,13 +139,13 @@ protected function _processClassType($classType) * * @param string $className * @return string processed class name - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _processClassName($className) { $className = trim($this->_objectManager->get('Magento\Escaper')->escapeHtml($className)); if ($className == '') { - throw new \Magento\Core\Exception(__('Invalid name of tax class specified.')); + throw new \Magento\Model\Exception(__('Invalid name of tax class specified.')); } return $className; } diff --git a/app/code/Magento/Tax/Exception.php b/app/code/Magento/Tax/Exception.php index 7a464a47c2378..a952e07d0804b 100644 --- a/app/code/Magento/Tax/Exception.php +++ b/app/code/Magento/Tax/Exception.php @@ -25,6 +25,6 @@ */ namespace Magento\Tax; -class Exception extends \Magento\Core\Exception +class Exception extends \Magento\Model\Exception { } diff --git a/app/code/Magento/Tax/Model/Calculation.php b/app/code/Magento/Tax/Model/Calculation.php index 15a3fd5ba42a2..81df6986bf783 100644 --- a/app/code/Magento/Tax/Model/Calculation.php +++ b/app/code/Magento/Tax/Model/Calculation.php @@ -34,7 +34,7 @@ /** * Tax Calculation Model */ -class Calculation extends \Magento\Core\Model\AbstractModel +class Calculation extends \Magento\Model\AbstractModel { const CALC_TAX_BEFORE_DISCOUNT_ON_EXCL = '0_0'; diff --git a/app/code/Magento/Tax/Model/Calculation/Rate.php b/app/code/Magento/Tax/Model/Calculation/Rate.php index b499ec2c18263..ca25ab6f9837c 100644 --- a/app/code/Magento/Tax/Model/Calculation/Rate.php +++ b/app/code/Magento/Tax/Model/Calculation/Rate.php @@ -48,7 +48,7 @@ */ namespace Magento\Tax\Model\Calculation; -class Rate extends \Magento\Core\Model\AbstractModel +class Rate extends \Magento\Model\AbstractModel { /** * @var mixed @@ -75,7 +75,7 @@ class Rate extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Tax\Model\Calculation\Rate\TitleFactory $taxTitleFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -84,7 +84,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Tax\Model\Calculation\Rate\TitleFactory $taxTitleFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -107,7 +107,7 @@ protected function _construct() * Prepare location settings and tax postcode before save rate * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeSave() { @@ -119,11 +119,11 @@ protected function _beforeSave() $this->getTaxPostcode() === ''; if ($isEmptyValues || $isWrongRange) { - throw new \Magento\Core\Exception(__('Please fill all required fields with valid information.')); + throw new \Magento\Model\Exception(__('Please fill all required fields with valid information.')); } if (!is_numeric($this->getRate()) || $this->getRate() <= 0) { - throw new \Magento\Core\Exception(__('Rate Percent should be a positive number.')); + throw new \Magento\Model\Exception(__('Rate Percent should be a positive number.')); } if ($this->getZipIsRange()) { @@ -131,15 +131,15 @@ protected function _beforeSave() $zipTo = $this->getZipTo(); if (strlen($zipFrom) > 9 || strlen($zipTo) > 9) { - throw new \Magento\Core\Exception(__('Maximum zip code length is 9.')); + throw new \Magento\Model\Exception(__('Maximum zip code length is 9.')); } if (!is_numeric($zipFrom) || !is_numeric($zipTo) || $zipFrom < 0 || $zipTo < 0) { - throw new \Magento\Core\Exception(__('Zip code should not contain characters other than digits.')); + throw new \Magento\Model\Exception(__('Zip code should not contain characters other than digits.')); } if ($zipFrom > $zipTo) { - throw new \Magento\Core\Exception(__('Range To should be equal or greater than Range From.')); + throw new \Magento\Model\Exception(__('Range To should be equal or greater than Range From.')); } $this->setTaxPostcode($zipFrom . '-' . $zipTo); @@ -181,12 +181,12 @@ protected function _afterSave() * Processing object before delete data * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _beforeDelete() { if ($this->_isInRule()) { - throw new \Magento\Core\Exception(__('The tax rate cannot be removed. It exists in a tax rule.')); + throw new \Magento\Model\Exception(__('The tax rate cannot be removed. It exists in a tax rule.')); } return parent::_beforeDelete(); } diff --git a/app/code/Magento/Tax/Model/Calculation/Rate/Title.php b/app/code/Magento/Tax/Model/Calculation/Rate/Title.php index 92e3274cd4ba6..c40924e23ba1e 100644 --- a/app/code/Magento/Tax/Model/Calculation/Rate/Title.php +++ b/app/code/Magento/Tax/Model/Calculation/Rate/Title.php @@ -43,7 +43,7 @@ */ namespace Magento\Tax\Model\Calculation\Rate; -class Title extends \Magento\Core\Model\AbstractModel +class Title extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Tax/Model/Calculation/Rule.php b/app/code/Magento/Tax/Model/Calculation/Rule.php index 82c9f670f67a3..eb198bd8829f3 100644 --- a/app/code/Magento/Tax/Model/Calculation/Rule.php +++ b/app/code/Magento/Tax/Model/Calculation/Rule.php @@ -38,7 +38,7 @@ */ namespace Magento\Tax\Model\Calculation; -class Rule extends \Magento\Core\Model\AbstractModel +class Rule extends \Magento\Model\AbstractModel { /** * @var mixed @@ -102,7 +102,7 @@ class Rule extends \Magento\Core\Model\AbstractModel * @param \Magento\Tax\Helper\Data $taxHelper * @param \Magento\Tax\Model\ClassModel $taxClass * @param \Magento\Tax\Model\Calculation $calculation - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -112,7 +112,7 @@ public function __construct( \Magento\Tax\Helper\Data $taxHelper, \Magento\Tax\Model\ClassModel $taxClass, \Magento\Tax\Model\Calculation $calculation, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { diff --git a/app/code/Magento/Tax/Model/ClassModel.php b/app/code/Magento/Tax/Model/ClassModel.php index 747a906ba2ae0..f07cdec6488b5 100644 --- a/app/code/Magento/Tax/Model/ClassModel.php +++ b/app/code/Magento/Tax/Model/ClassModel.php @@ -40,7 +40,7 @@ */ namespace Magento\Tax\Model; -class ClassModel extends \Magento\Core\Model\AbstractModel +class ClassModel extends \Magento\Model\AbstractModel { /** * Defines Customer Tax Class string @@ -61,7 +61,7 @@ class ClassModel extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Tax\Model\TaxClass\Factory $classFactory - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -69,7 +69,7 @@ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Tax\Model\TaxClass\Factory $classFactory, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -89,18 +89,18 @@ public function _construct() * Check whether this class can be deleted * * @return bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function checkClassCanBeDeleted() { if (!$this->getId()) { - throw new \Magento\Core\Exception(__('This class no longer exists.')); + throw new \Magento\Model\Exception(__('This class no longer exists.')); } $typeModel = $this->_classFactory->create($this); if ($typeModel->getAssignedToRules()->getSize() > 0) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'You cannot delete this tax class because it is used in Tax Rules. You have to delete the rules it is used in first.' ) @@ -109,7 +109,7 @@ public function checkClassCanBeDeleted() $objectCount = $typeModel->getAssignedToObjects()->getSize(); if ($objectCount > 0) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __( 'You cannot delete this tax class because it is used for %1 %2(s).', $objectCount, diff --git a/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php b/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php index 2bd94c85d5448..ccc51315ddfe3 100644 --- a/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php +++ b/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php @@ -27,41 +27,12 @@ class IncludePrice extends \Magento\Core\Model\Config\Value { - /** - * @var \Magento\Core\Model\App - */ - protected $_app; - - /** - * @param \Magento\Model\Context $context - * @param \Magento\Registry $registry - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\App\ConfigInterface $config - * @param \Magento\Core\Model\App $app - * @param \Magento\Core\Model\Resource\AbstractResource $resource - * @param \Magento\Data\Collection\Db $resourceCollection - * @param array $data - */ - public function __construct( - \Magento\Model\Context $context, - \Magento\Registry $registry, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\App\ConfigInterface $config, - \Magento\Core\Model\App $app, - \Magento\Core\Model\Resource\AbstractResource $resource = null, - \Magento\Data\Collection\Db $resourceCollection = null, - array $data = array() - ) { - $this->_app = $app; - parent::__construct($context, $registry, $storeManager, $config, $resource, $resourceCollection, $data); - } - /** * @return void */ public function _afterSave() { parent::_afterSave(); - $this->_app->cleanCache('checkout_quote'); + $this->_cacheManager->clean(array('checkout_quote')); } } diff --git a/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php b/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php index 1069d3aaa8c26..95b4df47ab059 100644 --- a/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php +++ b/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php @@ -105,12 +105,12 @@ public function getRequiredCsvFields() * * @param array $file file info retrieved from $_FILES array * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function importFromCsvFile($file) { if (!isset($file['tmp_name'])) { - throw new \Magento\Core\Exception('Invalid file upload attempt.'); + throw new \Magento\Model\Exception('Invalid file upload attempt.'); } $csvProcessor = new \Magento\File\Csv(); $ratesRawData = $csvProcessor->getData($file['tmp_name']); @@ -162,7 +162,7 @@ protected function _filterFileFields(array $fileFields) * @param array $invalidFields assoc array of invalid file fields * @param array $validFields assoc array of valid file fields * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _filterRateData(array $rateRawData, array $invalidFields, array $validFields) { @@ -181,7 +181,7 @@ protected function _filterRateData(array $rateRawData, array $invalidFields, arr } // check if number of fields in row match with number of valid fields if (count($rateRawData[$rowIndex]) != $validFieldsNum) { - throw new \Magento\Core\Exception('Invalid file format.'); + throw new \Magento\Model\Exception('Invalid file format.'); } } return $rateRawData; @@ -237,7 +237,7 @@ protected function _isStoreCodeValid($storeCode) * @param array $regionsCache cache of regions of already used countries (is used to optimize performance) * @param array $storesCache cache of stores related to tax rate titles * @return array regions cache populated with regions related to country of imported tax rate - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _importRate(array $rateData, array $regionsCache, array $storesCache) { @@ -245,7 +245,7 @@ protected function _importRate(array $rateData, array $regionsCache, array $stor $countryCode = $rateData[1]; $country = $this->_countryFactory->create()->loadByCode($countryCode, 'iso2_code'); if (!$country->getId()) { - throw new \Magento\Core\Exception('One of the countries has invalid code.'); + throw new \Magento\Model\Exception('One of the countries has invalid code.'); } $regionsCache = $this->_addCountryRegionsToCache($countryCode, $regionsCache); diff --git a/app/code/Magento/Tax/Model/Resource/Calculation.php b/app/code/Magento/Tax/Model/Resource/Calculation.php index b8efcbf4f0168..f8bc44628f8b7 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation.php @@ -30,7 +30,7 @@ */ namespace Magento\Tax\Model\Resource; -class Calculation extends \Magento\Core\Model\Resource\Db\AbstractDb +class Calculation extends \Magento\Model\Resource\Db\AbstractDb { /** * Rates cache diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Collection.php b/app/code/Magento/Tax/Model/Resource/Calculation/Collection.php index 5550a1b852504..24b5e4f9f4d9a 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation/Collection.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Tax * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rate.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rate.php index 6e8ce866f1286..0c13b00a151aa 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation/Rate.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rate.php @@ -34,7 +34,7 @@ */ namespace Magento\Tax\Model\Resource\Calculation; -class Rate extends \Magento\Core\Model\Resource\Db\AbstractDb +class Rate extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php index ed9c571b44faa..a0f99155e937c 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php @@ -30,7 +30,7 @@ */ namespace Magento\Tax\Model\Resource\Calculation\Rate; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * @var \Magento\Core\Model\StoreManagerInterface @@ -44,7 +44,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param mixed $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, @@ -53,7 +53,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Model\StoreManagerInterface $storeManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_storeManager = $storeManager; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); @@ -186,12 +186,16 @@ public function toOptionHash() * Convert items array to hash for select options * using fetchItem method * - * @see _toOptionHashOptimized() + * @see fetchItem() * * @return array */ public function toOptionHashOptimized() { - return $this->_toOptionHashOptimized('tax_calculation_rate_id', 'code'); + $result = array(); + while ($item = $this->fetchItem()) { + $result[$item->getData('tax_calculation_rate_id')] = $item->getData('code'); + } + return $result; } } diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title.php index 49f3360d99d8a..e22349a3f0e50 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title.php @@ -32,7 +32,7 @@ * @package Magento_Tax * @author Magento Core Team */ -class Title extends \Magento\Core\Model\Resource\Db\AbstractDb +class Title extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title/Collection.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title/Collection.php index 6c75b33a810ce..e40744268617c 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title/Collection.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Tax * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rule.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rule.php index e04ea361e591a..43339527ab28c 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation/Rule.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rule.php @@ -32,7 +32,7 @@ * @package Magento_Tax * @author Magento Core Team */ -class Rule extends \Magento\Core\Model\Resource\Db\AbstractDb +class Rule extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php index 99fb35d7dce75..7bbb2f3ce2ca1 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Tax * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization @@ -151,7 +151,7 @@ public function addRatesToResult() * @param string $type * @param int $id * @return \Magento\Tax\Model\Resource\Calculation\Rule\Collection - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function setClassTypeFilter($type, $id) { @@ -163,7 +163,7 @@ public function setClassTypeFilter($type, $id) $field = 'cd.customer_tax_class_id'; break; default: - throw new \Magento\Core\Exception('Invalid type supplied'); + throw new \Magento\Model\Exception('Invalid type supplied'); } $this->joinCalculationData('cd'); diff --git a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax.php b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax.php index b872b74b673fd..2a66756efc033 100644 --- a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax.php +++ b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax.php @@ -32,7 +32,7 @@ * @package Magento_Tax * @author Magento Core Team */ -class Tax extends \Magento\Core\Model\Resource\Db\AbstractDb +class Tax extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Collection.php b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Collection.php index ca675d95e3350..def135c52a3d9 100644 --- a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Collection.php +++ b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Tax * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php index 22331e4030a01..7eada36bf698d 100644 --- a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php +++ b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php @@ -34,7 +34,7 @@ */ namespace Magento\Tax\Model\Resource\Sales\Order\Tax; -class Item extends \Magento\Core\Model\Resource\Db\AbstractDb +class Item extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php index 989bdf0ba751e..e865c06f206b3 100644 --- a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php +++ b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php @@ -32,7 +32,7 @@ * @package Magento_Tax * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize resource diff --git a/app/code/Magento/Tax/Model/Resource/TaxClass.php b/app/code/Magento/Tax/Model/Resource/TaxClass.php index 97e2c11c93918..7e97af80be571 100644 --- a/app/code/Magento/Tax/Model/Resource/TaxClass.php +++ b/app/code/Magento/Tax/Model/Resource/TaxClass.php @@ -32,7 +32,7 @@ * @package Magento_Tax * @author Magento Core Team */ -class TaxClass extends \Magento\Core\Model\Resource\Db\AbstractDb +class TaxClass extends \Magento\Model\Resource\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Tax/Model/Resource/TaxClass/Collection.php b/app/code/Magento/Tax/Model/Resource/TaxClass/Collection.php index 314a31eb65853..8ed1c07036cca 100644 --- a/app/code/Magento/Tax/Model/Resource/TaxClass/Collection.php +++ b/app/code/Magento/Tax/Model/Resource/TaxClass/Collection.php @@ -34,7 +34,7 @@ */ namespace Magento\Tax\Model\Resource\TaxClass; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Tax/Model/Sales/Order/Tax.php b/app/code/Magento/Tax/Model/Sales/Order/Tax.php index 515217d8b9cea..d3c3aee98bba3 100644 --- a/app/code/Magento/Tax/Model/Sales/Order/Tax.php +++ b/app/code/Magento/Tax/Model/Sales/Order/Tax.php @@ -51,7 +51,7 @@ * @method int getHidden() * @method \Magento\Tax\Model\Sales\Order\Tax setHidden(int $value) */ -class Tax extends \Magento\Core\Model\AbstractModel +class Tax extends \Magento\Model\AbstractModel { /** * @return void diff --git a/app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php b/app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php index 04c0cc283dc97..f2723806cfe99 100644 --- a/app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php +++ b/app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php @@ -30,7 +30,7 @@ * @package Magento_Tax * @author Magento Core Team */ -class Item extends \Magento\Core\Model\AbstractModel +class Item extends \Magento\Model\AbstractModel { /** * Initialization diff --git a/app/code/Magento/Tax/Model/TaxClass/AbstractType.php b/app/code/Magento/Tax/Model/TaxClass/AbstractType.php index 5f986536f11b4..6a26805604ecd 100644 --- a/app/code/Magento/Tax/Model/TaxClass/AbstractType.php +++ b/app/code/Magento/Tax/Model/TaxClass/AbstractType.php @@ -56,7 +56,7 @@ public function __construct(\Magento\Tax\Model\Calculation\Rule $calculationRule /** * Get Collection of Tax Rules that are assigned to this tax class * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function getAssignedToRules() { diff --git a/app/code/Magento/Tax/Model/TaxClass/Factory.php b/app/code/Magento/Tax/Model/TaxClass/Factory.php index 7fab195f3b66f..3de9c823da5e3 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Factory.php +++ b/app/code/Magento/Tax/Model/TaxClass/Factory.php @@ -59,13 +59,13 @@ public function __construct(\Magento\ObjectManager $objectManager) * * @param \Magento\Tax\Model\ClassModel $taxClass * @return \Magento\Tax\Model\TaxClass\Type\TypeInterface - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function create(\Magento\Tax\Model\ClassModel $taxClass) { $taxClassType = $taxClass->getClassType(); if (!array_key_exists($taxClassType, $this->_types)) { - throw new \Magento\Core\Exception(sprintf('Invalid type of tax class "%s"', $taxClassType)); + throw new \Magento\Model\Exception(sprintf('Invalid type of tax class "%s"', $taxClassType)); } return $this->_objectManager->create( $this->_types[$taxClassType], diff --git a/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php b/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php index fa245f1f155d2..da60eae3646d9 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php +++ b/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php @@ -87,7 +87,7 @@ public function __construct( * \Magento\Tax\Model\TaxClass\Type\TypeInterface::getAssignedToObjects are refactored to return Data Objects. * Will be revisited in MAGETWO-21827 * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function getAssignedToObjects() { diff --git a/app/code/Magento/Tax/Model/TaxClass/Type/Product.php b/app/code/Magento/Tax/Model/TaxClass/Type/Product.php index 8b6e4ab35f0be..3bafa2e6247d9 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Type/Product.php +++ b/app/code/Magento/Tax/Model/TaxClass/Type/Product.php @@ -60,7 +60,7 @@ public function __construct( /** * Get Products with this tax class * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function getAssignedToObjects() { diff --git a/app/code/Magento/Tax/Model/TaxClass/Type/TypeInterface.php b/app/code/Magento/Tax/Model/TaxClass/Type/TypeInterface.php index 03162fcdecf7e..56a4b56a6125f 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Type/TypeInterface.php +++ b/app/code/Magento/Tax/Model/TaxClass/Type/TypeInterface.php @@ -34,14 +34,14 @@ interface TypeInterface /** * Get Collection of Objects that are assigned to this tax class * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function getAssignedToObjects(); /** * Get Collection of Tax Rules that are assigned to this tax class * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function getAssignedToRules(); diff --git a/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme.php b/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme.php index 3fd0f0304d536..1735231aedc12 100644 --- a/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme.php +++ b/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme.php @@ -67,6 +67,7 @@ public function __construct( */ public function indexAction() { + $this->_eventManager->dispatch('theme_registration_from_filesystem'); $this->_view->loadLayout(); $this->_setActiveMenu('Magento_Theme::system_design_theme'); $this->_view->renderLayout(); @@ -106,7 +107,7 @@ public function editAction() try { $theme->setType(\Magento\View\Design\ThemeInterface::TYPE_VIRTUAL); if ($themeId && (!$theme->load($themeId)->getId() || !$theme->isVisible())) { - throw new \Magento\Core\Exception(__('We cannot find theme "%1".', $themeId)); + throw new \Magento\Model\Exception(__('We cannot find theme "%1".', $themeId)); } $this->_coreRegistry->register('current_theme', $theme); @@ -121,7 +122,7 @@ public function editAction() } $this->_setActiveMenu('Magento_Theme::system_design_theme'); $this->_view->renderLayout(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect('adminhtml/*/'); } catch (\Exception $e) { @@ -166,7 +167,7 @@ public function saveAction() ); } if ($theme && !$theme->isEditable()) { - throw new \Magento\Core\Exception(__('Theme isn\'t editable.')); + throw new \Magento\Model\Exception(__('Theme isn\'t editable.')); } $theme->addData($themeData); if (isset($themeData['preview']['delete'])) { @@ -181,7 +182,7 @@ public function saveAction() $singleFile->update($theme, $customCssData); $this->messageManager->addSuccess(__('You saved the theme.')); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_getSession()->setThemeData($themeData); $this->_getSession()->setThemeCustomCssData($customCssData); @@ -222,7 +223,7 @@ public function deleteAction() $theme->delete(); $this->messageManager->addSuccess(__('You deleted the theme.')); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('We cannot delete the theme.')); @@ -246,7 +247,7 @@ public function uploadCssAction() try { $cssFileContent = $serviceModel->uploadCssFile('css_file_uploader'); $result = array('error' => false, 'content' => $cssFileContent['content']); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $result = array('error' => true, 'message' => $e->getMessage()); } catch (\Exception $e) { $result = array('error' => true, 'message' => __('We cannot upload the CSS file.')); @@ -259,7 +260,7 @@ public function uploadCssAction() * Upload js file * * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function uploadJsAction() { @@ -273,7 +274,7 @@ public function uploadJsAction() try { $theme = $themeFactory->create($themeId); if (!$theme) { - throw new \Magento\Core\Exception(__('We cannot find a theme with id "%1".', $themeId)); + throw new \Magento\Model\Exception(__('We cannot find a theme with id "%1".', $themeId)); } $jsFileData = $serviceModel->uploadJsFile('js_files_uploader'); $jsFile = $jsService->create(); @@ -289,7 +290,7 @@ public function uploadJsAction() ); $customJsFiles = $customization->getFilesByType(\Magento\View\Design\Theme\Customization\File\Js::TYPE); $result = array('error' => false, 'files' => $customization->generateFileInfo($customJsFiles)); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $result = array('error' => true, 'message' => $e->getMessage()); } catch (\Exception $e) { $result = array('error' => true, 'message' => __('We cannot upload the JS file.')); diff --git a/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Wysiwyg/Files.php b/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Wysiwyg/Files.php index d62108eae1ece..cc66f382d36a2 100644 --- a/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Wysiwyg/Files.php +++ b/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Wysiwyg/Files.php @@ -93,7 +93,7 @@ public function newFolderAction() try { $path = $this->_getSession()->getStoragePath(); $result = $this->_getStorage()->createFolder($name, $path); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $result = array('error' => true, 'message' => $e->getMessage()); } catch (\Exception $e) { $result = array('error' => true, 'message' => __('Sorry, there was an unknown error.')); diff --git a/app/code/Magento/Theme/Model/Uploader/Service.php b/app/code/Magento/Theme/Model/Uploader/Service.php index f6bb2980af933..31f5980bcf8c7 100644 --- a/app/code/Magento/Theme/Model/Uploader/Service.php +++ b/app/code/Magento/Theme/Model/Uploader/Service.php @@ -100,7 +100,7 @@ public function __construct( * * @param string $file - Key in the $_FILES array * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function uploadCssFile($file) { @@ -112,7 +112,7 @@ public function uploadCssFile($file) $isValidFileSize = $this->_validateFileSize($fileUploader->getFileSize(), $this->getCssUploadMaxSize()); if (!$isValidFileSize) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The CSS file must be less than %1M.', $this->getCssUploadMaxSizeInMb()) ); } @@ -126,7 +126,7 @@ public function uploadCssFile($file) * * @param string $file - Key in the $_FILES array * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function uploadJsFile($file) { @@ -138,7 +138,7 @@ public function uploadJsFile($file) $isValidFileSize = $this->_validateFileSize($fileUploader->getFileSize(), $this->getJsUploadMaxSize()); if (!$isValidFileSize) { - throw new \Magento\Core\Exception( + throw new \Magento\Model\Exception( __('The JS file must be less than %1M.', $this->getJsUploadMaxSizeInMb()) ); } diff --git a/app/code/Magento/Theme/Model/Wysiwyg/Storage.php b/app/code/Magento/Theme/Model/Wysiwyg/Storage.php index 737c97016d97b..f3e7b740077c4 100644 --- a/app/code/Magento/Theme/Model/Wysiwyg/Storage.php +++ b/app/code/Magento/Theme/Model/Wysiwyg/Storage.php @@ -108,7 +108,7 @@ public function __construct( * * @param string $targetPath * @return bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function uploadFile($targetPath) { @@ -120,7 +120,7 @@ public function uploadFile($targetPath) $result = $uploader->save($targetPath); if (!$result) { - throw new \Magento\Core\Exception(__('We cannot upload the file.')); + throw new \Magento\Model\Exception(__('We cannot upload the file.')); } $this->_createThumbnail($targetPath . '/' . $uploader->getUploadedFileName()); @@ -178,12 +178,12 @@ public function _createThumbnail($source) * @param string $name * @param string $path * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function createFolder($name, $path) { if (!preg_match(self::DIRECTORY_NAME_REGEXP, $name)) { - throw new \Magento\Core\Exception(__('Use only standard alphanumeric, dashes and underscores.')); + throw new \Magento\Model\Exception(__('Use only standard alphanumeric, dashes and underscores.')); } if (!$this->mediaWriteDirectory->isWritable($path)) { $path = $this->_helper->getStorageRoot(); @@ -192,7 +192,7 @@ public function createFolder($name, $path) $newPath = $path . '/' . $name; if ($this->mediaWriteDirectory->isExist($newPath)) { - throw new \Magento\Core\Exception(__('We found a directory with the same name.')); + throw new \Magento\Model\Exception(__('We found a directory with the same name.')); } $this->mediaWriteDirectory->create($newPath); @@ -233,12 +233,12 @@ public function deleteFile($file) * * @param string $currentPath * @return array - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function getDirsCollection($currentPath) { if (!$this->mediaWriteDirectory->isExist($currentPath)) { - throw new \Magento\Core\Exception(__('We cannot find a directory with this name.')); + throw new \Magento\Model\Exception(__('We cannot find a directory with this name.')); } $paths = $this->mediaWriteDirectory->search('.*', $currentPath); $directories = array(); @@ -306,7 +306,7 @@ public function getTreeArray() * * @param string $path * @return bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function deleteDirectory($path) { @@ -314,7 +314,7 @@ public function deleteDirectory($path) $pathCmp = rtrim($path, '/'); if ($rootCmp == $pathCmp) { - throw new \Magento\Core\Exception(__('We cannot delete root directory %1.', $path)); + throw new \Magento\Model\Exception(__('We cannot delete root directory %1.', $path)); } return $this->mediaWriteDirectory->delete($path); diff --git a/app/code/Magento/Theme/view/frontend/html/bugreport.phtml b/app/code/Magento/Theme/view/frontend/html/bugreport.phtml index af86bbb4e80f0..220c76c6979c2 100644 --- a/app/code/Magento/Theme/view/frontend/html/bugreport.phtml +++ b/app/code/Magento/Theme/view/frontend/html/bugreport.phtml @@ -29,5 +29,5 @@ target="_blank"> - + diff --git a/app/code/Magento/Theme/view/frontend/html/footer.phtml b/app/code/Magento/Theme/view/frontend/html/footer.phtml index 8db58345ee1e2..0998dbefb4cdd 100644 --- a/app/code/Magento/Theme/view/frontend/html/footer.phtml +++ b/app/code/Magento/Theme/view/frontend/html/footer.phtml @@ -29,7 +29,7 @@ getChildHtml() ?>

- + target="_blank">

getCopyright() ?>
diff --git a/app/code/Magento/Core/Helper/Translate.php b/app/code/Magento/Translation/Controller/Ajax.php similarity index 52% rename from app/code/Magento/Core/Helper/Translate.php rename to app/code/Magento/Translation/Controller/Ajax.php index d2589494f6131..b5fdb069d1453 100644 --- a/app/code/Magento/Core/Helper/Translate.php +++ b/app/code/Magento/Translation/Controller/Ajax.php @@ -18,68 +18,48 @@ * 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\Translation\Controller; -/** - * Core translate helper - */ -namespace Magento\Core\Helper; - -class Translate extends \Magento\App\Helper\AbstractHelper +class Ajax extends \Magento\App\Action\Action { /** - * Design package instance - * - * @var \Magento\View\DesignInterface - */ - protected $_design; - - /** - * Inline translate - * * @var \Magento\Translate\Inline\ParserInterface */ - protected $_inlineParser; + protected $inlineParser; /** - * @param \Magento\App\Helper\Context $context - * @param \Magento\View\DesignInterface $design + * @param \Magento\App\Action\Context $context * @param \Magento\Translate\Inline\ParserInterface $inlineParser */ public function __construct( - \Magento\App\Helper\Context $context, - \Magento\View\DesignInterface $design, + \Magento\App\Action\Context $context, \Magento\Translate\Inline\ParserInterface $inlineParser ) { - $this->_design = $design; - $this->_inlineParser = $inlineParser; parent::__construct($context); + + $this->inlineParser = $inlineParser; } /** - * Save translation data to database for specific area + * Ajax action for inline translation * - * @param array $translate - * @param string $area - * @param string $returnType - * @return string + * @return void */ - public function apply($translate, $area, $returnType = 'json') + public function indexAction() { - try { - if ($area) { - $this->_design->setArea($area); - } + $translate = (array)$this->getRequest()->getPost('translate'); - $this->_inlineParser->processAjaxPost($translate); - $result = $returnType == 'json' ? "{success:true}" : true; + try { + $this->inlineParser->processAjaxPost($translate); + $response = "{success:true}"; } catch (\Exception $e) { - $result = $returnType == 'json' ? "{error:true,message:'" . $e->getMessage() . "'}" : false; + $response = "{error:true,message:'" . $e->getMessage() . "'}"; } - return $result; + $this->getResponse()->setBody($response); + + $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); } } diff --git a/app/code/Magento/Core/Model/Translate/Inline/Config.php b/app/code/Magento/Translation/Model/Inline/Config.php similarity index 76% rename from app/code/Magento/Core/Model/Translate/Inline/Config.php rename to app/code/Magento/Translation/Model/Inline/Config.php index 5676b30fe9357..f88c6c4072905 100644 --- a/app/code/Magento/Core/Model/Translate/Inline/Config.php +++ b/app/code/Magento/Translation/Model/Inline/Config.php @@ -18,26 +18,21 @@ * 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\Translation\Model\Inline; /** * Inline Translation config */ -namespace Magento\Core\Model\Translate\Inline; - class Config implements \Magento\Translate\Inline\ConfigInterface { /** - * Core store config - * - * @var \Magento\Core\Model\Store\Config + * @var \Magento\Core\Model\Store\ConfigInterface */ - protected $_coreStoreConfig; + protected $config; /** * @var \Magento\Core\Helper\Data @@ -45,12 +40,12 @@ class Config implements \Magento\Translate\Inline\ConfigInterface protected $_helper; /** - * @param \Magento\Core\Model\Store\Config $coreStoreConfig + * @param \Magento\Core\Model\Store\ConfigInterface $config * @param \Magento\Core\Helper\Data $helper */ - public function __construct(\Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Helper\Data $helper) + public function __construct(\Magento\Core\Model\Store\ConfigInterface $config, \Magento\Core\Helper\Data $helper) { - $this->_coreStoreConfig = $coreStoreConfig; + $this->config = $config; $this->_helper = $helper; } @@ -59,7 +54,7 @@ public function __construct(\Magento\Core\Model\Store\Config $coreStoreConfig, \ */ public function isActive($scope = null) { - return $this->_coreStoreConfig->getConfigFlag('dev/translate_inline/active', $scope); + return $this->config->getConfigFlag('dev/translate_inline/active', $scope); } /** diff --git a/app/code/Magento/Core/Model/Translate/Inline/Parser.php b/app/code/Magento/Translation/Model/Inline/Parser.php similarity index 94% rename from app/code/Magento/Core/Model/Translate/Inline/Parser.php rename to app/code/Magento/Translation/Model/Inline/Parser.php index 9af6858f23acf..8ca3d2dd0734b 100644 --- a/app/code/Magento/Core/Model/Translate/Inline/Parser.php +++ b/app/code/Magento/Translation/Model/Inline/Parser.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -28,7 +26,7 @@ * This class is responsible for parsing content and applying necessary html element * wrapping and client scripts for inline translation. */ -namespace Magento\Core\Model\Translate\Inline; +namespace Magento\Translation\Model\Inline; class Parser implements \Magento\Translate\Inline\ParserInterface { @@ -37,13 +35,6 @@ class Parser implements \Magento\Translate\Inline\ParserInterface */ const DATA_TRANSLATE = 'data-translate'; - /** - * Regular Expression for detected and replace translate - * - * @var string - */ - protected $_tokenRegex = '\{\{\{(.*?)\}\}\{\{(.*?)\}\}\{\{(.*?)\}\}\{\{(.*?)\}\}\}'; - /** * Response body or JSON content string * @@ -56,7 +47,7 @@ class Parser implements \Magento\Translate\Inline\ParserInterface * * @var bool */ - protected $_isJson = \Magento\Translate\Inline\ParserInterface::JSON_FLAG_DEFAULT_STATE; + protected $_isJson = false; /** * Get max translate block in same tag @@ -117,7 +108,7 @@ class Parser implements \Magento\Translate\Inline\ParserInterface ); /** - * @var \Magento\Core\Model\Resource\Translate\StringFactory + * @var \Magento\Translation\Model\Resource\StringFactory */ protected $_resourceFactory; @@ -149,7 +140,7 @@ class Parser implements \Magento\Translate\Inline\ParserInterface /** * Initialize base inline translation model * - * @param \Magento\Core\Model\Resource\Translate\StringFactory $resource + * @param \Magento\Translation\Model\Resource\StringFactory $resource * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Zend_Filter_Interface $inputFilter * @param \Magento\App\State $appState @@ -157,7 +148,7 @@ class Parser implements \Magento\Translate\Inline\ParserInterface * @param \Magento\Translate\InlineInterface $translateInline */ public function __construct( - \Magento\Core\Model\Resource\Translate\StringFactory $resource, + \Magento\Translation\Model\Resource\StringFactory $resource, \Magento\Core\Model\StoreManagerInterface $storeManager, \Zend_Filter_Interface $inputFilter, \Magento\App\State $appState, @@ -191,7 +182,7 @@ public function processAjaxPost(array $translateParams) /** @var $validStoreId int */ $validStoreId = $this->_storeManager->getStore()->getId(); - /** @var $resource \Magento\Core\Model\Resource\Translate\String */ + /** @var $resource \Magento\Translation\Model\Resource\String */ $resource = $this->_resourceFactory->create(); foreach ($translateParams as $param) { if ($this->_appState->getAreaCode() == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) { @@ -420,13 +411,13 @@ private function _tagAttributes() private function _prepareTagAttributesForContent(&$content) { $quoteHtml = $this->_getHtmlQuote(); - $tagMatch = array(); - $nextTag = 0; - $tagRegExp = '#<([a-z]+)\s*?[^>]+?((' . $this->_tokenRegex . ')[^>]*?)+\\\\?/?>#iS'; + $tagMatch = array(); + $nextTag = 0; + $tagRegExp = '#<([a-z]+)\s*?[^>]+?((' . self::REGEXP_TOKEN . ')[^>]*?)+\\\\?/?>#iS'; while (preg_match($tagRegExp, $content, $tagMatch, PREG_OFFSET_CAPTURE, $nextTag)) { $tagHtml = $tagMatch[0][0]; $matches = array(); - $attrRegExp = '#' . $this->_tokenRegex . '#S'; + $attrRegExp = '#' . self::REGEXP_TOKEN . '#S'; $trArr = $this->_getTranslateData($attrRegExp, $tagHtml, array($this, '_getAttributeLocation')); if ($trArr) { $transRegExp = '# ' . $this->_getHtmlAttribute( @@ -548,7 +539,7 @@ private function _translateTags(&$content, $tagsList, $formatCallback) $tagClosurePos = $tagMatch[0][1] + strlen($tagHtml); $trArr = $this->_getTranslateData( - '#' . $this->_tokenRegex . '#iS', + '#' . self::REGEXP_TOKEN . '#iS', $tagHtml, array($this, '_getTagLocation'), array('tagName' => $tagName, 'tagList' => $tagsList) @@ -602,14 +593,14 @@ private function _otherText() { $next = 0; $matches = array(); - while (preg_match('#' . $this->_tokenRegex . '#', $this->_content, $matches, PREG_OFFSET_CAPTURE, $next)) { + while (preg_match('#' . self::REGEXP_TOKEN . '#', $this->_content, $matches, PREG_OFFSET_CAPTURE, $next)) { $translateProperties = json_encode( array( 'shown' => $matches[1][0], 'translated' => $matches[2][0], 'original' => $matches[3][0], 'location' => 'Text', - 'scope' => $matches[4][0] + 'scope' => $matches[4][0], ) ); diff --git a/app/code/Magento/Core/Model/Resource/Translate/String.php b/app/code/Magento/Translation/Model/Resource/String.php similarity index 83% rename from app/code/Magento/Core/Model/Resource/Translate/String.php rename to app/code/Magento/Translation/Model/Resource/String.php index ee94eceec4158..9014850570322 100644 --- a/app/code/Magento/Core/Model/Resource/Translate/String.php +++ b/app/code/Magento/Translation/Model/Resource/String.php @@ -18,21 +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_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Translate; +namespace Magento\Translation\Model\Resource; -/** - * String translate resource model - * - * @category Magento - * @package Magento_Core - * @author Magento Core Team - */ -class String extends \Magento\Core\Model\Resource\Db\AbstractDb +class String extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Locale\ResolverInterface @@ -40,23 +31,31 @@ class String extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_localeResolver; /** - * @var \Magento\Core\Model\StoreManagerInterface + * @var \Magento\BaseScopeResolverInterface + */ + protected $scopeResolver; + + /** + * @var null|string */ - protected $_storeManager; + protected $scope; /** * @param \Magento\App\Resource $resource * @param \Magento\Locale\ResolverInterface $localeResolver - * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\BaseScopeResolverInterface $scopeResolver + * @param null $scope */ public function __construct( \Magento\App\Resource $resource, \Magento\Locale\ResolverInterface $localeResolver, - \Magento\Core\Model\StoreManagerInterface $storeManager + \Magento\BaseScopeResolverInterface $scopeResolver, + $scope = null ) { - parent::__construct($resource); $this->_localeResolver = $localeResolver; - $this->_storeManager = $storeManager; + $this->scopeResolver = $scopeResolver; + $this->scope = $scope; + parent::__construct($resource); } /** @@ -66,18 +65,18 @@ public function __construct( */ protected function _construct() { - $this->_init('core_translate', 'key_id'); + $this->_init('translation', 'key_id'); } /** * Load * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param String $value * @param String $field * @return array|$this */ - public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = null) + public function load(\Magento\Model\AbstractModel $object, $value, $field = null) { if (is_string($value)) { $select = $this->_getReadAdapter()->select()->from( @@ -99,7 +98,7 @@ public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = * * @param String $field * @param String $value - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return \Magento\DB\Select */ protected function _getLoadSelect($field, $value, $object) @@ -112,10 +111,10 @@ protected function _getLoadSelect($field, $value, $object) /** * After translation loading * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - public function _afterLoad(\Magento\Core\Model\AbstractModel $object) + public function _afterLoad(\Magento\Model\AbstractModel $object) { $adapter = $this->_getReadAdapter(); $select = $adapter->select()->from( @@ -132,10 +131,10 @@ public function _afterLoad(\Magento\Core\Model\AbstractModel $object) /** * Before save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { $adapter = $this->_getWriteAdapter(); $select = $adapter->select()->from( @@ -156,10 +155,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * After save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { $adapter = $this->_getWriteAdapter(); $select = $adapter->select()->from( @@ -237,7 +236,7 @@ public function saveTranslate($string, $translate, $locale = null, $storeId = nu } if (is_null($storeId)) { - $storeId = $this->_getStoreId(); + $storeId = $this->getStoreId(); } $select = $write->select()->from( @@ -262,7 +261,7 @@ public function saveTranslate($string, $translate, $locale = null, $storeId = nu if ($row = $write->fetchRow($select, $bind)) { $original = $string; if (strpos($original, '::') !== false) { - list($scope, $original) = explode('::', $original); + list( , $original) = explode('::', $original); } if ($original == $translate) { $write->delete($table, array('key_id=?' => $row['key_id'])); @@ -286,12 +285,12 @@ public function saveTranslate($string, $translate, $locale = null, $storeId = nu } /** - * Get current store id + * Retrieve current store identifier * - * @return int + * @return \Magento\BaseScopeInterface */ - protected function _getStoreId() + protected function getStoreId() { - return $this->_storeManager->getStore()->getId(); + return $this->scopeResolver->getScope($this->scope)->getId(); } } diff --git a/app/code/Magento/Core/Model/Resource/Translate.php b/app/code/Magento/Translation/Model/Resource/Translate.php similarity index 79% rename from app/code/Magento/Core/Model/Resource/Translate.php rename to app/code/Magento/Translation/Model/Resource/Translate.php index 251e4a175c85d..128af4713e59e 100644 --- a/app/code/Magento/Core/Model/Resource/Translate.php +++ b/app/code/Magento/Translation/Model/Resource/Translate.php @@ -18,21 +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_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource; +namespace Magento\Translation\Model\Resource; -/** - * Translation resource model - * - * @category Magento - * @package Magento_Core - * @author Magento Core Team - */ -class Translate extends \Magento\Core\Model\Resource\Db\AbstractDb implements \Magento\Translate\ResourceInterface +class Translate extends \Magento\Model\Resource\Db\AbstractDb implements \Magento\Translate\ResourceInterface { /** * @var \Magento\App\State @@ -40,23 +31,31 @@ class Translate extends \Magento\Core\Model\Resource\Db\AbstractDb implements \M protected $_appState; /** - * @var \Magento\Core\Model\StoreManagerInterface + * @var \Magento\BaseScopeResolverInterface */ - protected $_storeManager; + protected $scopeResolver; + + /** + * @var null|string + */ + protected $scope; /** * @param \Magento\App\Resource $resource * @param \Magento\App\State $appState - * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\BaseScopeResolverInterface $scopeResolver + * @param null|string $scope */ public function __construct( \Magento\App\Resource $resource, \Magento\App\State $appState, - \Magento\Core\Model\StoreManagerInterface $storeManager + \Magento\BaseScopeResolverInterface $scopeResolver, + $scope = null ) { - parent::__construct($resource); $this->_appState = $appState; - $this->_storeManager = $storeManager; + $this->scopeResolver = $scopeResolver; + $this->scope = $scope; + parent::__construct($resource); } /** @@ -66,7 +65,7 @@ public function __construct( */ protected function _construct() { - $this->_init('core_translate', 'key_id'); + $this->_init('translation', 'key_id'); } /** @@ -83,7 +82,7 @@ public function getTranslationArray($storeId = null, $locale = null) } if (is_null($storeId)) { - $storeId = $this->_getStoreId(); + $storeId = $this->getStoreId(); } $adapter = $this->_getReadAdapter(); @@ -121,7 +120,7 @@ public function getTranslationArrayByStrings(array $strings, $storeId = null) } if (is_null($storeId)) { - $this->_getStoreId(); + $storeId = $this->getStoreId(); } $adapter = $this->_getReadAdapter(); @@ -158,12 +157,12 @@ public function getMainChecksum() } /** - * Get store id for translations + * Retrieve current store identifier * - * @return int + * @return \Magento\BaseScopeInterface */ - protected function _getStoreId() + protected function getStoreId() { - return $this->_storeManager->getStore()->getId(); + return $this->scopeResolver->getScope($this->scope)->getId(); } } diff --git a/app/code/Magento/Core/Model/Translate/String.php b/app/code/Magento/Translation/Model/String.php similarity index 68% rename from app/code/Magento/Core/Model/Translate/String.php rename to app/code/Magento/Translation/Model/String.php index 6775f04bb940f..623e74785b80d 100644 --- a/app/code/Magento/Core/Model/Translate/String.php +++ b/app/code/Magento/Translation/Model/String.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -27,29 +25,25 @@ /** * String translation model * - * @method \Magento\Core\Model\Resource\Translate\String _getResource() - * @method \Magento\Core\Model\Resource\Translate\String getResource() + * @method \Magento\Translation\Model\Resource\String _getResource() + * @method \Magento\Translation\Model\Resource\String getResource() * @method int getStoreId() - * @method \Magento\Core\Model\Translate\String setStoreId(int $value) + * @method \Magento\Translation\Model\String setStoreId(int $value) * @method string getTranslate() - * @method \Magento\Core\Model\Translate\String setTranslate(string $value) + * @method \Magento\Translation\Model\String setTranslate(string $value) * @method string getLocale() - * @method \Magento\Core\Model\Translate\String setLocale(string $value) - * - * @category Magento - * @package Magento_Core - * @author Magento Core Team + * @method \Magento\Translation\Model\String setLocale(string $value) */ -namespace Magento\Core\Model\Translate; +namespace Magento\Translation\Model; -class String extends \Magento\Core\Model\AbstractModel +class String extends \Magento\Model\AbstractModel { /** * @return void */ protected function _construct() { - $this->_init('Magento\Core\Model\Resource\Translate\String'); + $this->_init('Magento\Translation\Model\Resource\String'); } /** diff --git a/dev/tests/integration/testsuite/Magento/PubSub/Event/QueueWriterTest.php b/app/code/Magento/Translation/data/translation_setup/data-upgrade-1.0.0.0-1.0.0.1.php similarity index 68% rename from dev/tests/integration/testsuite/Magento/PubSub/Event/QueueWriterTest.php rename to app/code/Magento/Translation/data/translation_setup/data-upgrade-1.0.0.0-1.0.0.1.php index 9dc6cfa2a4c10..6e2120b4e8cff 100644 --- a/dev/tests/integration/testsuite/Magento/PubSub/Event/QueueWriterTest.php +++ b/app/code/Magento/Translation/data/translation_setup/data-upgrade-1.0.0.0-1.0.0.1.php @@ -1,7 +1,5 @@ offer($event); +/* @var $installer \Magento\Core\Model\Resource\Setup */ +$installer = $this; + +$installer->startSetup(); + +$select = $installer->getConnection() + ->select() + ->from($installer->getTable('core_translate')) + ->insertFromSelect($installer->getTable('translation')); + +$installer->getConnection()->query($select); + +$installer->getConnection()->dropTable($installer->getTable('core_translate')); - $this->assertNull($result); - } -} +$installer->endSetup(); diff --git a/app/code/Magento/Translation/etc/adminhtml/di.xml b/app/code/Magento/Translation/etc/adminhtml/di.xml new file mode 100644 index 0000000000000..5ade7363c26ea --- /dev/null +++ b/app/code/Magento/Translation/etc/adminhtml/di.xml @@ -0,0 +1,47 @@ + + + + + + + admin + + + + + admin + + + + + Magento_Translation::translate_inline.phtml + adminhtml/ajax/translate + Magento\View\LayoutInterface\Proxy + Magento\Backend\Model\UrlInterface + admin + + + diff --git a/app/code/Magento/Translation/etc/adminhtml/routes.xml b/app/code/Magento/Translation/etc/adminhtml/routes.xml new file mode 100644 index 0000000000000..f54eea71c040e --- /dev/null +++ b/app/code/Magento/Translation/etc/adminhtml/routes.xml @@ -0,0 +1,32 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/Translation/etc/cache.xml b/app/code/Magento/Translation/etc/cache.xml new file mode 100644 index 0000000000000..d8e3c37ea7c28 --- /dev/null +++ b/app/code/Magento/Translation/etc/cache.xml @@ -0,0 +1,31 @@ + + + + + + Translation files. + + diff --git a/app/code/Magento/Translation/etc/config.xml b/app/code/Magento/Translation/etc/config.xml new file mode 100644 index 0000000000000..95c9f1b2a6d13 --- /dev/null +++ b/app/code/Magento/Translation/etc/config.xml @@ -0,0 +1,38 @@ + + + + + + + 0 + 0 + + + + + + + diff --git a/app/code/Magento/Translation/etc/di.xml b/app/code/Magento/Translation/etc/di.xml new file mode 100644 index 0000000000000..f0c02add04e02 --- /dev/null +++ b/app/code/Magento/Translation/etc/di.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + Magento_Translation::translate_inline.phtml + translation/ajax/index + Magento\View\LayoutInterface\Proxy + Magento\Translate\Inline\ConfigInterface\Proxy + + + + + Magento\Filter\Input\MaliciousCode + + + + + Magento\Translate\Inline\Proxy + + + + + + Magento\Phrase\Renderer\Translate + Magento\Phrase\Renderer\Placeholder + Magento\Phrase\Renderer\Inline + + + + + + Magento\Translate + + + diff --git a/app/code/Magento/Translation/etc/frontend/routes.xml b/app/code/Magento/Translation/etc/frontend/routes.xml new file mode 100644 index 0000000000000..0cfe58766bc30 --- /dev/null +++ b/app/code/Magento/Translation/etc/frontend/routes.xml @@ -0,0 +1,32 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/Translation/etc/module.xml b/app/code/Magento/Translation/etc/module.xml new file mode 100644 index 0000000000000..05d7fae094c3e --- /dev/null +++ b/app/code/Magento/Translation/etc/module.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + diff --git a/app/code/Magento/Translation/sql/translation_setup/install-1.0.0.0.php b/app/code/Magento/Translation/sql/translation_setup/install-1.0.0.0.php new file mode 100644 index 0000000000000..0629dd3ff0a30 --- /dev/null +++ b/app/code/Magento/Translation/sql/translation_setup/install-1.0.0.0.php @@ -0,0 +1,110 @@ +startSetup(); + +/** + * Create table 'translation' + */ +$table = $installer->getConnection() + ->newTable($installer->getTable('translation')) + ->addColumn( + 'key_id', + \Magento\DB\Ddl\Table::TYPE_INTEGER, + null, + array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), + 'Key Id of Translation' + )->addColumn( + 'string', + \Magento\DB\Ddl\Table::TYPE_TEXT, + 255, + array( + 'nullable' => false, + 'default' => \Magento\TranslateInterface::DEFAULT_STRING, + ), + 'Translation String' + )->addColumn( + 'store_id', + \Magento\DB\Ddl\Table::TYPE_SMALLINT, + null, + array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), + 'Store Id' + )->addColumn( + 'translate', + \Magento\DB\Ddl\Table::TYPE_TEXT, + 255, + array(), + 'Translate' + )->addColumn( + 'locale', + \Magento\DB\Ddl\Table::TYPE_TEXT, + 20, + array( + 'nullable' => false, + 'default' => 'en_US', + ), + 'Locale' + )->addColumn( + 'crc_string', + \Magento\DB\Ddl\Table::TYPE_BIGINT, + null, + array( + 'nullable' => false, + 'default' => crc32(\Magento\TranslateInterface::DEFAULT_STRING) + ), + 'Translation String CRC32 Hash' + )->addIndex( + $installer->getIdxName( + 'translation', + array('store_id', 'locale', 'crc_string', 'string'), + \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE + ), + array('store_id', 'locale', 'crc_string', 'string'), + array('type' => \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) + )->addIndex( + $installer->getIdxName('translation', array('store_id')), + array('store_id') + )->addForeignKey( + $installer->getFkName('translation', 'store_id', 'core_store', 'store_id'), + 'store_id', + $installer->getTable('core_store'), + 'store_id', + \Magento\DB\Ddl\Table::ACTION_CASCADE, + \Magento\DB\Ddl\Table::ACTION_CASCADE + )->setComment('Translations'); +$installer->getConnection()->createTable($table); + +$installer->endSetup(); diff --git a/app/code/Magento/Core/view/adminhtml/translate_inline.phtml b/app/code/Magento/Translation/view/adminhtml/translate_inline.phtml similarity index 100% rename from app/code/Magento/Core/view/adminhtml/translate_inline.phtml rename to app/code/Magento/Translation/view/adminhtml/translate_inline.phtml diff --git a/app/code/Magento/Core/view/frontend/translate_inline.phtml b/app/code/Magento/Translation/view/frontend/translate_inline.phtml similarity index 100% rename from app/code/Magento/Core/view/frontend/translate_inline.phtml rename to app/code/Magento/Translation/view/frontend/translate_inline.phtml diff --git a/app/code/Magento/User/Controller/Adminhtml/Auth.php b/app/code/Magento/User/Controller/Adminhtml/Auth.php index a44e962515198..532417c8c1036 100644 --- a/app/code/Magento/User/Controller/Adminhtml/Auth.php +++ b/app/code/Magento/User/Controller/Adminhtml/Auth.php @@ -174,7 +174,7 @@ public function resetPasswordPostAction() $this->getResponse()->setRedirect( $this->_objectManager->get('Magento\Backend\Helper\Data')->getHomePageUrl() ); - } catch (\Magento\Core\Exception $exception) { + } catch (\Magento\Model\Exception $exception) { $this->messageManager->addMessages($exception->getMessages()); $this->_redirect( 'adminhtml/auth/resetpassword', @@ -189,7 +189,7 @@ public function resetPasswordPostAction() * @param int $userId * @param string $resetPasswordToken * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _validateResetPasswordLinkToken($userId, $resetPasswordToken) { @@ -199,18 +199,18 @@ protected function _validateResetPasswordLinkToken($userId, $resetPasswordToken) $resetPasswordToken ) || empty($resetPasswordToken) || empty($userId) || $userId < 0 ) { - throw new \Magento\Core\Exception(__('Please correct the password reset token.')); + throw new \Magento\Model\Exception(__('Please correct the password reset token.')); } /** @var $user \Magento\User\Model\User */ $user = $this->_userFactory->create()->load($userId); if (!$user->getId()) { - throw new \Magento\Core\Exception(__('Please specify the correct account and try again.')); + throw new \Magento\Model\Exception(__('Please specify the correct account and try again.')); } $userToken = $user->getRpToken(); if (strcmp($userToken, $resetPasswordToken) != 0 || $user->isResetPasswordLinkTokenExpired()) { - throw new \Magento\Core\Exception(__('Your password reset link has expired.')); + throw new \Magento\Model\Exception(__('Your password reset link has expired.')); } } diff --git a/app/code/Magento/User/Controller/Adminhtml/User.php b/app/code/Magento/User/Controller/Adminhtml/User.php index e8a28bf4b3cdf..5dd25d0d9b5ab 100644 --- a/app/code/Magento/User/Controller/Adminhtml/User.php +++ b/app/code/Magento/User/Controller/Adminhtml/User.php @@ -177,7 +177,7 @@ public function saveAction() $this->messageManager->addSuccess(__('You saved the user.')); $this->_getSession()->setUserData(false); $this->_redirect('adminhtml/*/'); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addMessages($e->getMessages()); $this->_getSession()->setUserData($data); $this->_redirect('adminhtml/*/edit', array('_current' => true)); diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Role.php b/app/code/Magento/User/Controller/Adminhtml/User/Role.php index 61406409521e5..da3ac59c511cb 100644 --- a/app/code/Magento/User/Controller/Adminhtml/User/Role.php +++ b/app/code/Magento/User/Controller/Adminhtml/User/Role.php @@ -262,7 +262,7 @@ public function saveRoleAction() $this->_addUserToRole($nRuid, $role->getId()); } $this->messageManager->addSuccess(__('You saved the role.')); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('An error occurred while saving this role.')); diff --git a/app/code/Magento/User/Model/Resource/Permissions/Collection.php b/app/code/Magento/User/Model/Resource/Permissions/Collection.php index 67df01ab2db31..f31ab4b3fa57c 100644 --- a/app/code/Magento/User/Model/Resource/Permissions/Collection.php +++ b/app/code/Magento/User/Model/Resource/Permissions/Collection.php @@ -32,7 +32,7 @@ * @package Magento_User * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize resource diff --git a/app/code/Magento/User/Model/Resource/Role.php b/app/code/Magento/User/Model/Resource/Role.php index 4299b11cd6b0d..cb6dd6ed93cc0 100644 --- a/app/code/Magento/User/Model/Resource/Role.php +++ b/app/code/Magento/User/Model/Resource/Role.php @@ -28,7 +28,7 @@ /** * Admin role resource model */ -class Role extends \Magento\Core\Model\Resource\Db\AbstractDb +class Role extends \Magento\Model\Resource\Db\AbstractDb { /** * Users table @@ -87,10 +87,10 @@ protected function _construct() /** * Process role before saving * - * @param \Magento\Core\Model\AbstractModel $role + * @param \Magento\Model\AbstractModel $role * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $role) + protected function _beforeSave(\Magento\Model\AbstractModel $role) { if (!$role->getId()) { $role->setCreated($this->dateTime->formatDate(true)); @@ -134,10 +134,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $role) /** * Process role after saving * - * @param \Magento\Core\Model\AbstractModel $role + * @param \Magento\Model\AbstractModel $role * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $role) + protected function _afterSave(\Magento\Model\AbstractModel $role) { $this->_updateRoleUsersAcl($role); $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(\Magento\Backend\Block\Menu::CACHE_TAGS)); @@ -147,10 +147,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $role) /** * Process role after deleting * - * @param \Magento\Core\Model\AbstractModel $role + * @param \Magento\Model\AbstractModel $role * @return $this */ - protected function _afterDelete(\Magento\Core\Model\AbstractModel $role) + protected function _afterDelete(\Magento\Model\AbstractModel $role) { $adapter = $this->_getWriteAdapter(); diff --git a/app/code/Magento/User/Model/Resource/Role/Collection.php b/app/code/Magento/User/Model/Resource/Role/Collection.php index 2b0240dad0994..ff99e071531fc 100644 --- a/app/code/Magento/User/Model/Resource/Role/Collection.php +++ b/app/code/Magento/User/Model/Resource/Role/Collection.php @@ -28,7 +28,7 @@ /** * Admin role collection */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize resource model diff --git a/app/code/Magento/User/Model/Resource/Role/User/Collection.php b/app/code/Magento/User/Model/Resource/Role/User/Collection.php index c14ba5cbfe460..d1f4e10817b11 100644 --- a/app/code/Magento/User/Model/Resource/Role/User/Collection.php +++ b/app/code/Magento/User/Model/Resource/Role/User/Collection.php @@ -32,7 +32,7 @@ * @package Magento_User * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize resource model diff --git a/app/code/Magento/User/Model/Resource/Rules.php b/app/code/Magento/User/Model/Resource/Rules.php index 83f2e3a9920ac..887b80576b55f 100644 --- a/app/code/Magento/User/Model/Resource/Rules.php +++ b/app/code/Magento/User/Model/Resource/Rules.php @@ -26,7 +26,7 @@ /** * Admin rule resource model */ -class Rules extends \Magento\Core\Model\Resource\Db\AbstractDb +class Rules extends \Magento\Model\Resource\Db\AbstractDb { /** * Root ACL resource @@ -88,7 +88,7 @@ protected function _construct() * * @param \Magento\User\Model\Rules $rule * @return void - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function saveRel(\Magento\User\Model\Rules $rule) { @@ -130,7 +130,7 @@ public function saveRel(\Magento\User\Model\Rules $rule) $adapter->commit(); $this->_aclCache->clean(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $adapter->rollBack(); throw $e; } catch (\Exception $e) { diff --git a/app/code/Magento/User/Model/Resource/Rules/Collection.php b/app/code/Magento/User/Model/Resource/Rules/Collection.php index a80c129da1983..a343164a6d66b 100644 --- a/app/code/Magento/User/Model/Resource/Rules/Collection.php +++ b/app/code/Magento/User/Model/Resource/Rules/Collection.php @@ -32,7 +32,7 @@ * @package Magento_User * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize resource model diff --git a/app/code/Magento/User/Model/Resource/User.php b/app/code/Magento/User/Model/Resource/User.php index 44541ddc2fa1c..2dcc688ae28f9 100644 --- a/app/code/Magento/User/Model/Resource/User.php +++ b/app/code/Magento/User/Model/Resource/User.php @@ -30,7 +30,7 @@ /** * ACL user resource */ -class User extends \Magento\Core\Model\Resource\Db\AbstractDb +class User extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Acl\CacheInterface @@ -139,7 +139,7 @@ public function hasAssigned2Role($user) { if (is_numeric($user)) { $userId = $user; - } elseif ($user instanceof \Magento\Core\Model\AbstractModel) { + } elseif ($user instanceof \Magento\Model\AbstractModel) { $userId = $user->getUserId(); } else { return null; @@ -162,10 +162,10 @@ public function hasAssigned2Role($user) /** * Set created/modified values before user save * - * @param \Magento\Core\Model\AbstractModel $user + * @param \Magento\Model\AbstractModel $user * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $user) + protected function _beforeSave(\Magento\Model\AbstractModel $user) { if ($user->isObjectNew()) { $user->setCreated($this->dateTime->formatDate(true)); @@ -178,10 +178,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $user) /** * Unserialize user extra data after user save * - * @param \Magento\Core\Model\AbstractModel $user + * @param \Magento\Model\AbstractModel $user * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $user) + protected function _afterSave(\Magento\Model\AbstractModel $user) { $user->setExtra(unserialize($user->getExtra())); if ($user->hasRoleId()) { @@ -241,10 +241,10 @@ protected function _createUserRole($parentId, ModelUser $user) /** * Unserialize user extra data after user load * - * @param \Magento\Core\Model\AbstractModel $user + * @param \Magento\Model\AbstractModel $user * @return $this */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $user) + protected function _afterLoad(\Magento\Model\AbstractModel $user) { if (is_string($user->getExtra())) { $user->setExtra(unserialize($user->getExtra())); @@ -255,11 +255,11 @@ protected function _afterLoad(\Magento\Core\Model\AbstractModel $user) /** * Delete user role record with user * - * @param \Magento\Core\Model\AbstractModel $user + * @param \Magento\Model\AbstractModel $user * @return bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - public function delete(\Magento\Core\Model\AbstractModel $user) + public function delete(\Magento\Model\AbstractModel $user) { $this->_beforeDelete($user); $adapter = $this->_getWriteAdapter(); @@ -271,7 +271,7 @@ public function delete(\Magento\Core\Model\AbstractModel $user) $adapter->delete($this->getMainTable(), $conditions); $adapter->delete($this->getTable('admin_role'), $conditions); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { throw $e; return false; } catch (\Exception $e) { @@ -286,10 +286,10 @@ public function delete(\Magento\Core\Model\AbstractModel $user) /** * Get user roles * - * @param \Magento\Core\Model\AbstractModel $user + * @param \Magento\Model\AbstractModel $user * @return array */ - public function getRoles(\Magento\Core\Model\AbstractModel $user) + public function getRoles(\Magento\Model\AbstractModel $user) { if (!$user->getId()) { return array(); @@ -323,10 +323,10 @@ public function getRoles(\Magento\Core\Model\AbstractModel $user) /** * Delete user role * - * @param \Magento\Core\Model\AbstractModel $user + * @param \Magento\Model\AbstractModel $user * @return $this */ - public function deleteFromRole(\Magento\Core\Model\AbstractModel $user) + public function deleteFromRole(\Magento\Model\AbstractModel $user) { if ($user->getUserId() <= 0) { return $this; @@ -346,10 +346,10 @@ public function deleteFromRole(\Magento\Core\Model\AbstractModel $user) /** * Check if role user exists * - * @param \Magento\Core\Model\AbstractModel $user + * @param \Magento\Model\AbstractModel $user * @return array */ - public function roleUserExists(\Magento\Core\Model\AbstractModel $user) + public function roleUserExists(\Magento\Model\AbstractModel $user) { if ($user->getUserId() > 0) { $roleTable = $this->getTable('admin_role'); @@ -369,10 +369,10 @@ public function roleUserExists(\Magento\Core\Model\AbstractModel $user) /** * Check if user exists * - * @param \Magento\Core\Model\AbstractModel $user + * @param \Magento\Model\AbstractModel $user * @return array */ - public function userExists(\Magento\Core\Model\AbstractModel $user) + public function userExists(\Magento\Model\AbstractModel $user) { $adapter = $this->_getReadAdapter(); $select = $adapter->select(); @@ -397,10 +397,10 @@ public function userExists(\Magento\Core\Model\AbstractModel $user) /** * Whether a user's identity is confirmed * - * @param \Magento\Core\Model\AbstractModel $user + * @param \Magento\Model\AbstractModel $user * @return bool */ - public function isUserUnique(\Magento\Core\Model\AbstractModel $user) + public function isUserUnique(\Magento\Model\AbstractModel $user) { return !$this->userExists($user); } @@ -408,7 +408,7 @@ public function isUserUnique(\Magento\Core\Model\AbstractModel $user) /** * Save user extra data * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $data * @return $this */ diff --git a/app/code/Magento/User/Model/Resource/User/Collection.php b/app/code/Magento/User/Model/Resource/User/Collection.php index fab622aa7a294..da464402a165d 100644 --- a/app/code/Magento/User/Model/Resource/User/Collection.php +++ b/app/code/Magento/User/Model/Resource/User/Collection.php @@ -32,7 +32,7 @@ * @package Magento_User * @author Magento Core Team */ -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Define resource model diff --git a/app/code/Magento/User/Model/Resource/User/Locked/Collection.php b/app/code/Magento/User/Model/Resource/User/Locked/Collection.php index 84273a9111ae2..29f552d953184 100644 --- a/app/code/Magento/User/Model/Resource/User/Locked/Collection.php +++ b/app/code/Magento/User/Model/Resource/User/Locked/Collection.php @@ -37,7 +37,7 @@ class Collection extends \Magento\User\Model\Resource\User\Collection /** * Collection Init Select * - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource * @return $this */ protected function _initSelect() diff --git a/app/code/Magento/User/Model/Role.php b/app/code/Magento/User/Model/Role.php index cc5802cd77104..fbca5b9dbe587 100644 --- a/app/code/Magento/User/Model/Role.php +++ b/app/code/Magento/User/Model/Role.php @@ -43,7 +43,7 @@ * @method string getRoleName() * @method \Magento\User\Model\Role setRoleName(string $value) */ -class Role extends \Magento\Core\Model\AbstractModel +class Role extends \Magento\Model\AbstractModel { /** * @var string diff --git a/app/code/Magento/User/Model/Rules.php b/app/code/Magento/User/Model/Rules.php index 08035e0828040..579efc6e762c8 100644 --- a/app/code/Magento/User/Model/Rules.php +++ b/app/code/Magento/User/Model/Rules.php @@ -39,7 +39,7 @@ * @method string getPermission() * @method \Magento\User\Model\Rules setPermission(string $value) */ -class Rules extends \Magento\Core\Model\AbstractModel +class Rules extends \Magento\Model\AbstractModel { /** * Class constructor diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php index bd6d39e67d2f4..eb476a74e9aee 100644 --- a/app/code/Magento/User/Model/User.php +++ b/app/code/Magento/User/Model/User.php @@ -54,7 +54,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.LongVariable) */ -class User extends \Magento\Core\Model\AbstractModel implements \Magento\Backend\Model\Auth\Credential\StorageInterface +class User extends \Magento\Model\AbstractModel implements \Magento\Backend\Model\Auth\Credential\StorageInterface { /** * Configuration paths for email templates and identities @@ -149,7 +149,7 @@ class User extends \Magento\Core\Model\AbstractModel implements \Magento\Backend * @param \Magento\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Encryption\EncryptorInterface $encryptor * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param array $data @@ -167,7 +167,7 @@ public function __construct( \Magento\Encryption\EncryptorInterface $encryptor, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -223,7 +223,7 @@ public function __wakeup() $this->_eventManager = $objectManager->get('Magento\Event\ManagerInterface'); $this->_userData = $objectManager->get('Magento\User\Helper\Data'); $this->_config = $objectManager->get('Magento\Backend\App\ConfigInterface'); - $this->_coreRegistry = $objectManager->get('Magento\Registry'); + $this->_registry = $objectManager->get('Magento\Registry'); $this->_validatorObject = $objectManager->get('Magento\Validator\ObjectFactory'); $this->_roleFactory = $objectManager->get('Magento\User\Model\RoleFactory'); $this->_encryptor = $objectManager->get('Magento\Encryption\EncryptorInterface'); @@ -519,7 +519,7 @@ public function getAclRole() * @param string $username * @param string $password * @return bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @throws \Magento\Backend\Model\Auth\Exception * @throws \Magento\Backend\Model\Auth\Plugin\Exception */ @@ -550,7 +550,7 @@ public function authenticate($username, $password) 'admin_user_authenticate_after', array('username' => $username, 'password' => $password, 'user' => $this, 'result' => $result) ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->unsetData(); throw $e; } @@ -633,12 +633,12 @@ protected function _getEncodedPassword($password) * * @param string $newToken * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function changeResetPasswordLinkToken($newToken) { if (!is_string($newToken) || empty($newToken)) { - throw new \Magento\Core\Exception(__('Please correct the password reset token.')); + throw new \Magento\Model\Exception(__('Please correct the password reset token.')); } $this->setRpToken($newToken); $this->setRpTokenCreatedAt($this->dateTime->now()); diff --git a/app/code/Magento/Webapi/Controller/ErrorProcessor.php b/app/code/Magento/Webapi/Controller/ErrorProcessor.php index cdadb7c32a6b0..5ef6407703497 100644 --- a/app/code/Magento/Webapi/Controller/ErrorProcessor.php +++ b/app/code/Magento/Webapi/Controller/ErrorProcessor.php @@ -25,6 +25,8 @@ */ namespace Magento\Webapi\Controller; +use Magento\App\State; + class ErrorProcessor { const DEFAULT_SHUTDOWN_FUNCTION = 'apiShutdownFunction'; @@ -42,13 +44,19 @@ class ErrorProcessor /**#@-*/ - /** @var \Magento\Core\Helper\Data */ + /** + * @var \Magento\Core\Helper\Data + */ protected $_coreHelper; - /** @var \Magento\Core\Model\App */ - protected $_app; + /** + * @var \Magento\App\State + */ + protected $_appState; - /** @var \Magento\Logger */ + /** + * @var \Magento\Logger + */ protected $_logger; /** @@ -64,21 +72,19 @@ class ErrorProcessor protected $directoryWrite; /** - * Initialize dependencies. Register custom shutdown function. - * * @param \Magento\Core\Helper\Data $helper - * @param \Magento\Core\Model\App $app + * @param \Magento\App\State $appState * @param \Magento\Logger $logger * @param \Magento\App\Filesystem $filesystem */ public function __construct( \Magento\Core\Helper\Data $helper, - \Magento\AppInterface $app, + \Magento\App\State $appState, \Magento\Logger $logger, \Magento\App\Filesystem $filesystem ) { $this->_coreHelper = $helper; - $this->_app = $app; + $this->_appState = $appState; $this->_logger = $logger; $this->_filesystem = $filesystem; $this->directoryWrite = $this->_filesystem->getDirectoryWrite(\Magento\App\Filesystem::VAR_DIR); @@ -115,7 +121,7 @@ public function maskException(\Exception $exception) } else if ($exception instanceof \Magento\Webapi\Exception) { $maskedException = $exception; } else { - if (!$this->_app->isDeveloperMode()) { + if ($this->_appState->getMode() !== State::MODE_DEVELOPER) { /** Create exception with masked message. */ $maskedException = new \Magento\Webapi\Exception( __('Internal Error. Details are available in Magento log file. Report ID: %1', $reportId), @@ -145,7 +151,7 @@ public function maskException(\Exception $exception) */ public function renderException(\Exception $exception, $httpCode = self::DEFAULT_ERROR_HTTP_CODE) { - if ($this->_app->isDeveloperMode() || $exception instanceof \Magento\Webapi\Exception) { + if ($this->_appState->getMode() == State::MODE_DEVELOPER || $exception instanceof \Magento\Webapi\Exception) { $this->render($exception->getMessage(), $exception->getTraceAsString(), $httpCode); } else { $reportId = $this->_logException($exception); @@ -218,7 +224,8 @@ protected function _formatError($errorMessage, $trace, $httpCode, $format) { $errorData = array(); $message = array('code' => $httpCode, 'message' => $errorMessage); - if ($this->_app->isDeveloperMode()) { + $isDeveloperMode = $this->_appState->getMode() == State::MODE_DEVELOPER; + if ($isDeveloperMode) { $message['trace'] = $trace; } $errorData['messages']['error'][] = $message; @@ -227,24 +234,18 @@ protected function _formatError($errorMessage, $trace, $httpCode, $format) $errorData = $this->_coreHelper->jsonEncode($errorData); break; case self::DATA_FORMAT_XML: - $errorData = '' . - '' . - '' . - '' . - '' . - '' . - $httpCode . - '' . - '' . - ($this->_app->isDeveloperMode() ? '' : '') . - '' . - '' . - '' . - ''; + $errorData = '' + . '' + . '' + . '' + . '' + . '' . $httpCode . '' + . '' + . ($isDeveloperMode ? '' : '') + . '' + . '' + . '' + . ''; break; } return $errorData; @@ -273,7 +274,7 @@ public function apiShutdownFunction() if ($error && $error['type'] & $fatalErrorFlag) { $errorMessage = "Fatal Error: '{$error['message']}' in '{$error['file']}' on line {$error['line']}"; $reportId = $this->_saveFatalErrorReport($errorMessage); - if ($this->_app->isDeveloperMode()) { + if ($this->_appState->getMode() == State::MODE_DEVELOPER) { $this->render($errorMessage); } else { $this->render(__('Server internal error. See details in report api/%1', $reportId)); diff --git a/app/code/Magento/Webapi/Controller/Rest.php b/app/code/Magento/Webapi/Controller/Rest.php index d705305c396c6..0047d63acffed 100644 --- a/app/code/Magento/Webapi/Controller/Rest.php +++ b/app/code/Magento/Webapi/Controller/Rest.php @@ -52,8 +52,8 @@ class Rest implements \Magento\App\FrontControllerInterface /** @var \Magento\App\State */ protected $_appState; - /** @var \Magento\AppInterface */ - protected $_application; + /** @var \Magento\View\LayoutInterface */ + protected $_layout; /** @var \Magento\Oauth\OauthInterface */ protected $_oauthService; @@ -71,19 +71,25 @@ class Rest implements \Magento\App\FrontControllerInterface protected $_errorProcessor; /** - * Initialize dependencies. + * Initialize dependencies * + * @var \Magento\App\AreaList + */ + protected $areaList; + + /** * @param RestRequest $request * @param RestResponse $response * @param Router $router * @param \Magento\ObjectManager $objectManager * @param \Magento\App\State $appState - * @param \Magento\AppInterface $application + * @param \Magento\View\LayoutInterface $layout * @param \Magento\Oauth\OauthInterface $oauthService * @param \Magento\Oauth\Helper\Request $oauthHelper * @param AuthorizationService $authorizationService * @param ServiceArgsSerializer $serializer * @param ErrorProcessor $errorProcessor + * @param \Magento\App\AreaList $areaList * * TODO: Consider removal of warning suppression * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -94,24 +100,26 @@ public function __construct( Router $router, \Magento\ObjectManager $objectManager, \Magento\App\State $appState, - \Magento\AppInterface $application, + \Magento\View\LayoutInterface $layout, \Magento\Oauth\OauthInterface $oauthService, \Magento\Oauth\Helper\Request $oauthHelper, AuthorizationService $authorizationService, ServiceArgsSerializer $serializer, - ErrorProcessor $errorProcessor + ErrorProcessor $errorProcessor, + \Magento\App\AreaList $areaList ) { $this->_router = $router; $this->_request = $request; $this->_response = $response; $this->_objectManager = $objectManager; $this->_appState = $appState; - $this->_application = $application; + $this->_layout = $layout; $this->_oauthService = $oauthService; $this->_oauthHelper = $oauthHelper; $this->_authorizationService = $authorizationService; $this->_serializer = $serializer; $this->_errorProcessor = $errorProcessor; + $this->areaList = $areaList; } /** @@ -125,10 +133,8 @@ public function dispatch(\Magento\App\RequestInterface $request) $pathParts = explode('/', trim($request->getPathInfo(), '/')); array_shift($pathParts); $request->setPathInfo('/' . implode('/', $pathParts)); - $this->_application->loadAreaPart( - $this->_application->getLayout()->getArea(), - \Magento\Core\Model\App\Area::PART_TRANSLATE - ); + $this->areaList->getArea($this->_layout->getArea()) + ->load(\Magento\Core\Model\App\Area::PART_TRANSLATE); try { if (!$this->_appState->isInstalled()) { throw new \Magento\Webapi\Exception(__('Magento is not yet installed')); diff --git a/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Json.php b/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Json.php index f79ac01eb557a..cbde612db3eb9 100644 --- a/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Json.php +++ b/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Json.php @@ -25,24 +25,28 @@ */ namespace Magento\Webapi\Controller\Rest\Request\Deserializer; +use \Magento\App\State; + class Json implements \Magento\Webapi\Controller\Rest\Request\DeserializerInterface { - /** @var \Magento\Core\Helper\Data */ + /** + * @var \Magento\Core\Helper\Data + */ protected $_helper; - /** @var \Magento\Core\Model\App */ - protected $_app; + /** + * @var State + */ + protected $_appState; /** - * Initialize dependencies. - * * @param \Magento\Core\Helper\Data $helper - * @param \Magento\Core\Model\App $app + * @param \Magento\App\State $appState */ - public function __construct(\Magento\Core\Helper\Data $helper, \Magento\Core\Model\App $app) + public function __construct(\Magento\Core\Helper\Data $helper, State $appState) { $this->_helper = $helper; - $this->_app = $app; + $this->_appState = $appState; } /** @@ -63,7 +67,7 @@ public function deserialize($encodedBody) try { $decodedBody = $this->_helper->jsonDecode($encodedBody); } catch (\Zend_Json_Exception $e) { - if (!$this->_app->isDeveloperMode()) { + if ($this->_appState->getMode() !== State::MODE_DEVELOPER) { throw new \Magento\Webapi\Exception(__('Decoding error.')); } else { throw new \Magento\Webapi\Exception( diff --git a/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Xml.php b/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Xml.php index 67ba2730dd980..23cbc4a9818b2 100644 --- a/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Xml.php +++ b/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Xml.php @@ -25,24 +25,24 @@ */ namespace Magento\Webapi\Controller\Rest\Request\Deserializer; +use Magento\App\State; + class Xml implements \Magento\Webapi\Controller\Rest\Request\DeserializerInterface { /** @var \Magento\Xml\Parser */ protected $_xmlParser; - /** @var \Magento\Core\Model\App */ - protected $_app; + /** @var State */ + protected $_appState; /** - * Initialize dependencies. - * * @param \Magento\Xml\Parser $xmlParser - * @param \Magento\Core\Model\App $app + * @param State $appState */ - public function __construct(\Magento\Xml\Parser $xmlParser, \Magento\Core\Model\App $app) + public function __construct(\Magento\Xml\Parser $xmlParser, State $appState) { $this->_xmlParser = $xmlParser; - $this->_app = $app; + $this->_appState = $appState; } /** @@ -80,7 +80,7 @@ public function deserialize($xmlRequestBody) /** Process errors during XML parsing. */ if ($this->_errorMessage !== null) { - if (!$this->_app->isDeveloperMode()) { + if ($this->_appState->getMode() !== State::MODE_DEVELOPER) { $exceptionMessage = __('Decoding error.'); } else { $exceptionMessage = 'Decoding Error: ' . $this->_errorMessage; diff --git a/app/code/Magento/Webapi/Controller/Rest/Response.php b/app/code/Magento/Webapi/Controller/Rest/Response.php index e962edf06906a..b2f530660f6b2 100644 --- a/app/code/Magento/Webapi/Controller/Rest/Response.php +++ b/app/code/Magento/Webapi/Controller/Rest/Response.php @@ -33,24 +33,26 @@ class Response extends \Magento\Webapi\Controller\Response /** @var \Magento\Webapi\Controller\Rest\Response\RendererInterface */ protected $_renderer; - /** @var \Magento\Core\Model\App */ - protected $_app; + /** + * @var \Magento\App\State + */ + protected $_appState; /** * Initialize dependencies. * * @param \Magento\Webapi\Controller\Rest\Response\Renderer\Factory $rendererFactory * @param \Magento\Webapi\Controller\ErrorProcessor $errorProcessor - * @param \Magento\Core\Model\App $app + * @param \Magento\App\State $appState */ public function __construct( \Magento\Webapi\Controller\Rest\Response\Renderer\Factory $rendererFactory, \Magento\Webapi\Controller\ErrorProcessor $errorProcessor, - \Magento\Core\Model\App $app + \Magento\App\State $appState ) { $this->_renderer = $rendererFactory->get(); $this->_errorProcessor = $errorProcessor; - $this->_app = $app; + $this->_appState = $appState; } /** @@ -103,7 +105,7 @@ protected function _renderMessages() if ($maskedException->getDetails()) { $messageData['parameters'] = $maskedException->getDetails(); } - if ($this->_app->isDeveloperMode()) { + if ($this->_appState->getMode() == \Magento\App\State::MODE_DEVELOPER) { $messageData['trace'] = $exception->getTraceAsString(); } $formattedMessages['errors'][] = $messageData; diff --git a/app/code/Magento/Webapi/Controller/Soap.php b/app/code/Magento/Webapi/Controller/Soap.php index bd2e20048b4de..7875b4460f756 100644 --- a/app/code/Magento/Webapi/Controller/Soap.php +++ b/app/code/Magento/Webapi/Controller/Soap.php @@ -62,8 +62,8 @@ class Soap implements \Magento\App\FrontControllerInterface /** @var \Magento\App\State */ protected $_appState; - /** @var \Magento\AppInterface */ - protected $_application; + /** @var \Magento\View\LayoutInterface */ + protected $_layout; /** * @var \Magento\Oauth\OauthInterface @@ -75,6 +75,11 @@ class Soap implements \Magento\App\FrontControllerInterface */ protected $_localeResolver; + /** + * @var \Magento\App\AreaList + */ + protected $areaList; + /** * @param Soap\Request $request * @param Response $response @@ -82,9 +87,12 @@ class Soap implements \Magento\App\FrontControllerInterface * @param \Magento\Webapi\Model\Soap\Server $soapServer * @param ErrorProcessor $errorProcessor * @param \Magento\App\State $appState - * @param \Magento\AppInterface $application + * @param \Magento\View\LayoutInterface $layout * @param \Magento\Oauth\OauthInterface $oauthService * @param \Magento\Locale\ResolverInterface $localeResolver + * @param \Magento\App\AreaList $areaList + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Webapi\Controller\Soap\Request $request, @@ -93,9 +101,10 @@ public function __construct( \Magento\Webapi\Model\Soap\Server $soapServer, ErrorProcessor $errorProcessor, \Magento\App\State $appState, - \Magento\AppInterface $application, + \Magento\View\LayoutInterface $layout, \Magento\Oauth\OauthInterface $oauthService, - \Magento\Locale\ResolverInterface $localeResolver + \Magento\Locale\ResolverInterface $localeResolver, + \Magento\App\AreaList $areaList ) { $this->_request = $request; $this->_response = $response; @@ -103,9 +112,10 @@ public function __construct( $this->_soapServer = $soapServer; $this->_errorProcessor = $errorProcessor; $this->_appState = $appState; - $this->_application = $application; $this->_oauthService = $oauthService; $this->_localeResolver = $localeResolver; + $this->_layout = $layout; + $this->areaList = $areaList; } /** @@ -119,10 +129,8 @@ public function dispatch(\Magento\App\RequestInterface $request) $pathParts = explode('/', trim($request->getPathInfo(), '/')); array_shift($pathParts); $request->setPathInfo('/' . implode('/', $pathParts)); - $this->_application->loadAreaPart( - $this->_application->getLayout()->getArea(), - \Magento\Core\Model\App\Area::PART_TRANSLATE - ); + $this->areaList->getArea($this->_layout->getArea()) + ->load(\Magento\Core\Model\App\Area::PART_TRANSLATE); try { if (!$this->_appState->isInstalled()) { throw new WebapiException(__('Magento is not yet installed')); @@ -193,10 +201,11 @@ protected function _prepareErrorResponse($exception) $this->_setResponseContentType($contentType); $this->_response->setHttpResponseCode($httpCode); $soapFault = new \Magento\Webapi\Model\Soap\Fault( - $this->_application, + $this->_request, $this->_soapServer, $maskedException, - $this->_localeResolver + $this->_localeResolver, + $this->_appState ); // TODO: Generate list of available URLs when invalid WSDL URL specified $this->_setResponseBody($soapFault->toXml()); diff --git a/app/code/Magento/Webapi/Model/Soap/Fault.php b/app/code/Magento/Webapi/Model/Soap/Fault.php index f7c4d9f8b9bc1..cb1f639ce3840 100644 --- a/app/code/Magento/Webapi/Model/Soap/Fault.php +++ b/app/code/Magento/Webapi/Model/Soap/Fault.php @@ -25,6 +25,8 @@ */ namespace Magento\Webapi\Model\Soap; +use Magento\App\State; + class Fault extends \RuntimeException { const FAULT_REASON_INTERNAL = 'Internal Error.'; @@ -84,9 +86,9 @@ class Fault extends \RuntimeException protected $_details = array(); /** - * @var \Magento\Core\Model\App + * @var \Magento\App\RequestInterface */ - protected $_application; + protected $_request; /** * @var Server @@ -99,24 +101,32 @@ class Fault extends \RuntimeException protected $_localeResolver; /** - * @param \Magento\Core\Model\App $application + * @var \Magento\App\State + */ + protected $appState; + + /** + * @param \Magento\App\RequestInterface $request * @param Server $soapServer * @param \Magento\Webapi\Exception $previousException * @param \Magento\Locale\ResolverInterface $localeResolver + * @param State $appState */ public function __construct( - \Magento\Core\Model\App $application, + \Magento\App\RequestInterface $request, Server $soapServer, \Magento\Webapi\Exception $previousException, - \Magento\Locale\ResolverInterface $localeResolver + \Magento\Locale\ResolverInterface $localeResolver, + State $appState ) { parent::__construct($previousException->getMessage(), $previousException->getCode(), $previousException); $this->_soapCode = $previousException->getOriginator(); $this->_parameters = $previousException->getDetails(); $this->_errorCode = $previousException->getCode(); - $this->_application = $application; + $this->_request = $request; $this->_soapServer = $soapServer; $this->_localeResolver = $localeResolver; + $this->appState = $appState; $this->_setFaultName($previousException->getName()); } @@ -127,7 +137,7 @@ public function __construct( */ public function toXml() { - if ($this->_application->isDeveloperMode()) { + if ($this->appState->getMode() == State::MODE_DEVELOPER) { $this->addDetails(array(self::NODE_DETAIL_TRACE => "getTraceAsString()}]]>")); } if ($this->getParameters()) { @@ -169,7 +179,7 @@ public function getFaultName() protected function _setFaultName($exceptionName) { if ($exceptionName) { - $contentType = $this->_application->getRequest()->getHeader('Content-Type'); + $contentType = $this->_request->getHeader('Content-Type'); /** SOAP action is specified in content type header if content type is application/soap+xml */ if (preg_match('|application/soap\+xml.+action="(.+)".*|', $contentType, $matches)) { $soapAction = $matches[1]; diff --git a/app/code/Magento/Webapi/etc/webapi_rest/di.xml b/app/code/Magento/Webapi/etc/webapi_rest/di.xml index 69e4d199206e1..9d49baaf00233 100644 --- a/app/code/Magento/Webapi/etc/webapi_rest/di.xml +++ b/app/code/Magento/Webapi/etc/webapi_rest/di.xml @@ -31,6 +31,7 @@ + diff --git a/app/code/Magento/Webapi/etc/webapi_soap/di.xml b/app/code/Magento/Webapi/etc/webapi_soap/di.xml index 52e0ee9a1c7bc..4415bbc060be1 100644 --- a/app/code/Magento/Webapi/etc/webapi_soap/di.xml +++ b/app/code/Magento/Webapi/etc/webapi_soap/di.xml @@ -31,6 +31,7 @@ + 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 7adbc06e57762..39eb5de39f1e8 100644 --- a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php +++ b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php @@ -25,7 +25,7 @@ */ namespace Magento\Weee\Model\Attribute\Backend\Weee; -use Magento\Core\Exception; +use Magento\Model\Exception; class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price { diff --git a/app/code/Magento/Weee/Model/Observer.php b/app/code/Magento/Weee/Model/Observer.php index 2f800f6169478..7ec5addd9afb1 100644 --- a/app/code/Magento/Weee/Model/Observer.php +++ b/app/code/Magento/Weee/Model/Observer.php @@ -25,7 +25,7 @@ */ namespace Magento\Weee\Model; -class Observer extends \Magento\Core\Model\AbstractModel +class Observer extends \Magento\Model\AbstractModel { /** * @var \Magento\Catalog\Model\Product\Type @@ -62,7 +62,7 @@ class Observer extends \Magento\Core\Model\AbstractModel * @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\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -74,7 +74,7 @@ public function __construct( \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\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -251,7 +251,7 @@ public function updateProductOptions(\Magento\Event\Observer $observer) $response = $observer->getEvent()->getResponseObject(); $options = $response->getAdditionalOptions(); - $_product = $this->_coreRegistry->registry('current_product'); + $_product = $this->_registry->registry('current_product'); if (!$_product) { return $this; } @@ -287,7 +287,7 @@ public function updateBundleProductOptions(\Magento\Event\Observer $observer) $selection = $observer->getEvent()->getSelection(); $options = $response->getAdditionalOptions(); - $_product = $this->_coreRegistry->registry('current_product'); + $_product = $this->_registry->registry('current_product'); $typeDynamic = \Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Attributes\Extend::DYNAMIC; if (!$_product || $_product->getPriceType() != $typeDynamic) { diff --git a/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php b/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php index bde9a7bbbc210..d622c1f004fe5 100644 --- a/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php +++ b/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php @@ -32,7 +32,7 @@ * @package Magento_Weee * @author Magento Core Team */ -class Tax extends \Magento\Core\Model\Resource\Db\AbstractDb +class Tax extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Core\Model\StoreManagerInterface diff --git a/app/code/Magento/Weee/Model/Resource/Tax.php b/app/code/Magento/Weee/Model/Resource/Tax.php index 0205ce4c2d7d0..3d8c6d73db0c1 100644 --- a/app/code/Magento/Weee/Model/Resource/Tax.php +++ b/app/code/Magento/Weee/Model/Resource/Tax.php @@ -31,7 +31,7 @@ /** * Wee tax resource model */ -class Tax extends \Magento\Core\Model\Resource\Db\AbstractDb +class Tax extends \Magento\Model\Resource\Db\AbstractDb { /** * @var \Magento\Stdlib\DateTime diff --git a/app/code/Magento/Weee/Model/Tax.php b/app/code/Magento/Weee/Model/Tax.php index 425d4a51623c7..e15d9623ad90a 100644 --- a/app/code/Magento/Weee/Model/Tax.php +++ b/app/code/Magento/Weee/Model/Tax.php @@ -28,7 +28,7 @@ use Magento\Catalog\Model\Product; use Magento\Core\Model\Website; -class Tax extends \Magento\Core\Model\AbstractModel +class Tax extends \Magento\Model\AbstractModel { /** * Including FPT only diff --git a/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php b/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php index b2d44402b2abf..00a54f436870c 100644 --- a/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php +++ b/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php @@ -131,14 +131,14 @@ public function getMainFieldset() /** * Add fields to main fieldset based on specified widget type * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ public function addFields() { // get configuration node and translation helper if (!$this->getWidgetType()) { - throw new \Magento\Core\Exception(__('Please specify a Widget Type.')); + throw new \Magento\Model\Exception(__('Please specify a Widget Type.')); } $config = $this->_widget->getConfigAsObject($this->getWidgetType()); if (!$config->getParameters()) { diff --git a/app/code/Magento/Widget/Controller/Adminhtml/Widget.php b/app/code/Magento/Widget/Controller/Adminhtml/Widget.php index e80ebdb798398..98ca02c4b3033 100644 --- a/app/code/Magento/Widget/Controller/Adminhtml/Widget.php +++ b/app/code/Magento/Widget/Controller/Adminhtml/Widget.php @@ -110,7 +110,7 @@ public function loadOptionsAction() } $this->_view->renderLayout(); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $result = array('error' => true, 'message' => $e->getMessage()); $this->getResponse()->setBody($this->_objectManager->get('Magento\Core\Helper\Data')->jsonEncode($result)); } diff --git a/app/code/Magento/Widget/Model/Resource/Widget.php b/app/code/Magento/Widget/Model/Resource/Widget.php index fb3b72f514501..bd7f1e28a8c3c 100644 --- a/app/code/Magento/Widget/Model/Resource/Widget.php +++ b/app/code/Magento/Widget/Model/Resource/Widget.php @@ -34,7 +34,7 @@ */ namespace Magento\Widget\Model\Resource; -class Widget extends \Magento\Core\Model\Resource\Db\AbstractDb +class Widget extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table diff --git a/app/code/Magento/Widget/Model/Resource/Widget/Instance.php b/app/code/Magento/Widget/Model/Resource/Widget/Instance.php index 9bbc407b3c633..3d7269e1fa3e2 100644 --- a/app/code/Magento/Widget/Model/Resource/Widget/Instance.php +++ b/app/code/Magento/Widget/Model/Resource/Widget/Instance.php @@ -34,9 +34,9 @@ */ namespace Magento\Widget\Model\Resource\Widget; -use Magento\Core\Model\AbstractModel; +use Magento\Model\AbstractModel; -class Instance extends \Magento\Core\Model\Resource\Db\AbstractDb +class Instance extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table diff --git a/app/code/Magento/Widget/Model/Resource/Widget/Instance/Collection.php b/app/code/Magento/Widget/Model/Resource/Widget/Instance/Collection.php index daf2cb9a1a0c5..624d11ca5a9eb 100644 --- a/app/code/Magento/Widget/Model/Resource/Widget/Instance/Collection.php +++ b/app/code/Magento/Widget/Model/Resource/Widget/Instance/Collection.php @@ -34,7 +34,7 @@ */ namespace Magento\Widget\Model\Resource\Widget\Instance; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Fields map for corellation names & real selected fields diff --git a/app/code/Magento/Widget/Model/Widget/Instance.php b/app/code/Magento/Widget/Model/Widget/Instance.php index f7b223cd47ddf..66090c5e3a530 100644 --- a/app/code/Magento/Widget/Model/Widget/Instance.php +++ b/app/code/Magento/Widget/Model/Widget/Instance.php @@ -43,7 +43,7 @@ * @package Magento_Widget * @author Magento Core Team */ -class Instance extends \Magento\Core\Model\AbstractModel +class Instance extends \Magento\Model\AbstractModel { const SPECIFIC_ENTITIES = 'specific'; @@ -137,7 +137,7 @@ class Instance extends \Magento\Core\Model\AbstractModel * @param \Magento\Widget\Model\NamespaceResolver $namespaceResolver * @param \Magento\Math\Random $mathRandom * @param \Magento\App\Filesystem $filesystem - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param string[] $relatedCacheTypes * @param array $data @@ -154,7 +154,7 @@ public function __construct( \Magento\Widget\Model\NamespaceResolver $namespaceResolver, \Magento\Math\Random $mathRandom, \Magento\App\Filesystem $filesystem, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $relatedCacheTypes = array(), array $data = array() diff --git a/app/code/Magento/Wishlist/Block/AbstractBlock.php b/app/code/Magento/Wishlist/Block/AbstractBlock.php index f6623f5653a42..27e896736812b 100644 --- a/app/code/Magento/Wishlist/Block/AbstractBlock.php +++ b/app/code/Magento/Wishlist/Block/AbstractBlock.php @@ -61,36 +61,14 @@ abstract class AbstractBlock extends \Magento\Catalog\Block\Product\AbstractProd protected $_productFactory; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\App\Http\Context $httpContext * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\App\Http\Context $httpContext, \Magento\Catalog\Model\ProductFactory $productFactory, array $data = array(), @@ -100,16 +78,6 @@ public function __construct( $this->_productFactory = $productFactory; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Wishlist/Block/Customer/Sidebar.php b/app/code/Magento/Wishlist/Block/Customer/Sidebar.php index de342a3717299..9e301f4ef97d8 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Sidebar.php +++ b/app/code/Magento/Wishlist/Block/Customer/Sidebar.php @@ -128,9 +128,11 @@ public function hasWishlistItems() public function getIdentities() { $identities = array(); - foreach ($this->getWishlistItems() as $item) { - /** @var $item \Magento\Wishlist\Model\Item */ - $identities = array_merge($identities, $item->getProduct()->getIdentities()); + if ($this->getItemCount()) { + foreach ($this->getWishlistItems() as $item) { + /** @var $item \Magento\Wishlist\Model\Item */ + $identities = array_merge($identities, $item->getProduct()->getIdentities()); + } } return $identities; } diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist.php index cd79559be5ca3..6dbefdbb1dfda 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Wishlist.php +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist.php @@ -54,38 +54,16 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock protected $_formKey; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\App\Http\Context $httpContext * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool * @param \Magento\Data\Form\FormKey $formKey * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\App\Http\Context $httpContext, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool, @@ -97,16 +75,6 @@ public function __construct( $this->_helperPool = $helperPool; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $httpContext, $productFactory, $data, diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php index d3ebf8e4bd19b..5a50c00c83932 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php @@ -53,37 +53,15 @@ class Options extends \Magento\Wishlist\Block\AbstractBlock ); /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\App\Http\Context $httpContext * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\App\Http\Context $httpContext, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool, @@ -93,16 +71,6 @@ public function __construct( $this->_helperPool = $helperPool; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $httpContext, $productFactory, $data, diff --git a/app/code/Magento/Wishlist/Block/Share/Wishlist.php b/app/code/Magento/Wishlist/Block/Share/Wishlist.php index 1525ba5d71ce2..7d6bd30553109 100644 --- a/app/code/Magento/Wishlist/Block/Share/Wishlist.php +++ b/app/code/Magento/Wishlist/Block/Share/Wishlist.php @@ -49,37 +49,15 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock protected $_customerFactory; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Registry $registry - * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Math\Random $mathRandom - * @param \Magento\Checkout\Helper\Cart $cartHelper - * @param \Magento\Wishlist\Helper\Data $wishlistHelper - * @param \Magento\Catalog\Helper\Product\Compare $compareProduct - * @param \Magento\Theme\Helper\Layout $layoutHelper - * @param \Magento\Catalog\Helper\Image $imageHelper + * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\App\Http\Context $httpContext * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param array $data * @param array $priceBlockTypes - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Registry $registry, - \Magento\Tax\Helper\Data $taxData, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Math\Random $mathRandom, - \Magento\Checkout\Helper\Cart $cartHelper, - \Magento\Wishlist\Helper\Data $wishlistHelper, - \Magento\Catalog\Helper\Product\Compare $compareProduct, - \Magento\Theme\Helper\Layout $layoutHelper, - \Magento\Catalog\Helper\Image $imageHelper, + \Magento\Catalog\Block\Product\Context $context, \Magento\App\Http\Context $httpContext, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, @@ -89,16 +67,6 @@ public function __construct( $this->_customerFactory = $customerFactory; parent::__construct( $context, - $catalogConfig, - $registry, - $taxData, - $catalogData, - $mathRandom, - $cartHelper, - $wishlistHelper, - $compareProduct, - $layoutHelper, - $imageHelper, $httpContext, $productFactory, $data, diff --git a/app/code/Magento/Wishlist/Controller/AbstractController.php b/app/code/Magento/Wishlist/Controller/AbstractController.php index bf2a8b5055158..9e0455e83ba88 100644 --- a/app/code/Magento/Wishlist/Controller/AbstractController.php +++ b/app/code/Magento/Wishlist/Controller/AbstractController.php @@ -127,7 +127,7 @@ public function allcartAction() if ($item->addToCart($cart, $isOwner)) { $addedItems[] = $item->getProduct(); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if ($e->getCode() == \Magento\Wishlist\Model\Item::EXCEPTION_CODE_NOT_SALABLE) { $notSalable[] = $item; } elseif ($e->getCode() == \Magento\Wishlist\Model\Item::EXCEPTION_CODE_HAS_REQUIRED_OPTIONS) { diff --git a/app/code/Magento/Wishlist/Controller/Index.php b/app/code/Magento/Wishlist/Controller/Index.php index b9c03c92aedb5..9fd3d969fc0f8 100644 --- a/app/code/Magento/Wishlist/Controller/Index.php +++ b/app/code/Magento/Wishlist/Controller/Index.php @@ -70,6 +70,11 @@ class Index extends \Magento\Wishlist\Controller\AbstractController implements */ protected $_transportBuilder; + /** + * @var \Magento\Translate\Inline\StateInterface + */ + protected $inlineTranslation; + /** * @param \Magento\App\Action\Context $context * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator @@ -77,6 +82,7 @@ class Index extends \Magento\Wishlist\Controller\AbstractController implements * @param \Magento\Wishlist\Model\Config $wishlistConfig * @param \Magento\App\Response\Http\FileFactory $fileResponseFactory * @param \Magento\Mail\Template\TransportBuilder $transportBuilder + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation */ public function __construct( \Magento\App\Action\Context $context, @@ -84,12 +90,14 @@ public function __construct( \Magento\Registry $coreRegistry, \Magento\Wishlist\Model\Config $wishlistConfig, \Magento\App\Response\Http\FileFactory $fileResponseFactory, - \Magento\Mail\Template\TransportBuilder $transportBuilder + \Magento\Mail\Template\TransportBuilder $transportBuilder, + \Magento\Translate\Inline\StateInterface $inlineTranslation ) { $this->_coreRegistry = $coreRegistry; $this->_wishlistConfig = $wishlistConfig; $this->_fileResponseFactory = $fileResponseFactory; $this->_transportBuilder = $transportBuilder; + $this->inlineTranslation = $inlineTranslation; parent::__construct($context, $formKeyValidator); } @@ -153,16 +161,16 @@ protected function _getWishlist($wishlistId = null) if ($wishlistId) { $wishlist->load($wishlistId); } else { - $wishlist->loadByCustomer($customerId, true); + $wishlist->loadByCustomerId($customerId, true); } if (!$wishlist->getId() || $wishlist->getCustomerId() != $customerId) { $wishlist = null; - throw new \Magento\Core\Exception(__("The requested wish list doesn't exist.")); + throw new \Magento\Model\Exception(__("The requested wish list doesn't exist.")); } $this->_coreRegistry->register('wishlist', $wishlist); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); return false; } catch (\Exception $e) { @@ -242,7 +250,7 @@ public function addAction() $result = $wishlist->addNewItem($product, $buyRequest); if (is_string($result)) { - throw new \Magento\Core\Exception($result); + throw new \Magento\Model\Exception($result); } $wishlist->save(); @@ -271,7 +279,7 @@ public function addAction() $this->_objectManager->get('Magento\Escaper')->escapeUrl($referer) ); $this->messageManager->addSuccess($message); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError( __('An error occurred while adding item to wish list: %1', $e->getMessage()) ); @@ -297,7 +305,7 @@ public function configureAction() $item = $this->_objectManager->create('Magento\Wishlist\Model\Item'); $item->loadWithOptions($id); if (!$item->getId()) { - throw new \Magento\Core\Exception(__('We can\'t load the wish list item.')); + throw new \Magento\Model\Exception(__('We can\'t load the wish list item.')); } $wishlist = $this->_getWishlist($item->getWishlistId()); if (!$wishlist) { @@ -325,7 +333,7 @@ public function configureAction() $this, $params ); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); $this->_redirect('*'); return; @@ -383,7 +391,7 @@ public function updateItemOptionsAction() $message = __('%1 has been updated in your wish list.', $product->getName()); $this->messageManager->addSuccess($message); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('An error occurred while updating wish list.')); @@ -501,7 +509,7 @@ public function removeAction() try { $item->delete(); $wishlist->save(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError( __('An error occurred while deleting the item from wish list: %1', $e->getMessage()) ); @@ -593,7 +601,7 @@ public function cartAction() $redirectUrl = $this->_redirect->getRefererUrl(); } $this->_objectManager->get('Magento\Wishlist\Helper\Data')->calculate(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if ($e->getCode() == \Magento\Wishlist\Model\Item::EXCEPTION_CODE_NOT_SALABLE) { $this->messageManager->addError(__('This product(s) is out of stock.')); } elseif ($e->getCode() == \Magento\Wishlist\Model\Item::EXCEPTION_CODE_HAS_REQUIRED_OPTIONS) { @@ -633,7 +641,7 @@ public function fromcartAction() try { $item = $cart->getQuote()->getItemById($itemId); if (!$item) { - throw new \Magento\Core\Exception(__("The requested cart item doesn't exist.")); + throw new \Magento\Model\Exception(__("The requested cart item doesn't exist.")); } $productId = $item->getProductId(); @@ -649,7 +657,7 @@ public function fromcartAction() $wishlistName = $this->_objectManager->get('Magento\Escaper')->escapeHtml($wishlist->getName()); $this->messageManager->addSuccess(__("%1 has been moved to wish list %2", $productName, $wishlistName)); $wishlist->save(); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('We can\'t move the item to the wish list.')); @@ -727,9 +735,8 @@ public function sendAction() return; } - $translate = $this->_objectManager->get('Magento\TranslateInterface'); - /* @var $translate \Magento\TranslateInterface */ - $translate->setTranslateInline(false); + $this->inlineTranslation->suspend(); + $sent = 0; try { @@ -790,13 +797,13 @@ public function sendAction() $wishlist->setShared($wishlist->getShared() + $sent); $wishlist->save(); - $translate->setTranslateInline(true); + $this->inlineTranslation->resume(); $this->_eventManager->dispatch('wishlist_share', array('wishlist' => $wishlist)); $this->messageManager->addSuccess(__('Your wish list has been shared.')); $this->_redirect('*/*', array('wishlist_id' => $wishlist->getId())); } catch (\Exception $e) { - $translate->setTranslateInline(true); + $this->inlineTranslation->resume(); $this->messageManager->addError($e->getMessage()); $this->_objectManager->get( 'Magento\Wishlist\Model\Session' diff --git a/app/code/Magento/Wishlist/Controller/Shared.php b/app/code/Magento/Wishlist/Controller/Shared.php index f2c204c3d83c9..b3dc3fcb2dfa8 100644 --- a/app/code/Magento/Wishlist/Controller/Shared.php +++ b/app/code/Magento/Wishlist/Controller/Shared.php @@ -139,7 +139,7 @@ public function cartAction() if ($this->_objectManager->get('Magento\Checkout\Helper\Cart')->getShouldRedirectToCart()) { $redirectUrl = $this->_objectManager->get('Magento\Checkout\Helper\Cart')->getCartUrl(); } - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { if ($e->getCode() == \Magento\Wishlist\Model\Item::EXCEPTION_CODE_NOT_SALABLE) { $this->messageManager->addError(__('This product(s) is out of stock.')); } else { diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php index 34958fb58507e..648f786e8f08f 100644 --- a/app/code/Magento/Wishlist/Helper/Data.php +++ b/app/code/Magento/Wishlist/Helper/Data.php @@ -204,7 +204,7 @@ public function getWishlist() } else { $this->_wishlist = $this->_wishlistFactory->create(); if ($this->getCustomer()) { - $this->_wishlist->loadByCustomer($this->getCustomer()); + $this->_wishlist->loadByCustomerId($this->getCustomer()->getId()); } } } diff --git a/app/code/Magento/Wishlist/Model/Item.php b/app/code/Magento/Wishlist/Model/Item.php index cc0f431c3dab0..f147de4aa2d15 100644 --- a/app/code/Magento/Wishlist/Model/Item.php +++ b/app/code/Magento/Wishlist/Model/Item.php @@ -42,7 +42,7 @@ use Magento\Wishlist\Model\Item\OptionFactory; use Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory; -class Item extends \Magento\Core\Model\AbstractModel implements +class Item extends \Magento\Model\AbstractModel implements \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface { const EXCEPTION_CODE_NOT_SALABLE = 901; @@ -144,7 +144,7 @@ class Item extends \Magento\Core\Model\AbstractModel implements * @param OptionFactory $wishlistOptFactory * @param CollectionFactory $wishlOptionCollectionFactory * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -158,7 +158,7 @@ public function __construct( OptionFactory $wishlistOptFactory, CollectionFactory $wishlOptionCollectionFactory, \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -230,14 +230,14 @@ protected function _compareOptions($options1, $options2) * * @param Option $option * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _addOptionCode($option) { if (!isset($this->_optionsByCode[$option->getCode()])) { $this->_optionsByCode[$option->getCode()] = $option; } else { - throw new \Magento\Core\Exception(__('An item option with code %1 already exists.', $option->getCode())); + throw new \Magento\Model\Exception(__('An item option with code %1 already exists.', $option->getCode())); } return $this; } @@ -313,15 +313,15 @@ protected function _afterSave() * Validate wish list item data * * @return bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function validate() { if (!$this->getWishlistId()) { - throw new \Magento\Core\Exception(__('We can\'t specify a wish list.')); + throw new \Magento\Model\Exception(__('We can\'t specify a wish list.')); } if (!$this->getProductId()) { - throw new \Magento\Core\Exception(__('Cannot specify product.')); + throw new \Magento\Model\Exception(__('Cannot specify product.')); } return true; @@ -372,7 +372,7 @@ public function loadByProductWishlist($wishlistId, $productId, $sharedStores) /** * Retrieve item product instance * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return \Magento\Catalog\Model\Product */ public function getProduct() @@ -380,7 +380,7 @@ public function getProduct() $product = $this->_getData('product'); if (is_null($product)) { if (!$this->getProductId()) { - throw new \Magento\Core\Exception(__('Cannot specify product.')); + throw new \Magento\Model\Exception(__('Cannot specify product.')); } $product = $this->_productFactory->create()->setStoreId($this->getStoreId())->load($this->getProductId()); @@ -405,7 +405,7 @@ public function getProduct() * @param \Magento\Checkout\Model\Cart $cart * @param bool $delete delete the item after successful add to cart * @return bool - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addToCart(\Magento\Checkout\Model\Cart $cart, $delete = false) { @@ -433,7 +433,7 @@ public function addToCart(\Magento\Checkout\Model\Cart $cart, $delete = false) } if (!$product->isSalable()) { - throw new \Magento\Core\Exception(null, self::EXCEPTION_CODE_NOT_SALABLE); + throw new \Magento\Model\Exception(null, self::EXCEPTION_CODE_NOT_SALABLE); } $buyRequest = $this->getBuyRequest(); @@ -661,7 +661,7 @@ public function getOptionsByCode() * * @param Option|\Magento\Object|array $option * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ public function addOption($option) { @@ -674,7 +674,7 @@ public function addOption($option) ->setProduct($option->getProduct()) ->setItem($this); } else { - throw new \Magento\Core\Exception(__('Invalid item option format.')); + throw new \Magento\Model\Exception(__('Invalid item option format.')); } $exOption = $this->getOptionByCode($option->getCode()); diff --git a/app/code/Magento/Wishlist/Model/Item/Option.php b/app/code/Magento/Wishlist/Model/Item/Option.php index e137b6259a0f7..618c53abbd3b8 100644 --- a/app/code/Magento/Wishlist/Model/Item/Option.php +++ b/app/code/Magento/Wishlist/Model/Item/Option.php @@ -29,7 +29,7 @@ use Magento\Catalog\Model\Product; use Magento\Wishlist\Model\Item; -class Option extends \Magento\Core\Model\AbstractModel implements +class Option extends \Magento\Model\AbstractModel implements \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface { /** diff --git a/app/code/Magento/Wishlist/Model/Observer.php b/app/code/Magento/Wishlist/Model/Observer.php index 4994f827ef15b..d2a00e3b79aa3 100644 --- a/app/code/Magento/Wishlist/Model/Observer.php +++ b/app/code/Magento/Wishlist/Model/Observer.php @@ -31,7 +31,7 @@ */ namespace Magento\Wishlist\Model; -class Observer extends \Magento\Core\Model\AbstractModel +class Observer extends \Magento\Model\AbstractModel { /** * Wishlist data @@ -68,7 +68,7 @@ class Observer extends \Magento\Core\Model\AbstractModel * @param \Magento\Customer\Model\Session $customerSession * @param WishlistFactory $wishlistFactory * @param \Magento\Message\ManagerInterface $messageManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -80,7 +80,7 @@ public function __construct( \Magento\Customer\Model\Session $customerSession, WishlistFactory $wishlistFactory, \Magento\Message\ManagerInterface $messageManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -103,7 +103,7 @@ protected function _getWishlist($customerId) if (!$customerId) { return false; } - return $this->_wishlistFactory->create()->loadByCustomer($customerId, true); + return $this->_wishlistFactory->create()->loadByCustomerId($customerId, true); } /** @@ -172,7 +172,7 @@ public function processAddToCart($observer) if ($this->_customerSession->isLoggedIn()) { $wishlist = $this->_wishlistFactory->create() - ->loadByCustomer($this->_customerSession->getCustomer(), true); + ->loadByCustomerId($this->_customerSession->getCustomerId(), true); } elseif ($sharedWishlist) { $wishlist = $this->_wishlistFactory->create()->loadByCode($sharedWishlist); } else { diff --git a/app/code/Magento/Wishlist/Model/Resource/Item.php b/app/code/Magento/Wishlist/Model/Resource/Item.php index a77b9c87689d5..0ed6419f89222 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Item.php +++ b/app/code/Magento/Wishlist/Model/Resource/Item.php @@ -34,7 +34,7 @@ */ namespace Magento\Wishlist\Model\Resource; -class Item extends \Magento\Core\Model\Resource\Db\AbstractDb +class Item extends \Magento\Model\Resource\Db\AbstractDb { /** * Initialize connection and define main table diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php b/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php index eaac0c3fcb090..abc5bdd144af5 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php +++ b/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php @@ -34,7 +34,7 @@ */ namespace Magento\Wishlist\Model\Resource\Item; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Product Visibility Filter to product collection flag diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Option.php b/app/code/Magento/Wishlist/Model/Resource/Item/Option.php index 84147c9728649..fc44a53bf950f 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Item/Option.php +++ b/app/code/Magento/Wishlist/Model/Resource/Item/Option.php @@ -33,7 +33,7 @@ */ namespace Magento\Wishlist\Model\Resource\Item; -class Option extends \Magento\Core\Model\Resource\Db\AbstractDb +class Option extends \Magento\Model\Resource\Db\AbstractDb { /** * @return void diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Option/Collection.php b/app/code/Magento/Wishlist/Model/Resource/Item/Option/Collection.php index b8692269e51e6..33e9dfb4bc746 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Item/Option/Collection.php +++ b/app/code/Magento/Wishlist/Model/Resource/Item/Option/Collection.php @@ -37,7 +37,7 @@ use Magento\Catalog\Model\Product; use Magento\Wishlist\Model\Item; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Array of option ids grouped by item id diff --git a/app/code/Magento/Wishlist/Model/Resource/Wishlist.php b/app/code/Magento/Wishlist/Model/Resource/Wishlist.php index 58b6b4bccc07b..cd727a342c0a3 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Wishlist.php +++ b/app/code/Magento/Wishlist/Model/Resource/Wishlist.php @@ -34,7 +34,7 @@ */ namespace Magento\Wishlist\Model\Resource; -class Wishlist extends \Magento\Core\Model\Resource\Db\AbstractDb +class Wishlist extends \Magento\Model\Resource\Db\AbstractDb { /** * Store wishlist items count @@ -65,7 +65,7 @@ protected function _construct() * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return \Zend_Db_Select */ protected function _getLoadSelect($field, $value, $object) diff --git a/app/code/Magento/Wishlist/Model/Resource/Wishlist/Collection.php b/app/code/Magento/Wishlist/Model/Resource/Wishlist/Collection.php index f766a82d82735..b22fe690c95d2 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Wishlist/Collection.php +++ b/app/code/Magento/Wishlist/Model/Resource/Wishlist/Collection.php @@ -34,7 +34,7 @@ */ namespace Magento\Wishlist\Model\Resource\Wishlist; -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize resource diff --git a/app/code/Magento/Wishlist/Model/Wishlist.php b/app/code/Magento/Wishlist/Model/Wishlist.php index 0b7cd9cba33bc..1bb6fa98b8866 100644 --- a/app/code/Magento/Wishlist/Model/Wishlist.php +++ b/app/code/Magento/Wishlist/Model/Wishlist.php @@ -25,7 +25,7 @@ */ namespace Magento\Wishlist\Model; -use Magento\Core\Exception; +use Magento\Model\Exception; use Magento\Customer\Model\Customer; use Magento\Wishlist\Model\Resource\Item\CollectionFactory; use Magento\Wishlist\Model\Resource\Wishlist as ResourceWishlist; @@ -43,7 +43,7 @@ * @method string getUpdatedAt() * @method \Magento\Wishlist\Model\Wishlist setUpdatedAt(string $value) */ -class Wishlist extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface +class Wishlist extends \Magento\Model\AbstractModel implements \Magento\Object\IdentityInterface { /** * Cache tag @@ -180,23 +180,19 @@ public function __construct( } /** - * Load wishlist by customer + * Load wishlist by customer id * - * @param Customer|int $customer + * @param int $customerId * @param bool $create Create wishlist if don't exists * @return $this */ - public function loadByCustomer($customer, $create = false) + public function loadByCustomerId($customerId, $create = false) { - if ($customer instanceof Customer) { - $customer = $customer->getId(); - } - - $customer = (int)$customer; + $customerId = (int)$customerId; $customerIdFieldName = $this->_getResource()->getCustomerIdFieldName(); - $this->_getResource()->load($this, $customer, $customerIdFieldName); + $this->_getResource()->load($this, $customerId, $customerIdFieldName); if (!$this->getId() && $create) { - $this->setCustomerId($customer); + $this->setCustomerId($customerId); $this->setSharingCode($this->_getSharingRandomCode()); $this->save(); } diff --git a/app/design/adminhtml/magento_backend/css/admin.css b/app/design/adminhtml/magento_backend/css/admin.css index b42a4da9d2654..f35e355d90034 100644 --- a/app/design/adminhtml/magento_backend/css/admin.css +++ b/app/design/adminhtml/magento_backend/css/admin.css @@ -131,7 +131,7 @@ button.primary, .adminhtml-catalog-event-index .page-actions .add, .adminhtml-urlrewrite-index .page-actions .add, .catalog-search-index .page-actions .add, -.catalog-product-review-index .page-actions .add, +.review-product-index .page-actions .add, .catalog-rule-promo-catalog-index .page-actions .add, .sales-rule-promo-quote-index .page-actions .add, .adminhtml-reminder-index .page-actions .add, @@ -256,9 +256,9 @@ button.primary:active, .catalog-search-index .page-actions .add:hover, .catalog-search-index .page-actions .add:focus, .catalog-search-index .page-actions .add:active, -.catalog-product-review-index .page-actions .add:hover, -.catalog-product-review-index .page-actions .add:focus, -.catalog-product-review-index .page-actions .add:active, +.review-product-index .page-actions .add:hover, +.review-product-index .page-actions .add:focus, +.review-product-index .page-actions .add:active, .catalog-rule-promo-catalog-index .page-actions .add:hover, .catalog-rule-promo-catalog-index .page-actions .add:focus, .catalog-rule-promo-catalog-index .page-actions .add:active, @@ -405,7 +405,7 @@ button.primary:active, .adminhtml-catalog-event-index .page-actions .add:active, .adminhtml-urlrewrite-index .page-actions .add:active, .catalog-search-index .page-actions .add:active, -.catalog-product-review-index .page-actions .add:active, +.review-product-index .page-actions .add:active, .catalog-rule-promo-catalog-index .page-actions .add:active, .sales-rule-promo-quote-index .page-actions .add:active, .adminhtml-reminder-index .page-actions .add:active, @@ -470,7 +470,7 @@ button.primary:visited, .adminhtml-catalog-event-index .page-actions .add:visited, .adminhtml-urlrewrite-index .page-actions .add:visited, .catalog-search-index .page-actions .add:visited, -.catalog-product-review-index .page-actions .add:visited, +.review-product-index .page-actions .add:visited, .catalog-rule-promo-catalog-index .page-actions .add:visited, .sales-rule-promo-quote-index .page-actions .add:visited, .adminhtml-reminder-index .page-actions .add:visited, @@ -557,8 +557,8 @@ button.primary.disabled, .adminhtml-urlrewrite-index .page-actions .add.disabled, .catalog-search-index .page-actions .add[disabled], .catalog-search-index .page-actions .add.disabled, -.catalog-product-review-index .page-actions .add[disabled], -.catalog-product-review-index .page-actions .add.disabled, +.review-product-index .page-actions .add[disabled], +.review-product-index .page-actions .add.disabled, .catalog-rule-promo-catalog-index .page-actions .add[disabled], .catalog-rule-promo-catalog-index .page-actions .add.disabled, .sales-rule-promo-quote-index .page-actions .add[disabled], @@ -731,10 +731,10 @@ button.primary.disabled:active, .catalog-search-index .page-actions .add.disabled:hover, .catalog-search-index .page-actions .add[disabled]:active, .catalog-search-index .page-actions .add.disabled:active, -.catalog-product-review-index .page-actions .add[disabled]:hover, -.catalog-product-review-index .page-actions .add.disabled:hover, -.catalog-product-review-index .page-actions .add[disabled]:active, -.catalog-product-review-index .page-actions .add.disabled:active, +.review-product-index .page-actions .add[disabled]:hover, +.review-product-index .page-actions .add.disabled:hover, +.review-product-index .page-actions .add[disabled]:active, +.review-product-index .page-actions .add.disabled:active, .catalog-rule-promo-catalog-index .page-actions .add[disabled]:hover, .catalog-rule-promo-catalog-index .page-actions .add.disabled:hover, .catalog-rule-promo-catalog-index .page-actions .add[disabled]:active, @@ -914,7 +914,7 @@ button.primary, .adminhtml-catalog-event-index .page-actions .add, .adminhtml-urlrewrite-index .page-actions .add, .catalog-search-index .page-actions .add, -.catalog-product-review-index .page-actions .add, +.review-product-index .page-actions .add, .catalog-rule-promo-catalog-index .page-actions .add, .sales-rule-promo-quote-index .page-actions .add, .adminhtml-reminder-index .page-actions .add, @@ -989,8 +989,8 @@ button.primary:hover, .adminhtml-urlrewrite-index .page-actions .add:hover, .catalog-search-index .page-actions .add:focus, .catalog-search-index .page-actions .add:hover, -.catalog-product-review-index .page-actions .add:focus, -.catalog-product-review-index .page-actions .add:hover, +.review-product-index .page-actions .add:focus, +.review-product-index .page-actions .add:hover, .catalog-rule-promo-catalog-index .page-actions .add:focus, .catalog-rule-promo-catalog-index .page-actions .add:hover, .sales-rule-promo-quote-index .page-actions .add:focus, @@ -1090,7 +1090,7 @@ button.primary:active, .adminhtml-catalog-event-index .page-actions .add:active, .adminhtml-urlrewrite-index .page-actions .add:active, .catalog-search-index .page-actions .add:active, -.catalog-product-review-index .page-actions .add:active, +.review-product-index .page-actions .add:active, .catalog-rule-promo-catalog-index .page-actions .add:active, .sales-rule-promo-quote-index .page-actions .add:active, .adminhtml-reminder-index .page-actions .add:active, @@ -1150,7 +1150,7 @@ button.primary:visited, .adminhtml-catalog-event-index .page-actions .add:visited, .adminhtml-urlrewrite-index .page-actions .add:visited, .catalog-search-index .page-actions .add:visited, -.catalog-product-review-index .page-actions .add:visited, +.review-product-index .page-actions .add:visited, .catalog-rule-promo-catalog-index .page-actions .add:visited, .sales-rule-promo-quote-index .page-actions .add:visited, .adminhtml-reminder-index .page-actions .add:visited, @@ -1253,10 +1253,10 @@ button.primary.disabled:active, .catalog-search-index .page-actions .add.disabled:hover, .catalog-search-index .page-actions .add[disabled]:active, .catalog-search-index .page-actions .add.disabled:active, -.catalog-product-review-index .page-actions .add[disabled]:hover, -.catalog-product-review-index .page-actions .add.disabled:hover, -.catalog-product-review-index .page-actions .add[disabled]:active, -.catalog-product-review-index .page-actions .add.disabled:active, +.review-product-index .page-actions .add[disabled]:hover, +.review-product-index .page-actions .add.disabled:hover, +.review-product-index .page-actions .add[disabled]:active, +.review-product-index .page-actions .add.disabled:active, .catalog-rule-promo-catalog-index .page-actions .add[disabled]:hover, .catalog-rule-promo-catalog-index .page-actions .add.disabled:hover, .catalog-rule-promo-catalog-index .page-actions .add[disabled]:active, @@ -1428,7 +1428,7 @@ button.primary.disabled:active, .adminhtml-catalog-event-index .page-actions .add, .adminhtml-urlrewrite-index .page-actions .add, .catalog-search-index .page-actions .add, -.catalog-product-review-index .page-actions .add, +.review-product-index .page-actions .add, .catalog-rule-promo-catalog-index .page-actions .add, .sales-rule-promo-quote-index .page-actions .add, .adminhtml-reminder-index .page-actions .add, @@ -1479,7 +1479,7 @@ button.primary.disabled:active, .adminhtml-catalog-event-index .page-actions .add:focus, .adminhtml-urlrewrite-index .page-actions .add:focus, .catalog-search-index .page-actions .add:focus, -.catalog-product-review-index .page-actions .add:focus, +.review-product-index .page-actions .add:focus, .catalog-rule-promo-catalog-index .page-actions .add:focus, .sales-rule-promo-quote-index .page-actions .add:focus, .adminhtml-reminder-index .page-actions .add:focus, @@ -1525,7 +1525,7 @@ button.primary.disabled:active, .adminhtml-catalog-event-index .page-actions .add > span, .adminhtml-urlrewrite-index .page-actions .add > span, .catalog-search-index .page-actions .add > span, -.catalog-product-review-index .page-actions .add > span, +.review-product-index .page-actions .add > span, .catalog-rule-promo-catalog-index .page-actions .add > span, .sales-rule-promo-quote-index .page-actions .add > span, .adminhtml-reminder-index .page-actions .add > span, @@ -1574,7 +1574,7 @@ button.primary.disabled:active, .adminhtml-catalog-event-index .page-actions .add > span:before, .adminhtml-urlrewrite-index .page-actions .add > span:before, .catalog-search-index .page-actions .add > span:before, -.catalog-product-review-index .page-actions .add > span:before, +.review-product-index .page-actions .add > span:before, .catalog-rule-promo-catalog-index .page-actions .add > span:before, .sales-rule-promo-quote-index .page-actions .add > span:before, .adminhtml-reminder-index .page-actions .add > span:before, @@ -1634,7 +1634,7 @@ button.primary.disabled:active, .eq-ie9 .adminhtml-catalog-event-index .page-actions .add > span:before, .eq-ie9 .adminhtml-urlrewrite-index .page-actions .add > span:before, .eq-ie9 .catalog-search-index .page-actions .add > span:before, -.eq-ie9 .catalog-product-review-index .page-actions .add > span:before, +.eq-ie9 .review-product-index .page-actions .add > span:before, .eq-ie9 .catalog-rule-promo-catalog-index .page-actions .add > span:before, .eq-ie9 .sales-rule-promo-quote-index .page-actions .add > span:before, .eq-ie9 .adminhtml-reminder-index .page-actions .add > span:before, @@ -6291,7 +6291,7 @@ table .col-draggable .draggable-handle { .adminhtml-catalog-event-index .col-1-layout, .adminhtml-urlrewrite-index .col-1-layout, .catalog-search-index .col-1-layout, -.catalog-product-review-index .col-1-layout, +.review-product-index .col-1-layout, .catalog-rule-promo-catalog-index .col-1-layout, .sales-rule-promo-quote-index .col-1-layout, .adminhtml-reminder-index .col-1-layout, @@ -6374,7 +6374,7 @@ table .col-draggable .draggable-handle { .adminhtml-catalog-event-index .grid-actions, .adminhtml-urlrewrite-index .grid-actions, .catalog-search-index .grid-actions, -.catalog-product-review-index .grid-actions, +.review-product-index .grid-actions, .catalog-rule-promo-catalog-index .grid-actions, .sales-rule-promo-quote-index .grid-actions, .adminhtml-reminder-index .grid-actions, @@ -6418,7 +6418,7 @@ table .col-draggable .draggable-handle { .adminhtml-catalog-event-index .page-actions.fixed, .adminhtml-urlrewrite-index .page-actions.fixed, .catalog-search-index .page-actions.fixed, -.catalog-product-review-index .page-actions.fixed, +.review-product-index .page-actions.fixed, .catalog-rule-promo-catalog-index .page-actions.fixed, .sales-rule-promo-quote-index .page-actions.fixed, .adminhtml-reminder-index .page-actions.fixed, @@ -6463,7 +6463,7 @@ table .col-draggable .draggable-handle { .adminhtml-catalog-event-index .page-actions, .adminhtml-urlrewrite-index .page-actions, .catalog-search-index .page-actions, -.catalog-product-review-index .page-actions, +.review-product-index .page-actions, .catalog-rule-promo-catalog-index .page-actions, .sales-rule-promo-quote-index .page-actions, .adminhtml-reminder-index .page-actions, diff --git a/app/etc/di.xml b/app/etc/di.xml index 4e9b0158b6028..189debd0ccdc8 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -30,7 +30,6 @@ - @@ -87,7 +86,12 @@ - + + + + Magento\Model\ActionValidator\RemoveAction\Proxy + + Magento\Message\Session\Proxy @@ -141,12 +145,12 @@ - Magento\Core\Model\App::PARAM_ALLOWED_MODULES + Magento\Module\Declaration\Reader\Filesystem::PARAM_ALLOWED_MODULES - Magento\Core\Model\App::PARAM_CACHE_FORCED_OPTIONS + Magento\App\Cache\Frontend\Factory::PARAM_CACHE_FORCED_OPTIONS Magento\Cache\Frontend\Decorator\TagScope @@ -160,19 +164,26 @@ - Magento\Core\Model\App::PARAM_BAN_CACHE + Magento\App\Cache\State::PARAM_BAN_CACHE - Magento\Core\Model\App::PARAM_RUN_CODE - Magento\Core\Model\App::PARAM_RUN_TYPE + Magento\Core\Model\StoreManager::PARAM_RUN_CODE + Magento\Core\Model\StoreManager::PARAM_RUN_TYPE Magento\App\Cache\Type\Translate Magento\Locale\Resolver\Proxy + Magento\Translate\ResourceInterface\Proxy + Magento\App\Request\Http\Proxy + + + + + Magento\Translate\InlineInterface\Proxy @@ -326,7 +337,7 @@ - Magento\Core\Model\Mview\View\State + Magento\Indexer\Model\Mview\View\State Magento\Mview\View\Changelog @@ -368,4 +379,9 @@ + + + Magento\Translate\Inline\ParserInterface\Proxy + + diff --git a/app/etc/local.xml.template b/app/etc/local.xml.template index a54acc9e4a5f9..5c517a2403da2 100644 --- a/app/etc/local.xml.template +++ b/app/etc/local.xml.template @@ -55,7 +55,7 @@ {{db_model}} - Magento\Core\Model\Resource\Type\Db\Pdo\Mysql + Magento\Model\Resource\Type\Db\Pdo\Mysql 1 diff --git a/dev/shell/indexer.php b/dev/shell/indexer.php index 7ac4fca66c177..5de788f9c0cc1 100644 --- a/dev/shell/indexer.php +++ b/dev/shell/indexer.php @@ -25,9 +25,11 @@ */ require_once __DIR__ . '/../../app/bootstrap.php'; +use Magento\Core\Model\StoreManager; + $params = array( - \Magento\Core\Model\App::PARAM_RUN_CODE => 'admin', - \Magento\Core\Model\App::PARAM_RUN_TYPE => 'store' + StoreManager::PARAM_RUN_CODE => 'admin', + StoreManager::PARAM_RUN_TYPE => 'store' ); $entryPoint = new \Magento\App\EntryPoint\EntryPoint(BP, $params); diff --git a/dev/shell/log.php b/dev/shell/log.php index b026dc0330dce..87a85315b0f36 100644 --- a/dev/shell/log.php +++ b/dev/shell/log.php @@ -25,9 +25,12 @@ */ require_once __DIR__ . '/../../app/bootstrap.php'; +use Magento\Core\Model\StoreManager; + $params = array( - \Magento\Core\Model\App::PARAM_RUN_CODE => 'admin', - \Magento\Core\Model\App::PARAM_RUN_TYPE => 'store' + StoreManager::PARAM_RUN_CODE => 'admin', + StoreManager::PARAM_RUN_TYPE => 'store' ); + $entryPoint = new \Magento\App\EntryPoint\EntryPoint(BP, $params); $entryPoint->run('Magento\Log\App\Shell', array('entryFileName' => basename(__FILE__))); diff --git a/dev/shell/newindexer.php b/dev/shell/newindexer.php index 5aba5c90f7506..d6ecda6972808 100644 --- a/dev/shell/newindexer.php +++ b/dev/shell/newindexer.php @@ -25,9 +25,11 @@ */ require_once __DIR__ . '/../../app/bootstrap.php'; +use Magento\Core\Model\StoreManager; + $params = array( - \Magento\Core\Model\App::PARAM_RUN_CODE => 'admin', - \Magento\Core\Model\App::PARAM_RUN_TYPE => 'store' + StoreManager::PARAM_RUN_CODE => 'admin', + StoreManager::PARAM_RUN_TYPE => 'store' ); $entryPoint = new \Magento\App\EntryPoint\EntryPoint(BP, $params); diff --git a/dev/tests/integration/framework/Magento/TestFramework/App.php b/dev/tests/integration/framework/Magento/TestFramework/App.php deleted file mode 100644 index ad1a721139913..0000000000000 --- a/dev/tests/integration/framework/Magento/TestFramework/App.php +++ /dev/null @@ -1,40 +0,0 @@ -getArea($code); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\State')->setAreaCode($code); - $area->load(); - } -} diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index 55c422a26f9af..237f60f66b1e7 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -231,8 +231,7 @@ public function initialize($overriddenParams = array()) $objectManager->configure( array( 'preferences' => array( - 'Magento\App\State' => 'Magento\TestFramework\App\State', - 'Magento\Core\Model\App' => 'Magento\TestFramework\App' + 'Magento\App\State' => 'Magento\TestFramework\App\State' ) ) ); @@ -253,7 +252,7 @@ public function initialize($overriddenParams = array()) ); $this->loadArea(\Magento\TestFramework\Application::DEFAULT_APP_AREA); - \Magento\Phrase::setRenderer($objectManager->get('Magento\Phrase\Renderer\Placeholder')); + \Magento\Phrase::setRenderer($objectManager->get('Magento\Phrase\RendererInterface')); /** @var \Magento\App\Filesystem\DirectoryList\Verification $verification */ $verification = $objectManager->get('Magento\App\Filesystem\DirectoryList\Verification'); @@ -346,12 +345,8 @@ public function install($adminUserName, $adminPassword, $adminRoleName) /* Initialize an application in non-installed mode */ $this->initialize(); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadAreaPart( - 'install', - \Magento\Core\Model\App\Area::PART_CONFIG - ); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea('install')->load(\Magento\Core\Model\App\Area::PART_CONFIG); /* Run all install and data-install scripts */ /** @var $updater \Magento\Module\Updater */ @@ -518,11 +513,11 @@ public function loadArea($areaCode) $areaCode ) ); - $app = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App'); + $app = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList'); if ($areaCode == \Magento\TestFramework\Application::DEFAULT_APP_AREA) { - $app->loadAreaPart($areaCode, \Magento\Core\Model\App\Area::PART_CONFIG); + $app->getArea($areaCode)->load(\Magento\Core\Model\App\Area::PART_CONFIG); } else { - $app->loadArea($areaCode); + \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea($areaCode); } } } diff --git a/dev/tests/integration/framework/Magento/TestFramework/Db/ConnectionAdapter.php b/dev/tests/integration/framework/Magento/TestFramework/Db/ConnectionAdapter.php index a4b7b4475934a..f5807f9f2ac07 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Db/ConnectionAdapter.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Db/ConnectionAdapter.php @@ -25,7 +25,7 @@ */ namespace Magento\TestFramework\Db; -class ConnectionAdapter extends \Magento\Core\Model\Resource\Type\Db\Pdo\Mysql +class ConnectionAdapter extends \Magento\Model\Resource\Type\Db\Pdo\Mysql { /** * Retrieve DB adapter class name diff --git a/dev/tests/integration/framework/Magento/TestFramework/Entity.php b/dev/tests/integration/framework/Magento/TestFramework/Entity.php index 318dfbe561273..b579163a30e65 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Entity.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Entity.php @@ -26,20 +26,20 @@ */ /** - * Class that implements CRUP tests for \Magento\Core\Model\AbstractModel based objects + * Class that implements CRUP tests for \Magento\Model\AbstractModel based objects */ namespace Magento\TestFramework; class Entity { /** - * @var \Magento\Core\Model\AbstractModel + * @var \Magento\Model\AbstractModel */ protected $_model; protected $_updateData; - public function __construct(\Magento\Core\Model\AbstractModel $model, array $updateData) + public function __construct(\Magento\Model\AbstractModel $model, array $updateData) { $this->_model = $model; $this->_updateData = $updateData; @@ -59,7 +59,7 @@ public function testCrud() } /** - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _getEmptyModel() { diff --git a/dev/tests/integration/framework/Magento/TestFramework/Helper/Bootstrap.php b/dev/tests/integration/framework/Magento/TestFramework/Helper/Bootstrap.php index 140f0dd2c097a..024c4cf05cbf8 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Helper/Bootstrap.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Helper/Bootstrap.php @@ -177,4 +177,14 @@ public function getBootstrap() { return $this->_bootstrap; } + + /** + * Load area + * @param string $areaCode + */ + public function loadArea($areaCode) + { + self::$_objectManager->get('Magento\App\State')->setAreaCode($areaCode); + self::$_objectManager->get('Magento\App\AreaList')->getArea($areaCode)->load(); + } } diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php index 06c4db3428b1c..0690631c2a165 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php @@ -116,7 +116,7 @@ public function dispatch($uri) /** * Request getter * - * @return \Magento\App\RequestInterface + * @return \Magento\TestFramework\Request */ public function getRequest() { @@ -129,7 +129,7 @@ public function getRequest() /** * Response getter * - * @return \Magento\App\ResponseInterface + * @return \Magento\TestFramework\Response */ public function getResponse() { diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EntityTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EntityTest.php index 3f6efda1e69b4..32a6b2d77e388 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EntityTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EntityTest.php @@ -29,7 +29,7 @@ class EntityTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject */ protected $_model; @@ -79,7 +79,7 @@ public function testTestCrud($saveCallback, $expectedException = null) $this->setExpectedException($expectedException); $this->_model = $this->getMock( - 'Magento\Core\Model\AbstractModel', + 'Magento\Model\AbstractModel', array('load', 'save', 'delete', 'getIdFieldName', '__wakeup'), array(), '', diff --git a/dev/tests/integration/phpunit.xml.dist b/dev/tests/integration/phpunit.xml.dist index 3fa1f5dd9865a..2477b7ef3c420 100644 --- a/dev/tests/integration/phpunit.xml.dist +++ b/dev/tests/integration/phpunit.xml.dist @@ -41,14 +41,12 @@ - - + ../../../app/code/Magento + ../../../lib/Magento - - ../../../app/code/Magento/*/sql - - ../../../app/code/Magento/*/data + ../../../app/code/Magento/*/sql + ../../../app/code/Magento/*/data @@ -57,7 +55,7 @@ . - + diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Config/FormTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Config/FormTest.php index d770ead3f318e..80d5dd29b2378 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Config/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Config/FormTest.php @@ -25,6 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ namespace Magento\Backend\Block\System\Config; +use Magento\App\Cache\State; /** * @magentoAppArea adminhtml @@ -251,20 +252,15 @@ public static function initFieldsUseConfigPathDataProvider() */ protected function _setupFieldsInheritCheckbox($useConfigField, $isConfigDataEmpty, $configDataValue) { - \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize( - array(\Magento\Core\Model\App::PARAM_BAN_CACHE => true) - ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Config\ScopeInterface' - )->setCurrentScope( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array( + State::PARAM_BAN_CACHE => true, + )); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Config\ScopeInterface') + ->setCurrentScope(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); $fileResolverMock = $this->getMockBuilder( 'Magento\Core\Model\Config\FileResolver' diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php index 23331fa9de287..d4126a6b6cb37 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ namespace Magento\Backend\Block\Widget\Grid; - +use Magento\Core\Model\StoreManager; /** * @magentoDataFixture Magento/Backend/Block/_files/backend_theme.php * @@ -67,15 +67,13 @@ protected function setUp() */ protected function _setFixtureTheme() { - \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize( - array( - \Magento\Core\Model\App::PARAM_RUN_CODE => 'admin', - \Magento\Core\Model\App::PARAM_RUN_TYPE => 'store', - \Magento\App\Filesystem::PARAM_APP_DIRS => array( - \Magento\App\Filesystem::THEMES_DIR => array('path' => __DIR__ . '/../../_files/design') - ) - ) - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array( + StoreManager::PARAM_RUN_CODE => 'admin', + StoreManager::PARAM_RUN_TYPE => 'store', + \Magento\App\Filesystem::PARAM_APP_DIRS => array( + \Magento\App\Filesystem::THEMES_DIR => array('path' => __DIR__ . '/../../_files/design') + ), + )); } /** diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/backend_theme.php b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/backend_theme.php index 2c76ae39c8338..f0e47ab05bacb 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/backend_theme.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/backend_theme.php @@ -22,13 +22,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** @var $registration \Magento\Core\Model\Theme\Registration */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); +$registration = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Core\Model\Theme\Registration'); +$registration->register( + __DIR__ . '/design', + '*/*/theme.xml' ); -$registration = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Theme\Registration' -); -$registration->register(__DIR__ . '/design', '*/*/theme.xml'); 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 21912f882d13f..369e00ff6c94d 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php @@ -128,9 +128,7 @@ public function testNotLoggedLoginActionWithRedirect() $this->dispatch('backend/admin/index/index'); - $response = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->getResponse(); + $response = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\ResponseInterface'); $code = $response->getHttpResponseCode(); $this->assertTrue($code >= 300 && $code < 400, 'Incorrect response code'); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/AuthTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/AuthTest.php index 50a44f70e0757..7a445822d2f6f 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/AuthTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/AuthTest.php @@ -42,14 +42,10 @@ protected function setUp() { parent::setUp(); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Backend\Model\Auth' - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Backend\Model\Auth'); } /** diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php index cde89d2f052d6..f130e87a05c02 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php @@ -117,7 +117,7 @@ public function validationDataProvider() * @param string $path * @param string $value * @magentoDbIsolation enabled - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @dataProvider validationExceptionDataProvider */ public function testValidationException($path, $value) diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/Image/AdapterTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/Image/AdapterTest.php index 1e5eb35f7b1ea..d395b6ef718a5 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/Image/AdapterTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/Image/AdapterTest.php @@ -42,7 +42,7 @@ protected function setUp() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * expectedExceptionMessage The specified image adapter cannot be used because of some missed dependencies. * @magentoDbIsolation enabled * @magentoAppIsolation enabled diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php index 82129c29d2dd7..eb49b87ed3361 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php @@ -41,19 +41,12 @@ class MenuTest extends \PHPUnit_Framework_TestCase protected function setUp() { parent::setUp(); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Backend\Model\Auth' - ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Config\ScopeInterface' - )->setCurrentScope( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Backend\Model\Auth'); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Config\ScopeInterface') + ->setCurrentScope(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); } public function testMenuItemManipulation() diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/ObserverTest.php index 7cb0ce99e77e3..27961d87326db 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/ObserverTest.php @@ -71,9 +71,7 @@ public function testActionPreDispatchAdminLoggedRedirect() $observer = $this->_buildObserver(); $this->_model->actionPreDispatchAdmin($observer); - $response = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->getResponse(); + $response = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\ResponseInterface'); $code = $response->getHttpResponseCode(); $this->assertTrue($code >= 300 && $code < 400); @@ -94,9 +92,7 @@ public function testActionPreDispatchAdminLoggedNoRedirect() $observer = $this->_buildObserver(); $this->_model->actionPreDispatchAdmin($observer); - $response = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->getResponse(); + $response = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\ResponseInterface'); $code = $response->getHttpResponseCode(); $this->assertFalse($code >= 300 && $code < 400); diff --git a/dev/tests/integration/testsuite/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/GridTest.php b/dev/tests/integration/testsuite/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/GridTest.php index fd73a81248b73..df1eff680af34 100644 --- a/dev/tests/integration/testsuite/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/GridTest.php +++ b/dev/tests/integration/testsuite/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/GridTest.php @@ -33,11 +33,8 @@ class GridTest extends \PHPUnit_Framework_TestCase */ public function testToHtmlHasOnClick() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); /** @var $layout \Magento\View\LayoutInterface */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Core\Model\Layout', diff --git a/dev/tests/integration/testsuite/Magento/Captcha/_files/dummy_user.php b/dev/tests/integration/testsuite/Magento/Captcha/_files/dummy_user.php index 59123f02fc8b3..abd97027ec6d8 100644 --- a/dev/tests/integration/testsuite/Magento/Captcha/_files/dummy_user.php +++ b/dev/tests/integration/testsuite/Magento/Captcha/_files/dummy_user.php @@ -28,11 +28,8 @@ /** * Create dummy user */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE -); +\Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); /** @var $user \Magento\User\Model\User */ $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\User'); $user->setFirstname( diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php index b5a8ff217c8f3..329b1529bb16d 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php @@ -40,7 +40,7 @@ class NewTest extends \PHPUnit_Framework_TestCase protected function setUp() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App') + \Magento\TestFramework\Helper\Bootstrap::getInstance() ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\Http\Context') ->setValue( diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/CrosssellTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/CrosssellTest.php index 4705f5fa8f8b4..663b8090b624c 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/CrosssellTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/CrosssellTest.php @@ -35,14 +35,10 @@ class CrosssellTest extends \PHPUnit_Framework_TestCase { public function testAll() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\Product' - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); $product->load(2); /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php index 8a4de53a87a6e..03634ace170ba 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php @@ -35,14 +35,10 @@ class RelatedTest extends \PHPUnit_Framework_TestCase { public function testAll() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\Product' - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); $product->load(2); /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/SendTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/SendTest.php new file mode 100644 index 0000000000000..96d9d0ac5f332 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/SendTest.php @@ -0,0 +1,72 @@ +get('Magento\App\State')->setAreaCode('frontend'); + + $this->customerSession = $objectManager->get('Magento\Customer\Model\Session'); + $this->block = $objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Catalog\Block\Product\Send', + '', + ['customerSession' => $this->customerSession] + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetUserName() + { + $this->customerSession->setCustomerId(1); + $this->assertEquals('Firstname Lastname', $this->block->getUserName()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetEmail() + { + $this->customerSession->setCustomerId(1); + $this->assertEquals('customer@example.com', $this->block->getEmail()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php index 8152599f13be9..489ef47e82ff4 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php @@ -73,21 +73,21 @@ public function testSaveActionApplyToData() } /** - * @magentoDataFixture Magento/Core/_files/db_translate_admin_store.php + * @magentoDataFixture Magento/Translation/_files/db_translate_admin_store.php * @magentoDataFixture Magento/Backend/controllers/_files/cache/all_types_enabled.php * @magentoDataFixture Magento/Catalog/controllers/_files/attribute_user_defined.php * @magentoAppIsolation enabled */ public function testSaveActionCleanAttributeLabelCache() { - /** @var \Magento\Core\Model\Resource\Translate\String $string */ - $string = $this->_objectManager->create('Magento\Core\Model\Resource\Translate\String'); - $this->assertEquals($this->_translate('string to translate'), 'predefined string translation'); + /** @var \Magento\Translation\Model\Resource\String $string */ + $string = $this->_objectManager->create('Magento\Translation\Model\Resource\String'); + $this->assertEquals('predefined string translation', $this->_translate('string to translate')); $string->saveTranslate('string to translate', 'new string translation'); $postData = $this->_getAttributeData() + array('attribute_id' => 1); $this->getRequest()->setPost($postData); $this->dispatch('backend/catalog/product_attribute/save'); - $this->assertEquals($this->_translate('string to translate'), 'new string translation'); + $this->assertEquals('new string translation', $this->_translate('string to translate')); } /** @@ -105,9 +105,9 @@ protected function _translate($string) 1 ); /** @var \Magento\TranslateInterface $translate */ - $translate = $this->_objectManager->create('Magento\TranslateInterface'); - $translate->init(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, null, true); - return $translate->translate(array($string)); + $translate = $this->_objectManager->get('Magento\TranslateInterface'); + $translate->loadData(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, true); + return __($string); } /** diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/ReviewTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/ReviewTest.php index 15c73dc4638f4..a84d6b38e6859 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/ReviewTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/ReviewTest.php @@ -42,7 +42,7 @@ public function testEditActionProductNameXss() 1, 'entity_pk_value' )->getId(); - $this->dispatch('backend/catalog/product_review/edit/id/' . $reviewId); + $this->dispatch('backend/review/product/edit/id/' . $reviewId); $responseBody = $this->getResponse()->getBody(); $this->assertContains('<script>alert("xss");</script>', $responseBody); $this->assertNotContains('', $responseBody); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php index 55c9d3f96606b..d709a83cc9638 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php @@ -83,6 +83,23 @@ public function testRemoveAction() $this->_assertCompareListEquals(array(1)); } + public function testRemoveActionWithSession() + { + $this->_requireCustomerWithTwoProducts(); + + $this->dispatch('catalog/product_compare/remove/product/1'); + + /** @var $messageManager \Magento\Message\Manager */ + $messageManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Message\Manager'); + $this->assertInstanceOf('Magento\Message\Success', $messageManager->getMessages()->getLastAddedMessage()); + $this->assertContains('Simple Product 1 Name', + (string)$messageManager->getMessages()->getLastAddedMessage()->getText()); + + $this->assertRedirect(); + + $this->_assertCompareListEquals(array(2)); + } + public function testIndexActionDisplay() { $this->_requireVisitorWithTwoProducts(); @@ -211,6 +228,64 @@ protected function _requireVisitorWithTwoProducts() $this->_assertCompareListEquals(array(1, 2)); } + protected function _requireCustomerWithTwoProducts() + { + $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Customer'); + /** @var \Magento\Customer\Model\Customer $customer */ + $customer + ->setWebsiteId(1) + ->setId(1) + ->setEntityTypeId(1) + ->setAttributeSetId(1) + ->setEmail('customer@example.com') + ->setPassword('password') + ->setGroupId(1) + ->setStoreId(1) + ->setIsActive(1) + ->setFirstname('Firstname') + ->setLastname('Lastname') + ->setDefaultBilling(1) + ->setDefaultShipping(1) + ; + $customer->isObjectNew(true); + $customer->save(); + + /** @var $session \Magento\Customer\Model\Session */ + $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Customer\Model\Session'); + $session->setCustomerId(1); + + /** @var $visitor \Magento\Log\Model\Visitor */ + $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Log\Model\Visitor'); + /** @var \Magento\Stdlib\DateTime $dateTime */ + $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Stdlib\DateTime'); + $visitor->setSessionId(md5(time()) . md5(microtime())) + ->setLastVisitAt($dateTime->now()) + ->save(); + + /** @var $item \Magento\Catalog\Model\Product\Compare\Item */ + $item = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product\Compare\Item'); + $item->setVisitorId($visitor->getId()) + ->setCustomerId(1) + ->setProductId(1) + ->save(); + + /** @var $item \Magento\Catalog\Model\Product\Compare\Item */ + $item = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product\Compare\Item'); + $item->setVisitorId($visitor->getId()) + ->setProductId(2) + ->save(); + + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Log\Model\Visitor') + ->load($visitor->getId()); + + $this->_assertCompareListEquals(array(1, 2)); + } + /** * Assert that current visitor has exactly expected products in compare list * diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/CompositeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/CompositeTest.php new file mode 100644 index 0000000000000..bf50deadd19bb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/CompositeTest.php @@ -0,0 +1,93 @@ +helper = Bootstrap::getObjectManager()->get('Magento\Catalog\Helper\Product\Composite'); + $this->registry = Bootstrap::getObjectManager()->get('Magento\Registry'); + } + + protected function tearDown() + { + $this->registry->unregister('composite_configure_result_error_message'); + $this->registry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->registry->unregister(RegistryConstants::CURRENT_CUSTOMER); + $this->registry->unregister('current_product'); + $this->registry->unregister('product'); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testRenderConfigureResult() + { + $configureResult = new \Magento\Object(); + $configureResult->setOk(true) + ->setProductId(1) + ->setCurrentCustomerId(1); + + $this->helper->renderConfigureResult($configureResult); + + $customerId = $this->registry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->assertEquals(1, $customerId); + $errorMessage = $this->registry->registry('composite_configure_result_error_message'); + $this->assertNull($errorMessage); + } + + public function testRenderConfigureResultNotOK() + { + $configureResult = new \Magento\Object(); + $configureResult->setError(true) + ->setMessage('Test Message'); + + $this->helper->renderConfigureResult($configureResult); + + $customerId = $this->registry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->assertNull($customerId); + $errorMessage = $this->registry->registry('composite_configure_result_error_message'); + $this->assertEquals('Test Message', $errorMessage); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/PriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/PriceTest.php new file mode 100644 index 0000000000000..944b4be679523 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/PriceTest.php @@ -0,0 +1,65 @@ +_helper = Bootstrap::getObjectManager()->get('Magento\Catalog\Helper\Product\Price'); + $this->_customerAccountService = Bootstrap::getObjectManager()->get( + 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' + ); + + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testSetCustomer() + { + $customerData = $this->_customerAccountService->getCustomer(1); + $this->assertInstanceOf('Magento\Catalog\Helper\Product\Price', $this->_helper->setCustomer($customerData)); + $customerDataRetrieved = $this->_helper->getCustomer(); + $this->assertEquals($customerData->__toArray(), $customerDataRetrieved->__toArray()); + } + +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/ViewTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/ViewTest.php index d03c3ce0bab88..8c228f0b96ece 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/ViewTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/ViewTest.php @@ -132,7 +132,7 @@ public function testPrepareAndRender() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @magentoAppIsolation enabled */ public function testPrepareAndRenderWrongController() @@ -144,7 +144,7 @@ public function testPrepareAndRenderWrongController() /** * @magentoAppIsolation enabled - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testPrepareAndRenderWrongProduct() { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTreeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTreeTest.php index da1ae41fdd67d..504b447c66761 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTreeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTreeTest.php @@ -97,7 +97,7 @@ public function testMove() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testMoveWrongParent() { @@ -106,7 +106,7 @@ public function testMoveWrongParent() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testMoveWrongId() { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php index 37b48822102b7..d44ac5689cb1b 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php @@ -72,12 +72,11 @@ protected function setUp() */ public function testProductUpdate() { - $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\CategoryFactory' - ); - $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Block\Product\ListProduct' - ); + $this->markTestSkipped('Incomplete due to MAGETWO-21369'); + $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\CategoryFactory'); + $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Block\Product\ListProduct'); $this->_processor->getIndexer()->setScheduled(false); $this->assertFalse( diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php index 6ca3b3b07dd7f..a08681eed03b4 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php @@ -150,7 +150,7 @@ public function testGetSetCurrentCategory() ->create('Magento\Catalog\Model\Layer\Category'); $model->setCurrentCategory(new \Magento\Object()); $this->fail('Assign category of invalid class.'); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { } try { @@ -159,7 +159,7 @@ public function testGetSetCurrentCategory() $model->setCurrentCategory(\Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Catalog\Model\Category')); $this->fail('Assign category with invalid id.'); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/ItemTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/ItemTest.php index a055f201ea33b..4d7e45a7d4beb 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/ItemTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/ItemTest.php @@ -59,7 +59,7 @@ public function testGetFilter() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testGetFilterException() { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php index 039725871b9ef..274000f36d166 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php @@ -66,7 +66,7 @@ public function testValidate() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testValidateDuplicate() { @@ -82,7 +82,7 @@ public function testValidateDuplicate() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testValidateDuplicateWebsite() { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php new file mode 100644 index 0000000000000..b2190e5060251 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php @@ -0,0 +1,88 @@ +_session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Customer\Model\Session'); + $this->_visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Log\Model\Visitor'); + /** @var \Magento\Stdlib\DateTime $dateTime */ + $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Stdlib\DateTime'); + $this->_visitor->setSessionId(md5(time()) . md5(microtime())) + ->setLastVisitAt($dateTime->now()) + ->save(); + $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product\Compare\ListCompare', ['logVisitor' => $this->_visitor]); + } + + protected function tearDown() + { + $this->_session->setCustomerId(null); + } + + public function testAddProductWithSession() + { + $this->_session->setCustomerId(1); + /** @var $product \Magento\Catalog\Model\Product */ + $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product') + ->load(1); + $this->_model->addProduct($product); + $this->assertTrue($this->_model->hasItems(1, $this->_visitor->getId())); + } + + public function testAddProductWithoutSession() + { + /** @var $product \Magento\Catalog\Model\Product */ + $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product') + ->load(1); + $this->_model->addProduct($product); + $this->assertFalse($this->_model->hasItems(1, $this->_visitor->getId())); + $this->assertTrue($this->_model->hasItems(0, $this->_visitor->getId())); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php index 717c91cb6f1bb..abc83afbef278 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php @@ -247,7 +247,7 @@ public function testCheckProductBuyState() /** * @magentoDataFixture Magento/Catalog/_files/product_simple.php - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testCheckProductBuyStateException() { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php index 29fdd966c8052..fb2e8b2c25ac8 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php @@ -110,21 +110,13 @@ public function testCRUD() public function testCleanCache() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->saveCache( - 'test', - 'catalog_product_999', - array('catalog_product_999') - ); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\CacheInterface') + ->save('test', 'catalog_product_999', array('catalog_product_999')); // potential bug: it cleans by cache tags, generated from its ID, which doesn't make much sense $this->_model->setId(999)->cleanCache(); $this->assertFalse( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadCache( - 'catalog_product_999' - ) + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\CacheInterface') + ->load('catalog_product_999') ); } @@ -216,7 +208,7 @@ public function testDuplicateSkuGeneration() /** * Delete model * - * @param \Magento\Core\Model\AbstractModel $duplicate + * @param \Magento\Model\AbstractModel $duplicate */ protected function _undo($duplicate) { @@ -399,7 +391,7 @@ public function testReset() /** * Check is model empty or not * - * @param \Magento\Core\Model\AbstractModel $model + * @param \Magento\Model\AbstractModel $model */ protected function _assertEmpty($model) { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/CollectionTest.php index 3910fc992d1d1..8b6ef68f00887 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/CollectionTest.php @@ -26,6 +26,8 @@ */ namespace Magento\Catalog\Model\Resource\Product; +use Magento\Customer\Service\V1\CustomerGroupServiceInterface; + class CollectionTest extends \PHPUnit_Framework_TestCase { /** @@ -90,4 +92,21 @@ public function testAddUrlRewrite() ); $this->assertEquals($expectedResult, $this->_collection->getColumnValues('request_path')); } + + /** + * @magentoDataFixture Magento/Catalog/Model/Resource/_files/product_simple.php + */ + public function testAddTierPriceData() + { + $this->_collection->setFlag('tier_price_added', false); + $this->_collection->addIdFilter(2); + $this->assertInstanceOf( + '\Magento\Catalog\Model\Resource\Product\Collection', + $this->_collection->addTierPriceData() + ); + $tierPrice = $this->_collection->getFirstItem()->getDataByKey('tier_price'); + $this->assertEquals(CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, current($tierPrice)['cust_group']); + $this->assertEquals(CustomerGroupServiceInterface::CUST_GROUP_ALL, next($tierPrice)['cust_group']); + $this->assertTrue($this->_collection->getFlag('tier_price_added')); + } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/_files/product_simple.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/_files/product_simple.php new file mode 100644 index 0000000000000..1426f5ec5348c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/_files/product_simple.php @@ -0,0 +1,67 @@ +create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(2) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Simple Products') + ->setSku('simple products') + ->setPrice(10) + ->setWeight(1) + ->setShortDescription("Short description") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 21, + 'price' => 81, + ) + ) + ) + ->setDescription('Description with html tag') + ->setMetaTitle('meta title') + ->setMetaKeyword('meta keyword') + ->setMetaDescription('meta description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setUrlKey('url-key') + ->setUrlPath('url-key.html') + ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php index 18e43419627cf..acc9d791f59d9 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php @@ -186,7 +186,7 @@ public function testGetProductRequestPath() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testGeneratePathDefault() { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple.php index 04fa15a5d3b70..d9cd3b8ea96ab 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple.php @@ -18,147 +18,138 @@ * 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) */ /** @var $product \Magento\Catalog\Model\Product */ -$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); $product->isObjectNew(true); -$product->setTypeId( - \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE -)->setId( - 1 -)->setAttributeSetId( - 4 -)->setWebsiteIds( - array(1) -)->setName( - 'Simple Product' -)->setSku( - 'simple' -)->setPrice( - 10 -)->setWeight( - 1 -)->setShortDescription( - "Short description" -)->setTaxClassId( - 0 -)->setTierPrice( - array( +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(1) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Simple Product') + ->setSku('simple') + ->setPrice(10) + ->setWeight(1) + ->setShortDescription("Short description") + ->setTaxClassId(0) + ->setTierPrice( array( - 'website_id' => 0, - 'cust_group' => \Magento\Customer\Model\Group::CUST_GROUP_ALL, - 'price_qty' => 2, - 'price' => 8 - ), - array( - 'website_id' => 0, - 'cust_group' => \Magento\Customer\Model\Group::CUST_GROUP_ALL, - 'price_qty' => 5, - 'price' => 5 + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), ) ) -)->setDescription( - 'Description with html tag' -)->setMetaTitle( - 'meta title' -)->setMetaKeyword( - 'meta keyword' -)->setMetaDescription( - 'meta description' -)->setVisibility( - \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH -)->setStatus( - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED -)->setCategoryIds( - array(2) -)->setStockData( - array('use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1) -)->setCanSaveCustomOptions( - true -)->setProductOptions( - array( - array( - 'id' => 1, - 'option_id' => 0, - 'previous_group' => 'text', - 'title' => 'Test Field', - 'type' => 'field', - 'is_require' => 1, - 'sort_order' => 0, - 'price' => 1, - 'price_type' => 'fixed', - 'sku' => '1-text', - 'max_characters' => 100 - ), + ->setDescription('Description with html tag') + + ->setMetaTitle('meta title') + ->setMetaKeyword('meta keyword') + ->setMetaDescription('meta description') + + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + + ->setCategoryIds(array(2)) + + ->setStockData( array( - 'id' => 2, - 'option_id' => 0, - 'previous_group' => 'date', - 'title' => 'Test Date and Time', - 'type' => 'date_time', - 'is_require' => 1, - 'sort_order' => 0, - 'price' => 2, - 'price_type' => 'fixed', - 'sku' => '2-date' - ), + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->setCanSaveCustomOptions(true) + ->setProductOptions( array( - 'id' => 3, - 'option_id' => 0, - 'previous_group' => 'select', - 'title' => 'Test Select', - 'type' => 'drop_down', - 'is_require' => 1, - 'sort_order' => 0, - 'values' => array( - array( - 'option_type_id' => -1, - 'title' => 'Option 1', - 'price' => 3, - 'price_type' => 'fixed', - 'sku' => '3-1-select' - ), - array( - 'option_type_id' => -1, - 'title' => 'Option 2', - 'price' => 3, - 'price_type' => 'fixed', - 'sku' => '3-2-select' + array( + 'id' => 1, + 'option_id' => 0, + 'previous_group' => 'text', + 'title' => 'Test Field', + 'type' => 'field', + 'is_require'=> 1, + 'sort_order'=> 0, + 'price' => 1, + 'price_type'=> 'fixed', + 'sku' => '1-text', + 'max_characters' => 100 + ), + array( + 'id' => 2, + 'option_id' => 0, + 'previous_group' => 'date', + 'title' => 'Test Date and Time', + 'type' => 'date_time', + 'is_require'=> 1, + 'sort_order'=> 0, + 'price' => 2, + 'price_type'=> 'fixed', + 'sku' => '2-date', + ), + array( + 'id' => 3, + 'option_id' => 0, + 'previous_group' => 'select', + 'title' => 'Test Select', + 'type' => 'drop_down', + 'is_require'=> 1, + 'sort_order'=> 0, + 'values' => array( + array( + 'option_type_id'=> -1, + 'title' => 'Option 1', + 'price' => 3, + 'price_type' => 'fixed', + 'sku' => '3-1-select', + ), + array( + 'option_type_id'=> -1, + 'title' => 'Option 2', + 'price' => 3, + 'price_type' => 'fixed', + 'sku' => '3-2-select', + ), ) - ) - ), - array( - 'id' => 4, - 'option_id' => 0, - 'previous_group' => 'select', - 'title' => 'Test Radio', - 'type' => 'radio', - 'is_require' => 1, - 'sort_order' => 0, - 'values' => array( - array( - 'option_type_id' => -1, - 'title' => 'Option 1', - 'price' => 3, - 'price_type' => 'fixed', - 'sku' => '4-1-radio' - ), - array( - 'option_type_id' => -1, - 'title' => 'Option 2', - 'price' => 3, - 'price_type' => 'fixed', - 'sku' => '4-2-radio' + ), + array( + 'id' => 4, + 'option_id' => 0, + 'previous_group' => 'select', + 'title' => 'Test Radio', + 'type' => 'radio', + 'is_require'=> 1, + 'sort_order'=> 0, + 'values' => array( + array( + 'option_type_id'=> -1, + 'title' => 'Option 1', + 'price' => 3, + 'price_type' => 'fixed', + 'sku' => '4-1-radio', + ), + array( + 'option_type_id'=> -1, + 'title' => 'Option 2', + 'price' => 3, + 'price_type' => 'fixed', + 'sku' => '4-2-radio', + ), ) - ) + ), ) ) -)->setHasOptions( - true -)->save(); + ->setHasOptions(true) + ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php index 04208ae05fa04..76ea3b2ce3200 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php @@ -38,16 +38,10 @@ class RendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); - $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\View\LayoutInterface' - )->createBlock( - 'Magento\Checkout\Block\Cart\Item\Renderer' - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface') + ->createBlock('Magento\Checkout\Block\Cart\Item\Renderer'); /** @var $item \Magento\Sales\Model\Quote\Item */ $item = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Quote\Item'); $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php index a617c39b47d3e..ab31955c328eb 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php @@ -81,7 +81,7 @@ class ManagerStub extends Manager * * @param string $eventName * @param array $params - * @return \Magento\Core\Model\App|null + * @return null */ public function dispatch($eventName, array $params = array()) { 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 139798f0e2c1d..a07d77ea11de3 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 @@ -60,13 +60,11 @@ public static function tearDownAfterClass() */ public function testGetFilesCollection() { + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); - $objectManager->get('Magento\View\DesignInterface')->setDesignTheme('magento_backend'); + $objectManager->get('Magento\View\DesignInterface') + ->setDesignTheme('magento_backend'); /** @var $model \Magento\Cms\Model\Wysiwyg\Images\Storage */ $model = $objectManager->create('Magento\Cms\Model\Wysiwyg\Images\Storage'); $collection = $model->getFilesCollection(self::$_baseDir, 'media'); diff --git a/dev/tests/integration/testsuite/Magento/Core/Helper/JsTest.php b/dev/tests/integration/testsuite/Magento/Core/Helper/JsTest.php index 329605f9c4a91..9e322f8d53ea3 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Helper/JsTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Helper/JsTest.php @@ -40,17 +40,12 @@ protected function setUp() $this->_helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Helper\Js'); } - public function testGetTranslateJson() - { - $this->assertNotNull(json_decode($this->_helper->getTranslateJson())); - } - public function testGetTranslatorScript() { $this->assertEquals( "", $this->_helper->getTranslatorScript() diff --git a/dev/tests/integration/testsuite/Magento/Core/Helper/Url/RewriteTest.php b/dev/tests/integration/testsuite/Magento/Core/Helper/Url/RewriteTest.php index e73f666000b15..8dc1a33797574 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Helper/Url/RewriteTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Helper/Url/RewriteTest.php @@ -50,7 +50,7 @@ public function testValidateRequestPath($requestPath) /** * @dataProvider requestPathExceptionDataProvider - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testValidateRequestPathException($requestPath) { @@ -67,7 +67,7 @@ public function testValidateSuffix($suffix) /** * @dataProvider requestPathExceptionDataProvider - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testValidateSuffixException($suffix) { diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/App/AreaTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/App/AreaTest.php index 671539966ca78..a61d4d77ea450 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/App/AreaTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/App/AreaTest.php @@ -35,11 +35,8 @@ class AreaTest extends \PHPUnit_Framework_TestCase public static function tearDownAfterClass() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->cleanCache( - array(\Magento\Core\Model\Design::CACHE_TAG) - ); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\CacheInterface')-> + clean(array(\Magento\Core\Model\Design::CACHE_TAG)); } protected function setUp() diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/App/EmulationTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/App/EmulationTest.php index d387d2b552df8..c00cf351fb642 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/App/EmulationTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/App/EmulationTest.php @@ -39,15 +39,12 @@ class EmulationTest extends \PHPUnit_Framework_TestCase */ public function testEnvironmentEmulation() { - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\App\Emulation' - ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); - $design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\DesignInterface'); + $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Core\Model\App\Emulation'); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + $design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\View\DesignInterface'); $initialEnvInfo = $this->_model->startEnvironmentEmulation(1); $initialDesign = $initialEnvInfo->getInitialDesign(); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php deleted file mode 100644 index fb3a67252b51a..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php +++ /dev/null @@ -1,155 +0,0 @@ -_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Core\Model\App'); - $this->_mageModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App'); - } - - public function testGetCookie() - { - $this->assertInstanceOf('Magento\Stdlib\Cookie', $this->_model->getCookie()); - } - - public function testSetErrorHandler() - { - $this->_model->setErrorHandler(array($this, 'errorHandler')); - try { - trigger_error('test', E_USER_NOTICE); - if (!$this->_errorCatchFlag) { - $this->fail('Error handler is not working'); - } - restore_error_handler(); - } catch (\Exception $e) { - restore_error_handler(); - throw $e; - } - } - - public function errorHandler() - { - $this->_errorCatchFlag = true; - } - - public function testGetArea() - { - $area = $this->_model->getArea('frontend'); - $this->assertInstanceOf('Magento\Core\Model\App\Area', $area); - $this->assertSame($area, $this->_model->getArea('frontend')); - } - - public function testGetDistroLocaleCode() - { - $this->assertEquals(\Magento\Core\Model\App::DISTRO_LOCALE_CODE, $this->_model->getDistroLocaleCode()); - } - - public function testGetBaseCurrencyCode() - { - $this->assertEquals('USD', $this->_model->getBaseCurrencyCode()); - } - - public function testGetCacheInstance() - { - $cache = $this->_mageModel->getCacheInstance(); - $this->assertInstanceOf('Magento\App\CacheInterface', $cache); - $this->assertSame($cache, $this->_mageModel->getCacheInstance()); - } - - public function testGetCache() - { - $this->assertInstanceOf('Magento\Cache\FrontendInterface', $this->_mageModel->getCache()); - } - - public function testLoadSaveRemoveCache() - { - $this->assertEmpty($this->_mageModel->loadCache('test_id')); - $this->_mageModel->saveCache('test_data', 'test_id'); - $this->assertEquals('test_data', $this->_mageModel->loadCache('test_id')); - $this->_mageModel->removeCache('test_id'); - $this->assertEmpty($this->_mageModel->loadCache('test_id')); - } - - public function testCleanCache() - { - $this->assertEmpty($this->_mageModel->loadCache('test_id')); - $this->_mageModel->saveCache('test_data', 'test_id', array('test_tag')); - $this->assertEquals('test_data', $this->_mageModel->loadCache('test_id')); - $this->_mageModel->cleanCache(array('test_tag')); - $this->assertEmpty($this->_mageModel->loadCache('test_id')); - } - - 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 testSetGetResponse() - { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\App\ResponseInterface' - )->headersSentThrowsException = false; - $this->assertInstanceOf('Magento\App\ResponseInterface', $this->_model->getResponse()); - $expectedHeader = array('name' => 'Content-Type', 'value' => 'text/html; charset=UTF-8', 'replace' => false); - $this->assertContains($expectedHeader, $this->_model->getResponse()->getHeaders()); - $response = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\App\ResponseInterface' - ); - $this->_model->setResponse($response); - $this->assertSame($response, $this->_model->getResponse()); - $this->assertEmpty($this->_model->getResponse()->getHeaders()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Config/DataTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Config/DataTest.php index f3a0cac935d29..0e1ad4f572dfd 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Config/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Config/DataTest.php @@ -63,11 +63,8 @@ public static function tearDownAfterClass() */ protected static function _refreshConfiguration() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->cleanCache( - array(\Magento\App\Config::CACHE_TAG) - ); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\CacheInterface') + ->clean(array(\Magento\App\Config::CACHE_TAG)); \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(); } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Design/Backend/ExceptionsTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Design/Backend/ExceptionsTest.php index f458f19e5dab3..b00b4757e09b5 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Design/Backend/ExceptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Design/Backend/ExceptionsTest.php @@ -120,7 +120,7 @@ public function saveExceptionDataProvider() /** * @var array $value - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @dataProvider saveWrongExceptionDataProvider * @magentoDbIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php index bea1b0a7d4fd7..b3a1fe9a28b7c 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php @@ -88,7 +88,7 @@ public function testCRUD() $model->setId(null); $model->save(); $this->fail('A validation failure is expected.'); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { // intentionally swallow exception } @@ -132,11 +132,8 @@ public function testLoadChangeCache() $design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Core\Model\Design'); $design->loadChange($storeId, $date); - $cachedDesign = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadCache( - $cacheId - ); + $cachedDesign = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\CacheInterface') + ->load($cacheId); $cachedDesign = unserialize($cachedDesign); $this->assertInternalType('array', $cachedDesign); @@ -148,11 +145,8 @@ public function testLoadChangeCache() $design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Core\Model\Design'); $design->loadChange($storeId, $date); - $cachedDesign = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadCache( - $cacheId - ); + $cachedDesign = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\CacheInterface') + ->load($cacheId); $cachedDesign = unserialize($cachedDesign); $this->assertTrue(is_array($cachedDesign)); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/LayoutTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/LayoutTest.php index a3b1d44d6bec1..e92faeecdb10c 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/LayoutTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/LayoutTest.php @@ -246,7 +246,7 @@ public function createBlockDataProvider() /** * @dataProvider blockNotExistsDataProvider - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testCreateBlockNotExists($name) { @@ -391,7 +391,7 @@ public function testGetChildBlocks() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testAddBlockInvalidType() { diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/ObserverTest.php index 8c8e0f712e74c..d5ccdd5ca9424 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/ObserverTest.php @@ -64,8 +64,8 @@ public function testThemeRegistration() 'Magento\Core\Model\Theme\Registration', array('register'), array( - $this->_objectManager->create('Magento\Core\Model\Resource\Theme\CollectionFactory'), - $this->_objectManager->create('Magento\Core\Model\Theme\Collection'), + $this->_objectManager->create('Magento\Core\Model\Resource\Theme\Data\CollectionFactory'), + $this->_objectManager->create('Magento\Core\Model\Theme\Data\Collection'), $this->_objectManager->create('Magento\App\Filesystem') ) ); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/HelperTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/HelperTest.php index c72b28c2ba885..35a6958e1a353 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/HelperTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/HelperTest.php @@ -29,7 +29,7 @@ class HelperTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Resource\Helper + * @var \Magento\DB\Helper */ protected $_model; @@ -41,7 +41,7 @@ class HelperTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Helper', + 'Magento\DB\Helper', array('modulePrefix' => 'core') ); $collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 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 4fb7e91b4ac70..cad51a5602ba0 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 @@ -112,8 +112,8 @@ public function testToOptionArrayHash() } /** - * @covers \Magento\Core\Model\Resource\Db\Collection\AbstractCollection::addFieldToSelect - * @covers \Magento\Core\Model\Resource\Db\Collection\AbstractCollection::removeFieldFromSelect + * @covers \Magento\Model\Resource\Db\Collection\AbstractCollection::addFieldToSelect + * @covers \Magento\Model\Resource\Db\Collection\AbstractCollection::removeFieldFromSelect */ public function testAddRemoveFieldToSelect() { @@ -132,7 +132,7 @@ public function testAddRemoveFieldToSelect() } /** - * @covers \Magento\Core\Model\Resource\Db\Collection\AbstractCollection::addExpressionFieldToSelect + * @covers \Magento\Model\Resource\Db\Collection\AbstractCollection::addExpressionFieldToSelect */ public function testAddExpressionFieldToSelect() { @@ -142,7 +142,7 @@ public function testAddExpressionFieldToSelect() } /** - * @covers \Magento\Core\Model\Resource\Db\Collection\AbstractCollection::getAllIds + * @covers \Magento\Model\Resource\Db\Collection\AbstractCollection::getAllIds */ public function testGetAllIds() { @@ -150,7 +150,7 @@ public function testGetAllIds() } /** - * @covers \Magento\Core\Model\Resource\Db\Collection\AbstractCollection::getData + * @covers \Magento\Model\Resource\Db\Collection\AbstractCollection::getData */ public function testGetData() { @@ -158,7 +158,7 @@ public function testGetData() } /** - * @covers \Magento\Core\Model\Resource\Db\Collection\AbstractCollection::join + * @covers \Magento\Model\Resource\Db\Collection\AbstractCollection::join */ public function testJoin() { diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/TransactionTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/TransactionTest.php index 2dac3dd7440cd..5d8ba652c0efd 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/TransactionTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/TransactionTest.php @@ -29,15 +29,14 @@ class TransactionTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Resource\Transaction + * @var \Magento\DB\Transaction */ protected $_model; protected function setUp() { - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Transaction' - ); + $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\DB\Transaction'); } /** diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php index 1534e6e91a27b..66c121d3f4f41 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php @@ -64,7 +64,8 @@ protected function _getStoreModel() 'storeManager' => $objectManager->get('Magento\Core\Model\StoreManager'), 'sidResolver' => $objectManager->get('Magento\Session\SidResolverInterface'), 'cookie' => $objectManager->get('Magento\Stdlib\Cookie'), - 'httpContext' => $objectManager->get('Magento\App\Http\Context') + 'httpContext' => $objectManager->get('Magento\App\Http\Context'), + 'config' => $objectManager->get('Magento\App\ConfigInterface') ); return $this->getMock('Magento\Core\Model\Store', array('getUrl'), $this->_modelParams); @@ -322,7 +323,7 @@ public function testCRUD() * @dataProvider saveValidationDataProvider * @magentoAppIsolation enabled * @magentoDbIsolation enabled - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testSaveValidation($badStoreData) { diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Theme/RegistrationTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Theme/RegistrationTest.php index 051cc76719b62..9e38fe746a427 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Theme/RegistrationTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Theme/RegistrationTest.php @@ -50,13 +50,17 @@ protected function setUp() ) ) ); - $this->_theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\View\Design\ThemeInterface' - ); - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Theme\Registration', - array('theme' => $this->_theme) - ); + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); + + $objectManager->get('Magento\App\State') + ->setAreaCode(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + $this->_theme = $objectManager + ->create('Magento\View\Design\ThemeInterface'); + $this->_model = $objectManager + ->create('Magento\Core\Model\Theme\Registration'); } /** @@ -128,4 +132,15 @@ public function testPhysicalThemeElimination() $testTheme->load($testTheme->getId()); $this->assertNotEquals((int)$testTheme->getType(), \Magento\View\Design\ThemeInterface::TYPE_PHYSICAL); } + + /** + * @magentoDbIsolation enabled + */ + public function testRegister() + { + $this->registerThemes(); + $themePath = implode(\Magento\View\Design\ThemeInterface::PATH_SEPARATOR, array('frontend', 'test_test_theme')); + $theme = $this->_model->getThemeFromDb($themePath); + $this->assertEquals($themePath, $theme->getFullPath()); + } } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php index e300336972247..d9ca1292b9ad7 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php @@ -89,15 +89,13 @@ protected function setUp() */ protected function _emulateFixtureTheme($themePath = 'test_default') { - \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize( - array( - \Magento\App\Filesystem::PARAM_APP_DIRS => array( - \Magento\App\Filesystem::THEMES_DIR => array('path' => realpath(__DIR__ . '/../_files/design')) - ) - ) - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array( + \Magento\App\Filesystem::PARAM_APP_DIRS => array( + \Magento\App\Filesystem::THEMES_DIR => array('path' => realpath(__DIR__ . '/../_files/design')), + ), + )); + \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend'); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Core\Model\App')->loadArea('frontend'); $objectManager->get('Magento\View\DesignInterface')->setDesignTheme($themePath); $this->_viewFileSystem = $objectManager->create('Magento\View\FileSystem'); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/magento_default_iphone/images/preview_image.jpg b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/magento_default_iphone/images/preview_image.jpg new file mode 100644 index 0000000000000..3c9b11dae2719 Binary files /dev/null and b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/magento_default_iphone/images/preview_image.jpg differ diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/magento_default_iphone/theme.xml b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/magento_default_iphone/theme.xml index 5dd26d0b174ee..d0008b53c35d8 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/magento_default_iphone/theme.xml +++ b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/magento_default_iphone/theme.xml @@ -30,6 +30,6 @@ 2.0.0.0 magento_default - images/preview.png + images/preview_image.jpg 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 4a7f9b246f7f0..0f27598254d34 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 @@ -24,19 +24,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) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG -); -\Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize( - array( - \Magento\App\Filesystem::PARAM_APP_DIRS => array( - \Magento\App\Filesystem::THEMES_DIR => array('path' => realpath(__DIR__)) - ) - ) -); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); +\Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array( + \Magento\App\Filesystem::PARAM_APP_DIRS => array( + \Magento\App\Filesystem::THEMES_DIR => array('path' => realpath(__DIR__)), + ), +)); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure( array('preferences' => array('Magento\Core\Model\Theme' => 'Magento\Core\Model\Theme\Data')) ); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/layout_update.php b/dev/tests/integration/testsuite/Magento/Core/_files/layout_update.php index 78d27c15c797e..14503047369b9 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/layout_update.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/layout_update.php @@ -27,12 +27,9 @@ /** @var $objectManager \Magento\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); -$objectManager->get( - 'Magento\Core\Model\App' -)->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG -); +$objectManager->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); /** @var $theme \Magento\View\Design\ThemeInterface */ $theme = $objectManager->create('Magento\View\Design\ThemeInterface'); $theme->setThemePath( diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/media_for_change.php b/dev/tests/integration/testsuite/Magento/Core/_files/media_for_change.php index 2fedb1e7fb586..1d68e59262456 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/media_for_change.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/media_for_change.php @@ -24,12 +24,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) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG -); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); $designDir = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppInstallDir() . '/media_for_change'; $themeDir = $designDir . '/frontend/test_default'; $sourcePath = dirname(__DIR__) . '/Model/_files/design/frontend/test_publication/'; diff --git a/dev/tests/integration/testsuite/Magento/Cron/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Cron/Model/ObserverTest.php index 6324ac62a81b4..e00fbd91cb3bc 100644 --- a/dev/tests/integration/testsuite/Magento/Cron/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Cron/Model/ObserverTest.php @@ -32,15 +32,11 @@ class ObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadAreaPart( - 'crontab', - \Magento\Core\Model\App\Area::PART_CONFIG - ); - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Cron\Model\Observer' - ); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea('crontab') + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); + $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Cron\Model\Observer'); $this->_model->dispatch('this argument is not used'); } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php index e633f021be866..3e34b3df8e61f 100755 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php @@ -1299,7 +1299,7 @@ public function testIsEmailAvailable() /** * @magentoDataFixture Magento/Customer/_files/customer.php - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Customer website ID must be specified when using the website scope */ public function testIsEmailAvailableNoWebsiteSpecified() diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php b/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php index 2963668e8bd36..085756b56570f 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php @@ -22,11 +22,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE -); +\Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); diff --git a/dev/tests/integration/testsuite/Magento/Data/Argument/Interpreter/StringTest.php b/dev/tests/integration/testsuite/Magento/Data/Argument/Interpreter/StringTest.php index b191d14f1c465..a199ee0364991 100644 --- a/dev/tests/integration/testsuite/Magento/Data/Argument/Interpreter/StringTest.php +++ b/dev/tests/integration/testsuite/Magento/Data/Argument/Interpreter/StringTest.php @@ -26,7 +26,7 @@ class StringTest extends \PHPUnit_Framework_TestCase { /** - * @var Number + * @var \Magento\Data\Argument\Interpreter\String */ protected $_model; @@ -50,7 +50,7 @@ protected function setUp() $translateRenderer->expects($this->any())->method('render')->will( $this->returnCallback( function ($input) { - return $input . ' (translated)'; + return end($input) . ' (translated)'; } ) ); diff --git a/dev/tests/integration/testsuite/Magento/DesignEditor/Model/Translate/InlineVdeTest.php b/dev/tests/integration/testsuite/Magento/DesignEditor/Model/Translate/InlineTest.php similarity index 96% rename from dev/tests/integration/testsuite/Magento/DesignEditor/Model/Translate/InlineVdeTest.php rename to dev/tests/integration/testsuite/Magento/DesignEditor/Model/Translate/InlineTest.php index 0abeb4fd815a9..d22c4e4ea9391 100644 --- a/dev/tests/integration/testsuite/Magento/DesignEditor/Model/Translate/InlineVdeTest.php +++ b/dev/tests/integration/testsuite/Magento/DesignEditor/Model/Translate/InlineTest.php @@ -26,10 +26,10 @@ */ namespace Magento\DesignEditor\Model\Translate; -class InlineVdeTest extends \PHPUnit_Framework_TestCase +class InlineTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\DesignEditor\Model\Translate\InlineVde + * @var \Magento\DesignEditor\Model\Translate\Inline */ protected $_model; @@ -57,7 +57,7 @@ protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_model = $objectManager->get('Magento\DesignEditor\Model\Translate\InlineVde'); + $this->_model = $objectManager->get('Magento\DesignEditor\Model\Translate\Inline'); $this->_request = $objectManager->get('Magento\App\RequestInterface'); $this->_request->setParam('translation_mode', 'text'); @@ -67,7 +67,7 @@ protected function setUp() public function testObjectCreation() { - $this->assertInstanceOf('Magento\DesignEditor\Model\Translate\InlineVde', $this->_model); + $this->assertInstanceOf('Magento\DesignEditor\Model\Translate\Inline', $this->_model); $this->assertInstanceOf('Magento\App\RequestInterface', $this->_request); $this->assertInstanceOf('Magento\DesignEditor\Helper\Data', $this->_helperData); } diff --git a/dev/tests/integration/testsuite/Magento/DesignEditor/Model/_files/design/themes.php b/dev/tests/integration/testsuite/Magento/DesignEditor/Model/_files/design/themes.php index 857074ed4f8a9..f93fc4b0bfe4a 100644 --- a/dev/tests/integration/testsuite/Magento/DesignEditor/Model/_files/design/themes.php +++ b/dev/tests/integration/testsuite/Magento/DesignEditor/Model/_files/design/themes.php @@ -32,13 +32,13 @@ ) ) ); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\App\State') + ->setAreaCode(\Magento\View\DesignInterface::DEFAULT_AREA); -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG -); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); /** @var $registration \Magento\Core\Model\Theme\Registration */ $registration = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/Block/Catalog/Product/LinksTest.php b/dev/tests/integration/testsuite/Magento/Downloadable/Block/Catalog/Product/LinksTest.php new file mode 100644 index 0000000000000..a7c0bad0e1414 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Downloadable/Block/Catalog/Product/LinksTest.php @@ -0,0 +1,176 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->registry = $this->objectManager->get('Magento\Registry'); + $this->taxCalculationModel = $this->objectManager->create('Magento\Tax\Model\Calculation'); + + $this->linksBlock = $this->objectManager->get('Magento\View\LayoutInterface') + ->createBlock('Magento\Downloadable\Block\Catalog\Product\Links'); + } + + public function tearDown() + { + $this->registry->unregister('product'); + $this->registry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->registry->unregister('_fixture/Magento_Tax_Model_Calculation_Rule'); + $this->registry->unregister('_fixture/Magento_Tax_Model_Calculation_Rate'); + } + + /** + * Test that has no customer registered. + * + * @magentoDataFixture Magento/Downloadable/_files/product_with_files.php + */ + public function testGetFormattedLinkPriceNoCustomer() + { + $product = $this->objectManager->create('Magento\Catalog\Model\Product')->load(1); + $this->registry->register('product', $product); + $link = array_values($this->linksBlock->getLinks())[0]; + $formattedLink = $this->linksBlock->getFormattedLinkPrice($link); + $this->assertEquals('+$15.00', $formattedLink); + } + + /** + * Test that uses customer's billing address as tax calculation base. + * + * @magentoConfigFixture current_store tax/display/type 3 + * @magentoConfigFixture current_store tax/calculation/based_on billing + * @magentoDataFixture Magento/Downloadable/_files/product_with_files.php + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_address.php + * @magentoDataFixture Magento/Customer/_files/customer_group.php + * @magentoDataFixture Magento/Tax/_files/tax_classes.php + */ + public function testGetFormattedLinkPriceCustomerBasedTax() + { + /** set the product and tax classes from tax_class fixture */ + $this->setUpTaxClasses(); + $link = array_values($this->linksBlock->getLinks())[0]; + $formattedLink = $this->linksBlock->getFormattedLinkPrice($link); + $this->assertEquals( + '+$15.00'. + ' (+$16.13 Incl. Tax)', + $formattedLink + ); + } + + /** + * Test a customer outside of region. + * + * @magentoConfigFixture current_store tax/display/type 3 + * @magentoConfigFixture current_store tax/calculation/based_on billing + * @magentoDataFixture Magento/Downloadable/_files/product_with_files.php + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_address.php + * @magentoDataFixture Magento/Customer/_files/customer_group.php + * @magentoDataFixture Magento/Tax/_files/tax_classes.php + */ + public function testGetFormattedLinkPriceCustomerBasedTaxDiffRegion() + { + /** set the product and tax classes from tax_class fixture */ + $this->setUpTaxClasses(13); + $link = array_values($this->linksBlock->getLinks())[0]; + $formattedLink = $this->linksBlock->getFormattedLinkPrice($link); + $this->assertEquals('+$15.00', $formattedLink); + } + + /** + * Test that has a customer but product based tax. + * + * @magentoConfigFixture current_store tax/display/type 3 + * @magentoDataFixture Magento/Downloadable/_files/product_with_files.php + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetFormattedLinkPriceCustomerProductTax() + { + $product = $this->objectManager->create('Magento\Catalog\Model\Product')->load(1); + $product->setTaxPercent(10); + $product->save(); + + $this->registry->register('product', $product); + $this->registry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + + $link = array_values($this->linksBlock->getLinks())[0]; + $formattedLink = $this->linksBlock->getFormattedLinkPrice($link); + $this->assertEquals( + '+$15.00'. + ' (+$16.50 Incl. Tax)', + $formattedLink + ); + } + + /** + * Set the product and tax classes from tax_class fixture + * + * @param int $addressRegionId Region to use for customer billing address. + * Defaults to 12 which is the same as in tax rate fixture + */ + private function setUpTaxClasses($addressRegionId = 12) + { + $taxRule = $this->registry->registry('_fixture/Magento_Tax_Model_Calculation_Rule'); + $customerTaxClasses = $taxRule->getTaxCustomerClass(); + $productTaxClasses = $taxRule->getTaxProductClass(); + + $customerGroup = $this->objectManager->create('Magento\Customer\Model\Group')->load(1); + $customerGroup->setTaxClassId($customerTaxClasses[0]); + $customerGroup->save(); + + $address = $this->objectManager->create('Magento\Customer\Model\Address')->load(1); + $address->setRegionId($addressRegionId); + $address->save(); + + $product = $this->objectManager->create('Magento\Catalog\Model\Product')->load(1); + $product->setTaxClassId($productTaxClasses[0]); + $product->save(); + + $this->registry->register('product', $product); + $this->registry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + } +} + \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php index 68b2f55c08fca..e09e7ed7c9106 100644 --- a/dev/tests/integration/testsuite/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php @@ -40,17 +40,12 @@ public function testPrepareForm() /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); - $objectManager->get('Magento\View\DesignInterface')->setDefaultDesignTheme(); - $entityType = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Eav\Model\Config' - )->getEntityType( - 'customer' - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + $objectManager->get('Magento\View\DesignInterface') + ->setDefaultDesignTheme(); + $entityType = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Eav\Model\Config') + ->getEntityType('customer'); $model = $objectManager->create('Magento\Customer\Model\Attribute'); $model->setEntityTypeId($entityType->getId()); $objectManager->get('Magento\Registry')->register('entity_attribute', $model); diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php index 9fe9222bfd58e..780676ae0d78d 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php @@ -67,10 +67,12 @@ public function testStoreDirective() ); $this->assertStringMatchesFormat('http://example.com/%sarbitrary_url/', $url); - $url = $this->_model->storeDirective( - array('{{store url="core/ajax/translate"}}', 'store', ' url="core/ajax/translate"') - ); - $this->assertStringMatchesFormat('http://example.com/%score/ajax/translate/', $url); + $url = $this->_model->storeDirective(array( + '{{store url="translation/ajax/index"}}', + 'store', + ' url="translation/ajax/index"', + )); + $this->assertStringMatchesFormat('http://example.com/%stranslation/ajax/index/', $url); } public function testEscapehtmlDirective() @@ -126,7 +128,7 @@ public function testLayoutDirective($area, $directiveParams, $expectedOutput) $design = $objectManager->create('Magento\Core\Model\View\Design', array('themes' => $themes)); $objectManager->addSharedInstance($design, 'Magento\Core\Model\View\Design'); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')->loadArea($area); + \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea($area); $collection = $objectManager->create('Magento\Core\Model\Resource\Theme\Collection'); $themeId = $collection->getThemeByFullPath('frontend/test_default')->getId(); diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php index 636278dc7ca9d..9b4000f1eccd5 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php @@ -115,11 +115,8 @@ public function testLoadDefault() */ public function testGetProcessedTemplate() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->getArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - )->load(); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Core\Model\App\Area::AREA_FRONTEND)->load(); $this->_setNotDefaultThemeForFixtureStore(); $expectedViewUrl = 'static/frontend/magento_plushe/en_US/Magento_Theme/favicon.ico'; $this->_model->setTemplateText('{{view url="Magento_Theme::favicon.ico"}}'); @@ -163,11 +160,8 @@ protected function _setNotDefaultThemeForFixtureStore() */ public function testGetProcessedTemplateDesignChange() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->getArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - )->load(); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Core\Model\App\Area::AREA_FRONTEND)->load(); $this->_model->setTemplateText('{{view url="Magento_Theme::favicon.ico"}}'); $this->assertStringEndsWith( 'static/frontend/magento_plushe/en_US/Magento_Theme/favicon.ico', @@ -181,11 +175,8 @@ public function testGetProcessedTemplateDesignChange() */ public function testGetProcessedTemplateSubject() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->getArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - )->load(); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Core\Model\App\Area::AREA_FRONTEND)->load(); $this->_setNotDefaultThemeForFixtureStore(); $expectedViewUrl = 'static/frontend/magento_plushe/en_US/Magento_Theme/favicon.ico'; $this->_model->setTemplateSubject('{{view url="Magento_Theme::favicon.ico"}}'); @@ -208,11 +199,8 @@ public function testGetProcessedTemplateSubject() */ public function testGetDefaultEmailLogo() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->getArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - )->load(); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Core\Model\App\Area::AREA_FRONTEND)->load(); $this->assertStringEndsWith( 'static/frontend/magento_blank/en_US/Magento_Email/logo_email.gif', $this->_model->getDefaultEmailLogo() diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/_files/themes.php b/dev/tests/integration/testsuite/Magento/Email/Model/_files/themes.php index 52d32b03a68a3..de6263e690b1d 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/_files/themes.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/_files/themes.php @@ -29,13 +29,15 @@ ) ); $objectManger = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); -$objectManger->get( - 'Magento\Core\Model\App' -)->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG -); -$objectManger->configure(array('preferences' => array('Magento\Core\Model\Theme' => 'Magento\Core\Model\Theme\Data'))); +$objectManger->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); + +$objectManger->configure(array( + 'preferences' => array( + 'Magento\Core\Model\Theme' => 'Magento\Core\Model\Theme\Data' + ) +)); /** @var $registration \Magento\Core\Model\Theme\Registration */ $registration = $objectManger->create('Magento\Core\Model\Theme\Registration'); $registration->register(implode('/', array('*', '*', 'theme.xml'))); diff --git a/dev/tests/integration/testsuite/Magento/GiftMessage/Block/Message/InlineTest.php b/dev/tests/integration/testsuite/Magento/GiftMessage/Block/Message/InlineTest.php index 5b46b8fe1cd18..b4d19dd52363c 100644 --- a/dev/tests/integration/testsuite/Magento/GiftMessage/Block/Message/InlineTest.php +++ b/dev/tests/integration/testsuite/Magento/GiftMessage/Block/Message/InlineTest.php @@ -47,14 +47,10 @@ protected function setUp() */ public function testThumbnail() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\Product' - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); $product->load(1); $size = $this->_block->getThumbnailSize(); diff --git a/dev/tests/integration/testsuite/Magento/GoogleShopping/Model/_files/flag_expired.php b/dev/tests/integration/testsuite/Magento/GoogleShopping/Model/_files/flag_expired.php index 6666010115eb3..d4d8469fe5145 100644 --- a/dev/tests/integration/testsuite/Magento/GoogleShopping/Model/_files/flag_expired.php +++ b/dev/tests/integration/testsuite/Magento/GoogleShopping/Model/_files/flag_expired.php @@ -31,9 +31,8 @@ $flag = $objectManager->create('Magento\GoogleShopping\Model\Flag'); $flag->lock(); -/** @var $flagResource \Magento\Core\Model\Resource\Flag */ -$flagResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Flag' -); +/** @var $flagResource \Magento\Flag\Resource */ +$flagResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Flag\Resource'); $flag->setLastUpdate(date('Y-m-d H:i:s', time() - \Magento\GoogleShopping\Model\Flag::FLAG_TTL - 1)); $flagResource->save($flag); diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Block/Adminhtml/Export/FilterTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Block/Adminhtml/Export/FilterTest.php index c41d2c84cef80..388b2241a95f2 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Block/Adminhtml/Export/FilterTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Block/Adminhtml/Export/FilterTest.php @@ -37,17 +37,12 @@ class FilterTest extends \PHPUnit_Framework_TestCase */ public function testGetDateFromToHtmlWithValue() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\View\DesignInterface' - )->setDefaultDesignTheme(); - $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\ImportExport\Block\Adminhtml\Export\Filter' - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\DesignInterface') + ->setDefaultDesignTheme(); + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\ImportExport\Block\Adminhtml\Export\Filter'); $method = new \ReflectionMethod( 'Magento\ImportExport\Block\Adminhtml\Export\Filter', '_getDateFromToHtmlWithValue' 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 1e09e70f8efc0..016c68038e18e 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php @@ -86,7 +86,7 @@ public function testGetWriter() /** * Check that method throw exception when writer was not defined * - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testGetWriterThrowsException() { diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/ExportTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/ExportTest.php index 54e79d021e81a..5acebb9b3f3fc 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/ExportTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/ExportTest.php @@ -86,7 +86,7 @@ public function getEntityDataProvider() /** * Test method '_getEntityAdapter' in case when entity is invalid * - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @covers \Magento\ImportExport\Model\Export::_getEntityAdapter */ public function testGetEntityAdapterWithInvalidEntity() diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php index 39fbf61a6f1cd..57f0cb8fcb413 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php @@ -155,18 +155,10 @@ protected function _assertCustomerData(array $expectedData) * @dataProvider importDataDataProvider * @covers \Magento\ImportExport\Model\Import\Entity\CustomerComposite::_importData */ - public function testImportData( - $behavior, - $sourceFile, - array $dataBefore, - array $dataAfter, - array $errors = array() - ) { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); + public function testImportData($behavior, $sourceFile, array $dataBefore, array $dataAfter, array $errors = array()) + { + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); // set entity adapter parameters $this->_entityAdapter->setParameters(array('behavior' => $behavior)); /** @var \Magento\App\Filesystem $filesystem */ diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php index e79b45dc89a88..0c3e669d3d9f2 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php @@ -257,13 +257,8 @@ protected function _addTestAddress(\Magento\ImportExport\Model\Import\Entity\Eav 'Magento\Customer\Model\Address' ); $tableName = $addressModel->getResource()->getEntityTable(); - $addressId = $objectManager->get( - 'Magento\Core\Model\Resource\HelperPool' - )->get( - 'Magento_ImportExport' - )->getNextAutoincrement( - $tableName - ); + $addressId = $objectManager->get('Magento\ImportExport\Model\Resource\Helper') + ->getNextAutoincrement($tableName); /** @var \Magento\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Stdlib\DateTime'); diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/CustomerImportTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/CustomerImportTest.php index 11126cde90ff4..4525ed9cc4662 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/CustomerImportTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/CustomerImportTest.php @@ -139,11 +139,8 @@ public function testImportData() */ public function testDeleteData() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); $source = new \Magento\ImportExport\Model\Import\Source\Csv( __DIR__ . '/_files/customers_to_import.csv', $this->directoryWrite diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/ImportTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/ImportTest.php index abc8436c9af3b..2e1c65079b3b1 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/ImportTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/ImportTest.php @@ -125,7 +125,7 @@ public function testValidateSource() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Entity is unknown */ public function testValidateSourceException() @@ -147,7 +147,7 @@ public function testGetEntity() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Entity is unknown */ public function testGetEntityEntityIsNotSet() @@ -175,7 +175,7 @@ public function testGetEntityBehaviors() /** * Test getEntityBehaviors with not existing behavior class * - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Invalid behavior token for customer */ public function testGetEntityBehaviorsWithUnknownBehavior() diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Resource/Import/DataTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Resource/Import/DataTest.php index 4da2db25b3c2e..5f9915d729cd1 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Resource/Import/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Resource/Import/DataTest.php @@ -67,7 +67,7 @@ public function testGetUniqueColumnData() /** * Test getUniqueColumnData() in case when in data stored in requested column is NOT unique * - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testGetUniqueColumnDataException() { diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/themes.php b/dev/tests/integration/testsuite/Magento/Less/_files/themes.php index 5d43a26038aae..3f3db4f663f73 100644 --- a/dev/tests/integration/testsuite/Magento/Less/_files/themes.php +++ b/dev/tests/integration/testsuite/Magento/Less/_files/themes.php @@ -29,6 +29,8 @@ ) ); $objectManger = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +$objectManger->get('Magento\App\State') + ->setAreaCode(\Magento\View\DesignInterface::DEFAULT_AREA); /** @var $registration \Magento\Core\Model\Theme\Registration */ $registration = $objectManger->create('Magento\Core\Model\Theme\Registration'); diff --git a/dev/tests/integration/testsuite/Magento/Log/Model/Resource/Visitor/Online/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Log/Model/Resource/Visitor/Online/CollectionTest.php new file mode 100644 index 0000000000000..6bc9125cb2f61 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Log/Model/Resource/Visitor/Online/CollectionTest.php @@ -0,0 +1,66 @@ +create('Magento\Log\Model\Resource\Visitor\Online\Collection'); + + $visitorOnlineCollection->addCustomerData(); + + $this->assertEquals(1, $visitorOnlineCollection->count(), "Invalid collection items quantity."); + /** @var \Magento\Log\Model\Visitor\Online $collectionItem */ + $collectionItem = $visitorOnlineCollection->getFirstItem(); + + /** @var \Magento\Log\Model\Visitor\Online $visitorOnline */ + $visitorOnline = Bootstrap::getObjectManager() + ->create('Magento\Log\Model\Visitor\Online') + ->load(1); + + $visitorOnline->addData([ + 'customer_email' => 'customer@example.com', + 'customer_firstname' => 'Firstname', + 'customer_lastname' => 'Lastname' + ]); + + foreach ($visitorOnline->getData() as $field => $expectedValue) { + $this->assertEquals( + $expectedValue, + $collectionItem->getData($field), + "'{$field}' field value is invalid." + ); + } + } +} diff --git a/app/code/Magento/Backend/Model/Resource/Translate/String.php b/dev/tests/integration/testsuite/Magento/Log/_files/visitor_online.php similarity index 65% rename from app/code/Magento/Backend/Model/Resource/Translate/String.php rename to dev/tests/integration/testsuite/Magento/Log/_files/visitor_online.php index 44129bdf32438..4712a7b0422bc 100644 --- a/app/code/Magento/Backend/Model/Resource/Translate/String.php +++ b/dev/tests/integration/testsuite/Magento/Log/_files/visitor_online.php @@ -18,26 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Backend * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Backend\Model\Resource\Translate; - -/** - * Backend string translate resource model - */ -class String extends \Magento\Core\Model\Resource\Translate\String -{ - /** - * Get current store id - * Use always default scope for store id - * - * @return int - */ - protected function _getStoreId() - { - return \Magento\Core\Model\Store::DEFAULT_STORE_ID; - } -} +/** @var \Magento\Log\Model\Visitor\Online $visitorOnline */ +$visitorOnline = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Log\Model\Visitor\Online'); +$visitorOnline->setData(array( + 'visitor_type' => 'c', + 'remote_addr' => '10101010', + 'first_visit_at' => '2014-03-02 00:00:00', + 'last_visit_at' => '2014-03-02 01:01:01', + 'customer_id' => 1, + 'last_url' => 'http://last_url', +)); +$visitorOnline->save(); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Model/Resource/Db/AbstractTest.php similarity index 88% rename from dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php rename to dev/tests/integration/testsuite/Magento/Model/Resource/Db/AbstractTest.php index 4b9a949d53b93..6023ae8e24814 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Model/Resource/Db/AbstractTest.php @@ -19,25 +19,24 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Core + * @package Magento_Lib * @subpackage integration_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Db; +namespace Magento\Model\Resource\Db; class AbstractTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Resource\Db\AbstractDb + * @var \Magento\Model\Resource\Db\AbstractDb */ protected $_model; protected function setUp() { $resource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\Resource'); - $this->_model = $this->getMockForAbstractClass( - 'Magento\Core\Model\Resource\Db\AbstractDb', + $this->_model = $this->getMockForAbstractClass('Magento\Model\Resource\Db\AbstractDb', array('resource' => $resource) ); } @@ -74,8 +73,7 @@ public function testGetTableName() array('tablePrefix' => 'prefix_') ); - $model = $this->getMockForAbstractClass( - 'Magento\Core\Model\Resource\Db\AbstractDb', + $model = $this->getMockForAbstractClass('Magento\Model\Resource\Db\AbstractDb', array('resource' => $resource) ); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/Collection/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Model/Resource/Db/Collection/AbstractTest.php similarity index 78% rename from dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/Collection/AbstractTest.php rename to dev/tests/integration/testsuite/Magento/Model/Resource/Db/Collection/AbstractTest.php index 88e1e6dde2e66..370453181c857 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/Collection/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Model/Resource/Db/Collection/AbstractTest.php @@ -21,26 +21,21 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Db\Collection; +namespace Magento\Model\Resource\Db\Collection; class AbstractTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @var \Magento\Model\Resource\Db\Collection\AbstractCollection */ protected $_model = null; protected function setUp() { - $resourceModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\Resource'); - $resource = $this->getMockForAbstractClass( - 'Magento\Core\Model\Resource\Db\AbstractDb', - array($resourceModel), - '', - true, - true, - true, - array('getMainTable', 'getIdFieldName') + $resourceModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\App\Resource'); + $resource = $this->getMockForAbstractClass('Magento\Model\Resource\Db\AbstractDb', + array($resourceModel), '', true, true, true, array('getMainTable', 'getIdFieldName') ); $resource->expects( @@ -58,13 +53,13 @@ protected function setUp() 'Magento\Event\ManagerInterface' ); - $entityFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\EntityFactory' - ); - $logger = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Logger'); + $entityFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Core\Model\EntityFactory'); + $logger = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Logger'); $this->_model = $this->getMockForAbstractClass( - 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection', + 'Magento\Model\Resource\Db\Collection\AbstractCollection', array($entityFactory, $logger, $fetchStrategy, $eventManager, null, $resource) ); } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php b/dev/tests/integration/testsuite/Magento/Model/Resource/Db/ProfilerTest.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php rename to dev/tests/integration/testsuite/Magento/Model/Resource/Db/ProfilerTest.php index 1773df4f0b8da..e66925ce7b856 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php +++ b/dev/tests/integration/testsuite/Magento/Model/Resource/Db/ProfilerTest.php @@ -1,6 +1,6 @@ get('Magento\App\Arguments'); $connectionConfig = $localConfig->getConnection('default'); $connectionConfig['profiler'] = array( - 'class' => 'Magento\Core\Model\Resource\Db\Profiler', + 'class' => 'Magento\Model\Resource\Db\Profiler', 'enabled' => 'true' ); $connectionConfig['dbname'] = $connectionConfig['dbName']; @@ -92,9 +92,9 @@ public function testProfilerInit($selectQuery, $queryType) $result->fetchAll(); } - /** @var \Magento\Core\Model\Resource\Db\Profiler $profiler */ + /** @var \Magento\Model\Resource\Db\Profiler $profiler */ $profiler = $connection->getProfiler(); - $this->assertInstanceOf('Magento\Core\Model\Resource\Db\Profiler', $profiler); + $this->assertInstanceOf('Magento\Model\Resource\Db\Profiler', $profiler); $queryProfiles = $profiler->getQueryProfiles($queryType); $this->assertCount(1, $queryProfiles); @@ -150,9 +150,9 @@ public function testProfilerDuringSqlException() $testTableName = $resource->getTableName('core_resource'); $connection->query('SELECT * FROM ' . $testTableName); - /** @var \Magento\Core\Model\Resource\Db\Profiler $profiler */ + /** @var \Magento\Model\Resource\Db\Profiler $profiler */ $profiler = $connection->getProfiler(); - $this->assertInstanceOf('Magento\Core\Model\Resource\Db\Profiler', $profiler); + $this->assertInstanceOf('Magento\Model\Resource\Db\Profiler', $profiler); $queryProfiles = $profiler->getQueryProfiles(\Magento\DB\Profiler::SELECT); $this->assertCount(2, $queryProfiles); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Entity/TableTest.php b/dev/tests/integration/testsuite/Magento/Model/Resource/Entity/TableTest.php similarity index 88% rename from dev/tests/integration/testsuite/Magento/Core/Model/Resource/Entity/TableTest.php rename to dev/tests/integration/testsuite/Magento/Model/Resource/Entity/TableTest.php index 019a03f82d936..8b3b9f60d5675 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Entity/TableTest.php +++ b/dev/tests/integration/testsuite/Magento/Model/Resource/Entity/TableTest.php @@ -24,12 +24,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Entity; +namespace Magento\Model\Resource\Entity; class TableTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Resource\Entity\Table + * @var \Magento\Model\Resource\Entity\Table */ protected $_model; @@ -41,10 +41,8 @@ protected function setUp() $config->test_key = 'test'; // @codingStandardsIgnoreEnd - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Entity\Table', - array('config' => $config) - ); + $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Model\Resource\Entity\Table', array('config' => $config)); } public function testGetTable() diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/IteratorTest.php b/dev/tests/integration/testsuite/Magento/Model/Resource/IteratorTest.php similarity index 74% rename from dev/tests/integration/testsuite/Magento/Core/Model/Resource/IteratorTest.php rename to dev/tests/integration/testsuite/Magento/Model/Resource/IteratorTest.php index b863dc5187505..de6e27ee3303d 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/IteratorTest.php +++ b/dev/tests/integration/testsuite/Magento/Model/Resource/IteratorTest.php @@ -24,12 +24,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource; +namespace Magento\Model\Resource; class IteratorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Resource\Iterator + * @var \Magento\Model\Resource\Iterator */ protected $_model; @@ -42,18 +42,8 @@ class IteratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Iterator' - ); - } - - public function testWalk() - { - $collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Store\Collection' - ); - $this->_model->walk($collection->getSelect(), array(array($this, 'walkCallback'))); - $this->assertGreaterThan(0, $this->_callbackCounter); + $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Model\Resource\Iterator'); } /** @@ -69,7 +59,7 @@ public function walkCallback($data) } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testWalkException() { diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/ResourceTest.php b/dev/tests/integration/testsuite/Magento/Model/ResourceTest.php similarity index 86% rename from dev/tests/integration/testsuite/Magento/Core/Model/ResourceTest.php rename to dev/tests/integration/testsuite/Magento/Model/ResourceTest.php index 601946d8f234e..4fd86172af5ed 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/ResourceTest.php +++ b/dev/tests/integration/testsuite/Magento/Model/ResourceTest.php @@ -1,6 +1,6 @@ array( - 'profiler' => array('class' => 'Magento\Core\Model\Resource\Db\Profiler', 'enabled' => 'true'), + 'profiler' => array( + 'class' => 'Magento\Model\Resource\Db\Profiler', + 'enabled' => 'true' + ), 'username' => 'username', 'password' => 'password', 'host' => 'host', @@ -76,10 +79,10 @@ public function testProfilerInit() ) ); - /** @var \Magento\Core\Model\Resource\Db\Profiler $profiler */ + /** @var \Magento\Model\Resource\Db\Profiler $profiler */ $profiler = $connection->getProfiler(); - $this->assertInstanceOf('Magento\Core\Model\Resource\Db\Profiler', $profiler); + $this->assertInstanceOf('Magento\Model\Resource\Db\Profiler', $profiler); $this->assertTrue($profiler->getEnabled()); } } 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 a04c44c0412f4..575383d026672 100644 --- a/dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php +++ b/dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php @@ -40,20 +40,18 @@ class OverviewTest extends \PHPUnit_Framework_TestCase protected function setUp() { + \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $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', - 'checkout_overview', - array( - 'data' => array( - 'renderer_template' => 'Magento_Multishipping::checkout/item/default.phtml', - 'row_renderer_template' => 'Magento_Multishipping::checkout/overview/item.phtml' + $this->_block = $this->_objectManager->get('Magento\View\LayoutInterface') + ->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( diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php index 75202219d5fb5..735e14d41ddc1 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php @@ -38,9 +38,9 @@ public function testSendPerSubscriber() /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var $app \Magento\TestFramework\App */ - $app = $objectManager->get('Magento\Core\Model\App'); - $app->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $objectManager->get('Magento\App\State')->setAreaCode(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $area = $objectManager->get('Magento\App\AreaList')->getArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $area->load(); /** @var $filter \Magento\Newsletter\Model\Template\Filter */ $filter = $objectManager->get('Magento\Newsletter\Model\Template\Filter'); @@ -77,8 +77,10 @@ public function testSendPerSubscriberProblem() { $errorMsg = md5(microtime()); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Core\Model\App')->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); $transport = $this->getMock('\Magento\Mail\TransportInterface'); $transport->expects( diff --git a/dev/tests/integration/testsuite/Magento/Outbound/Authentication/FactoryTest.php b/dev/tests/integration/testsuite/Magento/Outbound/Authentication/FactoryTest.php deleted file mode 100644 index 6670f8be51e3a..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Outbound/Authentication/FactoryTest.php +++ /dev/null @@ -1,60 +0,0 @@ -_authFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Outbound\Authentication\Factory', - array( - 'authenticationMap' => array( - EndpointInterface::AUTH_TYPE_HMAC => 'Magento\Outbound\Authentication\Hmac' - ) - ) - ); - } - - public function testGetFormatter() - { - $authObject = $this->_authFactory->getAuthentication(EndpointInterface::AUTH_TYPE_HMAC); - $this->assertInstanceOf('Magento\Outbound\Authentication\Hmac', $authObject); - } - - public function testGetFormatterIsCached() - { - $authObject = $this->_authFactory->getAuthentication(EndpointInterface::AUTH_TYPE_HMAC); - $authObject2 = $this->_authFactory->getAuthentication(EndpointInterface::AUTH_TYPE_HMAC); - $this->assertSame($authObject, $authObject2); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Outbound/Formatter/FactoryTest.php b/dev/tests/integration/testsuite/Magento/Outbound/Formatter/FactoryTest.php deleted file mode 100644 index 7d31e8189bac8..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Outbound/Formatter/FactoryTest.php +++ /dev/null @@ -1,56 +0,0 @@ -_formatterFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Outbound\Formatter\Factory', - array('formatterMap' => array(EndpointInterface::FORMAT_JSON => 'Magento\Outbound\Formatter\Json')) - ); - } - - public function testGetFormatter() - { - $formatter = $this->_formatterFactory->getFormatter(EndpointInterface::FORMAT_JSON); - $this->assertInstanceOf('Magento\Outbound\Formatter\Json', $formatter); - } - - public function testGetFormatterIsCached() - { - $formatter = $this->_formatterFactory->getFormatter(EndpointInterface::FORMAT_JSON); - $formatter2 = $this->_formatterFactory->getFormatter(EndpointInterface::FORMAT_JSON); - $this->assertSame($formatter, $formatter2); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Outbound/Formatter/JsonTest.php b/dev/tests/integration/testsuite/Magento/Outbound/Formatter/JsonTest.php deleted file mode 100644 index 4d5e8d28b75a9..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Outbound/Formatter/JsonTest.php +++ /dev/null @@ -1,74 +0,0 @@ -_formatter = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Outbound\Formatter\Json' - ); - } - - /** - * @dataProvider encodeDataProvider - * - * @param $body - * @param $formattedBody - */ - public function testFormat($body, $formattedBody) - { - $this->assertSame($formattedBody, $this->_formatter->format($body)); - } - - /** - * DataProvider for testing the JSON formatter. - * - * @return array - */ - public function encodeDataProvider() - { - return array( - array(array(), "[]"), - array(array('a' => array('b' => 'c', 'd' => 'e'), 'f' => 'g'), '{"a":{"b":"c","d":"e"},"f":"g"}'), - array(array(null), '[null]'), - array(array(true), '[true]'), - array(array(false), '[false]'), - array(array(-1), '[-1]'), - array(array(0), '[0]'), - array(array(1), '[1]'), - array(array(2.4), '[2.4]'), - array(array(2.0), '[2]'), - array(array(new \Magento\Outbound\Formatter\JsonTest\Data('public', 'protected')), '[{"dataA":"public"}]') - ); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Outbound/Formatter/JsonTest/Data.php b/dev/tests/integration/testsuite/Magento/Outbound/Formatter/JsonTest/Data.php deleted file mode 100644 index 9c5f1be9ce1e3..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Outbound/Formatter/JsonTest/Data.php +++ /dev/null @@ -1,47 +0,0 @@ -dataA = $first; - $this->_dataB = $second; - } - - public function getB() - { - return $this->_dataB; - } -} diff --git a/dev/tests/integration/testsuite/Magento/PageCache/Model/System/Config/Backend/TtlTest.php b/dev/tests/integration/testsuite/Magento/PageCache/Model/System/Config/Backend/TtlTest.php index c23344c327cea..6c9d5bc0304b3 100644 --- a/dev/tests/integration/testsuite/Magento/PageCache/Model/System/Config/Backend/TtlTest.php +++ b/dev/tests/integration/testsuite/Magento/PageCache/Model/System/Config/Backend/TtlTest.php @@ -73,7 +73,7 @@ public function beforeSaveDataProvider() */ public function testBeforeSaveWithException($value, $path) { - $this->setExpectedException('\Magento\Core\Exception'); + $this->setExpectedException('\Magento\Model\Exception'); $this->_prepareData($value, $path); } diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php index 74a0963f0b64a..c5c02f63ee6cd 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php @@ -21,19 +21,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')->loadArea('adminhtml'); -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\StoreManagerInterface' -)->getStore()->setConfig( - 'carriers/flatrate/active', - 1 -); -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\StoreManagerInterface' -)->getStore()->setConfig( - 'payment/paypal_express/active', - 1 -); +\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface')->getStore() + ->setConfig('carriers/flatrate/active', 1); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface')->getStore() + ->setConfig('payment/paypal_express/active', 1); /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); $product->setTypeId( diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php index 08630bc7ba8ab..54aba2fe7eed9 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php @@ -22,13 +22,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')->loadArea('adminhtml'); -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\StoreManagerInterface' -)->getStore()->setConfig( - 'carriers/flatrate/active', - 1 -); +\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface')->getStore() + ->setConfig('carriers/flatrate/active', 1); /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); $product->setTypeId( diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php index dc2b80c3f5b77..e255ed2b24e4e 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php @@ -21,13 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')->loadArea('adminhtml'); -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\StoreManagerInterface' -)->getStore()->setConfig( - 'carriers/flatrate/active', - 1 -); +\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface')->getStore() + ->setConfig('carriers/flatrate/active', 1); /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); $product->setTypeId( diff --git a/dev/tests/integration/testsuite/Magento/ProductAlert/Block/Email/StockTest.php b/dev/tests/integration/testsuite/Magento/ProductAlert/Block/Email/StockTest.php index fa24b92209dbe..cbd299281a7fb 100644 --- a/dev/tests/integration/testsuite/Magento/ProductAlert/Block/Email/StockTest.php +++ b/dev/tests/integration/testsuite/Magento/ProductAlert/Block/Email/StockTest.php @@ -47,14 +47,9 @@ protected function setUp() */ public function testThumbnail() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\Product' - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); $product->load(1); $size = $this->_block->getThumbnailSize(); diff --git a/dev/tests/integration/testsuite/Magento/PubSub/EventTest.php b/dev/tests/integration/testsuite/Magento/PubSub/EventTest.php deleted file mode 100644 index aebb49fa21ff5..0000000000000 --- a/dev/tests/integration/testsuite/Magento/PubSub/EventTest.php +++ /dev/null @@ -1,53 +0,0 @@ - 'body'); - $topic = 'topic'; - - $event = new \Magento\PubSub\Event($topic, $bodyData); - - $this->assertEquals(array(), $event->getHeaders()); - $this->assertEquals($bodyData, $event->getBodyData()); - $this->assertEquals($topic, $event->getTopic()); - $this->assertEquals(\Magento\PubSub\Event::STATUS_READY_TO_SEND, $event->getStatus()); - } - - public function testMarkProcessed() - { - $bodyData = array('some' => 'body'); - $topic = 'topic'; - $event = new \Magento\PubSub\Event($topic, $bodyData); - - $event->complete(); - - $this->assertEquals(\Magento\PubSub\Event::STATUS_PROCESSED, $event->getStatus()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php b/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php index 8453d769cb5e5..132642503a6bc 100644 --- a/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php +++ b/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php @@ -22,12 +22,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadAreaPart( - 'adminhtml', - \Magento\Core\Model\App\Area::PART_CONFIG -); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea('adminhtml') + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php'; require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_duplicated.php'; diff --git a/dev/tests/integration/testsuite/Magento/Review/Block/Adminhtml/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Review/Block/Adminhtml/Edit/FormTest.php new file mode 100644 index 0000000000000..af89aac89ffc9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/Block/Adminhtml/Edit/FormTest.php @@ -0,0 +1,54 @@ +create('Magento\Customer\Model\Customer') + ->setWebsiteId(1) + ->loadByEmail('customer@example.com'); + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Review\Block\Adminhtml\Edit\Form'); + /** @var \Magento\Escaper $escaper */ + $escaper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Escaper'); + $this->assertStringMatchesFormat( + '%A' . __('%2 %3 (%4)', + '%A', + $escaper->escapeHtml($customer->getFirstname()), + $escaper->escapeHtml($customer->getLastname()), + $escaper->escapeHtml($customer->getEmail()) + ) . '%A', + $block->toHtml() + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Review/Block/Adminhtml/MainTest.php b/dev/tests/integration/testsuite/Magento/Review/Block/Adminhtml/MainTest.php new file mode 100644 index 0000000000000..ab88f39e7f7c3 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/Block/Adminhtml/MainTest.php @@ -0,0 +1,53 @@ +create('Magento\Customer\Service\V1\CustomerAccountService'); + $customer = $service->authenticate('customer@example.com', 'password'); + $request = $objectManager->get('Magento\App\RequestInterface'); + $request->setParam('customerId', $customer->getId()); + /** @var \Magento\View\LayoutInterface $layout */ + $layout = $objectManager->get('Magento\View\LayoutInterface'); + $block = $layout->createBlock('Magento\Review\Block\Adminhtml\Main'); + $customerName = $customer->getFirstname() . ' ' . $customer->getLastname(); + /** @var \Magento\Escaper $escaper */ + $escaper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Escaper'); + $this->assertStringMatchesFormat( + '%A' . __('All Reviews of Customer `%1`', $escaper->escapeHtml($customerName)) . '%A', + $block->getHeaderHtml() + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Review/Block/FormTest.php b/dev/tests/integration/testsuite/Magento/Review/Block/FormTest.php new file mode 100644 index 0000000000000..e43088ec2b2ad --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/Block/FormTest.php @@ -0,0 +1,52 @@ +get('Magento\Customer\Model\Session'); + $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Service\V1\CustomerAccountService'); + $customer = $service->authenticate('customer@example.com', 'password'); + $session->setCustomerDataAsLoggedIn($customer); + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Review\Block\Form'); + /** @var \Magento\Escaper $escaper */ + $escaper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Escaper'); + $this->assertStringMatchesFormat( + '%A%A', + $block->toHtml() + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php b/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php new file mode 100644 index 0000000000000..1535b4f74d33c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php @@ -0,0 +1,59 @@ +loadArea( + \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE +); + +require __DIR__ . '/../../../Magento/Customer/_files/customer.php'; +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php'; + +$review = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Review\Model\Review', + ['data' => [ + 'customer_id' => $customer->getId(), + 'title' => 'Review Summary', + 'detail' => 'Review text', + 'nickname' => 'Nickname', + ]] +); + +$review + ->setEntityId($review->getEntityIdByCode(\Magento\Review\Model\Review::ENTITY_PRODUCT_CODE)) + ->setEntityPkValue($product->getId()) + ->setStatusId(\Magento\Review\Model\Review::STATUS_PENDING) + ->setStoreId( + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface') + ->getStore()->getId() + ) + ->setStores([ + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface') + ->getStore()->getId() + ]) + ->save(); + +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Registry')->register( + 'review_data', + $review +); diff --git a/dev/tests/integration/testsuite/Magento/Rss/Block/WishlistTest.php b/dev/tests/integration/testsuite/Magento/Rss/Block/WishlistTest.php new file mode 100644 index 0000000000000..edf9cb192e52e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Rss/Block/WishlistTest.php @@ -0,0 +1,108 @@ +_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->_customerSession = $this->_objectManager->create('Magento\Customer\Model\Session'); + $this->_coreData = $this->_objectManager->create('Magento\Core\Helper\Data'); + + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_increments.php + * @magentoAppArea frontend + */ + public function testCustomerTitle() + { + $fixtureCustomerId = 1; + $this->_customerSession->loginById($fixtureCustomerId); + + /** @var \Magento\Wishlist\Model\Wishlist $wishlist */ + $wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist') + ->loadByCustomerId($fixtureCustomerId); + + /** @var \Magento\App\Helper\Context $contextHelper */ + $contextHelper = $this->_objectManager->create('Magento\App\Helper\Context'); + + $wishlistHelper = $this->_objectManager->create('Magento\Rss\Helper\WishlistRss', + [ + 'context' => $contextHelper, + 'customerSession' => $this->_customerSession + ] + ); + + /** @var \Magento\Catalog\Block\Product\Context $context */ + $contextBlock = $this->_objectManager->create( + 'Magento\Rss\Block\Context', + [ + 'request' => $contextHelper->getRequest(), + 'wishlistHelper' => $wishlistHelper + ] + ); + /** @var \Magento\App\Request\Http $request */ + $request = $contextHelper->getRequest(); + $request->setParam('wishlist_id', $wishlist->getId()); + $request->setParam('data', $this->_coreData->urlEncode($fixtureCustomerId)); + + /** @var \Magento\Rss\Block\Wishlist $block */ + $block = $this->_objectManager->create('Magento\Rss\Block\Wishlist', + [ + 'context' => $contextBlock + ] + ); + + /** @var \Magento\Escaper $escaper */ + $escaper = $this->_objectManager->create('Magento\Escaper'); + + $expectedSting = '%A' . __("<![CDATA[%1 %2's Wishlist]]>", + $escaper->escapeHtml($this->_customerSession->getCustomerDataObject()->getFirstname()), + $escaper->escapeHtml($this->_customerSession->getCustomerDataObject()->getLastname()) + ) . '%A'; + $this->assertStringMatchesFormat($expectedSting, $block->toHtml()); + } +} + \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php b/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php index 1147544f6b2ba..847c96368a982 100644 --- a/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php +++ b/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php @@ -164,22 +164,15 @@ public function testCategoryAction() */ protected function _loginAdmin() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\View\DesignInterface' - )->setDefaultDesignTheme(); - $this->getRequest()->setServer( - array( - '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\UrlInterface' - )->turnOffSecretKey(); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\DesignInterface') + ->setDefaultDesignTheme(); + $this->getRequest()->setServer(array( + '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\UrlInterface') + ->turnOffSecretKey(); } } diff --git a/dev/tests/integration/testsuite/Magento/Rss/Helper/WishlistRssTest.php b/dev/tests/integration/testsuite/Magento/Rss/Helper/WishlistRssTest.php new file mode 100644 index 0000000000000..88799cf4a052e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Rss/Helper/WishlistRssTest.php @@ -0,0 +1,129 @@ +_fixtureCustomerId = 1; + + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->_customerSession = $this->_objectManager->create('Magento\Customer\Model\Session'); + $this->_coreData = $this->_objectManager->create('Magento\Core\Helper\Data'); + + $this->_contextHelper = $this->_objectManager->create('Magento\App\Helper\Context'); + $request = $this->_contextHelper->getRequest(); + $request->setParam('data', $this->_coreData->urlEncode($this->_fixtureCustomerId)); + + $this->_wishlistHelper = $this->_objectManager->create('Magento\Rss\Helper\WishlistRss', + [ + 'context' => $this->_contextHelper, + 'customerSession' => $this->_customerSession + ] + ); + + $this->_customerSession->loginById($this->_fixtureCustomerId); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoAppArea frontend + */ + public function testGetCustomer() + { + $this->assertEquals($this->_customerSession->getCustomerDataObject(), $this->_wishlistHelper->getCustomer()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_increments.php + * @magentoAppArea frontend + */ + public function testGetWishlistByParam() + { + /** @var \Magento\Wishlist\Model\Wishlist $wishlist */ + $wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist') + ->loadByCustomerId($this->_fixtureCustomerId); + $wishlist->load($wishlist->getId()); + + /** @var \Magento\App\Request\Http $request */ + $request = $this->_contextHelper->getRequest(); + $request->setParam('wishlist_id', $wishlist->getId()); + + $this->assertEquals($wishlist, $this->_wishlistHelper->getWishlist()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_increments.php + * @magentoAppArea frontend + */ + public function testGetWishlistByCustomerId() + { + /** @var \Magento\Wishlist\Model\Wishlist $wishlist */ + $wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist') + ->loadByCustomerId($this->_fixtureCustomerId); + + /** @var \Magento\App\Request\Http $request */ + $request = $this->_contextHelper->getRequest(); + $request->setParam('wishlist_id', ''); + + $this->assertEquals($wishlist, $this->_wishlistHelper->getWishlist()); + } +} + \ No newline at end of file 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 85421462a8d87..908ea87a9b4aa 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 @@ -43,11 +43,8 @@ class AbstractTest extends \PHPUnit_Framework_TestCase public function testAddAttributesToForm() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $objectManager->get('Magento\View\DesignInterface')->setDefaultDesignTheme(); $arguments = array( diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Report/Filter/Form/CouponTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Report/Filter/Form/CouponTest.php index d990315e297e6..600ffdfb3297f 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Report/Filter/Form/CouponTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Report/Filter/Form/CouponTest.php @@ -36,18 +36,17 @@ class CouponTest extends \PHPUnit_Framework_TestCase { /** - * Application object + * Layout * - * @var \Magento\Core\Model\App + * @var \Magento\View\LayoutInterface */ - protected $_application; + protected $_layout; protected function setUp() { parent::setUp(); - $this->_application = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - ); + $this->_layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\View\LayoutInterface'); } /** @@ -56,9 +55,7 @@ protected function setUp() public function testAfterToHtml() { /** @var $block \Magento\Sales\Block\Adminhtml\Report\Filter\Form\Coupon */ - $block = $this->_application->getLayout()->createBlock( - 'Magento\Sales\Block\Adminhtml\Report\Filter\Form\Coupon' - ); + $block = $this->_layout->createBlock('Magento\Sales\Block\Adminhtml\Report\Filter\Form\Coupon'); $block->setFilterData(new \Magento\Object()); $html = $block->toHtml(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/CommentsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/CommentsTest.php index 1bd919d5c5e8b..cc15c5f001701 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/CommentsTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/CommentsTest.php @@ -77,7 +77,7 @@ public function getCommentsDataProvider() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testGetCommentsWrongEntityException() { diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php index e52fc87dd8495..b7c94c44d7078 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php @@ -157,4 +157,28 @@ public function getAclResourceDataProvider() array('', true, 'Magento_Sales::actions') ); } + + + /** + * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php + * @magentoAppArea adminhtml + */ + public function testConfigureProductToAddAction() + { + $this->getRequest()->setParam('id', 1) + ->setParam('isAjax', true); + + $this->dispatch('backend/sales/order_create/configureProductToAdd'); + + $body = $this->getResponse()->getBody(); + + $this->assertNotEmpty($body); + $this->assertContains('>Quantity', $body); + $this->assertContains('>Test Configurable', $body); + $this->assertContains('"code":"test_configurable","label":"Test Configurable"', $body); + $this->assertContains('"label":"Option 1","price":"5","oldPrice":"5","products":[', $body); + $this->assertContains('"label":"Option 2","price":"5","oldPrice":"5","products":[', $body); + $this->assertContains('"basePrice":"100","oldPrice":"100","productId":"1","chooseText":"Choose an Option..."', + $body); + } } 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 756cff856d1cf..570c9abb8a67c 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php @@ -277,7 +277,7 @@ public function testSetBillingAddressValidationErrors() try { $this->_model->createOrder(); $this->fail('Validation errors are expected to lead to exception during createOrder() call.'); - } catch (\Magento\Core\Exception $e) { + } catch (\Magento\Model\Exception $e) { /** createOrder is expected to throw exception with empty message when validation error occurs */ } $errorMessages = array(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php index 70a54bcff6d2b..940cf587a4e6f 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php @@ -33,12 +33,10 @@ class CreditmemoTest extends \PHPUnit_Framework_TestCase */ public function testSendEmail() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); - $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Order'); $order->loadByIncrementId('100000001'); $order->setCustomerEmail('customer@example.com'); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/InvoiceTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/InvoiceTest.php index 45e8f74f42140..cb747bc161a77 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/InvoiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/InvoiceTest.php @@ -33,12 +33,10 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase */ public function testSendEmail() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); - $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Order'); $order->loadByIncrementId('100000001'); $order->setCustomerEmail('customer@example.com'); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/OrderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/OrderTest.php index 986e00ea29289..fc2f3d6342df3 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/OrderTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/OrderTest.php @@ -33,12 +33,10 @@ class OrderTest extends \PHPUnit_Framework_TestCase */ public function testSendNewOrderEmail() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); - $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Order'); $order->loadByIncrementId('100000001'); $order->setCustomerEmail('customer@example.com'); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice.php b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice.php index a64957bf7cfc6..5cb6328ae1b0d 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice.php @@ -34,7 +34,6 @@ $invoice = $orderService->prepareInvoice(); $invoice->register(); $order->setIsInProcess(true); -$transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Transaction' -); +$transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\DB\Transaction'); $transactionSave->addObject($invoice)->addObject($order)->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_fixture_store_order.php b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_fixture_store_order.php index eae3988b0f89f..4a183d932f290 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_fixture_store_order.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_fixture_store_order.php @@ -34,7 +34,6 @@ $invoice = $orderService->prepareInvoice(); $invoice->register(); $order->setIsInProcess(true); -$transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Transaction' -); +$transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\DB\Transaction'); $transactionSave->addObject($invoice)->addObject($order)->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_payflowpro.php b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_payflowpro.php index 22519ca399d59..74104e8bfbacc 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_payflowpro.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_payflowpro.php @@ -35,7 +35,6 @@ /** To allow invoice cancelling it should be created without capturing. */ $invoice->setRequestedCaptureCase(\Magento\Sales\Model\Order\Invoice::NOT_CAPTURE)->register(); $order->setIsInProcess(true); -$transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Transaction' -); +$transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\DB\Transaction'); $transactionSave->addObject($invoice)->addObject($order)->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php index 229758d86870b..cdfa0326eb981 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php @@ -25,11 +25,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE -); +\Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); @@ -136,13 +133,10 @@ $creditmemo->register(); $creditmemo->save(); -$transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Transaction' -)->addObject( - $creditmemo -)->addObject( - $creditmemo->getOrder() -); +$transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\DB\Transaction') + ->addObject($creditmemo) + ->addObject($creditmemo->getOrder()); if ($creditmemo->getInvoice()) { $transactionSave->addObject($creditmemo->getInvoice()); } diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_saved_cc.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_saved_cc.php index 4342c567bd868..51e48d41f0bea 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_saved_cc.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_saved_cc.php @@ -25,9 +25,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var \Magento\Core\Model\App $app */ -$app = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App'); -$app->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); +\Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $addressData = include __DIR__ . '/address_data.php'; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php index d1e5c8066758b..da673e38d43a0 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php @@ -24,7 +24,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) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')->loadArea('frontend'); +\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend'); $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); $product->setTypeId( 'simple' diff --git a/dev/tests/integration/testsuite/Magento/Tax/Block/Adminhtml/Rate/ImportExportTest.php b/dev/tests/integration/testsuite/Magento/Tax/Block/Adminhtml/Rate/ImportExportTest.php index 8cb1e7b6e990d..b88a6634f8d5b 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Block/Adminhtml/Rate/ImportExportTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Block/Adminhtml/Rate/ImportExportTest.php @@ -35,16 +35,10 @@ class ImportExportTest extends \PHPUnit_Framework_TestCase protected function setUp() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); - $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\View\LayoutInterface' - )->createBlock( - 'Magento\Tax\Block\Adminhtml\Rate\ImportExport' - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface') + ->createBlock('Magento\Tax\Block\Adminhtml\Rate\ImportExport'); } protected function tearDown() diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/ClassTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/ClassTest.php index ed356b343ecec..859a109f8efe0 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/ClassTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/ClassTest.php @@ -48,7 +48,7 @@ public function testCheckClassCanBeDeletedCustomerClassAssertException() \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_CUSTOMER )->getFirstItem(); - $this->setExpectedException('Magento\Core\Exception'); + $this->setExpectedException('Magento\Model\Exception'); $model->checkClassCanBeDeleted(); } @@ -90,7 +90,7 @@ public function testCheckClassCanBeDeletedProductClassAssertException() $model->getId() )->save(); - $this->setExpectedException('Magento\Core\Exception'); + $this->setExpectedException('Magento\Model\Exception'); $model->checkClassCanBeDeleted(); } @@ -130,7 +130,7 @@ public function testCheckClassCanBeDeletedCustomerClassUsedInTaxRule() /** @var $model \Magento\Tax\Model\ClassModel */ $model = $this->_objectManager->create('Magento\Tax\Model\ClassModel')->load($customerClasses[0]); $this->setExpectedException( - 'Magento\Core\Exception', + 'Magento\Model\Exception', 'You cannot delete this tax class because it is used in' . ' Tax Rules. You have to delete the rules it is used in first.' ); @@ -152,7 +152,7 @@ public function testCheckClassCanBeDeletedProductClassUsedInTaxRule() /** @var $model \Magento\Tax\Model\ClassModel */ $model = $this->_objectManager->create('Magento\Tax\Model\ClassModel')->load($productClasses[0]); $this->setExpectedException( - 'Magento\Core\Exception', + 'Magento\Model\Exception', 'You cannot delete this tax class because it is used in' . ' Tax Rules. You have to delete the rules it is used in first.' ); diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/CsvImportHandlerTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/CsvImportHandlerTest.php index 1978887042cc9..184bd170800c8 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/CsvImportHandlerTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/CsvImportHandlerTest.php @@ -75,7 +75,7 @@ public function testImportFromCsvFileWithCorrectData() /** * @magentoDbIsolation enabled - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage One of the countries has invalid code. */ public function testImportFromCsvFileThrowsExceptionWhenCountryCodeIsInvalid() diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Resource/Calculation/Rule/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/Resource/Calculation/Rule/CollectionTest.php index c0b86b6098968..add9eae9b65bd 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/Resource/Calculation/Rule/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/Resource/Calculation/Rule/CollectionTest.php @@ -73,7 +73,7 @@ public function setClassTypeFilterDataProvider() /** * Test setClassTypeFilter with wrong Class Type * - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testSetClassTypeFilterWithWrongType() { diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/TaxClass/Type/CustomerTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/TaxClass/Type/CustomerTest.php index c7a9487896876..fa9b2a2413ecd 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/TaxClass/Type/CustomerTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/TaxClass/Type/CustomerTest.php @@ -58,7 +58,7 @@ public function testGetAssignedToObjects() /** @var $model \Magento\Tax\Model\TaxClass\Type\Customer */ $model = $this->_objectManager->create('Magento\Tax\Model\TaxClass\Type\Customer'); $model->setId(self::TAX_CLASS_ID); - /** @var $collection \Magento\Core\Model\Resource\Db\Collection\AbstractCollection */ + /** @var $collection \Magento\Model\Resource\Db\Collection\AbstractCollection */ $collection = $model->getAssignedToObjects(); $this->assertEquals(self::TAX_CLASS_ID, $collection->getFirstItem()->getData('tax_class_id')); $this->assertEquals(self::GROUP_CODE, $collection->getFirstItem()->getData('customer_group_code')); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php index 342ae4db75a7a..6a86defe013cb 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php @@ -57,9 +57,7 @@ function ($module, $class, $area) { \Magento\Customer\Model\Group::NOT_LOGGED_IN_ID, \Magento\Customer\Model\Group::NOT_LOGGED_IN_ID ); - /** @var \Magento\Core\Model\App $app */ - $app = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App'); - $app->loadArea($area); + \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea($area); $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create($class); $this->assertNotNull($block); @@ -145,13 +143,11 @@ private function _addBlock($module, $blockClass, $class, $templateBlocks) ) { $area = 'adminhtml'; } - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG - ); - $templateBlocks[$module . ', ' . $blockClass . ', ' . $area] = array($module, $blockClass, $area); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); + $templateBlocks[$module . ', ' . $blockClass . ', ' . $area] + = array($module, $blockClass, $area); return $templateBlocks; } } diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/LayoutFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/LayoutFilesTest.php index 83a956a9c77f4..cecd3f6f219a1 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/LayoutFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/LayoutFilesTest.php @@ -49,7 +49,7 @@ protected function setUp() */ public function testLayoutArguments($area, $layoutFile) { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')->loadArea($area); + \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea($area); $dom = new \DOMDocument(); $dom->load($layoutFile); $xpath = new \DOMXPath($dom); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php index 6d2639cc8233f..7094313503b71 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php @@ -106,12 +106,9 @@ public function allTemplatesDataProvider() $area = 'adminhtml'; } - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadAreaPart( - $area, - \Magento\Core\Model\App\Area::PART_CONFIG - ); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea($area) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Config\ScopeInterface') ->setCurrentScope($area); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ViewFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ViewFilesTest.php index 1cc5cbfe1b042..158eba67b8cbf 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ViewFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ViewFilesTest.php @@ -37,19 +37,14 @@ public function testViewFilesFromModulesView() * @param string $file */ function ($application, $file) { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - $application - ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\View\DesignInterface' - )->setDefaultDesignTheme(); - $result = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\View\FileSystem' - )->getViewFile( - $file - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea($application); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\View\DesignInterface') + ->setDefaultDesignTheme(); + $result = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\View\FileSystem') + ->getViewFile($file); $this->assertFileExists($result); }, $this->viewFilesFromModulesViewDataProvider() diff --git a/dev/tests/integration/testsuite/Magento/Translate/InlineTest.php b/dev/tests/integration/testsuite/Magento/Translate/InlineTest.php index 78de4a3d734ef..5b542f6c50714 100644 --- a/dev/tests/integration/testsuite/Magento/Translate/InlineTest.php +++ b/dev/tests/integration/testsuite/Magento/Translate/InlineTest.php @@ -35,6 +35,11 @@ class InlineTest extends \PHPUnit_Framework_TestCase */ protected $_storeId = 'default'; + /** + * @var \Magento\Translate\Inline\StateInterface + */ + protected $state; + public static function setUpBeforeClass() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\State')->setAreaCode('frontend'); @@ -50,6 +55,9 @@ protected function setUp() $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Translate\Inline' ); + $this->state = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + 'Magento\Translate\Inline\StateInterface' + ); /* Called getConfig as workaround for setConfig bug */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Core\Model\StoreManagerInterface' @@ -81,7 +89,7 @@ public function testIsAllowed() ) ) ); - $this->_model->disable(); + $this->state->suspend(); $this->assertFalse($this->_model->isAllowed()); $this->assertFalse($this->_model->isAllowed($this->_storeId)); $this->assertFalse( diff --git a/dev/tests/integration/testsuite/Magento/Translate/_files/_inline_page_expected.html b/dev/tests/integration/testsuite/Magento/Translate/_files/_inline_page_expected.html index 979aa22786d5a..a031b1ee3228e 100644 --- a/dev/tests/integration/testsuite/Magento/Translate/_files/_inline_page_expected.html +++ b/dev/tests/integration/testsuite/Magento/Translate/_files/_inline_page_expected.html @@ -43,7 +43,7 @@ (function($){ $(document).ready(function() { $(this).translateInline({ - ajaxUrl: 'http://localhost/index.php/core/ajax/translate/', + ajaxUrl: 'http://localhost/index.php/translation/ajax/index/', area: 'frontend', editTrigger: {img: 'http://localhost/pub/media/theme/static/frontend/{{design_package}}/default/en_US/Magento_Core/fam_book_open.png'} }); diff --git a/dev/tests/integration/testsuite/Magento/TranslateTest.php b/dev/tests/integration/testsuite/Magento/TranslateTest.php index 7f066d9f7aa06..0ad27a46c0c86 100644 --- a/dev/tests/integration/testsuite/Magento/TranslateTest.php +++ b/dev/tests/integration/testsuite/Magento/TranslateTest.php @@ -48,18 +48,6 @@ class TranslateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $pathChunks = array( - __DIR__, - 'Core', - 'Model', - '_files', - 'design', - 'frontend', - 'test_default', - 'i18n', - 'en_US.csv' - ); - $this->_viewFileSystem = $this->getMock( 'Magento\View\FileSystem', array('getFilename', 'getDesignTheme'), @@ -68,13 +56,12 @@ protected function setUp() false ); - $this->_viewFileSystem->expects( - $this->any() - )->method( - 'getFilename' - )->will( - $this->returnValue(implode('/', $pathChunks)) - ); + $this->_viewFileSystem->expects($this->any()) + ->method( + 'getFilename' + )->will( + $this->returnValue(__DIR__ . '/Core/Model/_files/design/frontend/test_default/i18n/en_US.csv') + ); $theme = $this->getMock('\Magento\View\Design\ThemeInterface', array()); $theme->expects($this->any())->method('getId')->will($this->returnValue(10)); @@ -110,37 +97,38 @@ protected function setUp() $objectManager->addSharedInstance($this->_designModel, 'Magento\Core\Model\View\Design\Proxy'); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Translate'); - $this->_model->init(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $objectManager->addSharedInstance($this->_model, 'Magento\Translate'); + $objectManager->removeSharedInstance('Magento\Phrase\Renderer\Composite'); + $objectManager->removeSharedInstance('Magento\Phrase\Renderer\Translate'); + \Magento\Phrase::setRenderer($objectManager->get('Magento\Phrase\RendererInterface')); + $this->_model->loadData(\Magento\Core\Model\App\Area::AREA_FRONTEND); } /** - * @magentoDataFixture Magento/Core/_files/db_translate.php + * @magentoDataFixture Magento/Translation/_files/db_translate.php * @magentoDataFixture Magento/Backend/controllers/_files/cache/all_types_enabled.php * @covers \Magento\Backend\Model\Resource\Translate::_getStoreId * @covers \Magento\Backend\Model\Resource\Translate\String::_getStoreId */ - public function testInitCaching() + public function testLoadDataCaching() { - // ensure string translation is cached - $this->_model->init(\Magento\Core\Model\App\Area::AREA_FRONTEND, null); - - /** @var \Magento\Core\Model\Resource\Translate\String $translateString */ + /** @var \Magento\Translation\Model\Resource\String $translateString */ $translateString = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Translate\String' + 'Magento\Translation\Model\Resource\String' ); $translateString->saveTranslate('Fixture String', 'New Db Translation'); - $this->_model->init(\Magento\Core\Model\App\Area::AREA_FRONTEND, null); + $this->_model->loadData(\Magento\Core\Model\App\Area::AREA_FRONTEND); $this->assertEquals( - 'Fixture Db Translation', - $this->_model->translate(array('Fixture String')), + 'Fixture Db Translation', + __('Fixture String'), 'Translation is expected to be cached' ); - $this->_model->init(\Magento\Core\Model\App\Area::AREA_FRONTEND, null, true); + $this->_model->loadData(\Magento\Core\Model\App\Area::AREA_FRONTEND, true); $this->assertEquals( - 'New Db Translation', - $this->_model->translate(array('Fixture String')), + 'New Db Translation', + __('Fixture String'), 'Forced load should not use cache' ); } @@ -151,10 +139,7 @@ public function testInitCaching() */ public function testTranslate($inputText, $expectedTranslation) { - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Translate'); - $this->_model->init(\Magento\Core\Model\App\Area::AREA_FRONTEND); - - $actualTranslation = $this->_model->translate(array($inputText)); + $actualTranslation = __($inputText); $this->assertEquals($expectedTranslation, $actualTranslation); } @@ -170,11 +155,4 @@ public function translateDataProvider() array('Design value to translate', 'Design translated value') ); } - - public function testGetSetTranslateInline() - { - $this->assertEquals(true, $this->_model->getTranslateInline()); - $this->_model->setTranslateInline(false); - $this->assertEquals(false, $this->_model->getTranslateInline()); - } } diff --git a/dev/tests/integration/testsuite/Magento/Core/Controller/AjaxTest.php b/dev/tests/integration/testsuite/Magento/Translation/Controller/AjaxTest.php similarity index 79% rename from dev/tests/integration/testsuite/Magento/Core/Controller/AjaxTest.php rename to dev/tests/integration/testsuite/Magento/Translation/Controller/AjaxTest.php index 17fa32f5b2721..385dc44315ee2 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Controller/AjaxTest.php +++ b/dev/tests/integration/testsuite/Magento/Translation/Controller/AjaxTest.php @@ -18,27 +18,25 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core - * @subpackage integration_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Controller; + +namespace Magento\Translation\Controller; class AjaxTest extends \Magento\TestFramework\TestCase\AbstractController { /** - * @dataProvider translateActionDataProvider + * @dataProvider indexActionDataProvider */ - public function testTranslateAction($postData) + public function testIndexAction($postData) { $this->getRequest()->setPost('translate', $postData); - $this->dispatch('core/ajax/translate'); + $this->dispatch('translation/ajax/index'); $this->assertEquals('{success:true}', $this->getResponse()->getBody()); } - public function translateActionDataProvider() + public function indexActionDataProvider() { return array(array('test'), array(array('test'))); } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/InlineParserTest.php b/dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/Core/Model/Translate/InlineParserTest.php rename to dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php index dab5c946478cc..5211f3c32c7d3 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/InlineParserTest.php +++ b/dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php @@ -18,18 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core - * @subpackage integration_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Translate; + +namespace Magento\Translation\Model; class InlineParserTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Translate\Inline\Parser + * @var \Magento\Translation\Model\Inline\Parser */ protected $_inlineParser; @@ -48,9 +46,10 @@ public static function setUpBeforeClass() protected function setUp() { /** @var $inline \Magento\Translate\Inline */ - $inline = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Translate\Inline'); + $inline = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Translate\Inline'); $this->_inlineParser = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Translate\Inline\Parser', + 'Magento\Translation\Model\Inline\Parser', array('translateInline' => $inline) ); /* Called getConfig as workaround for setConfig bug */ @@ -83,7 +82,7 @@ public function testProcessAjaxPost($originalText, $translatedText, $isPerStore $this->_inlineParser->processAjaxPost($inputArray); $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Translate\String' + 'Magento\Translation\Model\String' ); $model->load($originalText); try { diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/StringTest.php b/dev/tests/integration/testsuite/Magento/Translation/Model/StringTest.php similarity index 81% rename from dev/tests/integration/testsuite/Magento/Core/Model/Translate/StringTest.php rename to dev/tests/integration/testsuite/Magento/Translation/Model/StringTest.php index a8c7d53497fa9..1703515679b18 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/StringTest.php +++ b/dev/tests/integration/testsuite/Magento/Translation/Model/StringTest.php @@ -18,31 +18,29 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core - * @subpackage integration_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Translate; + +namespace Magento\Translation\Model; class StringTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Translate\String + * @var \Magento\Translation\Model\String */ protected $_model; protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Translate\String' + 'Magento\Translation\Model\String' ); } public function testConstructor() { - $this->assertInstanceOf('Magento\Core\Model\Resource\Translate\String', $this->_model->getResource()); + $this->assertInstanceOf('Magento\Translation\Model\Resource\String', $this->_model->getResource()); } public function testSetGetString() diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/db_translate.php b/dev/tests/integration/testsuite/Magento/Translation/_files/db_translate.php similarity index 89% rename from dev/tests/integration/testsuite/Magento/Core/_files/db_translate.php rename to dev/tests/integration/testsuite/Magento/Translation/_files/db_translate.php index f8a7fd6458e5d..97239d9ff2aae 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/db_translate.php +++ b/dev/tests/integration/testsuite/Magento/Translation/_files/db_translate.php @@ -22,8 +22,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var \Magento\Core\Model\Resource\Translate\String $translateString */ +/** @var \Magento\Translation\Model\Resource\String $translateString */ $translateString = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Translate\String' + 'Magento\Translation\Model\Resource\String' ); $translateString->saveTranslate('Fixture String', 'Fixture Db Translation'); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/db_translate_admin_store.php b/dev/tests/integration/testsuite/Magento/Translation/_files/db_translate_admin_store.php similarity index 84% rename from dev/tests/integration/testsuite/Magento/Core/_files/db_translate_admin_store.php rename to dev/tests/integration/testsuite/Magento/Translation/_files/db_translate_admin_store.php index 8007a6d477674..51ef0a7601d8a 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/db_translate_admin_store.php +++ b/dev/tests/integration/testsuite/Magento/Translation/_files/db_translate_admin_store.php @@ -23,13 +23,14 @@ */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, + 'Magento\App\AreaList' +)->getArea( + \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE +)->load( \Magento\Core\Model\App\Area::PART_CONFIG ); -/** @var \Magento\Core\Model\Resource\Translate\String $translateString */ +/** @var \Magento\Translation\Model\Resource\String $translateString */ $translateString = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Translate\String' + 'Magento\Translation\Model\Resource\String' ); $translateString->saveTranslate('string to translate', 'predefined string translation', null); diff --git a/dev/tests/integration/testsuite/Magento/UrlTest.php b/dev/tests/integration/testsuite/Magento/UrlTest.php index c6a2dcd29566c..ea0b91fd9b61e 100644 --- a/dev/tests/integration/testsuite/Magento/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlTest.php @@ -102,15 +102,14 @@ public function testGetBaseUrlConfigured($params, $expectedUrl) public function testGetBaseUrlWithTypeRestoring() { /** - * Get base ull with default type + * Get base URL with default type */ $this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url'); /** * Set specified type */ - $this->_model->setType(\Magento\UrlInterface::URL_TYPE_WEB); - $webUrl = $this->_model->getBaseUrl(); + $webUrl = $this->_model->getBaseUrl(['_type' => \Magento\UrlInterface::URL_TYPE_WEB]); $this->assertEquals('http://localhost/', $webUrl, 'Incorrect web url'); $this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url'); diff --git a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php index b1a03217d4426..7c7254b3f6ea2 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php @@ -184,10 +184,8 @@ public function testRoleUserExists() public function testGetCollection() { - $this->assertInstanceOf( - 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection', - $this->_model->getCollection() - ); + $this->assertInstanceOf('Magento\Model\Resource\Db\Collection\AbstractCollection', + $this->_model->getCollection()); } public function testGetName() @@ -313,7 +311,7 @@ public function testHasAssigned2Role() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage User Name is a required field. * @expectedExceptionMessage First Name is a required field. * @expectedExceptionMessage Last Name is a required field. @@ -363,7 +361,7 @@ public function testBeforeSavePasswordHash() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Your password confirmation must match your password. * @magentoDbIsolation enabled */ @@ -375,7 +373,7 @@ public function testBeforeSavePasswordsDoNotMatch() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Your password must include both numeric and alphabetic characters. * @magentoDbIsolation enabled */ @@ -387,7 +385,7 @@ public function testBeforeSavePasswordTooShort() /** * @dataProvider beforeSavePasswordInsecureDataProvider - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Your password must include both numeric and alphabetic characters. * @magentoDbIsolation enabled * @param string $password @@ -404,7 +402,7 @@ public function beforeSavePasswordInsecureDataProvider() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage A user with the same user name or email already exists. * @magentoDbIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Magento/User/_files/dummy_user.php b/dev/tests/integration/testsuite/Magento/User/_files/dummy_user.php index 25980f5aca0e4..0c3b7f65e03b5 100644 --- a/dev/tests/integration/testsuite/Magento/User/_files/dummy_user.php +++ b/dev/tests/integration/testsuite/Magento/User/_files/dummy_user.php @@ -28,11 +28,9 @@ /** * Create dummy user */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE -); + +\Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\User'); $user->setFirstname( 'Dummy' @@ -47,11 +45,8 @@ )->save(); -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE -); +\Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\User'); $user->setFirstname( 'CreateDate' diff --git a/dev/tests/integration/testsuite/Magento/View/Design/Theme/ValidatorTest.php b/dev/tests/integration/testsuite/Magento/View/Design/Theme/ValidatorTest.php index ecd6c253aa646..7cf081f70b4a1 100644 --- a/dev/tests/integration/testsuite/Magento/View/Design/Theme/ValidatorTest.php +++ b/dev/tests/integration/testsuite/Magento/View/Design/Theme/ValidatorTest.php @@ -67,7 +67,7 @@ public function testValidateWithInvalidData() /** * Get theme model * - * @return \Magento\Core\Model\AbstractModel + * @return \Magento\Model\AbstractModel */ protected function _getThemeModel() { diff --git a/dev/tests/integration/testsuite/Magento/View/PublicationTest.php b/dev/tests/integration/testsuite/Magento/View/PublicationTest.php index d9bea1241e3d0..6713a818d9095 100644 --- a/dev/tests/integration/testsuite/Magento/View/PublicationTest.php +++ b/dev/tests/integration/testsuite/Magento/View/PublicationTest.php @@ -358,7 +358,8 @@ public function testPublishCssFileFromModule( ) ); - $objectManager->get('Magento\Core\Model\App')->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); $this->viewUrl->getViewFileUrl($cssViewFile, $designParams); @@ -643,12 +644,9 @@ public function testCssWithBase64Data() ) ) ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG - ); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); /** @var $themeCollection \Magento\Core\Model\Theme\Collection */ $themeCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( diff --git a/dev/tests/integration/testsuite/Magento/View/_files/design/themes.php b/dev/tests/integration/testsuite/Magento/View/_files/design/themes.php index 6f40f04a19c81..707147d3a095f 100644 --- a/dev/tests/integration/testsuite/Magento/View/_files/design/themes.php +++ b/dev/tests/integration/testsuite/Magento/View/_files/design/themes.php @@ -24,15 +24,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) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG -); -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure( - array('preferences' => array('Magento\Core\Model\Theme' => 'Magento\Core\Model\Theme\Data')) -); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure(array( + 'preferences' => array( + 'Magento\Core\Model\Theme' => 'Magento\Core\Model\Theme\Data' + ) +)); /** @var $registration \Magento\Core\Model\Theme\Registration */ $registration = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Core\Model\Theme\Registration' diff --git a/dev/tests/integration/testsuite/Magento/Widget/Model/WidgetTest.php b/dev/tests/integration/testsuite/Magento/Widget/Model/WidgetTest.php index 8a08c25000689..03e3128ec5e54 100644 --- a/dev/tests/integration/testsuite/Magento/Widget/Model/WidgetTest.php +++ b/dev/tests/integration/testsuite/Magento/Widget/Model/WidgetTest.php @@ -69,11 +69,8 @@ public function testGetPlaceholderImageUrl($type, $expectedFile) ' "new_products" widget in Catalog module' ); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $objectManager->get('Magento\View\DesignInterface')->setDesignTheme('magento_backend'); $expectedFilePath = "/adminhtml/magento_backend/en_US/{$expectedFile}"; $expectedPubFile = $objectManager->get( diff --git a/dev/tests/integration/testsuite/Magento/Widget/_files/themes.php b/dev/tests/integration/testsuite/Magento/Widget/_files/themes.php index 4e456f4493afa..34815b00ba925 100644 --- a/dev/tests/integration/testsuite/Magento/Widget/_files/themes.php +++ b/dev/tests/integration/testsuite/Magento/Widget/_files/themes.php @@ -24,12 +24,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) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' -)->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, - \Magento\Core\Model\App\Area::PART_CONFIG -); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\AreaList') + ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) + ->load(\Magento\Core\Model\App\Area::PART_CONFIG); /** @var $registration \Magento\Core\Model\Theme\Registration */ $registration = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Core\Model\Theme\Registration' diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Block/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Block/AbstractTest.php index 3a50eb0137767..eee2825692a56 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/Block/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/Block/AbstractTest.php @@ -37,19 +37,9 @@ protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_block = $this->getMockForAbstractClass( - 'Magento\Wishlist\Block\AbstractBlock', + 'Magento\Wishlist\Block\AbstractBlock', array( - $objectManager->get('Magento\View\Element\Template\Context'), - $objectManager->get('Magento\Catalog\Model\Config'), - $objectManager->get('Magento\Registry'), - $objectManager->get('Magento\Tax\Helper\Data'), - $objectManager->get('Magento\Catalog\Helper\Data'), - $objectManager->get('Magento\Math\Random'), - $objectManager->get('Magento\Checkout\Helper\Cart'), - $objectManager->get('Magento\Wishlist\Helper\Data'), - $objectManager->get('Magento\Catalog\Helper\Product\Compare'), - $objectManager->get('Magento\Theme\Helper\Layout'), - $objectManager->get('Magento\Catalog\Helper\Image'), + $objectManager->get('Magento\Catalog\Block\Product\Context'), $objectManager->get('Magento\App\Http\Context'), $objectManager->get('Magento\Catalog\Model\ProductFactory'), ) @@ -62,17 +52,12 @@ protected function setUp() */ public function testImage() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\App' - )->loadArea( - \Magento\Core\Model\App\Area::AREA_FRONTEND - ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\View\DesignInterface' - )->setDefaultDesignTheme(); - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\Product' - ); + \Magento\TestFramework\Helper\Bootstrap::getInstance() + ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\DesignInterface') + ->setDefaultDesignTheme(); + $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); $product->load(1); $size = $this->_block->getImageSize(); diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist.php b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist.php index 3b030637ca0a4..4051cf223e6f7 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist.php @@ -29,7 +29,7 @@ require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php'; $wishlist = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Wishlist\Model\Wishlist'); -$wishlist->loadByCustomer($customer->getId(), true); +$wishlist->loadByCustomerId($customer->getId(), true); $item = $wishlist->addNewItem($product, new \Magento\Object(array())); // 'product' => '1', // 'related_product' => '', diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_increments.php b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_increments.php index 15820eb08e36c..8ad43321ad96a 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_increments.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_increments.php @@ -37,6 +37,6 @@ /** @var \Magento\Wishlist\Model\Wishlist $wishlist */ $wishlist = $objectManager->create('Magento\Wishlist\Model\Wishlist'); -$wishlist->loadByCustomer($customer->getId(), true); +$wishlist->loadByCustomerId($customer->getId(), true); $wishlist->addNewItem($product); $wishlist->save(); diff --git a/dev/tests/performance/framework/Magento/TestFramework/Application.php b/dev/tests/performance/framework/Magento/TestFramework/Application.php index d47b31f0d3980..1485f25356638 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Application.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Application.php @@ -43,13 +43,6 @@ class Application */ protected $_config; - /** - * Application object - * - * @var \Magento\Core\Model\App - */ - protected $_application; - /** * Path to shell installer script * @@ -211,8 +204,6 @@ protected function _updateFilesystemPermissions() */ protected function _bootstrap() { - /** @var $app \Magento\Core\Model\App */ - $this->_application = $this->getObjectManager()->get('Magento\Core\Model\App'); $this->getObjectManager()->configure( $this->getObjectManager()->get('Magento\App\ObjectManager\ConfigLoader')->load(self::AREA_CODE) ); diff --git a/dev/tests/performance/testsuite/home_page.jmx b/dev/tests/performance/testsuite/home_page.jmx index eb502c8233e4a..1c3a9155c3ec0 100644 --- a/dev/tests/performance/testsuite/home_page.jmx +++ b/dev/tests/performance/testsuite/home_page.jmx @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + @@ -63,7 +63,7 @@ - + @@ -79,14 +79,15 @@ false true false + Java false - + <title>Home page</title> - <h2>Home Page</h2> + <h1 class="title"><span class="base" data-ui-id="page-title" >Home Page</span></h1> Assertion.response_data false diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Library/_files/blacklist.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/Library/_files/blacklist.txt index 09c097335f2a1..2796e1b0d7f2d 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Library/_files/blacklist.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Library/_files/blacklist.txt @@ -62,7 +62,6 @@ lib/Magento/App/Module/ResourceResolver.php lib/Magento/Event/Invoker/InvokerDefault.php lib/Magento/Phrase/Renderer/Translate.php lib/Magento/Backup/Snapshot.php -lib/Magento/Outbound/Authentication/Hmac.php lib/Magento/Oauth/Exception.php lib/Magento/App/Helper/AbstractHelper.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 index c62d65bccd589..b8dc7df584403 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/classes/blacklist.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/classes/blacklist.txt @@ -16,8 +16,8 @@ \Magento\Core\Model\Config\FileResolver \Magento\Core\Model\Config\Cache \Magento\Core\Model\Config\Base -\Magento\Core\Model\Translate\String -\Magento\Core\Model\Translate\Inline\Config -\Magento\Core\Model\Translate\Inline\Parser +\Magento\Translation\Model\String +\Magento\Translation\Model\Inline\Config +\Magento\Translation\Model\Inline\Parser \Magento\Translate \Magento\Email\Model\Template diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php index 1ad2e08bf7dbe..de6e42f208ebe 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php @@ -332,6 +332,7 @@ 'tax_class' => 'Magento_Tax', 'tax_order_aggregated_created' => 'Magento_Tax', 'tax_order_aggregated_updated' => 'Magento_Tax', + 'translation' => 'Magento_Translation', 'weee_discount' => 'Magento_Weee', 'weee_tax' => 'Magento_Weee', 'widget' => 'Magento_Widget', 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 e8f9d28826980..1766f231afb5c 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 @@ -793,9 +793,26 @@ array('Mage_Core_Model_Config_System'), array('Mage_Core_Model_Design_Source_Apply'), array('Mage_Core_Model_Language'), + array('Magento\Core\Model\Flag', 'Magento\Flag'), + array('Magento\Core\Exception', 'Magento\Model\Exception'), + array('Magento\Core\Model\AbstractModel', 'Magento\Model\AbstractModel'), array('Magento\Core\Model\Email\Info', 'Magento\Mail\MessageInterface'), array('Magento\Core\Model\Email\Sender', 'Magento\Mail\Template\TransportBuilder'), array('Magento\Core\Model\Email\Template\Mailer', 'Magento\Mail\Template\TransportBuilder'), + array('Magento\Core\Model\Resource\AbstractResource', 'Magento\Model\Resource\AbstractResource'), + array('Magento\Core\Model\Resource\Db\AbstractDb', 'Magento\Model\Resource\Db\AbstractDb'), + array('Magento\Core\Model\Resource\Db\Profiler', 'Magento\Model\Resource\Db\Profiler'), + array('Magento\Core\Model\Resource\Entity\AbstractEntity', 'Magento\Model\Resource\Entity\AbstractEntity'), + array('Magento\Core\Model\Resource\Entity\Table', 'Magento\Model\Resource\Entity\Table'), + array('Magento\Core\Model\Resource\Flag', 'Magento\Flag\Resource'), + array('Magento\Core\Model\Resource\Iterator', 'Magento\Model\Resource\Iterator'), + array('Magento\Core\Model\Resource\Type\AbstractType', 'Magento\Model\Resource\Type\AbstractType'), + array('Magento\Core\Model\Resource\Type\Db', 'Magento\Model\Resource\Type\Db'), + array('Magento\Core\Model\Resource\Type\Db\Pdo\Mysql', 'Magento\Model\Resource\Type\Db\Pdo\Mysql'), + array( + 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection', + 'Magento\Model\Resource\Db\Collection\AbstractCollection' + ), array('Magento\Email\Model\Info', 'Magento\Mail\MessageInterface'), array('Magento\Email\Model\Sender', 'Magento\Mail\Template\TransportBuilder'), array('Magento\Email\Model\Template\Mailer', 'Magento\Mail\Template\TransportBuilder'), @@ -1260,7 +1277,12 @@ ), array('Magento\Sales\Model\ResourceFactory'), array('Magento\Sales\Model\Resource\Helper\Mysql4', 'Magento\Sales\Model\Resource\Helper'), - array('Magento\Core\Model\Resource\Helper\Mysql4', 'Magento\Core\Model\Resource\Helper'), + array('Magento\Core\Model\Resource\Helper\Mysql4', 'Magento\DB\Helper'), + array('Magento\Core\Model\Resource\Helper', 'Magento\DB\Helper'), + array('Magento\Core\Model\Resource\Helper\AbstractHelper', 'Magento\DB\Helper\AbstractHelper'), + array('Magento\Core\Model\Resource\HelperFactory'), + array('Magento\Core\Model\Resource\HelperPool'), + array('Magento\Core\Model\Resource\Transaction', 'Magento\DB\Transaction'), array('Magento\Catalog\Model\Resource\Helper\Mysql4', 'Magento\Catalog\Model\Resource\Helper'), array('Magento\Eav\Model\Resource\Helper\Mysql4', 'Magento\Eav\Model\Resource\Helper'), array( @@ -1320,6 +1342,7 @@ array('Magento\Core\Model\ModuleListInterface'), array('Magento\Core\Model\RouterList'), array('Magento\Core\Model\App\State'), + array('Magento\Core\Model\App'), array('Magento\Core\Model\Event\Config\Converter'), array('Magento\Core\Model\Event\Config\Data'), array('Magento\Core\Model\Event\Config\Reader'), @@ -2103,5 +2126,43 @@ array('Magento\Catalog\Helper\Product\Url', 'Magento\Filter\Translit'), array('Magento\Catalog\Model\Product\Indexer\Price'), array('Magento\Catalog\Model\Resource\Product\Indexer\Price'), - array('Magento\Indexer\Model\Processor\CacheInvalidate', 'Magento\Indexer\Model\Processor\InvalidateCache') + ['Magento\PubSub'], // unused library code which was removed + ['Magento\Outbound'], // unused library code which was removed + array('Magento\Indexer\Model\Processor\CacheInvalidate', 'Magento\Indexer\Model\Processor\InvalidateCache'), + array( + 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Reviews', + 'Magento\Review\Block\Adminhtml\Product\Edit\Tab\Reviews' + ), + array( + 'Magento\Catalog\Controller\Adminhtml\Product\Review', + 'Magento\Review\Controller\Adminhtml\Product' + ), + array( + 'Magento\Review\Block\Helper', + 'Magento\Review\Block\Product\ReviewRenderer' + ), + array( + 'Magento\LauncherInterface', + 'Magento\AppInterface', + ), + array('Magento\Convert\ConvertException'), + array('Magento\Convert\Container\AbstractContainer'), + array('Magento\Convert\Mapper\Column'), + array('Magento\Convert\Mapper\MapperInterface'), + ['Magento\Core\Controller\Ajax', 'Magento\Translation\Controller\Ajax'], + ['Magento\Core\Helper\Translate', 'Magento\Translation\Helper\Data'], + ['Magento\Core\Model\Translate\Inline\Config', 'Magento\Translation\Model\Inline\Config'], + ['Magento\Core\Model\Translate\Inline\Parser', 'Magento\Translation\Model\Inline\Parser'], + ['Magento\Core\Model\Resource\Translate\String', 'Magento\Translation\Model\Resource\String'], + ['Magento\Core\Model\Resource\Translate', 'Magento\Translation\Model\Resource\Translate'], + ['Magento\Core\Model\Translate\String', 'Magento\Translation\Model\String'], + ['Magento\Translation\Helper\Data'], + ['Magento\Translate\Factory'], + ['Magento\Backend\Model\Translate'], + ['Magento\Backend\Model\Resource\Translate'], + ['Magento\Backend\Model\Resource\Translate\String'], + ['Magento\DesignEditor\Model\Translate\InlineVde', 'Magento\DesignEditor\Model\Translate\Inline'], + ['Magento\Backend\Model\Translate\Inline'], + ['Magento\Backend\Model\Translate\Inline\ConfigFactory'], + ['Magento\Translate\Inline\ConfigFactory'], ); 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 b2fbea6609244..bddf1b0120ca4 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 @@ -34,7 +34,7 @@ array('CACHE_TAG', 'Magento\AppInterface'), array( 'CACHE_TAG', - 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection', + 'Magento\Model\Resource\Db\Collection\AbstractCollection', 'Magento_Core_Model_Cache_Type_Collection::CACHE_TAG' ), array('CACHE_TAG', 'Magento\Translate', 'Magento_Core_Model_Cache_Type_Translate::CACHE_TAG'), @@ -70,7 +70,6 @@ 'Magento_Core_Model_Config_Resource::DEFAULT_WRITE_CONNECTION' ), array('DEFAULT_CURRENCY', 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::DEFAULT_CURRENCY'), - array('DEFAULT_ERROR_HANDLER', 'Magento\Core\Model\App'), array('DEFAULT_READ_CONNECTION', 'Magento\App\Resource\Config'), array('DEFAULT_WRITE_CONNECTION', 'Magento\App\Resource\Config'), array('DEFAULT_ERROR_HANDLER', 'Mage'), @@ -593,5 +592,11 @@ 'XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY', '\Magento\Catalog\Helper\Category\Flat', '\Magento\Catalog\Model\Indexer\Category\Flat\Config::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY' - ) + ), + array('CSV_SEPARATOR', 'Magento\Translate'), + array('SCOPE_SEPARATOR', 'Magento\Translate'), + array('CONFIG_KEY_AREA', 'Magento\Translate'), + array('CONFIG_KEY_LOCALE', 'Magento\Translate'), + array('CONFIG_KEY_SCOPE', 'Magento\Translate'), + array('CONFIG_KEY_DESIGN_THEME', 'Magento\Translate'), ); 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 93d322e683d60..762f6fc6c6c71 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 @@ -32,7 +32,7 @@ array('_addLink', 'Magento\Customer\Block\Account\Link'), array('_addMinimalPrice', 'Magento\Catalog\Model\Resource\Product\Collection'), array('_addTaxPercents', 'Magento\Catalog\Model\Resource\Product\Collection'), - array('_afterSaveCommit', 'Magento\Core\Model\AbstractModel'), + array('_afterSaveCommit', 'Magento\Model\AbstractModel'), array('_afterSetConfig', 'Magento\Eav\Model\Entity\AbstractEntity'), array('_aggregateByOrderCreatedAt', 'Magento\SalesRule\Model\Resource\Report\Rule'), array('_amountByCookies', 'Magento\Sendfriend\Model\Sendfriend'), @@ -51,8 +51,6 @@ array('_canShowField', 'Magento\Backend\Block\System\Config\Form'), array('_canUseCacheForInit', 'Magento\Core\Model\Config'), array('_canUseLocalModules'), - array('_checkCookieStore', 'Magento\Core\Model\App'), - array('_checkGetStore', 'Magento\Core\Model\App'), array('_checkUrlSettings', 'Magento\Backend\Controller\Adminhtml\Action'), array('_collectOrigData', 'Magento\Catalog\Model\Resource\AbstractResource'), array('_decodeInput', 'Magento\Catalog\Controller\Adminhtml\Product'), @@ -69,10 +67,8 @@ array('_getAttributeFilterBlockName', 'Magento\CatalogSearch\Block\Layer'), array('_getAvailable', 'Magento\GiftMessage\Model\Observer'), array('_getBytesIniValue', 'Magento\Catalog\Model\Product\Option\Type\File'), - array('_getCacheId', 'Magento\Core\Model\App'), array('_getCacheKey', 'Magento\Catalog\Model\Layer\Filter\Price'), array('_getCacheLockId', 'Magento\Core\Model\Config'), - array('_getCacheTags', 'Magento\Core\Model\App'), array('_getCarrier', 'Magento\Shipping\Model\Config', 'Magento\Shipping\Model\CarrierFactory::create||get'), array('_getChildHtml'), array('_getConfig', 'Magento\Theme\Helper\Layout'), @@ -112,24 +108,15 @@ array('_getSetData', 'Magento\Backend\Block\Catalog\Product\Attribute\Set\Main'), array('_getSession', 'Magento\Paygate\Model\Authorizenet', 'Magento_Paygate_Model_Authorizenet::_session'), array('_getSHAInSet', '', 'Magento_Ogone_Model_Api::getHash'), - array('_getStoreByGroup', 'Magento\Core\Model\App'), - array('_getStoreByWebsite', 'Magento\Core\Model\App'), array('_getStoreTaxRequest', 'Magento\Tax\Model\Sales\Total\Quote\Shipping'), array('_getUploadMaxFilesize', 'Magento\Catalog\Model\Product\Option\Type\File'), array('_hookQueries', 'Magento\Core\Model\Resource\Setup'), array('_importAddress', 'Magento\Paypal\Model\Api\Nvp'), array('_inheritDesign', 'Magento\Catalog\Model\Design'), - array('_initBaseConfig', 'Magento\Core\Model\App'), - array('_initCache', 'Magento\Core\Model\App'), - array('_initCurrentStore', 'Magento\Core\Model\App'), - array('_initFileSystem', 'Magento\Core\Model\App'), array('_initLayoutMessages', 'Magento\App\Action\Action'), - array('_initLogger', 'Magento\Core\Model\App'), - array('_initModules', 'Magento\Core\Model\App'), array('_initModulesPreNamespaces', 'Magento\Core\Model\Config'), array('_initOrder', 'Magento\Shipping\Block\Tracking\Popup'), array('_initShipment', 'Magento\Shipping\Block\Tracking\Popup'), - array('_initStores', 'Magento\Core\Model\App'), array('_inludeControllerClass', '', '_includeControllerClass'), array('_isApplyDesign', 'Magento\Catalog\Model\Design'), array('_isApplyFor', 'Magento\Catalog\Model\Design'), @@ -186,7 +173,6 @@ array('isInStore', 'Magento\Customer\Model\Customer'), array('_sendUploadResponse', 'Magento\Newsletter\Controller\Adminhtml\Subscriber'), array('_setAttribteValue'), - array('_shouldSkipProcessUpdates', 'Magento\Core\Model\App'), array('_sort', 'Magento\Backend\Model\Config\Structure\Converter'), array( '_submitRecurringPaymentProfiles', @@ -209,6 +195,7 @@ array('addConstraint', 'Magento\DB\Adapter\Pdo\Mysql'), array('addCss', 'Magento\Theme\Block\Html\Head'), array('addCssIe', 'Magento\Theme\Block\Html\Head'), + array('addCustomerData', 'Magento\Catalog\Model\Product\Item', 'setCustomerId'), array('addCustomersToAlertQueueAction'), array('addCustomerToSegments'), array('addHandle', 'Magento\Core\Model\Layout\Update', 'Magento\Core\Model\Layout\Merge'), @@ -270,7 +257,6 @@ array('authFailed', '', '\Magento\HTTP\Authentication::setAuthenticationFailed'), array('authFrontend'), array('authValidate', '', '\Magento\HTTP\Authentication::getCredentials'), - array('baseInit', 'Magento\Core\Model\App'), array('bundlesAction', 'Magento\Catalog\Controller\Adminhtml\Product'), array('calcTaxAmount', 'Magento\Sales\Model\Quote\Item\AbstractItem'), array('callbackQueryHook', 'Magento\Core\Model\Resource\Setup'), @@ -306,7 +292,7 @@ array('cloneIndexTable', 'Magento\Index\Model\Resource\AbstractResource'), array('collectRoutes', 'Magento\Backend\App\Router\DefaultRouter'), array('collectRoutes', 'Magento\Core\App\Router\Base'), - array('composeLocaleHierarchy', 'Magento\Core\Helper\Translate'), + array('composeLocaleHierarchy', 'Magento\Translation\Helper\Data'), array('convertOldTaxData', 'Magento\Tax\Model\Resource\Setup'), array('convertOldTreeToNew', 'Magento\Catalog\Model\Resource\Setup'), array('copyFieldset', 'Magento\Core\Helper\Data', 'copyFieldsetToTarget'), @@ -420,7 +406,6 @@ array('getHeaderText', 'Magento_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option_Search'), array('getHelperClassName', 'Magento\Core\Model\Config'), array('getHtmlFormat', 'Magento\Customer\Model\Address\AbstractAddress'), - array('getInitParam', 'Magento\Core\Model\App'), array( 'getInitParams', 'Magento\TestFramework\Bootstrap', @@ -558,6 +543,16 @@ array('getSectionNode', 'Magento\Core\Model\Config'), array('getSecure', 'Magento\Backend\Model\UrlInterface', 'isSecure'), array('getSecure', 'Magento\Url', 'isSecure'), + array('_prepareSessionUrlWithParams', 'Magento\Url'), + array('_getQueryParams', 'Magento\Url'), + array('_setRouteFrontName', 'Magento\Url'), + array('setType', 'Magento\Url'), + array('purgeQueryParams', 'Magento\Url', 'Use setQueryParams([]) instead'), + array('purgeQueryParams', 'Magento\Url\QueryParamsResolver', 'Use setQueryParams([]) instead'), + array('purgeQueryParams', 'Magento\Url\QueryParamsResolverInterface', 'Use setQueryParams([]) instead'), + array('_getDefaultActionName', 'Magento\Url', 'Magento\UrlInterface::DEFAULT_ACTION_NAME'), + array('_getDefaultControllerName', 'Magento\Url', 'Magento\UrlInterface::DEFAULT_CONTROLLER_NAME'), + array('_getDefaultUrlType', 'Magento\Url', 'Magento\UrlInterface::DEFAULT_URL_TYPE'), 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'), @@ -619,7 +614,6 @@ ), array('getUploadMaxSize', 'Magento\Backend\Block\Media\Uploader', 'Magento_File_Size::getUploadMaxSize()'), array('getUrlForReferer', 'Magento\Backend\Block\Page\Footer'), - array('getUseCacheFilename', 'Magento\Core\Model\App'), array('getValidator', 'Magento\SalesRule\Model\Observer'), array('getValidatorData', 'Magento\Core\Model\Session\AbstractSession', 'use _getSessionEnvironment method'), array('getValueTable'), @@ -645,7 +639,6 @@ array('implodeStreetAddress', 'Magento\Customer\Model\Address\AbstractAddress'), array('importFromTextArray'), array('init', 'Magento\App\FrontController'), - array('init', 'Magento\Core\Model\App'), array('init', 'Magento\Core\Model\Config'), array('init', 'Magento\Webapi\Controller\Front'), array('initCache'), @@ -654,7 +647,6 @@ array('initLayoutMessages', 'Magento\App\Action\Action'), array('initSerializerBlock', 'Magento\Backend\Block\Catalog\Product\Edit\Tab\Ajax\Serializer'), array('initSerializerBlock', 'Magento\Backend\Block\Widget\Grid\Serializer'), - array('initSpecified', 'Magento\Core\Model\App'), array('insertProductPrice', 'Magento\Catalog\Model\Resource\Product\Attribute\Backend\Tierprice'), array('isAbsolutePath'), array('isAdmin', 'Magento\Core\Model\Store'), @@ -664,7 +656,6 @@ array('isDirectOutput', 'Magento\Core\Model\Layout'), array('isDirectOutput', 'Magento\View\LayoutInterface'), array('isFulAmountCovered'), - array('isInstalled', 'Magento\Core\Model\App'), array('isLeyeredNavigationAllowed'), array('isLocalConfigLoaded', 'Magento\Core\Model\Config'), array('isModuleEnabled', 'Magento\Core\Model\Config', 'Magento_Core_Model_ModuleManager::isEnabled'), @@ -706,7 +697,6 @@ array('postDispatchSystemImportExportRun'), array('prepareAddressInfo', 'Magento\Sales\Block\Recurring\Profile\View'), array('prepareAttributesForSave', 'Magento\ImportExport\Model\Import\Entity\Product'), - array('prepareCacheId', 'Magento\Core\Model\App'), array('prepareFeesInfo', 'Magento\Sales\Block\Recurring\Profile\View'), array('prepareGoogleOptimizerScripts'), array('prepareRedirect', 'Magento\Core\Controller\Varien\Exception'), @@ -910,12 +900,9 @@ array('_getUsers', 'Magento\User\Block\Role\Grid\User', 'getUsers'), array('_getGridHtml', 'Magento\User\Block\Role\Tab\Users', 'getGridHtml'), array('_getSelectedRoles', 'Magento\User\Block\User\Edit\Tab\Roles', 'getSelectedRoles'), - array('_prepareSelect', 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection'), + array('_prepareSelect', 'Magento\Model\Resource\Db\Collection\AbstractCollection'), array('_prepareSelect', 'Magento\Data\Collection\Db'), array('_createOrderFromAddress', 'Magento\Checkout\Model\Type\AbstractType'), - array('castField', 'Magento\Core\Model\Resource\Helper'), - array('getQueryUsingAnalyticFunction', 'Magento\Core\Model\Resource\Helper'), - array('limitUnion', 'Magento\Core\Model\Resource\Helper'), array('_addLoadAttributesSelectFields', 'Magento\Catalog\Model\Resource\AbstractResource'), array('attributeSelectFields', 'Magento\Catalog\Model\Resource\Helper'), array('_addLoadAttributesSelectFields', 'Magento\Eav\Model\Entity\AbstractEntity'), @@ -955,7 +942,6 @@ array('_helper', 'Magento\Catalog\Model\Product\Type\AbstractType'), array('getHelper', 'Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute\Collection'), array('getHelper', 'Magento\Cms\Model\Wysiwyg\Images\Storage'), - array('getHelper', 'Magento\Core\Model\App'), array('getCatalogHelper', 'Magento\Backend\Block\Catalog\Category\Tabs'), array('getStabilityOptions', 'Magento\Connect\Model\Extension'), array('_getSession', 'Magento\Centinel\Model\Service'), @@ -986,10 +972,6 @@ array('turnOnSerializableMode', 'Magento\Backup\Model\Resource\Db', 'prepareTransactionIsolationLevel'), array('_getResourceModel', '\Magento\Webapi\Model\Source\Acl\Role', '$this->_resource'), array('_getSession', '\Magento\GiftMessage\Model\Save', '$this->_session'), - array('_initRequest', '\Magento\Core\Model\App'), - array('run', '\Magento\Core\Model\App'), - array('_initFrontController', '\Magento\Core\Model\App'), - array('_getFrontControllerByCurrentArea', '\Magento\Core\Model\App'), array('run', '\Magento\AppInterface'), array('setModuleDir', 'Magento\Module\Dir\Reader'), array('setModuleDir', 'Magento\Core\Model\Config'), @@ -1069,8 +1051,8 @@ array('validateIpAddr', '\Magento\Core\Helper\Http', '\Zend_Validate_Ip::isValid'), array('getRemoteAddr', '\Magento\Core\Helper\Http', 'Magento\HTTP\PhpEnvironment\RemoteAddress::getRemoteAddress'), array('getServerAddr', '\Magento\Core\Helper\Http', 'Magento\HTTP\PhpEnvironment\ServerAddress::getServerAddress'), - array('formatDate', 'Magento\Core\Model\Resource\AbstractResource', '\Magento\Stdlib\DateTime::formatDate'), - array('mktime', 'Magento\Core\Model\Resource\AbstractResource', '\Magento\Stdlib\DateTime::toTimestamp'), + array('formatDate', 'Magento\Model\Resource\AbstractResource', '\Magento\Stdlib\DateTime::formatDate'), + array('mktime', 'Magento\Model\Resource\AbstractResource', '\Magento\Stdlib\DateTime::toTimestamp'), array('getPlainTemplateMode', '\Magento\Email\Model\Template\Filter'), array('getMessage', '\Magento\Core\Model\Session\Context', 'getMessageFactory'), array('getMessageFactory', '\Magento\Core\Model\Session\Context', 'getMessagesFactory'), @@ -1582,6 +1564,12 @@ array('displayGirthValue', 'Magento\Usa\Helper\Data', 'Magento\Usps\Helper\Data::displayGirthValue'), array('reindexProductPrices', '\Magento\Catalog\Model\Observer'), array('getCustomer', 'Magento\Checkout\Block\Onepage\AbstractOnepage'), + ['_compareSortOrder', 'Magento\Sales\Model\Config\Ordered'], + [ + '_toOptionHashOptimized', + 'Magento\Data\Collection\Db', + 'Magento\Tax\Model\Resource\Calculation\Rate\Collection::toOptionHashOptimized' + ], array('getSwitchCurrencyUrl', 'Magento\Directory\Block\Currency'), array('getPageVarName', 'Magento\Catalog\Block\Product\ProductList\Toolbar'), array('getOrderVarName', 'Magento\Catalog\Block\Product\ProductList\Toolbar'), @@ -1592,5 +1580,32 @@ array('getModeUrl', 'Magento\Catalog\Block\Product\ProductList\Toolbar'), array('getLimitUrl', 'Magento\Catalog\Block\Product\ProductList\Toolbar'), array('_getAvailableLimit', 'Magento\Catalog\Block\Product\ProductList\Toolbar'), - array('getCacheIdTags', 'Magento\Core\Model\AbstractModel') + array('getCacheIdTags', 'Magento\Core\Model\AbstractModel'), + array('addCustomerData', 'Magento\Log\Model\Visitor'), + array('quoteSubmitAfter', 'Magento\Customer\Model\Observer'), + array('loadByCustomer', 'Magento\Wishlist\Model\Wishlist'), + ['_sessionVarCallback', 'Magento\Url', 'Replaced with inlined closure'], + array( + 'reviewsAction', + 'Magento\Catalog\Controller\Adminhtml\Product', + 'Magento\Review\Controller\Adminhtml\Product\Reviews::gridAction' + ), + ['_insertInlineScriptsHtml', 'Magento\DesignEditor\Model\Translate\Inline', 'addInlineScript'], + ['initializeTranslation', 'Magento\Backend\Model\Observer'], + ['getTranslateJson', 'Magento\Core\Helper\Js'], + ['_isEmptyTranslateArg', 'Magento\Translate'], + ['_getTranslatedString', 'Magento\Translate'], + ['initLocale', 'Magento\Translate'], + ['_prepareDataString', 'Magento\Translate'], + ['getInlineObject', 'Magento\Translate'], + ['init', 'Magento\Translate', 'loadData'], + ['disable', 'Magento\Translate\Inline'], + ['_getAjaxUrl', 'Magento\Translate\Inline', 'getAjaxUrl'], + ['_stripInlineTranslations', 'Magento\Translate\Inline', 'stripInlineTranslations'], + ['isAllowed', 'Magento\Translate'], + ['translate', 'Magento\Translate'], + ['_getStoreId', 'Magento\Translation\Model\Resource\Translate', 'getScope'], + ['_getStoreId', 'Magento\Translation\Model\Resource\String', 'getScope'], + ['getAvailableModes', 'Magento\DesignEditor\Helper\Data'], + ['initializeTranslation', 'Magento\DesignEditor\Model\Observer'], ); 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 7cc83fa232597..e0309177413d0 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 @@ -196,7 +196,7 @@ array('_dir', 'Magento\Backup\Model\Fs\Collection'), array('_dir', 'Magento\Cms\Model\Wysiwyg\Images\Storage'), array('_dirs', 'Magento\Core\Helper\Theme'), - array('_dirs', 'Magento\Core\Model\Resource\Type\Db\Pdo\Mysql'), + array('_dirs', 'Magento\Model\Resource\Type\Db\Pdo\Mysql'), array('_filesystem', 'Magento\GiftWrapping\Model\Wrapping'), array('_dirs', 'Magento\Index\Model\Lock\Storage'), array('_filesystem', 'Magento\Index\Model\Lock\Storage'), @@ -301,5 +301,36 @@ array('_orderVarName', 'Magento\Catalog\Block\Product\ProductList\Toolbar'), array('_directionVarName', 'Magento\Catalog\Block\Product\ProductList\Toolbar'), array('_modeVarName', 'Magento\Catalog\Block\Product\ProductList\Toolbar'), - array('_limitVarName', 'Magento\Catalog\Block\Product\ProductList\Toolbar') + array('_limitVarName', 'Magento\Catalog\Block\Product\ProductList\Toolbar'), + array('_encryptedSessionId', 'Magento\Url'), + ['_tokenRegex', 'Magento\Translate\Inline'], + ['_translator', 'Magento\Translate\Inline'], + ['_appState', 'Magento\Translate\Inline'], + ['_translateInline', 'Magento\Translate'], + ['_inlineInterface', 'Magento\Translate'], + ['_translateFactory', 'Magento\Translate'], + ['_placeholderRender', 'Magento\Translate'], + ['_canUseInline', 'Magento\Translate'], + ['_eventManager', 'Magento\Translate'], + ['_inlineFactory', 'Magento\App\Helper\Context', 'translateInline'], + ['_inlineFactory', 'Magento\App\Helper\AbstractHelper', 'translateInline'], + ['_storeManager', 'Magento\Translation\Model\Resource\Translate'], + ['_storeManager', 'Magento\Translation\Model\Resource\String'], + ['_isVdeRequest', 'Magento\DesignEditor\Helper\Data'], + ['_translator', 'Magento\Phrase\Renderer\Translate', 'translator'], + ['_translator', 'Magento\Core\Model\Validator\Factory'], + ['_configFactory', 'Magento\Core\Model\App\Emulation', 'inlineConfig'], + ['_coreStoreConfig', 'Magento\Translation\Model\Inline\Config', 'config'], + ['_translate', 'Magento\Directory\Model\Observer'], + ['_translate', 'Magento\Newsletter\Model\Subscriber'], + ['_translate', 'Magento\Sendfriend\Model\Sendfriend'], + ['_translateModel', 'Magento\Sitemap\Model\Observer'], + ['_translator', 'Magento\Checkout\Helper\Data'], + ['_translate', 'Magento\GiftRegistry\Model\Entity'], + ['_translate', 'Magento\Log\Model\Cron'], + ['_translate', 'Magento\ProductAlert\Model\Observer'], + ['translate', 'Magento\Reminder\Model\Rule'], + ['_translate', 'Magento\Rma\Model\Rma'], + ['_translate', 'Magento\Rma\Model\Rma\Status\History'], + ['_translate', 'Magento\Sales\Model\Order\Pdf\AbstractPdf'], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt index 2c13d976008f5..186e9737999df 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt @@ -45,9 +45,6 @@ lib/Magento/Cache/Backend/Eaccelerator.php lib/Magento/Cache/Backend/Memcached.php lib/Magento/Cache/Core.php lib/Magento/Connect -lib/Magento/Convert/ConvertException.php -lib/Magento/Convert/Mapper/Column.php -lib/Magento/Convert/Mapper/MapperInterface.php lib/Magento/Data/Collection.php lib/Magento/Data/Collection/Db.php lib/Magento/Data/Collection/Db/FetchStrategy/Cache.php diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/blacklist/common.txt index a468ec09ba31e..85dc1e4ba3ca4 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/blacklist/common.txt @@ -40,9 +40,9 @@ lib/Magento/Translate/Adapter.php lib/Magento/Translate/AdapterInterface.php # WrapperInterface methods cannot be camelCase as they follow method naming convention from framework classes lib/Magento/Filesystem/WrapperInterface.php -# Newer version of phpcs does not complain about spacing issue. This appears to be a bug in the phpcs version that is currently run in bamboo. -app/code/Magento/Sales/Model/Order/Payment/Transaction.php - -# Skipped for no reason +# PSR-1 not applied to dev/tests/integration/testsuite/Magento +# PSR-1 not applied to dev/tests/unit/testsuite/Magento +# Newer version of phpcs does not complain about spacing issue. This appears to be a bug in the phpcs version that is currently run in bamboo. +app/code/Magento/Sales/Model/Order/Payment/Transaction.php diff --git a/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php b/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php index 16f31eec36e5b..55ae9dfb68591 100644 --- a/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php +++ b/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php @@ -93,34 +93,33 @@ class Adminhtml extends \PHPUnit_Framework_TestCase protected function setUp() { // These mocks are accessed via context - $this->_designMock = $this->_makeMock('Magento\View\DesignInterface'); - $this->_sessionMock = $this->_makeMock('Magento\Core\Model\Session'); - $this->_sidResolver = $this->_makeMock('Magento\Core\Model\Session\SidResolver'); - $this->_translatorMock = $this->_makeMock('Magento\TranslateInterface'); - $this->_layoutMock = $this->_makeMock('Magento\Core\Model\Layout'); - $this->_requestMock = $this->_makeMock('Magento\App\RequestInterface'); - $this->_messagesMock = $this->_makeMock('Magento\View\Element\Messages'); - $this->_urlMock = $this->_makeMock('Magento\UrlInterface'); - $this->_eventManagerMock = $this->_makeMock('Magento\Event\ManagerInterface'); - $this->_controllerMock = $this->_makeMock('Magento\App\FrontController'); - $this->_loggerMock = $this->_makeMock('Magento\Logger'); - $this->_filesystemMock = $this->_makeMock('Magento\App\Filesystem'); - $this->_cacheMock = $this->_makeMock('Magento\App\CacheInterface'); - $this->_storeConfigMock = $this->_makeMock('Magento\Core\Model\Store\Config'); - $this->_storeManagerMock = $this->_makeMock('Magento\Core\Model\StoreManager'); - $viewUrlMock = $this->_makeMock('Magento\View\Url'); - $viewConfigMock = $this->_makeMock('Magento\View\ConfigInterface'); - $viewFileSystemMock = $this->_makeMock('Magento\View\FileSystem'); - $templatePoolMock = $this->_makeMock('Magento\View\TemplateEnginePool'); - $authorizationMock = $this->_makeMock('Magento\AuthorizationInterface'); - $cacheStateMock = $this->_makeMock('Magento\App\Cache\StateInterface'); - $appMock = $this->_makeMock('Magento\Core\Model\App'); - $escaperMock = $this->_makeMock('Magento\Escaper'); - $filterManagerMock = $this->_makeMock('Magento\Filter\FilterManager'); - $backendSessionMock = $this->_makeMock('Magento\Backend\Model\Session'); - $appState = $this->_makeMock('Magento\App\State'); - $this->_mathMock = $this->_makeMock('Magento\Math\Random'); - $this->_formKey = $this->_makeMock('Magento\Data\Form\FormKey'); + $this->_designMock = $this->_makeMock('Magento\View\DesignInterface'); + $this->_sessionMock = $this->_makeMock('Magento\Core\Model\Session'); + $this->_sidResolver = $this->_makeMock('Magento\Core\Model\Session\SidResolver'); + $this->_translatorMock = $this->_makeMock('Magento\TranslateInterface'); + $this->_layoutMock = $this->_makeMock('Magento\Core\Model\Layout'); + $this->_requestMock = $this->_makeMock('Magento\App\RequestInterface'); + $this->_messagesMock = $this->_makeMock('Magento\View\Element\Messages'); + $this->_urlMock = $this->_makeMock('Magento\UrlInterface'); + $this->_eventManagerMock = $this->_makeMock('Magento\Event\ManagerInterface'); + $this->_controllerMock = $this->_makeMock('Magento\App\FrontController'); + $this->_loggerMock = $this->_makeMock('Magento\Logger'); + $this->_filesystemMock = $this->_makeMock('Magento\App\Filesystem'); + $this->_cacheMock = $this->_makeMock('Magento\App\CacheInterface'); + $this->_storeConfigMock = $this->_makeMock('Magento\Core\Model\Store\Config'); + $this->_storeManagerMock = $this->_makeMock('Magento\Core\Model\StoreManager'); + $viewUrlMock = $this->_makeMock('Magento\View\Url'); + $viewConfigMock = $this->_makeMock('Magento\View\ConfigInterface'); + $viewFileSystemMock = $this->_makeMock('Magento\View\FileSystem'); + $templatePoolMock = $this->_makeMock('Magento\View\TemplateEnginePool'); + $authorizationMock = $this->_makeMock('Magento\AuthorizationInterface'); + $cacheStateMock = $this->_makeMock('Magento\App\Cache\StateInterface'); + $escaperMock = $this->_makeMock('Magento\Escaper'); + $filterManagerMock = $this->_makeMock('Magento\Filter\FilterManager'); + $backendSessionMock = $this->_makeMock('Magento\Backend\Model\Session'); + $appState = $this->_makeMock('Magento\App\State'); + $this->_mathMock = $this->_makeMock('Magento\Math\Random'); + $this->_formKey = $this->_makeMock('Magento\Data\Form\FormKey'); $appState->setAreaCode(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); @@ -148,7 +147,6 @@ protected function setUp() $viewConfigMock, $cacheStateMock, $this->_loggerMock, - $appMock, $escaperMock, $filterManagerMock, $this->_filesystemMock, diff --git a/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php b/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php index 41595e761b918..71895ee10704e 100644 --- a/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php +++ b/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php @@ -37,8 +37,8 @@ class ObjectManager * @var array */ protected $_specialCases = array( - 'Magento\Core\Model\Resource\AbstractResource' => '_getResourceModelMock', - 'Magento\TranslateInterface' => '_getTranslatorMock' + 'Magento\Model\Resource\AbstractResource' => '_getResourceModelMock', + 'Magento\TranslateInterface' => '_getTranslatorMock', ); /** 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 c314e440bf512..0f48d33875a3b 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 @@ -50,9 +50,9 @@ class ObjectManagerTest extends \PHPUnit_Framework_TestCase * @var array */ protected $_modelDependencies = array( - 'eventManager' => 'Magento\Event\ManagerInterface', - 'cacheManager' => 'Magento\App\CacheInterface', - 'resource' => 'Magento\Core\Model\Resource\AbstractResource', + 'eventManager' => 'Magento\Event\ManagerInterface', + 'cacheManager' => 'Magento\App\CacheInterface', + 'resource' => 'Magento\Model\Resource\AbstractResource', 'resourceCollection' => 'Magento\Data\Collection\Db' ); diff --git a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/NotificationServiceTest.php b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/NotificationServiceTest.php index 03771fd42dea2..140119d4d7d5e 100644 --- a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/NotificationServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/NotificationServiceTest.php @@ -79,7 +79,7 @@ public function testMarkAsRead() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Wrong notification ID specified. */ public function testMarkAsReadThrowsExceptionWhenNotificationIdIsInvalid() diff --git a/dev/tests/unit/testsuite/Magento/App/AreaListTest.php b/dev/tests/unit/testsuite/Magento/App/AreaListTest.php index 0233b72b3c725..1955c8bf55928 100644 --- a/dev/tests/unit/testsuite/Magento/App/AreaListTest.php +++ b/dev/tests/unit/testsuite/Magento/App/AreaListTest.php @@ -35,21 +35,23 @@ class AreaListTest extends \PHPUnit_Framework_TestCase */ protected $_resolverFactory; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + protected function setUp() { - $this->_resolverFactory = $this->getMock( - '\Magento\App\Area\FrontNameResolverFactory', - array(), - array(), - '', - false - ); + $this->objectManagerMock = $this->getMock('Magento\ObjectManager'); + $this->_resolverFactory = $this + ->getMock('\Magento\App\Area\FrontNameResolverFactory', array(), array(), '', false); } public function testGetCodeByFrontNameWhenAreaDoesNotContainFrontName() { $expected = 'expectedFrontName'; $this->_model = new \Magento\App\AreaList( + $this->objectManagerMock, $this->_resolverFactory, array('testArea' => array('frontNameResolver' => 'testValue')), $expected @@ -74,8 +76,9 @@ public function testGetCodeByFrontNameReturnsAreaCode() { $expected = 'testArea'; $this->_model = new \Magento\App\AreaList( + $this->objectManagerMock, $this->_resolverFactory, - array('testArea' => array('frontName' => 'testFrontName')), + array('testArea'=>array('frontName' => 'testFrontName')), $expected ); @@ -87,6 +90,7 @@ public function testGetFrontNameWhenAreaCodeAndFrontNameAreSet() { $expected = 'testFrontName'; $this->_model = new \Magento\App\AreaList( + $this->objectManagerMock, $this->_resolverFactory, array('testAreaCode' => array('frontName' => 'testFrontName')), $expected @@ -98,7 +102,7 @@ public function testGetFrontNameWhenAreaCodeAndFrontNameAreSet() public function testGetFrontNameWhenAreaCodeAndFrontNameArentSet() { - $this->_model = new \Magento\App\AreaList($this->_resolverFactory, array(), ''); + $this->_model = new \Magento\App\AreaList($this->objectManagerMock, $this->_resolverFactory, array(), ''); $actual = $this->_model->getFrontName('testAreaCode'); $this->assertNull($actual); @@ -107,9 +111,7 @@ public function testGetFrontNameWhenAreaCodeAndFrontNameArentSet() public function testGetCodes() { $this->_model = new \Magento\App\AreaList( - $this->_resolverFactory, - array('area1' => 'value1', 'area2' => 'value2'), - '' + $this->objectManagerMock, $this->_resolverFactory, array('area1' => 'value1', 'area2' => 'value2'), '' ); $expected = array(0 => 'area1', 1 => 'area2'); diff --git a/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php b/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php index 68455d27908b0..cf17a2030a14d 100644 --- a/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php +++ b/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php @@ -66,7 +66,7 @@ protected function setUp() public function testRunExecutesApplication() { $applicationName = '\Magento\App\TestApplication'; - $applicationMock = $this->getMock('\Magento\LauncherInterface'); + $applicationMock = $this->getMock('\Magento\AppInterface'); $applicationMock->expects($this->once())->method('launch')->will($this->returnValue($this->_responseMock)); $this->_objectManagerMock->expects( $this->once() @@ -84,7 +84,7 @@ public function testRunExecutesApplication() public function testRunCatchesExceptionThrownByApplication() { $applicationName = '\Magento\App\TestApplication'; - $applicationMock = $this->getMock('\Magento\LauncherInterface'); + $applicationMock = $this->getMock('\Magento\AppInterface'); $applicationMock->expects( $this->once() )->method( diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Router/NoRouteHandlerTest.php b/dev/tests/unit/testsuite/Magento/Backend/App/Router/NoRouteHandlerTest.php similarity index 83% rename from dev/tests/unit/testsuite/Magento/Backend/Model/Router/NoRouteHandlerTest.php rename to dev/tests/unit/testsuite/Magento/Backend/App/Router/NoRouteHandlerTest.php index 208f72a8c655e..b20448c046896 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Router/NoRouteHandlerTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/App/Router/NoRouteHandlerTest.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\Backend\Model\Router; +namespace Magento\Backend\App\Router; class NoRouteHandlerTest extends \PHPUnit_Framework_TestCase { @@ -35,6 +35,11 @@ class NoRouteHandlerTest extends \PHPUnit_Framework_TestCase */ protected $_requestMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_routeConfigMock; + /** * @var \Magento\Backend\App\Router\NoRouteHandler */ @@ -43,9 +48,10 @@ class NoRouteHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); + $this->_routeConfigMock = $this->getMock('\Magento\App\Route\ConfigInterface'); $this->_helperMock = $this->getMock('Magento\Backend\Helper\Data', array(), array(), '', false); $this->_helperMock->expects($this->any())->method('getAreaFrontName')->will($this->returnValue('backend')); - $this->_model = new \Magento\Backend\App\Router\NoRouteHandler($this->_helperMock); + $this->_model = new \Magento\Backend\App\Router\NoRouteHandler($this->_helperMock, $this->_routeConfigMock); } /** @@ -53,13 +59,16 @@ protected function setUp() */ public function testProcessWithBackendAreaFrontName() { - $this->_requestMock->expects( - $this->once() - )->method( - 'getPathInfo' - )->will( - $this->returnValue('backend/admin/custom') - ); + $this->_routeConfigMock + ->expects($this->once()) + ->method('getRouteFrontName') + ->with('adminhtml') + ->will($this->returnValue('admin')); + + $this->_requestMock + ->expects($this->once()) + ->method('getPathInfo') + ->will($this->returnValue('backend/admin/custom')); $this->_requestMock->expects( $this->once() 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 83003db94afd6..a4c37c6cd56fe 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/GridTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/GridTest.php @@ -57,9 +57,6 @@ public function testAddGetClearRss($isUseStoreInUrl) $storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); - $appMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); - $appMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); - $appMock->expects($this->any())->method('getDefaultStoreView')->will($this->returnValue($storeMock)); $urlBuilderMock = $this->getMock('Magento\Backend\Model\Url', array(), array(), '', false); @@ -67,13 +64,10 @@ public function testAddGetClearRss($isUseStoreInUrl) $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $block = $helper->getObject( - 'Magento\Backend\Block\Widget\Grid', - array( - 'app' => $appMock, - 'storeManager' => $storeManagerMock, - 'urlModel' => $urlMock, - 'urlBuilder' => $urlBuilderMock + $block = $helper->getObject('Magento\Backend\Block\Widget\Grid', array( + 'storeManager' => $storeManagerMock, + 'urlModel' => $urlMock, + 'urlBuilder' => $urlBuilderMock, ) ); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php index 3f5bbee270ea2..2e42ecb04f06e 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php @@ -66,26 +66,17 @@ protected function setUp() */ public function testLoginFailed() { - $this->_modelFactoryMock->expects( - $this->once() - )->method( - 'create' - )->with( - 'Magento\Backend\Model\Auth\Credential\StorageInterface' - )->will( - $this->returnValue($this->_credentialStorage) - ); - $exceptionMock = new \Magento\Core\Exception(); - $this->_credentialStorage->expects( - $this->once() - )->method( - 'login' - )->with( - 'username', - 'password' - )->will( - $this->throwException($exceptionMock) - ); + $this->_modelFactoryMock + ->expects($this->once()) + ->method('create') + ->with('Magento\Backend\Model\Auth\Credential\StorageInterface') + ->will($this->returnValue($this->_credentialStorage)); + $exceptionMock = new \Magento\Model\Exception; + $this->_credentialStorage + ->expects($this->once()) + ->method('login') + ->with('username', 'password') + ->will($this->throwException($exceptionMock)); $this->_credentialStorage->expects($this->never())->method('getId'); $this->_eventManagerMock->expects($this->once())->method('dispatch')->with('backend_auth_user_login_failed'); $this->_model->login('username', 'password'); 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 347a6c7ef5854..dbee3f484bcc7 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 @@ -29,10 +29,19 @@ public function testSaveMergedJsCssMustBeCleaned() { $eventDispatcher = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false); $appState = $this->getMock('Magento\App\State', array(), array(), '', false); - $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $cacheManager = $this->getMock('Magento\App\CacheInterface'); - $logger = $this->getMock('Magento\Logger', array(), array(), '', false); - $context = new \Magento\Model\Context($logger, $eventDispatcher, $cacheManager, $appState, $storeManager); + $logger = $this->getMock('Magento\Logger', array(), array(), '', false); + $actionValidatorMock = $this->getMock( + 'Magento\Model\ActionValidator\RemoveAction', array(), array(), '', false + ); + + $context = new \Magento\Model\Context( + $logger, + $eventDispatcher, + $cacheManager, + $appState, + $actionValidatorMock + ); $resource = $this->getMock('Magento\Core\Model\Resource\Config\Data', array(), array(), '', false); $resource->expects($this->any())->method('addCommitCallback')->will($this->returnValue($resource)); 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 09eec4321d50a..08b130b79add1 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 @@ -51,7 +51,7 @@ protected function setUp() $this->returnValue($eventDispatcherMock) ); $this->_resourceMock = $this->getMock( - 'Magento\Core\Model\Resource\AbstractResource', + 'Magento\Model\Resource\AbstractResource', array( '_construct', '_getReadAdapter', 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 e4fccbe8a95ef..0d66f30e247f1 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 @@ -29,10 +29,18 @@ public function testSaveMergedJsCssMustBeCleaned() { $eventDispatcher = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false); $appState = $this->getMock('Magento\App\State', array(), array(), '', false); - $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $cacheManager = $this->getMock('Magento\App\CacheInterface'); $logger = $this->getMock('Magento\Logger', array(), array(), '', false); - $context = new \Magento\Model\Context($logger, $eventDispatcher, $cacheManager, $appState, $storeManager); + $actionValidatorMock = $this->getMock( + '\Magento\Model\ActionValidator\RemoveAction', array(), array(), '', false + ); + $context = new \Magento\Model\Context( + $logger, + $eventDispatcher, + $cacheManager, + $appState, + $actionValidatorMock + ); $resource = $this->getMock('Magento\Core\Model\Resource\Config\Data', array(), array(), '', false); $resource->expects($this->any())->method('addCommitCallback')->will($this->returnValue($resource)); 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 a59914f134abe..d2bfcc4d65bcb 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 @@ -107,7 +107,7 @@ public function testShouldCloneFields() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testGetCloneModelThrowsExceptionIfNoSourceModelIsSet() { diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php index 42fb7202ce234..af723b9a82bd3 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php @@ -94,11 +94,8 @@ protected function setUp() ); $this->_transFactoryMock = $this->getMock( - 'Magento\Core\Model\Resource\TransactionFactory', - array('create'), - array(), - '', - false + 'Magento\DB\TransactionFactory', + array('create'), array(), '', false ); $this->_appConfigMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $this->_configLoaderMock = $this->getMock( @@ -149,7 +146,9 @@ public function testSaveEmptiesNonSetArguments() public function testSaveToCheckAdminSystemConfigChangedSectionEvent() { - $transactionMock = $this->getMock('Magento\Core\Model\Resource\Transaction', array(), array(), '', false); + $transactionMock = $this->getMock( + 'Magento\DB\Transaction', array(), array(), '', false + ); $this->_transFactoryMock->expects($this->any())->method('create')->will($this->returnValue($transactionMock)); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigFactoryTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigFactoryTest.php deleted file mode 100644 index 144ded3efd8f4..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigFactoryTest.php +++ /dev/null @@ -1,44 +0,0 @@ -getMockForAbstractClass('Magento\ObjectManager'); - $objectManager->expects( - $this->once() - )->method( - 'get' - )->with( - $this->equalTo('Magento\Backend\Model\Translate\Inline\Config') - )->will( - $this->returnValue($result) - ); - $factory = new ConfigFactory($objectManager); - $this->assertEquals($result, $factory->get()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/TranslateTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/TranslateTest.php deleted file mode 100644 index fd480cefae7b7..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/TranslateTest.php +++ /dev/null @@ -1,82 +0,0 @@ -getMock('\Magento\Locale\ResolverInterface'); - $appMock = $this->getMock('\Magento\AppInterface', array(), array(), '', false); - $appStateMock = $this->getMock('\Magento\App\State', array(), array(), '', false); - $appStateMock->expects($this->any())->method('getAreaCode')->will($this->returnValue($area)); - $scopeMock = $this->getMock('\Magento\BaseScopeInterface'); - $scopeResolverMock = $this->getMock('\Magento\BaseScopeResolverInterface'); - $scopeResolverMock->expects($this->once())->method('getScope')->will($this->returnValue($scopeMock)); - $themeMock = $this->getMock('\Magento\View\Design\ThemeInterface', array()); - $themeMock->expects($this->once())->method('getId')->will($this->returnValue(1)); - $designMock = $this->getMock('\Magento\View\DesignInterface'); - $designMock->expects($this->once())->method('getDesignTheme')->will($this->returnValue($themeMock)); - - $inlineMock = $this->getMock('\Magento\Translate\InlineInterface'); - $inlineMock->expects($this->at(0))->method('isAllowed')->with()->will($this->returnValue(false)); - $inlineMock->expects( - $this->at(1) - )->method( - 'isAllowed' - )->with( - $this->equalTo($expectedScope) - )->will( - $this->returnValue(true) - ); - $translateFactoryMock = $this->getMock('\Magento\Translate\Factory', array(), array(), '', false); - $translateFactoryMock->expects($this->any())->method('create')->will($this->returnValue($inlineMock)); - - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - /** @var \Magento\Backend\Model\Translate $translate */ - $translate = $helper->getObject( - 'Magento\Backend\Model\Translate', - array( - 'app' => $appMock, - 'appState' => $appStateMock, - 'scopeResolver' => $scopeResolverMock, - 'viewDesign' => $designMock, - 'translateFactory' => $translateFactoryMock, - 'localeResolver' => $localeMock - ) - ); - $translate->init(); - } - - public function initDataProvider() - { - return array(array('adminhtml', 'admin'), array('frontend', null)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php index d0d4c60e1d3d7..02864d14eb437 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php @@ -42,7 +42,7 @@ public function setUp() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Could not rebuild index for undefined product */ public function testEmptyId() diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowsTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowsTest.php index 8799fe97642fb..37a3a3c3aaa3c 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowsTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowsTest.php @@ -42,7 +42,7 @@ public function setUp() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Bad value was supplied. */ public function testEmptyIds() diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php index 7e54bdacca445..81dba29756a44 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php @@ -43,6 +43,11 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase */ protected $_indexerMock; + /** + * @var \Magento\Indexer\Model\IndexerFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_indexerFactoryMock; + /** * @var \Magento\Catalog\Model\Indexer\Product\Flat\State|\PHPUnit_Framework_MockObject_MockObject */ @@ -61,6 +66,15 @@ public function setUp() ); $this->_indexerMock->expects($this->any())->method('getId')->will($this->returnValue(1)); + $this->_indexerFactoryMock = $this->getMock( + 'Magento\Indexer\Model\IndexerFactory', array('create'), array(), '', false + ); + + $this->_indexerFactoryMock + ->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->_indexerMock)); + $this->_stateMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Product\Flat\State', array('isFlatEnabled'), @@ -68,10 +82,10 @@ public function setUp() '', false ); - $this->_model = $this->_objectManager->getObject( - 'Magento\Catalog\Model\Indexer\Product\Flat\Processor', - array('indexer' => $this->_indexerMock, 'state' => $this->_stateMock) - ); + $this->_model = $this->_objectManager->getObject('Magento\Catalog\Model\Indexer\Product\Flat\Processor', array( + 'indexerFactory' => $this->_indexerFactoryMock, + 'state' => $this->_stateMock + )); } /** diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRuleTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRuleTest.php new file mode 100644 index 0000000000000..c963cc87b308a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRuleTest.php @@ -0,0 +1,131 @@ +_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->_priceProcessorMock = $this->getMock( + 'Magento\Catalog\Model\Indexer\Product\Price\Processor', array(), array(), '', false + ); + + $this->_model = $this->_objectManager->getObject( + '\Magento\Catalog\Model\Indexer\Product\Price\Plugin\CatalogRule', + array( + 'processor' => $this->_priceProcessorMock + ) + ); + } + + public function testAfterApplyAll() + { + $this->_priceProcessorMock->expects($this->once()) + ->method('markIndexerAsInvalid'); + + $ruleMock = $this->getMock('Magento\CatalogRule\Model\Rule', array(), array(), '', false); + $this->_model->afterApplyAll($ruleMock); + } + + /** + * @param int|\Magento\Catalog\Model\Product $product + * @param int $expectedIdCall + * @dataProvider affectedProductsDataProvider + */ + public function testAroundApplyToProduct($product, $expectedIdCall) + { + $this->_priceProcessorMock->expects($this->once()) + ->method('reindexRow') + ->with($expectedIdCall); + + $ruleMock = $this->getMock('Magento\CatalogRule\Model\Rule', array(), array(), '', false); + $this->_model->aroundApplyToProduct( + $ruleMock, + function () { + + }, + $product + ); + } + + /** + * @param int|\Magento\Catalog\Model\Product $product + * @param int $expectedIdCall + * @dataProvider affectedProductsDataProvider + */ + public function testAroundApplyAllRulesToProduct($product, $expectedIdCall) + { + $this->_priceProcessorMock->expects($this->once()) + ->method('reindexRow') + ->with($expectedIdCall); + + $ruleMock = $this->getMock('Magento\CatalogRule\Model\Rule', array(), array(), '', false); + $this->_model->aroundApplyToProduct( + $ruleMock, + function () { + + }, + $product + ); + } + + /** + * @return array + */ + public function affectedProductsDataProvider() + { + $productId = 11; + $productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $productMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue($productId)); + + return array( + array($productId, $productId), + array($productMock, $productId) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php index 7c802405dd55c..ccc40806f8175 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php @@ -39,7 +39,7 @@ class CustomerGroupTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Customer\Model\Resource\Group|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_subjectMock; @@ -47,7 +47,9 @@ public function setUp() { $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_subjectMock = $this->getMock('Magento\Customer\Model\Resource\Group', array(), array(), '', false); + $this->_subjectMock = $this->getMock( + '\Magento\Customer\Service\V1\CustomerGroupServiceInterface', array(), array(), '', false + ); $indexerMock = $this->getMock( 'Magento\Indexer\Model\Indexer', @@ -67,11 +69,11 @@ public function setUp() public function testAroundDelete() { - $this->assertEquals('return_value', $this->_model->afterDelete($this->_subjectMock, 'return_value')); + $this->assertEquals('return_value', $this->_model->afterDeleteGroup($this->_subjectMock, 'return_value')); } public function testAroundSave() { - $this->assertEquals('return_value', $this->_model->afterSave($this->_subjectMock, 'return_value')); + $this->assertEquals('return_value', $this->_model->afterSaveGroup($this->_subjectMock, 'return_value')); } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Filter/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Filter/FactoryTest.php index b9141664e7190..e155bce18780c 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Filter/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Filter/FactoryTest.php @@ -86,7 +86,7 @@ public function testCreateWithArguments() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage WrongClass doesn't extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ public function testWrongTypeException() diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Option/Type/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Option/Type/FactoryTest.php index 33851f12097af..65c38b3536ef0 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Option/Type/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Option/Type/FactoryTest.php @@ -86,7 +86,7 @@ public function testCreateWithArguments() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage WrongClass doesn't extends \Magento\Catalog\Model\Product\Option\Type\DefaultType */ public function testWrongTypeException() diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php index 17fb08763437d..ec3727b3ce8c4 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php @@ -94,22 +94,29 @@ public function setUp() $eventManagerMock = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false); + $actionValidatorMock = $this->getMock( + '\Magento\Model\ActionValidator\RemoveAction', array(), array(), '', false + ); + $actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); $cacheInterfaceMock = $this->getMock('Magento\App\CacheInterface', array(), array(), '', false); $contextMock = $this->getMock( '\Magento\Model\Context', - array('getEventDispatcher', 'getCacheManager', 'getAppState'), - array(), - '', - false + array('getEventDispatcher', 'getCacheManager', 'getAppState', 'getActionValidator'), array(), '', false ); $contextMock->expects($this->any())->method('getAppState')->will($this->returnValue($stateMock)); $contextMock->expects($this->any())->method('getEventDispatcher')->will($this->returnValue($eventManagerMock)); - $contextMock->expects($this->any())->method('getCacheManager')->will($this->returnValue($cacheInterfaceMock)); + $contextMock->expects($this->any()) + ->method('getCacheManager') + ->will($this->returnValue($cacheInterfaceMock)); + + $contextMock->expects($this->any()) + ->method('getActionValidator') + ->will($this->returnValue($actionValidatorMock)); $this->_model = new \Magento\Catalog\Model\Product( $contextMock, diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php index 506f957735023..a13b5f948964e 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php @@ -52,36 +52,30 @@ public function setUp() $cacheInterfaceMock = $this->getMock('Magento\App\CacheInterface', array(), array(), '', false); + $actionValidatorMock = $this->getMock( + '\Magento\Model\ActionValidator\RemoveAction', array(), array(), '', false + ); + $actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); + $contextMock = $this->getMock( '\Magento\Model\Context', - array('getEventDispatcher', 'getCacheManager'), - array(), - '', - false + array('getEventDispatcher', 'getCacheManager', 'getActionValidator'), array(), '', false ); $contextMock->expects($this->any())->method('getEventDispatcher')->will($this->returnValue($eventManagerMock)); $contextMock->expects($this->any())->method('getCacheManager')->will($this->returnValue($cacheInterfaceMock)); + $contextMock->expects($this->any())->method('getActionValidator') + ->will($this->returnValue($actionValidatorMock)); $dbAdapterMock = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array(), array(), '', false); $dbAdapterMock->expects($this->any())->method('getTransactionLevel')->will($this->returnValue(1)); $resourceMock = $this->getMock( - 'Magento\Core\Model\Resource\AbstractResource', - array( - '_construct', - '_getReadAdapter', - '_getWriteAdapter', - 'getIdFieldName', - 'save', - 'saveInSetIncluding', - 'isUsedBySuperProducts', - 'delete' - ), - array(), - '', - false + 'Magento\Model\Resource\AbstractResource', + array('_construct', '_getReadAdapter', '_getWriteAdapter', 'getIdFieldName', + 'save', 'saveInSetIncluding', 'isUsedBySuperProducts', 'delete'), + array(), '', false ); $resourceMock->expects($this->any())->method('_getWriteAdapter')->will($this->returnValue($dbAdapterMock)); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php new file mode 100644 index 0000000000000..b8a5b12babacf --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php @@ -0,0 +1,135 @@ +entityFactoryMock = $this->getMock( + 'Magento\Core\Model\EntityFactory', array('create'), array(), '', false + ); + $this->loggerMock = $this->getMock('Magento\Logger', array('log'), array(), '', false); + $this->fetchStrategyMock = $this->getMock( + 'Magento\Data\Collection\Db\FetchStrategy\Query', array('fetchAll'), array(), '', false + ); + $this->eventManagerMock = $this->getMock('Magento\Event\Manager', array(), array(), '', false); + $this->optionsFactoryMock = $this->getMock( + 'Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory', + array('create'), + array(), + '', + false + ); + $this->storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); + $this->resourceMock = $this->getMock( + 'Magento\Catalog\Model\Resource\Product\Option', + array('getReadConnection', '__wakeup', 'getMainTable', 'getTable'), + array(), + '', + false + ); + $this->selectMock = $this->getMock('Zend_Db_Select', array('from', 'reset'), array(), '', false); + $this->adapterMock = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('select'), array(), '', false); + $this->adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + $this->resourceMock->expects($this->once()) + ->method('getReadConnection') + ->will($this->returnValue($this->adapterMock)); + $this->resourceMock->expects($this->once()) + ->method('getMainTable') + ->will($this->returnValue('test_main_table')); + $this->resourceMock->expects($this->once()) + ->method('getTable') + ->with('test_main_table') + ->will($this->returnValue('test_main_table')); + + $this->collection = new Collection( + $this->entityFactoryMock, + $this->loggerMock, + $this->fetchStrategyMock, + $this->eventManagerMock, + $this->optionsFactoryMock, + $this->storeManagerMock, + null, + $this->resourceMock + ); + } + + public function testReset() + { + $this->collection->reset(); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/Stub.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/Stub.php index 6122b164af80c..082910be1074d 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/Stub.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/Stub.php @@ -26,6 +26,6 @@ */ namespace Magento\Catalog\Model\Resource\Product\Option; -class Stub extends \Magento\Core\Model\AbstractModel +class Stub extends \Magento\Model\AbstractModel { } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueStub.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueStub.php index bfce1a9d1751d..44b78557f1486 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueStub.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueStub.php @@ -39,9 +39,9 @@ public function __construct() /** * Save option value price data * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object */ - public function saveValueTitles(\Magento\Core\Model\AbstractModel $object) + public function saveValueTitles(\Magento\Model\AbstractModel $object) { $this->_saveValueTitles($object); } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Template/Filter/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Template/Filter/FactoryTest.php index 96142590fa4e7..29c7adf6aecb9 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Template/Filter/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Template/Filter/FactoryTest.php @@ -86,7 +86,7 @@ public function testCreateWithArguments() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage WrongClass doesn't extends \Magento\Filter\Template */ public function testWrongTypeException() diff --git a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Adminhtml/Stock/ItemTest.php b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Adminhtml/Stock/ItemTest.php index ea69ef997d947..780eaa6cca05a 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Adminhtml/Stock/ItemTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Adminhtml/Stock/ItemTest.php @@ -36,7 +36,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase protected function setUp() { $resourceMock = $this->getMock( - 'Magento\Core\Model\Resource\AbstractResource', + 'Magento\Model\Resource\AbstractResource', array('_construct', '_getReadAdapter', '_getWriteAdapter', 'getIdFieldName'), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/OptionTest.php b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/OptionTest.php index e34f04be7b8f3..937181def82f8 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/OptionTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/OptionTest.php @@ -244,7 +244,7 @@ public function testInitializeWhenResultNotDecimalGetBackordersMessageHasOptionQ } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage The stock item for Product in option is not valid. */ public function testInitializeWithInvalidOptionQty() diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php index ef19c60743fce..f4dce99726336 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php @@ -42,7 +42,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_translator = $this->getMock('Magento\TranslateInterface', array(), array(), '', false); + $this->_translator = $this->getMock('Magento\Translate\Inline\StateInterface', array(), array(), '', false); $context = $this->getMock('\Magento\App\Helper\Context', array(), array(), '', false); $storeConfig = $this->getMock('\Magento\Core\Model\Store\Config', array(), array(), '', false); @@ -180,8 +180,10 @@ public function testSendPaymentFailedEmail() $this->returnValue($this->getMock('Magento\Mail\TransportInterface')) ); - $this->_translator->expects($this->at(0))->method('setTranslateInline')->with(false); - $this->_translator->expects($this->at(1))->method('setTranslateInline')->with(true); + $this->_translator->expects($this->at(1)) + ->method('suspend'); + $this->_translator->expects($this->at(1)) + ->method('resume'); $productOne = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productOne->expects($this->once())->method('getName')->will($this->returnValue('Product One')); diff --git a/dev/tests/integration/testsuite/Magento/Url/QueryParamsResolverTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/Config/Source/Cart/SummaryTest.php similarity index 56% rename from dev/tests/integration/testsuite/Magento/Url/QueryParamsResolverTest.php rename to dev/tests/unit/testsuite/Magento/Checkout/Model/Config/Source/Cart/SummaryTest.php index 9897113bd210c..456c760ec8ea5 100644 --- a/dev/tests/integration/testsuite/Magento/Url/QueryParamsResolverTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/Config/Source/Cart/SummaryTest.php @@ -18,35 +18,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_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; +namespace Magento\Checkout\Model\Config\Source\Cart; -class QueryParamsResolverTest extends \PHPUnit_Framework_TestCase +use Magento\TestFramework\Helper\ObjectManager; + +class SummaryTest extends \PHPUnit_Framework_TestCase { - /** - * @var \Magento\Url\QueryParamsResolver - */ - protected $_model; + /** @var \Magento\Checkout\Model\Config\Source\Cart\Summary */ + protected $object; + + /** @var ObjectManager */ + protected $objectManager; protected function setUp() { - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Url\QueryParamsResolver' - ); + $this->objectManager = new ObjectManager($this); + $this->object = $this->objectManager->getObject('Magento\Checkout\Model\Config\Source\Cart\Summary'); } - public function testSetGetPurgeQueryParams() + public function testToOptionArray() { - $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()); + $this->assertEquals( + [ + ['value' => 0, 'label' => 'Display number of items in cart'], + ['value' => 1, 'label' => 'Display item quantities'], + ], + $this->object->toOptionArray() + ); } } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/ObserverTest.php new file mode 100644 index 0000000000000..b5b66f0dc3bb1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/ObserverTest.php @@ -0,0 +1,95 @@ +objectManager = new ObjectManager($this); + $this->checkoutSession = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); + $this->messageManager = $this->getMock('Magento\Message\ManagerInterface', [], [], '', false); + $this->object = $this->objectManager->getObject('Magento\Checkout\Model\Observer', [ + 'checkoutSession' => $this->checkoutSession, + 'messageManager' => $this->messageManager, + ]); + } + + public function testUnsetAll() + { + $this->checkoutSession->expects($this->once())->method('clearQuote')->will($this->returnSelf()); + $this->checkoutSession->expects($this->once())->method('clearStorage')->will($this->returnSelf()); + + $this->object->unsetAll(); + } + + public function testLoadCustomerQuoteThrowingCoreException() + { + $this->checkoutSession->expects($this->once())->method('loadCustomerQuote')->will( + $this->throwException(new \Magento\Model\Exception('Message')) + ); + $this->messageManager->expects($this->once())->method('addError')->with('Message'); + + $this->object->loadCustomerQuote(); + } + + public function testLoadCustomerQuoteThrowingException() + { + $exception = new \Exception('Message'); + $this->checkoutSession->expects($this->once())->method('loadCustomerQuote')->will( + $this->throwException($exception) + ); + $this->messageManager->expects($this->once())->method('addException') + ->with($exception, 'Load customer quote error'); + + $this->object->loadCustomerQuote(); + } + + public function testSalesQuoteSaveAfter() + { + $observer = $this->getMock('Magento\Event\Observer', [], [], '', false); + $observer->expects($this->once())->method('getEvent')->will( + $this->returnValue(new \Magento\Object( + ['quote' => new \Magento\Object(['is_checkout_cart' => 1, 'id' => 7])] + )) + ); + $this->checkoutSession->expects($this->once())->method('getQuoteId')->with(7); + + $this->object->salesQuoteSaveAfter($observer); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/AbstractTypeTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/AbstractTypeTest.php new file mode 100644 index 0000000000000..5b9b754fa294d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/AbstractTypeTest.php @@ -0,0 +1,156 @@ +checkoutSession = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); + $this->customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', [], [], '', false); + $this->customerAddressService = $this->getMock('Magento\Customer\Service\V1\CustomerAddressServiceInterface'); + + $this->customerObject = $this->getMock('Magento\Customer\Service\V1\Data\Customer', [], [], '', false); + $this->model = $this->getMockForAbstractClass( + '\Magento\Checkout\Model\Type\AbstractType', + [ + 'checkoutSession' => $this->checkoutSession, + 'customerSession' => $this->customerSession, + 'orderFactory' => $this->orderFactory, + 'customerAddressService' => $this->customerAddressService + ], + '', + true + ); + } + + public function testGetCheckoutSession() + { + $this->assertSame($this->checkoutSession, $this->model->getCheckoutSession()); + } + + public function testGetCustomerSession() + { + $this->assertSame($this->customerSession, $this->model->getCustomerSession()); + } + + public function testGetCustomer() + { + $this->customerSession->expects($this->once())->method('getCustomerDataObject') + ->will($this->returnValue($this->customerObject)); + $this->assertSame($this->customerObject, $this->model->getCustomer()); + } + + public function testGetQuote() + { + $quoteMock = $this->getMock('Magento\Sales\Model\Quote', [], [], '', false); + $this->checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); + + $this->assertSame($quoteMock, $this->model->getQuote()); + } + + public function testGetQuoteItems() + { + $quoteMock = $this->getMock('Magento\Sales\Model\Quote', [], [], '', false); + $itemMock = $this->getMock('Magento\Sales\Model\Quote\Item', [], [], '', false); + $this->checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); + $quoteMock->expects($this->once())->method('getAllItems')->will($this->returnValue([$itemMock])); + + $this->assertEquals([$itemMock], $this->model->getQuoteItems()); + } + + /** + * @param string $serviceMethod + * @param string $modelMethod + * @dataProvider getDefaultAddressDataProvider + */ + public function testGetCustomerDefaultShippingAddress($serviceMethod, $modelMethod) + { + $address = $this->getMock('Magento\Customer\Service\V1\Data\Address', [], [], '', false); + $customerId = 1; + $this->customerSession->expects($this->once())->method('getCustomerDataObject') + ->will($this->returnValue($this->customerObject)); + $this->customerObject->expects($this->once())->method('getId') + ->will($this->returnValue($customerId)); + $this->customerAddressService->expects($this->once())->method($serviceMethod)->with($customerId) + ->will($this->returnValue($address)); + $this->customerAddressService->expects($this->never())->method('getAddresses'); + + $this->assertSame($address, $this->model->$modelMethod()); + } + + /** + * @param string $serviceMethod + * @param string $modelMethod + * @dataProvider getDefaultAddressDataProvider + */ + public function testGetCustomerDefaultShippingAddressIfDefaultNotAvailable($serviceMethod, $modelMethod) + { + $address = $this->getMock('Magento\Customer\Service\V1\Data\Address', [], [], '', false); + $customerId = 1; + $this->customerSession->expects($this->once())->method('getCustomerDataObject') + ->will($this->returnValue($this->customerObject)); + $this->customerObject->expects($this->once())->method('getId') + ->will($this->returnValue($customerId)); + $this->customerAddressService->expects($this->once())->method($serviceMethod)->with($customerId) + ->will($this->returnValue(null)); + $this->customerAddressService->expects($this->once())->method('getAddresses')->with($customerId) + ->will($this->returnValue([$address])); + + $this->assertSame($address, $this->model->$modelMethod()); + } + + public function getDefaultAddressDataProvider() + { + return [ + ['getDefaultShippingAddress', 'getCustomerDefaultShippingAddress'], + ['getDefaultBillingAddress', 'getCustomerDefaultBillingAddress'], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php b/dev/tests/unit/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php index c1cfaef73a898..accf4d9860dcf 100644 --- a/dev/tests/unit/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php +++ b/dev/tests/unit/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php @@ -240,7 +240,7 @@ public function testGetResizeHeight() public function testDeleteDirectoryOverRoot() { $this->setExpectedException( - '\Magento\Core\Exception', + '\Magento\Model\Exception', sprintf('Directory %s is not under storage root path.', self::INVALID_DIRECTORY_OVER_ROOT) ); $this->_model->deleteDirectory(self::INVALID_DIRECTORY_OVER_ROOT); @@ -252,7 +252,7 @@ public function testDeleteDirectoryOverRoot() public function testDeleteRootDirectory() { $this->setExpectedException( - '\Magento\Core\Exception', + '\Magento\Model\Exception', sprintf('We cannot delete root directory %s.', self::STORAGE_ROOT_DIR) ); $this->_model->deleteDirectory(self::STORAGE_ROOT_DIR); diff --git a/dev/tests/unit/testsuite/Magento/Config/Converter/Dom/FlatTest.php b/dev/tests/unit/testsuite/Magento/Config/Converter/Dom/FlatTest.php index b4975ad8fc366..6285c6fd5b237 100644 --- a/dev/tests/unit/testsuite/Magento/Config/Converter/Dom/FlatTest.php +++ b/dev/tests/unit/testsuite/Magento/Config/Converter/Dom/FlatTest.php @@ -41,8 +41,13 @@ protected function setUp() { $arrayNodeConfig = new \Magento\Config\Dom\ArrayNodeConfig( new \Magento\Config\Dom\NodePathMatcher(), - array('/root/multipleNode' => 'id'), - array('/root/node_one/subnode') + array( + '/root/multipleNode' => 'id', + '/root/wrongArray' => 'id', + ), + array( + '/root/node_one/subnode', + ) ); $this->_model = new \Magento\Config\Converter\Dom\Flat($arrayNodeConfig); $this->_fixturePath = realpath(__DIR__ . '/../../') . '/_files/converter/dom/flat/'; @@ -58,4 +63,28 @@ public function testConvert() $actual = $this->_model->convert($dom); $this->assertEquals($expected, $actual); } + + /** + * @expectedException \UnexpectedValueException + * @expectedExceptionMessage Node path '/root/someOtherVal' is not unique, but it has not been marked as array. + */ + public function testConvertWithNotUnique() + { + $dom = new \DOMDocument(); + $dom->load($this->_fixturePath . 'source_notuniq.xml'); + + $this->_model->convert($dom); + } + + /** + * @expectedException \UnexpectedValueException + * @expectedExceptionMessage Array is expected to contain value for key 'id'. + */ + public function testConvertWrongArray() + { + $dom = new \DOMDocument(); + $dom->load($this->_fixturePath . 'source_wrongarray.xml'); + + $this->_model->convert($dom); + } } diff --git a/dev/tests/unit/testsuite/Magento/Config/Converter/DomTest.php b/dev/tests/unit/testsuite/Magento/Config/Converter/DomTest.php new file mode 100644 index 0000000000000..955869d88a85d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/Converter/DomTest.php @@ -0,0 +1,50 @@ +loadXML(file_get_contents(__DIR__ . "/../_files/converter/dom/{$sourceFile}")); + $resultFile = include __DIR__ . "/../_files/converter/dom/{$resultFile}"; + + $converterDom = new Dom(); + $this->assertEquals($resultFile, $converterDom->convert($dom)); + } + + public function convertDataProvider() + { + return array( + array('cdata.xml', 'cdata.php',), + array('attributes.xml', 'attributes.php',), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Config/DomTest.php b/dev/tests/unit/testsuite/Magento/Config/DomTest.php index 34f881af3c162..07ef8cdd0ea1a 100644 --- a/dev/tests/unit/testsuite/Magento/Config/DomTest.php +++ b/dev/tests/unit/testsuite/Magento/Config/DomTest.php @@ -163,4 +163,17 @@ public function testValidateCustomErrorFormatInvalid() $dom = new \Magento\Config\Dom($xml, array(), null, null, $errorFormat); $dom->validate(__DIR__ . '/_files/sample.xsd'); } + + public function testValidateUnknownError() + { + $xml = ''; + $schemaFile = __DIR__ . '/_files/sample.xsd'; + $dom = new \Magento\Config\Dom($xml); + $domMock = $this->getMock('DOMDocument', array('schemaValidate'), array()); + $domMock->expects($this->once()) + ->method('schemaValidate') + ->with($schemaFile) + ->will($this->returnValue(false)); + $this->assertEquals(array('Unknown validation error'), $dom->validateDomDocument($domMock, $schemaFile)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Config/Reader/FilesystemTest.php b/dev/tests/unit/testsuite/Magento/Config/Reader/FilesystemTest.php index d86f529913c26..07852ff61547b 100644 --- a/dev/tests/unit/testsuite/Magento/Config/Reader/FilesystemTest.php +++ b/dev/tests/unit/testsuite/Magento/Config/Reader/FilesystemTest.php @@ -77,6 +77,22 @@ public function testRead() $model->read('scope'); } + public function testReadWithoutFiles() + { + $model = new Filesystem( + $this->_fileResolverMock, + $this->_converterMock, + $this->_schemaLocatorMock, + $this->_validationStateMock, + 'fileName', + array() + ); + $this->_fileResolverMock + ->expects($this->once())->method('get')->will($this->returnValue(array())); + + $this->assertEmpty($model->read('scope')); + } + /** * @expectedException \Magento\Exception * @expectedExceptionMessage Invalid Document diff --git a/app/code/Magento/Backend/Model/Translate/Inline.php b/dev/tests/unit/testsuite/Magento/Config/ScopeTest.php similarity index 50% rename from app/code/Magento/Backend/Model/Translate/Inline.php rename to dev/tests/unit/testsuite/Magento/Config/ScopeTest.php index 777d94c75f5f6..70db7e09076b3 100644 --- a/app/code/Magento/Backend/Model/Translate/Inline.php +++ b/dev/tests/unit/testsuite/Magento/Config/ScopeTest.php @@ -17,42 +17,44 @@ * Do not edit or add to this file if you wish to upgrade Magento to 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_Backend + * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Backend\Model\Translate; -/** - * Inline Translations PHP part - */ -class Inline extends \Magento\Translate\Inline +namespace Magento\Config; + +class ScopeTest extends \PHPUnit_Framework_TestCase { /** - * Return URL for ajax requests - * - * @return string + * @var \Magento\Config\Scope */ - protected function _getAjaxUrl() - { - return $this->_url->getUrl(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE . '/ajax/translate'); - } + protected $model; /** - * Replace translation templates with HTML fragments - * - * @param array|string &$body - * @param bool $isJson - * @return $this + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\App\AreaList */ - public function processResponseBody(&$body, $isJson = false) + protected $areaListMock; + + protected function setUp() + { + $this->areaListMock = $this->getMock('Magento\App\AreaList', array('getCodes'), array(), '', false); + $this->model = new Scope($this->areaListMock); + } + + public function testScopeSetGet() + { + $scopeName = 'test_scope'; + $this->model->setCurrentScope($scopeName); + $this->assertEquals($scopeName, $this->model->getCurrentScope()); + } + + public function testGetAllScopes() { - if (!$this->isAllowed()) { - $this->_stripInlineTranslations($body); - return $this; - } - return parent::processResponseBody($body, $isJson); + $expectedBalances = array('primary', 'test_scope'); + $this->areaListMock->expects($this->once()) + ->method('getCodes') + ->will($this->returnValue(array('test_scope'))); + $this->assertEquals($expectedBalances, $this->model->getAllScopes()); } } diff --git a/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php b/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php index 6bb89cb617493..f6c83e53fced4 100644 --- a/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php +++ b/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php @@ -76,4 +76,50 @@ public function getParentThemeDataProvider() array('test_external_package_descendant', array('default_test2')) ); } + + /** + * @param string $themePath + * @param array $expected + * @dataProvider dataGetterDataProvider + */ + public function testDataGetter($themePath, $expected) + { + $expected = reset($expected); + $config = new \Magento\Config\Theme(file_get_contents(__DIR__ . "/_files/area/$themePath/theme.xml")); + $this->assertSame($expected['version'], $config->getThemeVersion()); + $this->assertSame($expected['media'], $config->getMedia()); + } + + /** + * @return array + */ + public function dataGetterDataProvider() + { + return array( + array( + 'default_default', + array(array( + 'version' => '2.0.0.9', + 'media' => array('preview_image' => 'media/default_default.jpg'), + ))), + array( + 'default_test', + array(array( + 'version' => '2.1.0.0', + 'media' => array('preview_image' => ''), + ))), + array( + 'default_test2', + array(array( + 'version' => '2.0.0.0', + 'media' => array('preview_image' => ''), + ))), + array( + 'test_default', + array(array( + 'version' => '2.0.1.0', + 'media' => array('preview_image' => 'media/test_default.jpg'), + ))), + ); + } } diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/area/default_default/theme.xml b/dev/tests/unit/testsuite/Magento/Config/_files/area/default_default/theme.xml index e9252cc20f9dc..9341a2afe7ed4 100644 --- a/dev/tests/unit/testsuite/Magento/Config/_files/area/default_default/theme.xml +++ b/dev/tests/unit/testsuite/Magento/Config/_files/area/default_default/theme.xml @@ -28,5 +28,8 @@ --> Default - 2.0.0.0 + 2.0.0.9 + + media/default_default.jpg + diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/area/default_test/theme.xml b/dev/tests/unit/testsuite/Magento/Config/_files/area/default_test/theme.xml index 986333806f52b..a3f7dcec65698 100644 --- a/dev/tests/unit/testsuite/Magento/Config/_files/area/default_test/theme.xml +++ b/dev/tests/unit/testsuite/Magento/Config/_files/area/default_test/theme.xml @@ -28,6 +28,9 @@ --> Test - 2.0.0.0 + 2.1.0.0 default_default + + + diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/area/test_default/theme.xml b/dev/tests/unit/testsuite/Magento/Config/_files/area/test_default/theme.xml index e9252cc20f9dc..69d2f7d346212 100644 --- a/dev/tests/unit/testsuite/Magento/Config/_files/area/test_default/theme.xml +++ b/dev/tests/unit/testsuite/Magento/Config/_files/area/test_default/theme.xml @@ -28,5 +28,8 @@ --> Default - 2.0.0.0 + 2.0.1.0 + + media/test_default.jpg + diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/attributes.php b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/attributes.php new file mode 100644 index 0000000000000..0d6d61ae19897 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/attributes.php @@ -0,0 +1,70 @@ + array( + array( + 'item' => array( + array( + '__attributes__' => array( + 'id' => 'id1', + 'attrZero' => 'value 0', + ), + '__content__' => 'Item 1.1', + ), + array( + '__attributes__' => array( + 'id' => 'id2', + 'attrOne' => 'value 2', + ), + 'subitem' => array( + array( + '__attributes__' => array( + 'id' => 'id2.1', + 'attrTwo' => 'value 2.1', + ), + '__content__' => 'Item 2.1', + ), + array( + '__attributes__' => array( + 'id' => 'id2.2', + ), + 'value' => array( + array('__content__' => 1), + array('__content__' => 2), + array('__content__' => 'test'), + ), + ), + ), + ), + array( + '__attributes__' => array( + 'id' => 'id3', + 'attrThree' => 'value 3', + ), + '__content__' => 'Item 3.1', + ), + ), + ), + ), +); \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/attributes.xml b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/attributes.xml new file mode 100644 index 0000000000000..d8cbb5a8626c4 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/attributes.xml @@ -0,0 +1,37 @@ + + + + Item 1.1 + + Item 2.1 + + 1 + 2 + test + + + Item 3.1 + diff --git a/dev/tests/integration/testsuite/Magento/PubSub/Event/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/cdata.php similarity index 70% rename from dev/tests/integration/testsuite/Magento/PubSub/Event/FactoryTest.php rename to dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/cdata.php index 56fd99a57b72a..ca689ddbd7bca 100644 --- a/dev/tests/integration/testsuite/Magento/PubSub/Event/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/cdata.php @@ -1,7 +1,5 @@ create('topic', array()); - - $this->assertInstanceOf('Magento\PubSub\EventInterface', $event); - } -} +return array( + 'root' => array( + array( + 'cdata' => array( + array( + 'node_one' => array( + array('__content__' => ''), + ), + ), + ), + 'cdata_next' => array( + array('__content__' => ''), + ), + ), + ), +); \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/PubSub/_files/config.xml b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/cdata.xml similarity index 82% rename from dev/tests/integration/testsuite/Magento/PubSub/_files/config.xml rename to dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/cdata.xml index 0224ee61daf8d..c1d31ac726410 100644 --- a/dev/tests/integration/testsuite/Magento/PubSub/_files/config.xml +++ b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/cdata.xml @@ -1,4 +1,4 @@ - + - - \ No newline at end of file + + + ]]> + + + ]]> + + diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/flat/source_notuniq.xml b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/flat/source_notuniq.xml new file mode 100644 index 0000000000000..1bf30dd2fd3ed --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/flat/source_notuniq.xml @@ -0,0 +1,41 @@ + + + + + + Value1 + + + + 1 + + + 2 + + 1 + 2 + + diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/flat/source_wrongarray.xml b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/flat/source_wrongarray.xml new file mode 100644 index 0000000000000..ce692e13db6b4 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/_files/converter/dom/flat/source_wrongarray.xml @@ -0,0 +1,43 @@ + + + + + + Value1 + + + + 1 + + + 2 + + abcd + bcde + cdef + abcd + + diff --git a/dev/tests/unit/testsuite/Magento/Controller/Router/Route/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Controller/Router/Route/FactoryTest.php new file mode 100644 index 0000000000000..aec5d73f0578e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Controller/Router/Route/FactoryTest.php @@ -0,0 +1,104 @@ +objectManager = $this->getMockBuilder('Magento\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @test + */ + public function testCreateRoute() + { + $routerClass = 'router'; + + $router = $this->getMockBuilder('Zend_Controller_Router_Route_Interface') + ->setMockClassName($routerClass) + ->getMock(); + + $parameterRoute = 'route'; + $parameterDefaults = 'defaults'; + $parameterRegs = 'regs'; + $parameterLocale = 'locale'; + + $this->objectManager->expects($this->once()) + ->method('create') + ->with( + $this->logicalOr( + $routerClass, + array( + 'route' => $parameterRoute, + 'defaults' => $parameterDefaults, + 'regs' => $parameterRegs, + 'locale' => $parameterLocale, + ) + ) + ) + ->will($this->returnValue($router)); + + $object = new \Magento\Controller\Router\Route\Factory($this->objectManager); + $expectedRouter = $object->createRoute( + $routerClass, + $parameterRoute, + $parameterDefaults, + $parameterRegs, + $parameterLocale + ); + + $this->assertInstanceOf($routerClass, $expectedRouter); + $this->assertInstanceOf('Zend_Controller_Router_Route_Interface', $expectedRouter); + } + + /** + * @test + * @expectedException \LogicException + */ + public function testCreateRouteNegative() + { + $this->objectManager->expects($this->once()) + ->method('create') + ->will($this->returnValue(new \StdClass)); + + $object = new \Magento\Controller\Router\Route\Factory($this->objectManager); + $object->createRoute( + 'routerClass', + 'router' + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Convert/ConvertArrayTest.php b/dev/tests/unit/testsuite/Magento/Convert/ConvertArrayTest.php index 74b46f57fafe1..47285d9e20ed5 100644 --- a/dev/tests/unit/testsuite/Magento/Convert/ConvertArrayTest.php +++ b/dev/tests/unit/testsuite/Magento/Convert/ConvertArrayTest.php @@ -25,8 +25,6 @@ */ namespace Magento\Convert; -use Magento\Convert\ConvertArray; - class ConvertArrayTest extends \PHPUnit_Framework_TestCase { /** @@ -52,6 +50,21 @@ public function testAssocToXml() $this->assertEquals($expectedResult, $result->asXML()); } + /** + * @expectedException \Exception + * @expectedExceptionMessage Associative and numeric keys must not be mixed at one level. + */ + public function testAssocToXmlExceptionByKey() + { + $data = array( + 'one' => array( + 100, + 'two' => 'three', + ), + ); + $this->_model->assocToXml($data); + } + /** * @param array $array * @param string $rootName diff --git a/dev/tests/unit/testsuite/Magento/Convert/ExcelTest.php b/dev/tests/unit/testsuite/Magento/Convert/ExcelTest.php index 4a5d9f74d2cf5..4ffbb7a37882c 100644 --- a/dev/tests/unit/testsuite/Magento/Convert/ExcelTest.php +++ b/dev/tests/unit/testsuite/Magento/Convert/ExcelTest.php @@ -41,6 +41,16 @@ class ExcelTest extends \PHPUnit_Framework_TestCase array(1, 'Jon Doe', 'jon.doe@magento.com', 'General', '310-111-1111', 90232, 'United States', 'California') ); + protected $_testHeader = array( + 'HeaderID', 'HeaderName', 'HeaderEmail', 'HeaderGroup', 'HeaderPhone', 'HeaderZIP', + 'HeaderCountry', 'HeaderRegion', + ); + + protected $_testFooter = array( + 'FooterID', 'FooterName', 'FooterEmail', 'FooterGroup', 'FooterPhone', 'FooterZIP', + 'FooterCountry', 'FooterRegion', + ); + /** * Path for Sample File * @@ -75,7 +85,9 @@ public function callbackMethod($row) public function testConvert() { $convert = new \Magento\Convert\Excel(new \ArrayIterator($this->_testData)); - $isEqual = file_get_contents($this->_getSampleOutputFile()) == $convert->convert(); + $convert->setDataHeader($this->_testHeader); + $convert->setDataFooter($this->_testFooter); + $isEqual = (file_get_contents($this->_getSampleOutputFile()) == $convert->convert()); $this->assertTrue($isEqual, 'Failed asserting that data is the same.'); } @@ -107,6 +119,8 @@ protected function _writeFile($callback = false) if (!$callback) { $convert = new \Magento\Convert\Excel(new \ArrayIterator($this->_testData)); + $convert->setDataHeader($this->_testHeader); + $convert->setDataFooter($this->_testFooter); } else { $convert = new \Magento\Convert\Excel( new \ArrayIterator($this->_testData), diff --git a/dev/tests/unit/testsuite/Magento/Convert/ObjectTest.php b/dev/tests/unit/testsuite/Magento/Convert/ObjectTest.php new file mode 100644 index 0000000000000..9bf012b2491e7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Convert/ObjectTest.php @@ -0,0 +1,145 @@ +model = new Object(); + } + + public function testToOptionArray() + { + $mockFirst = $this->getMock('Magento\Object', array('getId', 'getCode'), array()); + $mockFirst->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $mockFirst->expects($this->once()) + ->method('getCode') + ->will($this->returnValue('code1')); + $mockSecond = $this->getMock('Magento\Object', array('getId', 'getCode'), array()); + $mockSecond->expects($this->once()) + ->method('getId') + ->will($this->returnValue(2)); + $mockSecond->expects($this->once()) + ->method('getCode') + ->will($this->returnValue('code2')); + + $callable = function ($item) { + return $item->getCode(); + }; + + $items = array( + $mockFirst, + $mockSecond, + ); + $result = array( + array('value' => 1, 'label' => 'code1'), + array('value' => 2, 'label' => 'code2'), + ); + $this->assertEquals($result, $this->model->toOptionArray($items, 'id', $callable)); + } + + public function testToOptionHash() + { + $mockFirst = $this->getMock('Magento\Object', array('getSome', 'getId'), array()); + $mockFirst->expects($this->once()) + ->method('getId') + ->will($this->returnValue(3)); + $mockFirst->expects($this->once()) + ->method('getSome') + ->will($this->returnValue('code3')); + $mockSecond = $this->getMock('Magento\Object', array('getSome', 'getId'), array()); + $mockSecond->expects($this->once()) + ->method('getId') + ->will($this->returnValue(4)); + $mockSecond->expects($this->once()) + ->method('getSome') + ->will($this->returnValue('code4')); + + $callable = function ($item) { + return $item->getId(); + }; + $items = array( + $mockFirst, + $mockSecond, + ); + $result = array( + 3 => 'code3', + 4 => 'code4', + ); + + $this->assertEquals($result, $this->model->toOptionHash($items, $callable, 'some')); + } + + public function testConvertDataToArray() + { + $object = new \stdClass(); + $object->a = array(array(1)); + $mockFirst = $this->getMock('Magento\Object', array('getData')); + $mockSecond = $this->getMock('Magento\Object', array('getData')); + + $mockFirst->expects($this->any()) + ->method('getData') + ->will($this->returnValue(array( + 'id' => 1, + 'o' => $mockSecond, + ))); + + $mockSecond->expects($this->any()) + ->method('getData') + ->will($this->returnValue(array( + 'id' => 2, + 'o' => $mockFirst, + ))); + + $data = array( + 'object' => $mockFirst, + 'stdClass' => $object, + 'test' => 'test', + ); + $result = array( + 'object' => array( + 'id' => 1, + 'o' => array( + 'id' => 2, + 'o' => '*** CYCLE DETECTED ***', + ), + ), + 'stdClass' => array( + 'a' => array( + array(1), + ), + ), + 'test' => 'test', + ); + $this->assertEquals($result, $this->model->convertDataToArray($data)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Convert/XmlTest.php b/dev/tests/unit/testsuite/Magento/Convert/XmlTest.php index de7157327858e..81a7fd8c292ba 100644 --- a/dev/tests/unit/testsuite/Magento/Convert/XmlTest.php +++ b/dev/tests/unit/testsuite/Magento/Convert/XmlTest.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 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) */ @@ -39,11 +37,23 @@ protected function setUp() public function testXmlToAssoc() { - $xmlstr = <<getXml(); + $result = $this->_model->xmlToAssoc(new \SimpleXMLElement($xmlstr)); + $this->assertEquals( + array( + 'one' => '1', + 'two' => array('three' => '3', 'four' => '4'), + 'five' => array(0 => '5', 1 => '6'), + ), + $result + ); + } + + protected function getXml() + { + return << -<_>134 +<_>13456 XML; - $result = $this->_model->xmlToAssoc(new \SimpleXMLElement($xmlstr)); - $this->assertEquals(array('one' => '1', 'two' => array('three' => '3', 'four' => '4')), $result); } } diff --git a/dev/tests/unit/testsuite/Magento/Convert/_files/output.txt b/dev/tests/unit/testsuite/Magento/Convert/_files/output.txt index a913c5e78070d..5f977525d48cf 100644 --- a/dev/tests/unit/testsuite/Magento/Convert/_files/output.txt +++ b/dev/tests/unit/testsuite/Magento/Convert/_files/output.txt @@ -1 +1 @@ -IDNameEmailGroupTelephoneZIPCountryState/Province1Jon Doejon.doe@magento.comGeneral310-111-111190232United StatesCalifornia
\ No newline at end of file +HeaderIDHeaderNameHeaderEmailHeaderGroupHeaderPhoneHeaderZIPHeaderCountryHeaderRegionIDNameEmailGroupTelephoneZIPCountryState/Province1Jon Doejon.doe@magento.comGeneral310-111-111190232United StatesCaliforniaFooterIDFooterNameFooterEmailFooterGroupFooterPhoneFooterZIPFooterCountryFooterRegion
\ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/DesignLoaderTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/DesignLoaderTest.php index 02649b4fe974a..0f66de76774c6 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/DesignLoaderTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/DesignLoaderTest.php @@ -33,7 +33,7 @@ class DesignLoaderTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_appMock; + protected $_areaListMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -47,35 +47,25 @@ class DesignLoaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_appMock = $this->getMock('\Magento\Core\Model\App', array(), array(), '', false); + $this->_areaListMock = $this->getMock('\Magento\App\AreaList', array(), array(), '', false); $this->_requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); $this->_layoutMock = $this->getMock('Magento\View\LayoutInterface'); - $this->_model = new \Magento\View\DesignLoader($this->_requestMock, $this->_appMock, $this->_layoutMock); + $this->_model = new \Magento\View\DesignLoader( + $this->_requestMock, + $this->_areaListMock, + $this->_layoutMock + ); } public function testLoad() { $area = $this->getMock('Magento\Core\Model\App\Area', array(), array(), '', false); $this->_layoutMock->expects($this->once())->method('getArea')->will($this->returnValue('area')); - $this->_appMock->expects($this->once())->method('getArea')->with('area')->will($this->returnValue($area)); - $area->expects( - $this->at(0) - )->method( - 'load' - )->with( - \Magento\Core\Model\App\Area::PART_DESIGN - )->will( - $this->returnValue($area) - ); - $area->expects( - $this->at(1) - )->method( - 'load' - )->with( - \Magento\Core\Model\App\Area::PART_TRANSLATE - )->will( - $this->returnValue($area) - ); + $this->_areaListMock->expects($this->once())->method('getArea')->with('area')->will($this->returnValue($area)); + $area->expects($this->at(0))->method('load') + ->with(\Magento\Core\Model\App\Area::PART_DESIGN)->will($this->returnValue($area)); + $area->expects($this->at(1))->method('load') + ->with(\Magento\Core\Model\App\Area::PART_TRANSLATE)->will($this->returnValue($area)); $this->_model->load($this->_requestMock); } } 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 fd74a015bd226..d23c519243cf4 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 @@ -56,11 +56,6 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase */ protected $dateModelMock; - /** - * @var \Magento\Core\Model\App |\PHPUnit_Framework_MockObject_MockObject - */ - protected $applicationMock; - /** * @var \Magento\Core\Model\File\Storage\Directory\Database |\PHPUnit_Framework_MockObject_MockObject */ @@ -106,7 +101,6 @@ protected function setUp() false ); $this->dateModelMock = $this->getMock('Magento\Stdlib\DateTime\DateTime', array(), array(), '', false); - $this->applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); $this->directoryMock = $this->getMock( 'Magento\Core\Model\File\Storage\Directory\Database', array('setPath', 'setName', '__wakeup', 'save', 'getParentId'), @@ -139,24 +133,10 @@ protected function setUp() $this->returnValue($this->directoryMock) ); - $this->applicationMock->expects( - $this->any() - )->method( - 'getConfig' - )->will( - $this->returnValue($this->configMock) - ); - - $this->configMock->expects( - $this->any() - )->method( - 'getValue' - )->with( - \Magento\Core\Model\File\Storage::XML_PATH_STORAGE_MEDIA_DATABASE, - 'default' - )->will( - $this->returnValue($this->customConnectionName) - ); + $this->configMock->expects($this->any()) + ->method('getValue') + ->with(\Magento\Core\Model\File\Storage::XML_PATH_STORAGE_MEDIA_DATABASE, 'default') + ->will($this->returnValue($this->customConnectionName)); $this->contextMock->expects($this->once())->method('getLogger')->will($this->returnValue($this->loggerMock)); @@ -165,7 +145,7 @@ protected function setUp() $this->registryMock, $this->helperStorageDatabase, $this->dateModelMock, - $this->applicationMock, + $this->configMock, $this->directoryFactoryMock, $this->resourceDirectoryDatabaseMock, null, diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/LayoutTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/LayoutTest.php index ddedfe212520e..ea1ba62a6d85a 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/LayoutTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/LayoutTest.php @@ -61,7 +61,7 @@ protected function setUp() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testCreateBlockException() { diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php index a76d2e04506a0..0c84a2e127432 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php @@ -26,14 +26,14 @@ */ /** - * Test class for \Magento\Core\Model\Resource\Db\AbstractDb. + * Test class for \Magento\Model\Resource\Db\AbstractDb. */ namespace Magento\Core\Model\Resource\Db; class AbstractTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Resource\Db\AbstractDb|PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Model\Resource\Db\AbstractDb|PHPUnit_Framework_MockObject_MockObject */ protected $_model; @@ -46,7 +46,7 @@ protected function setUp() { $this->_resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false); $this->_model = $this->getMock( - 'Magento\Core\Model\Resource\Db\AbstractDb', + 'Magento\Model\Resource\Db\AbstractDb', array('_construct', '_getWriteAdapter'), array($this->_resource) ); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Layout/AbstractTestCase.php b/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Layout/AbstractTestCase.php index 80a2ff151f4d3..5e5eec5b7784a 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Layout/AbstractTestCase.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Layout/AbstractTestCase.php @@ -81,7 +81,7 @@ protected function _getResource(\Zend_Db_Select $select) $connection->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0)); $resource = $this->getMockForAbstractClass( - 'Magento\Core\Model\Resource\Db\AbstractDb', + 'Magento\Model\Resource\Db\AbstractDb', array(), '', false, @@ -98,7 +98,7 @@ protected function _getResource(\Zend_Db_Select $select) /** * @abstract * @param \Zend_Db_Select $select - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ abstract protected function _getCollection(\Zend_Db_Select $select); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/StoreManagerTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/StoreManagerTest.php index b98146d1c2828..933a3db8504b9 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/StoreManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/StoreManagerTest.php @@ -212,7 +212,7 @@ public function testGetSafeStoreWithExceptionWithCurrentStore() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testGetSafeStoreWithExceptionAndWithoutCurrentStore() { 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 e542caa702929..822a49b39d020 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 @@ -33,7 +33,7 @@ class ApplicationInitializerTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $applicationMock; + protected $appStateMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -47,15 +47,18 @@ class ApplicationInitializerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->applicationMock = $this->getMock('Magento\AppInterface'); + $this->appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false); $this->sidResolverMock = $this->getMock('\Magento\Session\SidResolverInterface', array(), array(), '', false); $this->subjectMock = $this->getMock('Magento\App\Cron', array(), array(), '', false); - $this->model = new ApplicationInitializer($this->applicationMock, $this->sidResolverMock); + $this->model = new ApplicationInitializer( + $this->appStateMock, + $this->sidResolverMock + ); } public function testBeforeExecutePerformsRequiredChecks() { - $this->applicationMock->expects($this->once())->method('requireInstalledInstance'); + $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->sidResolverMock->expects($this->once())->method('setUseSessionInUrl')->with(false); $this->model->beforeLaunch($this->subjectMock); } diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Cron/Model/ObserverTest.php index 46b8eba3ea633..5c1d55219cdfb 100644 --- a/dev/tests/unit/testsuite/Magento/Cron/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Cron/Model/ObserverTest.php @@ -42,9 +42,9 @@ class ObserverTest extends \PHPUnit_Framework_TestCase protected $_objectManager; /** - * @var \Magento\Core\Model\App|\PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_app; + protected $_cache; /** * @var \Magento\Cron\Model\Config|\PHPUnit_Framework_MockObject_MockObject @@ -87,7 +87,7 @@ public function setUp() $this->_objectManager = $this->getMockBuilder( 'Magento\App\ObjectManager' )->disableOriginalConstructor()->getMock(); - $this->_app = $this->getMockBuilder('Magento\Core\Model\App')->disableOriginalConstructor()->getMock(); + $this->_cache = $this->getMock('Magento\App\CacheInterface'); $this->_config = $this->getMockBuilder('Magento\Cron\Model\Config')->disableOriginalConstructor()->getMock(); $this->_coreStoreConfig = $this->getMockBuilder( 'Magento\Core\Model\Store\Config' @@ -116,7 +116,7 @@ public function setUp() $this->_observer = new \Magento\Cron\Model\Observer( $this->_objectManager, $this->_scheduleFactory, - $this->_app, + $this->_cache, $this->_config, $this->_coreStoreConfig, $this->_request, @@ -130,8 +130,12 @@ public function setUp() public function testDispatchNoPendingJobs() { $lastRun = time() + 10000000; - $this->_app->expects($this->any())->method('loadCache')->will($this->returnValue($lastRun)); - $this->_coreStoreConfig->expects($this->any())->method('getConfig')->will($this->returnValue(0)); + $this->_cache->expects($this->any()) + ->method('load') + ->will($this->returnValue($lastRun)); + $this->_coreStoreConfig->expects($this->any()) + ->method('getConfig') + ->will($this->returnValue(0)); $this->_config->expects($this->once())->method('getJobs')->will($this->returnValue(array())); @@ -148,8 +152,12 @@ public function testDispatchNoPendingJobs() public function testDispatchNoJobConfig() { $lastRun = time() + 10000000; - $this->_app->expects($this->any())->method('loadCache')->will($this->returnValue($lastRun)); - $this->_coreStoreConfig->expects($this->any())->method('getConfig')->will($this->returnValue(0)); + $this->_cache->expects($this->any()) + ->method('load') + ->will($this->returnValue($lastRun)); + $this->_coreStoreConfig->expects($this->any()) + ->method('getConfig') + ->will($this->returnValue(0)); $this->_config->expects( $this->once() @@ -179,8 +187,12 @@ public function testDispatchNoJobConfig() public function testDispatchCanNotLock() { $lastRun = time() + 10000000; - $this->_app->expects($this->any())->method('loadCache')->will($this->returnValue($lastRun)); - $this->_coreStoreConfig->expects($this->any())->method('getConfig')->will($this->returnValue(0)); + $this->_cache->expects($this->any()) + ->method('load') + ->will($this->returnValue($lastRun)); + $this->_coreStoreConfig->expects($this->any()) + ->method('getConfig') + ->will($this->returnValue(0)); $schedule = $this->getMockBuilder( 'Magento\Cron\Model\Schedule' @@ -216,8 +228,12 @@ public function testDispatchExceptionTooLate() $exceptionMessage = 'Too late for the schedule'; $lastRun = time() + 10000000; - $this->_app->expects($this->any())->method('loadCache')->will($this->returnValue($lastRun)); - $this->_coreStoreConfig->expects($this->any())->method('getConfig')->will($this->returnValue(0)); + $this->_cache->expects($this->any()) + ->method('load') + ->will($this->returnValue($lastRun)); + $this->_coreStoreConfig->expects($this->any()) + ->method('getConfig') + ->will($this->returnValue(0)); $schedule = $this->getMockBuilder( 'Magento\Cron\Model\Schedule' @@ -290,7 +306,9 @@ public function testDispatchExceptionNoCallback() $this->_config->expects($this->once())->method('getJobs')->will($this->returnValue($jobConfig)); $lastRun = time() + 10000000; - $this->_app->expects($this->any())->method('loadCache')->will($this->returnValue($lastRun)); + $this->_cache->expects($this->any()) + ->method('load') + ->will($this->returnValue($lastRun)); $this->_coreStoreConfig->expects( $this->any() @@ -345,14 +363,12 @@ public function testDispatchExceptionNotExecutable() $this->_config->expects($this->once())->method('getJobs')->will($this->returnValue($jobConfig)); $lastRun = time() + 10000000; - $this->_app->expects($this->any())->method('loadCache')->will($this->returnValue($lastRun)); - $this->_coreStoreConfig->expects( - $this->any() - )->method( - 'getConfig' - )->will( - $this->returnValue(strtotime('+1 day')) - ); + $this->_cache->expects($this->any()) + ->method('load') + ->will($this->returnValue($lastRun)); + $this->_coreStoreConfig->expects($this->any()) + ->method('getConfig') + ->will($this->returnValue(strtotime('+1 day'))); $scheduleMock = $this->getMockBuilder('Magento\Cron\Model\Schedule')->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); @@ -433,14 +449,12 @@ public function testDispatchRunJob() $this->_config->expects($this->once())->method('getJobs')->will($this->returnValue($jobConfig)); $lastRun = time() + 10000000; - $this->_app->expects($this->any())->method('loadCache')->will($this->returnValue($lastRun)); - $this->_coreStoreConfig->expects( - $this->any() - )->method( - 'getConfig' - )->will( - $this->returnValue(strtotime('+1 day')) - ); + $this->_cache->expects($this->any()) + ->method('load') + ->will($this->returnValue($lastRun)); + $this->_coreStoreConfig->expects($this->any()) + ->method('getConfig') + ->will($this->returnValue(strtotime('+1 day'))); $scheduleMock = $this->getMockBuilder('Magento\Cron\Model\Schedule')->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); @@ -478,24 +492,14 @@ public function testDispatchNotGenerate() $this->returnValue(array('test_group' => array())) ); - $this->_app->expects( - $this->at(0) - )->method( - 'loadCache' - )->with( - $this->equalTo(\Magento\Cron\Model\Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT) - )->will( - $this->returnValue(time() - 10000000) - ); - $this->_app->expects( - $this->at(2) - )->method( - 'loadCache' - )->with( - $this->equalTo(\Magento\Cron\Model\Observer::CACHE_KEY_LAST_HISTORY_CLEANUP_AT) - )->will( - $this->returnValue(time() + 10000000) - ); + $this->_cache->expects($this->at(0)) + ->method('load') + ->with($this->equalTo(\Magento\Cron\Model\Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT)) + ->will($this->returnValue(time() - 10000000)); + $this->_cache->expects($this->at(2)) + ->method('load') + ->with($this->equalTo(\Magento\Cron\Model\Observer::CACHE_KEY_LAST_HISTORY_CLEANUP_AT)) + ->will($this->returnValue(time() + 10000000)); $this->_coreStoreConfig->expects($this->any())->method('getConfig')->will($this->returnValue(0)); @@ -510,7 +514,7 @@ public function testDispatchNotGenerate() $this->_collection->addItem(new \Magento\Object()); $this->_collection->addItem($schedule); - $this->_app->expects($this->any())->method('saveCache'); + $this->_cache->expects($this->any())->method('save'); $scheduleMock = $this->getMockBuilder('Magento\Cron\Model\Schedule')->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); @@ -540,24 +544,14 @@ public function testDispatchGenerate() ); $this->_config->expects($this->at(1))->method('getJobs')->will($this->returnValue($jobs)); - $this->_app->expects( - $this->at(0) - )->method( - 'loadCache' - )->with( - $this->equalTo(\Magento\Cron\Model\Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT) - )->will( - $this->returnValue(time() - 10000000) - ); - $this->_app->expects( - $this->at(2) - )->method( - 'loadCache' - )->with( - $this->equalTo(\Magento\Cron\Model\Observer::CACHE_KEY_LAST_HISTORY_CLEANUP_AT) - )->will( - $this->returnValue(time() + 10000000) - ); + $this->_cache->expects($this->at(0)) + ->method('load') + ->with($this->equalTo(\Magento\Cron\Model\Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT)) + ->will($this->returnValue(time() - 10000000)); + $this->_cache->expects($this->at(2)) + ->method('load') + ->with($this->equalTo(\Magento\Cron\Model\Observer::CACHE_KEY_LAST_HISTORY_CLEANUP_AT)) + ->will($this->returnValue(time() + 10000000)); $this->_coreStoreConfig->expects($this->at(0))->method('getConfig')->will($this->returnValue(0)); @@ -575,7 +569,7 @@ public function testDispatchGenerate() $this->_collection->addItem(new \Magento\Object()); $this->_collection->addItem($schedule); - $this->_app->expects($this->any())->method('saveCache'); + $this->_cache->expects($this->any())->method('save'); $scheduleMock = $this->getMockBuilder( 'Magento\Cron\Model\Schedule' @@ -611,8 +605,12 @@ public function testDispatchCleanup() $this->_config->expects($this->once())->method('getJobs')->will($this->returnValue($jobConfig)); - $this->_app->expects($this->at(0))->method('loadCache')->will($this->returnValue(time() + 10000000)); - $this->_app->expects($this->at(1))->method('loadCache')->will($this->returnValue(time() - 10000000)); + $this->_cache->expects($this->at(0)) + ->method('load') + ->will($this->returnValue(time() + 10000000)); + $this->_cache->expects($this->at(1)) + ->method('load') + ->will($this->returnValue(time() - 10000000)); $this->_coreStoreConfig->expects($this->any())->method('getConfig')->will($this->returnValue(0)); 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 459018658c0bf..baecc1ffaa1c5 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php @@ -285,7 +285,7 @@ public function testResetPasswordActionCoreException() ); // Setup a core exception to return - $exception = new \Magento\Core\Exception(); + $exception = new \Magento\Model\Exception(); $error = new \Magento\Message\Error('Something Bad happened'); $exception->addMessage($error); @@ -322,7 +322,7 @@ public function testResetPasswordActionCoreExceptionWarn() ); // Setup a core exception to return - $exception = new \Magento\Core\Exception($warningText); + $exception = new \Magento\Model\Exception($warningText); $error = new \Magento\Message\Warning('Something Not So Bad happened'); $exception->addMessage($error); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php index fc1f50bfa7e44..704ee5a9d56d5 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php @@ -35,7 +35,7 @@ class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase { /** - * @var DepersonalizePlugin + * @var \Magento\Customer\Model\Layout\DepersonalizePlugin */ protected $plugin; diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php index 58c7cb5a37474..cf8ec428ec2ae 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php @@ -86,7 +86,7 @@ public function testGetAttribute() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Attribute object is undefined */ public function testGetAttributeException() diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php index 20c0dfd851ecc..60b5c365d7c84 100755 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php @@ -118,6 +118,11 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase */ private $_urlMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Logger + */ + private $_loggerMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Helper\Data */ @@ -254,7 +259,13 @@ public function setUp() $this->returnValue($this->_customerHelperMock) ); - $this->_urlMock = $this->getMockBuilder('\Magento\UrlInterface')->disableOriginalConstructor()->getMock(); + $this->_urlMock = $this->getMockBuilder('\Magento\UrlInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->_loggerMock = $this->getMockBuilder('\Magento\Logger') + ->disableOriginalConstructor() + ->getMock(); } public function testActivateAccount() @@ -453,7 +464,7 @@ public function testLoginAccountWithException() )->method( 'authenticate' )->will( - $this->throwException(new \Magento\Core\Exception('exception message')) + $this->throwException(new \Magento\Model\Exception('exception message')) ); $this->_customerFactoryMock->expects( @@ -689,7 +700,7 @@ public function testSendPasswordResetLinkBadEmailOrWebsite() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Invalid transactional email code: 0 */ public function testSendPasswordResetLinkSendException() @@ -716,7 +727,7 @@ public function testSendPasswordResetLinkSendException() )->method( 'sendPasswordResetConfirmationEmail' )->will( - $this->throwException(new \Magento\Core\Exception(__('Invalid transactional email code: %1', 0))) + $this->throwException(new \Magento\Model\Exception(__('Invalid transactional email code: %1', 0))) ); $customerService = $this->_createService(); @@ -728,6 +739,36 @@ public function testSendPasswordResetLinkSendException() ); } + public function testSendPasswordResetLinkSendMailException() + { + $email = 'foo@example.com'; + $this->_mockReturnValue( + $this->_customerModelMock, + array( + 'getId' => self::ID, + 'setWebsiteId' => $this->_customerModelMock, + 'loadByEmail' => $this->_customerModelMock, + ) + ); + $this->_customerFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->_customerModelMock)); + + $exception = new \Magento\Mail\Exception(__('The mail server is down')); + + $this->_customerModelMock->expects($this->once()) + ->method('sendPasswordResetConfirmationEmail') + ->will($this->throwException($exception)); + + $this->_loggerMock->expects($this->once()) + ->method('logException') + ->with($exception); + + $customerService = $this->_createService(); + + $customerService->initiatePasswordReset($email, self::WEBSITE_ID, CustomerAccountServiceInterface::EMAIL_RESET); + } + public function testResetPassword() { $resetToken = 'lsdj579slkj5987slkj595lkj'; @@ -1041,6 +1082,40 @@ public function testResendConfirmationNotNeeded() $customerService->resendConfirmation('email@test.com', 2); } + public function testResendConfirmationWithMailException() + { + $this->_customerFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->_customerModelMock)); + $this->_customerModelMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue(55)); + $this->_customerModelMock->expects($this->once()) + ->method('setWebsiteId') + ->will($this->returnSelf()); + $this->_customerModelMock->expects($this->any()) + ->method('isConfirmationRequired') + ->will($this->returnValue(true)); + $this->_customerModelMock->expects($this->any()) + ->method('getConfirmation') + ->will($this->returnValue('123abc')); + + $exception = new \Magento\Mail\Exception(__('The mail server is down')); + + $this->_customerModelMock->expects($this->once()) + ->method('sendNewAccountEmail') + ->withAnyParameters() + ->will($this->throwException($exception)); + + $this->_loggerMock->expects($this->once()) + ->method('logException') + ->with($exception); + + $customerService = $this->_createService(); + $customerService->resendConfirmation('email', 1); + // If we call sendNewAccountEmail and no exception is returned, the test succeeds + } + /** * @dataProvider testGetConfirmationStatusDataProvider * @param string $expected The expected confirmation status. @@ -1753,6 +1828,76 @@ public function testIsEmailAvailableNegative() $this->assertFalse($service->isEmailAvailable('email', 1)); } + public function testCreateAccountMailException() + { + $this->_customerFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->_customerModelMock)); + + // This is to get the customer model through validation + $this->_customerModelMock->expects($this->any()) + ->method('getFirstname') + ->will($this->returnValue('John')); + + $this->_customerModelMock->expects($this->any()) + ->method('getLastname') + ->will($this->returnValue('Doe')); + + $this->_customerModelMock->expects($this->any()) + ->method('getEmail') + ->will($this->returnValue('somebody@example.com')); + + // This is to get the customer model through Converter::getCustomerModel + $this->_customerModelMock->expects($this->once()) + ->method('load') + ->will($this->returnSelf()); + + $this->_customerModelMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue(true)); + + $exception = new \Magento\Mail\Exception(__('The mail server is down')); + + $this->_customerModelMock->expects($this->once()) + ->method('sendNewAccountEmail') + ->will($this->throwException($exception)); + + $this->_loggerMock->expects($this->once()) + ->method('logException') + ->with($exception); + + $this->_customerModelMock->expects($this->once()) + ->method('getAttributes') + ->will($this->returnValue([])); + + $mockCustomer = $this->getMockBuilder('Magento\Customer\Service\V1\Data\Customer') + ->disableOriginalConstructor() + ->getMock(); + + $mockCustomer->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue(true)); + + $mockCustomer->expects($this->once()) + ->method('__toArray') + ->will($this->returnValue(['attributeSetId' => true])); + + /** + * @var \Magento\Customer\Service\V1\Data\CustomerDetails | \PHPUnit_Framework_MockObject_MockObject + */ + $mockCustomerDetail = $this->getMockBuilder('Magento\Customer\Service\V1\Data\CustomerDetails') + ->disableOriginalConstructor() + ->getMock(); + + $mockCustomerDetail->expects($this->once()) + ->method('getCustomer') + ->will($this->returnValue($mockCustomer)); + + $service = $this->_createService(); + $service->createAccount($mockCustomerDetail, 'abc123'); + // If we get no mail exception, the test in considered a success + } + private function _setupStoreMock() { $this->_storeManagerMock = $this->getMockBuilder( @@ -1802,8 +1947,11 @@ private function _createService() $this->_customerAddressServiceMock, $this->_customerMetadataService, $this->_urlMock, + $this->_loggerMock, $this->_objectManagerMock ); return $customerService; } + + } diff --git a/dev/tests/unit/testsuite/Magento/Data/Collection/DbTest.php b/dev/tests/unit/testsuite/Magento/Data/Collection/DbTest.php index 5ae0934eedff5..3fab3af764149 100644 --- a/dev/tests/unit/testsuite/Magento/Data/Collection/DbTest.php +++ b/dev/tests/unit/testsuite/Magento/Data/Collection/DbTest.php @@ -31,23 +31,46 @@ class DbTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Data\Collection\Db */ - protected $_collection; + protected $collection; + + /** + * @var \Magento\Logger|\PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @var \Magento\Core\Model\EntityFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $entityFactoryMock; + + /** + * @var \Magento\Data\Collection\Db\FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fetchStrategyMock; protected function setUp() { - $fetchStrategy = $this->getMockForAbstractClass('Magento\Data\Collection\Db\FetchStrategyInterface'); - $entityFactory = $this->getMock('Magento\Core\Model\EntityFactory', array(), array(), '', false); - $logger = $this->getMock('Magento\Logger', array(), array(), '', false); - $this->_collection = new \Magento\Data\Collection\Db($entityFactory, $logger, $fetchStrategy); + $this->fetchStrategyMock = $this->getMock( + 'Magento\Data\Collection\Db\FetchStrategy\Query', array('fetchAll'), array(), '', false + ); + $this->entityFactoryMock = $this->getMock( + 'Magento\Core\Model\EntityFactory', array('create'), array(), '', false + ); + $this->loggerMock = $this->getMock('Magento\Logger', array('log'), array(), '', false); + $this->collection = new \Magento\Data\Collection\Db( + $this->entityFactoryMock, + $this->loggerMock, + $this->fetchStrategyMock + ); } protected function tearDown() { - unset($this->_collection); + unset($this->collection); } /** - * @return \PHPUnit_Framework_MockObject_MockObject|Zend_Db_Adapter_Abstract + * @return \PHPUnit_Framework_MockObject_MockObject|\Zend_Db_Adapter_Abstract */ public function testSetAddOrder() { @@ -60,18 +83,18 @@ public function testSetAddOrder() true, array('fetchAll') ); - $this->_collection->setConnection($adapter); + $this->collection->setConnection($adapter); - $select = $this->_collection->getSelect(); + $select = $this->collection->getSelect(); $this->assertEmpty($select->getPart(\Zend_Db_Select::ORDER)); /* Direct access to select object is available and many places are using it for sort order declaration */ $select->order('select_field', \Magento\Data\Collection::SORT_ORDER_ASC); - $this->_collection->addOrder('some_field', \Magento\Data\Collection::SORT_ORDER_ASC); - $this->_collection->setOrder('other_field', \Magento\Data\Collection::SORT_ORDER_ASC); - $this->_collection->addOrder('other_field', \Magento\Data\Collection::SORT_ORDER_DESC); + $this->collection->addOrder('some_field', \Magento\Data\Collection::SORT_ORDER_ASC); + $this->collection->setOrder('other_field', \Magento\Data\Collection::SORT_ORDER_ASC); + $this->collection->addOrder('other_field', \Magento\Data\Collection::SORT_ORDER_DESC); - $this->_collection->load(); + $this->collection->load(); $selectOrders = $select->getPart(\Zend_Db_Select::ORDER); $this->assertEquals(array('select_field', 'ASC'), array_shift($selectOrders)); $this->assertEquals('some_field ASC', (string)array_shift($selectOrders)); @@ -87,12 +110,12 @@ public function testSetAddOrder() */ public function testUnshiftOrder($adapter) { - $this->_collection->setConnection($adapter); - $this->_collection->addOrder('some_field', \Magento\Data\Collection::SORT_ORDER_ASC); - $this->_collection->unshiftOrder('other_field', \Magento\Data\Collection::SORT_ORDER_ASC); + $this->collection->setConnection($adapter); + $this->collection->addOrder('some_field', \Magento\Data\Collection::SORT_ORDER_ASC); + $this->collection->unshiftOrder('other_field', \Magento\Data\Collection::SORT_ORDER_ASC); - $this->_collection->load(); - $selectOrders = $this->_collection->getSelect()->getPart(\Zend_Db_Select::ORDER); + $this->collection->load(); + $selectOrders = $this->collection->getSelect()->getPart(\Zend_Db_Select::ORDER); $this->assertEquals('other_field ASC', (string)array_shift($selectOrders)); $this->assertEquals('some_field ASC', (string)array_shift($selectOrders)); $this->assertEmpty(array_shift($selectOrders)); @@ -114,10 +137,10 @@ public function testAddFieldToFilter() )->will( $this->returnValue('is_imported = 1') ); - $this->_collection->setConnection($adapter); - $select = $this->_collection->getSelect()->from('test'); + $this->collection->setConnection($adapter); + $select = $this->collection->getSelect()->from('test'); - $this->_collection->addFieldToFilter('is_imported', array('eq' => '1')); + $this->collection->addFieldToFilter('is_imported', array('eq' => '1')); $this->assertEquals('SELECT `test`.* FROM `test` WHERE (is_imported = 1)', $select->assemble()); } @@ -148,10 +171,10 @@ public function testAddFieldToFilterWithMultipleParams() )->will( $this->returnValue("name like 'M%'") ); - $this->_collection->setConnection($adapter); - $select = $this->_collection->getSelect()->from("test"); + $this->collection->setConnection($adapter); + $select = $this->collection->getSelect()->from("test"); - $this->_collection->addFieldToFilter( + $this->collection->addFieldToFilter( array('weight', 'name'), array(array('in' => array(1, 3)), array('like' => 'M%')) ); @@ -172,7 +195,7 @@ public function testAddFieldToFilterWithMultipleParams() $this->returnValue('is_imported = 1') ); - $this->_collection->addFieldToFilter('is_imported', array('eq' => '1')); + $this->collection->addFieldToFilter('is_imported', array('eq' => '1')); $this->assertEquals( "SELECT `test`.* FROM `test` WHERE ((weight in (1, 3)) OR (name like 'M%')) AND (is_imported = 1)", $select->assemble() @@ -202,10 +225,10 @@ public function testAddFieldToFilterValueContainsQuestionMark() $this->returnValue('email LIKE \'%value?%\'') ); $adapter->expects($this->once())->method('select')->will($this->returnValue(new \Magento\DB\Select($adapter))); - $this->_collection->setConnection($adapter); + $this->collection->setConnection($adapter); - $select = $this->_collection->getSelect()->from('test'); - $this->_collection->addFieldToFilter('email', array('like' => 'value?')); + $select = $this->collection->getSelect()->from('test'); + $this->collection->addFieldToFilter('email', array('like' => 'value?')); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (email LIKE '%value?%')", $select->assemble()); } @@ -240,10 +263,10 @@ public function testAddFieldToFilterFieldIsQuoted() )->will( $this->returnValue('`email` = "foo@example.com"') ); - $this->_collection->setConnection($adapter); - $select = $this->_collection->getSelect()->from('test'); + $this->collection->setConnection($adapter); + $select = $this->collection->getSelect()->from('test'); - $this->_collection->addFieldToFilter('email', array('eq' => 'foo@example.com')); + $this->collection->addFieldToFilter('email', array('eq' => 'foo@example.com')); $this->assertEquals('SELECT `test`.* FROM `test` WHERE (`email` = "foo@example.com")', $select->assemble()); } @@ -256,15 +279,15 @@ public function testAddFieldToFilterFieldIsQuoted() public function testClone() { $adapter = $this->getMockForAbstractClass('Zend_Db_Adapter_Abstract', array(), '', false); - $this->_collection->setConnection($adapter); - $this->assertInstanceOf('Zend_Db_Select', $this->_collection->getSelect()); + $this->collection->setConnection($adapter); + $this->assertInstanceOf('Zend_Db_Select', $this->collection->getSelect()); - $clonedCollection = clone $this->_collection; + $clonedCollection = clone $this->collection; $this->assertInstanceOf('Zend_Db_Select', $clonedCollection->getSelect()); $this->assertNotSame( $clonedCollection->getSelect(), - $this->_collection->getSelect(), + $this->collection->getSelect(), 'Collection was cloned but $this->_select in both initial and cloned collections reference the same object' ); } @@ -280,8 +303,8 @@ public function testClone() public function testPrintLogQueryPrinting($printQuery, $printFlag, $query, $expected) { $this->expectOutputString($expected); - $this->_collection->setFlag('print_query', $printFlag); - $this->_collection->printLogQuery($printQuery, false, $query); + $this->collection->setFlag('print_query', $printFlag); + $this->collection->printLogQuery($printQuery, false, $query); } public function printLogQueryPrintingDataProvider() @@ -302,21 +325,238 @@ public function printLogQueryPrintingDataProvider() */ public function testPrintLogQueryLogging($logQuery, $logFlag, $expectedCalls) { - $fetchStrategy = $this->getMock('Magento\Data\Collection\Db\FetchStrategyInterface'); - $entityFactory = $this->getMock('Magento\Core\Model\EntityFactory', array(), array(), '', false); - $logger = $this->getMock('Magento\Logger', array(), array(), '', false); - $collection = $this->getMock( - 'Magento\Data\Collection\Db', - array('_logQuery'), - array($entityFactory, $logger, $fetchStrategy) - ); - $collection->setFlag('log_query', $logFlag); - $collection->expects($this->exactly($expectedCalls))->method('_logQuery'); - $collection->printLogQuery(false, $logQuery, 'some_query'); + $this->collection->setFlag('log_query', $logFlag); + $this->loggerMock->expects($this->exactly($expectedCalls))->method('log'); + $this->collection->printLogQuery(false, $logQuery, 'some_query'); } public function printLogQueryLoggingDataProvider() { - return array(array(true, false, 1), array(false, true, 1), array(false, false, 0)); + return array( + array(true, false, 1), + array(false, true, 1), + array(false, false, 0), + ); + } + + /** + * @expectedException \Zend_Exception + * @expectedExceptionMessage dbModel read resource does not implement \Zend_Db_Adapter_Abstract + */ + public function testSetConnectionException() + { + $adapter = new \stdClass(); + $this->collection->setConnection($adapter); + } + + public function testFetchItem() + { + $data = array(1 => 'test'); + $counter = 0; + $statementMock = $this->getMock('Zend_Db_Statement_Pdo', array('fetch'), array(), '', false); + $statementMock->expects($this->exactly(2)) + ->method('fetch') + ->will($this->returnCallback(function () use (&$counter, $data) { + return ++$counter % 2 ? array() : $data; + })); + + $adapterMock = $this->getMock('Zend_Db_Adapter_Pdo_Mysql', + array('select', 'query'), array(), '', false); + $selectMock = $this->getMock( + 'Magento\DB\Select', array(), array('adapter' => $adapterMock) + ); + $adapterMock->expects($this->once()) + ->method('query') + ->with($selectMock, $this->anything()) + ->will($this->returnValue($statementMock)); + $adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($selectMock)); + + $this->collection->setConnection($adapterMock); + $this->assertFalse($this->collection->fetchItem()); + + $objectMock = $this->getMock('Magento\Object', array('setData'), array()); + $objectMock->expects($this->once()) + ->method('setData') + ->with($data); + $this->entityFactoryMock->expects($this->once()) + ->method('create') + ->with('Magento\Object') + ->will($this->returnValue($objectMock)); + + $this->assertEquals($objectMock, $this->collection->fetchItem()); + } + + public function testGetSize() + { + $countSql = 500; + $adapterMock = $this->getMock( + 'Zend_Db_Adapter_Pdo_Mysql', + array('select', 'quoteInto', 'prepareSqlCondition', 'fetchOne'), + array(), + '', + false + ); + $selectMock = $this->getMock( + 'Magento\DB\Select', array('orWhere', 'where', 'reset', 'columns'), array('adapter' => $adapterMock) + ); + $selectMock->expects($this->exactly(4)) + ->method('reset'); + $selectMock->expects($this->once()) + ->method('columns') + ->with('COUNT(*)'); + $adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($selectMock)); + $adapterMock->expects($this->exactly(2)) + ->method('quoteInto') + ->will($this->returnValueMap(array( + array('testField1=?', 'testValue1', null, null, 'testField1=testValue1'), + array('testField4=?', 'testValue4', null, null, 'testField4=testValue4'), + ))); + $selectMock->expects($this->once()) + ->method('orWhere') + ->with('testField1=testValue1'); + $selectMock->expects($this->exactly(3)) + ->method('where') + ->will($this->returnValueMap(array( + array('testValue2', $this->returnSelf()), + array('testField3 = testValue3', null, \Magento\DB\Select::TYPE_CONDITION, $this->returnSelf()), + array('testField4=testValue4', $this->returnSelf()), + ))); + $adapterMock->expects($this->once()) + ->method('prepareSqlCondition') + ->with('testField3', 'testValue3') + ->will($this->returnValue('testField3 = testValue3')); + $adapterMock->expects($this->once()) + ->method('fetchOne') + ->with($selectMock, array()) + ->will($this->returnValue($countSql)); + + $this->collection->addFilter('testField1', 'testValue1', 'or'); + $this->collection->addFilter('testField2', 'testValue2', 'string'); + $this->collection->addFilter('testField3', 'testValue3', 'public'); + $this->collection->addFilter('testField4', 'testValue4'); + $this->collection->setConnection($adapterMock); + $this->assertEquals($countSql, $this->collection->getSize()); + $this->assertEquals($countSql, $this->collection->getSize()); + } + + public function testGetSelectSql() + { + $adapterMock = $this->getMock('Zend_Db_Adapter_Pdo_Mysql', array('select'), array(), '', false); + $selectMock = $this->getMock( + 'Magento\DB\Select', array('__toString'), array('adapter' => $adapterMock) + ); + $adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($selectMock)); + + $sql = 'query'; + $selectMock->expects($this->once()) + ->method('__toString') + ->will($this->returnValue($sql)); + + $this->collection->setConnection($adapterMock); + $this->assertEquals($sql, $this->collection->getSelectSql(true)); + $this->assertEquals($selectMock, $this->collection->getSelectSql()); + } + + public function testGetData() + { + $adapterMock = $this->getMock( + 'Zend_Db_Adapter_Pdo_Mysql', + array('select', 'quoteInto', 'prepareSqlCondition', 'fetchOne'), + array(), + '', + false + ); + $selectMock = $this->getMock( + 'Magento\DB\Select', array('orWhere', 'where', 'reset', 'columns'), array('adapter' => $adapterMock) + ); + $selectMock->expects($this->once()) + ->method('where') + ->with('aliasField3 = testValue3', null, \Magento\DB\Select::TYPE_CONDITION) + ->will($this->returnSelf()); + + $adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($selectMock)); + $adapterMock->expects($this->once()) + ->method('prepareSqlCondition') + ->with('aliasField3', 'testValue3') + ->will($this->returnValue('aliasField3 = testValue3')); + + $this->collection->addFilter('testField3', 'testValue3', 'public'); + $this->collection->addFilterToMap('testFilter', 'testAlias', 'testGroup'); + $this->collection->addFilterToMap('testField3', 'aliasField3'); + + $this->collection->setConnection($adapterMock); + $this->assertNull($this->collection->getData()); + } + + /** + * @dataProvider distinctDataProvider + */ + public function testDistinct($flag, $expectedFlag) + { + $adapterMock = $this->getMock('Zend_Db_Adapter_Pdo_Mysql', array('select'), array(), '', false); + $selectMock = $this->getMock('Magento\DB\Select', array('distinct'), array('adapter' => $adapterMock)); + $adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($selectMock)); + $selectMock->expects($this->once()) + ->method('distinct') + ->with($expectedFlag); + + $this->collection->setConnection($adapterMock); + $this->collection->distinct($flag); + } + + public function distinctDataProvider() + { + return array( + array(true, true), + array(false, false), + ); + } + + public function testToOptionHash() + { + $data = array(10 => 'test'); + $adapterMock = $this->getMock('Zend_Db_Adapter_Pdo_Mysql', + array('select', 'query'), array(), '', false); + $selectMock = $this->getMock( + 'Magento\DB\Select', array(), array('adapter' => $adapterMock) + ); + $adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($selectMock)); + + $this->fetchStrategyMock->expects($this->once()) + ->method('fetchAll') + ->with($selectMock, array()) + ->will($this->returnValue(array($data))); + + $objectMock = $this->getMock('Magento\Object', array('addData', 'setIdFieldName', 'getData'), array()); + $objectMock->expects($this->once()) + ->method('addData') + ->with($data); + $objectMock->expects($this->any()) + ->method('getData') + ->will($this->returnValueMap(array( + array(null, null, 10), + array('name', null, 'test'), + ))); + $this->entityFactoryMock->expects($this->once()) + ->method('create') + ->with('Magento\Object') + ->will($this->returnValue($objectMock)); + + $this->collection->setConnection($adapterMock); + $this->collection->loadData(false, false); + $this->collection->loadData(false, false); + $this->assertEquals($data, $this->collection->toOptionHash()); } } diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Helper/DataTest.php index eb7c49c8f1953..8cb2d01af1ecd 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Helper/DataTest.php @@ -100,13 +100,4 @@ public function testGetDisabledCacheTypes() ); $this->assertEquals($this->_disabledCacheTypes, $this->_model->getDisabledCacheTypes()); } - - public function testGetAvailableModes() - { - $this->_model = new \Magento\DesignEditor\Helper\Data($this->_context, self::TEST_FRONT_NAME); - $this->assertEquals( - array(\Magento\DesignEditor\Model\State::MODE_NAVIGATION), - $this->_model->getAvailableModes() - ); - } } diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php index d21384fa4136b..099fd82667289 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php @@ -102,9 +102,9 @@ class StateTest extends \PHPUnit_Framework_TestCase protected $_objectManager; /** - * @var \Magento\Core\Model\App|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $_application; + protected $_configMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -161,13 +161,8 @@ protected function setUp() ); $this->_objectManager = $this->getMock('Magento\ObjectManager'); - $this->_application = $this->getMock( - 'Magento\Core\Model\App', - array('getStore', 'getConfig'), - array(), - '', - false - ); + $this->_application = $this->getMock('Magento\Core\Model\App', array('getStore', 'getConfig'), + array(), '', false); $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array('setConfig'), array(), '', false); $storeManager->expects( @@ -181,19 +176,14 @@ protected function setUp() $this->returnSelf() ); - $configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); - $configMock->expects( - $this->any() - )->method( - 'setNode' - )->with( - $this->equalTo('default/' . \Magento\View\DesignInterface::XML_PATH_THEME_ID), - $this->equalTo(self::THEME_ID) - )->will( - $this->returnSelf() - ); - - $this->_application->expects($this->any())->method('getConfig')->will($this->returnValue($configMock)); + $this->_configMock = $this->getMock('Magento\App\ConfigInterface'); + $this->_configMock->expects($this->any()) + ->method('setNode') + ->with( + $this->equalTo('default/' . \Magento\View\DesignInterface::XML_PATH_THEME_ID), + $this->equalTo(self::THEME_ID) + ) + ->will($this->returnSelf()); $this->_theme = $this->getMock('Magento\Core\Model\Theme', array('getId', '__wakeup'), array(), '', false); $this->_theme->expects($this->any())->method('getId')->will($this->returnValue(self::THEME_ID)); @@ -220,7 +210,7 @@ protected function setUp() $this->_cacheStateMock, $this->_dataHelper, $this->_objectManager, - $this->_application, + $this->_configMock, $this->_themeContext, $storeManager ); diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Theme/ContextTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Theme/ContextTest.php index 7ebe277f7b3e8..5bb4ace7095ed 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Theme/ContextTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Theme/ContextTest.php @@ -112,7 +112,7 @@ public function testSetEditableThemeById() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Wrong theme type set as editable */ public function testSetEditableThemeByIdWrongType() @@ -141,7 +141,7 @@ public function testSetEditableThemeByIdWrongType() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage We can't find theme "1". */ public function testSetEditableThemeByIdWrongThemeId() @@ -171,7 +171,7 @@ public function testGetEditableTheme() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Theme has not been set */ public function testGetEditableThemeNotSet() @@ -214,7 +214,7 @@ public function testGetStagingThemeLazyTest() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Theme "" is not editable. */ public function testGetStagingThemeWrongType() diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Translate/Inline/ProviderTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Translate/Inline/ProviderTest.php new file mode 100644 index 0000000000000..99ba875304bb1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Translate/Inline/ProviderTest.php @@ -0,0 +1,84 @@ +translateVde = $this->getMock('Magento\DesignEditor\Model\Translate\Inline', [], [], '', false); + $this->translateInline = $this->getMock('Magento\Translate\Inline', [], [], '', false); + $this->request = $this->getMock('Magento\App\RequestInterface', [], [], '', false); + } + + /** + * @param bool $isVde + * @param string $instanceName + * + * @dataProvider dataProviderGet + */ + public function testGet($isVde, $instanceName) + { + $helper = $this->getMock('Magento\DesignEditor\Helper\Data', [], [], '', false); + $helper->expects($this->once()) + ->method('isVdeRequest') + ->will($this->returnValue($isVde)); + + $provider = new \Magento\DesignEditor\Model\Translate\Inline\Provider( + $this->translateVde, + $this->translateInline, + $helper, + $this->request + ); + + $this->assertInstanceOf($instanceName, $provider->get()); + } + + /** + * @return array + */ + public function dataProviderGet() + { + return [ + [false, 'Magento\Translate\Inline'], + [true, 'Magento\DesignEditor\Model\Translate\Inline'], + ]; + } +} 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 f3fd794bbcff6..2e07228958673 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/NavigationModeTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/NavigationModeTest.php @@ -150,7 +150,6 @@ public function testGetRouteUrl() self::ROUTE_PATH; $this->assertEquals($expectedUrl, $this->_model->getRouteUrl($sourceUrl)); - $this->assertEquals($this->_model, $this->_model->setType(null)); $this->assertEquals($expectedUrl, $this->_model->getRouteUrl($expectedUrl)); } } diff --git a/dev/tests/unit/testsuite/Magento/Dhl/Model/CarrierTest.php b/dev/tests/unit/testsuite/Magento/Dhl/Model/CarrierTest.php index 3d1ce80c12203..4a833874ddf66 100644 --- a/dev/tests/unit/testsuite/Magento/Dhl/Model/CarrierTest.php +++ b/dev/tests/unit/testsuite/Magento/Dhl/Model/CarrierTest.php @@ -209,7 +209,7 @@ public function testPrepareShippingLabelContent() /** * @dataProvider prepareShippingLabelContentExceptionDataProvider - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Unable to retrieve shipping label */ public function testPrepareShippingLabelContentException(\SimpleXMLElement $xml) 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 fb015b05dc24d..85fec4ab45071 100644 --- a/dev/tests/unit/testsuite/Magento/Directory/Model/Currency/DefaultLocatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Directory/Model/Currency/DefaultLocatorTest.php @@ -36,7 +36,7 @@ class DefaultLocatorTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_appMock; + protected $_configMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -51,32 +51,19 @@ class DefaultLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $backendData = $this->getMock('Magento\Backend\Helper\Data', array(), array(), '', false); - $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->_requestMock = $this->getMockForAbstractClass('Magento\App\RequestInterface', + array($backendData), '', false, false, true, array('getParam')); + $this->_configMock = $this->getMock('\Magento\App\ConfigInterface'); $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_model = new \Magento\Directory\Model\Currency\DefaultLocator( - $this->_appMock, - $this->_storeManagerMock + $this->_configMock, $this->_storeManagerMock ); } public function testGetDefaultCurrencyReturnDefaultStoreDefaultCurrencyIfNoStoreIsSpecified() { - $this->_appMock->expects( - $this->once() - )->method( - 'getBaseCurrencyCode' - )->will( - $this->returnValue('storeCurrency') - ); + $this->_configMock->expects($this->once())->method('getValue') + ->will($this->returnValue('storeCurrency')); $this->assertEquals('storeCurrency', $this->_model->getDefaultCurrency($this->_requestMock)); } diff --git a/dev/tests/unit/testsuite/Magento/Directory/Model/Resource/Country/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Directory/Model/Resource/Country/CollectionTest.php index 97fbae8720597..038e8abd6ef86 100644 --- a/dev/tests/unit/testsuite/Magento/Directory/Model/Resource/Country/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Directory/Model/Resource/Country/CollectionTest.php @@ -39,8 +39,7 @@ protected function setUp() $select = $this->getMock('Zend_Db_Select', array(), array(), '', false); $connection->expects($this->once())->method('select')->will($this->returnValue($select)); - $resource = $this->getMockForAbstractClass( - 'Magento\Core\Model\Resource\Db\AbstractDb', + $resource = $this->getMockForAbstractClass('Magento\Model\Resource\Db\AbstractDb', array(), '', false, diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php index d946efdb96ad5..15d2e90b82c17 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php @@ -100,7 +100,7 @@ public function testSetResourceInvalidPath() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @exectedExceptionMessage Please set resource file and link type. */ public function testGetFileSizeNoResource() @@ -109,7 +109,7 @@ public function testGetFileSizeNoResource() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Invalid download link type. */ public function testGetFileSizeInvalidLinkType() @@ -131,7 +131,7 @@ public function testGetFileSize() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Invalid download link type. */ public function testGetFileSizeNoFile() diff --git a/dev/tests/unit/testsuite/Magento/Eav/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Eav/Helper/DataTest.php new file mode 100644 index 0000000000000..e0ea91910b9c3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Eav/Helper/DataTest.php @@ -0,0 +1,79 @@ +getMock('\Magento\App\Helper\Context', [], [], '', false); + $attributeConfig = $this->getMock('\Magento\Eav\Model\Entity\Attribute\Config', [], [], '', false); + $coreStoreConfig = $this->getMock('\Magento\Core\Model\Store\Config', [], [], '', false); + $eavConfig = $this->getMock('\Magento\Eav\Model\Config', [], [], '', false); + $this->_helper = new Data($context, $attributeConfig, $coreStoreConfig, $eavConfig); + $this->_eavConfig = $eavConfig; + } + + public function testGetAttributeMetadata() + { + $attribute = new \Magento\Object([ + 'entity_type_id' => '1', + 'attribute_id' => '2', + 'backend' => new \Magento\Object(['table' => 'customer_entity_varchar']), + 'backend_type' => 'varchar' + ]); + $this->_eavConfig->expects($this->once()) + ->method('getAttribute') + ->will($this->returnValue($attribute)); + + $result = $this->_helper->getAttributeMetadata('customer', 'lastname'); + $expected = [ + 'entity_type_id' => '1', + 'attribute_id' => '2', + 'attribute_table' => 'customer_entity_varchar', + 'backend_type' => 'varchar' + ]; + + foreach ($result as $key => $value) { + $this->assertArrayHasKey($key, $expected, 'Attribute metadata with key "' . $key . '" not found.'); + $this->assertEquals($expected[$key], $value, + 'Attribute metadata with key "' . $key . '" has invalid value.' + ); + } + } +} diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/TypeTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/TypeTest.php index 25778858bf148..24c4bf24d25ef 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/TypeTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/TypeTest.php @@ -98,7 +98,7 @@ protected function setUp() false ); $this->resourceMock = $this->getMockForAbstractClass( - 'Magento\Core\Model\Resource\Db\AbstractDb', + 'Magento\Model\Resource\Db\AbstractDb', array(), '', false, diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php index ecbaf5c0d9243..a7b7e1753aa5d 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php @@ -66,7 +66,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected $connectionMock; /** - * @var \Magento\Core\Model\Resource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Model\Resource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ protected $resourceMock; @@ -103,12 +103,7 @@ protected function setUp() ); $this->connectionMock = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array(), array(), '', false); $this->resourceMock = $this->getMockForAbstractClass( - 'Magento\Core\Model\Resource\Db\AbstractDb', - array(), - '', - false, - true, - true, + 'Magento\Model\Resource\Db\AbstractDb', array(), '', false, true, true, array('__wakeup', 'getReadConnection', 'getMainTable', 'getTable') ); $this->selectMock = $this->getMock('Zend_Db_Select', array(), array(), '', false); 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 f51a7f483674f..a5410faa5f3d3 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 @@ -53,10 +53,10 @@ public function testSaveOptionSystemAttribute() ); $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - /** @var $model \Magento\Core\Model\AbstractModel */ - $arguments = $objectManagerHelper->getConstructArguments('Magento\Core\Model\AbstractModel'); + /** @var $model \Magento\Model\AbstractModel */ + $arguments = $objectManagerHelper->getConstructArguments('Magento\Model\AbstractModel'); $arguments['data'] = $attributeData; - $model = $this->getMock('Magento\Core\Model\AbstractModel', null, $arguments); + $model = $this->getMock('Magento\Model\AbstractModel', null, $arguments); $model->setDefault(array('2')); $model->setOption(array('delete' => array(1 => '', 2 => ''))); @@ -122,10 +122,10 @@ public function testSaveOptionNewUserDefinedAttribute() $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - /** @var $model \Magento\Core\Model\AbstractModel */ - $arguments = $objectManagerHelper->getConstructArguments('Magento\Core\Model\AbstractModel'); + /** @var $model \Magento\Model\AbstractModel */ + $arguments = $objectManagerHelper->getConstructArguments('Magento\Model\AbstractModel'); $arguments['data'] = $attributeData; - $model = $this->getMock('Magento\Core\Model\AbstractModel', null, $arguments); + $model = $this->getMock('Magento\Model\AbstractModel', null, $arguments); $model->setOption(array('value' => array('option_1' => array('Backend Label', 'Frontend Label')))); $adapter->expects( @@ -202,9 +202,9 @@ public function testSaveOptionNoValue() list($adapter, $resourceModel) = $this->_prepareResourceModel(); $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - /** @var $model \Magento\Core\Model\AbstractModel */ - $arguments = $objectManagerHelper->getConstructArguments('Magento\Core\Model\AbstractModel'); - $model = $this->getMock('Magento\Core\Model\AbstractModel', null, $arguments); + /** @var $model \Magento\Model\AbstractModel */ + $arguments = $objectManagerHelper->getConstructArguments('Magento\Model\AbstractModel'); + $model = $this->getMock('Magento\Model\AbstractModel', null, $arguments); $model->setOption('not-an-array'); $adapter->expects($this->once())->method('insert')->with('eav_attribute'); diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Validator/Attribute/DataTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Validator/Attribute/DataTest.php index 25d298ffb37d9..df07544e90f71 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Validator/Attribute/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Validator/Attribute/DataTest.php @@ -453,7 +453,7 @@ protected function _getDataModelMock($returnValue, $argument = null) protected function _getEntityMock() { $entity = $this->getMockBuilder( - 'Magento\Core\Model\AbstractModel' + 'Magento\Model\AbstractModel' )->setMethods( array('getAttribute', 'getResource', 'getEntityType', '__wakeup') )->disableOriginalConstructor()->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Event/ManagerStub.php b/dev/tests/unit/testsuite/Magento/Event/ManagerStub.php index 5ebf59e6e33a1..ee46156751cb4 100644 --- a/dev/tests/unit/testsuite/Magento/Event/ManagerStub.php +++ b/dev/tests/unit/testsuite/Magento/Event/ManagerStub.php @@ -27,14 +27,14 @@ */ namespace Magento\Event; -class ManagerStub extends \Magento\Event\ManagerInterface +class ManagerStub implements \Magento\Event\ManagerInterface { /** * Stub dispatch event * * @param string $eventName * @param array $params - * @return \Magento\Core\Model\App|null + * @return null */ public function dispatch($eventName, array $params = array()) { diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php index 5ddbc9c3edc2c..510695442b7cb 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php @@ -63,6 +63,23 @@ protected function setUp() false ); + $customerMock = $this->getMockBuilder('\Magento\Customer\Service\V1\Data\Customer') + ->disableOriginalConstructor() + ->getMock(); + $customerMock + ->expects($this->any()) + ->method('getId') + ->will($this->returnValue(1)); + + $priceHelperMock = $this->getMockBuilder('Magento\Catalog\Helper\Product\Price') + ->disableOriginalConstructor() + ->getMock(); + + $priceHelperMock + ->expects($this->any()) + ->method('getCustomer') + ->will($this->returnValue($customerMock)); + $objectHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->block = $objectHelper->getObject( 'Magento\GroupedProduct\Block\Adminhtml\Product\Composite\Fieldset\Grouped', @@ -70,6 +87,7 @@ protected function setUp() 'registry' => $this->registryMock, 'storeManager' => $this->storeManagerMock, 'coreHelper' => $this->coreHelperMock, + 'priceHelper' => $priceHelperMock, 'data' => array('product' => $this->productMock) ) ); diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php index 368abf34407e6..90ca94e4a1cac 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php @@ -127,9 +127,9 @@ public function testAddAttributeValuesToRow() $this->returnValue($testAttributeOptions) ); - /** @var $item \Magento\Core\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject */ + /** @var $item \Magento\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject */ $item = $this->getMockForAbstractClass( - 'Magento\Core\Model\AbstractModel', + 'Magento\Model\AbstractModel', array(), '', false, 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 644dd5dc5051c..ea366593f755c 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 @@ -292,9 +292,9 @@ public function testExportItem() $this->_model->setWriter($writer); $this->_model->setParameters(array()); - $arguments = $this->_objectManager->getConstructArguments('Magento\Core\Model\AbstractModel'); + $arguments = $this->_objectManager->getConstructArguments('Magento\Model\AbstractModel'); $arguments['data'] = $this->_addressData; - $item = $this->getMockForAbstractClass('Magento\Core\Model\AbstractModel', $arguments); + $item = $this->getMockForAbstractClass('Magento\Model\AbstractModel', $arguments); $this->_model->exportItem($item); } 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 d76fb1b559d83..bf67facee9e6c 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 @@ -231,9 +231,9 @@ public function testExportItem() $this->_model->setWriter($writer); $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - $arguments = $objectManagerHelper->getConstructArguments('Magento\Core\Model\AbstractModel'); + $arguments = $objectManagerHelper->getConstructArguments('Magento\Model\AbstractModel'); $arguments['data'] = $this->_customerData; - $item = $this->getMockForAbstractClass('Magento\Core\Model\AbstractModel', $arguments); + $item = $this->getMockForAbstractClass('Magento\Model\AbstractModel', $arguments); $this->_model->exportItem($item); } diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/AbstractTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/AbstractTest.php index 35e4bd98895f2..e3c867d54e841 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/AbstractTest.php @@ -89,7 +89,7 @@ protected function _createSourceAdapterMock(array $columns) * Test for method validateData() * * @covers \Magento\ImportExport\Model\Import\Entity\AbstractEntity::validateData - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Columns number: "1" have empty headers */ public function testValidateDataEmptyColumnName() @@ -102,7 +102,7 @@ public function testValidateDataEmptyColumnName() * Test for method validateData() * * @covers \Magento\ImportExport\Model\Import\Entity\AbstractEntity::validateData - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Columns number: "1" have empty headers */ public function testValidateDataColumnNameWithWhitespaces() @@ -115,7 +115,7 @@ public function testValidateDataColumnNameWithWhitespaces() * Test for method validateData() * * @covers \Magento\ImportExport\Model\Import\Entity\AbstractEntity::validateData - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Column names: "_test1" are invalid */ public function testValidateDataAttributeNames() diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php index 0f35918a39a64..764ba955bf46a 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php @@ -111,12 +111,11 @@ protected function setUp() $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $translateInline = $this->getMock('\Magento\Translate\InlineInterface', array(), array(), '', false); $translateInline->expects($this->any())->method('isAllowed')->will($this->returnValue(false)); - $inlineFactory = $this->getMock('\Magento\Translate\InlineFactory', array(), array(), '', false); - $inlineFactory->expects($this->any())->method('get')->will($this->returnValue($translateInline)); - $context = $this->getMock('Magento\App\Helper\Context', array('getInlineFactory'), array(), '', false); - $context->expects($this->any())->method('getInlineFactory')->will($this->returnValue($inlineFactory)); + + $context = $this->getMock('Magento\App\Helper\Context', array('getTranslateInline'), array(), '', false); + $context->expects($this->any())->method('getTranslateInline')->will($this->returnValue($translateInline)); + $data = array( - 'inlineFactory' => $inlineFactory, 'context' => $context, 'locale' => $this->getMock('Magento\Locale', array(), array(), '', false), 'dateModel' => $this->getMock('Magento\Stdlib\DateTime\DateTime', 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 29500ee2d174f..ba159e44482e3 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 @@ -70,7 +70,7 @@ class EavAbstractTest extends \PHPUnit_Framework_TestCase protected $_resourceHelper; /** - * @var \Magento\Core\Model\App + * @var \Magento\Core\Model\StoreManagerInterface */ protected $_storeManager; diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/EntityAbstractTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/EntityAbstractTest.php index 263118634b93f..5f60c0b1ad59b 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/EntityAbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/EntityAbstractTest.php @@ -550,7 +550,7 @@ protected function _getDataSet($code, $type, $validValue, $invalidValue, $isUniq * Test for method validateData() * * @covers \Magento\ImportExport\Model\Import\AbstractEntity::validateData - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testValidateDataPermanentAttributes() { @@ -569,7 +569,7 @@ public function testValidateDataPermanentAttributes() * Test for method validateData() * * @covers \Magento\ImportExport\Model\Import\AbstractEntity::validateData - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testValidateDataEmptyColumnName() { @@ -581,7 +581,7 @@ public function testValidateDataEmptyColumnName() * Test for method validateData() * * @covers \Magento\ImportExport\Model\Import\AbstractEntity::validateData - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testValidateDataColumnNameWithWhitespaces() { @@ -593,7 +593,7 @@ public function testValidateDataColumnNameWithWhitespaces() * Test for method validateData() * * @covers \Magento\ImportExport\Model\Import\AbstractEntity::validateData - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testValidateDataAttributeNames() { diff --git a/dev/tests/unit/testsuite/Magento/Index/Model/ProcessTest.php b/dev/tests/unit/testsuite/Magento/Index/Model/ProcessTest.php index 5b11219519e78..be7f77d8e6d68 100644 --- a/dev/tests/unit/testsuite/Magento/Index/Model/ProcessTest.php +++ b/dev/tests/unit/testsuite/Magento/Index/Model/ProcessTest.php @@ -119,7 +119,7 @@ protected function _prepareIndexProcess() ); $resource = $this->getMockForAbstractClass( - 'Magento\Core\Model\Resource\Db\AbstractDb', + 'Magento\Model\Resource\Db\AbstractDb', array(), '', false, 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 8598069d3ded4..e6332dab15fc5 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 @@ -42,14 +42,14 @@ public function testSupportEngine(array $supportedEngines, $expectedResult) $connectionMock->expects($this->once())->method('fetchPairs')->will($this->returnValue($supportedEngines)); $adapterFactory = $this->getMock( - 'Magento\Core\Model\Resource\Type\Db\Pdo\MysqlFactory', + 'Magento\Model\Resource\Type\Db\Pdo\MysqlFactory', array('create'), array(), '', false ); $adapterMock = $this->getMock( - 'Magento\Core\Model\Resource\Type\Db\Pdo\Mysql', + 'Magento\Model\Resource\Type\Db\Pdo\Mysql', array('getConnection'), array(), '', @@ -87,7 +87,7 @@ public function possibleEngines() public function testGetRequiredExtensions($config, $dbExtensions, $expectedResult) { $adapterFactory = $this->getMock( - 'Magento\Core\Model\Resource\Type\Db\Pdo\MysqlFactory', + 'Magento\Model\Resource\Type\Db\Pdo\MysqlFactory', array('create'), array(), '', 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 27974606b70d0..54e7b92e0b896 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php @@ -44,9 +44,6 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase /** @var \Magento\ObjectManager|\PHPUnit_Framework_MockObject_MockObject */ protected $_objectManagerMock; - /** @var \Magento\Core\Model\App|\PHPUnit_Framework_MockObject_MockObject */ - protected $_appMock; - /** @var \Magento\Core\Model\Layout\Filter\Acl|\PHPUnit_Framework_MockObject_MockObject */ protected $_layoutFilterMock; @@ -117,15 +114,9 @@ protected function setUp() 'Magento\ObjectManager' )->disableOriginalConstructor()->getMock(); // Initialize mocks which are used in several test cases - $this->_appMock = $this->getMockBuilder( - 'Magento\Core\Model\App' - )->setMethods( - array('getConfig') - )->disableOriginalConstructor()->getMock(); $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' )->disableOriginalConstructor()->getMock(); @@ -336,7 +327,7 @@ public function testSaveActionException() )->with( self::INTEGRATION_ID )->will( - $this->throwException(new \Magento\Core\Exception($exceptionMessage)) + $this->throwException(new \Magento\Model\Exception($exceptionMessage)) ); // Verify error $this->_messageManager->expects($this->once())->method('addError')->with($this->equalTo($exceptionMessage)); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/AbstractModelTest.php b/dev/tests/unit/testsuite/Magento/Model/AbstractModelTest.php similarity index 75% rename from dev/tests/unit/testsuite/Magento/Core/Model/AbstractModelTest.php rename to dev/tests/unit/testsuite/Magento/Model/AbstractModelTest.php index 4df9a387ac381..509508ae03b86 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/AbstractModelTest.php +++ b/dev/tests/unit/testsuite/Magento/Model/AbstractModelTest.php @@ -22,27 +22,27 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model; +namespace Magento\Model; class AbstractModelTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\AbstractModel + * @var \Magento\Model\AbstractModel */ protected $model; /** - * @var \Magento\Core\Model\Context|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Model\Context|\PHPUnit_Framework_MockObject_MockObject */ protected $contextMock; /** - * @var \Magento\Core\Model\Registry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Registry|\PHPUnit_Framework_MockObject_MockObject */ protected $registryMock; /** - * @var \Magento\Core\Model\Resource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Model\Resource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ protected $resourceMock; @@ -56,18 +56,26 @@ class AbstractModelTest extends \PHPUnit_Framework_TestCase */ protected $adapterMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionValidatorMock; + protected function setUp() { - + $this->actionValidatorMock = $this->getMock( + '\Magento\Model\ActionValidator\RemoveAction', array(), array(), '', false + ); $this->contextMock = new \Magento\Model\Context( $this->getMock('Magento\Logger', array(), array(), '', false), $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false), $this->getMock('Magento\App\CacheInterface', array(), array(), '', false), - $this->getMock('Magento\App\State', array(), array(), '', false) + $this->getMock('Magento\App\State', array(), array(), '', false), + $this->actionValidatorMock ); $this->registryMock = $this->getMock('Magento\Registry', array(), array(), '', false); $this->resourceMock = $this->getMock( - 'Magento\Core\Model\Resource\Db\AbstractDb', + 'Magento\Model\Resource\Db\AbstractDb', array( '_construct', '_getReadAdapter', @@ -84,7 +92,7 @@ protected function setUp() ); $this->resourceCollectionMock = $this->getMock('Magento\Data\Collection\Db', array(), array(), '', false); $this->model = $this->getMockForAbstractClass( - 'Magento\Core\Model\AbstractModel', + 'Magento\Model\AbstractModel', array($this->contextMock, $this->registryMock, $this->resourceMock, $this->resourceCollectionMock) ); $this->adapterMock = $this->getMock('Magento\DB\Adapter\AdapterInterface', array(), array(), '', false); @@ -98,6 +106,7 @@ protected function setUp() public function testDelete() { + $this->actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); $this->adapterMock->expects($this->once()) ->method('beginTransaction'); $this->resourceMock->expects($this->once()) @@ -113,6 +122,7 @@ public function testDelete() */ public function testDeleteRaiseException() { + $this->actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); $this->adapterMock->expects($this->once()) ->method('beginTransaction'); $this->resourceMock->expects($this->once()) @@ -124,5 +134,14 @@ public function testDeleteRaiseException() ->method('rollBack'); $this->model->delete(); } + + /** + * @expectedException \Magento\Model\Exception + * @expectedExceptionMessage Delete operation is forbidden for current area + */ + public function testDeleteOnModelThatCanNotBeRemoved() + { + $this->actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(false)); + $this->model->delete(); + } } - \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Model/ActionValidator/RemoveActionTest.php b/dev/tests/unit/testsuite/Magento/Model/ActionValidator/RemoveActionTest.php new file mode 100644 index 0000000000000..31f42b0eb42f5 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Model/ActionValidator/RemoveActionTest.php @@ -0,0 +1,77 @@ +getMock('\Magento\Registry', array(), array(), '', false); + $registryMock->expects($this->once()) + ->method('registry')->with('isSecureArea')->will($this->returnValue($secureArea)); + + $model = new \Magento\Model\ActionValidator\RemoveAction($registryMock, array('class' => $protectedModel)); + $this->assertEquals($expectedResult, $model->isAllowed($modelToCheck)); + } + + /** + * return array + */ + public function isAllowedDataProvider() + { + $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); + $bannerMock = $this->getMock('\Magento\Wishlist\Model\Wishlist', array(), array(), '', false); + + return array( + array( + 'modelToCheck' => $productMock, + 'protectedModel' => 'Model', + 'secureArea' => false, + 'expectedResult' => true + ), + array( + 'modelToCheck' => $bannerMock, + 'protectedModel' => get_class($bannerMock), + 'secureArea' => false, + 'expectedResult' => false + ), + array( + 'modelToCheck' => $bannerMock, + 'protectedModel' => get_class($bannerMock), + 'secureArea' => true, + 'expectedResult' => true + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Mview/Config/Data/ProxyTest.php b/dev/tests/unit/testsuite/Magento/Mview/Config/Data/ProxyTest.php new file mode 100644 index 0000000000000..f78c37a9cd013 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/Config/Data/ProxyTest.php @@ -0,0 +1,130 @@ +objectManagerMock = $this->getMock( + 'Magento\ObjectManager', array(), array(), '', false + ); + $this->dataMock = $this->getMock( + 'Magento\Mview\Config\Data', array(), array(), '', false + ); + } + + public function testMergeShared() + { + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Mview\Config\Data') + ->will($this->returnValue($this->dataMock)); + $this->dataMock->expects($this->once()) + ->method('merge') + ->with(['some_config']); + + $this->model = new Proxy( + $this->objectManagerMock, + 'Magento\Mview\Config\Data', + true + ); + + $this->model->merge(['some_config']); + } + + public function testMergeNonShared() + { + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Mview\Config\Data') + ->will($this->returnValue($this->dataMock)); + $this->dataMock->expects($this->once()) + ->method('merge') + ->with(['some_config']); + + $this->model = new Proxy( + $this->objectManagerMock, + 'Magento\Mview\Config\Data', + false + ); + + $this->model->merge(['some_config']); + } + + public function testGetShared() + { + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Mview\Config\Data') + ->will($this->returnValue($this->dataMock)); + $this->dataMock->expects($this->once()) + ->method('get') + ->with('some_path', 'default') + ->will($this->returnValue('some_value')); + + $this->model = new Proxy( + $this->objectManagerMock, + 'Magento\Mview\Config\Data', + true + ); + + $this->assertEquals('some_value', $this->model->get('some_path', 'default')); + } + + public function testGetNonShared() + { + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Mview\Config\Data') + ->will($this->returnValue($this->dataMock)); + $this->dataMock->expects($this->once()) + ->method('get') + ->with('some_path', 'default') + ->will($this->returnValue('some_value')); + + $this->model = new Proxy( + $this->objectManagerMock, + 'Magento\Mview\Config\Data', + false + ); + + $this->assertEquals('some_value', $this->model->get('some_path', 'default')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Translate/Inline/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Mview/ConfigTest.php similarity index 50% rename from dev/tests/unit/testsuite/Magento/Core/Model/Translate/Inline/ConfigTest.php rename to dev/tests/unit/testsuite/Magento/Mview/ConfigTest.php index 674afdf6cf894..c84d1aed64ab2 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Translate/Inline/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Mview/ConfigTest.php @@ -17,37 +17,48 @@ * Do not edit or add to this file if you wish to upgrade Magento to 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) */ -namespace Magento\Core\Model\Translate\Inline; +namespace Magento\Mview; class ConfigTest extends \PHPUnit_Framework_TestCase { - public function testIsActive() + /** + * @var \Magento\Mview\Config + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Mview\Config\Data + */ + protected $dataMock; + + protected function setUp() { - $store = 'some store'; - $result = 'result'; - $coreStoreConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false); - $coreStoreConfig->expects( - $this->once() - )->method( - 'getConfigFlag' - )->with( - $this->equalTo('dev/translate_inline/active'), - $this->equalTo($store) - )->will( - $this->returnValue($result) + $this->dataMock = $this->getMock( + 'Magento\Mview\Config\Data', array(), array(), '', false ); - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $config = $objectManager->getObject( - '\Magento\Core\Model\Translate\Inline\Config', - array('coreStoreConfig' => $coreStoreConfig) + $this->model = new Config( + $this->dataMock ); - $this->assertEquals($result, $config->isActive($store)); + } + + public function testGetViews() + { + $this->dataMock->expects($this->once()) + ->method('get') + ->will($this->returnValue(['some_data'])); + $this->assertEquals(['some_data'], $this->model->getViews()); + } + + public function testGetView() + { + $this->dataMock->expects($this->once()) + ->method('get') + ->with('some_view') + ->will($this->returnValue(['some_data'])); + $this->assertEquals(['some_data'], $this->model->getView('some_view')); } } diff --git a/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php b/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php index d24dec77bc7fe..15142e5ffb80f 100644 --- a/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php +++ b/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php @@ -86,12 +86,59 @@ public function testGetName() $this->assertEquals('ViewIdTest' . '_' . \Magento\Mview\View\Changelog::NAME_SUFFIX, $this->model->getName()); } + public function testGetViewId() + { + $this->model->setViewId('ViewIdTest'); + $this->assertEquals('ViewIdTest', $this->model->getViewId()); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage View's identifier is not set + */ + public function testGetNameWithException() + { + $this->model->getName(); + } + public function testGetColumnName() { $this->assertEquals(\Magento\Mview\View\Changelog::COLUMN_NAME, $this->model->getColumnName()); } - public function testGetVersionWithException() + public function testGetVersion() + { + $changelogTableName = 'viewIdtest_cl'; + $this->mockIsTableExists($changelogTableName, true); + $this->mockGetTableName(); + + $this->connectionMock->expects($this->once()) + ->method('fetchRow') + ->will($this->returnValue(['Auto_increment' => 11])); + + $this->model->setViewId('viewIdtest'); + $this->assertEquals(10, $this->model->getVersion()); + } + + public function testGetVersionWithExceptionNoAutoincrement() + { + $changelogTableName = 'viewIdtest_cl'; + $this->mockIsTableExists($changelogTableName, true); + $this->mockGetTableName(); + + $this->connectionMock->expects($this->once()) + ->method('fetchRow') + ->will($this->returnValue([])); + + $this->setExpectedException( + 'Exception', + "Table status for `{$changelogTableName}` is incorrect. Can`t fetch version id." + ); + $this->model->setViewId('viewIdtest'); + $this->model->getVersion(); + } + + public function testGetVersionWithExceptionNoTable() { $changelogTableName = 'viewIdtest_cl'; $this->mockIsTableExists($changelogTableName, false); @@ -102,7 +149,7 @@ public function testGetVersionWithException() $this->model->getVersion(); } - public function testDropWithException() + public function testDrop() { $changelogTableName = 'viewIdtest_cl'; $this->mockIsTableExists($changelogTableName, false); @@ -113,6 +160,44 @@ public function testDropWithException() $this->model->drop(); } + public function testDropWithException() + { + $changelogTableName = 'viewIdtest_cl'; + $this->mockIsTableExists($changelogTableName, true); + $this->mockGetTableName(); + + $this->connectionMock->expects($this->once()) + ->method('dropTable') + ->with($changelogTableName) + ->will($this->returnValue(true)); + + $this->model->setViewId('viewIdtest'); + $this->model->drop(); + } + + public function testCreate() + { + $changelogTableName = 'viewIdtest_cl'; + $this->mockIsTableExists($changelogTableName, false); + $this->mockGetTableName(); + + $tableMock = $this->getMock('Magento\DB\Ddl\Table', array(), array(), '', false, false); + $tableMock->expects($this->exactly(2)) + ->method('addColumn') + ->will($this->returnSelf()); + + $this->connectionMock->expects($this->once()) + ->method('newTable') + ->with($changelogTableName) + ->will($this->returnValue($tableMock)); + $this->connectionMock->expects($this->once()) + ->method('createTable') + ->with($tableMock); + + $this->model->setViewId('viewIdtest'); + $this->model->create(); + } + public function testCreateWithException() { $changelogTableName = 'viewIdtest_cl'; @@ -124,6 +209,37 @@ public function testCreateWithException() $this->model->create(); } + public function testGetList() + { + $changelogTableName = 'viewIdtest_cl'; + $this->mockIsTableExists($changelogTableName, true); + $this->mockGetTableName(); + + $selectMock = $this->getMock('Magento\DB\Select', array(), array(), '', false, false); + $selectMock->expects($this->once()) + ->method('distinct') + ->with(true) + ->will($this->returnSelf()); + $selectMock->expects($this->once()) + ->method('from') + ->with($changelogTableName, ['entity_id']) + ->will($this->returnSelf()); + $selectMock->expects($this->exactly(2)) + ->method('where') + ->will($this->returnSelf()); + + $this->connectionMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($selectMock)); + $this->connectionMock->expects($this->once()) + ->method('fetchCol') + ->with($selectMock) + ->will($this->returnValue(['some_data'])); + + $this->model->setViewId('viewIdtest'); + $this->assertEquals(['some_data'], $this->model->getList(1, 2)); + } + public function testGetListWithException() { $changelogTableName = 'viewIdtest_cl'; diff --git a/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php index 8a915840b5061..861b5d4824927 100644 --- a/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php @@ -25,7 +25,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase { - public function testLoadData() + public function testLoadDataAndGetViewsByStateMode() { $indexerIdOne = 'first_indexer_id'; $indexerIdSecond = 'second_indexer_id'; @@ -50,22 +50,29 @@ public function testLoadData() array('getItems') )->disableOriginalConstructor()->getMock(); - $state = $this->getMockBuilder( - 'Magento\Mview\View\State' - )->setMethods( - array('getViewId', '__wakeup') - )->disableOriginalConstructor()->getMock(); + $state = $this->getMockForAbstractClass( + 'Magento\Mview\View\StateInterface', [], '', false, false, true, + ['getViewId', 'getMode', '__wakeup'] + ); $state->expects($this->any())->method('getViewId')->will($this->returnValue('second_indexer_id')); - $indexer = $this->getMockBuilder( - 'Magento\Object' - )->setMethods( - array('load', 'setState') - )->disableOriginalConstructor()->getMock(); + $state->expects( + $this->any() + )->method( + 'getMode' + )->will( + $this->returnValue(\Magento\Mview\View\StateInterface::MODE_DISABLED) + ); + + $view = $this->getMockForAbstractClass( + 'Magento\Mview\ViewInterface', [], '', false, false, true, + ['load', 'setState', 'getState', '__wakeup'] + ); - $indexer->expects($this->once())->method('setState')->with($state); - $indexer->expects($this->any())->method('load')->with($this->logicalOr($indexerIdOne, $indexerIdSecond)); + $view->expects($this->once())->method('setState')->with($state); + $view->expects($this->any())->method('getState')->will($this->returnValue($state)); + $view->expects($this->any())->method('load')->with($this->logicalOr($indexerIdOne, $indexerIdSecond)); $entityFactory->expects( $this->any() @@ -74,7 +81,7 @@ public function testLoadData() )->with( 'Magento\Mview\ViewInterface' )->will( - $this->returnValue($indexer) + $this->returnValue($view) ); $statesFactory->expects($this->once())->method('create')->will($this->returnValue($states)); @@ -91,5 +98,13 @@ public function testLoadData() $collection = new \Magento\Mview\View\Collection($entityFactory, $config, $statesFactory); $this->assertInstanceOf('Magento\Mview\View\Collection', $collection->loadData()); + + $views = $collection->getViewsByStateMode(\Magento\Mview\View\StateInterface::MODE_DISABLED); + $this->assertCount(2, $views); + $this->assertInstanceOf('Magento\Mview\ViewInterface', $views[0]); + $this->assertInstanceOf('Magento\Mview\ViewInterface', $views[1]); + + $views = $collection->getViewsByStateMode(\Magento\Mview\View\StateInterface::MODE_ENABLED); + $this->assertCount(0, $views); } } diff --git a/dev/tests/unit/testsuite/Magento/Mview/View/SubscriptionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Mview/View/SubscriptionFactoryTest.php new file mode 100644 index 0000000000000..1a4971b8a3a1b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/View/SubscriptionFactoryTest.php @@ -0,0 +1,55 @@ +objectManagerMock = $this->getMock('Magento\ObjectManager', array(), array(), '', false); + $this->model = new SubscriptionFactory($this->objectManagerMock); + } + + public function testCreate() + { + $subscriptionInterfaceMock = $this->getMockForAbstractClass( + 'Magento\Mview\View\SubscriptionInterface', array(), '', false + ); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Mview\View\SubscriptionInterface', ['some_data']) + ->will($this->returnValue($subscriptionInterfaceMock)); + $this->assertEquals($subscriptionInterfaceMock, $this->model->create(['some_data'])); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Mview/View/SubscriptionTest.php b/dev/tests/unit/testsuite/Magento/Mview/View/SubscriptionTest.php new file mode 100644 index 0000000000000..3c394e5c77712 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/View/SubscriptionTest.php @@ -0,0 +1,293 @@ +connectionMock = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', [], [], '', false); + + $this->resourceMock = $this->getMock( + 'Magento\App\Resource', array('getConnection', 'getTableName'), [], '', false, false + ); + $this->mockGetConnection($this->connectionMock); + $this->triggerFactoryMock = $this->getMock( + 'Magento\DB\Ddl\TriggerFactory', [], [], '', false, false + ); + $this->viewCollectionMock = $this->getMockForAbstractClass( + 'Magento\Mview\View\CollectionInterface', [], '', false, false, true, [] + ); + $this->viewMock = $this->getMockForAbstractClass( + 'Magento\Mview\ViewInterface', [], '', false, false, true, [] + ); + + $this->connectionMock->expects($this->any()) + ->method('quoteIdentifier') + ->will($this->returnArgument(0)); + + $this->model = new Subscription( + $this->resourceMock, + $this->triggerFactoryMock, + $this->viewCollectionMock, + $this->viewMock, + 'tableName', + 'columnName' + ); + } + + + public function testGetView() + { + $this->assertEquals($this->viewMock, $this->model->getView()); + } + + public function testGetTableName() + { + $this->assertEquals('tableName', $this->model->getTableName()); + } + + public function testGetColumnName() + { + $this->assertEquals('columnName', $this->model->getColumnName()); + } + + public function testCreate() + { + $this->mockGetTableName(); + + $triggerMock = $this->getMock('Magento\DB\Ddl\Trigger', [], [], '', false, false); + $triggerMock->expects($this->exactly(3)) + ->method('setName') + ->will($this->returnSelf()); + $triggerMock->expects($this->exactly(3)) + ->method('getName') + ->will($this->returnValue('triggerName')); + $triggerMock->expects($this->exactly(3)) + ->method('setTime') + ->with(\Magento\DB\Ddl\Trigger::TIME_AFTER) + ->will($this->returnSelf()); + $triggerMock->expects($this->exactly(3)) + ->method('setEvent') + ->will($this->returnSelf()); + $triggerMock->expects($this->exactly(3)) + ->method('setTable') + ->with('tableName') + ->will($this->returnSelf()); + $triggerMock->expects($this->exactly(6)) + ->method('addStatement') + ->will($this->returnSelf()); + + $changelogMock = $this->getMockForAbstractClass( + 'Magento\Mview\View\ChangelogInterface', [], '', false, false, true, [] + ); + $changelogMock->expects($this->exactly(3)) + ->method('getName') + ->will($this->returnValue('test_view_cl')); + $changelogMock->expects($this->exactly(3)) + ->method('getColumnName') + ->will($this->returnValue('entity_id')); + + $this->viewMock->expects($this->exactly(3)) + ->method('getChangelog') + ->will($this->returnValue($changelogMock)); + + $this->triggerFactoryMock->expects($this->exactly(3)) + ->method('create') + ->will($this->returnValue($triggerMock)); + + $otherChangelogMock = $this->getMockForAbstractClass( + 'Magento\Mview\View\ChangelogInterface', [], '', false, false, true, [] + ); + $otherChangelogMock->expects($this->exactly(3)) + ->method('getName') + ->will($this->returnValue('other_test_view_cl')); + $otherChangelogMock->expects($this->exactly(3)) + ->method('getColumnName') + ->will($this->returnValue('entity_id')); + + $otherViewMock = $this->getMockForAbstractClass( + 'Magento\Mview\ViewInterface', [], '', false, false, true, [] + ); + $otherViewMock->expects($this->exactly(1)) + ->method('getId') + ->will($this->returnValue('other_id')); + $otherViewMock->expects($this->exactly(1)) + ->method('getSubscriptions') + ->will($this->returnValue([['name' => 'tableName'], ['name' => 'otherTableName']])); + $otherViewMock->expects($this->exactly(3)) + ->method('getChangelog') + ->will($this->returnValue($otherChangelogMock)); + + $this->viewMock->expects($this->exactly(3)) + ->method('getId') + ->will($this->returnValue('this_id')); + $this->viewMock->expects($this->never()) + ->method('getSubscriptions'); + + $this->viewCollectionMock->expects($this->exactly(1)) + ->method('getViewsByStateMode') + ->with(\Magento\Mview\View\StateInterface::MODE_ENABLED) + ->will($this->returnValue([$this->viewMock, $otherViewMock])); + + $this->connectionMock->expects($this->exactly(3)) + ->method('dropTrigger') + ->with('triggerName') + ->will($this->returnValue(true)); + $this->connectionMock->expects($this->exactly(3)) + ->method('createTrigger') + ->with($triggerMock); + + $this->model->create(); + } + + public function testRemove() + { + $this->mockGetTableName(); + + $triggerMock = $this->getMock('Magento\DB\Ddl\Trigger', [], [], '', false, false); + $triggerMock->expects($this->exactly(3)) + ->method('setName') + ->will($this->returnSelf()); + $triggerMock->expects($this->exactly(3)) + ->method('getName') + ->will($this->returnValue('triggerName')); + $triggerMock->expects($this->exactly(3)) + ->method('setTime') + ->with(\Magento\DB\Ddl\Trigger::TIME_AFTER) + ->will($this->returnSelf()); + $triggerMock->expects($this->exactly(3)) + ->method('setEvent') + ->will($this->returnSelf()); + $triggerMock->expects($this->exactly(3)) + ->method('setTable') + ->with('tableName') + ->will($this->returnSelf()); + $triggerMock->expects($this->exactly(3)) + ->method('addStatement') + ->will($this->returnSelf()); + + $this->triggerFactoryMock->expects($this->exactly(3)) + ->method('create') + ->will($this->returnValue($triggerMock)); + + $otherChangelogMock = $this->getMockForAbstractClass( + 'Magento\Mview\View\ChangelogInterface', [], '', false, false, true, [] + ); + $otherChangelogMock->expects($this->exactly(3)) + ->method('getName') + ->will($this->returnValue('other_test_view_cl')); + $otherChangelogMock->expects($this->exactly(3)) + ->method('getColumnName') + ->will($this->returnValue('entity_id')); + + $otherViewMock = $this->getMockForAbstractClass( + 'Magento\Mview\ViewInterface', [], '', false, false, true, [] + ); + $otherViewMock->expects($this->exactly(1)) + ->method('getId') + ->will($this->returnValue('other_id')); + $otherViewMock->expects($this->exactly(1)) + ->method('getSubscriptions') + ->will($this->returnValue([['name' => 'tableName'], ['name' => 'otherTableName']])); + $otherViewMock->expects($this->exactly(3)) + ->method('getChangelog') + ->will($this->returnValue($otherChangelogMock)); + + $this->viewMock->expects($this->exactly(3)) + ->method('getId') + ->will($this->returnValue('this_id')); + $this->viewMock->expects($this->never()) + ->method('getSubscriptions'); + + $this->viewCollectionMock->expects($this->exactly(1)) + ->method('getViewsByStateMode') + ->with(\Magento\Mview\View\StateInterface::MODE_ENABLED) + ->will($this->returnValue([$this->viewMock, $otherViewMock])); + + $this->connectionMock->expects($this->exactly(3)) + ->method('dropTrigger') + ->with('triggerName') + ->will($this->returnValue(true)); + + $triggerMock->expects($this->exactly(3)) + ->method('getStatements') + ->will($this->returnValue(true)); + + $this->connectionMock->expects($this->exactly(3)) + ->method('createTrigger') + ->with($triggerMock); + + $this->model->remove(); + } + + /** + * @param $connection + */ + protected function mockGetConnection($connection) + { + $this->resourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($connection)); + } + + protected function mockGetTableName() + { + $this->resourceMock->expects($this->any()) + ->method('getTableName') + ->will($this->returnArgument(0)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php b/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php index e76339216a78c..fc85d7fb3bfd6 100644 --- a/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php +++ b/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php @@ -41,7 +41,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected $actionFactoryMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Core\Model\Mview\View\State + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\Mview\View\State */ protected $stateMock; @@ -68,18 +68,18 @@ protected function setUp() ); $this->actionFactoryMock = $this->getMock('Magento\Mview\ActionFactory', array('get'), array(), '', false); $this->stateMock = $this->getMock( - 'Magento\Core\Model\Mview\View\State', - array( - 'getViewId', + 'Magento\Indexer\Model\Mview\View\State', + array('getViewId', 'loadByView', 'getVersionId', 'setVersionId', + 'getUpdated', 'getStatus', 'setStatus', 'getMode', 'setMode', 'save', - '__wakeup' + '__wakeup', ), array(), '', @@ -87,7 +87,7 @@ protected function setUp() ); $this->changelogMock = $this->getMock( 'Magento\Mview\View\Changelog', - array('getViewId', 'setViewId', 'create', 'drop', 'getVersion', 'getList'), + array('getViewId', 'setViewId', 'create', 'drop', 'getVersion', 'getList', 'clear'), array(), '', false @@ -108,6 +108,24 @@ protected function setUp() ); } + public function testGetActionClass() + { + $this->model->setData('action_class', 'actionClass'); + $this->assertEquals('actionClass', $this->model->getActionClass()); + } + + public function testGetGroup() + { + $this->model->setData('group', 'some_group'); + $this->assertEquals('some_group', $this->model->getGroup()); + } + + public function testGetSubscriptions() + { + $this->model->setData('subscriptions', ['subscription']); + $this->assertEquals(['subscription'], $this->model->getSubscriptions()); + } + public function testLoad() { $viewId = 'view_test'; @@ -144,9 +162,15 @@ public function testLoadWithException() 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'); + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::MODE_DISABLED)); + $this->stateMock->expects($this->once()) + ->method('setMode') + ->with(\Magento\Mview\View\StateInterface::MODE_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( @@ -160,12 +184,57 @@ public function testSubscribe() $this->model->subscribe(); } + public function testSubscribeEnabled() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::MODE_ENABLED)); + $this->stateMock->expects($this->never()) + ->method('setMode'); + $this->changelogMock->expects($this->never()) + ->method('create'); + $this->subscriptionFactoryMock->expects($this->never()) + ->method('create'); + $this->loadView(); + $this->model->subscribe(); + } + + /** + * @expectedException \Exception + */ + public function testSubscribeWithException() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::MODE_DISABLED)); + + $this->changelogMock->expects($this->once()) + ->method('create') + ->will($this->returnCallback( + function () { + throw new \Exception(); + } + )); + + $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('setVersionId')->with(null)->will($this->returnSelf()); - $this->stateMock->expects($this->once())->method('setMode')->with('disabled')->will($this->returnSelf()); - $this->changelogMock->expects($this->once())->method('drop'); + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::MODE_ENABLED)); + $this->stateMock->expects($this->once()) + ->method('setVersionId') + ->with(null) + ->will($this->returnSelf()); + $this->stateMock->expects($this->once()) + ->method('setMode') + ->with(\Magento\Mview\View\StateInterface::MODE_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( @@ -179,18 +248,74 @@ public function testUnsubscribe() $this->model->unsubscribe(); } + public function testUnsubscribeDisabled() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::MODE_DISABLED)); + $this->stateMock->expects($this->never()) + ->method('setVersionId'); + $this->stateMock->expects($this->never()) + ->method('setMode'); + $this->changelogMock->expects($this->never()) + ->method('drop'); + $this->subscriptionFactoryMock->expects($this->never()) + ->method('create'); + $this->loadView(); + $this->model->unsubscribe(); + } + + /** + * @expectedException \Exception + */ + public function testUnsubscribeWithException() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::MODE_ENABLED)); + + $subscriptionMock = $this->getMock('Magento\Mview\View\Subscription', array('remove'), array(), '', false); + $subscriptionMock->expects($this->exactly(1)) + ->method('remove') + ->will($this->returnCallback( + function () { + throw new \Exception(); + } + )); + $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->exactly(2))->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->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(\Magento\Mview\View\StateInterface::MODE_ENABLED)); + $this->stateMock->expects($this->exactly(2)) + ->method('getStatus') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::STATUS_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() @@ -235,13 +360,26 @@ 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->exactly(2))->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->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(\Magento\Mview\View\StateInterface::MODE_ENABLED)); + $this->stateMock->expects($this->exactly(2)) + ->method('getStatus') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::STATUS_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() @@ -283,6 +421,223 @@ function () { $this->model->update(); } + public function testSuspend() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::MODE_ENABLED)); + $this->stateMock->expects($this->once()) + ->method('setVersionId') + ->with(11) + ->will($this->returnSelf()); + $this->stateMock->expects($this->once()) + ->method('setStatus') + ->with(\Magento\Mview\View\StateInterface::STATUS_SUSPENDED) + ->will($this->returnSelf()); + $this->stateMock->expects($this->once()) + ->method('save') + ->will($this->returnSelf()); + + $this->changelogMock->expects($this->once()) + ->method('getVersion') + ->will($this->returnValue(11)); + + $this->loadView(); + $this->model->suspend(); + } + + public function testSuspendDisabled() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::MODE_DISABLED)); + $this->stateMock->expects($this->never()) + ->method('setVersionId'); + $this->stateMock->expects($this->never()) + ->method('setStatus'); + $this->stateMock->expects($this->never()) + ->method('save'); + + $this->changelogMock->expects($this->never()) + ->method('getVersion'); + + $this->loadView(); + $this->model->suspend(); + } + + public function testResume() + { + $this->stateMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::STATUS_SUSPENDED)); + $this->stateMock->expects($this->once()) + ->method('setStatus') + ->with(\Magento\Mview\View\StateInterface::STATUS_IDLE) + ->will($this->returnSelf()); + $this->stateMock->expects($this->once()) + ->method('save') + ->will($this->returnSelf()); + + $this->loadView(); + $this->model->resume(); + } + + /** + * @param string $status + * @dataProvider dataProviderResumeNotSuspended + */ + public function testResumeNotSuspended($status) + { + $this->stateMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue($status)); + $this->stateMock->expects($this->never()) + ->method('setStatus'); + $this->stateMock->expects($this->never()) + ->method('save'); + + $this->loadView(); + $this->model->resume(); + } + + public function dataProviderResumeNotSuspended() + { + return [ + [\Magento\Mview\View\StateInterface::STATUS_IDLE], + [\Magento\Mview\View\StateInterface::STATUS_WORKING], + ]; + } + + public function testClearChangelog() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::MODE_ENABLED)); + $this->stateMock->expects($this->once()) + ->method('getVersionId') + ->will($this->returnValue(11)); + $this->changelogMock->expects($this->once()) + ->method('clear') + ->with(11) + ->will($this->returnValue(true)); + $this->loadView(); + $this->model->clearChangelog(); + } + + public function testClearChangelogDisabled() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue(\Magento\Mview\View\StateInterface::MODE_DISABLED)); + $this->stateMock->expects($this->never()) + ->method('getVersionId'); + $this->changelogMock->expects($this->never()) + ->method('clear'); + $this->loadView(); + $this->model->clearChangelog(); + } + + public function testSetState() + { + $this->model->setState($this->stateMock); + $this->assertEquals($this->stateMock, $this->model->getState()); + } + + /** + * @param string $mode + * @param bool $result + * @dataProvider dataProviderIsEnabled + */ + public function testIsEnabled($mode, $result) + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue($mode)); + $this->assertEquals($result, $this->model->isEnabled()); + } + + public function dataProviderIsEnabled() + { + return [ + [\Magento\Mview\View\StateInterface::MODE_ENABLED, true], + [\Magento\Mview\View\StateInterface::MODE_DISABLED, false], + ]; + } + + /** + * @param string $status + * @param bool $result + * @dataProvider dataProviderIsIdle + */ + public function testIsIdle($status, $result) + { + $this->stateMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue($status)); + $this->assertEquals($result, $this->model->isIdle()); + } + + public function dataProviderIsIdle() + { + return [ + [\Magento\Mview\View\StateInterface::STATUS_IDLE, true], + [\Magento\Mview\View\StateInterface::STATUS_WORKING, false], + [\Magento\Mview\View\StateInterface::STATUS_SUSPENDED, false], + ]; + } + + /** + * @param string $status + * @param bool $result + * @dataProvider dataProviderIsWorking + */ + public function testIsWorking($status, $result) + { + $this->stateMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue($status)); + $this->assertEquals($result, $this->model->isWorking()); + } + + public function dataProviderIsWorking() + { + return [ + [\Magento\Mview\View\StateInterface::STATUS_IDLE, false], + [\Magento\Mview\View\StateInterface::STATUS_WORKING, true], + [\Magento\Mview\View\StateInterface::STATUS_SUSPENDED, false], + ]; + } + + /** + * @param string $status + * @param bool $result + * @dataProvider dataProviderIsSuspended + */ + public function testIsSuspended($status, $result) + { + $this->stateMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue($status)); + $this->assertEquals($result, $this->model->isSuspended()); + } + + public function dataProviderIsSuspended() + { + return [ + [\Magento\Mview\View\StateInterface::STATUS_IDLE, false], + [\Magento\Mview\View\StateInterface::STATUS_WORKING, false], + [\Magento\Mview\View\StateInterface::STATUS_SUSPENDED, true], + ]; + } + + public function testGetUpdated() + { + $this->stateMock->expects($this->once()) + ->method('getUpdated') + ->will($this->returnValue('some datetime')); + $this->assertEquals('some datetime', $this->model->getUpdated()); + } + protected function loadView() { $viewId = 'view_test'; diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_config.php b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_config.php index 2defee53d4478..b552b2677918f 100644 --- a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_config.php +++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_config.php @@ -22,10 +22,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ return array( - 'inputXML' => '' . - '' . - '' . - '
', + 'inputXML' => '' + . '' + . '
' + . '
' + . '', 'expected' => array( 'view_one' => array( 'view_id' => 'view_one', 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 7388ed4c27408..20cb631c8148d 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\AppInterface' => 'Magento\Core\Model\App\Proxy' + 'Magento\App\RequestInterface' => 'Magento\App\Request\Http\Proxy', ), 'Magento\App\State' => array('arguments' => array('test name' => 'test value')), 'Magento\Core\Model\Config\Modules' => array( 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 40795af762f88..6e89639248b37 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,7 +26,7 @@ - + diff --git a/dev/tests/unit/testsuite/Magento/Outbound/Authentication/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Outbound/Authentication/FactoryTest.php deleted file mode 100644 index f8e9b74f3b992..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Outbound/Authentication/FactoryTest.php +++ /dev/null @@ -1,111 +0,0 @@ -_mockObjectManager = $this->getMockBuilder( - 'Magento\ObjectManager' - )->setMethods( - array('get') - )->disableOriginalConstructor()->getMockForAbstractClass(); - - $this->_authFactory = new \Magento\Outbound\Authentication\Factory( - array('hmac' => 'Test_Authentication_Hmac'), - $this->_mockObjectManager - ); - - $this->_expectedObject = $this->getMockBuilder( - 'Magento\Outbound\Authentication\Hmac' - )->disableOriginalConstructor()->getMock(); - - $this->_formatterFactory = new \Magento\Outbound\Formatter\Factory( - array('json' => 'Test_Formatter_Json'), - $this->_mockObjectManager - ); - } - - public function testGetAuthenticationSuccess() - { - $this->_mockObjectManager->expects( - $this->once() - )->method( - 'get' - )->with( - 'Test_Authentication_Hmac' - )->will( - $this->returnValue($this->_expectedObject) - ); - - $authObject = $this->_authFactory->getAuthentication(\Magento\Outbound\EndpointInterface::AUTH_TYPE_HMAC); - $this->assertInstanceOf('Magento\Outbound\Authentication\Hmac', $authObject); - $this->assertEquals($this->_expectedObject, $authObject); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage There is no authentication for the type given: TEST_AUTH_TYPE_STRING - */ - public function testGetAuthenticationNoType() - { - $this->_authFactory->getAuthentication('TEST_AUTH_TYPE_STRING'); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Authentication class for hmac does not implement authentication interface - */ - public function testGetAuthenticationNoModel() - { - $this->_mockObjectManager->expects( - $this->once() - )->method( - 'get' - )->with( - 'Test_Authentication_Hmac' - )->will( - $this->returnValue($this->getMock('Magento\Object')) - ); - $this->_authFactory->getAuthentication(\Magento\Outbound\EndpointInterface::AUTH_TYPE_HMAC); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Outbound/Authentication/HmacTest.php b/dev/tests/unit/testsuite/Magento/Outbound/Authentication/HmacTest.php deleted file mode 100644 index 2cc4ae1b370c2..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Outbound/Authentication/HmacTest.php +++ /dev/null @@ -1,115 +0,0 @@ -_mockStoreManager = $this->getMockBuilder( - 'Magento\Core\Model\StoreManagerInterface' - )->disableOriginalConstructor()->getMock(); - $this->_model = new \Magento\Outbound\Authentication\Hmac($this->_mockStoreManager); - - $this->_mockMessage = $this->getMockBuilder( - 'Magento\Outbound\MessageInterface' - )->disableOriginalConstructor()->getMock(); - $this->_mockMessage->expects($this->any())->method('getBody')->will($this->returnValue(self::BODY)); - - $this->_mockUser = $this->getMockBuilder( - 'Magento\Outbound\UserInterface' - )->disableOriginalConstructor()->getMock(); - } - - public function testHeaders() - { - $store = $this->getMockBuilder('Magento\Core\Model\Store')->disableOriginalConstructor()->getMock(); - $this->_mockStoreManager->expects($this->once())->method('getSafeStore')->will($this->returnValue($store)); - $store->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://' . self::DOMAIN)); - - $this->_mockUser->expects( - $this->once() - )->method( - 'getSharedSecret' - )->will( - $this->returnValue(self::SHARED_SECRET) - ); - - $hash = (string)hash_hmac( - \Magento\Outbound\Authentication\Hmac::SHA256_ALGORITHM, - self::BODY, - self::SHARED_SECRET - ); - - $headers = $this->_model->getSignatureHeaders($this->_mockMessage->getBody(), $this->_mockUser); - $this->assertArrayHasKey(\Magento\Outbound\Authentication\Hmac::DOMAIN_HEADER, $headers); - $this->assertSame(self::DOMAIN, $headers[\Magento\Outbound\Authentication\Hmac::DOMAIN_HEADER]); - $this->assertArrayHasKey(\Magento\Outbound\Authentication\Hmac::HMAC_HEADER, $headers); - $this->assertSame($hash, $headers[\Magento\Outbound\Authentication\Hmac::HMAC_HEADER]); - } - - /** - * @expectedException \LogicException - * @expectedMessage The shared secret cannot be a empty. - */ - public function testEmptySecret() - { - $this->_mockUser->expects($this->once())->method('getSharedSecret')->will($this->returnValue('')); - - $this->_model->getSignatureHeaders($this->_mockMessage, $this->_mockUser); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Outbound/Formatter/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Outbound/Formatter/FactoryTest.php deleted file mode 100644 index 4ebf5af1e8e7c..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Outbound/Formatter/FactoryTest.php +++ /dev/null @@ -1,107 +0,0 @@ -_mockObjectManager = $this->getMockBuilder( - 'Magento\ObjectManager' - )->setMethods( - array('get') - )->disableOriginalConstructor()->getMockForAbstractClass(); - - $this->_expectedObject = $this->getMockBuilder( - 'Magento\Outbound\Formatter\Json' - )->disableOriginalConstructor()->getMock(); - - $this->_formatterFactory = new \Magento\Outbound\Formatter\Factory( - array('json' => 'Test_Formatter_Json'), - $this->_mockObjectManager - ); - } - - public function testGetFormatter() - { - $this->_mockObjectManager->expects( - $this->once() - )->method( - 'get' - )->with( - 'Test_Formatter_Json' - )->will( - $this->returnValue($this->_expectedObject) - ); - - $formatter = $this->_formatterFactory->getFormatter(\Magento\Outbound\EndpointInterface::FORMAT_JSON); - $this->assertInstanceOf('Magento\Outbound\Formatter\Json', $formatter); - $this->assertEquals($this->_expectedObject, $formatter); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage WrongFormatName - */ - public function testGetFormatterWrongFormatName() - { - $this->_formatterFactory->getFormatter('WrongFormatName'); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Formatter class for json does not implement FormatterInterface. - */ - public function testGetFormatterWrongFormatterClass() - { - $this->_mockObjectManager->expects( - $this->once() - )->method( - 'get' - )->with( - 'Test_Formatter_Json' - )->will( - $this->returnValue($this->getMock('Magento\Object')) - ); - - $this->_formatterFactory->getFormatter(\Magento\Outbound\EndpointInterface::FORMAT_JSON); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Outbound/Formatter/JsonTest.php b/dev/tests/unit/testsuite/Magento/Outbound/Formatter/JsonTest.php deleted file mode 100644 index 22cba156c064d..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Outbound/Formatter/JsonTest.php +++ /dev/null @@ -1,79 +0,0 @@ -_formatter = new \Magento\Outbound\Formatter\Json(); - } - - /** - * @dataProvider encodeDataProvider - * - * @param $input - * @param $expectedOutput - */ - public function testFormat($input, $expectedOutput) - { - $this->assertSame($expectedOutput, $this->_formatter->format($input)); - } - - public function testGetContentType() - { - $this->assertSame(\Magento\Outbound\Formatter\Json::CONTENT_TYPE, $this->_formatter->getContentType()); - } - - /** - * DataProvider for testing the JSON formatter. - * - * @return array - */ - public function encodeDataProvider() - { - return array( - array(array(), "[]"), - array(array('a' => array('b' => 'c', 'd' => 'e'), 'f' => 'g'), '{"a":{"b":"c","d":"e"},"f":"g"}'), - array(array(null), '[null]'), - array(array(true), '[true]'), - array(array(false), '[false]'), - array(array(-1), '[-1]'), - array(array(0), '[0]'), - array(array(1), '[1]'), - array(array(2.4), '[2.4]'), - array(array(2.0), '[2]'), - array(array(new \Magento\Outbound\Formatter\JsonTest\Data('public', 'protected')), '[{"dataA":"public"}]') - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Outbound/Formatter/JsonTest/Data.php b/dev/tests/unit/testsuite/Magento/Outbound/Formatter/JsonTest/Data.php deleted file mode 100644 index a1e7ceee9865c..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Outbound/Formatter/JsonTest/Data.php +++ /dev/null @@ -1,47 +0,0 @@ -dataA = $first; - $this->_dataB = $second; - } - - public function getB() - { - return $this->_dataB; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Outbound/Message/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Outbound/Message/FactoryTest.php deleted file mode 100644 index fb45f7b6ac96d..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Outbound/Message/FactoryTest.php +++ /dev/null @@ -1,237 +0,0 @@ - 'hash'); - - /** @var \Magento\Outbound\Message\Factory */ - protected $_factory; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_mockObjectManager; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_mockFormatFactory; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_mockFormatter; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_mockAuthFactory; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_mockEndpoint; - - /** - * @return void - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function setUp() - { - $this->_mockObjectManager = $this->getMockBuilder( - 'Magento\ObjectManager' - )->setMethods( - array('create') - )->disableOriginalConstructor()->getMockForAbstractClass(); - - $this->_mockFormatFactory = $this->getMockBuilder( - 'Magento\Outbound\Formatter\Factory' - )->disableOriginalConstructor()->getMock(); - - $this->_mockAuthFactory = $this->getMockBuilder( - 'Magento\Outbound\Authentication\Factory' - )->disableOriginalConstructor()->getMock(); - - $this->_factory = new \Magento\Outbound\Message\Factory( - $this->_mockObjectManager, - $this->_mockFormatFactory, - $this->_mockAuthFactory - ); - - $this->_mockFormatter = $this->getMockBuilder( - 'Magento\Outbound\FormatterInterface' - )->disableOriginalConstructor()->getMock(); - - $this->_mockEndpoint = $this->getMockBuilder( - 'Magento\Outbound\EndpointInterface' - )->disableOriginalConstructor()->getMock(); - - $this->_mockEndpoint->expects($this->once())->method('getFormat')->will($this->returnValue('some_format')); - - $this->_mockFormatFactory->expects( - $this->once() - )->method( - 'getFormatter' - )->with( - $this->equalTo('some_format') - )->will( - $this->returnValue($this->_mockFormatter) - ); - - $this->_mockFormatter->expects( - $this->once() - )->method( - 'getContentType' - )->will( - $this->returnValue(self::CONTENT_TYPE) - ); - - $this->_mockFormatter->expects( - $this->once() - )->method( - 'format' - )->with( - $this->equalTo(self::$body) - )->will( - $this->returnValue(self::FORMATTED_BODY) - ); - - $this->_mockEndpoint->expects( - $this->once() - )->method( - 'getAuthenticationType' - )->will( - $this->returnValue(self::AUTH_TYPE) - ); - - $mockAuth = $this->getMockBuilder( - 'Magento\Outbound\AuthenticationInterface' - )->disableOriginalConstructor()->getMock(); - - $this->_mockAuthFactory->expects( - $this->once() - )->method( - 'getAuthentication' - )->with( - $this->equalTo(self::AUTH_TYPE) - )->will( - $this->returnValue($mockAuth) - ); - - $mockUser = $this->getMockBuilder('Magento\Outbound\UserInterface')->disableOriginalConstructor()->getMock(); - - $this->_mockEndpoint->expects($this->once())->method('getUser')->will($this->returnValue($mockUser)); - - $mockAuth->expects( - $this->once() - )->method( - 'getSignatureHeaders' - )->with( - $this->equalTo(self::FORMATTED_BODY), - $this->equalTo($mockUser) - )->will( - $this->returnValue(self::$signatureHeaders) - ); - - $this->_mockEndpoint->expects( - $this->once() - )->method( - 'getEndpointUrl' - )->will( - $this->returnValue(self::ENDPOINT_URL) - ); - - $this->_mockEndpoint->expects( - $this->once() - )->method( - 'getTimeoutInSecs' - )->will( - $this->returnValue(self::TIMEOUT) - ); - - $this->_mockObjectManager->expects( - $this->once() - )->method( - 'create' - )->with( - $this->equalTo('Magento\Outbound\Message'), - $this->anything() - )->will( - $this->returnCallback(array($this, 'verifyManagerCreate')) - ); - } - - public function testCreate() - { - $this->assertEquals('SUCCESS', $this->_factory->create($this->_mockEndpoint, self::TOPIC, self::$body)); - } - - /** - * Used to verify the correct arguments are passed in to \Magento\ObjectManager::create - * - * @param $className - * @param array $arguments - * - * @return string - */ - public function verifyManagerCreate($className, array $arguments) - { - $this->assertSame('Magento\Outbound\Message', $className); - - $this->assertCount(4, $arguments); - - $this->assertArrayHasKey('endpointUrl', $arguments); - $this->assertSame(self::ENDPOINT_URL, $arguments['endpointUrl']); - - $this->assertArrayHasKey('headers', $arguments); - $headers = $arguments['headers']; - $this->assertArrayHasKey(\Magento\Outbound\Message\FactoryInterface::TOPIC_HEADER, $headers); - $this->assertSame(self::TOPIC, $headers[\Magento\Outbound\Message\FactoryInterface::TOPIC_HEADER]); - $this->assertArrayHasKey(\Magento\Outbound\FormatterInterface::CONTENT_TYPE_HEADER, $headers); - $this->assertSame(self::CONTENT_TYPE, $headers[\Magento\Outbound\FormatterInterface::CONTENT_TYPE_HEADER]); - foreach (self::$signatureHeaders as $key => $value) { - $this->assertArrayHasKey($key, $headers); - $this->assertSame($value, $headers[$key]); - } - - $this->assertArrayHasKey('body', $arguments); - $this->assertSame(self::FORMATTED_BODY, $arguments['body']); - - $this->assertArrayHasKey('timeout', $arguments); - $this->assertSame(self::TIMEOUT, $arguments['timeout']); - - return 'SUCCESS'; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Outbound/MessageTest.php b/dev/tests/unit/testsuite/Magento/Outbound/MessageTest.php deleted file mode 100644 index 14b0a62acd464..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Outbound/MessageTest.php +++ /dev/null @@ -1,47 +0,0 @@ - 'val1', 'key2' => 'val2'), "Body"); - // check endpoint url - $this->assertSame('http://localhost', $uut->getEndpointUrl()); - // check headers - $rsltHdr = $uut->getHeaders(); - $this->assertSame('val1', $rsltHdr['key1']); - $this->assertSame('val2', $rsltHdr['key2']); - // check for body - $this->assertSame("Body", $uut->getBody()); - // check for default timeout - $this->assertSame(20, $uut->getTimeout()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Outbound/Transport/Http/ResponseTest.php b/dev/tests/unit/testsuite/Magento/Outbound/Transport/Http/ResponseTest.php deleted file mode 100644 index 18363f3aae4b8..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Outbound/Transport/Http/ResponseTest.php +++ /dev/null @@ -1,72 +0,0 @@ -assertTrue($uut->isSuccessful()); - } - - public function testIsSuccessfulFalse() - { - $uut = new \Magento\Outbound\Transport\Http\Response("HTTP/2.0 301 Moved Permanently"); - $this->assertFalse($uut->isSuccessful()); - } - - public function testGetStatusCode() - { - $uut = new \Magento\Outbound\Transport\Http\Response("HTTP/2.0 299 OK"); - $this->assertSame(299, $uut->getStatusCode()); - } - - public function testGetMessage() - { - $uut = new \Magento\Outbound\Transport\Http\Response("HTTP/2.0 299 A-OK"); - $this->assertSame("A-OK", $uut->getMessage()); - } - - public function testGetBody() - { - $uut = new \Magento\Outbound\Transport\Http\Response("HTTP/2.0 200 OK\nHdrkey: Hdrval\n\nRaw Body"); - $this->assertSame("Raw Body", $uut->getBody()); - } - - public function testGetHeaders() - { - $hdrs = array('Key1' => 'val1', 'Key2' => 'val2'); - $uut = new \Magento\Outbound\Transport\Http\Response( - "HTTP/2.0 200 OK\nkey1: val1\nkey2: val2\n\nMessage Body" - ); - $this->assertEquals($hdrs, $uut->getHeaders()); - $this->assertEquals($hdrs['Key1'], $uut->getHeader('Key1')); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Outbound/Transport/HttpTest.php b/dev/tests/unit/testsuite/Magento/Outbound/Transport/HttpTest.php deleted file mode 100644 index d85c6be71d7b7..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Outbound/Transport/HttpTest.php +++ /dev/null @@ -1,124 +0,0 @@ -_mockVrnHttpAdptrCrl = $this->getMockBuilder( - 'Magento\HTTP\Adapter\Curl' - )->disableOriginalConstructor()->getMock(); - $this->_mockMessage = $this->getMockBuilder( - 'Magento\Outbound\Message' - )->disableOriginalConstructor()->getMock(); - $this->_mockMessage->expects( - $this->any() - )->method( - 'getHeaders' - )->will( - $this->returnValue(array('header' => 'value')) - ); - } - - /** - * Test case for when http adapter returns null - * - * @expectedException \Zend_Http_Exception - */ - public function testNullResponse() - { - $uut = new \Magento\Outbound\Transport\Http($this->_mockVrnHttpAdptrCrl); - $this->_mockVrnHttpAdptrCrl->expects($this->any())->method('read')->will($this->returnValue(null)); - $uut->dispatch($this->_mockMessage); - } - - public function testPositive() - { - $uut = new \Magento\Outbound\Transport\Http($this->_mockVrnHttpAdptrCrl); - $this->_mockVrnHttpAdptrCrl->expects( - $this->any() - )->method( - 'read' - )->will( - $this->returnValue("HTTP/2.0 200 OK\nHdrkey: Hdrval\n\nMessage Body") - ); - $response = $uut->dispatch($this->_mockMessage); - $this->assertSame(200, $response->getStatusCode()); - $this->assertSame("OK", $response->getMessage()); - $this->assertSame(array("Hdrkey" => "Hdrval"), $response->getHeaders()); - $this->assertSame("Message Body", $response->getBody()); - } - - /** - * @dataProvider timeoutDataProvider - * - * @param $timeout - */ - public function testMessageTimeout($timeout, $expectedTimeout) - { - $uut = new \Magento\Outbound\Transport\Http($this->_mockVrnHttpAdptrCrl); - $this->_mockMessage->expects($this->any())->method('getTimeout')->will($this->returnValue($timeout)); - $config = array('verifypeer' => true, 'verifyhost' => 2, 'timeout' => $expectedTimeout); - $this->_mockVrnHttpAdptrCrl->expects($this->once())->method('setConfig')->with($config); - $this->_mockVrnHttpAdptrCrl->expects( - $this->any() - )->method( - 'read' - )->will( - $this->returnValue("HTTP/2.0 200 OK\nHdrkey: Hdrval\n\nMessage Body") - ); - $response = $uut->dispatch($this->_mockMessage); - $this->assertSame(200, $response->getStatusCode()); - $this->assertSame("OK", $response->getMessage()); - $this->assertSame(array("Hdrkey" => "Hdrval"), $response->getHeaders()); - $this->assertSame("Message Body", $response->getBody()); - } - - /** - * DataProvider for testing dispatch with different message timeout. - * - * @return array - */ - public function timeoutDataProvider() - { - return array( - array(0, \Magento\Outbound\Message::DEFAULT_TIMEOUT), - array(null, \Magento\Outbound\Message::DEFAULT_TIMEOUT), - array(5, 5), - array(\Magento\Outbound\Message::DEFAULT_TIMEOUT, \Magento\Outbound\Message::DEFAULT_TIMEOUT) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FactoryTest.php index 8ad0bff6f3265..3944bfe93d3a2 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FactoryTest.php @@ -84,7 +84,7 @@ public function testCreateMethodWithArguments() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage WrongClass class doesn't implement \Magento\Payment\Model\MethodInterface */ public function testWrongTypeException() diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php index fe468190727ad..66c6ec7698ded 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php @@ -67,8 +67,6 @@ protected function setUp() ->getMock(); $localeResolver = $this->getMock('Magento\Locale\ResolverInterface', array(), array(), '', false, false); - $appMock = $this->getMock('\Magento\Core\Model\App', array('getLocaleResolver'), array(), '', false); - $appMock->expects($this->any())->method('getLocaleResolver')->will($this->returnValue($localeResolver)); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_model = $helper->getObject( 'Magento\Paypal\Block\Express\Form', @@ -77,7 +75,7 @@ protected function setUp() 'paypalConfigFactory' => $paypalConfigFactory, 'currentCustomer' => $this->currentCustomer, 'layout' => $layout, - 'app' => $appMock + 'localeResolver' => $localeResolver ) ); } diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Block/Payflow/Link/IframeTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Block/Payflow/Link/IframeTest.php new file mode 100644 index 0000000000000..aefd6a256cb82 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Paypal/Block/Payflow/Link/IframeTest.php @@ -0,0 +1,66 @@ +getMock('Magento\View\Element\Template\Context', [], [], '', false); + $checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); + $orderFactoryMock = $this->getMock('Magento\Sales\Model\OrderFactory', ['getQuote'], [], '', false); + $hssHelperMock = $this->getMock('Magento\Paypal\Helper\Hss', [], [], '', false); + $paymentDataMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $quoteMock = $this->getMock('Magento\Sales\Model\Quote', ['getPayment', '__wakeup'], [], '', false); + $paymentMock = $this->getMock('Magento\Sales\Model\Quote\Payment', [], [], '', false); + + $checkoutSessionMock->expects($this->any()) + ->method('getQuote') + ->will($this->returnValue($quoteMock)); + $quoteMock->expects($this->any()) + ->method('getPayment') + ->will($this->returnValue($paymentMock)); + $hssHelperMock->expects($this->any()) + ->method('getHssMethods') + ->will($this->returnValue([])); + + $block = new \Magento\Paypal\Block\Payflow\Advanced\Iframe( + $contextMock, + $orderFactoryMock, + $checkoutSessionMock, + $hssHelperMock, + $paymentDataMock + ); + + $this->assertFalse($block->isScopePrivate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php index 381ccfcdf5883..18df9b8c4a29b 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php @@ -61,12 +61,14 @@ protected function setUp() $this->returnValue($mark) ); $localeResolver = $this->getMock('Magento\Locale\ResolverInterface', array(), array(), '', false, false); - $appMock = $this->getMock('\Magento\Core\Model\App', array('getLocaleResolver'), array(), '', false); - $appMock->expects($this->any())->method('getLocaleResolver')->will($this->returnValue($localeResolver)); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_model = $helper->getObject( 'Magento\Paypal\Block\PayflowExpress\Form', - array('paypalConfigFactory' => $paypalConfigFactory, 'layout' => $layout, 'app' => $appMock) + [ + 'paypalConfigFactory' => $paypalConfigFactory, + 'layout' => $layout, + 'localeResolver' => $localeResolver + ] ); } diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php index 2b6af88185454..c0f2a215abf56 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php @@ -212,8 +212,8 @@ public function testAddBillingAgreementToSession($isValid) $agreement = $this->getMock('Magento\Paypal\Model\Billing\Agreement', array(), array(), '', false); $agreement->expects($this->once())->method('isValid')->will($this->returnValue($isValid)); $comment = $this->getMockForAbstractClass( - 'Magento\Core\Model\AbstractModel', - array(), + 'Magento\Model\AbstractModel', + [], '', false, true, diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php index 3f2e1f3598fb6..bdf98a26f3010 100644 --- a/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php @@ -40,33 +40,34 @@ class SessionTest extends \PHPUnit_Framework_TestCase */ protected $_cookieMock; - /** - * @var \Magento\Core\Model\Resource\AbstractResource|\PHPUnit_Framework_MockObject_MockObject - */ - protected $_resource; - protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_configMock = $this->getMock('Magento\Session\Config\ConfigInterface'); $this->_cookieMock = $this->getMock('Magento\Stdlib\Cookie', array(), array(), '', false); - $this->_resource = $this->getMockForAbstractClass( - 'Magento\Core\Model\Resource\Db\AbstractDb', - array(), - '', - false, - false, - true, - array('__wakeup', 'getIdFieldName', 'getConnection', 'beginTransaction', 'delete', 'commit', 'rollBack') + $resourceMock = $this->getMockForAbstractClass('Magento\Model\Resource\Db\AbstractDb', + array(), '', false, false, true, + array('__wakeup', 'getIdFieldName', 'getConnection', 'beginTransaction', 'delete', 'commit', 'rollBack')); + + $appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false); + $eventDispatcherMock = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false, false); + $cacheManagerMock = $this->getMock('Magento\App\CacheInterface', array(), array(), '', false, false); + $loggerMock = $this->getMock('Magento\Logger', array(), array(), '', false); + $actionValidatorMock = $this->getMock( + '\Magento\Model\ActionValidator\RemoveAction', array(), array(), '', false ); - $this->_model = $helper->getObject( - 'Magento\Persistent\Model\Session', - array( - 'sessionConfig' => $this->_configMock, - 'cookie' => $this->_cookieMock, - 'resource' => $this->_resource - ) + $actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); + + $context = new \Magento\Model\Context( + $loggerMock, $eventDispatcherMock, $cacheManagerMock, $appStateMock, $actionValidatorMock ); + + $this->_model = $helper->getObject('Magento\Persistent\Model\Session', array( + 'sessionConfig' => $this->_configMock, + 'cookie' => $this->_cookieMock, + 'resource' => $resourceMock, + 'context' => $context + )); } /** diff --git a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/CompositeTest.php b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/CompositeTest.php index 26d864ffe663b..8a358cac536c2 100644 --- a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/CompositeTest.php +++ b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/CompositeTest.php @@ -59,32 +59,35 @@ public function testConstructorException() public function testRender() { $text = 'some text'; - $arguments = array('arg1', 'arg2'); + $arguments = ['arg1', 'arg2']; $resultAfterFirst = 'rendered text first'; $resultAfterSecond = 'rendered text second'; $this->rendererOne->expects( $this->once() )->method( - 'render' - )->with( - $text, - $arguments - )->will( - $this->returnValue($resultAfterFirst) - ); + 'render' + )->with( + [$text], + $arguments + )->will( + $this->returnValue($resultAfterFirst) + ); $this->rendererTwo->expects( $this->once() )->method( - 'render' - )->with( - $resultAfterFirst, - $arguments - )->will( - $this->returnValue($resultAfterSecond) - ); + 'render' + )->with( + [ + $text, + $resultAfterFirst + ], + $arguments + )->will( + $this->returnValue($resultAfterSecond) + ); - $this->assertEquals($resultAfterSecond, $this->object->render($text, $arguments)); + $this->assertEquals($resultAfterSecond, $this->object->render([$text], $arguments)); } } diff --git a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/InlineTest.php b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/InlineTest.php new file mode 100644 index 0000000000000..453b1de3b1b7d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/InlineTest.php @@ -0,0 +1,91 @@ +translator = $this->getMock('Magento\TranslateInterface', [], [], '', false); + $this->provider = $this->getMock('Magento\Translate\Inline\ProviderInterface', [], [], '', false); + + $this->renderer = new \Magento\Phrase\Renderer\Inline( + $this->translator, + $this->provider + ); + } + + public function testRenderIfInlineTranslationIsAllowed() + { + $theme = 'theme'; + $text = 'test'; + $result = sprintf('{{{%s}}{{%s}}}', $text, $theme); + + $this->translator->expects($this->once()) + ->method('getTheme') + ->will($this->returnValue($theme)); + + $inlineTranslate = $this->getMock('Magento\Translate\InlineInterface', [], [], '', []); + $inlineTranslate->expects($this->once()) + ->method('isAllowed') + ->will($this->returnValue(true)); + + $this->provider->expects($this->once()) + ->method('get') + ->will($this->returnValue($inlineTranslate)); + + $this->assertEquals($result, $this->renderer->render([$text], [])); + } + + public function testRenderIfInlineTranslationIsNotAllowed() + { + $text = 'test'; + + $inlineTranslate = $this->getMock('Magento\Translate\InlineInterface', [], [], '', []); + $inlineTranslate->expects($this->once()) + ->method('isAllowed') + ->will($this->returnValue(false)); + + $this->provider->expects($this->once()) + ->method('get') + ->will($this->returnValue($inlineTranslate)); + + $this->assertEquals($text, $this->renderer->render([$text], [])); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/PlaceholderTest.php b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/PlaceholderTest.php index 8db4fed7be6de..d011a00e191f4 100644 --- a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/PlaceholderTest.php +++ b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/PlaceholderTest.php @@ -43,7 +43,7 @@ protected function setUp() */ public function testRenderPlaceholder($text, array $arguments, $result) { - $this->assertEquals($result, $this->_renderer->render($text, $arguments)); + $this->assertEquals($result, $this->_renderer->render([$text], $arguments)); } /** diff --git a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/TranslateTest.php b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/TranslateTest.php index 91fd867c99065..e3ab5658d6fa9 100644 --- a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/TranslateTest.php +++ b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/TranslateTest.php @@ -46,20 +46,44 @@ protected function setUp() ); } - public function testTranslate() + public function testRenderByCode() { + $text = 'original text'; $result = 'rendered text'; $this->_translator->expects( $this->once() )->method( - 'translate' - )->with( - array('text', 'param1', 'param2', 'param3') + 'getTheme' )->will( - $this->returnValue($result) + $this->returnValue('theme') ); + $this->_translator->expects( + $this->once() + )->method( + 'getData' + )->will( + $this->returnValue(['theme::' . $text => $result]) + ); + + $this->assertEquals($result, $this->_renderer->render([$text], [])); + } + + public function testRenderByText() + { + $text = 'original text'; + $result = 'rendered text'; + + $this->_translator->expects($this->once()) + ->method('getTheme') + ->will($this->returnValue('theme')); + $this->_translator->expects($this->once()) + ->method('getData') + ->will($this->returnValue([ + 'theme::' . $text => $result, + $text => $result, + ])); - $this->assertEquals($result, $this->_renderer->render('text', array('param1', 'param2', 'param3'))); + $this->assertEquals($result, $this->_renderer->render([$text], [])); } } diff --git a/dev/tests/unit/testsuite/Magento/PhraseTest.php b/dev/tests/unit/testsuite/Magento/PhraseTest.php index b072e616195d7..4eacdbc290a70 100644 --- a/dev/tests/unit/testsuite/Magento/PhraseTest.php +++ b/dev/tests/unit/testsuite/Magento/PhraseTest.php @@ -45,30 +45,31 @@ protected function tearDown() public function testRendering() { $text = 'some text'; - $arguments = array('arg1', 'arg2'); + $arguments = ['arg1', 'arg2']; $result = 'rendered text'; - $phrase = new \Magento\Phrase($text, $arguments); $this->_renderer->expects( $this->once() )->method( 'render' )->with( - $text, + [$text], $arguments )->will( $this->returnValue($result) ); + $phrase = new \Magento\Phrase($text, $arguments); $this->assertEquals($result, $phrase->render()); } public function testRenderingWithoutRenderer() { $this->_removeRendererFromPhrase(); + $result = 'some text'; - $phrase = new \Magento\Phrase($result); + $phrase = new \Magento\Phrase($result); $this->assertEquals($result, $phrase->render()); } @@ -82,21 +83,21 @@ public function testDefersRendering() public function testThatToStringIsAliasToRender() { $text = 'some text'; - $arguments = array('arg1', 'arg2'); + $arguments = ['arg1', 'arg2']; $result = 'rendered text'; - $phrase = new \Magento\Phrase($text, $arguments); $this->_renderer->expects( $this->once() )->method( 'render' )->with( - $text, + [$text], $arguments )->will( $this->returnValue($result) ); + $phrase = new \Magento\Phrase($text, $arguments); $this->assertEquals($result, (string)$phrase); } diff --git a/dev/tests/unit/testsuite/Magento/PubSub/Event/FactoryTest.php b/dev/tests/unit/testsuite/Magento/PubSub/Event/FactoryTest.php deleted file mode 100644 index 56fd99a57b72a..0000000000000 --- a/dev/tests/unit/testsuite/Magento/PubSub/Event/FactoryTest.php +++ /dev/null @@ -1,37 +0,0 @@ -create('topic', array()); - - $this->assertInstanceOf('Magento\PubSub\EventInterface', $event); - } -} diff --git a/dev/tests/unit/testsuite/Magento/PubSub/Event/QueueWriterTest.php b/dev/tests/unit/testsuite/Magento/PubSub/Event/QueueWriterTest.php deleted file mode 100644 index 609c0e4c07a53..0000000000000 --- a/dev/tests/unit/testsuite/Magento/PubSub/Event/QueueWriterTest.php +++ /dev/null @@ -1,38 +0,0 @@ -getMockBuilder('Magento\PubSub\EventInterface')->disableOriginalConstructor()->getMock(); - $queue = new \Magento\PubSub\Event\QueueWriter(); - $result = $queue->offer($event); - - $this->assertNull($result); - } -} diff --git a/dev/tests/unit/testsuite/Magento/PubSub/EventTest.php b/dev/tests/unit/testsuite/Magento/PubSub/EventTest.php deleted file mode 100644 index 7ee81b4246882..0000000000000 --- a/dev/tests/unit/testsuite/Magento/PubSub/EventTest.php +++ /dev/null @@ -1,53 +0,0 @@ - 'body'); - $topic = 'topic'; - - $event = new \Magento\PubSub\Event($topic, $bodyData); - - $this->assertEquals(array(), $event->getHeaders()); - $this->assertEquals($bodyData, $event->getBodyData()); - $this->assertEquals($topic, $event->getTopic()); - $this->assertEquals(\Magento\PubSub\Event::STATUS_READY_TO_SEND, $event->getStatus()); - } - - public function testComplete() - { - $bodyData = array('some' => 'body'); - $topic = 'topic'; - $event = new \Magento\PubSub\Event($topic, $bodyData); - - $event->complete(); - - $this->assertEquals(\Magento\PubSub\Event::STATUS_PROCESSED, $event->getStatus()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/PubSub/Message/DispatcherAsyncTest.php b/dev/tests/unit/testsuite/Magento/PubSub/Message/DispatcherAsyncTest.php deleted file mode 100644 index dcd66a6e72419..0000000000000 --- a/dev/tests/unit/testsuite/Magento/PubSub/Message/DispatcherAsyncTest.php +++ /dev/null @@ -1,95 +0,0 @@ -_eventFactoryMock = $this->getMockBuilder( - 'Magento\PubSub\Event\FactoryInterface' - )->disableOriginalConstructor()->getMock(); - - $this->_queueWriter = $this->getMockBuilder( - 'Magento\PubSub\Event\QueueWriterInterface' - )->disableOriginalConstructor()->getMock(); - $this->_queueWriter->expects($this->once())->method('offer'); - - // When the create method is called, program routes to the logEventData callback to log what arguments it - // received. - $this->_eventFactoryMock->expects( - $this->once() - )->method( - 'create' - )->with()->will( - $this->returnCallback(array($this, 'logEventData')) - ); - $this->_eventMock = $this->getMockBuilder( - 'Magento\PubSub\EventInterface' - )->disableOriginalConstructor()->getMock(); - - $this->_dispatcher = new \Magento\PubSub\Message\DispatcherAsync( - $this->_eventFactoryMock, - $this->_queueWriter - ); - } - - public function testDispatch() - { - $expectedData = array('topic' => 'event_topic', 'data' => 'event_data'); - $this->_dispatcher->dispatch($expectedData['topic'], $expectedData['data']); - $this->assertEquals($expectedData, $this->_actualData); - } - - /** - * Log the topic and data that are passed to the event factory's create method. This is to ensure that the - * create method is called as expected. - * - * @param $topic - * @param $data - * @return \PHPUnit_Framework_MockObject_MockObject - */ - public function logEventData($topic, $data) - { - $this->_actualData = array('topic' => $topic, 'data' => $data); - return $this->_eventMock; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Review/Block/Adminhtml/MainTest.php b/dev/tests/unit/testsuite/Magento/Review/Block/Adminhtml/MainTest.php new file mode 100644 index 0000000000000..5e8660335d175 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Review/Block/Adminhtml/MainTest.php @@ -0,0 +1,74 @@ +customerAccount = $this + ->getMockForAbstractClass('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $this->customerAccount->expects($this->once()) + ->method('getCustomer') + ->with('customer id') + ->will($this->returnValue(new \Magento\Object())); + $this->request = $this->getMockForAbstractClass('Magento\App\RequestInterface'); + $this->request->expects($this->at(0)) + ->method('getParam') + ->with('customerId', false) + ->will($this->returnValue('customer id')); + $this->request->expects($this->at(1)) + ->method('getParam') + ->with('productId', false) + ->will($this->returnValue(false)); + + + $objectManagerHelper = new ObjectManagerHelper($this); + $this->model = $objectManagerHelper->getObject( + 'Magento\Review\Block\Adminhtml\Main', + [ + 'request' => $this->request, + 'customerAccount' => $this->customerAccount + ] + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Review/Model/Resource/Review/Summary/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Review/Model/Resource/Review/Summary/CollectionTest.php new file mode 100644 index 0000000000000..cfd7e6a9abcbf --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Review/Model/Resource/Review/Summary/CollectionTest.php @@ -0,0 +1,146 @@ +fetchStrategyMock = $this->getMock( + 'Magento\Data\Collection\Db\FetchStrategy\Query', array('fetchAll'), array(), '', false + ); + $this->entityFactoryMock = $this->getMock( + 'Magento\Core\Model\EntityFactory', array('create'), array(), '', false + ); + $this->loggerMock = $this->getMock('Magento\Logger', array('log'), array(), '', false); + $this->resourceMock = $this->getMock( + 'Magento\App\Resource', array('getConnection', 'getTableName'), array(), '', false + ); + $this->adapterMock = $this->getMock( + 'Zend_Db_Adapter_Pdo_Mysql', array('select', 'query'), array(), '', false + ); + $this->selectMock = $this->getMock( + 'Magento\DB\Select', array('from'), array('adapter' => $this->adapterMock) + ); + $this->adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + $this->resourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->resourceMock->expects($this->once()) + ->method('getTableName') + ->will($this->returnArgument(0)); + + $this->collection = new Collection( + $this->entityFactoryMock, + $this->loggerMock, + $this->fetchStrategyMock, + $this->resourceMock + ); + } + + public function testFetchItem() + { + $data = array(1 => 'test'); + $statementMock = $this->getMock('Zend_Db_Statement_Pdo', array('fetch'), array(), '', false); + $statementMock->expects($this->once()) + ->method('fetch') + ->will($this->returnValue($data)); + + $this->adapterMock->expects($this->once()) + ->method('query') + ->with($this->selectMock, $this->anything()) + ->will($this->returnValue($statementMock)); + + $objectMock = $this->getMock('Magento\Object', array('setData'), array()); + $objectMock->expects($this->once()) + ->method('setData') + ->with($data); + $this->entityFactoryMock->expects($this->once()) + ->method('create') + ->with('Magento\Review\Model\Review\Summary') + ->will($this->returnValue($objectMock)); + $item = $this->collection->fetchItem(); + + $this->assertEquals($objectMock, $item); + $this->assertEquals('primary_id', $item->getIdFieldName()); + } + + public function testLoad() + { + $data = array(10 => 'test'); + $this->fetchStrategyMock->expects($this->once()) + ->method('fetchAll') + ->with($this->selectMock, array()) + ->will($this->returnValue(array($data))); + + $objectMock = $this->getMock('Magento\Object', array('addData'), array()); + $objectMock->expects($this->once()) + ->method('addData') + ->with($data); + $this->entityFactoryMock->expects($this->once()) + ->method('create') + ->with('Magento\Review\Model\Review\Summary') + ->will($this->returnValue($objectMock)); + + $this->collection->load(); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreditmemoTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreditmemoTest.php index b852bfb658f3d..ef51a31fa2659 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreditmemoTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreditmemoTest.php @@ -226,7 +226,7 @@ public function testSaveActionWithNegativeCreditmemo() } /** - * Set expectations in case of \Magento\Core\Exception for saveAction method + * Set expectations in case of \Magento\Model\Exception for saveAction method * * @param array $data * @param string $errorMessage diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Config/Source/Order/StatusTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Config/Source/Order/StatusTest.php new file mode 100644 index 0000000000000..067d6c06599dd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Config/Source/Order/StatusTest.php @@ -0,0 +1,63 @@ +config = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false); + + $this->objectManager = new ObjectManager($this); + $this->object = $this->objectManager->getObject('Magento\Sales\Model\Config\Source\Order\Status', [ + 'orderConfig' => $this->config + ]); + } + + public function testToOptionArray() + { + $this->config->expects($this->once())->method('getStateStatuses') + ->will($this->returnValue(['status1', 'status2'])); + + $this->assertEquals( + [ + ['value' => '', 'label' => '-- Please Select --'], + ['value' => 0, 'label' => 'status1'], + ['value' => 1, 'label' => 'status2'], + ], + $this->object->toOptionArray() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php index cb784de4afb0a..3b7196b1a546a 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php @@ -42,7 +42,7 @@ public function testInsertTotals() $paymentData = $this->getMock('Magento\Payment\Helper\Data', array(), array(), '', false); $string = $this->getMock('Magento\Stdlib\String', array(), array(), '', false); $coreStoreConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false); - $translate = $this->getMock('Magento\TranslateInterface', array(), array(), '', false); + $translate = $this->getMock('Magento\Translate\Inline\StateInterface', array(), array(), '', false); $filesystem = $this->getMock('Magento\App\Filesystem', array(), array(), '', false); $pdfItemsFactory = $this->getMock('Magento\Sales\Model\Order\Pdf\ItemsFactory', array(), array(), '', false); $localeMock = $this->getMock('Magento\Stdlib\DateTime\TimezoneInterface', array(), array(), '', false, false); @@ -98,20 +98,20 @@ public function testInsertTotals() $model = $this->getMockForAbstractClass( 'Magento\Sales\Model\Order\Pdf\AbstractPdf', array( - $paymentData, - $string, - $coreStoreConfig, - $translate, + $paymentData, + $string, + $coreStoreConfig, $filesystem, - $pdfConfig, - $pdfTotalFactory, - $pdfItemsFactory, - $localeMock + $pdfConfig, + $pdfTotalFactory, + $pdfItemsFactory, + $localeMock, + $translate ), - '', - true, - false, - true, + '', + true, + false, + true, array('drawLineBlocks') ); $model->expects($this->once())->method('drawLineBlocks')->will($this->returnValue($page)); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php index 3b8add09c8654..65e5113b75330 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php @@ -40,7 +40,7 @@ protected function setUp() $paymentDataMock = $this->getMock('Magento\Payment\Helper\Data', array(), array(), '', false); $stringMock = $this->getMock('Magento\Stdlib\String', array(), array(), '', false, false); $storeConfigMock = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false, false); - $translateMock = $this->getMock('Magento\TranslateInterface', array(), array(), '', false, false); + $translateMock = $this->getMock('Magento\Translate\Inline\StateInterface', array(), array(), '', false, false); $directoryMock = $this->getMock('Magento\Filesystem\Directory\Write', array(), array(), '', false, false); $directoryMock->expects($this->any())->method('getAbsolutePath')->will( $this->returnCallback( @@ -99,12 +99,12 @@ function ($argument) { $paymentDataMock, $stringMock, $storeConfigMock, - $translateMock, $filesystemMock, $this->_pdfConfigMock, $totalFactoryMock, $pdfItemsFactoryMock, $localeDateMock, + $translateMock, $storeManagerMock, $localeResolverMock, array() diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/Total/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/Total/FactoryTest.php index be178a3097064..552a2caf3c441 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/Total/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/Total/FactoryTest.php @@ -87,7 +87,7 @@ public static function createDataProvider() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage The PDF total model TEST must be or extend * \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal. */ diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Total/Config/BaseTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Total/Config/BaseTest.php new file mode 100644 index 0000000000000..52e5dc3b1d80a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Total/Config/BaseTest.php @@ -0,0 +1,156 @@ +configCacheType = $this->getMock('Magento\App\Cache\Type\Config', [], [], '', false); + $this->logger = $this->getMock('Magento\Logger', [], [], '', false); + $this->salesConfig = $this->getMock('Magento\Sales\Model\Config', [], [], '', false); + $this->orderTotalFactory = $this->getMock('Magento\Sales\Model\Order\TotalFactory', [], [], '', false); + + $objectManager = new ObjectManager($this); + $this->object = $objectManager->getObject('Magento\Sales\Model\Order\Total\Config\Base', [ + 'configCacheType' => $this->configCacheType, + 'logger' => $this->logger, + 'salesConfig' => $this->salesConfig, + 'orderTotalFactory' => $this->orderTotalFactory, + ]); + } + + public function testGetTotalModels() + { + $total = $this->getMockForAbstractClass('Magento\Sales\Model\Order\Total\AbstractTotal'); + $this->salesConfig->expects($this->once())->method('getGroupTotals')->will( + $this->returnValue([ + 'some_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1903], + 'other_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1723], + ]) + ); + + $this->orderTotalFactory->expects($this->any())->method('create') + ->with('Magento\Sales\Model\Order\Total\AbstractTotal') + ->will($this->returnValue($total)); + + $this->configCacheType->expects($this->once())->method('save') + ->with('a:2:{i:0;s:10:"other_code";i:1;s:9:"some_code";}', 'sorted_collectors'); + + $this->assertSame( + ['other_code' => $total, 'some_code' => $total], + $this->object->getTotalModels() + ); + } + + /** + * @expectedException Magento\Model\Exception + * @expectedExceptionMessage The total model should be extended from \Magento\Sales\Model\Order\Total\AbstractTotal. + */ + public function testGetTotalModelsInvalidTotalModel() + { + $this->salesConfig->expects($this->once())->method('getGroupTotals')->will( + $this->returnValue([ + 'some_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1903], + 'other_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1723], + ]) + ); + + $this->orderTotalFactory->expects($this->any())->method('create') + ->with('Magento\Sales\Model\Order\Total\AbstractTotal') + ->will($this->returnValue($this)); + + $this->object->getTotalModels(); + } + + public function testGetTotalUnserializeCachedCollectorCodes() + { + $total = $this->getMockForAbstractClass('Magento\Sales\Model\Order\Total\AbstractTotal'); + $this->salesConfig->expects($this->any())->method('getGroupTotals')->will( + $this->returnValue([ + 'some_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1903], + 'other_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1723], + ]) + ); + + $this->orderTotalFactory->expects($this->any())->method('create') + ->with('Magento\Sales\Model\Order\Total\AbstractTotal') + ->will($this->returnValue($total)); + + $this->configCacheType->expects($this->once())->method('load')->with('sorted_collectors') + ->will($this->returnValue('a:2:{i:0;s:10:"other_code";i:1;s:9:"some_code";}')); + $this->configCacheType->expects($this->never())->method('save'); + + $this->assertSame( + ['other_code' => $total, 'some_code' => $total], + $this->object->getTotalModels() + ); + } + + public function testGetTotalModelsSortingSubroutine() + { + $total = $this->getMockForAbstractClass('Magento\Sales\Model\Order\Total\AbstractTotal'); + $this->salesConfig->expects($this->once())->method('getGroupTotals')->will( + $this->returnValue([ + 'some_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1903], + 'other_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1112], + 'equal_order' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1112], + 'big_order' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 3000], + 'no_order' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal'], + ]) + ); + + $this->orderTotalFactory->expects($this->any())->method('create') + ->with('Magento\Sales\Model\Order\Total\AbstractTotal') + ->will($this->returnValue($total)); + + $this->assertSame( + [ + 'no_order' => $total, + 'equal_order' => $total, + 'other_code' => $total, + 'some_code' => $total, + 'big_order' => $total, + ], + $this->object->getTotalModels() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sitemap/Model/SitemapTest.php b/dev/tests/unit/testsuite/Magento/Sitemap/Model/SitemapTest.php index 24c6fb96fc569..615893e4b314d 100644 --- a/dev/tests/unit/testsuite/Magento/Sitemap/Model/SitemapTest.php +++ b/dev/tests/unit/testsuite/Magento/Sitemap/Model/SitemapTest.php @@ -173,7 +173,7 @@ protected function setUp() /** * Check not allowed sitemap path validation * - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Please define a correct path. */ public function testNotAllowedPath() @@ -186,7 +186,7 @@ public function testNotAllowedPath() /** * Check not exists sitemap path validation * - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Please create the specified folder "" before saving the sitemap. */ public function testPathNotExists() @@ -200,7 +200,7 @@ public function testPathNotExists() /** * Check not writable sitemap path validation * - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Please make sure that "/" is writable by the web-server. */ public function testPathNotWritable() @@ -216,7 +216,7 @@ public function testPathNotWritable() /** * Check invalid chars in sitemap filename validation * - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception * @expectedExceptionMessage Please use only letters (a-z or A-Z), numbers (0-9) or underscores (_) in the filename. No spaces or other characters are allowed. */ //@codingStandardsIgnoreEnd diff --git a/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/FactoryTest.php index 0b60f8dda9c05..21b055cfc42a4 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/FactoryTest.php @@ -98,7 +98,7 @@ public function testCreateWithWrongClassType() $taxClassFactory = new \Magento\Tax\Model\TaxClass\Factory($objectManager); $this->setExpectedException( - 'Magento\Core\Exception', + 'Magento\Model\Exception', sprintf('Invalid type of tax class "%s"', $wrongClassType) ); $taxClassFactory->create($classMock); diff --git a/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/Type/CustomerTest.php b/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/Type/CustomerTest.php index de302bec8527b..b2d4be0733b5a 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/Type/CustomerTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/Type/CustomerTest.php @@ -31,7 +31,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase public function testGetAssignedObjects() { $collectionMock = $this->getMockBuilder( - 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection' + 'Magento\Model\Resource\Db\Collection\AbstractCollection' )->setMethods( array('addFieldToFilter') )->disableOriginalConstructor()->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/Type/ProductTest.php b/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/Type/ProductTest.php index b1e846dd80101..b6a2f3ac5b6fe 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/Type/ProductTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Model/TaxClass/Type/ProductTest.php @@ -31,7 +31,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase public function testGetAssignedObjects() { $collectionMock = $this->getMockBuilder( - 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection' + 'Magento\Model\Resource\Db\Collection\AbstractCollection' )->setMethods( array('addAttributeToFilter') )->disableOriginalConstructor()->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Test/Tools/Di/Code/Scanner/XmlScannerTest.php b/dev/tests/unit/testsuite/Magento/Test/Tools/Di/Code/Scanner/XmlScannerTest.php index 5ed420965b70e..bfff47d2609d0 100644 --- a/dev/tests/unit/testsuite/Magento/Test/Tools/Di/Code/Scanner/XmlScannerTest.php +++ b/dev/tests/unit/testsuite/Magento/Test/Tools/Di/Code/Scanner/XmlScannerTest.php @@ -89,7 +89,7 @@ public function testCollectEntities() 'Invalid proxy class for ' . substr('\Magento\SomeModule\Model\Nested\Element\Proxy', 0, -5) ); $actual = $this->_model->collectEntities($this->_testFiles); - $expected = array('Magento\Core\Model\App\Proxy'); + $expected = array('Magento\App\Request\Http\Proxy'); $this->assertEquals($expected, $actual); } } 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 5730fc299b510..a2992be949198 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 @@ */ --> - + diff --git a/dev/tests/unit/testsuite/Magento/Theme/Controller/Adminhtml/System/Design/ThemeTest.php b/dev/tests/unit/testsuite/Magento/Theme/Controller/Adminhtml/System/Design/ThemeTest.php index 5b52451ed933f..d8d36e878a369 100644 --- a/dev/tests/unit/testsuite/Magento/Theme/Controller/Adminhtml/System/Design/ThemeTest.php +++ b/dev/tests/unit/testsuite/Magento/Theme/Controller/Adminhtml/System/Design/ThemeTest.php @@ -47,11 +47,23 @@ class ThemeTest extends \PHPUnit_Framework_TestCase */ protected $_request; + /** + * @var \Magento\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManager; + + /** + * @var \Magento\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $view; + protected function setUp() { $this->_objectManagerMock = $this->getMock('Magento\ObjectManager', array(), array(), '', false); $this->_request = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); + $this->eventManager = $this->getMock('\Magento\Event\ManagerInterface', array(), array(), '', false); + $this->view = $this->getMock('\Magento\App\ViewInterface', array(), array(), '', false); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_model = $helper->getObject( @@ -59,7 +71,9 @@ protected function setUp() array( 'request' => $this->_request, 'objectManager' => $this->_objectManagerMock, - 'response' => $this->getMock('Magento\App\Response\Http', array(), array(), '', false) + 'response' => $this->getMock('Magento\App\Response\Http', array(), array(), '', false), + 'eventManager' => $this->eventManager, + 'view' => $this->view, ) ); } @@ -78,50 +92,50 @@ public function testSaveAction() $this->_request->expects( $this->at(0) )->method( - 'getParam' - )->with( - 'back', - false - )->will( - $this->returnValue(true) - ); + 'getParam' + )->with( + 'back', + false + )->will( + $this->returnValue(true) + ); $this->_request->expects( $this->at(1) )->method( - 'getParam' - )->with( - 'theme' - )->will( - $this->returnValue($themeData) - ); + 'getParam' + )->with( + 'theme' + )->will( + $this->returnValue($themeData) + ); $this->_request->expects( $this->at(2) )->method( - 'getParam' - )->with( - 'custom_css_content' - )->will( - $this->returnValue($customCssContent) - ); + 'getParam' + )->with( + 'custom_css_content' + )->will( + $this->returnValue($customCssContent) + ); $this->_request->expects( $this->at(3) )->method( - 'getParam' - )->with( - 'js_removed_files' - )->will( - $this->returnValue($jsRemovedFiles) - ); + 'getParam' + )->with( + 'js_removed_files' + )->will( + $this->returnValue($jsRemovedFiles) + ); $this->_request->expects( $this->at(4) )->method( - 'getParam' - )->with( - 'js_order' - )->will( - $this->returnValue($jsOrder) - ); + 'getParam' + )->with( + 'js_order' + )->will( + $this->returnValue($jsOrder) + ); $this->_request->expects($this->once(5))->method('getPost')->will($this->returnValue(true)); $themeMock = $this->getMock( @@ -147,33 +161,63 @@ public function testSaveAction() $this->_objectManagerMock->expects( $this->at(0) )->method( - 'get' - )->with( - 'Magento\View\Design\Theme\FlyweightFactory' - )->will( - $this->returnValue($themeFactory) - ); + 'get' + )->with( + 'Magento\View\Design\Theme\FlyweightFactory' + )->will( + $this->returnValue($themeFactory) + ); $this->_objectManagerMock->expects( $this->at(1) )->method( - 'get' - )->with( - 'Magento\Theme\Model\Theme\Customization\File\CustomCss' - )->will( - $this->returnValue(null) - ); + 'get' + )->with( + 'Magento\Theme\Model\Theme\Customization\File\CustomCss' + )->will( + $this->returnValue(null) + ); $this->_objectManagerMock->expects( $this->at(2) )->method( - 'create' - )->with( - 'Magento\Theme\Model\Theme\SingleFile' - )->will( - $this->returnValue(null) - ); + 'create' + )->with( + 'Magento\Theme\Model\Theme\SingleFile' + )->will( + $this->returnValue(null) + ); $this->_model->saveAction(); } + + public function testIndexAction() + { + $menuModel = $this->getMock('\Magento\Backend\Model\Menu', array(), array(), '', false); + $menuModel->expects($this->once()) + ->method('getParentItems') + ->with($this->equalTo('Magento_Theme::system_design_theme')) + ->will($this->returnValue(array())); + + $menuBlock = $this->getMock('\Magento\Backend\Block\Menu', array(), array(), '', false); + $menuBlock->expects($this->once()) + ->method('getMenuModel') + ->will($this->returnValue($menuModel)); + + $layout = $this->getMock('\Magento\View\LayoutInterface', array(), array(), '', false); + $layout->expects($this->any()) + ->method('getBlock') + ->with($this->equalTo('menu')) + ->will($this->returnValue($menuBlock)); + + $this->view->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($layout)); + + $this->eventManager->expects($this->once()) + ->method('dispatch') + ->with($this->equalTo('theme_registration_from_filesystem')) + ->will($this->returnValue(null)); + $this->_model->indexAction(); + } } diff --git a/dev/tests/unit/testsuite/Magento/Theme/Model/Uploader/ServiceTest.php b/dev/tests/unit/testsuite/Magento/Theme/Model/Uploader/ServiceTest.php index d1acfc769cb89..8188053767bbf 100644 --- a/dev/tests/unit/testsuite/Magento/Theme/Model/Uploader/ServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Theme/Model/Uploader/ServiceTest.php @@ -223,7 +223,7 @@ public function testUploadCssFile() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testUploadInvalidCssFile() { @@ -302,7 +302,7 @@ public function testUploadJsFile() } /** - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testUploadInvalidJsFile() { diff --git a/dev/tests/unit/testsuite/Magento/Theme/Model/Wysiwyg/StorageTest.php b/dev/tests/unit/testsuite/Magento/Theme/Model/Wysiwyg/StorageTest.php index 0efdc6f31e662..76f3ac2176cfe 100644 --- a/dev/tests/unit/testsuite/Magento/Theme/Model/Wysiwyg/StorageTest.php +++ b/dev/tests/unit/testsuite/Magento/Theme/Model/Wysiwyg/StorageTest.php @@ -155,7 +155,7 @@ public function testUploadFile() /** * @covers \Magento\Theme\Model\Wysiwyg\Storage::uploadFile - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testUploadInvalidFile() { @@ -253,7 +253,7 @@ public function testCreateFolder($isWritable) /** * @covers \Magento\Theme\Model\Wysiwyg\Storage::createFolder - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testCreateFolderWithInvalidName() { @@ -263,7 +263,7 @@ public function testCreateFolderWithInvalidName() /** * @covers \Magento\Theme\Model\Wysiwyg\Storage::createFolder - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testCreateFolderDirectoryAlreadyExist() { @@ -319,7 +319,7 @@ public function testGetDirsCollection() /** * @covers \Magento\Theme\Model\Wysiwyg\Storage::getDirsCollection - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testGetDirsCollectionWrongDirName() { @@ -532,7 +532,7 @@ public function testDeleteDirectory() /** * @covers \Magento\Theme\Model\Wysiwyg\Storage::deleteDirectory - * @expectedException \Magento\Core\Exception + * @expectedException \Magento\Model\Exception */ public function testDeleteRootDirectory() { diff --git a/dev/tests/unit/testsuite/Magento/Translate/Inline/ConfigFactoryTest.php b/dev/tests/unit/testsuite/Magento/Translate/Inline/ConfigFactoryTest.php deleted file mode 100644 index 60b6068ce485e..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Translate/Inline/ConfigFactoryTest.php +++ /dev/null @@ -1,44 +0,0 @@ -getMockForAbstractClass('Magento\ObjectManager'); - $objectManager->expects( - $this->once() - )->method( - 'get' - )->with( - $this->equalTo('Magento\Translate\Inline\ConfigInterface') - )->will( - $this->returnValue($result) - ); - $factory = new \Magento\Translate\Inline\ConfigFactory($objectManager); - $this->assertEquals($result, $factory->get()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Translate/Inline/ProxyTest.php b/dev/tests/unit/testsuite/Magento/Translate/Inline/ProxyTest.php new file mode 100644 index 0000000000000..05446a40ec831 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Translate/Inline/ProxyTest.php @@ -0,0 +1,153 @@ +objectManagerMock = $this->getMock( + 'Magento\ObjectManager', + array('get', 'create', 'configure'), + array(), + '', + false + ); + $this->translateMock = $this->getMock('Magento\Translate\Inline', array(), array(), '', false); + } + + public function testIsAllowed() + { + $this->objectManagerMock->expects( + $this->once() + )->method( + 'get' + )->with( + 'Magento\Translate\Inline' + )->will( + $this->returnValue($this->translateMock) + ); + $this->objectManagerMock->expects($this->never())->method('create'); + $this->translateMock->expects($this->once())->method('isAllowed')->will($this->returnValue(false)); + + $model = new Proxy( + $this->objectManagerMock, + 'Magento\Translate\Inline', + true + ); + + $this->assertFalse($model->isAllowed()); + } + + public function testGetParser() + { + $parser = new \stdClass(); + $this->objectManagerMock->expects( + $this->once() + )->method( + 'create' + )->with( + 'Magento\Translate\Inline' + )->will( + $this->returnValue($this->translateMock) + ); + $this->objectManagerMock->expects($this->never())->method('get'); + $this->translateMock->expects($this->once())->method('getParser')->will($this->returnValue($parser)); + + + $model = new Proxy( + $this->objectManagerMock, + 'Magento\Translate\Inline', + false + ); + + $this->assertEquals($parser, $model->getParser()); + } + + public function testProcessResponseBody() + { + $isJson = true; + $this->objectManagerMock->expects( + $this->once() + )->method( + 'get' + )->with( + 'Magento\Translate\Inline' + )->will( + $this->returnValue($this->translateMock) + ); + $this->objectManagerMock->expects($this->never())->method('create'); + + $this->translateMock->expects($this->once()) + ->method('processResponseBody') + ->with('', $isJson) + ->will($this->returnSelf()); + + $model = new Proxy( + $this->objectManagerMock, + 'Magento\Translate\Inline', + true + ); + $body = ''; + + $this->assertEquals($this->translateMock, $model->processResponseBody($body, $isJson)); + } + + public function testGetAdditionalHtmlAttribute() + { + $this->objectManagerMock->expects( + $this->once() + )->method( + 'create' + )->with( + 'Magento\Translate\Inline' + )->will( + $this->returnValue($this->translateMock) + ); + $this->objectManagerMock->expects($this->never())->method('get'); + $this->translateMock->expects($this->exactly(2)) + ->method('getAdditionalHtmlAttribute') + ->with($this->logicalOr('some_value', null)) + ->will($this->returnArgument(0)); + + $model = new Proxy( + $this->objectManagerMock, + 'Magento\Translate\Inline', + false + ); + + $this->assertEquals('some_value', $model->getAdditionalHtmlAttribute('some_value')); + $this->assertNull($model->getAdditionalHtmlAttribute()); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Translate/Inline/StateTest.php b/dev/tests/unit/testsuite/Magento/Translate/Inline/StateTest.php new file mode 100644 index 0000000000000..639ac538ee9f6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Translate/Inline/StateTest.php @@ -0,0 +1,74 @@ +model = new State(); + } + + public function testIsEnabled() + { + $this->assertTrue($this->model->isEnabled()); + + $this->model->disable(); + $this->assertFalse($this->model->isEnabled()); + + $this->model->enable(); + $this->assertTrue($this->model->isEnabled()); + } + + public function testSuspend() + { + $this->assertTrue($this->model->isEnabled()); + + $this->model->suspend(); + $this->assertFalse($this->model->isEnabled()); + + $this->model->suspend(true); + $this->assertFalse($this->model->isEnabled()); + } + + public function testResume() + { + $this->assertTrue($this->model->isEnabled()); + + $this->model->resume(null); + $this->assertNull($this->model->isEnabled()); + + $this->model->resume(); + $this->assertNull($this->model->isEnabled()); + + $this->model->resume(false); + $this->assertFalse($this->model->isEnabled()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Translate/InlineTest.php b/dev/tests/unit/testsuite/Magento/Translate/InlineTest.php new file mode 100644 index 0000000000000..dbc47938fa916 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Translate/InlineTest.php @@ -0,0 +1,320 @@ +scopeResolverMock = $this->getMock('Magento\BaseScopeResolverInterface', array(), array(), '', false); + $this->urlMock = $this->getMock('Magento\UrlInterface', array(), array(), '', false); + $this->layoutMock = $this->getMock('Magento\View\LayoutInterface', array(), array(), '', false); + $this->configMock = $this->getMock('Magento\Translate\Inline\ConfigInterface', array(), array(), '', false); + $this->parserMock = $this->getMock('Magento\Translate\Inline\ParserInterface', array(), array(), '', false); + $this->stateMock = $this->getMock('Magento\Translate\Inline\StateInterface', array(), array(), '', false); + } + + /** + * @param bool $isEnabled + * @param bool $isActive + * @param bool $isDevAllowed + * @param bool $result + * @dataProvider isAllowedDataProvider + */ + public function testIsAllowed($isEnabled, $isActive, $isDevAllowed, $result) + { + $this->prepareIsAllowed($isEnabled, $isActive, $isDevAllowed); + + $model = new Inline( + $this->scopeResolverMock, + $this->urlMock, + $this->layoutMock, + $this->configMock, + $this->parserMock, + $this->stateMock + ); + + $this->assertEquals($result, $model->isAllowed()); + $this->assertEquals($result, $model->isAllowed()); + } + + public function isAllowedDataProvider() + { + return array( + array(true, true, true, true), + array(true, false, true, false), + array(true, true, false, false), + array(true, false, false, false), + array(false, true, true, false), + array(false, false, true, false), + array(false, true, false, false), + array(false, false, false, false), + ); + } + + public function testGetParser() + { + $model = new Inline( + $this->scopeResolverMock, + $this->urlMock, + $this->layoutMock, + $this->configMock, + $this->parserMock, + $this->stateMock + ); + $this->assertEquals($this->parserMock, $model->getParser()); + } + + /** + * @param string|array $body + * @param string $expected + * @dataProvider processResponseBodyStripInlineDataProvider + */ + public function testProcessResponseBodyStripInline($body, $expected) + { + $scope = 'admin'; + $this->prepareIsAllowed(false, true, true, $scope); + + $model = new Inline( + $this->scopeResolverMock, + $this->urlMock, + $this->layoutMock, + $this->configMock, + $this->parserMock, + $this->stateMock, + '', + '', + $scope + ); + $model->processResponseBody($body, true); + $this->assertEquals($body, $expected); + } + + public function processResponseBodyStripInlineDataProvider() + { + return array( + array('test', 'test'), + array('{{{aaaaaa}}{{bbbbb}}{{eeeee}}{{cccccc}}}', 'aaaaaa'), + array(array('test1', 'test2'), array('test1', 'test2'),), + array(array('{{{aaaaaa}}', 'test3'), array('{{{aaaaaa}}', 'test3'),), + array(array('{{{aaaaaa}}{{bbbbb}}', 'test4'), array('{{{aaaaaa}}{{bbbbb}}', 'test4'),), + array(array('{{{aaaaaa}}{{bbbbb}}{{eeeee}}{{cccccc}}}', 'test5'), array('aaaaaa', 'test5'),), + ); + } + + /** + * @param string $scope + * @param array|string $body + * @param array|string $expected + * @dataProvider processResponseBodyDataProvider + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + public function testProcessResponseBody($scope, $body, $expected) + { + $isJson = true; + if ($scope == 'admin') { + $this->prepareIsAllowed(true, true, true, $scope); + } + $jsonCall = is_array($body) ? 2 * (count($body) + 1) : 2; + $this->parserMock->expects( + $this->exactly($jsonCall) + )->method( + 'setIsJson' + )->will( + $this->returnValueMap(array( + array($isJson, $this->returnSelf()), + array(!$isJson, $this->returnSelf()), + )) + ); + $this->parserMock->expects( + $this->exactly(1) + )->method( + 'processResponseBodyString' + )->with( + is_array($body) ? reset($body) : $body + ); + $this->parserMock->expects( + $this->exactly(2) + )->method( + 'getContent' + )->will( + $this->returnValue(is_array($body) ? reset($body) : $body) + ); + + $model = new Inline( + $this->scopeResolverMock, + $this->urlMock, + $this->layoutMock, + $this->configMock, + $this->parserMock, + $this->stateMock, + '', + '', + $scope + ); + + $model->processResponseBody($body, $isJson); + $this->assertEquals($body, $expected); + } + + public function processResponseBodyDataProvider() + { + return array( + array('admin', 'test', 'test'), + array('not_admin', 'test1', 'test1'), + ); + } + + /** + * @param $scope + * @param $body + * @param $expected + * @dataProvider processResponseBodyGetInlineScriptDataProvider + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + public function testProcessResponseBodyGetInlineScript($scope, $body, $expected) + { + $isJson = true; + if ($scope == 'admin') { + $this->prepareIsAllowed(true, true, true, $scope); + } + $jsonCall = is_array($body) ? 2 * (count($body) + 1) : 2; + $this->parserMock->expects( + $this->exactly($jsonCall) + )->method( + 'setIsJson' + )->will( + $this->returnValueMap(array( + array($isJson, $this->returnSelf()), + array(!$isJson, $this->returnSelf()), + )) + ); + $this->parserMock->expects( + $this->exactly(1) + )->method( + 'processResponseBodyString' + )->with( + is_array($body) ? reset($body) : $body + ); + $this->parserMock->expects( + $this->exactly(2) + )->method( + 'getContent' + )->will( + $this->returnValue(is_array($body) ? reset($body) : $body) + ); + + $model = new Inline( + $this->scopeResolverMock, + $this->urlMock, + $this->layoutMock, + $this->configMock, + $this->parserMock, + $this->stateMock, + '', + '', + $scope + ); + + $model->processResponseBody($body, $isJson); + $this->assertEquals($body, $expected); + } + + public function processResponseBodyGetInlineScriptDataProvider() + { + return array( + array('admin', 'test', 'test'), + array('not_admin', 'test1', 'test1'), + ); + } + + /** + * @param bool $isEnabled + * @param bool $isActive + * @param bool $isDevAllowed + * @param null|string $scope + */ + protected function prepareIsAllowed($isEnabled, $isActive, $isDevAllowed, $scope = null) + { + $scopeMock = $this->getMock('Magento\BaseScopeInterface', array(), array(), '', false); + $this->stateMock->expects($this->any())->method('isEnabled')->will($this->returnValue($isEnabled)); + $this->scopeResolverMock->expects( + $this->once() + )->method( + 'getScope' + )->with( + $scope + )->will( + $this->returnValue($scopeMock) + ); + + $this->configMock->expects( + $this->once() + )->method( + 'isActive' + )->with( + $scopeMock + )->will( + $this->returnValue($isActive) + ); + + $this->configMock->expects( + $this->exactly((int)$isActive) + )->method( + 'isDevAllowed' + )->will( + $this->returnValue($isDevAllowed) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Translation/Model/Inline/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Translation/Model/Inline/ConfigTest.php new file mode 100644 index 0000000000000..466850e73c4bc --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Translation/Model/Inline/ConfigTest.php @@ -0,0 +1,95 @@ +storeConfigMock = $this->getMock( + 'Magento\Core\Model\Store\Config', + array('getConfigFlag'), + array(), + '', + false + ); + $this->helperMock = $this->getMock('Magento\Core\Helper\Data', array('isDevAllowed'), array(), '', false); + $this->model = new Config( + $this->storeConfigMock, + $this->helperMock + ); + } + + public function testIsActive() + { + $store = 'some store'; + $result = 'result'; + + $this->storeConfigMock->expects( + $this->once() + )->method( + 'getConfigFlag' + )->with( + $this->equalTo('dev/translate_inline/active'), + $this->equalTo($store) + )->will( + $this->returnValue($result) + ); + + $this->assertEquals($result, $this->model->isActive($store)); + } + + public function testIsDevAllowed() + { + $store = 'some store'; + $result = 'result'; + + $this->helperMock->expects( + $this->once() + )->method( + 'isDevAllowed' + )->with( + $store + )->will( + $this->returnValue($result) + ); + + $this->assertEquals($result, $this->model->isDevAllowed($store)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Url/QueryParamsResolverTest.php b/dev/tests/unit/testsuite/Magento/Url/QueryParamsResolverTest.php new file mode 100644 index 0000000000000..a2e8f51db4d39 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Url/QueryParamsResolverTest.php @@ -0,0 +1,84 @@ +object = $objectManager->getObject('Magento\Url\QueryParamsResolver'); + } + + public function testGetQuery() + { + $this->object->addQueryParams(['foo' => 'bar', 'true' => 'false']); + $this->assertEquals('foo=bar&true=false', $this->object->getQuery()); + } + + public function testGetQueryEscaped() + { + $this->object->addQueryParams(['foo' => 'bar', 'true' => 'false']); + $this->assertEquals('foo=bar&true=false', $this->object->getQuery(true)); + } + + public function testSetQuery() + { + $this->object->setQuery('foo=bar&true=false'); + $this->assertEquals(['foo' => 'bar', 'true' => 'false'], $this->object->getQueryParams()); + } + + public function testSetQueryIdempotent() + { + $this->object->setQuery(null); + $this->assertEquals([], $this->object->getQueryParams()); + } + + public function testSetQueryParam() + { + $this->object->setQueryParam('foo', 'bar'); + $this->object->setQueryParam('true', 'false'); + $this->object->setQueryParam('foo', 'bar'); + $this->assertEquals(['foo' => 'bar', 'true' => 'false'], $this->object->getQueryParams()); + } + + public function testSetQueryParams() + { + $this->object->setQueryParams(['foo' => 'bar', 'true' => 'false']); + $this->assertEquals(['foo' => 'bar', 'true' => 'false'], $this->object->getQueryParams()); + } + + public function testAddQueryParamsIdempotent() + { + $this->object->setData('query_params', ['foo' => 'bar', 'true' => 'false']); + $this->object->addQueryParams(['foo' => 'bar', 'true' => 'false']); + $this->assertEquals(['foo' => 'bar', 'true' => 'false'], $this->object->getQueryParams()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Url/RouteParamsResolverFactoryTest.php b/dev/tests/unit/testsuite/Magento/Url/RouteParamsResolverFactoryTest.php new file mode 100644 index 0000000000000..a2ba6024047f2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Url/RouteParamsResolverFactoryTest.php @@ -0,0 +1,55 @@ +objectManager = $this->getMock('Magento\ObjectManager'); + + $objectManager = new ObjectManager($this); + $this->object = $objectManager->getObject( + 'Magento\Url\RouteParamsResolverFactory', + ['objectManager' => $this->objectManager] + ); + } + + public function testCreate() + { + $producedInstance = $this->getMock('Magento\Url\RouteParamsResolverInterface'); + $this->objectManager->expects($this->once())->method('create')->with('Magento\Url\RouteParamsResolverInterface') + ->will($this->returnValue($producedInstance)); + + $this->assertSame($producedInstance, $this->object->create([])); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Url/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Url/ValidatorTest.php new file mode 100644 index 0000000000000..e197b477f0a24 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Url/ValidatorTest.php @@ -0,0 +1,58 @@ + "Invalid URL '%value%'."]; + + protected function setUp() + { + $objectManager = new ObjectManager($this); + $this->object = $objectManager->getObject('Magento\Url\Validator'); + } + + public function testConstruct() + { + $this->assertEquals($this->expectedValidationMessages, $this->object->getMessageTemplates()); + } + + public function testIsValidWhenValid() + { + $this->assertEquals(true, $this->object->isValid('http://example.com')); + $this->assertEquals([], $this->object->getMessages()); + } + + public function testIsValidWhenInvalid() + { + $this->assertEquals(false, $this->object->isValid('%value%')); + $this->assertEquals($this->expectedValidationMessages, $this->object->getMessages()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/UrlTest.php b/dev/tests/unit/testsuite/Magento/UrlTest.php index ac07552b48be0..7299071825ef7 100644 --- a/dev/tests/unit/testsuite/Magento/UrlTest.php +++ b/dev/tests/unit/testsuite/Magento/UrlTest.php @@ -18,40 +18,87 @@ * 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; +/** + * Test class for Magento\Url + */ class UrlTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\UrlInterface + * @var \Magento\Core\Model\Url\RouteParamsResolver|\PHPUnit_Framework_MockObject_MockObject + */ + protected $routeParamsResolverMock; + + /** + * @var \Magento\Url\ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeResolverMock; + + /** + * @var \Magento\Url\ScopeInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeMock; + + /** + * @var \Magento\Url\QueryParamsResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $queryParamsResolverMock; + + /** + * @var \Magento\Session\SidResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $_model; + protected $sidResolverMock; /** - * @var \Magento\TestFramework\Helper\ObjectManager + * @var \Magento\Session\Generic|\PHPUnit_Framework_MockObject_MockObject */ - protected $_objectManager; + protected $sessionMock; 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) - ); + $this->routeParamsResolverMock = $this->getMock('Magento\Core\Model\Url\RouteParamsResolver', + ['getType', 'hasData', 'getData', 'getRouteParams'], [], '', false); + $this->scopeResolverMock = $this->getMock('Magento\Url\ScopeResolverInterface'); + $this->scopeMock = $this->getMock('Magento\Url\ScopeInterface'); + $this->queryParamsResolverMock = $this->getMock('Magento\Url\QueryParamsResolverInterface', [], [], '', false); + $this->sidResolverMock = $this->getMock('Magento\Session\SidResolverInterface'); + $this->sessionMock = $this->getMock('Magento\Session\Generic', [], [], '', false); + } + + /** + * @return \Magento\Url\RouteParamsResolverFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected function getRouteParamsResolver() + { + $routeParamsResolverFactoryMock = $this->getMock('Magento\Url\RouteParamsResolverFactory', [], [], '', false); + $routeParamsResolverFactoryMock->expects($this->once())->method('create') + ->will($this->returnValue($this->routeParamsResolverMock)); + return $routeParamsResolverFactoryMock; + } + + /** + * @param array $mockMethods + * @return \Magento\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected function getRequestMock($mockMethods = []) + { + $interfaceMethods = array('getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam'); + return $this->getMock('Magento\App\RequestInterface', array_merge($interfaceMethods, $mockMethods)); + } + + /** + * @param array $arguments + * @return \Magento\Url + */ + protected function getUrlModel($arguments = []) + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + return $objectManager->getObject('Magento\Url', $arguments); } /** @@ -61,32 +108,15 @@ protected function setUp() */ 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 = $this->getRequestMock(['getServer', 'getScheme', 'getHttpHost']); + $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)); + $model = $this->getUrlModel(['request' => $requestMock]); $this->assertEquals($url, $model->getCurrentUrl()); } @@ -98,4 +128,465 @@ public function getCurrentUrlProvider() 'custom_port' => array(8080, 'http://example.com:8080/fancy_uri') ); } + + public function testGetUseSession() + { + $model = $this->getUrlModel(); + + $model->setUseSession(false); + $this->assertFalse((bool)$model->getUseSession()); + + $model->setUseSession(true); + $this->assertTrue($model->getUseSession()); + } + + public function testGetBaseUrlNotLinkType() + { + $model = $this->getUrlModel( + ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver()] + ); + + $baseUrl = 'base-url'; + $urlType = 'not-link'; + $this->routeParamsResolverMock->expects($this->any())->method('getType')->will($this->returnValue($urlType)); + $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue($baseUrl)); + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + + $baseUrlParams = ['_scope' => $this->scopeMock, '_type' => $urlType, '_secure' => true]; + $this->assertEquals($baseUrl, $model->getBaseUrl($baseUrlParams)); + } + + public function testGetUrlValidateFilter() + { + $model = $this->getUrlModel(); + $this->assertEquals('http://test.com', $model->getUrl('http://test.com')); + } + + /** + * @param string|array|bool $query + * @param string $queryResult + * @param string $returnUri + * @dataProvider getUrlDataProvider + */ + public function testGetUrl($query, $queryResult, $returnUri) + { + $requestMock = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']); + $routeConfigMock = $this->getMock('Magento\App\Route\ConfigInterface'); + $model = $this->getUrlModel( + ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), + 'queryParamsResolver' => $this->queryParamsResolverMock, + 'request' => $requestMock, 'routeConfig' => $routeConfigMock] + ); + + $baseUrl = 'http://localhost/index.php/'; + $urlType = \Magento\UrlInterface::URL_TYPE_LINK; + + $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue($baseUrl)); + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->routeParamsResolverMock->expects($this->any())->method('getType')->will($this->returnValue($urlType)); + $this->routeParamsResolverMock->expects($this->any())->method('getRouteParams') + ->will($this->returnValue(['id' => 100])); + $requestMock->expects($this->once())->method('isDirectAccessFrontendName')->will($this->returnValue(true)); + $routeConfigMock->expects($this->once())->method('getRouteFrontName')->will($this->returnValue('catalog')); + $this->queryParamsResolverMock->expects($this->once())->method('getQuery') + ->will($this->returnValue($queryResult)); + + $url = $model->getUrl('catalog/product/view', [ + '_fragment' => 'anchor', + '_escape' => 1, + '_query' => $query, + '_nosid' => 0, + 'id' => 100 + ]); + $this->assertEquals($returnUri, $url); + } + + public function testGetUrlIdempotentSetRoutePath() + { + $model = $this->getUrlModel([ + 'scopeResolver' => $this->scopeResolverMock, + 'routeParamsResolver' => $this->getRouteParamsResolver(), + ]); + $model->setData('route_path', 'catalog/product/view'); + + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + + $this->assertEquals('catalog/product/view', $model->getUrl('catalog/product/view')); + } + + public function testGetUrlIdempotentSetRouteName() + { + $model = $this->getUrlModel([ + 'scopeResolver' => $this->scopeResolverMock, + 'routeParamsResolver' => $this->getRouteParamsResolver(), + 'request' => $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']), + ]); + $model->setData('route_name', 'catalog'); + + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + + $this->assertEquals('/product/view/', $model->getUrl('catalog/product/view')); + } + + public function testGetUrlRouteHasParams() + { + $this->routeParamsResolverMock->expects($this->any())->method('getRouteParams') + ->will($this->returnValue(['foo' => 'bar', 'true' => false])); + $model = $this->getUrlModel([ + 'scopeResolver' => $this->scopeResolverMock, + 'routeParamsResolver' => $this->getRouteParamsResolver(), + 'request' => $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']), + ]); + + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + + $this->assertEquals('/index/index/foo/bar/', $model->getUrl('catalog')); + } + + public function testGetUrlRouteUseRewrite() + { + $this->routeParamsResolverMock->expects($this->any())->method('getRouteParams') + ->will($this->returnValue(['foo' => 'bar'])); + $request = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']); + $request->expects($this->once())->method('getAlias')->will($this->returnValue('/catalog/product/view/')); + $model = $this->getUrlModel([ + 'scopeResolver' => $this->scopeResolverMock, + 'routeParamsResolver' => $this->getRouteParamsResolver(), + 'request' => $request, + ]); + + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + + $this->assertEquals('/catalog/product/view/', $model->getUrl('catalog', ['_use_rewrite' => 1])); + } + + public function getUrlDataProvider() + { + return [ + 'string query' => [ + 'foo=bar', 'foo=bar', 'http://localhost/index.php/catalog/product/view/id/100/?foo=bar#anchor' + ], + 'array query' => [ + ['foo' => 'bar'], 'foo=bar', 'http://localhost/index.php/catalog/product/view/id/100/?foo=bar#anchor' + ], + 'without query' => [false, '', 'http://localhost/index.php/catalog/product/view/id/100/#anchor'], + ]; + } + + public function testGetUrlWithAsterisksPath() + { + $requestMock = $this->getRequestMock([ + 'isDirectAccessFrontendName', + 'getAlias', + 'getRequestedRouteName', + 'getRequestedControllerName', + 'getRequestedActionName', + ]); + $routeConfigMock = $this->getMock('Magento\App\Route\ConfigInterface'); + $model = $this->getUrlModel( + ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), + 'queryParamsResolver' => $this->queryParamsResolverMock, + 'request' => $requestMock, 'routeConfig' => $routeConfigMock] + ); + + $baseUrl = 'http://localhost/index.php/'; + $urlType = \Magento\UrlInterface::URL_TYPE_LINK; + + $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue($baseUrl)); + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->routeParamsResolverMock->expects($this->any())->method('getType')->will($this->returnValue($urlType)); + $this->routeParamsResolverMock->expects($this->any())->method('getRouteParams') + ->will($this->returnValue(['key' => 'value'])); + $requestMock->expects($this->once())->method('isDirectAccessFrontendName')->will($this->returnValue(true)); + + $requestMock->expects($this->once())->method('getRequestedRouteName')->will($this->returnValue('catalog')); + $requestMock->expects($this->once())->method('getRequestedControllerName')->will($this->returnValue('product')); + $requestMock->expects($this->once())->method('getRequestedActionName')->will($this->returnValue('view')); + $routeConfigMock->expects($this->once())->method('getRouteFrontName')->will($this->returnValue('catalog')); + + $url = $model->getUrl('*/*/*/key/value'); + $this->assertEquals('http://localhost/index.php/catalog/product/view/key/value/', $url); + } + + public function testGetDirectUrl() + { + $requestMock = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']); + $routeConfigMock = $this->getMock('Magento\App\Route\ConfigInterface'); + $model = $this->getUrlModel( + ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), + 'queryParamsResolver' => $this->queryParamsResolverMock, + 'request' => $requestMock, 'routeConfig' => $routeConfigMock] + ); + + $baseUrl = 'http://localhost/index.php/'; + $urlType = \Magento\UrlInterface::URL_TYPE_LINK; + + $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue($baseUrl)); + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->routeParamsResolverMock->expects($this->any())->method('getType')->will($this->returnValue($urlType)); + $requestMock->expects($this->once())->method('isDirectAccessFrontendName')->will($this->returnValue(true)); + + $url = $model->getDirectUrl('direct-url'); + $this->assertEquals('http://localhost/index.php/direct-url', $url); + } + + /** + * @param string $url + * @dataProvider getRebuiltUrlDataProvider + */ + public function testGetRebuiltUrl($url) + { + $requestMock = $this->getRequestMock(['getHttpHost']); + $model = $this->getUrlModel([ + 'session' => $this->sessionMock, + 'request' => $requestMock, + 'sidResolver' => $this->sidResolverMock, + 'scopeResolver' => $this->scopeResolverMock, + 'routeParamsResolver' => $this->getRouteParamsResolver(), + 'queryParamsResolver' => $this->queryParamsResolverMock, + ]); + + $this->queryParamsResolverMock->expects($this->once())->method('getQuery') + ->will($this->returnValue('query=123')); + + $this->assertEquals($url, $model->getRebuiltUrl($url)); + } + + public function testGetRedirectUrl() + { + $model = $this->getUrlModel( + ['routeParamsResolver' => $this->getRouteParamsResolver(), 'session' => $this->sessionMock, + 'sidResolver' => $this->sidResolverMock, 'queryParamsResolver' => $this->queryParamsResolverMock] + ); + + $this->sidResolverMock->expects($this->once())->method('getUseSessionInUrl')->will($this->returnValue(true)); + $this->sessionMock->expects($this->once())->method('getSessionIdForHost')->will($this->returnValue(false)); + $this->sidResolverMock->expects($this->once())->method('getUseSessionVar')->will($this->returnValue(true)); + $this->routeParamsResolverMock->expects($this->once())->method('hasData')->with('secure_is_forced') + ->will($this->returnValue(true)); + $this->sidResolverMock->expects($this->never())->method('getSessionIdQueryParam'); + $this->queryParamsResolverMock->expects($this->once())->method('getQuery')->will($this->returnValue('foo=bar')); + + $this->assertEquals('http://example.com/?foo=bar', $model->getRedirectUrl('http://example.com/')); + } + + public function testGetRedirectUrlWithSessionId() + { + $model = $this->getUrlModel( + ['routeParamsResolver' => $this->getRouteParamsResolver(), 'session' => $this->sessionMock, + 'sidResolver' => $this->sidResolverMock, 'queryParamsResolver' => $this->queryParamsResolverMock] + ); + + $this->sidResolverMock->expects($this->once())->method('getUseSessionInUrl')->will($this->returnValue(true)); + $this->sessionMock->expects($this->once())->method('getSessionIdForHost') + ->will($this->returnValue('session-id')); + $this->sidResolverMock->expects($this->once())->method('getUseSessionVar')->will($this->returnValue(false)); + $this->sidResolverMock->expects($this->once())->method('getSessionIdQueryParam'); + $this->queryParamsResolverMock->expects($this->once())->method('getQuery')->will($this->returnValue('foo=bar')); + + $this->assertEquals('http://example.com/?foo=bar', $model->getRedirectUrl('http://example.com/')); + } + + public function getRebuiltUrlDataProvider() + { + return [ + 'with port' => ['https://example.com:88/index.php/catalog/index/view?query=123#hash'], + 'without port' => ['https://example.com/index.php/catalog/index/view?query=123#hash'], + ]; + } + + public function testGetRouteUrlWithValidUrl() + { + $model = $this->getUrlModel(['routeParamsResolver' => $this->getRouteParamsResolver()]); + + $this->routeParamsResolverMock->expects($this->never())->method('unsetData'); + $this->assertEquals('http://example.com', $model->getRouteUrl('http://example.com')); + } + + public function testAddSessionParam() + { + $model = $this->getUrlModel([ + 'session' => $this->sessionMock, + 'sidResolver' => $this->sidResolverMock, + 'queryParamsResolver' => $this->queryParamsResolverMock, + ]); + + $this->sidResolverMock->expects($this->once())->method('getSessionIdQueryParam')->with($this->sessionMock) + ->will($this->returnValue('sid')); + $this->sessionMock->expects($this->once())->method('getSessionId')->will($this->returnValue('session-id')); + $this->queryParamsResolverMock->expects($this->once())->method('setQueryParam')->with('sid', 'session-id'); + + $model->addSessionParam(); + } + + /** + * @param bool $result + * @param string $baseUrl + * @param string $referrer + * @dataProvider isOwnOriginUrlDataProvider + */ + public function testIsOwnOriginUrl($result, $baseUrl, $referrer) + { + $requestMock = $this->getRequestMock(['setServer', 'getServer']); + $model = $this->getUrlModel(['scopeResolver' => $this->scopeResolverMock, 'request' => $requestMock]); + + $this->scopeMock->expects($this->any())->method('getBaseUrl')->will($this->returnValue($baseUrl)); + $this->scopeResolverMock->expects($this->any())->method('getScopes') + ->will($this->returnValue([$this->scopeMock])); + $requestMock->expects($this->once())->method('getServer')->with('HTTP_REFERER') + ->will($this->returnValue($referrer)); + + $this->assertEquals($result, $model->isOwnOriginUrl()); + } + + public function isOwnOriginUrlDataProvider() + { + return [ + 'is origin url' => [true, 'http://localhost/', 'http://localhost/'], + 'is not origin url' => [false, 'http://localhost/', 'http://example.com/'], + ]; + } + + /** + * @param string $urlType + * @param string $configPath + * @param bool $isSecure + * @param int $isSecureCallCount + * @param string $key + * @dataProvider getConfigDataDataProvider + */ + public function testGetConfigData($urlType, $configPath, $isSecure, $isSecureCallCount, $key) + { + $urlSecurityInfoMock = $this->getMock('Magento\Url\SecurityInfoInterface'); + $model = $this->getUrlModel([ + 'urlSecurityInfo' => $urlSecurityInfoMock, + 'routeParamsResolver' => $this->getRouteParamsResolver(), + 'scopeResolver' => $this->scopeResolverMock, + ]); + + $this->routeParamsResolverMock->expects($this->at(0))->method('hasData')->with('secure_is_forced') + ->will($this->returnValue(false)); + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeMock->expects($this->once())->method('isUrlSecure')->will($this->returnValue(true)); + $this->routeParamsResolverMock->expects($this->at(1))->method('hasData')->with('secure') + ->will($this->returnValue(false)); + $this->routeParamsResolverMock->expects($this->any())->method('getType') + ->will($this->returnValue($urlType)); + $this->routeParamsResolverMock->expects($this->once())->method('getData')->will($this->returnValue($isSecure)); + $this->scopeMock->expects($this->once())->method('getConfig')->with($configPath) + ->will($this->returnValue('http://localhost/')); + $urlSecurityInfoMock->expects($this->exactly($isSecureCallCount))->method('isSecure') + ->will($this->returnValue(false)); + + $this->assertEquals('http://localhost/', $model->getConfigData($key)); + } + + public function getConfigDataDataProvider() + { + return [ + 'secure url' => ['some-type', 'web/secure/base_url_secure', true, 0, 'base_url_secure'], + 'unsecure url' => [ + \Magento\UrlInterface::URL_TYPE_LINK, 'web/unsecure/base_url_unsecure', false, 1, 'base_url_unsecure' + ], + ]; + } + + public function testGetConfigDataWithSecureIsForcedParam() + { + $model = $this->getUrlModel([ + 'routeParamsResolver' => $this->getRouteParamsResolver(), + 'scopeResolver' => $this->scopeResolverMock, + ]); + + $this->routeParamsResolverMock->expects($this->once())->method('hasData')->with('secure_is_forced') + ->will($this->returnValue(true)); + $this->routeParamsResolverMock->expects($this->once())->method('getData')->with('secure') + ->will($this->returnValue(true)); + + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeMock->expects($this->once())->method('getConfig')->with('web/secure/base_url_secure_forced') + ->will($this->returnValue('http://localhost/')); + + $this->assertEquals('http://localhost/', $model->getConfigData('base_url_secure_forced')); + } + + /** + * @param string $html + * @param string $result + * @dataProvider sessionUrlVarWithMatchedHostsAndBaseUrlDataProvider + */ + public function testSessionUrlVarWithMatchedHostsAndBaseUrl($html, $result) + { + $requestMock = $this->getRequestMock(['getHttpHost']); + $model = $this->getUrlModel( + ['session' => $this->sessionMock, 'request' => $requestMock, 'sidResolver' => $this->sidResolverMock, + 'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver()] + ); + + $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('localhost')); + $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://localhost')); + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->sidResolverMock->expects($this->never())->method('getSessionIdQueryParam'); + + $this->assertEquals($result, $model->sessionUrlVar($html)); + } + + public function testSessionUrlVarWithoutMatchedHostsAndBaseUrl() + { + $requestMock = $this->getRequestMock(['getHttpHost']); + $model = $this->getUrlModel( + ['session' => $this->sessionMock, 'request' => $requestMock, 'sidResolver' => $this->sidResolverMock, + 'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver()] + ); + + $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('localhost')); + $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://example.com')); + $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->sidResolverMock->expects($this->once())->method('getSessionIdQueryParam') + ->will($this->returnValue('SID')); + $this->sessionMock->expects($this->once())->method('getSessionId') + ->will($this->returnValue('session-id')); + + $this->assertEquals( + 'www.example.com', + $model->sessionUrlVar('www.example.com') + ); + } + + public function sessionUrlVarWithMatchedHostsAndBaseUrlDataProvider() + { + return [ + [ + 'www.example.com', + 'www.example.com', + ], + [ + 'www.example.com', + 'www.example.com', + ], + [ + 'www.example.com', + 'www.example.com', + ], + [ + 'www.example.com', + 'www.example.com', + ], + ]; + } + + public function testSetRequest() + { + $requestMethods = ['getServer', 'getScheme', 'getHttpHost']; + $initRequestMock = $this->getRequestMock($requestMethods); + $requestMock = $this->getRequestMock($requestMethods); + $initRequestMock->expects($this->any())->method('getScheme')->will($this->returnValue('fake')); + $initRequestMock->expects($this->any())->method('getHttpHost')->will($this->returnValue('fake-host')); + $requestMock->expects($this->any())->method('getScheme')->will($this->returnValue('http')); + $requestMock->expects($this->any())->method('getHttpHost')->will($this->returnValue('example.com')); + + $model = $this->getUrlModel(['request' => $initRequestMock]); + $model->setRequest($requestMock); + $this->assertEquals('http://example.com', $model->getCurrentUrl()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/ErrorProcessorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/ErrorProcessorTest.php index d4c8add660445..caa8a15dd3b46 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/ErrorProcessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/ErrorProcessorTest.php @@ -33,8 +33,8 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Core\Helper\Data */ protected $_helperMock; - /** @var \Magento\Core\Model\App */ - protected $_appMock; + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $_appStateMock; /** @var \Magento\Logger */ protected $_loggerMock; @@ -46,7 +46,9 @@ protected function setUp() 'Magento\Core\Helper\Data' )->disableOriginalConstructor()->getMock(); - $this->_appMock = $this->getMockBuilder('Magento\Core\Model\App')->disableOriginalConstructor()->getMock(); + $this->_appStateMock = $this->getMockBuilder('Magento\App\State') + ->disableOriginalConstructor() + ->getMock(); $this->_loggerMock = $this->getMockBuilder('Magento\Logger')->disableOriginalConstructor()->getMock(); @@ -55,7 +57,7 @@ protected function setUp() /** Initialize SUT. */ $this->_errorProcessor = new \Magento\Webapi\Controller\ErrorProcessor( $this->_helperMock, - $this->_appMock, + $this->_appStateMock, $this->_loggerMock, $filesystemMock ); @@ -67,7 +69,7 @@ protected function tearDown() { unset($this->_errorProcessor); unset($this->_helperMock); - unset($this->_appMock); + unset($this->_appStateMock); parent::tearDown(); } @@ -115,7 +117,7 @@ public function testRenderJsonInDeveloperMode() { $_SERVER['HTTP_ACCEPT'] = 'json'; /** Mock app to return enabled developer mode flag. */ - $this->_appMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(true)); + $this->_appStateMock->expects($this->any())->method('getMode')->will($this->returnValue('developer')); /** Assert that jsonEncode method will be executed once. */ $this->_helperMock->expects( $this->once() @@ -156,7 +158,7 @@ public function testRenderXmlInDeveloperMode() { $_SERVER['HTTP_ACCEPT'] = 'xml'; /** Mock app to return enabled developer mode flag. */ - $this->_appMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(true)); + $this->_appStateMock->expects($this->any())->method('getMode')->will($this->returnValue('developer')); /** Init output buffering to catch output via echo function. */ ob_start(); $this->_errorProcessor->render('Message', 'Trace message.', 401); @@ -187,7 +189,7 @@ public function testRenderDefaultFormat() public function testMaskExceptionInDeveloperMode() { /** Mock app isDeveloperMode to return true. */ - $this->_appMock->expects($this->once())->method('isDeveloperMode')->will($this->returnValue(true)); + $this->_appStateMock->expects($this->once())->method('getMode')->will($this->returnValue('developer')); /** Init Logical exception. */ $errorMessage = 'Error Message'; $logicalException = new \LogicException($errorMessage); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/Request/Deserializer/JsonTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/Request/Deserializer/JsonTest.php index 2b107f68bcfaa..66a5c02f57c06 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/Request/Deserializer/JsonTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/Request/Deserializer/JsonTest.php @@ -37,23 +37,17 @@ class JsonTest extends \PHPUnit_Framework_TestCase protected $_helperMock; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_appMock; + protected $_appStateMock; protected function setUp() { /** Prepare mocks for SUT constructor. */ - $this->_helperMock = $this->getMockBuilder( - 'Magento\Core\Helper\Data' - )->disableOriginalConstructor()->getMock(); - $this->_appMock = $this->getMockBuilder( - 'Magento\Core\Model\App' - )->setMethods( - array('isDeveloperMode') - )->disableOriginalConstructor()->getMock(); + $this->_helperMock = $this->getMockBuilder('Magento\Core\Helper\Data')->disableOriginalConstructor()->getMock(); + $this->_appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false); /** Initialize SUT. */ $this->_jsonDeserializer = new \Magento\Webapi\Controller\Rest\Request\Deserializer\Json( $this->_helperMock, - $this->_appMock + $this->_appStateMock ); parent::setUp(); } @@ -62,7 +56,7 @@ protected function tearDown() { unset($this->_jsonDeserializer); unset($this->_helperMock); - unset($this->_appMock); + unset($this->_appStateMock); parent::tearDown(); } @@ -99,14 +93,12 @@ public function testDeserialize() public function testDeserializeInvalidEncodedBodyExceptionDeveloperModeOff() { /** Prepare mocks for SUT constructor. */ - $this->_helperMock->expects( - $this->once() - )->method( - 'jsonDecode' - )->will( - $this->throwException(new \Zend_Json_Exception()) - ); - $this->_appMock->expects($this->once())->method('isDeveloperMode')->will($this->returnValue(false)); + $this->_helperMock->expects($this->once()) + ->method('jsonDecode') + ->will($this->throwException(new \Zend_Json_Exception)); + $this->_appStateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue('production')); /** Initialize SUT. */ $inputInvalidJson = '{"key1":"test1"."key2":"test2"}'; try { @@ -135,7 +127,9 @@ public function testDeserializeInvalidEncodedBodyExceptionDeveloperModeOn() new \Zend_Json_Exception('Decoding error:' . PHP_EOL . 'Decoding failed: Syntax error') ) ); - $this->_appMock->expects($this->once())->method('isDeveloperMode')->will($this->returnValue(true)); + $this->_appStateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue('developer')); /** Initialize SUT. */ $inputInvalidJson = '{"key1":"test1"."key2":"test2"}'; try { diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/Request/Deserializer/XmlTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/Request/Deserializer/XmlTest.php index d11c8cc738e16..27303edf1a7b1 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/Request/Deserializer/XmlTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/Request/Deserializer/XmlTest.php @@ -32,21 +32,17 @@ class XmlTest extends \PHPUnit_Framework_TestCase protected $_xmlDeserializer; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_appMock; + protected $_appStateMock; protected function setUp() { /** Prepare mocks for SUT constructor. */ $this->_xmlParserMock = $this->getMock('Magento\Xml\Parser', array('xmlToArray', 'loadXML')); - $this->_appMock = $this->getMockBuilder( - 'Magento\Core\Model\App' - )->setMethods( - array('isDeveloperMode') - )->disableOriginalConstructor()->getMock(); + $this->_appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false); /** Initialize SUT. */ $this->_xmlDeserializer = new \Magento\Webapi\Controller\Rest\Request\Deserializer\Xml( $this->_xmlParserMock, - $this->_appMock + $this->_appStateMock ); parent::setUp(); } @@ -55,7 +51,7 @@ protected function tearDown() { unset($this->_xmlDeserializer); unset($this->_xmlParserMock); - unset($this->_appMock); + unset($this->_appStateMock); parent::tearDown(); } @@ -109,7 +105,9 @@ public function testHandleErrors() public function testDeserializeMagentoWebapiExceptionDeveloperModeOn() { /** Prepare mocks for SUT constructor. */ - $this->_appMock->expects($this->once())->method('isDeveloperMode')->will($this->returnValue(true)); + $this->_appStateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue('developer')); $errorMessage = 'End tag for "key1" was omitted.'; $this->_xmlDeserializer->handleErrors(null, $errorMessage, null, null); $this->_xmlParserMock->expects($this->once())->method('loadXML'); @@ -133,7 +131,9 @@ public function testDeserializeMagentoWebapiExceptionDeveloperModeOn() public function testDeserializeMagentoWebapiExceptionDeveloperModeOff() { /** Prepare mocks for SUT constructor. */ - $this->_appMock->expects($this->once())->method('isDeveloperMode')->will($this->returnValue(false)); + $this->_appStateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue('production')); $errorMessage = 'End tag for "key1" was omitted.'; $this->_xmlDeserializer->handleErrors(null, $errorMessage, null, null); $this->_xmlParserMock->expects($this->once())->method('loadXML'); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/ResponseTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/ResponseTest.php index f68b278b49922..9794ae8436dc6 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/ResponseTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/ResponseTest.php @@ -30,8 +30,8 @@ class ResponseTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Webapi\Controller\Rest\Response */ protected $_responseRest; - /** @var \Magento\Core\Model\App */ - protected $_appMock; + /** @var \Magento\App\State */ + protected $_appStateMock; /** @var \Magento\Webapi\Controller\Rest\Response\Renderer\Xml */ protected $_rendererMock; @@ -49,16 +49,15 @@ protected function setUp() 'Magento\Webapi\Controller\Rest\Response\Renderer\Factory' )->disableOriginalConstructor()->getMock(); $rendererFactoryMock->expects($this->any())->method('get')->will($this->returnValue($this->_rendererMock)); - $this->_errorProcessorMock = $this->getMockBuilder( - 'Magento\Webapi\Controller\ErrorProcessor' - )->disableOriginalConstructor()->getMock(); - $this->_appMock = $this->getMockBuilder('Magento\Core\Model\App')->disableOriginalConstructor()->getMock(); + $this->_errorProcessorMock = $this->getMockBuilder('Magento\Webapi\Controller\ErrorProcessor') + ->disableOriginalConstructor()->getMock(); + $this->_appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false); /** Init SUP. */ $this->_responseRest = new \Magento\Webapi\Controller\Rest\Response( $rendererFactoryMock, $this->_errorProcessorMock, - $this->_appMock + $this->_appStateMock ); $this->_responseRest->headersSentThrowsException = false; parent::setUp(); @@ -67,7 +66,7 @@ protected function setUp() protected function tearDown() { unset($this->_responseRest); - unset($this->_appMock); + unset($this->_appStateMock); unset($this->_rendererMock); unset($this->_errorProcessorMock); parent::tearDown(); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php index 46d2a35bfa22a..041cf7add6b5e 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php @@ -54,6 +54,16 @@ class RestTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Authz\Service\AuthorizationV1Interface */ protected $_authzServiceMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $areaListMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $areaMock; + const SERVICE_METHOD = 'testMethod'; const SERVICE_ID = 'Magento\Webapi\Controller\TestService'; @@ -100,16 +110,16 @@ protected function setUp() 'Magento\Authz\Service\AuthorizationV1Interface' )->disableOriginalConstructor()->getMock(); - /** @var $applicationMock \Magento\AppInterface */ - $applicationMock = $this->getMockBuilder('Magento\AppInterface')->disableOriginalConstructor()->getMock(); $layoutMock = $this->getMockBuilder('Magento\View\LayoutInterface')->disableOriginalConstructor()->getMock(); - $applicationMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock)); $errorProcessorMock = $this->getMock('Magento\Webapi\Controller\ErrorProcessor', array(), array(), '', 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'); + $this->areaListMock = $this->getMock('\Magento\App\AreaList', array(), array(), '', false); + $this->areaMock = $this->getMock('Magento\App\AreaInterface'); + $this->areaListMock->expects($this->any())->method('getArea')->will($this->returnValue($this->areaMock)); /** Init SUT. */ $this->_restController = $objectManager->getObject( @@ -120,10 +130,11 @@ protected function setUp() 'router' => $this->_routerMock, 'objectManager' => $this->_objectManagerMock, 'appState' => $this->_appStateMock, - 'application' => $applicationMock, + 'layout' => $layoutMock, 'authorizationService' => $this->_authzServiceMock, 'serializer' => $serializer, - 'errorProcessor' => $errorProcessorMock + 'errorProcessor' => $errorProcessorMock, + 'areaList' => $this->areaListMock ) ); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php index afb0a746e20f2..ee910bac71aa9 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php @@ -48,9 +48,6 @@ class SoapTest extends \PHPUnit_Framework_TestCase /** @var \Magento\App\State */ protected $_appStateMock; - /** @var \Magento\Core\Model\App */ - protected $_applicationMock; - /** @var \Magento\Oauth\Oauth */ protected $_oauthServiceMock; @@ -66,37 +63,31 @@ protected function setUp() { parent::setUp(); - $this->_soapServerMock = $this->getMockBuilder( - 'Magento\Webapi\Model\Soap\Server' - )->disableOriginalConstructor()->setMethods( - array('getApiCharset', 'generateUri', 'handle') - )->getMock(); - $this->_wsdlGeneratorMock = $this->getMockBuilder( - 'Magento\Webapi\Model\Soap\Wsdl\Generator' - )->disableOriginalConstructor()->setMethods( - array('generate') - )->getMock(); - $this->_requestMock = $this->getMockBuilder( - 'Magento\Webapi\Controller\Soap\Request' - )->disableOriginalConstructor()->setMethods( - array('getParam', 'getRequestedServices') - )->getMock(); - $this->_responseMock = $this->getMockBuilder( - 'Magento\Webapi\Controller\Response' - )->disableOriginalConstructor()->setMethods( - array('clearHeaders', 'setHeader', 'sendResponse') - )->getMock(); - $this->_errorProcessorMock = $this->getMockBuilder( - 'Magento\Webapi\Controller\ErrorProcessor' - )->disableOriginalConstructor()->setMethods( - array('maskException') - )->getMock(); - $this->_appStateMock = $this->getMockBuilder('Magento\App\State')->disableOriginalConstructor()->getMock(); - $localeMock = $this->getMockBuilder( - 'Magento\Locale' - )->disableOriginalConstructor()->setMethods( - array('getLanguage') - )->getMock(); + $this->_soapServerMock = $this->getMockBuilder('Magento\Webapi\Model\Soap\Server') + ->disableOriginalConstructor() + ->setMethods(array('getApiCharset', 'generateUri', 'handle')) + ->getMock(); + $this->_wsdlGeneratorMock = $this->getMockBuilder('Magento\Webapi\Model\Soap\Wsdl\Generator') + ->disableOriginalConstructor() + ->setMethods(array('generate')) + ->getMock(); + $this->_requestMock = $this->getMockBuilder('Magento\Webapi\Controller\Soap\Request') + ->disableOriginalConstructor() + ->setMethods(array('getParam', 'getRequestedServices')) + ->getMock(); + $this->_responseMock = $this->getMockBuilder('Magento\Webapi\Controller\Response') + ->disableOriginalConstructor() + ->setMethods(array('clearHeaders', 'setHeader', 'sendResponse')) + ->getMock(); + $this->_errorProcessorMock = $this->getMockBuilder('Magento\Webapi\Controller\ErrorProcessor') + ->disableOriginalConstructor() + ->setMethods(array('maskException')) + ->getMock(); + $this->_appStateMock = $this->getMock('\Magento\App\State', array(), array(), '', false); + $localeMock = $this->getMockBuilder('Magento\Locale') + ->disableOriginalConstructor() + ->setMethods(array('getLanguage')) + ->getMock(); $localeMock->expects($this->any())->method('getLanguage')->will($this->returnValue('en')); $localeResolverMock = $this->getMockBuilder( @@ -106,28 +97,19 @@ protected function setUp() )->getMock(); $localeResolverMock->expects($this->any())->method('getLocale')->will($this->returnValue($localeMock)); - $this->_applicationMock = $this->getMockBuilder( - 'Magento\Core\Model\App' - )->disableOriginalConstructor()->setMethods( - array('getLocale', 'isDeveloperMode') - )->getMock(); + $layoutMock = $this->getMock('Magento\View\LayoutInterface'); - $this->_applicationMock = $this->getMockBuilder( - 'Magento\Core\Model\App' - )->disableOriginalConstructor()->getMock(); - $this->_applicationMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(false)); - $layoutMock = $this->getMockBuilder('Magento\View\LayoutInterface')->disableOriginalConstructor()->getMock(); - $this->_applicationMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock)); - - $this->_oauthServiceMock = $this->getMockBuilder( - 'Magento\Oauth\Oauth' - )->disableOriginalConstructor()->getMock(); + $this->_oauthServiceMock = $this->getMockBuilder('Magento\Oauth\Oauth') + ->disableOriginalConstructor() + ->getMock(); $this->_responseMock->expects($this->any())->method('clearHeaders')->will($this->returnSelf()); $this->_soapServerMock->expects($this->any())->method('setWSDL')->will($this->returnSelf()); $this->_soapServerMock->expects($this->any())->method('setEncoding')->will($this->returnSelf()); $this->_soapServerMock->expects($this->any())->method('setReturnResponse')->will($this->returnSelf()); - + $areaListMock = $this->getMock('Magento\App\AreaList', array(), array(), '', false); + $areaMock = $this->getMock('Magento\App\AreaInterface'); + $areaListMock->expects($this->any())->method('getArea')->will($this->returnValue($areaMock)); $this->_soapController = new \Magento\Webapi\Controller\Soap( $this->_requestMock, $this->_responseMock, @@ -135,9 +117,10 @@ protected function setUp() $this->_soapServerMock, $this->_errorProcessorMock, $this->_appStateMock, - $this->_applicationMock, + $layoutMock, $this->_oauthServiceMock, - $localeResolverMock + $localeResolverMock, + $areaListMock ); } 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 e176e157e15e7..2a55c3f49b8cf 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php @@ -30,8 +30,10 @@ class FaultTest extends \PHPUnit_Framework_TestCase { const WSDL_URL = 'http://host.com/?wsdl&services=customerV1'; - /** @var \Magento\Core\Model\App */ - protected $_appMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_requestMock; /** @var \Magento\Webapi\Model\Soap\Server */ protected $_soapServerMock; @@ -42,9 +44,14 @@ class FaultTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject*/ protected $_localeResolverMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_appStateMock; + protected function setUp() { - $this->_appMock = $this->getMockBuilder('Magento\Core\Model\App')->disableOriginalConstructor()->getMock(); + $this->_requestMock = $this->getMock('\Magento\App\RequestInterface'); /** Initialize SUT. */ $message = "Soap fault reason."; $details = array('param1' => 'value1', 'param2' => 2); @@ -71,11 +78,14 @@ protected function setUp() $this->returnValue(new \Zend_Locale('en_US')) ); + $this->_appStateMock = $this->getMock('\Magento\App\State', array(), array(), '', false); + $this->_soapFault = new \Magento\Webapi\Model\Soap\Fault( - $this->_appMock, + $this->_requestMock, $this->_soapServerMock, $webapiException, - $this->_localeResolverMock + $this->_localeResolverMock, + $this->_appStateMock ); parent::setUp(); } @@ -83,13 +93,13 @@ protected function setUp() protected function tearDown() { unset($this->_soapFault); - unset($this->_appMock); + unset($this->_requestMock); parent::tearDown(); } public function testToXmlDeveloperModeOff() { - $this->_appMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(false)); + $this->_appStateMock->expects($this->any())->method('getMode')->will($this->returnValue('production')); $wsdlUrl = urlencode(self::WSDL_URL); $expectedResult = << @@ -132,7 +142,7 @@ public function testToXmlDeveloperModeOff() public function testToXmlDeveloperModeOn() { - $this->_appMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(true)); + $this->_appStateMock->expects($this->any())->method('getMode')->will($this->returnValue('developer')); $actualXml = $this->_soapFault->toXml(true); $this->assertContains('', $actualXml, 'Exception trace is not found in XML.'); } @@ -225,10 +235,11 @@ public function testConstructor() $details ); $soapFault = new \Magento\Webapi\Model\Soap\Fault( - $this->_appMock, + $this->_requestMock, $this->_soapServerMock, $webapiException, - $this->_localeResolverMock + $this->_localeResolverMock, + $this->_appStateMock ); $actualXml = $soapFault->toXml(); $wsdlUrl = urlencode(self::WSDL_URL); 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 4a75903649553..d1c4c1dcfe3b0 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php @@ -30,9 +30,6 @@ class ServerTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Webapi\Model\Soap\Server */ protected $_soapServer; - /** @var \Magento\Core\Model\App */ - protected $_appMock; - /** @var \Magento\Core\Model\Store */ protected $_storeMock; diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Block/Customer/SidebarTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Block/Customer/SidebarTest.php index db97c1b17721f..d86b1a604c7b7 100644 --- a/dev/tests/unit/testsuite/Magento/Wishlist/Block/Customer/SidebarTest.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Block/Customer/SidebarTest.php @@ -30,10 +30,19 @@ class SidebarTest extends \PHPUnit_Framework_TestCase */ protected $block; + /** + * @var \Magento\Wishlist\Helper\Data | \PHPUnit_Framework_MockObject_MockObject + */ + protected $wishlistHelper; + protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->block = $objectManager->getObject('Magento\Wishlist\Block\Customer\Sidebar'); + $this->wishlistHelper = $this->getMock('Magento\Wishlist\Helper\Data', ['getItemCount'], [], '', false); + $this->block = $objectManager->getObject( + 'Magento\Wishlist\Block\Customer\Sidebar', + ['wishlistHelper' => $this->wishlistHelper] + ); } protected function tearDown() @@ -41,17 +50,19 @@ protected function tearDown() $this->block = null; } - public function testGetIdentities() + public function testGetIdentitiesItemsPresent() { - $productTags = array('catalog_product_1'); + $productTags = ['catalog_product_1']; + + $this->wishlistHelper->expects($this->once())->method('getItemCount')->will($this->returnValue(5)); - $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); $product->expects($this->once())->method('getIdentities')->will($this->returnValue($productTags)); $item = $this->getMock( 'Magento\Sales\Model\Resource\Order\Item', - array('getProduct', '__wakeup'), - array(), + ['getProduct', '__wakeup'], + [], '', false ); @@ -59,7 +70,16 @@ public function testGetIdentities() $collection = new \ReflectionProperty('Magento\Wishlist\Block\Customer\Sidebar', '_collection'); $collection->setAccessible(true); - $collection->setValue($this->block, array($item)); + $collection->setValue($this->block, [$item]); + + $this->assertEquals($productTags, $this->block->getIdentities()); + } + + public function testGetIdentitiesNoItems() + { + $productTags = []; + + $this->wishlistHelper->expects($this->once())->method('getItemCount')->will($this->returnValue(0)); $this->assertEquals($productTags, $this->block->getIdentities()); } diff --git a/downloader/app/Magento/Downloader/Controller.php b/downloader/app/Magento/Downloader/Controller.php index aeebd46d7c896..915385ad150e4 100644 --- a/downloader/app/Magento/Downloader/Controller.php +++ b/downloader/app/Magento/Downloader/Controller.php @@ -536,7 +536,6 @@ public static function singleton() \Magento\App\ObjectManager::getInstance()->get('Magento\App\State')->setIsDownloader(); } - \Magento\App\ObjectManager::getInstance()->get('Magento\Core\Model\App'); if (self::isInstalled()) { \Mage::getSingleton('Magento\Backend\Model\UrlInterface')->turnOffSecretKey(); } diff --git a/app/code/Magento/Reports/Model/Resource/HelperFactory.php b/lib/Magento/App/AreaInterface.php similarity index 77% rename from app/code/Magento/Reports/Model/Resource/HelperFactory.php rename to lib/Magento/App/AreaInterface.php index 014f633731813..c766ec39fc7db 100644 --- a/app/code/Magento/Reports/Model/Resource/HelperFactory.php +++ b/lib/Magento/App/AreaInterface.php @@ -1,6 +1,5 @@ objectManager = $objectManager; $this->_resolverFactory = $resolverFactory; $this->_areas = $areas; $this->_defaultAreaCode = $default; @@ -108,4 +124,21 @@ public function getDefaultRouter($areaCode) { return isset($this->_areas[$areaCode]['router']) ? $this->_areas[$areaCode]['router'] : null; } + + /** + * Retrieve application area + * + * @param string $code + * @return \Magento\Core\Model\App\Area + */ + public function getArea($code) + { + if (!isset($this->_areaInstances[$code])) { + $this->_areaInstances[$code] = $this->objectManager->create( + 'Magento\App\AreaInterface', + array('areaCode' => $code) + ); + } + return $this->_areaInstances[$code]; + } } diff --git a/lib/Magento/App/Cache/Frontend/Factory.php b/lib/Magento/App/Cache/Frontend/Factory.php index 34c7c319b682c..5b8e138fa9ffa 100644 --- a/lib/Magento/App/Cache/Frontend/Factory.php +++ b/lib/Magento/App/Cache/Frontend/Factory.php @@ -33,6 +33,10 @@ class Factory * Default cache entry lifetime */ const DEFAULT_LIFETIME = 7200; + /** + * Caching params, that applied for all cache frontends regardless of type + */ + const PARAM_CACHE_FORCED_OPTIONS = 'cache_options'; /** * @var \Magento\ObjectManager diff --git a/lib/Magento/App/Cache/State.php b/lib/Magento/App/Cache/State.php index e00edbdf6df35..795a53c001eaa 100644 --- a/lib/Magento/App/Cache/State.php +++ b/lib/Magento/App/Cache/State.php @@ -30,7 +30,12 @@ class State implements StateInterface /** * Cache identifier used to store cache type statuses */ - const CACHE_ID = 'core_cache_options'; + const CACHE_ID = 'core_cache_options'; + + /** + * Disallow cache + */ + const PARAM_BAN_CACHE = 'global_ban_use_cache'; /** * Persistent storage of cache type statuses diff --git a/lib/Magento/App/Cron.php b/lib/Magento/App/Cron.php index 7b9281bbea93d..9883a71e17fbf 100644 --- a/lib/Magento/App/Cron.php +++ b/lib/Magento/App/Cron.php @@ -28,7 +28,7 @@ use Magento\App\ObjectManager\ConfigLoader; use Magento\Event\ManagerInterface; -class Cron implements \Magento\LauncherInterface +class Cron implements \Magento\AppInterface { /** * @var \Magento\Event\ManagerInterface diff --git a/lib/Magento/App/Helper/AbstractHelper.php b/lib/Magento/App/Helper/AbstractHelper.php index 90fb579bad2fb..1404b471136e5 100644 --- a/lib/Magento/App/Helper/AbstractHelper.php +++ b/lib/Magento/App/Helper/AbstractHelper.php @@ -45,11 +45,9 @@ abstract class AbstractHelper protected $_request; /** - * Translator model - * - * @var \Magento\TranslateInterface + * @var \Magento\Translate\InlineInterface */ - protected $_inlineFactory; + protected $translateInline; /** * @var \Magento\Module\Manager @@ -88,7 +86,7 @@ abstract class AbstractHelper */ public function __construct(Context $context) { - $this->_inlineFactory = $context->getInlineFactory(); + $this->translateInline = $context->getTranslateInline(); $this->_moduleManager = $context->getModuleManager(); $this->_logger = $context->getLogger(); $this->_request = $context->getRequest(); diff --git a/lib/Magento/App/Helper/Context.php b/lib/Magento/App/Helper/Context.php index 3e73af0dd14c8..4e3a97e2dbad9 100644 --- a/lib/Magento/App/Helper/Context.php +++ b/lib/Magento/App/Helper/Context.php @@ -28,9 +28,9 @@ class Context implements \Magento\ObjectManager\ContextInterface { /** - * @var \Magento\TranslateInterface + * @var \Magento\Translate\InlineInterface */ - protected $_inlineFactory; + protected $translateInline; /** * @var \Magento\Module\Manager @@ -74,7 +74,7 @@ class Context implements \Magento\ObjectManager\ContextInterface /** * @param \Magento\Logger $logger - * @param \Magento\Translate\InlineFactory $inlineFactory + * @param \Magento\Translate\InlineInterface $translateInline * @param \Magento\Module\Manager $moduleManager * @param \Magento\App\RequestInterface $httpRequest * @param \Magento\Cache\ConfigInterface $cacheConfig @@ -87,7 +87,7 @@ class Context implements \Magento\ObjectManager\ContextInterface */ public function __construct( \Magento\Logger $logger, - \Magento\Translate\InlineFactory $inlineFactory, + \Magento\Translate\InlineInterface $translateInline, \Magento\Module\Manager $moduleManager, \Magento\App\RequestInterface $httpRequest, \Magento\Cache\ConfigInterface $cacheConfig, @@ -96,7 +96,7 @@ public function __construct( \Magento\HTTP\Header $httpHeader, \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress ) { - $this->_inlineFactory = $inlineFactory; + $this->translateInline = $translateInline; $this->_moduleManager = $moduleManager; $this->_httpRequest = $httpRequest; $this->_cacheConfig = $cacheConfig; @@ -108,11 +108,11 @@ public function __construct( } /** - * @return \Magento\Translate\InlineFactory + * @return \Magento\Translate\InlineInterface */ - public function getInlineFactory() + public function getTranslateInline() { - return $this->_inlineFactory; + return $this->translateInline; } /** diff --git a/lib/Magento/App/Http.php b/lib/Magento/App/Http.php index 9ae9e08fccc5d..40e9c971504c7 100644 --- a/lib/Magento/App/Http.php +++ b/lib/Magento/App/Http.php @@ -33,7 +33,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Http implements \Magento\LauncherInterface +class Http implements \Magento\AppInterface { /** * @var \Magento\ObjectManager diff --git a/lib/Magento/AppInterface.php b/lib/Magento/AppInterface.php index ea9c71c57fa9a..8bf3f0de29370 100644 --- a/lib/Magento/AppInterface.php +++ b/lib/Magento/AppInterface.php @@ -33,163 +33,14 @@ interface AppInterface const DISTRO_LOCALE_CODE = 'en_US'; /** - * Throw an exception, if the application has not been installed yet - * - * @return void - * @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 + * Magento version */ - public function getArea($code); + const VERSION = '2.0.0.0-dev71'; /** - * Get distributive locale code - * - * @return string - */ - public function getDistroLocaleCode(); - - /** - * 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(); - - /** - * 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 + * Launch application * * @return \Magento\App\ResponseInterface */ - 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(); + public function launch(); } diff --git a/lib/Magento/Convert/Container/AbstractContainer.php b/lib/Magento/Convert/Container/AbstractContainer.php deleted file mode 100644 index 6e32462a68187..0000000000000 --- a/lib/Magento/Convert/Container/AbstractContainer.php +++ /dev/null @@ -1,190 +0,0 @@ - - */ -abstract class AbstractContainer -{ - /** - * @var array - */ - protected $_vars; - - /** - * @var array - */ - protected $_data; - - /** - * @var int - */ - protected $_position; - - /** - * @param string $key - * @param string|null $default - * @return string - */ - public function getVar($key, $default = null) - { - if (!isset($this->_vars[$key])) { - return $default; - } - 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)) { - $this->_vars = $key; - } else { - $this->_vars[$key] = $value; - } - 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.", ConvertException::FATAL); - } - return true; - } - - /** - * @param array|null $data - * @return true - */ - public function validateDataGrid($data = null) - { - if (is_null($data)) { - $data = $this->getData(); - } - if (!is_array($data) || !is_array(current($data))) { - if (count($data) == 0) { - return true; - } - $this->addException("Invalid data type, expecting 2D grid array.", ConvertException::FATAL); - } - return true; - } - - /** - * @param array $grid - * @return array - */ - public function getGridFields($grid) - { - $fields = array(); - foreach ($grid as $row) { - foreach (array_keys($row) as $fieldName) { - if (!in_array($fieldName, $fields)) { - $fields[] = $fieldName; - } - } - } - return $fields; - } - - /** - * @param string $error - * @param string|null $level - * @return ConvertException - */ - public function addException($error, $level = null) - { - $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; - return $this; - } -} diff --git a/lib/Magento/Convert/ConvertException.php b/lib/Magento/Convert/ConvertException.php deleted file mode 100644 index 4c6a93b3a8caf..0000000000000 --- a/lib/Magento/Convert/ConvertException.php +++ /dev/null @@ -1,112 +0,0 @@ -_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; - return $this; - } -} diff --git a/lib/Magento/Convert/Mapper/Column.php b/lib/Magento/Convert/Mapper/Column.php deleted file mode 100644 index f95122a1362c8..0000000000000 --- a/lib/Magento/Convert/Mapper/Column.php +++ /dev/null @@ -1,67 +0,0 @@ - - */ -namespace Magento\Convert\Mapper; - -use Magento\Convert\Container\AbstractContainer; - -class Column extends AbstractContainer implements MapperInterface -{ - /** - * @return $this - */ - public function map() - { - $data = $this->getData(); - $this->validateDataGrid($data); - if ($this->getVars() && is_array($this->getVars())) { - $attributesToSelect = $this->getVars(); - } else { - $attributesToSelect = array(); - } - $onlySpecified = (bool)$this->getVar('_only_specified') === true; - $mappedData = array(); - foreach ($data as $i => $row) { - $newRow = array(); - foreach ($row as $field => $value) { - if (!$onlySpecified || $onlySpecified && isset($attributesToSelect[$field])) { - $newRow[$this->getVar($field, $field)] = $value; - } - } - $mappedData[$i] = $newRow; - } - $this->setData($mappedData); - return $this; - } -} diff --git a/lib/Magento/Convert/Mapper/MapperInterface.php b/lib/Magento/Convert/Mapper/MapperInterface.php deleted file mode 100644 index 3db75aece8bea..0000000000000 --- a/lib/Magento/Convert/Mapper/MapperInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - */ -namespace Magento\Convert\Mapper; - -interface MapperInterface -{ - /** - * @return $this - */ - public function map(); -} diff --git a/lib/Magento/DB/Adapter/Pdo/Mysql.php b/lib/Magento/DB/Adapter/Pdo/Mysql.php index b6f9a3b5337ca..198f00ec0d9db 100644 --- a/lib/Magento/DB/Adapter/Pdo/Mysql.php +++ b/lib/Magento/DB/Adapter/Pdo/Mysql.php @@ -29,7 +29,7 @@ use Magento\Cache\FrontendInterface; use Magento\DB\Adapter\AdapterInterface; use Magento\DB\Ddl\Table; -use Magento\DB\Helper; +use Magento\DB\ExpressionConverter; use Magento\DB\Profiler; use Magento\DB\Select; use Magento\DB\Statement\Parameter; @@ -3282,7 +3282,7 @@ public function getTableName($tableName) { $prefix = 't_'; if (strlen($tableName) > self::LENGTH_TABLE_NAME) { - $shortName = Helper::shortName($tableName); + $shortName = ExpressionConverter::shortName($tableName); if (strlen($shortName) > self::LENGTH_TABLE_NAME) { $hash = md5($tableName); if (strlen($prefix.$hash) > self::LENGTH_TABLE_NAME) { @@ -3331,7 +3331,7 @@ public function getIndexName($tableName, $fields, $indexType = '') $hash = $tableName . '_' . $fields; if (strlen($hash) + strlen($prefix) > self::LENGTH_INDEX_NAME) { - $short = Helper::shortName($prefix . $hash); + $short = ExpressionConverter::shortName($prefix . $hash); if (strlen($short) > self::LENGTH_INDEX_NAME) { $hash = md5($hash); if (strlen($hash) + strlen($shortPrefix) > self::LENGTH_INDEX_NAME) { @@ -3362,7 +3362,7 @@ public function getForeignKeyName($priTableName, $priColumnName, $refTableName, $prefix = 'fk_'; $hash = sprintf('%s_%s_%s_%s', $priTableName, $priColumnName, $refTableName, $refColumnName); if (strlen($prefix.$hash) > self::LENGTH_FOREIGN_NAME) { - $short = Helper::shortName($prefix.$hash); + $short = ExpressionConverter::shortName($prefix . $hash); if (strlen($short) > self::LENGTH_FOREIGN_NAME) { $hash = md5($hash); if (strlen($prefix.$hash) > self::LENGTH_FOREIGN_NAME) { diff --git a/lib/Magento/DB/ExpressionConverter.php b/lib/Magento/DB/ExpressionConverter.php new file mode 100644 index 0000000000000..9eae86917129c --- /dev/null +++ b/lib/Magento/DB/ExpressionConverter.php @@ -0,0 +1,104 @@ + 'addr', + 'admin' => 'adm', + 'attribute' => 'attr', + 'enterprise' => 'ent', + 'catalog' => 'cat', + 'category' => 'ctgr', + 'customer' => 'cstr', + 'notification' => 'ntfc', + 'product' => 'prd', + 'session' => 'sess', + 'user' => 'usr', + 'entity' => 'entt', + 'datetime' => 'dtime', + 'decimal' => 'dec', + 'varchar' => 'vchr', + 'index' => 'idx', + 'compare' => 'cmp', + 'bundle' => 'bndl', + 'option' => 'opt', + 'gallery' => 'glr', + 'media' => 'mda', + 'value' => 'val', + 'link' => 'lnk', + 'title' => 'ttl', + 'super' => 'spr', + 'label' => 'lbl', + 'website' => 'ws', + 'aggregat' => 'aggr', + 'minimal' => 'min', + 'inventory' => 'inv', + 'status' => 'sts', + 'agreement' => 'agrt', + 'layout' => 'lyt', + 'resource' => 'res', + 'directory' => 'dir', + 'downloadable' => 'dl', + 'element' => 'elm', + 'fieldset' => 'fset', + 'checkout' => 'chkt', + 'newsletter' => 'nlttr', + 'shipping' => 'shpp', + 'calculation' => 'calc', + 'search' => 'srch', + 'query' => 'qr' + ); + + /** + * Convert name using dictionary + * + * @param string $name + * @return string + */ + public static function shortName($name) + { + return strtr($name, self::$_translateMap); + } + + /** + * Add or replace translate to dictionary + * + * @param string $from + * @param string $to + * @return void + */ + public static function addTranslate($from, $to) + { + self::$_translateMap[$from] = $to; + } +} diff --git a/lib/Magento/DB/Helper.php b/lib/Magento/DB/Helper.php index 420e00fe4751a..acef42054b34f 100644 --- a/lib/Magento/DB/Helper.php +++ b/lib/Magento/DB/Helper.php @@ -1,5 +1,7 @@ - */ namespace Magento\DB; -class Helper +class Helper extends \Magento\DB\Helper\AbstractHelper { /** - * Dictionary for generate short name + * Returns array of quoted orders with direction * - * @var array + * @param \Magento\DB\Select $select + * @param bool $autoReset + * @return array */ - protected static $_translateMap = array( - 'address' => 'addr', - 'admin' => 'adm', - 'attribute' => 'attr', - 'enterprise' => 'ent', - 'catalog' => 'cat', - 'category' => 'ctgr', - 'customer' => 'cstr', - 'notification' => 'ntfc', - 'product' => 'prd', - 'session' => 'sess', - 'user' => 'usr', - 'entity' => 'entt', - 'datetime' => 'dtime', - 'decimal' => 'dec', - 'varchar' => 'vchr', - 'index' => 'idx', - 'compare' => 'cmp', - 'bundle' => 'bndl', - 'option' => 'opt', - 'gallery' => 'glr', - 'media' => 'mda', - 'value' => 'val', - 'link' => 'lnk', - 'title' => 'ttl', - 'super' => 'spr', - 'label' => 'lbl', - 'website' => 'ws', - 'aggregat' => 'aggr', - 'minimal' => 'min', - 'inventory' => 'inv', - 'status' => 'sts', - 'agreement' => 'agrt', - 'layout' => 'lyt', - 'resource' => 'res', - 'directory' => 'dir', - 'downloadable' => 'dl', - 'element' => 'elm', - 'fieldset' => 'fset', - 'checkout' => 'chkt', - 'newsletter' => 'nlttr', - 'shipping' => 'shpp', - 'calculation' => 'calc', - 'search' => 'srch', - 'query' => 'qr' - ); + protected function _prepareOrder(\Magento\DB\Select $select, $autoReset = false) + { + $selectOrders = $select->getPart(\Zend_Db_Select::ORDER); + if (!$selectOrders) { + return array(); + } + + $orders = array(); + foreach ($selectOrders as $term) { + if (is_array($term)) { + if (!is_numeric($term[0])) { + $orders[] = sprintf('%s %s', $this->_getReadAdapter()->quoteIdentifier($term[0], true), $term[1]); + } + } else { + if (!is_numeric($term)) { + $orders[] = $this->_getReadAdapter()->quoteIdentifier($term, true); + } + } + } + + if ($autoReset) { + $select->reset(\Zend_Db_Select::ORDER); + } + + return $orders; + } /** - * Convert name using dictionary + * Truncate alias name from field. * - * @param string $name + * Result string depends from second optional argument $reverse + * which can be true if you need the first part of the field. + * Field can be with 'dot' delimiter. + * + * @param string $field + * @param bool $reverse OPTIONAL * @return string */ - public static function shortName($name) + protected function _truncateAliasName($field, $reverse = false) { - return strtr($name, self::$_translateMap); + $string = $field; + if (!is_numeric($field) && (strpos($field, '.') !== false)) { + $size = strpos($field, '.'); + if ($reverse) { + $string = substr($field, 0, $size); + } else { + $string = substr($field, $size + 1); + } + } + + return $string; } /** - * Add or replace translate to dictionary + * Returns quoted group by fields + * + * @param \Magento\DB\Select $select + * @param bool $autoReset + * @return array + */ + protected function _prepareGroup(\Magento\DB\Select $select, $autoReset = false) + { + $selectGroups = $select->getPart(\Zend_Db_Select::GROUP); + if (!$selectGroups) { + return array(); + } + + $groups = array(); + foreach ($selectGroups as $term) { + $groups[] = $this->_getReadAdapter()->quoteIdentifier($term, true); + } + + if ($autoReset) { + $select->reset(\Zend_Db_Select::GROUP); + } + + return $groups; + } + + /** + * Prepare and returns having array + * + * @param \Magento\DB\Select $select + * @param bool $autoReset + * @return array + * @throws \Zend_Db_Exception + */ + protected function _prepareHaving(\Magento\DB\Select $select, $autoReset = false) + { + $selectHavings = $select->getPart(\Zend_Db_Select::HAVING); + if (!$selectHavings) { + return array(); + } + + $havings = array(); + $columns = $select->getPart(\Zend_Db_Select::COLUMNS); + foreach ($columns as $columnEntry) { + $correlationName = (string)$columnEntry[1]; + $column = $columnEntry[2]; + foreach ($selectHavings as $having) { + /** + * Looking for column expression in the having clause + */ + if (strpos($having, $correlationName) !== false) { + if (is_string($column)) { + /** + * Replace column expression to column alias in having clause + */ + $havings[] = str_replace($correlationName, $column, $having); + } else { + throw new \Zend_Db_Exception( + sprintf("Can't prepare expression without column alias: '%s'", $correlationName) + ); + } + } + } + } + + if ($autoReset) { + $select->reset(\Zend_Db_Select::HAVING); + } + + return $havings; + } + + /** + * + * @param string $query + * @param int $limitCount + * @param int $limitOffset + * @param array $columnList + * @return string + */ + protected function _assembleLimit($query, $limitCount, $limitOffset, $columnList = array()) + { + if ($limitCount !== null) { + $limitCount = intval($limitCount); + if ($limitCount <= 0) { + //throw new \Exception("LIMIT argument count={$limitCount} is not valid"); + } + + $limitOffset = intval($limitOffset); + if ($limitOffset < 0) { + //throw new \Exception("LIMIT argument offset={$limitOffset} is not valid"); + } + + if ($limitOffset + $limitCount != $limitOffset + 1) { + $columns = array(); + foreach ($columnList as $columnEntry) { + $columns[] = $columnEntry[2] ? $columnEntry[2] : $columnEntry[1]; + } + $query = sprintf('%s LIMIT %s, %s', $query, $limitCount, $limitOffset); + } + } + + return $query; + } + + /** + * Prepare select column list + * + * @param \Magento\DB\Select $select + * @param string|null $groupByCondition OPTIONAL + * @return mixed|array + * @throws \Zend_Db_Exception + */ + public function prepareColumnsList(\Magento\DB\Select $select, $groupByCondition = null) + { + if (!count($select->getPart(\Zend_Db_Select::FROM))) { + return $select->getPart(\Zend_Db_Select::COLUMNS); + } + + $columns = $select->getPart(\Zend_Db_Select::COLUMNS); + $tables = $select->getPart(\Zend_Db_Select::FROM); + $preparedColumns = array(); + + foreach ($columns as $columnEntry) { + list($correlationName, $column, $alias) = $columnEntry; + if ($column instanceof \Zend_Db_Expr) { + if ($alias !== null) { + if (preg_match('/(^|[^a-zA-Z_])^(SELECT)?(SUM|MIN|MAX|AVG|COUNT)\s*\(/i', $column)) { + $column = new \Zend_Db_Expr($column); + } + $preparedColumns[strtoupper($alias)] = array(null, $column, $alias); + } else { + throw new \Zend_Db_Exception("Can't prepare expression without alias"); + } + } else { + if ($column == \Zend_Db_Select::SQL_WILDCARD) { + if ($tables[$correlationName]['tableName'] instanceof \Zend_Db_Expr) { + throw new \Zend_Db_Exception( + "Can't prepare expression when tableName is instance of \Zend_Db_Expr" + ); + } + $tableColumns = $this->_getReadAdapter()->describeTable($tables[$correlationName]['tableName']); + foreach (array_keys($tableColumns) as $col) { + $preparedColumns[strtoupper($col)] = array($correlationName, $col, null); + } + } else { + $columnKey = is_null($alias) ? $column : $alias; + $preparedColumns[strtoupper($columnKey)] = array($correlationName, $column, $alias); + } + } + } + + return $preparedColumns; + } + + /** + * Add prepared column group_concat expression + * + * @param \Magento\DB\Select $select + * @param string $fieldAlias Field alias which will be added with column group_concat expression + * @param string $fields + * @param string $groupConcatDelimiter + * @param string $fieldsDelimiter + * @param string $additionalWhere + * @return \Magento\DB\Select + */ + public function addGroupConcatColumn( + $select, + $fieldAlias, + $fields, + $groupConcatDelimiter = ',', + $fieldsDelimiter = '', + $additionalWhere = '' + ) { + if (is_array($fields)) { + $fieldExpr = $this->_getReadAdapter()->getConcatSql($fields, $fieldsDelimiter); + } else { + $fieldExpr = $fields; + } + if ($additionalWhere) { + $fieldExpr = $this->_getReadAdapter()->getCheckSql($additionalWhere, $fieldExpr, "''"); + } + $separator = ''; + if ($groupConcatDelimiter) { + $separator = sprintf(" SEPARATOR '%s'", $groupConcatDelimiter); + } + $select->columns(array($fieldAlias => new \Zend_Db_Expr(sprintf('GROUP_CONCAT(%s%s)', $fieldExpr, $separator)))); + return $select; + } + + /** + * Returns expression of days passed from $startDate to $endDate + * + * @param string|\Zend_Db_Expr $startDate + * @param string|\Zend_Db_Expr $endDate + * @return \Zend_Db_Expr + */ + public function getDateDiff($startDate, $endDate) + { + $dateDiff = '(TO_DAYS(' . $endDate . ') - TO_DAYS(' . $startDate . '))'; + return new \Zend_Db_Expr($dateDiff); + } + + /** + * Escapes and quotes LIKE value. + * Stating escape symbol in expression is not required, because we use standard MySQL escape symbol. + * For options and escaping see escapeLikeValue(). + * + * @param string $value + * @param array $options + * @return \Zend_Db_Expr * - * @param string $from - * @param string $to - * @return void + * @see escapeLikeValue() */ - public static function addTranslate($from, $to) + public function addLikeEscape($value, $options = array()) { - self::$_translateMap[$from] = $to; + $value = $this->escapeLikeValue($value, $options); + return new \Zend_Db_Expr($this->_getReadAdapter()->quote($value)); } } diff --git a/app/code/Magento/Core/Model/Resource/Helper/AbstractHelper.php b/lib/Magento/DB/Helper/AbstractHelper.php similarity index 96% rename from app/code/Magento/Core/Model/Resource/Helper/AbstractHelper.php rename to lib/Magento/DB/Helper/AbstractHelper.php index b77b8f2babaf2..5c1da9937fcbc 100644 --- a/app/code/Magento/Core/Model/Resource/Helper/AbstractHelper.php +++ b/lib/Magento/DB/Helper/AbstractHelper.php @@ -1,5 +1,7 @@ */ class Transaction { @@ -111,11 +106,11 @@ protected function _runCallbacks() /** * Adding object for using in transaction * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $alias * @return $this */ - public function addObject(\Magento\Core\Model\AbstractModel $object, $alias = '') + public function addObject(\Magento\Model\AbstractModel $object, $alias = '') { $this->_objects[] = $object; if (!empty($alias)) { diff --git a/lib/Magento/Data/Collection/Db.php b/lib/Magento/Data/Collection/Db.php index aa69184f461f1..91e38b5e406e7 100644 --- a/lib/Magento/Data/Collection/Db.php +++ b/lib/Magento/Data/Collection/Db.php @@ -635,33 +635,6 @@ protected function _toOptionHash($valueField = null, $labelField = 'name') return parent::_toOptionHash($valueField, $labelField); } - /** - * Convert items array to hash for select options - * using fetchItem method - * - * The difference between _toOptionHash() and this one is that this - * method fetch items one by one and does not load all collection items at once - * return items hash - * array($value => $label) - * - * @see fetchItem() - * - * @param string $valueField - * @param string $labelField - * @return array - */ - protected function _toOptionHashOptimized($valueField = null, $labelField = 'name') - { - if ($valueField === null) { - $valueField = $this->getIdFieldName(); - } - $result = array(); - while ($item = $this->fetchItem()) { - $result[$item->getData($valueField)] = $item->getData($labelField); - } - return $result; - } - /** * Get all data array for collection * @@ -790,7 +763,7 @@ public function addFilterToMap($filter, $alias, $group = 'fields') { if (is_null($this->_map)) { $this->_map = array($group => array()); - } elseif (is_null($this->_map[$group])) { + } elseif (empty($this->_map[$group])) { $this->_map[$group] = array(); } $this->_map[$group][$filter] = $alias; diff --git a/lib/Magento/Filesystem/Driver/Http.php b/lib/Magento/Filesystem/Driver/Http.php index 3d1032ab9afdb..1e58a58f171f5 100644 --- a/lib/Magento/Filesystem/Driver/Http.php +++ b/lib/Magento/Filesystem/Driver/Http.php @@ -180,7 +180,7 @@ public function fileOpen($path, $mode) $hostname . "\r\n" . 'User-Agent: Magento ver/' . - \Magento\Core\Model\App::VERSION . + \Magento\AppInterface::VERSION . "\r\n" . 'Connection: close' . "\r\n" . diff --git a/app/code/Magento/Core/Model/Flag.php b/lib/Magento/Flag.php similarity index 74% rename from app/code/Magento/Core/Model/Flag.php rename to lib/Magento/Flag.php index 52672980b0305..aedaab5ef8068 100644 --- a/app/code/Magento/Core/Model/Flag.php +++ b/lib/Magento/Flag.php @@ -18,30 +18,24 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model; +namespace Magento; /** - * Core Flag model + * Flag model * - * @method \Magento\Core\Model\Resource\Flag _getResource() - * @method \Magento\Core\Model\Resource\Flag getResource() + * @method \Magento\Flag\Resource _getResource() + * @method \Magento\Flag\Resource getResource() * @method string getFlagCode() - * @method \Magento\Core\Model\Flag setFlagCode(string $value) + * @method \Magento\Flag setFlagCode(string $value) * @method int getState() - * @method \Magento\Core\Model\Flag setState(int $value) + * @method \Magento\Flag setState(int $value) * @method string getLastUpdate() - * @method \Magento\Core\Model\Flag setLastUpdate(string $value) - * - * @category Magento - * @package Magento_Core - * @author Magento Core Team + * @method \Magento\Flag setLastUpdate(string $value) */ -class Flag extends AbstractModel +class Flag extends \Magento\Model\AbstractModel { /** * Flag code @@ -61,19 +55,19 @@ protected function _construct() if ($this->hasData('flag_code')) { $this->_flagCode = $this->getData('flag_code'); } - $this->_init('Magento\Core\Model\Resource\Flag'); + $this->_init('Magento\Flag\Resource'); } /** * Processing object before save data * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ protected function _beforeSave() { if (is_null($this->_flagCode)) { - throw new \Magento\Core\Exception(__('Please define flag code.')); + throw new \Magento\Model\Exception(__('Please define flag code.')); } $this->setFlagCode($this->_flagCode); @@ -110,13 +104,13 @@ public function setFlagData($value) /** * load self (load by flag code) * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return $this */ public function loadSelf() { if (is_null($this->_flagCode)) { - throw new \Magento\Core\Exception(__('Please define flag code.')); + throw new \Magento\Model\Exception(__('Please define flag code.')); } return $this->load($this->_flagCode, 'flag_code'); diff --git a/app/code/Magento/Core/Model/Resource/Flag.php b/lib/Magento/Flag/Resource.php similarity index 79% rename from app/code/Magento/Core/Model/Resource/Flag.php rename to lib/Magento/Flag/Resource.php index de91ae9b59ace..ded104d288edc 100644 --- a/app/code/Magento/Core/Model/Resource/Flag.php +++ b/lib/Magento/Flag/Resource.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_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource; +namespace Magento\Flag; /** - * Flag model - * - * @category Magento - * @package Magento_Core - * @author Magento Core Team + * Flag Resource model */ -class Flag extends \Magento\Core\Model\Resource\Db\AbstractDb +class Resource extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table diff --git a/lib/Magento/Translate/InlineFactory.php b/lib/Magento/FlagFactory.php similarity index 66% rename from lib/Magento/Translate/InlineFactory.php rename to lib/Magento/FlagFactory.php index 37a9e911c0d1c..4f56f7db29491 100644 --- a/lib/Magento/Translate/InlineFactory.php +++ b/lib/Magento/FlagFactory.php @@ -1,7 +1,5 @@ _objectManager = $objectManager; + $this->_instanceName = $instanceName; } /** - * Return instance of inline translate parser object + * Create class instance with specified parameters * * @param array $data - * @throws \InvalidArgumentException - * @return \Magento\Translate\InlineInterface + * @return \Magento\Flag */ - public function get(array $data = null) + public function create(array $data = array()) { - $model = $this->_objectManager->get('Magento\Translate\InlineInterface', $data); - return $model; + return $this->_objectManager->create($this->_instanceName, $data); } } diff --git a/lib/Magento/Json/Encoder.php b/lib/Magento/Json/Encoder.php index 60bbd075b7bd5..1e5b9bf1d2589 100644 --- a/lib/Magento/Json/Encoder.php +++ b/lib/Magento/Json/Encoder.php @@ -49,10 +49,7 @@ public function __construct(\Magento\Translate\InlineInterface $translateInline) public function encode($data) { $json = \Zend_Json::encode($data); - if ($this->translateInline->isAllowed()) { - $this->translateInline->processResponseBody($json, true); - } - + $this->translateInline->processResponseBody($json, true); return $json; } } diff --git a/lib/Magento/Locale/Lists.php b/lib/Magento/Locale/Lists.php index 9006ab993523c..f41e56b38b765 100644 --- a/lib/Magento/Locale/Lists.php +++ b/lib/Magento/Locale/Lists.php @@ -40,11 +40,6 @@ class Lists implements \Magento\Locale\ListsInterface */ protected $_config; - /** - * @var \Magento\AppInterface - */ - protected $_app; - /** * @var \Magento\Locale\ResolverInterface */ @@ -59,7 +54,6 @@ class Lists implements \Magento\Locale\ListsInterface * @param \Magento\App\State $appState * @param \Magento\BaseScopeResolverInterface $scopeResolver * @param \Magento\Locale\ConfigInterface $config - * @param \Magento\AppInterface $app * @param \Magento\Locale\ResolverInterface $localeResolver * @param string $currencyInstalled * @param string $locale @@ -68,7 +62,6 @@ public function __construct( \Magento\App\State $appState, \Magento\BaseScopeResolverInterface $scopeResolver, \Magento\Locale\ConfigInterface $config, - \Magento\AppInterface $app, \Magento\Locale\ResolverInterface $localeResolver, $currencyInstalled, $locale = null @@ -76,7 +69,6 @@ public function __construct( $this->_appState = $appState; $this->_scopeResolver = $scopeResolver; $this->_config = $config; - $this->_app = $app; $this->_localeResolver = $localeResolver; if ($locale !== null) { $this->_localeResolver->setLocale($locale); diff --git a/lib/Magento/Locale/Resolver.php b/lib/Magento/Locale/Resolver.php index fb3ac3e320354..793d4fc1dd75b 100644 --- a/lib/Magento/Locale/Resolver.php +++ b/lib/Magento/Locale/Resolver.php @@ -52,9 +52,9 @@ class Resolver implements \Magento\Locale\ResolverInterface protected $_scopeConfig; /** - * @var \Magento\AppInterface + * @var \Magento\App\CacheInterface */ - protected $_app; + protected $_cache; /** * Emulated locales stack @@ -69,20 +69,20 @@ class Resolver implements \Magento\Locale\ResolverInterface protected $_localeFactory; /** - * @param \Magento\Locale\ScopeConfigInterface $scopeConfig - * @param \Magento\AppInterface $app + * @param ScopeConfigInterface $scopeConfig + * @param \Magento\App\CacheInterface $cache * @param \Magento\LocaleFactory $localeFactory * @param string $defaultLocalePath - * @param mixed $locale + * @param null $locale */ public function __construct( \Magento\Locale\ScopeConfigInterface $scopeConfig, - \Magento\AppInterface $app, + \Magento\App\CacheInterface $cache, \Magento\LocaleFactory $localeFactory, $defaultLocalePath, $locale = null ) { - $this->_app = $app; + $this->_cache = $cache; $this->_scopeConfig = $scopeConfig; $this->_localeFactory = $localeFactory; $this->_defaultLocalePath = $defaultLocalePath; @@ -140,7 +140,7 @@ public function setLocale($locale = null) public function getLocale() { if (!$this->_locale) { - \Zend_Locale_Data::setCache($this->_app->getCache()->getLowLevelFrontend()); + \Zend_Locale_Data::setCache($this->_cache->getFrontend()->getLowLevelFrontend()); $this->_locale = $this->_localeFactory->create(array('locale' => $this->getLocaleCode())); } elseif ($this->_locale->__toString() != $this->_localeCode) { $this->setLocale($this->_localeCode); diff --git a/app/code/Magento/Core/Model/AbstractModel.php b/lib/Magento/Model/AbstractModel.php similarity index 91% rename from app/code/Magento/Core/Model/AbstractModel.php rename to lib/Magento/Model/AbstractModel.php index 5ba4e0820995a..0b38933e50589 100644 --- a/app/code/Magento/Core/Model/AbstractModel.php +++ b/lib/Magento/Model/AbstractModel.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model; +namespace Magento\Model; /** * Abstract model class @@ -52,14 +50,14 @@ abstract class AbstractModel extends \Magento\Object /** * Resource model instance * - * @var \Magento\Core\Model\Resource\Db\AbstractDb + * @var \Magento\Model\Resource\Db\AbstractDb */ protected $_resource; /** * Resource collection * - * @var \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @var \Magento\Model\Resource\Db\Collection\AbstractCollection */ protected $_resourceCollection; @@ -126,7 +124,7 @@ abstract class AbstractModel extends \Magento\Object /** * @var \Magento\Registry */ - protected $_coreRegistry; + protected $_registry; /** * @var \Magento\Logger @@ -139,26 +137,32 @@ abstract class AbstractModel extends \Magento\Object protected $_appState; /** - * @param \Magento\Model\Context $context + * @var \Magento\Model\ActionValidator\RemoveAction + */ + protected $_actionValidator; + + /** + * @param Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\Resource\AbstractResource $resource + * @param Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\Resource\AbstractResource $resource = null, + \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_coreRegistry = $registry; + $this->_registry = $registry; $this->_appState = $context->getAppState(); $this->_eventManager = $context->getEventDispatcher(); $this->_cacheManager = $context->getCacheManager(); $this->_resource = $resource; $this->_resourceCollection = $resourceCollection; $this->_logger = $context->getLogger(); + $this->_actionValidator = $context->getActionValidator(); if (method_exists($this->_resource, 'getIdFieldName') || $this->_resource instanceof \Magento\Object) { $this->_idFieldName = $this->_getResource()->getIdFieldName(); @@ -195,7 +199,7 @@ protected function _init($resourceModel) public function __sleep() { $properties = array_keys(get_object_vars($this)); - $properties = array_diff($properties, array('_eventManager', '_cacheManager', '_coreRegistry', '_appState')); + $properties = array_diff($properties, array('_eventManager', '_cacheManager', '_registry', '_appState')); return $properties; } @@ -209,7 +213,7 @@ public function __wakeup() $objectManager = \Magento\App\ObjectManager::getInstance(); $this->_eventManager = $objectManager->get('Magento\Event\ManagerInterface'); $this->_cacheManager = $objectManager->get('Magento\App\CacheInterface'); - $this->_coreRegistry = $objectManager->get('Magento\Registry'); + $this->_registry = $objectManager->get('Magento\Registry'); $context = $objectManager->get('Magento\Model\Context'); if ($context instanceof \Magento\Model\Context) { $this->_appState = $context->getAppState(); @@ -237,13 +241,13 @@ protected function _setResourceModel($resourceName, $collectionName = null) /** * Get resource instance * - * @throws \Magento\Core\Exception - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @throws \Magento\Model\Exception + * @return \Magento\Model\Resource\Db\AbstractDb */ protected function _getResource() { if (empty($this->_resourceName) && empty($this->_resource)) { - throw new \Magento\Core\Exception(__('Resource is not set.')); + throw new \Magento\Model\Exception(__('Resource is not set.')); } return $this->_resource ?: \Magento\App\ObjectManager::getInstance()->get($this->_resourceName); @@ -263,13 +267,13 @@ public function getResourceName() * Get collection instance * * @deplacated - * @throws \Magento\Core\Exception - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @throws \Magento\Model\Exception + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function getResourceCollection() { if (empty($this->_resourceCollection) && empty($this->_collectionName)) { - throw new \Magento\Core\Exception(__('Model collection resource name is not defined.')); + throw new \Magento\Model\Exception(__('Model collection resource name is not defined.')); } return $this->_resourceCollection ? clone $this ->_resourceCollection : \Magento\App\ObjectManager::getInstance() @@ -281,7 +285,7 @@ public function getResourceCollection() /** * Retrieve collection instance * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return \Magento\Model\Resource\Db\Collection\AbstractCollection */ public function getCollection() { @@ -453,14 +457,14 @@ protected function _beforeSave() * Validate model before saving it * * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _validateBeforeSave() { $validator = $this->_getValidatorBeforeSave(); if ($validator && !$validator->isValid($this)) { $errors = $validator->getMessages(); - $exception = new \Magento\Core\Exception(implode(PHP_EOL, $errors)); + $exception = new \Magento\Model\Exception(implode(PHP_EOL, $errors)); foreach ($errors as $errorMessage) { $exception->addMessage(new \Magento\Message\Error($errorMessage)); } @@ -599,31 +603,20 @@ public function delete() * Processing object before delete data * * @return $this + * @throws Exception */ protected function _beforeDelete() { + if (!$this->_actionValidator->isAllowed($this)) { + throw new Exception(__('Delete operation is forbidden for current area')); + } + $this->_eventManager->dispatch('model_delete_before', array('object' => $this)); $this->_eventManager->dispatch($this->_eventPrefix . '_delete_before', $this->_getEventData()); $this->cleanModelCache(); return $this; } - /** - * Safeguard func that will check, if we are in admin area - * - * @return void - * @throws \Magento\Core\Exception - */ - protected function _protectFromNonAdmin() - { - if ($this->_coreRegistry->registry('isSecureArea')) { - return; - } - if ($this->_appState->getAreaCode() !== \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) { - throw new \Magento\Core\Exception(__('Cannot complete this operation from non-admin area.')); - } - } - /** * Processing object after delete data * @@ -652,7 +645,7 @@ protected function _afterDeleteCommit() /** * Retrieve model resource * - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @return \Magento\Model\Resource\Db\AbstractDb */ public function getResource() { diff --git a/lib/Magento/Model/ActionValidator/RemoveAction.php b/lib/Magento/Model/ActionValidator/RemoveAction.php new file mode 100644 index 0000000000000..b862218c7be50 --- /dev/null +++ b/lib/Magento/Model/ActionValidator/RemoveAction.php @@ -0,0 +1,84 @@ +registry = $registry; + $this->protectedModels = $protectedModels; + } + + /** + * Safeguard function that checks if item can be removed + * + * @param AbstractModel $model + * @return bool + */ + public function isAllowed(AbstractModel $model) + { + $isAllowed = true; + + if ($this->registry->registry('isSecureArea')) { + $isAllowed = true; + } elseif (in_array($this->getBaseClassName($model), $this->protectedModels)) { + $isAllowed = false; + } + + return $isAllowed; + } + + /** + * Get clean model name without Interceptor and Proxy part and slashes + * @param object $object + * @return mixed + */ + protected function getBaseClassName($object) + { + $className = ltrim(get_class($object), "\\"); + $className = str_replace(array('\Interceptor', '\Proxy'), array(''), $className); + + return $className; + } +} diff --git a/lib/Magento/Model/ActionValidator/RemoveAction/Allowed.php b/lib/Magento/Model/ActionValidator/RemoveAction/Allowed.php new file mode 100644 index 0000000000000..5ebb78f9c41ef --- /dev/null +++ b/lib/Magento/Model/ActionValidator/RemoveAction/Allowed.php @@ -0,0 +1,42 @@ +_eventDispatcher = $eventDispatcher; $this->_cacheManager = $cacheManager; $this->_appState = $appState; $this->_logger = $logger; + $this->_actionValidator = $actionValidator; } /** @@ -96,4 +104,12 @@ public function getAppState() { return $this->_appState; } + + /** + * @return \Magento\Model\ActionValidator\RemoveAction + */ + public function getActionValidator() + { + return $this->_actionValidator; + } } diff --git a/app/code/Magento/Core/Exception.php b/lib/Magento/Model/Exception.php similarity index 92% rename from app/code/Magento/Core/Exception.php rename to lib/Magento/Model/Exception.php index 8313830691210..3361c6d7e4cee 100644 --- a/app/code/Magento/Core/Exception.php +++ b/lib/Magento/Model/Exception.php @@ -18,20 +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\Core; +namespace Magento\Model; /** - * Magento Core \Exception + * Magento Model Exception * * This class will be extended by other modules - * - * @category Magento - * @package Magento_Core */ class Exception extends \Exception { @@ -74,7 +69,7 @@ public function getMessages($type = '') * * @param string $message * @param bool $append - * @return \Magento\Core\Exception + * @return \Magento\Model\Exception */ public function setMessage($message, $append = false) { diff --git a/app/code/Magento/Core/Model/Resource/AbstractResource.php b/lib/Magento/Model/Resource/AbstractResource.php similarity index 94% rename from app/code/Magento/Core/Model/Resource/AbstractResource.php rename to lib/Magento/Model/Resource/AbstractResource.php index 7fcfccd555fb7..22feb833c54ea 100644 --- a/app/code/Magento/Core/Model/Resource/AbstractResource.php +++ b/lib/Magento/Model/Resource/AbstractResource.php @@ -18,19 +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_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource; +namespace Magento\Model\Resource; /** * Abstract resource model - * - * @category Magento - * @package Magento_Core - * @author Magento Core Team */ abstract class AbstractResource { @@ -168,7 +162,7 @@ protected function _serializeField(\Magento\Object $object, $field, $defaultValu /** * Unserialize \Magento\Object field in an object * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $field * @param mixed $defaultValue * @return void @@ -245,11 +239,11 @@ public function getValidationRulesBeforeSave() /** * Prepare the list of entity fields that should be selected from DB. Apply filtration based on active fieldset. * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param string $tableName * @return array|string */ - protected function _getColumnsForEntityLoad(\Magento\Core\Model\AbstractModel $object, $tableName) + protected function _getColumnsForEntityLoad(\Magento\Model\AbstractModel $object, $tableName) { $fieldsetColumns = $object->getFieldset(); if (!empty($fieldsetColumns)) { diff --git a/app/code/Magento/Core/Model/Resource/Db/AbstractDb.php b/lib/Magento/Model/Resource/Db/AbstractDb.php similarity index 87% rename from app/code/Magento/Core/Model/Resource/Db/AbstractDb.php rename to lib/Magento/Model/Resource/Db/AbstractDb.php index c116be27c4fa6..743220e65a814 100644 --- a/app/code/Magento/Core/Model/Resource/Db/AbstractDb.php +++ b/lib/Magento/Model/Resource/Db/AbstractDb.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_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Db; +namespace Magento\Model\Resource\Db; /** * Abstract resource model class - * - * @category Magento - * @package Magento_Core - * @author Magento Core Team */ -abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource +abstract class AbstractDb extends \Magento\Model\Resource\AbstractResource { /** * Cached resources singleton @@ -233,13 +227,13 @@ protected function _setMainTable($mainTable, $idFieldName = null) /** * Get primary key field name * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return string */ public function getIdFieldName() { if (empty($this->_idFieldName)) { - throw new \Magento\Core\Exception(__('Empty identifier field name')); + throw new \Magento\Model\Exception(__('Empty identifier field name')); } return $this->_idFieldName; } @@ -248,13 +242,13 @@ public function getIdFieldName() * Returns main table name - extracted from "module/table" style and * validated by db adapter * - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception * @return string */ public function getMainTable() { if (empty($this->_mainTable)) { - throw new \Magento\Core\Exception(__('Empty main table name')); + throw new \Magento\Model\Exception(__('Empty main table name')); } return $this->getTable($this->_mainTable); } @@ -343,12 +337,12 @@ public function getReadConnection() /** * Load an object * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @param mixed $value * @param string $field field to load by (defaults to model id) * @return $this */ - public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = null) + public function load(\Magento\Model\AbstractModel $object, $value, $field = null) { if (is_null($field)) { $field = $this->getIdFieldName(); @@ -375,7 +369,7 @@ public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return \Zend_Db_Select */ protected function _getLoadSelect($field, $value, $object) @@ -388,10 +382,10 @@ protected function _getLoadSelect($field, $value, $object) /** * Save object object data * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - public function save(\Magento\Core\Model\AbstractModel $object) + public function save(\Magento\Model\AbstractModel $object) { if ($object->isDeleted()) { return $this->delete($object); @@ -449,10 +443,10 @@ public function save(\Magento\Core\Model\AbstractModel $object) /** * Delete the object * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this */ - public function delete(\Magento\Core\Model\AbstractModel $object) + public function delete(\Magento\Model\AbstractModel $object) { $this->_beforeDelete($object); $this->_getWriteAdapter()->delete( @@ -494,10 +488,10 @@ public function resetUniqueField() /** * Unserialize serializeable object fields * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return void */ - public function unserializeFields(\Magento\Core\Model\AbstractModel $object) + public function unserializeFields(\Magento\Model\AbstractModel $object) { foreach ($this->_serializableFields as $field => $parameters) { list($serializeDefault, $unserializeDefault) = $parameters; @@ -532,10 +526,10 @@ public function getUniqueFields() /** * Prepare data for save * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return array */ - protected function _prepareDataForSave(\Magento\Core\Model\AbstractModel $object) + protected function _prepareDataForSave(\Magento\Model\AbstractModel $object) { return $this->_prepareDataForTable($object, $this->getMainTable()); } @@ -544,7 +538,7 @@ protected function _prepareDataForSave(\Magento\Core\Model\AbstractModel $object * Check that model data fields that can be saved * has really changed comparing with origData * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return bool */ public function hasDataChanged($object) @@ -578,11 +572,11 @@ protected function _prepareValueForSave($value, $type) /** * Check for unique values existence * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return $this - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ - protected function _checkUnique(\Magento\Core\Model\AbstractModel $object) + protected function _checkUnique(\Magento\Model\AbstractModel $object) { $existent = array(); $fields = $this->getUniqueFields(); @@ -622,7 +616,7 @@ protected function _checkUnique(\Magento\Core\Model\AbstractModel $object) } else { $error = __('%1 already exist.', implode(', ', $existent)); } - throw new \Magento\Core\Exception($error); + throw new \Magento\Model\Exception($error); } return $this; } @@ -630,10 +624,10 @@ protected function _checkUnique(\Magento\Core\Model\AbstractModel $object) /** * After load * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return void */ - public function afterLoad(\Magento\Core\Model\AbstractModel $object) + public function afterLoad(\Magento\Model\AbstractModel $object) { $this->_afterLoad($object); } @@ -641,10 +635,10 @@ public function afterLoad(\Magento\Core\Model\AbstractModel $object) /** * Perform actions after object load * - * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object + * @param \Magento\Model\AbstractModel|\Magento\Object $object * @return $this */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(\Magento\Model\AbstractModel $object) { return $this; } @@ -652,10 +646,10 @@ protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) /** * Perform actions before object save * - * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object + * @param \Magento\Model\AbstractModel|\Magento\Object $object * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(\Magento\Model\AbstractModel $object) { return $this; } @@ -663,10 +657,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) /** * Perform actions after object save * - * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object + * @param \Magento\Model\AbstractModel|\Magento\Object $object * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(\Magento\Model\AbstractModel $object) { return $this; } @@ -674,10 +668,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) /** * Perform actions before object delete * - * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object + * @param \Magento\Model\AbstractModel|\Magento\Object $object * @return $this */ - protected function _beforeDelete(\Magento\Core\Model\AbstractModel $object) + protected function _beforeDelete(\Magento\Model\AbstractModel $object) { return $this; } @@ -685,10 +679,10 @@ protected function _beforeDelete(\Magento\Core\Model\AbstractModel $object) /** * Perform actions after object delete * - * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object + * @param \Magento\Model\AbstractModel|\Magento\Object $object * @return $this */ - protected function _afterDelete(\Magento\Core\Model\AbstractModel $object) + protected function _afterDelete(\Magento\Model\AbstractModel $object) { return $this; } @@ -696,10 +690,10 @@ protected function _afterDelete(\Magento\Core\Model\AbstractModel $object) /** * Serialize serializable fields of the object * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Model\AbstractModel $object * @return void */ - protected function _serializeFields(\Magento\Core\Model\AbstractModel $object) + protected function _serializeFields(\Magento\Model\AbstractModel $object) { foreach ($this->_serializableFields as $field => $parameters) { list($serializeDefault, $unserializeDefault) = $parameters; diff --git a/app/code/Magento/Core/Model/Resource/Db/Collection/AbstractCollection.php b/lib/Magento/Model/Resource/Db/Collection/AbstractCollection.php similarity index 95% rename from app/code/Magento/Core/Model/Resource/Db/Collection/AbstractCollection.php rename to lib/Magento/Model/Resource/Db/Collection/AbstractCollection.php index 76ca676c9c15f..55a49e34b9a0b 100644 --- a/app/code/Magento/Core/Model/Resource/Db/Collection/AbstractCollection.php +++ b/lib/Magento/Model/Resource/Db/Collection/AbstractCollection.php @@ -18,19 +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_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Db\Collection; +namespace Magento\Model\Resource\Db\Collection; /** - * Abstract Core Resource Collection - * - * @category Magento - * @package Magento_Core - * @author Magento Core Team + * Abstract Resource Collection */ abstract class AbstractCollection extends \Magento\Data\Collection\Db { @@ -51,7 +45,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Resource instance * - * @var \Magento\Core\Model\Resource\Db\AbstractDb + * @var \Magento\Model\Resource\Db\AbstractDb */ protected $_resource; @@ -112,27 +106,27 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db protected $_eventObject = ''; /** - * Core event manager proxy + * Event manager proxy * * @var \Magento\Event\ManagerInterface */ protected $_eventManager = null; /** - * @param \Magento\Core\Model\EntityFactory $entityFactory + * @param \Magento\Data\Collection\EntityFactoryInterface $entityFactory * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager * @param \Zend_Db_Adapter_Abstract $connection - * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource + * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( - \Magento\Core\Model\EntityFactory $entityFactory, + \Magento\Data\Collection\EntityFactoryInterface $entityFactory, \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, $connection = null, - \Magento\Core\Model\Resource\Db\AbstractDb $resource = null + \Magento\Model\Resource\Db\AbstractDb $resource = null ) { $this->_eventManager = $eventManager; parent::__construct($entityFactory, $logger, $fetchStrategy, $connection); @@ -471,7 +465,7 @@ public function getResourceModelName() /** * Get resource instance * - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @return \Magento\Model\Resource\Db\AbstractDb */ public function getResource() { diff --git a/app/code/Magento/Core/Model/Resource/Db/Profiler.php b/lib/Magento/Model/Resource/Db/Profiler.php similarity index 93% rename from app/code/Magento/Core/Model/Resource/Db/Profiler.php rename to lib/Magento/Model/Resource/Db/Profiler.php index c6c31c786e6ab..d32255cc980f8 100644 --- a/app/code/Magento/Core/Model/Resource/Db/Profiler.php +++ b/lib/Magento/Model/Resource/Db/Profiler.php @@ -1,6 +1,6 @@ _type)) { @@ -66,7 +66,7 @@ protected function _getTimerName($operation) $timerName .= '_' . $this->_host; } - return \Magento\Core\Model\Resource\Db\Profiler::TIMER_PREFIX . ':' . $timerName; + return \Magento\Model\Resource\Db\Profiler::TIMER_PREFIX . ':' . $timerName; } /** diff --git a/app/code/Magento/Core/Model/Resource/Entity/AbstractEntity.php b/lib/Magento/Model/Resource/Entity/AbstractEntity.php similarity index 94% rename from app/code/Magento/Core/Model/Resource/Entity/AbstractEntity.php rename to lib/Magento/Model/Resource/Entity/AbstractEntity.php index 906df00a68565..340c61674899b 100644 --- a/app/code/Magento/Core/Model/Resource/Entity/AbstractEntity.php +++ b/lib/Magento/Model/Resource/Entity/AbstractEntity.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Entity; +namespace Magento\Model\Resource\Entity; abstract class AbstractEntity { diff --git a/app/code/Magento/Core/Model/Resource/Entity/Table.php b/lib/Magento/Model/Resource/Entity/Table.php similarity index 86% rename from app/code/Magento/Core/Model/Resource/Entity/Table.php rename to lib/Magento/Model/Resource/Entity/Table.php index 983f15bd9bcb8..bbfc72d9bf725 100644 --- a/app/code/Magento/Core/Model/Resource/Entity/Table.php +++ b/lib/Magento/Model/Resource/Entity/Table.php @@ -18,18 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 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\Entity; +namespace Magento\Model\Resource\Entity; /** * Class describing db table resource entity * */ -class Table extends \Magento\Core\Model\Resource\Entity\AbstractEntity +class Table extends \Magento\Model\Resource\Entity\AbstractEntity { /** * Get table diff --git a/app/code/Magento/Core/Model/Resource/Iterator.php b/lib/Magento/Model/Resource/Iterator.php similarity index 86% rename from app/code/Magento/Core/Model/Resource/Iterator.php rename to lib/Magento/Model/Resource/Iterator.php index 841099b3b60c7..d59c1463fb81d 100644 --- a/app/code/Magento/Core/Model/Resource/Iterator.php +++ b/lib/Magento/Model/Resource/Iterator.php @@ -18,18 +18,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_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) */ /** * Active record implementation - * - * @author Magento Core Team */ -namespace Magento\Core\Model\Resource; +namespace Magento\Model\Resource; class Iterator extends \Magento\Object { @@ -40,7 +36,7 @@ class Iterator extends \Magento\Object * @param array|string $callbacks * @param array $args * @param \Magento\DB\Adapter\AdapterInterface $adapter - * @return \Magento\Core\Model\Resource\Iterator + * @return \Magento\Model\Resource\Iterator */ public function walk($query, array $callbacks, array $args = array(), $adapter = null) { @@ -66,7 +62,7 @@ public function walk($query, array $callbacks, array $args = array(), $adapter = * @param \Zend_Db_Statement_Interface|Zend_Db_Select|string $query * @param \Zend_Db_Adapter_Abstract $conn * @return \Zend_Db_Statement_Interface - * @throws \Magento\Core\Exception + * @throws \Magento\Model\Exception */ protected function _getStatement($query, $conn = null) { @@ -80,11 +76,11 @@ protected function _getStatement($query, $conn = null) if (is_string($query)) { if (!$conn instanceof \Zend_Db_Adapter_Abstract) { - throw new \Magento\Core\Exception(__('Invalid connection')); + throw new \Magento\Model\Exception(__('Invalid connection')); } return $conn->query($query); } - throw new \Magento\Core\Exception(__('Invalid query')); + throw new \Magento\Model\Exception(__('Invalid query')); } } diff --git a/app/code/Magento/Core/Model/Resource/Type/AbstractType.php b/lib/Magento/Model/Resource/Type/AbstractType.php similarity index 89% rename from app/code/Magento/Core/Model/Resource/Type/AbstractType.php rename to lib/Magento/Model/Resource/Type/AbstractType.php index 095b349949f81..e7c006c937e3b 100644 --- a/app/code/Magento/Core/Model/Resource/Type/AbstractType.php +++ b/lib/Magento/Model/Resource/Type/AbstractType.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Type; +namespace Magento\Model\Resource\Type; abstract class AbstractType { @@ -39,7 +37,7 @@ abstract class AbstractType * * @var String */ - protected $_entityClass = 'Magento\Core\Model\Resource\Entity\AbstractEntity'; + protected $_entityClass = 'Magento\Model\Resource\Entity\AbstractEntity'; /** * Retrieve entity type diff --git a/app/code/Magento/Core/Model/Resource/Type/Db.php b/lib/Magento/Model/Resource/Type/Db.php similarity index 80% rename from app/code/Magento/Core/Model/Resource/Type/Db.php rename to lib/Magento/Model/Resource/Type/Db.php index 68df0a5500cfb..189b81158510a 100644 --- a/app/code/Magento/Core/Model/Resource/Type/Db.php +++ b/lib/Magento/Model/Resource/Type/Db.php @@ -18,20 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Type; +namespace Magento\Model\Resource\Type; -abstract class Db extends \Magento\Core\Model\Resource\Type\AbstractType +abstract class Db extends \Magento\Model\Resource\Type\AbstractType { /** * Constructor */ public function __construct() { - $this->_entityClass = 'Magento\Core\Model\Resource\Entity\Table'; + $this->_entityClass = 'Magento\Model\Resource\Entity\Table'; } } diff --git a/app/code/Magento/Core/Model/Resource/Type/Db/Pdo/Mysql.php b/lib/Magento/Model/Resource/Type/Db/Pdo/Mysql.php similarity index 95% rename from app/code/Magento/Core/Model/Resource/Type/Db/Pdo/Mysql.php rename to lib/Magento/Model/Resource/Type/Db/Pdo/Mysql.php index 82b0d8b36231f..c8d7a0884d43f 100644 --- a/app/code/Magento/Core/Model/Resource/Type/Db/Pdo/Mysql.php +++ b/lib/Magento/Model/Resource/Type/Db/Pdo/Mysql.php @@ -21,9 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Resource\Type\Db\Pdo; +namespace Magento\Model\Resource\Type\Db\Pdo; -class Mysql extends \Magento\Core\Model\Resource\Type\Db implements \Magento\App\Resource\ConnectionAdapterInterface +class Mysql extends \Magento\Model\Resource\Type\Db implements \Magento\App\Resource\ConnectionAdapterInterface { /** * Filesystem class diff --git a/lib/Magento/Module/Declaration/Reader/Filesystem.php b/lib/Magento/Module/Declaration/Reader/Filesystem.php index af33aa214314a..4a9fa5a8f7797 100644 --- a/lib/Magento/Module/Declaration/Reader/Filesystem.php +++ b/lib/Magento/Module/Declaration/Reader/Filesystem.php @@ -34,6 +34,10 @@ class Filesystem extends \Magento\Config\Reader\Filesystem { + /** + * Allowed modules + */ + const PARAM_ALLOWED_MODULES = 'allowed_modules'; /** * The list of allowed modules * diff --git a/lib/Magento/Mview/View/Subscription.php b/lib/Magento/Mview/View/Subscription.php index ef8396f97464d..d9f23edb5c3b8 100644 --- a/lib/Magento/Mview/View/Subscription.php +++ b/lib/Magento/Mview/View/Subscription.php @@ -86,7 +86,7 @@ public function __construct( \Magento\App\Resource $resource, \Magento\DB\Ddl\TriggerFactory $triggerFactory, \Magento\Mview\View\CollectionInterface $viewCollection, - $view, + \Magento\Mview\ViewInterface $view, $tableName, $columnName ) { @@ -97,9 +97,6 @@ public function __construct( $this->tableName = $tableName; $this->columnName = $columnName; $this->resource = $resource; - - // Force collection clear - $this->viewCollection->clear(); } /** diff --git a/lib/Magento/Outbound/Authentication/Factory.php b/lib/Magento/Outbound/Authentication/Factory.php deleted file mode 100644 index 22541b23d84c7..0000000000000 --- a/lib/Magento/Outbound/Authentication/Factory.php +++ /dev/null @@ -1,75 +0,0 @@ -_authenticationMap = $authenticationMap; - $this->_objectManager = $objectManager; - } - - /** - * Returns an Authentication that matches the type specified within Endpoint - * - * @param string $authenticationType - * @return AuthenticationInterface - * @throws \LogicException - */ - public function getAuthentication($authenticationType) - { - if (!isset($this->_authenticationMap[$authenticationType])) { - throw new \LogicException("There is no authentication for the type given: {$authenticationType}"); - } - - $authentication = $this->_objectManager->get($this->_authenticationMap[$authenticationType]); - if (!$authentication instanceof AuthenticationInterface) { - throw new \LogicException( - "Authentication class for {$authenticationType} does not implement authentication interface" - ); - } - return $authentication; - } -} diff --git a/lib/Magento/Outbound/Authentication/Hmac.php b/lib/Magento/Outbound/Authentication/Hmac.php deleted file mode 100644 index 067c1551d4ada..0000000000000 --- a/lib/Magento/Outbound/Authentication/Hmac.php +++ /dev/null @@ -1,94 +0,0 @@ -_storeManager = $storeManager; - } - - /** - * Get authentication signature to add to the headers - * - * @param string $body - * @param UserInterface $user - * @return array Headers to add to message - * @throws \LogicException - */ - public function getSignatureHeaders($body, UserInterface $user) - { - $secret = $user->getSharedSecret(); - if ('' === $secret || is_null($secret)) { - throw new \LogicException('The shared secret cannot be empty.'); - } - - // Add HMAC Signature - $signature = hash_hmac(self::SHA256_ALGORITHM, $body, $secret); - return array(self::DOMAIN_HEADER => $this->_getDomain(), self::HMAC_HEADER => $signature); - } - - /** - * An overridable method to get the domain name - * - * @return array|bool - */ - protected function _getDomain() - { - return parse_url($this->_storeManager->getSafeStore()->getBaseUrl(UrlInterface::URL_TYPE_WEB), PHP_URL_HOST); - } -} diff --git a/lib/Magento/Outbound/AuthenticationInterface.php b/lib/Magento/Outbound/AuthenticationInterface.php deleted file mode 100644 index 06af4943d08de..0000000000000 --- a/lib/Magento/Outbound/AuthenticationInterface.php +++ /dev/null @@ -1,41 +0,0 @@ -_formatterMap = $formatterMap; - $this->_objectManager = $objectManager; - } - - /** - * Get formatter for specified format - * - * @param string $format - * @return FormatterInterface - * @throws \LogicException - */ - public function getFormatter($format) - { - if (!isset($this->_formatterMap[$format])) { - throw new \LogicException("There is no formatter for the format given: {$format}"); - } - $formatterClassName = $this->_formatterMap[$format]; - - $formatter = $this->_objectManager->get($formatterClassName); - if (!$formatter instanceof FormatterInterface) { - throw new \LogicException("Formatter class for {$format} does not implement FormatterInterface."); - } - return $formatter; - } -} diff --git a/lib/Magento/Outbound/Formatter/Json.php b/lib/Magento/Outbound/Formatter/Json.php deleted file mode 100644 index 7ead0bd109a66..0000000000000 --- a/lib/Magento/Outbound/Formatter/Json.php +++ /dev/null @@ -1,62 +0,0 @@ -_endpointUrl = $endpointUrl; - $this->_headers = $headers; - $this->_body = $body; - $this->_timeout = $timeout; - } - - /** - * return endpoint url - * - * @return string - */ - public function getEndpointUrl() - { - return $this->_endpointUrl; - } - - /** - * Return headers array - * - * @return array - */ - public function getHeaders() - { - return $this->_headers; - } - - /** - * return body - * - * @return string|null - */ - public function getBody() - { - return $this->_body; - } - - /** - * return timeout in seconds - * - * @return int - */ - public function getTimeout() - { - return $this->_timeout; - } -} diff --git a/lib/Magento/Outbound/Message/Factory.php b/lib/Magento/Outbound/Message/Factory.php deleted file mode 100644 index 20c43be8881a2..0000000000000 --- a/lib/Magento/Outbound/Message/Factory.php +++ /dev/null @@ -1,109 +0,0 @@ -_objectManager = $objectManager; - $this->_formatterFactory = $formatterFactory; - $this->_authFactory = $authFactory; - } - - /** - * Create a message for a given endpoint, topic and message data - * - * @param EndpointInterface $endpoint - * @param string $topic topic of the message - * @param array $bodyData body of the message - * @return Message - */ - 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( - FactoryInterface::TOPIC_HEADER => $topic, - FormatterInterface::CONTENT_TYPE_HEADER => $formatter->getContentType() - ); - $formattedBody = $formatter->format($bodyData); - - $headers = array_merge( - $headers, - $this->_authFactory->getAuthentication( - $endpoint->getAuthenticationType() - )->getSignatureHeaders( - $formattedBody, - $endpoint->getUser() - ) - ); - - return $this->_objectManager->create( - 'Magento\Outbound\Message', - array( - 'endpointUrl' => $endpoint->getEndpointUrl(), - 'headers' => $headers, - 'body' => $formattedBody, - 'timeout' => $endpoint->getTimeoutInSecs() - ) - ); - } -} diff --git a/lib/Magento/Outbound/Message/FactoryInterface.php b/lib/Magento/Outbound/Message/FactoryInterface.php deleted file mode 100644 index baaef67d6b9ef..0000000000000 --- a/lib/Magento/Outbound/Message/FactoryInterface.php +++ /dev/null @@ -1,44 +0,0 @@ -_curl = $curl; - } - - /** - * Dispatch message and return response - * - * @param MessageInterface $message - * @return Response - */ - public function dispatch(MessageInterface $message) - { - $config = array('verifypeer' => true, 'verifyhost' => 2); - - $timeout = $message->getTimeout(); - if (!is_null($timeout) && $timeout > 0) { - $config['timeout'] = $timeout; - } else { - $config['timeout'] = Message::DEFAULT_TIMEOUT; - } - $this->_curl->setConfig($config); - - $this->_curl->write( - \Zend_Http_Client::POST, - $message->getEndpointUrl(), - self::HTTP_VERSION, - $this->_prepareHeaders($message->getHeaders()), - $message->getBody() - ); - - return new Response($this->_curl->read()); - } - - /** - * Prepare headers for dispatch - * - * @param string[] $headers - * @return string[] - */ - protected function _prepareHeaders($headers) - { - $result = array(); - foreach ($headers as $headerName => $headerValue) { - $result[] = sprintf('%s: %s', $headerName, $headerValue); - } - return $result; - } -} diff --git a/lib/Magento/Outbound/Transport/Http/Response.php b/lib/Magento/Outbound/Transport/Http/Response.php deleted file mode 100644 index f93615b0cdb05..0000000000000 --- a/lib/Magento/Outbound/Transport/Http/Response.php +++ /dev/null @@ -1,111 +0,0 @@ -_response = \Zend_Http_Response::fromString($string); - } - - /** - * Describes whether response code indicates success - * - * @return bool - */ - public function isSuccessful() - { - return $this->_response->isSuccessful(); - } - - /** - * Gets response status - * - * @return int - */ - public function getStatusCode() - { - return $this->_response->getStatus(); - } - - /** - * Gets response header - * - * @return string - */ - public function getMessage() - { - return $this->_response->getMessage(); - } - - /** - * Gets response body - * - * This class is just hiding the 'getBody' function since calling that after our curl library has already decoded - * the body, could cause an error. A perfect example is if the response for our curl call was gzip'ed, curl would - * have gunzipped it but left the header indicating it was compressed, then \Zend_Http_Response::getBody() would - * attempt to decompress the raw body, which was already decompressed, causing an error/corruption. - * - * @return string - */ - public function getBody() - { - // CURL Doesn't give us access to a truly RAW body, so calling getBody() will fail if Transfer-Encoding is set - return $this->_response->getRawBody(); - } - - /** - * Gets response headers - * - * @return array - */ - public function getHeaders() - { - return $this->_response->getHeaders(); - } - - /** - * Gets a given response header - * - * @param string $headerName - * @return array|null|string - */ - public function getHeader($headerName) - { - return $this->_response->getHeader($headerName); - } -} diff --git a/lib/Magento/Outbound/TransportInterface.php b/lib/Magento/Outbound/TransportInterface.php deleted file mode 100644 index db0f97a48a835..0000000000000 --- a/lib/Magento/Outbound/TransportInterface.php +++ /dev/null @@ -1,39 +0,0 @@ -render($this->_text, $this->_arguments) : $this->_text; + return self::$_renderer ? self::$_renderer->render([$this->_text], $this->_arguments) : $this->_text; } /** diff --git a/lib/Magento/Phrase/Renderer/Composite.php b/lib/Magento/Phrase/Renderer/Composite.php index 0cd02bf2adbbf..621f03d83bd06 100644 --- a/lib/Magento/Phrase/Renderer/Composite.php +++ b/lib/Magento/Phrase/Renderer/Composite.php @@ -51,17 +51,18 @@ public function __construct(array $renderers) } /** - * Render result text + * Render source text * - * @param string $text - * @param array $arguments + * @param [] $source + * @param [] $arguments * @return string */ - public function render($text, array $arguments = array()) + public function render(array $source, array $arguments = array()) { + $result = $source; foreach ($this->_renderers as $render) { - $text = $render->render($text, $arguments); + $result[] = $render->render($result, $arguments); } - return $text; + return end($result); } } diff --git a/lib/Magento/Phrase/Renderer/Inline.php b/lib/Magento/Phrase/Renderer/Inline.php new file mode 100644 index 0000000000000..4d7d9fa808775 --- /dev/null +++ b/lib/Magento/Phrase/Renderer/Inline.php @@ -0,0 +1,78 @@ +translator = $translator; + $this->inlineProvider = $inlineProvider; + } + + /** + * Render source text + * + * @param [] $source + * @param [] $arguments + * @return string + */ + public function render(array $source, array $arguments) + { + $text = end($source); + + if (!$this->inlineProvider->get()->isAllowed()) { + return $text; + } + + if (strpos($text, '{{{') === false + || strpos($text, '}}}') === false + || strpos($text, '}}{{') === false + ) { + $text = '{{{' + . implode('}}{{', array_reverse($source)) + . '}}{{' . $this->translator->getTheme() . '}}}'; + } + + return $text; + } +} diff --git a/lib/Magento/Phrase/Renderer/Placeholder.php b/lib/Magento/Phrase/Renderer/Placeholder.php index 80c38da33ed20..e2cda7057c901 100644 --- a/lib/Magento/Phrase/Renderer/Placeholder.php +++ b/lib/Magento/Phrase/Renderer/Placeholder.php @@ -28,14 +28,16 @@ class Placeholder implements \Magento\Phrase\RendererInterface { /** - * {@inheritdoc} + * Render source text * - * @param string $text - * @param array $arguments + * @param [] $source + * @param [] $arguments * @return string */ - public function render($text, array $arguments) + public function render(array $source, array $arguments) { + $text = end($source); + if ($arguments) { $placeholders = array(); foreach (array_keys($arguments) as $key) { @@ -43,6 +45,7 @@ public function render($text, array $arguments) } $text = str_replace($placeholders, $arguments, $text); } + return $text; } } diff --git a/lib/Magento/Phrase/Renderer/Translate.php b/lib/Magento/Phrase/Renderer/Translate.php index 97d6027c7a5db..89b990cc4a99f 100644 --- a/lib/Magento/Phrase/Renderer/Translate.php +++ b/lib/Magento/Phrase/Renderer/Translate.php @@ -28,11 +28,9 @@ class Translate implements \Magento\Phrase\RendererInterface { /** - * Basic object for translation - * * @var \Magento\TranslateInterface */ - protected $_translator; + protected $translator; /** * Renderer construct @@ -41,20 +39,33 @@ class Translate implements \Magento\Phrase\RendererInterface */ public function __construct(\Magento\TranslateInterface $translator) { - $this->_translator = $translator; + $this->translator = $translator; } /** - * {@inheritdoc} + * Render source text * - * @param string $text - * @param array $arguments + * @param [] $source + * @param [] $arguments * @return string */ - public function render($text, array $arguments) + public function render(array $source, array $arguments) { - array_unshift($arguments, $text); + $text = end($source); + + $code = $this->translator->getTheme() + . \Magento\View\Service::SCOPE_SEPARATOR + . $text; + + $data = $this->translator->getData(); + + if (array_key_exists($code, $data)) { + return $data[$code]; + } + if (array_key_exists($text, $data)) { + return $data[$text]; + } - return call_user_func(array($this->_translator, 'translate'), $arguments); + return $text; } } diff --git a/lib/Magento/Phrase/RendererInterface.php b/lib/Magento/Phrase/RendererInterface.php index aa9b6526926a4..7540d233ac6c3 100644 --- a/lib/Magento/Phrase/RendererInterface.php +++ b/lib/Magento/Phrase/RendererInterface.php @@ -28,11 +28,11 @@ interface RendererInterface { /** - * Render result text + * Render source text * - * @param string $text - * @param array $arguments + * @param [] $source + * @param [] $arguments * @return string */ - public function render($text, array $arguments); + public function render(array $source, array $arguments); } diff --git a/lib/Magento/PubSub/Event.php b/lib/Magento/PubSub/Event.php deleted file mode 100644 index fd1a7cc44c345..0000000000000 --- a/lib/Magento/PubSub/Event.php +++ /dev/null @@ -1,124 +0,0 @@ -_topic = $topic; - $this->_bodyData = $bodyData; - } - - /** - * Returns the status code of the event. Status indicates if the event has been processed - * or not. - * - * @return int - */ - public function getStatus() - { - return $this->_status; - } - - /** - * Returns a PHP array of data that represents what should be included in the message body. - * - * @return array - */ - public function getBodyData() - { - return $this->_bodyData; - } - - /** - * Prepare headers before return - * - * @return array - */ - public function getHeaders() - { - return $this->_headers; - } - - /** - * Returns a PHP string representing the topic of WebHook - * - * @return string - */ - public function getTopic() - { - return $this->_topic; - } - - /** - * Mark event as processed - * - * @return $this - */ - public function complete() - { - $this->_status = EventInterface::STATUS_PROCESSED; - return $this; - } - - /** - * Mark event as processed - * - * @return $this - */ - public function markAsInProgress() - { - $this->_status = EventInterface::STATUS_IN_PROGRESS; - return $this; - } -} diff --git a/lib/Magento/PubSub/Event/Factory.php b/lib/Magento/PubSub/Event/Factory.php deleted file mode 100644 index 4f31380791219..0000000000000 --- a/lib/Magento/PubSub/Event/Factory.php +++ /dev/null @@ -1,43 +0,0 @@ -_eventQueue = $eventQueue; - $this->_jobQueue = $jobQueue; - $this->_jobFactory = $jobFactory; - $this->_subscriptionSet = $subscriptionSet; - } - - /** - * Build job queue from event queue - * - * @return void - */ - public function handle() - { - $event = $this->_eventQueue->poll(); - while (!is_null($event)) { - $subscriptions = $this->_subscriptionSet->getSubscriptionsByTopic($event->getTopic()); - foreach ($subscriptions as $subscription) { - /** @var $job \Magento\PubSub\JobInterface */ - $job = $this->_jobFactory->create($subscription, $event); - $this->_jobQueue->offer($job); - } - $event->complete(); - $event = $this->_eventQueue->poll(); - } - } -} diff --git a/lib/Magento/PubSub/Event/QueueReaderInterface.php b/lib/Magento/PubSub/Event/QueueReaderInterface.php deleted file mode 100644 index 7f230bcb5cdc2..0000000000000 --- a/lib/Magento/PubSub/Event/QueueReaderInterface.php +++ /dev/null @@ -1,38 +0,0 @@ -_jobQueueReader = $jobQueueReader; - $this->_jobQueueWriter = $jobQueueWriter; - $this->_transport = $transport; - $this->_messageFactory = $messageFactory; - } - - /** - * Process the queue of jobs - * @return null - */ - public function handle() - { - $job = $this->_jobQueueReader->poll(); - while (!is_null($job)) { - $event = $job->getEvent(); - $message = $this->_messageFactory->create( - $job->getSubscription()->getEndpoint(), - $event->getTopic(), - $event->getBodyData() - ); - $response = $this->_transport->dispatch($message); - if ($response->isSuccessful()) { - $job->complete(); - } else { - $job->handleFailure(); - $this->_jobQueueWriter->offer($job); - } - $job = $this->_jobQueueReader->poll(); - } - } -} diff --git a/lib/Magento/PubSub/Job/QueueReaderInterface.php b/lib/Magento/PubSub/Job/QueueReaderInterface.php deleted file mode 100644 index d1e40e40a699f..0000000000000 --- a/lib/Magento/PubSub/Job/QueueReaderInterface.php +++ /dev/null @@ -1,38 +0,0 @@ -_eventFactory = $eventFactory; - $this->_eventQueue = $eventQueue; - } - - /** - * Dispatch event with given topic and data - * - * @param string $topic - * @param array $data should only contain primitives, no objects. - * @return void - */ - public function dispatch($topic, $data) - { - $event = $this->_eventFactory->create($topic, $data); - $this->_eventQueue->offer($event); - } -} diff --git a/lib/Magento/PubSub/Message/DispatcherAsyncInterface.php b/lib/Magento/PubSub/Message/DispatcherAsyncInterface.php deleted file mode 100644 index 5dfaff943ebbb..0000000000000 --- a/lib/Magento/PubSub/Message/DispatcherAsyncInterface.php +++ /dev/null @@ -1,40 +0,0 @@ -_viewDesign = $viewDesign; - $this->_localeHierarchy = $config->getHierarchy(); - $this->_translateFactory = $translateFactory; $this->_cache = $cache; $this->_viewFileSystem = $viewFileSystem; - $this->_placeholderRender = $placeholderRender; $this->_moduleList = $moduleList; $this->_modulesReader = $modulesReader; $this->_scopeResolver = $scopeResolver; $this->_translateResource = $translate; $this->_locale = $locale; $this->_appState = $appState; - $this->filesystem = $filesystem; + $this->request = $request; $this->directory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::ROOT_DIR); - $this->_eventManager = $eventManager; + $this->_localeHierarchy = $config->getHierarchy(); } /** - * Initialization translation data + * Initialize translation data * - * @param string $area - * @param \Magento\Object $initParams + * @param string|null $area * @param bool $forceReload * @return $this */ - public function init($area = null, $initParams = null, $forceReload = false) + public function loadData($area = null, $forceReload = false) { - $area = isset($area) ? $area : $this->_appState->getAreaCode(); - $this->setConfig(array(self::CONFIG_KEY_AREA => $area)); - - $this->_translateInline = $this->getInlineObject($initParams)->isAllowed(); + $this->setConfig( + ['area' => isset($area) ? $area : $this->_appState->getAreaCode()] + ); if (!$forceReload) { $this->_data = $this->_loadCache(); @@ -266,14 +191,12 @@ public function init($area = null, $initParams = null, $forceReload = false) return $this; } } - - $this->_data = array(); + $this->_data = []; foreach ($this->_moduleList->getModules() as $module) { $this->_loadModuleTranslation($module['name']); } - - $this->_loadThemeTranslation($forceReload, $area); + $this->_loadThemeTranslation($forceReload); $this->_loadDbTranslation($forceReload); if (!$forceReload) { @@ -292,18 +215,29 @@ public function init($area = null, $initParams = null, $forceReload = false) protected function setConfig($config) { $this->_config = $config; - if (!isset($this->_config[self::CONFIG_KEY_LOCALE])) { - $this->_config[self::CONFIG_KEY_LOCALE] = $this->getLocale(); + if (!isset($this->_config['locale'])) { + $this->_config['locale'] = $this->getLocale(); } - if (!isset($this->_config[self::CONFIG_KEY_SCOPE])) { - $this->_config[self::CONFIG_KEY_SCOPE] = $this->_scopeResolver->getScope()->getCode(); + if (!isset($this->_config['scope'])) { + $this->_config['scope'] = $this->getScope(); } - if (!isset($this->_config[self::CONFIG_KEY_DESIGN_THEME])) { - $this->_config[self::CONFIG_KEY_DESIGN_THEME] = $this->_viewDesign->getDesignTheme()->getId(); + if (!isset($this->_config['theme'])) { + $this->_config['theme'] = $this->_viewDesign->getDesignTheme()->getId(); } return $this; } + /** + * Retrieve scope code + * + * @return string + */ + protected function getScope() + { + $scope = ($this->getConfig('area') == 'adminhtml') ? 'admin' : null; + return $this->_scopeResolver->getScope($scope)->getCode(); + } + /** * Retrieve config value by key * @@ -318,17 +252,6 @@ protected function getConfig($key) return null; } - /** - * Determine if translation is enabled and allowed. - * - * @param mixed $scope - * @return bool - */ - public function isAllowed($scope = null) - { - return $this->getInlineObject()->isAllowed($scope); - } - /** * Load data from module translation files * @@ -374,20 +297,22 @@ protected function _addData($data, $scope = false, $forceReload = false) if ($key === $value) { continue; } - $key = $this->_prepareDataString($key); - $value = $this->_prepareDataString($value); + + $key = str_replace('""', '"', $key); + $value = str_replace('""', '"', $value); + if ($scope && isset($this->_dataScope[$key]) && !$forceReload) { /** * Checking previous value */ - $scopeKey = $this->_dataScope[$key] . self::SCOPE_SEPARATOR . $key; + $scopeKey = $this->_dataScope[$key] . \Magento\View\Service::SCOPE_SEPARATOR . $key; if (!isset($this->_data[$scopeKey])) { if (isset($this->_data[$key])) { $this->_data[$scopeKey] = $this->_data[$key]; unset($this->_data[$key]); } } - $scopeKey = $scope . self::SCOPE_SEPARATOR . $key; + $scopeKey = $scope . \Magento\View\Service::SCOPE_SEPARATOR . $key; $this->_data[$scopeKey] = $value; } else { $this->_data[$key] = $value; @@ -397,38 +322,22 @@ protected function _addData($data, $scope = false, $forceReload = false) return $this; } - /** - * Prepare data string - * - * @param string $string - * @return string - */ - protected function _prepareDataString($string) - { - return str_replace('""', '"', $string); - } - /** * Load current theme translation * * @param bool $forceReload - * @param string|null $area * @return $this */ - protected function _loadThemeTranslation($forceReload = false, $area = null) + protected function _loadThemeTranslation($forceReload = false) { - if (!$this->_config[self::CONFIG_KEY_DESIGN_THEME]) { + if (!$this->_config['theme']) { return $this; } $requiredLocaleList = $this->_composeRequiredLocaleList($this->getLocale()); foreach ($requiredLocaleList as $locale) { - $file = $this->_getThemeTranslationFile($locale, $area); - $this->_addData( - $this->_getFileData($file), - self::CONFIG_KEY_DESIGN_THEME . $this->_config[self::CONFIG_KEY_DESIGN_THEME], - $forceReload - ); + $file = $this->_getThemeTranslationFile($locale); + $this->_addData($this->_getFileData($file), 'theme' . $this->_config['theme'], $forceReload); } return $this; } @@ -444,7 +353,7 @@ protected function _loadDbTranslation($forceReload = false) $requiredLocaleList = $this->_composeRequiredLocaleList($this->getLocale()); foreach ($requiredLocaleList as $locale) { $arr = $this->_translateResource->getTranslationArray(null, $locale); - $this->_addData($arr, $this->getConfig(self::CONFIG_KEY_SCOPE), $forceReload); + $this->_addData($arr, $this->getConfig('scope'), $forceReload); } return $this; } @@ -467,15 +376,13 @@ protected function _getModuleTranslationFile($moduleName, $locale) * Retrieve translation file for theme * * @param string $locale - * @param string|null $area * @return string */ - protected function _getThemeTranslationFile($locale, $area = null) + protected function _getThemeTranslationFile($locale) { - $area = isset($area) ? $area : $this->_appState->getAreaCode(); return $this->_viewFileSystem->getFilename( \Magento\App\Filesystem::LOCALE_DIR . '/' . $locale . '.csv', - array('area' => $area) + ['area' => $this->getConfig('area')] ); } @@ -490,7 +397,7 @@ protected function _getFileData($file) $data = array(); if ($this->directory->isExist($this->directory->getRelativePath($file))) { $parser = new \Magento\File\Csv(); - $parser->setDelimiter(self::CSV_SEPARATOR); + $parser->setDelimiter(','); $data = $parser->getDataPairs($file); } return $data; @@ -501,7 +408,7 @@ protected function _getFileData($file) * * @return array */ - protected function getData() + public function getData() { if (is_null($this->_data)) { return array(); @@ -514,7 +421,7 @@ protected function getData() * * @return string */ - protected function getLocale() + public function getLocale() { if (null === $this->_localeCode) { $this->_localeCode = $this->_locale->getLocaleCode(); @@ -526,7 +433,7 @@ protected function getLocale() * Set locale * * @param string $locale - * @return $this + * @return \Magento\TranslateInterface */ public function setLocale($locale) { @@ -535,83 +442,17 @@ public function setLocale($locale) } /** - * Translate + * Retrieve theme code * - * @param array $args * @return string - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - public function translate($args) - { - $text = array_shift($args); - - if ($this->_isEmptyTranslateArg($text)) { - return ''; - } - - if (!empty($_REQUEST['theme'])) { - $module = self::CONFIG_KEY_DESIGN_THEME . $_REQUEST['theme']['theme_title']; - } else { - $module = self::CONFIG_KEY_DESIGN_THEME . $this->_config[self::CONFIG_KEY_DESIGN_THEME]; - } - $code = $module . self::SCOPE_SEPARATOR . $text; - $translated = $this->_getTranslatedString($text, $code); - $result = $this->_placeholderRender->render($translated, $args); - - if ($this->_translateInline && $this->getTranslateInline()) { - if (strpos( - $result, - '{{{' - ) === false || strpos( - $result, - '}}}' - ) === false || strpos( - $result, - '}}{{' - ) === false - ) { - $result = '{{{' . $result . '}}{{' . $translated . '}}{{' . $text . '}}{{' . $module . '}}}'; - } - } - return $result; - } - - /** - * Check is empty translate argument - * - * @param mixed $text - * @return bool */ - protected function _isEmptyTranslateArg($text) + public function getTheme() { - if (is_object($text) && is_callable(array($text, 'getText'))) { - $text = $text->getText(); + $theme = $this->request->getParam('theme'); + if (empty($theme)) { + return 'theme' . $this->getConfig('theme'); } - return empty($text); - } - - /** - * Set Translate inline mode - * - * @param bool $flag - * @return $this - */ - public function setTranslateInline($flag = false) - { - $this->_canUseInline = $flag; - return $this; - } - - /** - * Retrieve active translate mode - * - * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) - */ - public function getTranslateInline() - { - return $this->_canUseInline; + return 'theme' . $theme['theme_title']; } /** @@ -621,19 +462,19 @@ public function getTranslateInline() */ protected function getCacheId() { - if (is_null($this->_cacheId)) { + if ($this->_cacheId === null) { $this->_cacheId = \Magento\App\Cache\Type\Translate::TYPE_IDENTIFIER; - if (isset($this->_config[self::CONFIG_KEY_LOCALE])) { - $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_LOCALE]; + if (isset($this->_config['locale'])) { + $this->_cacheId .= '_' . $this->_config['locale']; } - if (isset($this->_config[self::CONFIG_KEY_AREA])) { - $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_AREA]; + if (isset($this->_config['area'])) { + $this->_cacheId .= '_' . $this->_config['area']; } - if (isset($this->_config[self::CONFIG_KEY_SCOPE])) { - $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_SCOPE]; + if (isset($this->_config['scope'])) { + $this->_cacheId .= '_' . $this->_config['scope']; } - if (isset($this->_config[self::CONFIG_KEY_DESIGN_THEME])) { - $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_DESIGN_THEME]; + if (isset($this->_config['theme'])) { + $this->_cacheId .= '_' . $this->_config['theme']; } } return $this->_cacheId; @@ -663,64 +504,4 @@ protected function _saveCache() $this->_cache->save(serialize($this->getData()), $this->getCacheId(), array(), false); return $this; } - - /** - * Return translated string from text. - * - * @param string $text - * @param string $code - * @return string - */ - protected function _getTranslatedString($text, $code) - { - if (array_key_exists($code, $this->getData())) { - $translated = $this->_data[$code]; - } elseif (array_key_exists($text, $this->getData())) { - $translated = $this->_data[$text]; - } else { - $translated = $text; - } - return $translated; - } - - /** - * Returns the translate interface object. - * - * @param \Magento\Object $initParams - * @return \Magento\Translate\InlineInterface - */ - protected function getInlineObject($initParams = null) - { - if (null === $this->_inlineInterface) { - if ($initParams === null) { - $this->_inlineInterface = $this->_translateFactory->create(); - } else { - $this->_inlineInterface = $this->_translateFactory->create( - $initParams->getParams(), - $initParams->getInlineType() - ); - } - } - return $this->_inlineInterface; - } - - /** - * This method initializes the Translate object for this instance. - * - * @param string $localeCode - * @param string|null $area - * @return \Magento\TranslateInterface - */ - public function initLocale($localeCode, $area = null) - { - $this->setLocale($localeCode); - - $dispatchResult = new \Magento\Object(array('inline_type' => null)); - $this->_eventManager->dispatch( - 'translate_initialization_before', - array('translate_object' => $this, 'result' => $dispatchResult) - ); - $this->init($area, $dispatchResult, true); - return $this; - } } diff --git a/lib/Magento/Translate/Factory.php b/lib/Magento/Translate/Factory.php deleted file mode 100644 index d776e49a9b24f..0000000000000 --- a/lib/Magento/Translate/Factory.php +++ /dev/null @@ -1,72 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Return instance of inline translate object based on passed in class name. - * - * @param array $data - * @param string $className - * @throws \InvalidArgumentException - * @return \Magento\Translate\InlineInterface - */ - public function create(array $data = null, $className = null) - { - if ($className === null) { - $className = self::DEFAULT_CLASS_NAME; - } - $model = $this->_objectManager->get($className, $data); - if (!$model instanceof \Magento\Translate\InlineInterface) { - throw new \InvalidArgumentException('Invalid inline translate model: ' . $className); - } - return $model; - } -} diff --git a/lib/Magento/Translate/Inline.php b/lib/Magento/Translate/Inline.php index 3645abf2c9205..c40e588b49cd1 100644 --- a/lib/Magento/Translate/Inline.php +++ b/lib/Magento/Translate/Inline.php @@ -29,134 +29,123 @@ class Inline implements \Magento\Translate\InlineInterface { - /** - * Regular Expression for detected and replace translate - * - * @var string - */ - protected $_tokenRegex = '\{\{\{(.*?)\}\}\{\{(.*?)\}\}\{\{(.*?)\}\}\{\{(.*?)\}\}\}'; - - /** - * @var \Magento\TranslateInterface - */ - protected $_translator; - /** * Indicator to hold state of whether inline translation is allowed * * @var bool */ - protected $_isAllowed; + protected $isAllowed; /** - * @var \Magento\Translate\Inline\ParserFactory + * @var \Magento\Translate\Inline\ParserInterface */ - protected $_parserFactory; + protected $parser; /** * Flag about inserted styles and scripts for inline translates * * @var bool */ - protected $_isScriptInserted = false; + protected $isScriptInserted = false; /** * @var \Magento\UrlInterface */ - protected $_url; + protected $url; /** * @var \Magento\View\LayoutInterface */ - protected $_layout; + protected $layout; /** - * @var \Magento\App\State + * @var \Magento\Translate\Inline\ConfigInterface */ - protected $_appState; + protected $config; /** - * @var \Magento\Translate\Inline\ConfigFactory + * @var \Magento\BaseScopeResolverInterface */ - protected $_configFactory; + protected $scopeResolver; /** - * @var \Magento\BaseScopeResolverInterface + * @var string */ - protected $_scopeResolver; + protected $templateFileName; /** * @var string */ - protected $_templateFileName = ''; + protected $translatorRoute; /** - * @var string + * @var null|string */ - protected $_translatorRoute = ''; + protected $scope; + + /** + * @var Inline\StateInterface + */ + protected $state; /** - * Initialize inline translation model - * * @param \Magento\BaseScopeResolverInterface $scopeResolver - * @param \Magento\Translate\Inline\ParserFactory $parserFactory - * @param \Magento\TranslateInterface $translate * @param \Magento\UrlInterface $url * @param \Magento\View\LayoutInterface $layout - * @param \Magento\Translate\Inline\ConfigFactory $configFactory - * @param \Magento\App\State $appState + * @param Inline\ConfigInterface $config + * @param Inline\ParserInterface $parser + * @param Inline\StateInterface $state * @param string $templateFileName * @param string $translatorRoute + * @param null $scope */ public function __construct( \Magento\BaseScopeResolverInterface $scopeResolver, - \Magento\Translate\Inline\ParserFactory $parserFactory, - \Magento\TranslateInterface $translate, \Magento\UrlInterface $url, \Magento\View\LayoutInterface $layout, - \Magento\Translate\Inline\ConfigFactory $configFactory, - \Magento\App\State $appState, + \Magento\Translate\Inline\ConfigInterface $config, + \Magento\Translate\Inline\ParserInterface $parser, + \Magento\Translate\Inline\StateInterface $state, $templateFileName = '', - $translatorRoute = '' + $translatorRoute = '', + $scope = null ) { - $this->_scopeResolver = $scopeResolver; - $this->_configFactory = $configFactory; - $this->_parserFactory = $parserFactory; - $this->_translator = $translate; - $this->_url = $url; - $this->_layout = $layout; - $this->_appState = $appState; - $this->_templateFileName = $templateFileName; - $this->_translatorRoute = $translatorRoute; + $this->scopeResolver = $scopeResolver; + $this->url = $url; + $this->layout = $layout; + $this->config = $config; + $this->parser = $parser; + $this->state = $state; + $this->templateFileName = $templateFileName; + $this->translatorRoute = $translatorRoute; + $this->scope = $scope; } /** - * Is enabled and allowed Inline Translates + * Check if Inline Translates is allowed * - * @param BaseScopeInterface|int|null $scope * @return bool */ - public function isAllowed($scope = null) + public function isAllowed() { - if (is_null($this->_isAllowed)) { - if (!$scope instanceof BaseScopeInterface) { - $scope = $this->_scopeResolver->getScope($scope); + if ($this->isAllowed === null) { + if (!$this->scope instanceof BaseScopeInterface) { + $scope = $this->scopeResolver->getScope($this->scope); } - - $config = $this->_configFactory->get(); - $this->_isAllowed = $config->isActive($scope) && $config->isDevAllowed($scope); + $this->isAllowed = $this->config->isActive($scope) + && $this->config->isDevAllowed($scope); } - return $this->_translator->getTranslateInline() && $this->_isAllowed; + return $this->state->isEnabled() && $this->isAllowed; } /** - * Disable inline translation functionality + * Retrieve Inline Parser instance * - * @return void + * @return Inline\ParserInterface */ - public function disable() + public function getParser() { - $this->_isAllowed = false; + return $this->parser; } /** @@ -168,22 +157,25 @@ public function disable() */ public function processResponseBody(&$body, $isJson = false) { - $parser = $this->_parserFactory->get(); - $parser->setIsJson($isJson); - if (!$this->isAllowed()) { + if ($this->scope == 'admin' && !$this->isAllowed()) { + $this->stripInlineTranslations($body); return $this; } + $this->getParser()->setIsJson($isJson); + if (is_array($body)) { foreach ($body as &$part) { $this->processResponseBody($part, $isJson); } } elseif (is_string($body)) { - $content = $parser->processResponseBodyString($body, $this); - $this->_insertInlineScriptsHtml($content); - $body = $parser->getContent(); + $this->getParser()->processResponseBodyString($body); + $this->addInlineScript(); + $body = $this->getParser()->getContent(); } - $parser->setIsJson(\Magento\Translate\Inline\ParserInterface::JSON_FLAG_DEFAULT_STATE); + + $this->getParser()->setIsJson(false); + return $this; } @@ -199,29 +191,42 @@ public function getAdditionalHtmlAttribute($tagName = null) } /** - * Create block to render script and html with added inline translation content. + * Add inline script code + * + * Insert script and html with + * added inline translation content. * - * @param string $content * @return void */ - protected function _insertInlineScriptsHtml($content) + protected function addInlineScript() { - if ($this->_isScriptInserted || stripos($content, '') === false) { + $content = $this->getParser()->getContent(); + if (stripos($content, '') === false) { return; } + if (!$this->isScriptInserted) { + $this->getParser()->setContent(str_ireplace('', $this->getInlineScript() . '', $content)); + $this->isScriptInserted = true; + } + } + /** + * Retrieve inline script code + * + * Create block to render script and html with + * added inline translation content. + * + * @return string + */ + protected function getInlineScript() + { /** @var $block \Magento\View\Element\Template */ - $block = $this->_layout->createBlock('Magento\View\Element\Template'); - - $block->setAjaxUrl($this->_getAjaxUrl()); - - $block->setTemplate($this->_templateFileName); - - $html = $block->toHtml(); + $block = $this->layout->createBlock('Magento\View\Element\Template'); - $this->_parserFactory->get()->setContent(str_ireplace('', $html . '', $content)); + $block->setAjaxUrl($this->getAjaxUrl()); + $block->setTemplate($this->templateFileName); - $this->_isScriptInserted = true; + return $block->toHtml(); } /** @@ -229,10 +234,12 @@ protected function _insertInlineScriptsHtml($content) * * @return string */ - protected function _getAjaxUrl() + protected function getAjaxUrl() { - $scope = $this->_scopeResolver->getScope(); - return $this->_url->getUrl($this->_translatorRoute, array('_secure' => $scope->isCurrentlySecure())); + return $this->url->getUrl( + $this->translatorRoute, + ['_secure' => $this->scopeResolver->getScope()->isCurrentlySecure()] + ); } /** @@ -241,14 +248,14 @@ protected function _getAjaxUrl() * @param array|string &$body * @return $this */ - protected function _stripInlineTranslations(&$body) + protected function stripInlineTranslations(&$body) { if (is_array($body)) { foreach ($body as &$part) { - $this->_stripInlineTranslations($part); + $this->stripInlineTranslations($part); } } else if (is_string($body)) { - $body = preg_replace('#' . $this->_tokenRegex . '#', '$1', $body); + $body = preg_replace('#' . \Magento\Translate\Inline\ParserInterface::REGEXP_TOKEN . '#', '$1', $body); } return $this; } diff --git a/lib/Magento/Translate/Inline/ConfigInterface.php b/lib/Magento/Translate/Inline/ConfigInterface.php index 602795dff4717..e11b50272a6ea 100644 --- a/lib/Magento/Translate/Inline/ConfigInterface.php +++ b/lib/Magento/Translate/Inline/ConfigInterface.php @@ -30,7 +30,7 @@ interface ConfigInterface /** * Check whether inline translation is enabled * - * @param int|null $scope + * @param null|string|bool|int|\Magento\Core\Model\Store $scope * @return bool */ public function isActive($scope = null); @@ -38,7 +38,7 @@ public function isActive($scope = null); /** * Check whether allowed client ip for inline translation * - * @param mixed $scope + * @param null|string|bool|int|\Magento\Core\Model\Store $scope * @return bool */ public function isDevAllowed($scope = null); diff --git a/lib/Magento/Translate/Inline/ParserFactory.php b/lib/Magento/Translate/Inline/ParserFactory.php index 22f3cb38db8c6..5b61f797c10e8 100644 --- a/lib/Magento/Translate/Inline/ParserFactory.php +++ b/lib/Magento/Translate/Inline/ParserFactory.php @@ -27,6 +27,11 @@ class ParserFactory { + /** + * Default instance type + */ + const DEFAULT_INSTANCE_TYPE = 'Magento\Translate\Inline\ParserInterface'; + /** * Object Manager * @@ -50,15 +55,15 @@ public function __construct(\Magento\ObjectManager $objectManager) */ public function get() { - return $this->_objectManager->get('Magento\Translate\Inline\ParserInterface'); + return $this->_objectManager->get(self::DEFAULT_INSTANCE_TYPE); } /** - * @param array $data + * @param array $arguments * @return \Magento\Translate\Inline\ParserInterface */ - public function create(array $data = null) + public function create(array $arguments = array()) { - return $this->_objectManager->create('Magento\Translate\Inline\ParserInterface', $data); + return $this->_objectManager->create(self::DEFAULT_INSTANCE_TYPE, $arguments); } } diff --git a/lib/Magento/Translate/Inline/ParserInterface.php b/lib/Magento/Translate/Inline/ParserInterface.php index b9265c685f70d..fe20466db7030 100644 --- a/lib/Magento/Translate/Inline/ParserInterface.php +++ b/lib/Magento/Translate/Inline/ParserInterface.php @@ -26,9 +26,9 @@ interface ParserInterface { /** - * Default state for jason flag + * Regular Expression for detected and replace translate */ - const JSON_FLAG_DEFAULT_STATE = false; + const REGEXP_TOKEN = '\{\{\{(.*?)\}\}\{\{(.*?)\}\}\{\{(.*?)\}\}\{\{(.*?)\}\}\}'; /** * Parse and save edited translation diff --git a/lib/Magento/Translate/Inline/ConfigFactory.php b/lib/Magento/Translate/Inline/Provider.php similarity index 68% rename from lib/Magento/Translate/Inline/ConfigFactory.php rename to lib/Magento/Translate/Inline/Provider.php index 503f602662a20..44911077b6dc4 100644 --- a/lib/Magento/Translate/Inline/ConfigFactory.php +++ b/lib/Magento/Translate/Inline/Provider.php @@ -1,7 +1,5 @@ _objectManager = $objectManager; + $this->inlineTranslate = $inlineTranslate; } /** - * Get instance of inline translate config + * Return instance of inline translate class * - * @return \Magento\Translate\Inline\ConfigInterface + * @return \Magento\Translate\InlineInterface */ public function get() { - return $this->_objectManager->get('Magento\Translate\Inline\ConfigInterface'); + return $this->inlineTranslate; } } diff --git a/lib/Magento/LauncherInterface.php b/lib/Magento/Translate/Inline/ProviderInterface.php similarity index 67% rename from lib/Magento/LauncherInterface.php rename to lib/Magento/Translate/Inline/ProviderInterface.php index 52c70a45f86d4..0e644613cc620 100644 --- a/lib/Magento/LauncherInterface.php +++ b/lib/Magento/Translate/Inline/ProviderInterface.php @@ -1,7 +1,5 @@ objectManager = $objectManager; + $this->instanceName = $instanceName; + $this->isShared = $shared; + } + + /** + * @return array + */ + public function __sleep() + { + return array('_subject', '_isShared'); + } + + /** + * Retrieve ObjectManager from global scope + * + * @return void + */ + public function __wakeup() + { + $this->objectManager = \Magento\App\ObjectManager::getInstance(); + } + + /** + * Clone proxied instance + * + * @return void + */ + public function __clone() + { + $this->subject = clone $this->_getSubject(); + } + + /** + * Get proxied instance + * + * @return \Magento\DesignEditor\Model\Translate\Inline + */ + protected function _getSubject() + { + if (!$this->subject) { + $this->subject = true === $this->isShared + ? $this->objectManager->get($this->instanceName) + : $this->objectManager->create($this->instanceName); + } + return $this->subject; + } + + /** + * Check if Inline Translates is allowed + * + * @return bool + */ + public function isAllowed() + { + return $this->_getSubject()->isAllowed(); + } + + /** + * Retrieve Inline Parser instance + * + * @return \Magento\Translate\Inline\ParserInterface + */ + public function getParser() + { + return $this->_getSubject()->getParser(); + } + + /** + * Replace translation templates with HTML fragments + * + * @param array|string &$body + * @param bool $isJson + * @return $this + */ + public function processResponseBody(&$body, $isJson = false) + { + return $this->_getSubject()->processResponseBody($body, $isJson); + } + + /** + * Additional translation mode html attribute is not needed for base inline translation. + * + * @param mixed|string|null $tagName + * @return mixed + */ + public function getAdditionalHtmlAttribute($tagName = null) + { + return $this->_getSubject()->getAdditionalHtmlAttribute($tagName); + } +} diff --git a/lib/Magento/Translate/Inline/State.php b/lib/Magento/Translate/Inline/State.php new file mode 100644 index 0000000000000..c25dc6153827a --- /dev/null +++ b/lib/Magento/Translate/Inline/State.php @@ -0,0 +1,102 @@ +isEnabled = false; + } + + /** + * Enable inline translation + * + * @return void + */ + public function enable() + { + $this->isEnabled = true; + } + + /** + * Check if inline translation enabled/disabled + * + * @return bool + */ + public function isEnabled() + { + return $this->isEnabled; + } + + /** + * Suspend inline translation + * + * Store current inline translation status + * and apply new status or disable inline translation. + * + * @param bool $status + * @return void + */ + public function suspend($status = false) + { + if ($this->storedStatus === null) { + $this->storedStatus = $this->isEnabled; + $this->isEnabled = $status; + } + } + + /** + * Disable inline translation + * + * Restore inline translation status + * or apply new status. + * + * @param bool $status + * @return void + */ + public function resume($status = true) + { + $this->isEnabled = !$status ? $status : $this->storedStatus; + $this->storedStatus = null; + } +} diff --git a/lib/Magento/Translate/Inline/StateInterface.php b/lib/Magento/Translate/Inline/StateInterface.php new file mode 100644 index 0000000000000..b5879eb6ddebd --- /dev/null +++ b/lib/Magento/Translate/Inline/StateInterface.php @@ -0,0 +1,71 @@ +_translate->initLocale($localeCode); + $this->_translate->setLocale($localeCode) + ->loadData(null, true); } } } diff --git a/lib/Magento/TranslateInterface.php b/lib/Magento/TranslateInterface.php index 308558a629aa5..ac94cec7d5c7b 100644 --- a/lib/Magento/TranslateInterface.php +++ b/lib/Magento/TranslateInterface.php @@ -1,7 +1,5 @@ setData('route_front_name', $name); - return $this; - } - /** * Retrieve use session rule * @@ -284,16 +245,6 @@ public function getUseSession() return $this->_useSession; } - /** - * Retrieve default action name - * - * @return string - */ - protected function _getDefaultActionName() - { - return self::DEFAULT_ACTION_NAME; - } - /** * Retrieve configuration data * @@ -369,21 +320,11 @@ protected function _getRequest() protected function _getType() { if (!$this->_routeParamsResolver->hasData('type')) { - $this->_routeParamsResolver->setData('type', $this->_getDefaultUrlType()); + $this->_routeParamsResolver->setData('type', self::DEFAULT_URL_TYPE); } return $this->_routeParamsResolver->getType(); } - /** - * @param string $type - * @return mixed - */ - public function setType($type) - { - $this->_routeParamsResolver->setType($type); - return $this; - } - /** * Retrieve is secure mode URL * @@ -467,8 +408,8 @@ public function getBaseUrl($params = array()) $this->_routeParamsResolver->setType(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK); } - $result = $this->_getScope()->getBaseUrl($this->_getType(), $this->_isSecure()); - $this->_routeParamsResolver->setType($this->_getDefaultUrlType()); + $result = $this->_getScope()->getBaseUrl($this->_getType(), $this->_isSecure()); + $this->_routeParamsResolver->setType(self::DEFAULT_URL_TYPE); return $result; } @@ -541,12 +482,12 @@ protected function _getActionPath() if ($this->_getControllerName()) { $path .= $this->_getControllerName() . '/'; } elseif ($hasParams) { - $path .= $this->_getDefaultControllerName() . '/'; + $path .= self::DEFAULT_CONTROLLER_NAME . '/'; } if ($this->_getActionName()) { $path .= $this->_getActionName() . '/'; } elseif ($hasParams) { - $path .= $this->_getDefaultActionName() . '/'; + $path .= self::DEFAULT_ACTION_NAME . '/'; } return $path; @@ -575,9 +516,6 @@ protected function _getRoutePath($routeParams = array()) $routePath .= $key . '/' . $value . '/'; } } - if ($routePath != '' && substr($routePath, -1, 1) !== '/') { - $routePath .= '/'; - } $this->setData('route_path', $routePath); } return $this->_getData('route_path'); @@ -620,9 +558,8 @@ protected function _getRouteFrontName() $this->_getRouteName(), $this->_scopeResolver->getAreaCode() ); - $this->_setRouteFrontName($frontName); + $this->setData('route_front_name', $frontName); } - return $this->_getData('route_front_name'); } @@ -657,11 +594,12 @@ protected function _setControllerName($data) /** * Retrieve controller name * + * @param mixed $default * @return string|null */ - protected function _getControllerName() + protected function _getControllerName($default = null) { - return $this->_getData('controller_name') ? $this->_getData('controller_name') : null; + return $this->_getData('controller_name') ? $this->_getData('controller_name') : $default; } /** @@ -751,10 +689,10 @@ public function getRouteUrl($routePath = null, $routeParams = null) */ public function addSessionParam() { - if (!self::$_encryptedSessionId) { - self::$_encryptedSessionId = $this->_session->getSessionId(); - } - $this->setQueryParam($this->_sidResolver->getSessionIdQueryParam($this->_session), self::$_encryptedSessionId); + $this->setQueryParam( + $this->_sidResolver->getSessionIdQueryParam($this->_session), + $this->_session->getSessionId() + ); return $this; } @@ -781,37 +719,17 @@ protected function _getQuery($escape = false) } /** - * Set query Params as array + * Add query Params as array * * @param array $data * @return \Magento\UrlInterface */ - public function setQueryParams(array $data) + public function addQueryParams(array $data) { - $this->_queryParamsResolver->setQueryParams($data); + $this->_queryParamsResolver->addQueryParams($data); return $this; } - /** - * Purge Query params array - * - * @return \Magento\UrlInterface - */ - public function purgeQueryParams() - { - return $this->_queryParamsResolver->purgeQueryParams(); - } - - /** - * Return Query Params - * - * @return array - */ - protected function _getQueryParams() - { - return $this->_queryParamsResolver->getQueryParams(); - } - /** * Set query param * @@ -867,7 +785,7 @@ public function getUrl($routePath = null, $routeParams = null) $query = null; if (isset($routeParams['_query'])) { - $this->purgeQueryParams(); + $this->_queryParamsResolver->setQueryParams([]); $query = $routeParams['_query']; unset($routeParams['_query']); } @@ -885,10 +803,10 @@ public function getUrl($routePath = null, $routeParams = null) if (is_string($query)) { $this->_setQuery($query); } elseif (is_array($query)) { - $this->setQueryParams($query, !empty($routeParams['_current'])); + $this->addQueryParams($query, !empty($routeParams['_current'])); } if ($query === false) { - $this->setQueryParams(array()); + $this->addQueryParams(array()); } } @@ -919,19 +837,6 @@ public function getUrl($routePath = null, $routeParams = null) * @return \Magento\UrlInterface */ protected function _prepareSessionUrl($url) - { - return $this->_prepareSessionUrlWithParams($url, array()); - } - - /** - * Check and add session id to URL, session is obtained with parameters - * - * @param string $url - * @param array $params - * - * @return \Magento\UrlInterface - */ - protected function _prepareSessionUrlWithParams($url, array $params) { if (!$this->getUseSession()) { return $this; @@ -1015,7 +920,28 @@ public function sessionUrlVar($html) { return preg_replace_callback( '#(\?|&|&)___SID=([SU])(&|&)?#', - array($this, "_sessionVarCallback"), + // @codingStandardsIgnoreStart + /** + * Callback function for session replace + * + * @param array $match + * @return string + */ + // @codingStandardsIgnoreEnd + function ($match) { + if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) { + return $match[1] + . $this->_sidResolver->getSessionIdQueryParam($this->_session) + . '=' . $this->_session->getSessionId() + . (isset($match[3]) ? $match[3] : ''); + } else { + if ($match[1] == '?') { + return isset($match[3]) ? '?' : ''; + } elseif ($match[1] == '&' || $match[1] == '&') { + return isset($match[3]) ? $match[3] : ''; + } + } + }, $html ); } @@ -1045,34 +971,6 @@ public function useSessionIdForUrl($secure = false) return $this->getData($key); } - /** - * Callback function for session replace - * - * @param array $match - * @return string - */ - protected function _sessionVarCallback($match) - { - if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) { - return $match[1] . $this->_sidResolver->getSessionIdQueryParam( - $this->_session - ) . '=' . $this->_session->getSessionId() . (isset( - $match[3] - ) ? $match[3] : ''); - } else { - if ($match[1] == '?' && isset($match[3])) { - return '?'; - } elseif ($match[1] == '?' && !isset($match[3])) { - return ''; - } elseif (($match[1] == '&' || $match[1] == '&') && !isset($match[3])) { - return ''; - } elseif (($match[1] == '&' || $match[1] == '&') && isset($match[3])) { - return $match[3]; - } - } - return ''; - } - /** * Check if users originated URL is one of the domain URLs assigned to scopes * @@ -1102,8 +1000,7 @@ public function isOwnOriginUrl() */ public function getRedirectUrl($url) { - $this->_prepareSessionUrlWithParams($url, array('name' => self::SESSION_NAMESPACE)); - + $this->_prepareSessionUrl($url); $query = $this->_getQuery(false); if ($query) { $url .= (strpos($url, '?') === false ? '?' : '&') . $query; diff --git a/lib/Magento/Url/QueryParamsResolver.php b/lib/Magento/Url/QueryParamsResolver.php index 9f5ee5dff3f27..06beda4db672a 100644 --- a/lib/Magento/Url/QueryParamsResolver.php +++ b/lib/Magento/Url/QueryParamsResolver.php @@ -47,11 +47,10 @@ public function getQuery($escape = false) */ public function setQuery($data) { - if ($this->_getData('query') == $data) { - return $this; + if ($this->_getData('query') != $data) { + $this->unsetData('query_params'); + $this->setData('query', $data); } - $this->unsetData('query_params'); - $this->setData('query', $data); return $this; } @@ -91,16 +90,15 @@ public function getQueryParams() /** * {@inheritdoc} */ - public function purgeQueryParams() + public function setQueryParams(array $data) { - $this->setData('query_params', array()); - return $this; + return $this->setData('query_params', $data); } /** * {@inheritdoc} */ - public function setQueryParams(array $data) + public function addQueryParams(array $data) { $this->unsetData('query'); diff --git a/lib/Magento/Url/QueryParamsResolverInterface.php b/lib/Magento/Url/QueryParamsResolverInterface.php index 3bfcbf5c64851..4c3382043e869 100644 --- a/lib/Magento/Url/QueryParamsResolverInterface.php +++ b/lib/Magento/Url/QueryParamsResolverInterface.php @@ -58,19 +58,20 @@ public function setQueryParam($key, $data); public function getQueryParams(); /** - * Purge Query params array + * Set query parameters * + * @param array $data * @return \Magento\Url\QueryParamsResolverInterface */ - public function purgeQueryParams(); + public function setQueryParams(array $data); /** - * Set query Params as array + * Add query parameters * * @param array $data * @return \Magento\Url\QueryParamsResolverInterface */ - public function setQueryParams(array $data); + public function addQueryParams(array $data); /** * Unset data from the object. diff --git a/lib/Magento/Url/Validator.php b/lib/Magento/Url/Validator.php index c7c8e6041c3db..8ec85cc803ca5 100644 --- a/lib/Magento/Url/Validator.php +++ b/lib/Magento/Url/Validator.php @@ -39,7 +39,6 @@ class Validator extends \Zend_Validate_Abstract * Error keys */ const INVALID_URL = 'invalidUrl'; - /**#@-*/ /** @@ -68,7 +67,6 @@ public function isValid($value) { $this->_setValue($value); - //check valid URL if (!\Zend_Uri::check($value)) { $this->_error(self::INVALID_URL); return false; diff --git a/lib/Magento/UrlInterface.php b/lib/Magento/UrlInterface.php index d6dece6783dff..b98e807fbba20 100644 --- a/lib/Magento/UrlInterface.php +++ b/lib/Magento/UrlInterface.php @@ -44,6 +44,13 @@ interface UrlInterface const URL_TYPE_JS = 'js'; + /** + * Default url type + * + * Equals to self::URL_TYPE_LINK + */ + const DEFAULT_URL_TYPE = 'link'; + /** * Default controller name */ @@ -103,12 +110,12 @@ public function getRouteUrl($routePath = null, $routeParams = null); public function addSessionParam(); /** - * Set query Params as array + * Add query parameters * * @param array $data * @return \Magento\UrlInterface */ - public function setQueryParams(array $data); + public function addQueryParams(array $data); /** * Set query param diff --git a/lib/Magento/View/Context.php b/lib/Magento/View/Context.php index 046e91dbb3a15..e1899993d53df 100644 --- a/lib/Magento/View/Context.php +++ b/lib/Magento/View/Context.php @@ -30,8 +30,8 @@ use Magento\View\Url as ViewUrl; use Magento\View\ConfigInterface as ViewConfig; use Magento\Logger; -use Magento\Core\Model\App; use Magento\App\State as AppState; +use Magento\View\LayoutInterface; use Magento\Session\SessionManager; use Magento\App\CacheInterface as Cache; use Magento\App\Cache\StateInterface as CacheState; @@ -146,13 +146,6 @@ class Context */ protected $logger; - /** - * Application - * - * @var \Magento\Core\Model\App - */ - protected $app; - /** * Application state * @@ -176,8 +169,8 @@ class Context * @param ViewConfig $viewConfig * @param CacheState $cacheState * @param Logger $logger - * @param App $app * @param AppState $appState + * @param LayoutInterface $layout * * @todo reduce parameter number * @@ -197,8 +190,8 @@ public function __construct( ViewConfig $viewConfig, CacheState $cacheState, Logger $logger, - App $app, - AppState $appState + AppState $appState, + LayoutInterface $layout ) { $this->request = $request; $this->eventManager = $eventManager; @@ -209,12 +202,12 @@ public function __construct( $this->session = $session; $this->storeConfig = $storeConfig; $this->frontController = $frontController; - $this->viewUrl = $viewUrl; - $this->viewConfig = $viewConfig; - $this->cacheState = $cacheState; - $this->logger = $logger; - $this->app = $app; - $this->appState = $appState; + $this->viewUrl = $viewUrl; + $this->viewConfig = $viewConfig; + $this->cacheState = $cacheState; + $this->logger = $logger; + $this->appState = $appState; + $this->layout = $layout; } /** @@ -357,16 +350,6 @@ public function getLogger() return $this->logger; } - /** - * Retrieve application - * - * @return \Magento\Core\Model\App - */ - public function getApp() - { - return $this->app; - } - /** * Retrieve layout area * @@ -374,7 +357,7 @@ public function getApp() */ public function getArea() { - return $this->app->getLayout()->getArea(); + return $this->layout->getArea(); } /** diff --git a/lib/Magento/View/Design/ThemeInterface.php b/lib/Magento/View/Design/ThemeInterface.php index 3f42b9f4f0c72..f93136a0dfbcd 100644 --- a/lib/Magento/View/Design/ThemeInterface.php +++ b/lib/Magento/View/Design/ThemeInterface.php @@ -25,8 +25,6 @@ /** * Interface ThemeInterface - * - * @method int|null getId() */ interface ThemeInterface { diff --git a/lib/Magento/View/DesignLoader.php b/lib/Magento/View/DesignLoader.php index 0e72228f85385..6f2180296b489 100644 --- a/lib/Magento/View/DesignLoader.php +++ b/lib/Magento/View/DesignLoader.php @@ -35,9 +35,9 @@ class DesignLoader /** * Application * - * @var \Magento\Core\Model\App + * @var \Magento\App\AreaList */ - protected $_app; + protected $_areaList; /** * Layout @@ -47,19 +47,17 @@ class DesignLoader protected $_layout; /** - * Constructor - * * @param \Magento\App\RequestInterface $request - * @param \Magento\Core\Model\App $app - * @param \Magento\View\LayoutInterface $layout + * @param \Magento\App\AreaList $areaList + * @param LayoutInterface $layout */ public function __construct( \Magento\App\RequestInterface $request, - \Magento\Core\Model\App $app, + \Magento\App\AreaList $areaList, \Magento\View\LayoutInterface $layout ) { $this->_request = $request; - $this->_app = $app; + $this->_areaList = $areaList; $this->_layout = $layout; } @@ -70,7 +68,7 @@ public function __construct( */ public function load() { - $area = $this->_app->getArea($this->_layout->getArea()); + $area = $this->_areaList->getArea($this->_layout->getArea()); $area->load(\Magento\Core\Model\App\Area::PART_DESIGN); $area->load(\Magento\Core\Model\App\Area::PART_TRANSLATE); $area->detectDesign($this->_request); diff --git a/lib/Magento/View/Element/AbstractBlock.php b/lib/Magento/View/Element/AbstractBlock.php index 99b21c765134b..40886401533c6 100644 --- a/lib/Magento/View/Element/AbstractBlock.php +++ b/lib/Magento/View/Element/AbstractBlock.php @@ -140,13 +140,6 @@ abstract class AbstractBlock extends \Magento\Object implements BlockInterface */ protected $_logger; - /** - * Application - * - * @var \Magento\Core\Model\App - */ - protected $_app; - /** * Escaper * @@ -166,6 +159,11 @@ abstract class AbstractBlock extends \Magento\Object implements BlockInterface */ protected $_localeDate; + /** + * @var \Magento\Translate\Inline\StateInterface + */ + protected $inlineTranslation; + /** * The property is used to define content-scope of block. Can be private or public. * If it isn't defined then application considers it as false. @@ -199,6 +197,8 @@ public function __construct(\Magento\View\Element\Context $context, array $data $this->_escaper = $context->getEscaper(); $this->filterManager = $context->getFilterManager(); $this->_localeDate = $context->getLocaleDate(); + $this->inlineTranslation = $context->getInlineTranslation(); + $this->_isScopePrivate = false; parent::__construct($data); $this->_construct(); } @@ -635,7 +635,7 @@ public function toHtml() $html = $this->_loadCache(); if ($html === false) { if ($this->hasData('translate_inline')) { - $this->_translator->setTranslateInline($this->getData('translate_inline')); + $this->inlineTranslation->suspend($this->getData('translate_inline')); } $this->_beforeToHtml(); @@ -643,7 +643,7 @@ public function toHtml() $this->_saveCache($html); if ($this->hasData('translate_inline')) { - $this->_translator->setTranslateInline(true); + $this->inlineTranslation->resume(); } } $html = $this->_afterToHtml($html); diff --git a/lib/Magento/View/Element/Context.php b/lib/Magento/View/Element/Context.php index 58b9e614ab691..e2f2579bc2c6a 100644 --- a/lib/Magento/View/Element/Context.php +++ b/lib/Magento/View/Element/Context.php @@ -152,8 +152,11 @@ class Context implements \Magento\ObjectManager\ContextInterface protected $_localeDate; /** - * Constructor - * + * @var \Magento\Translate\Inline\StateInterface + */ + protected $inlineTranslation; + + /** * @param \Magento\App\RequestInterface $request * @param \Magento\View\LayoutInterface $layout * @param \Magento\Event\ManagerInterface $eventManager @@ -171,10 +174,9 @@ class Context implements \Magento\ObjectManager\ContextInterface * @param \Magento\Escaper $escaper * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate - * @param array $data + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation * * @SuppressWarnings(PHPMD.ExcessiveParameterList) - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function __construct( \Magento\App\RequestInterface $request, @@ -194,7 +196,7 @@ public function __construct( \Magento\Escaper $escaper, \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, - array $data = array() + \Magento\Translate\Inline\StateInterface $inlineTranslation ) { $this->_request = $request; $this->_layout = $layout; @@ -213,6 +215,7 @@ public function __construct( $this->_escaper = $escaper; $this->_filterManager = $filterManager; $this->_localeDate = $localeDate; + $this->inlineTranslation = $inlineTranslation; } /** @@ -305,6 +308,16 @@ public function getTranslator() return $this->_translator; } + /** + * Get inline translation status object + * + * @return \Magento\Translate\Inline\StateInterface + */ + public function getInlineTranslation() + { + return $this->inlineTranslation; + } + /** * Get URL builder * diff --git a/lib/Magento/View/Element/Template/Context.php b/lib/Magento/View/Element/Template/Context.php index 1cc1eaf77e19a..8b910c79a9086 100644 --- a/lib/Magento/View/Element/Template/Context.php +++ b/lib/Magento/View/Element/Template/Context.php @@ -59,8 +59,6 @@ class Context extends \Magento\View\Element\Context protected $_storeManager; /** - * Constructor - * * @param \Magento\App\RequestInterface $request * @param \Magento\View\LayoutInterface $layout * @param \Magento\Event\ManagerInterface $eventManager @@ -78,12 +76,12 @@ class Context extends \Magento\View\Element\Context * @param \Magento\Escaper $escaper * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\App\Filesystem $filesystem * @param \Magento\View\FileSystem $viewFileSystem * @param \Magento\View\TemplateEnginePool $enginePool * @param \Magento\App\State $appState * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -105,12 +103,12 @@ public function __construct( \Magento\Escaper $escaper, \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Translate\Inline\StateInterface $inlineTranslation, \Magento\App\Filesystem $filesystem, \Magento\View\FileSystem $viewFileSystem, \Magento\View\TemplateEnginePool $enginePool, \Magento\App\State $appState, - \Magento\Core\Model\StoreManagerInterface $storeManager, - array $data = array() + \Magento\Core\Model\StoreManagerInterface $storeManager ) { parent::__construct( $request, @@ -130,7 +128,7 @@ public function __construct( $escaper, $filterManager, $localeDate, - $data + $inlineTranslation ); $this->_storeManager = $storeManager; diff --git a/pub/cron.php b/pub/cron.php index 7e00cc661c173..3ac4fa68e379f 100644 --- a/pub/cron.php +++ b/pub/cron.php @@ -26,10 +26,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +use Magento\Core\Model\StoreManager; + require dirname(__DIR__) . '/app/bootstrap.php'; umask(0); $params = array( - \Magento\Core\Model\App::PARAM_RUN_CODE => 'admin', + StoreManager::PARAM_RUN_CODE => 'admin', \Magento\Core\Model\Store::CUSTOM_ENTRY_POINT_PARAM => true ); $entryPoint = new \Magento\App\EntryPoint\EntryPoint(BP, $params); diff --git a/pub/get.php b/pub/get.php index e23bae7b7e630..bf2e09045ba70 100644 --- a/pub/get.php +++ b/pub/get.php @@ -26,6 +26,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +use Magento\App\Cache\Frontend\Factory; +use Magento\Module\Declaration\Reader\Filesystem; + require dirname(__DIR__) . '/app/bootstrap.php'; $mediaDirectory = null; @@ -76,8 +79,8 @@ // Materialize file in application $params = $_SERVER; if (empty($mediaDirectory)) { - $params[\Magento\Core\Model\App::PARAM_ALLOWED_MODULES] = array('Magento_Core'); - $params[\Magento\Core\Model\App::PARAM_CACHE_FORCED_OPTIONS]['frontend_options']['disable_save'] = true; + $params[Filesystem::PARAM_ALLOWED_MODULES] = array('Magento_Core'); + $params[Factory::PARAM_CACHE_FORCED_OPTIONS]['frontend_options']['disable_save'] = true; } $entryPoint = new \Magento\App\EntryPoint\EntryPoint(dirname(__DIR__), $params);