diff --git a/.gitignore b/.gitignore
index 7a2f12aac2541..90b240f3af0e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,3 +34,4 @@ atlassian*
/var/*
!/var/.htaccess
+/vendor
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4a4d7ccf5c67c..a00a72467d328 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,58 @@
+0.1.0-alpha90
+=============
+ * Service layer implementation:
+ * Created the Admin Shopping Cart Service
+ * Created the Create Shopping Cart Items Service
+ * Created the Create Shopping Cart Shipping Address Service
+ * Created the Create Shopping Cart Billing Address Service
+ * Created the Service Layer for Orders
+ * Created CRUD service & APIs to manage options for configurable products
+ * Created CRUD service & APIs to manage options for bundle products
+ * Fixed bugs:
+ * Fixed an issue where adding a customer address with an invalid value of the custom address attribute caused a fatal error in SOAP
+ * Fixed an issue where the wrong FedEx rates were displayed
+ * Fixed an issue where the Bill Me Later option did not work in Payflow payment methods
+ * Fixed an issue where order comments were broken for orders placed with Authorize.net
+ * Fixed the naming of the My Account -> Recurring Payment page
+ * Fixed a UI elements issue in the disabled Magento_PayPalRecurringPayment and Magento_RecurringPayment modules
+ * Fixed an issue where it was impossible to save configuration of a configurable product when adding it to an order in the Admin panel
+ * Fixed an issue where the Select a store page was displayed during admin order creation when the Single Store mode was enabled
+ * Fixed an issue when an exception was thrown when attempting to open the Customer Account page if the Recently Viewed widget was configured for the store
+ * Updated the content of the Privacy Policy page
+ * Fixed an issue where it was possible to update a tax rate using the POST http method
+ * Fixed an issue where it was impossible to update Inventory Qty for a SKU using API
+ * Fixed a JavaScript syntax error on the Create New Customer page
+ * Fixed an issue where it was impossible to add new sample while creating a downloadable product
+ * Fixed a JavaScript which appeared when clicking the Add New Address button in the Address Book on the storefront
+ * Fixed an issue where it was possible to update Tax Rules using the PUT http method which is supposed to be used for create operation only
+ * Fixed an issue where it was possible to create a Tax Rule specifying a product tax class instead of a customer tax class and vice versa
+ * Fixed an issue with making websiteId a mandatory field when updating a customer using REST
+ * Fixed an issue where the default value was not applied after clicking the 'Use default' link for a product price field in the catalog in the Admin panel
+ * Fixed an issue where the price update mass action could not be performed
+ * Fixed a JS error in the cross-sells product settings in the Admin panel
+ * Added the following functional tests:
+ * Mass Delete Backend Customer
+ * Moderate Product Review
+ * Framework improvements:
+ * Added the ability to access admin functionality using admin user login for mobile
+ * Refactored and unified Access Control List (ACL) to make it more consistent
+ * Created a Cookie Manager (a cookie management class)
+ * Changes in functional tests:
+ * Enabled the CustomerMetadataService tests for SOAP
+ * Themes update:
+ * Fixed issues in the Blank theme
+ * Implemented improvements for the Blank theme, core templates and Storefront UI Library
+ * Modularity:
+ * Created the Notification library component and made it possible to disable the AdminNotification module
+ * Made it possible to disable the SendToFriend module
+ * Created an optional ConfigurableImportExport module to remove dependency between the CatalogImportExport and ConfigurableProduct modules
+ * Created an optional GroupedImportExport module to remove dependency between the CatalogImportExport and GroupedProduct modules
+ * Introduce search library:
+ * Created a Search request configuration
+ * Created a Query object structure from the XML declaration
+ * Composer Integration:
+ * Added support for using 3rd-party components as Composer packages
+
0.1.0-alpha89
=============
* Fixed bugs:
diff --git a/README.md b/README.md
index fe79310ea4cca..2b7d837ea1746 100644
--- a/README.md
+++ b/README.md
@@ -6,3 +6,4 @@ All Submissions you make to Magento, an eBay Inc. company (“Magento”) throug
1. You grant Magento a perpetual, worldwide, non-exclusive, no charge, royalty free, irrevocable license under your applicable copyrights and patents to reproduce, prepare derivative works of, display, publically perform, sublicense and distribute any feedback, ideas, code, or other information (“Submission”) you submit through GitHub.
2. Your Submission is an original work of authorship and you are the owner or are legally entitled to grant the license stated above.
+3. You agree to the X.commerce Agreement found here: https://www.x.com/developers/x.commerce/x.commerce-user-agreement.
diff --git a/app/autoload.php b/app/autoload.php
index f2ab699eefe54..073340091ce7a 100644
--- a/app/autoload.php
+++ b/app/autoload.php
@@ -23,5 +23,10 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+$vendorDir = require __DIR__ . '/etc/vendor_path.php';
+$vendorAutoload = __DIR__ . '/../' . $vendorDir . '/autoload.php';
+if (file_exists($vendorAutoload)) {
+ require_once $vendorAutoload;
+}
require_once __DIR__ . '/../lib/internal/Magento/Framework/Autoload/IncludePath.php';
spl_autoload_register([new \Magento\Framework\Autoload\IncludePath(), 'load']);
diff --git a/app/bootstrap.php b/app/bootstrap.php
index f9b998c6bce1a..31abb9bdfa5c7 100644
--- a/app/bootstrap.php
+++ b/app/bootstrap.php
@@ -30,9 +30,9 @@
umask(0);
/* PHP version validation */
-if (version_compare(phpversion(), '5.4.0', '<') === true) {
+if (version_compare(phpversion(), '5.4.11', '<') === true) {
if (PHP_SAPI == 'cli') {
- echo 'Magento supports PHP 5.4.0 or newer. Please read http://www.magento.com/install.';
+ echo 'Magento supports PHP 5.4.11 or newer. Please read http://www.magento.com/install.';
} else {
echo <<
@@ -40,7 +40,7 @@
Whoops, it looks like you have an invalid PHP version.
-
Magento supports PHP 5.4.0 or newer.
+
Magento supports PHP 5.4.11 or newer.
Find out
how to install Magento using PHP-CGI as a work-around.
@@ -60,7 +60,6 @@
* Require necessary files
*/
require_once BP . '/app/functions.php';
-
require_once __DIR__ . '/autoload.php';
(new \Magento\Framework\Autoload\IncludePath())->addIncludePath(array(BP . '/app/code', BP . '/lib/internal'));
$classMapPath = BP . '/var/classmap.ser';
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
index e227a878d8c22..a3be2bc9ccef4 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
@@ -25,6 +25,8 @@
*/
namespace Magento\AdminNotification\Block\Grid\Renderer;
+use \Magento\Framework\Notification\MessageInterface;
+
class Severity extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{
/**
@@ -58,21 +60,21 @@ public function render(\Magento\Framework\Object $row)
$value = '';
switch ($row->getData($this->getColumn()->getIndex())) {
- case \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL:
+ case MessageInterface::SEVERITY_CRITICAL:
$class = 'critical';
- $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL);
+ $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_CRITICAL);
break;
- case \Magento\AdminNotification\Model\Inbox::SEVERITY_MAJOR:
+ case MessageInterface::SEVERITY_MAJOR:
$class = 'major';
- $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_MAJOR);
+ $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_MAJOR);
break;
- case \Magento\AdminNotification\Model\Inbox::SEVERITY_MINOR:
+ case MessageInterface::SEVERITY_MINOR:
$class = 'minor';
- $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_MINOR);
+ $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_MINOR);
break;
- case \Magento\AdminNotification\Model\Inbox::SEVERITY_NOTICE:
+ case MessageInterface::SEVERITY_NOTICE:
$class = 'notice';
- $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_NOTICE);
+ $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_NOTICE);
break;
}
return '' . $value . '';
diff --git a/app/code/Magento/AdminNotification/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php
index 19695d3a9e4b5..9af0a88bfcc20 100644
--- a/app/code/Magento/AdminNotification/Block/System/Messages.php
+++ b/app/code/Magento/AdminNotification/Block/System/Messages.php
@@ -70,14 +70,14 @@ protected function _toHtml()
/**
* Retrieve message list
*
- * @return \Magento\AdminNotification\Model\System\MessageInterface[]
+ * @return \Magento\Framework\Notification\MessageInterface[]
*/
public function getLastCritical()
{
$items = array_values($this->_messages->getItems());
if (isset(
$items[0]
- ) && $items[0]->getSeverity() == \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL
+ ) && $items[0]->getSeverity() == \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL
) {
return $items[0];
}
@@ -92,7 +92,7 @@ public function getLastCritical()
public function getCriticalCount()
{
return $this->_messages->getCountBySeverity(
- \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL
+ \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL
);
}
@@ -104,7 +104,7 @@ public function getCriticalCount()
public function getMajorCount()
{
return $this->_messages->getCountBySeverity(
- \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_MAJOR
+ \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR
);
}
diff --git a/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php b/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php
index fbc13f1755268..e5e88769696bd 100644
--- a/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php
+++ b/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php
@@ -17,13 +17,13 @@
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
- *
+ *
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace Magento\AdminNotification\Block\System\Messages;
-use Magento\AdminNotification\Model\System\MessageInterface;
+use Magento\Framework\Notification\MessageInterface;
class UnreadMessagePopup extends \Magento\Backend\Block\Template
{
diff --git a/app/code/Magento/AdminNotification/Model/Inbox.php b/app/code/Magento/AdminNotification/Model/Inbox.php
index 7e762b79a6e08..e620d1472a61a 100644
--- a/app/code/Magento/AdminNotification/Model/Inbox.php
+++ b/app/code/Magento/AdminNotification/Model/Inbox.php
@@ -23,6 +23,9 @@
*/
namespace Magento\AdminNotification\Model;
+use \Magento\Framework\Notification\MessageInterface;
+use \Magento\Framework\Notification\NotifierInterface;
+
/**
* AdminNotification Inbox model
*
@@ -45,16 +48,8 @@
*
* @author Magento Core Team
*/
-class Inbox extends \Magento\Framework\Model\AbstractModel
+class Inbox extends \Magento\Framework\Model\AbstractModel implements NotifierInterface
{
- const SEVERITY_CRITICAL = 1;
-
- const SEVERITY_MAJOR = 2;
-
- const SEVERITY_MINOR = 3;
-
- const SEVERITY_NOTICE = 4;
-
/**
* @return void
*/
@@ -72,10 +67,10 @@ protected function _construct()
public function getSeverities($severity = null)
{
$severities = array(
- self::SEVERITY_CRITICAL => __('critical'),
- self::SEVERITY_MAJOR => __('major'),
- self::SEVERITY_MINOR => __('minor'),
- self::SEVERITY_NOTICE => __('notice')
+ MessageInterface::SEVERITY_CRITICAL => __('critical'),
+ MessageInterface::SEVERITY_MAJOR => __('major'),
+ MessageInterface::SEVERITY_MINOR => __('minor'),
+ MessageInterface::SEVERITY_NOTICE => __('notice')
);
if (!is_null($severity)) {
@@ -118,7 +113,8 @@ public function getNoticeStatus()
*/
public function parse(array $data)
{
- return $this->getResource()->parse($this, $data);
+ $this->getResource()->parse($this, $data);
+ return $this;
}
/**
@@ -167,7 +163,7 @@ public function add($severity, $title, $description, $url = '', $isInternal = tr
*/
public function addCritical($title, $description, $url = '', $isInternal = true)
{
- $this->add(self::SEVERITY_CRITICAL, $title, $description, $url, $isInternal);
+ $this->add(MessageInterface::SEVERITY_CRITICAL, $title, $description, $url, $isInternal);
return $this;
}
@@ -182,7 +178,7 @@ public function addCritical($title, $description, $url = '', $isInternal = true)
*/
public function addMajor($title, $description, $url = '', $isInternal = true)
{
- $this->add(self::SEVERITY_MAJOR, $title, $description, $url, $isInternal);
+ $this->add(MessageInterface::SEVERITY_MAJOR, $title, $description, $url, $isInternal);
return $this;
}
@@ -197,7 +193,7 @@ public function addMajor($title, $description, $url = '', $isInternal = true)
*/
public function addMinor($title, $description, $url = '', $isInternal = true)
{
- $this->add(self::SEVERITY_MINOR, $title, $description, $url, $isInternal);
+ $this->add(MessageInterface::SEVERITY_MINOR, $title, $description, $url, $isInternal);
return $this;
}
@@ -212,7 +208,7 @@ public function addMinor($title, $description, $url = '', $isInternal = true)
*/
public function addNotice($title, $description, $url = '', $isInternal = true)
{
- $this->add(self::SEVERITY_NOTICE, $title, $description, $url, $isInternal);
+ $this->add(MessageInterface::SEVERITY_NOTICE, $title, $description, $url, $isInternal);
return $this;
}
}
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 870c60a0c1a08..48086ca6ec037 100644
--- a/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php
+++ b/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php
@@ -54,7 +54,7 @@ protected function _initSelect()
array('neq' => 1)
)->addFieldToFilter(
'severity',
- \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL
+ \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL
)->setPageSize(
1
);
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 8e44afd3851e1..bea61d7a1c425 100644
--- a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php
+++ b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php
@@ -17,7 +17,7 @@
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
- *
+ *
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
@@ -28,7 +28,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
/**
* System message list
*
- * @var \Magento\AdminNotification\Model\System\MessageList
+ * @var \Magento\Framework\Notification\MessageList
*/
protected $_messageList;
@@ -44,7 +44,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
* @param \Magento\Framework\Logger $logger
* @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
* @param \Magento\Framework\Event\ManagerInterface $eventManager
- * @param \Magento\AdminNotification\Model\System\MessageList $messageList
+ * @param \Magento\Framework\Notification\MessageList $messageList
* @param mixed $connection
* @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource
*/
@@ -53,7 +53,7 @@ public function __construct(
\Magento\Framework\Logger $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
\Magento\Framework\Event\ManagerInterface $eventManager,
- \Magento\AdminNotification\Model\System\MessageList $messageList,
+ \Magento\Framework\Notification\MessageList $messageList,
$connection = null,
\Magento\Framework\Model\Resource\Db\AbstractDb $resource = null
) {
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 c848602c9de06..444e85dfa2e70 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
@@ -17,7 +17,7 @@
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
- *
+ *
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
@@ -28,7 +28,7 @@ class Synchronized extends \Magento\AdminNotification\Model\Resource\System\Mess
/**
* Unread message list
*
- * @var \Magento\AdminNotification\Model\System\MessageInterface[]
+ * @var \Magento\Framework\Notification\MessageInterface[]
*/
protected $_unreadMessages = array();
@@ -74,7 +74,7 @@ public function _afterLoad()
/**
* Retrieve list of unread messages
*
- * @return \Magento\AdminNotification\Model\System\MessageInterface[]
+ * @return \Magento\Framework\Notification\MessageInterface[]
*/
public function getUnread()
{
diff --git a/app/code/Magento/AdminNotification/Model/System/Message.php b/app/code/Magento/AdminNotification/Model/System/Message.php
index d4588cf27e11a..4701404784803 100644
--- a/app/code/Magento/AdminNotification/Model/System/Message.php
+++ b/app/code/Magento/AdminNotification/Model/System/Message.php
@@ -17,13 +17,13 @@
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
- *
+ *
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace Magento\AdminNotification\Model\System;
-class Message extends \Magento\Framework\Model\AbstractModel implements \Magento\AdminNotification\Model\System\MessageInterface
+class Message extends \Magento\Framework\Model\AbstractModel implements \Magento\Framework\Notification\MessageInterface
{
/**
* @return void
diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php
index 2ede00eb20d10..92cc992a3b3a9 100644
--- a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php
+++ b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php
@@ -23,7 +23,7 @@
*/
namespace Magento\AdminNotification\Model\System\Message;
-class Baseurl implements \Magento\AdminNotification\Model\System\MessageInterface
+class Baseurl implements \Magento\Framework\Notification\MessageInterface
{
/**
* @var \Magento\Framework\UrlInterface
diff --git a/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php b/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php
index a7f57b85e2123..75154b6ad9c51 100644
--- a/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php
+++ b/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php
@@ -23,7 +23,7 @@
*/
namespace Magento\AdminNotification\Model\System\Message;
-class CacheOutdated implements \Magento\AdminNotification\Model\System\MessageInterface
+class CacheOutdated implements \Magento\Framework\Notification\MessageInterface
{
/**
* @var \Magento\Framework\UrlInterface
@@ -124,6 +124,6 @@ public function getLink()
*/
public function getSeverity()
{
- return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL;
+ return \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL;
}
}
diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php b/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php
index 5e1c628a00dcd..515b60a1229b5 100644
--- a/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php
+++ b/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php
@@ -23,7 +23,7 @@
*/
namespace Magento\AdminNotification\Model\System\Message\Media;
-abstract class AbstractSynchronization implements \Magento\AdminNotification\Model\System\MessageInterface
+abstract class AbstractSynchronization implements \Magento\Framework\Notification\MessageInterface
{
/**
* @var \Magento\Core\Model\File\Storage\Flag
@@ -94,6 +94,6 @@ public function isDisplayed()
*/
public function getSeverity()
{
- return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_MAJOR;
+ return \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR;
}
}
diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Security.php b/app/code/Magento/AdminNotification/Model/System/Message/Security.php
index 6a67afb6d0ff6..be4632352156b 100644
--- a/app/code/Magento/AdminNotification/Model/System/Message/Security.php
+++ b/app/code/Magento/AdminNotification/Model/System/Message/Security.php
@@ -23,7 +23,7 @@
*/
namespace Magento\AdminNotification\Model\System\Message;
-class Security implements \Magento\AdminNotification\Model\System\MessageInterface
+class Security implements \Magento\Framework\Notification\MessageInterface
{
/**
* Cache key for saving verification result
@@ -160,6 +160,6 @@ public function getText()
*/
public function getSeverity()
{
- return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL;
+ return \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL;
}
}
diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json
index d6f84501f5473..ebd21d9c35d9d 100644
--- a/app/code/Magento/AdminNotification/composer.json
+++ b/app/code/Magento/AdminNotification/composer.json
@@ -2,17 +2,17 @@
"name": "magento/module-admin-notification",
"description": "N/A",
"require": {
- "php": "5.4.*|5.5.*",
- "magento/module-store": "0.1.0-alpha89",
- "magento/module-core": "0.1.0-alpha89",
- "magento/module-backend": "0.1.0-alpha89",
- "magento/module-theme": "0.1.0-alpha89",
- "magento/framework": "0.1.0-alpha89",
+ "php": "~5.4.11|~5.5.0",
+ "magento/module-store": "0.1.0-alpha90",
+ "magento/module-core": "0.1.0-alpha90",
+ "magento/module-backend": "0.1.0-alpha90",
+ "magento/module-theme": "0.1.0-alpha90",
+ "magento/framework": "0.1.0-alpha90",
"lib-libxml": "*",
"magento/magento-composer-installer": "*"
},
"type": "magento2-module",
- "version": "0.1.0-alpha89",
+ "version": "0.1.0-alpha90",
"extra": {
"map": [
[
diff --git a/app/code/Magento/AdminNotification/etc/adminhtml/acl.xml b/app/code/Magento/AdminNotification/etc/acl.xml
similarity index 95%
rename from app/code/Magento/AdminNotification/etc/adminhtml/acl.xml
rename to app/code/Magento/AdminNotification/etc/acl.xml
index 86839ec9013db..46059d5147d92 100644
--- a/app/code/Magento/AdminNotification/etc/adminhtml/acl.xml
+++ b/app/code/Magento/AdminNotification/etc/acl.xml
@@ -23,7 +23,7 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
-
+
diff --git a/app/code/Magento/AdminNotification/etc/adminhtml/di.xml b/app/code/Magento/AdminNotification/etc/adminhtml/di.xml
index 3c16d79e9a5ea..9c8ba85f63df1 100644
--- a/app/code/Magento/AdminNotification/etc/adminhtml/di.xml
+++ b/app/code/Magento/AdminNotification/etc/adminhtml/di.xml
@@ -24,13 +24,12 @@
*/
-->
-
+ Magento\AdminNotification\Model\System\Message\BaseurlMagento\AdminNotification\Model\System\Message\SecurityMagento\AdminNotification\Model\System\Message\CacheOutdated
- Magento\AdminNotification\Model\System\Message\SurveyMagento\AdminNotification\Model\System\Message\Media\Synchronization\ErrorMagento\AdminNotification\Model\System\Message\Media\Synchronization\Success
diff --git a/app/code/Magento/AdminNotification/etc/di.xml b/app/code/Magento/AdminNotification/etc/di.xml
new file mode 100644
index 0000000000000..a6372146ba8fd
--- /dev/null
+++ b/app/code/Magento/AdminNotification/etc/di.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ Magento\AdminNotification\Model\Inbox
+
+
+
+
diff --git a/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js b/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js
index 710f9b6561af6..b5710b6b02861 100644
--- a/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js
+++ b/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js
@@ -55,18 +55,6 @@ define([
});
$(document).ready(function(){
- $('body').on('surveyYes surveyNo', function(e, data) {
- if (e.type == 'surveyYes') {
- var win = window.open(data.surveyUrl, '', 'width=900,height=600,resizable=1,scrollbars=1');
- win.focus();
- }
- $.ajax({
- url: data.surveyAction,
- type: 'post',
- data: {decision: data.decision}
- })
- });
-
$('#system_messages .message-system-short .error').on('click', function() {
$('#message-system-all').systemMessageDialog('open', 1);
});
@@ -75,4 +63,4 @@ define([
});
});
-});
\ No newline at end of file
+});
diff --git a/app/code/Magento/Authorization/Model/Acl/AclRetriever.php b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php
new file mode 100644
index 0000000000000..2e131fb3e149b
--- /dev/null
+++ b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php
@@ -0,0 +1,165 @@
+logger = $logger;
+ $this->rulesCollectionFactory = $rulesCollectionFactory;
+ $this->aclBuilder = $aclBuilder;
+ $this->roleCollectionFactory = $roleCollectionFactory;
+ }
+
+ /**
+ * Get a list of available resources using user details
+ *
+ * @param string $userType
+ * @param int $userId
+ * @return string[]
+ * @throws AuthorizationException
+ * @throws LocalizedException
+ */
+ public function getAllowedResourcesByUser($userType, $userId)
+ {
+ if ($userType == UserContextInterface::USER_TYPE_GUEST) {
+ return [self::PERMISSION_ANONYMOUS];
+ } elseif ($userType == UserContextInterface::USER_TYPE_CUSTOMER) {
+ return [self::PERMISSION_SELF];
+ }
+ try {
+ $role = $this->_getUserRole($userType, $userId);
+ if (!$role) {
+ throw new AuthorizationException('The role associated with the specified user cannot be found.');
+ }
+ $allowedResources = $this->getAllowedResourcesByRole($role->getId());
+ } catch (AuthorizationException $e) {
+ throw $e;
+ } catch (\Exception $e) {
+ $this->logger->logException($e);
+ throw new LocalizedException(
+ 'Error happened while getting a list of allowed resources. Check exception log for details.'
+ );
+ }
+ return $allowedResources;
+ }
+
+ /**
+ * Get a list of available resource using user role id
+ *
+ * @param string $roleId
+ * @return string[]
+ */
+ public function getAllowedResourcesByRole($roleId)
+ {
+ $allowedResources = [];
+ $rulesCollection = $this->rulesCollectionFactory->create();
+ $rulesCollection->getByRoles($roleId)->load();
+ $acl = $this->aclBuilder->getAcl();
+ /** @var \Magento\Authorization\Model\Rules $ruleItem */
+ foreach ($rulesCollection->getItems() as $ruleItem) {
+ $resourceId = $ruleItem->getResourceId();
+ if ($acl->has($resourceId) && $acl->isAllowed($roleId, $resourceId)) {
+ $allowedResources[] = $resourceId;
+ }
+ }
+ return $allowedResources;
+ }
+
+ /**
+ * Identify user role from user identifier.
+ *
+ * @param string $userType
+ * @param int $userId
+ * @return \Magento\Authorization\Model\Role|bool False if no role associated with provided user was found.
+ * @throws \LogicException
+ */
+ protected function _getUserRole($userType, $userId)
+ {
+ if (!$this->_canRoleBeCreatedForUserType($userType)) {
+ throw new \LogicException(
+ "The role with user type '{$userType}' does not exist and cannot be created"
+ );
+ }
+ $roleCollection = $this->roleCollectionFactory->create();
+ /** @var Role $role */
+ $role = $roleCollection->setUserFilter($userId, $userType)->getFirstItem();
+ return $role->getId() ? $role : false;
+ }
+
+ /**
+ * Check if the role can be associated with user having provided user type.
+ *
+ * Roles can be created for integrations and admin users only.
+ *
+ * @param int $userType
+ * @return bool
+ */
+ protected function _canRoleBeCreatedForUserType($userType)
+ {
+ return ($userType == UserContextInterface::USER_TYPE_INTEGRATION)
+ || ($userType == UserContextInterface::USER_TYPE_ADMIN);
+ }
+}
diff --git a/app/code/Magento/User/Model/Acl/Loader/Role.php b/app/code/Magento/Authorization/Model/Acl/Loader/Role.php
similarity index 79%
rename from app/code/Magento/User/Model/Acl/Loader/Role.php
rename to app/code/Magento/Authorization/Model/Acl/Loader/Role.php
index 4054deab32508..dc82131a87f36 100644
--- a/app/code/Magento/User/Model/Acl/Loader/Role.php
+++ b/app/code/Magento/Authorization/Model/Acl/Loader/Role.php
@@ -21,10 +21,10 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\User\Model\Acl\Loader;
+namespace Magento\Authorization\Model\Acl\Loader;
-use Magento\User\Model\Acl\Role\Group as RoleGroup;
-use Magento\User\Model\Acl\Role\User as RoleUser;
+use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
+use Magento\Authorization\Model\Acl\Role\User as RoleUser;
class Role implements \Magento\Framework\Acl\LoaderInterface
{
@@ -34,23 +34,23 @@ class Role implements \Magento\Framework\Acl\LoaderInterface
protected $_resource;
/**
- * @var \Magento\User\Model\Acl\Role\GroupFactory
+ * @var \Magento\Authorization\Model\Acl\Role\GroupFactory
*/
protected $_groupFactory;
/**
- * @var \Magento\User\Model\Acl\Role\UserFactory
+ * @var \Magento\Authorization\Model\Acl\Role\UserFactory
*/
protected $_roleFactory;
/**
- * @param \Magento\User\Model\Acl\Role\GroupFactory $groupFactory
- * @param \Magento\User\Model\Acl\Role\UserFactory $roleFactory
+ * @param \Magento\Authorization\Model\Acl\Role\GroupFactory $groupFactory
+ * @param \Magento\Authorization\Model\Acl\Role\UserFactory $roleFactory
* @param \Magento\Framework\App\Resource $resource
*/
public function __construct(
- \Magento\User\Model\Acl\Role\GroupFactory $groupFactory,
- \Magento\User\Model\Acl\Role\UserFactory $roleFactory,
+ \Magento\Authorization\Model\Acl\Role\GroupFactory $groupFactory,
+ \Magento\Authorization\Model\Acl\Role\UserFactory $roleFactory,
\Magento\Framework\App\Resource $resource
) {
$this->_resource = $resource;
@@ -66,7 +66,7 @@ public function __construct(
*/
public function populateAcl(\Magento\Framework\Acl $acl)
{
- $roleTableName = $this->_resource->getTableName('admin_role');
+ $roleTableName = $this->_resource->getTableName('authorization_role');
$adapter = $this->_resource->getConnection('core_read');
$select = $adapter->select()->from($roleTableName)->order('tree_level');
diff --git a/app/code/Magento/User/Model/Acl/Loader/Rule.php b/app/code/Magento/Authorization/Model/Acl/Loader/Rule.php
similarity index 95%
rename from app/code/Magento/User/Model/Acl/Loader/Rule.php
rename to app/code/Magento/Authorization/Model/Acl/Loader/Rule.php
index 25230c259ff89..8a2953d65d1f2 100644
--- a/app/code/Magento/User/Model/Acl/Loader/Rule.php
+++ b/app/code/Magento/Authorization/Model/Acl/Loader/Rule.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\User\Model\Acl\Loader;
+namespace Magento\Authorization\Model\Acl\Loader;
class Rule implements \Magento\Framework\Acl\LoaderInterface
{
@@ -53,7 +53,7 @@ public function __construct(
*/
public function populateAcl(\Magento\Framework\Acl $acl)
{
- $ruleTable = $this->_resource->getTableName("admin_rule");
+ $ruleTable = $this->_resource->getTableName("authorization_rule");
$adapter = $this->_resource->getConnection('core_read');
diff --git a/app/code/Magento/User/Model/Acl/Role/Generic.php b/app/code/Magento/Authorization/Model/Acl/Role/Generic.php
similarity index 93%
rename from app/code/Magento/User/Model/Acl/Role/Generic.php
rename to app/code/Magento/Authorization/Model/Acl/Role/Generic.php
index 80a8b3f6cdee3..3b39cf76eaacd 100644
--- a/app/code/Magento/User/Model/Acl/Role/Generic.php
+++ b/app/code/Magento/Authorization/Model/Acl/Role/Generic.php
@@ -21,10 +21,10 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\User\Model\Acl\Role;
+namespace Magento\Authorization\Model\Acl\Role;
/**
- * User acl role
+ * Generic acl role
*/
class Generic extends \Zend_Acl_Role
{
diff --git a/app/code/Magento/User/Model/Acl/Role/Group.php b/app/code/Magento/Authorization/Model/Acl/Role/Group.php
similarity index 90%
rename from app/code/Magento/User/Model/Acl/Role/Group.php
rename to app/code/Magento/Authorization/Model/Acl/Role/Group.php
index 08b5df2068844..7c2346d4f59d3 100644
--- a/app/code/Magento/User/Model/Acl/Role/Group.php
+++ b/app/code/Magento/Authorization/Model/Acl/Role/Group.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\User\Model\Acl\Role;
+namespace Magento\Authorization\Model\Acl\Role;
/**
* Acl Group model
*/
-class Group extends \Magento\User\Model\Acl\Role\Generic
+class Group extends \Magento\Authorization\Model\Acl\Role\Generic
{
/**
* All the group roles are prepended by G
diff --git a/app/code/Magento/User/Model/Acl/Role/User.php b/app/code/Magento/Authorization/Model/Acl/Role/User.php
similarity index 90%
rename from app/code/Magento/User/Model/Acl/Role/User.php
rename to app/code/Magento/Authorization/Model/Acl/Role/User.php
index 4d37e7ca89adb..69383609782c7 100644
--- a/app/code/Magento/User/Model/Acl/Role/User.php
+++ b/app/code/Magento/Authorization/Model/Acl/Role/User.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\User\Model\Acl\Role;
+namespace Magento\Authorization\Model\Acl\Role;
/**
* User acl role
*/
-class User extends \Magento\User\Model\Acl\Role\Generic
+class User extends \Magento\Authorization\Model\Acl\Role\Generic
{
/**
* All the user roles are prepended by U
diff --git a/app/code/Magento/Authorization/Model/CompositeUserContext.php b/app/code/Magento/Authorization/Model/CompositeUserContext.php
new file mode 100644
index 0000000000000..5707ac12a3252
--- /dev/null
+++ b/app/code/Magento/Authorization/Model/CompositeUserContext.php
@@ -0,0 +1,129 @@
+add($userContext['type']);
+ }
+ }
+
+ /**
+ * Add user context.
+ *
+ * @param UserContextInterface $userContext
+ * @return CompositeUserContext
+ */
+ protected function add(UserContextInterface $userContext)
+ {
+ $this->userContexts[] = $userContext;
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getUserId()
+ {
+ return $this->getUserContext() ? $this->getUserContext()->getUserId() : null;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getUserType()
+ {
+ return $this->getUserContext() ? $this->getUserContext()->getUserType() : null;
+ }
+
+ /**
+ * Retrieve user context
+ *
+ * @return UserContextInterface|bool False if none of the registered user contexts can identify user type
+ */
+ protected function getUserContext()
+ {
+ if (is_null($this->chosenUserContext)) {
+ /** @var UserContextInterface $userContext */
+ foreach ($this->userContexts as $userContext) {
+ if ($userContext->getUserType() && !is_null($userContext->getUserId())) {
+ $this->chosenUserContext = $userContext;
+ break;
+ }
+ }
+ if (is_null($this->chosenUserContext)) {
+ $this->chosenUserContext = false;
+ }
+ }
+ return $this->chosenUserContext;
+ }
+
+ /**
+ * Compare contexts sortOrder
+ *
+ * @param array $contextDataFirst
+ * @param array $contextDataSecond
+ * @return int
+ */
+ protected function compareContextsSortOrder($contextDataFirst, $contextDataSecond)
+ {
+ if ((int)$contextDataFirst['sortOrder'] == (int)$contextDataSecond['sortOrder']) {
+ return 0;
+ }
+
+ if ((int)$contextDataFirst['sortOrder'] < (int)$contextDataSecond['sortOrder']) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+}
diff --git a/app/code/Magento/User/Model/Resource/Permissions/Collection.php b/app/code/Magento/Authorization/Model/Resource/Permissions/Collection.php
similarity index 88%
rename from app/code/Magento/User/Model/Resource/Permissions/Collection.php
rename to app/code/Magento/Authorization/Model/Resource/Permissions/Collection.php
index 2ca9f8d6506b4..4fca3cee80e13 100644
--- a/app/code/Magento/User/Model/Resource/Permissions/Collection.php
+++ b/app/code/Magento/Authorization/Model/Resource/Permissions/Collection.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\User\Model\Resource\Permissions;
+namespace Magento\Authorization\Model\Resource\Permissions;
/**
* Admin permissions collection
@@ -37,6 +37,6 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
*/
protected function _construct()
{
- $this->_init('Magento\User\Model\Rules', 'Magento\User\Model\Resource\Rules');
+ $this->_init('Magento\Authorization\Model\Rules', 'Magento\Authorization\Model\Resource\Rules');
}
}
diff --git a/app/code/Magento/User/Model/Resource/Role.php b/app/code/Magento/Authorization/Model/Resource/Role.php
similarity index 76%
rename from app/code/Magento/User/Model/Resource/Role.php
rename to app/code/Magento/Authorization/Model/Resource/Role.php
index ea45c024f84d9..e79cf181e42bc 100644
--- a/app/code/Magento/User/Model/Resource/Role.php
+++ b/app/code/Magento/Authorization/Model/Resource/Role.php
@@ -21,22 +21,15 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\User\Model\Resource;
+namespace Magento\Authorization\Model\Resource;
-use Magento\User\Model\Acl\Role\User as RoleUser;
+use Magento\Authorization\Model\Acl\Role\User as RoleUser;
/**
* Admin role resource model
*/
class Role extends \Magento\Framework\Model\Resource\Db\AbstractDb
{
- /**
- * Users table
- *
- * @var string
- */
- protected $_usersTable;
-
/**
* Rule table
*
@@ -78,10 +71,8 @@ public function __construct(
*/
protected function _construct()
{
- $this->_init('admin_role', 'role_id');
-
- $this->_usersTable = $this->getTable('admin_user');
- $this->_ruleTable = $this->getTable('admin_rule');
+ $this->_init('authorization_role', 'role_id');
+ $this->_ruleTable = $this->getTable('authorization_rule');
}
/**
@@ -139,7 +130,6 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role)
*/
protected function _afterSave(\Magento\Framework\Model\AbstractModel $role)
{
- $this->_updateRoleUsersAcl($role);
$this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(\Magento\Backend\Block\Menu::CACHE_TAGS));
return $this;
}
@@ -164,47 +154,21 @@ protected function _afterDelete(\Magento\Framework\Model\AbstractModel $role)
/**
* Get role users
*
- * @param \Magento\User\Model\Role $role
+ * @param \Magento\Authorization\Model\Role $role
* @return array
*/
- public function getRoleUsers(\Magento\User\Model\Role $role)
+ public function getRoleUsers(\Magento\Authorization\Model\Role $role)
{
$read = $this->_getReadAdapter();
$binds = array('role_id' => $role->getId(), 'role_type' => RoleUser::ROLE_TYPE);
- $select = $read->select()->from(
- $this->getMainTable(),
- array('user_id')
- )->where(
- 'parent_id = :role_id'
- )->where(
- 'role_type = :role_type'
- )->where(
- 'user_id > 0'
- );
+ $select = $read->select()
+ ->from($this->getMainTable(), array('user_id'))
+ ->where('parent_id = :role_id')
+ ->where('role_type = :role_type')
+ ->where('user_id > 0');
return $read->fetchCol($select, $binds);
}
-
- /**
- * Update role users ACL
- *
- * @param \Magento\User\Model\Role $role
- * @return bool
- */
- private function _updateRoleUsersAcl(\Magento\User\Model\Role $role)
- {
- $write = $this->_getWriteAdapter();
- $users = $this->getRoleUsers($role);
- $rowsCount = 0;
-
- if (sizeof($users) > 0) {
- $bind = array('reload_acl_flag' => 1);
- $where = array('user_id IN(?)' => $users);
- $rowsCount = $write->update($this->_usersTable, $bind, $where);
- }
-
- return $rowsCount > 0;
- }
}
diff --git a/app/code/Magento/User/Model/Resource/Role/Collection.php b/app/code/Magento/Authorization/Model/Resource/Role/Collection.php
similarity index 89%
rename from app/code/Magento/User/Model/Resource/Role/Collection.php
rename to app/code/Magento/Authorization/Model/Resource/Role/Collection.php
index 3cce8f1b699cc..98e25949f8a51 100644
--- a/app/code/Magento/User/Model/Resource/Role/Collection.php
+++ b/app/code/Magento/Authorization/Model/Resource/Role/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\User\Model\Resource\Role;
+namespace Magento\Authorization\Model\Resource\Role;
-use Magento\User\Model\Acl\Role\Group as RoleGroup;
+use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
/**
* Admin role collection
@@ -37,7 +37,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
*/
protected function _construct()
{
- $this->_init('Magento\User\Model\Role', 'Magento\User\Model\Resource\Role');
+ $this->_init('Magento\Authorization\Model\Role', 'Magento\Authorization\Model\Resource\Role');
}
/**
diff --git a/app/code/Magento/User/Model/Resource/Role/Grid/Collection.php b/app/code/Magento/Authorization/Model/Resource/Role/Grid/Collection.php
similarity index 85%
rename from app/code/Magento/User/Model/Resource/Role/Grid/Collection.php
rename to app/code/Magento/Authorization/Model/Resource/Role/Grid/Collection.php
index a111d9b1d60a9..9355017b41d60 100644
--- a/app/code/Magento/User/Model/Resource/Role/Grid/Collection.php
+++ b/app/code/Magento/Authorization/Model/Resource/Role/Grid/Collection.php
@@ -21,14 +21,14 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\User\Model\Resource\Role\Grid;
+namespace Magento\Authorization\Model\Resource\Role\Grid;
-use Magento\User\Model\Acl\Role\Group as RoleGroup;
+use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
/**
* Admin role data grid collection
*/
-class Collection extends \Magento\User\Model\Resource\Role\Collection
+class Collection extends \Magento\Authorization\Model\Resource\Role\Collection
{
/**
* Prepare select for load
diff --git a/app/code/Magento/User/Model/Resource/Rules.php b/app/code/Magento/Authorization/Model/Resource/Rules.php
similarity index 95%
rename from app/code/Magento/User/Model/Resource/Rules.php
rename to app/code/Magento/Authorization/Model/Resource/Rules.php
index 1a82b9a498289..478eff8864c77 100644
--- a/app/code/Magento/User/Model/Resource/Rules.php
+++ b/app/code/Magento/Authorization/Model/Resource/Rules.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\User\Model\Resource;
+namespace Magento\Authorization\Model\Resource;
/**
* Admin rule resource model
@@ -80,17 +80,17 @@ public function __construct(
*/
protected function _construct()
{
- $this->_init('admin_rule', 'rule_id');
+ $this->_init('authorization_rule', 'rule_id');
}
/**
* Save ACL resources
*
- * @param \Magento\User\Model\Rules $rule
+ * @param \Magento\Authorization\Model\Rules $rule
* @return void
* @throws \Magento\Framework\Model\Exception
*/
- public function saveRel(\Magento\User\Model\Rules $rule)
+ public function saveRel(\Magento\Authorization\Model\Rules $rule)
{
try {
$adapter = $this->_getWriteAdapter();
diff --git a/app/code/Magento/User/Model/Resource/Rules/Collection.php b/app/code/Magento/Authorization/Model/Resource/Rules/Collection.php
similarity index 91%
rename from app/code/Magento/User/Model/Resource/Rules/Collection.php
rename to app/code/Magento/Authorization/Model/Resource/Rules/Collection.php
index 8814282b44043..a07788825876b 100644
--- a/app/code/Magento/User/Model/Resource/Rules/Collection.php
+++ b/app/code/Magento/Authorization/Model/Resource/Rules/Collection.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\User\Model\Resource\Rules;
+namespace Magento\Authorization\Model\Resource\Rules;
/**
* Rules collection
@@ -37,7 +37,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
*/
protected function _construct()
{
- $this->_init('Magento\User\Model\Rules', 'Magento\User\Model\Resource\Rules');
+ $this->_init('Magento\Authorization\Model\Rules', 'Magento\Authorization\Model\Resource\Rules');
}
/**
diff --git a/app/code/Magento/User/Model/Resource/Setup.php b/app/code/Magento/Authorization/Model/Resource/Setup.php
similarity index 69%
rename from app/code/Magento/User/Model/Resource/Setup.php
rename to app/code/Magento/Authorization/Model/Resource/Setup.php
index da215bd1e5866..e66ee4ec3dd32 100644
--- a/app/code/Magento/User/Model/Resource/Setup.php
+++ b/app/code/Magento/Authorization/Model/Resource/Setup.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\User\Model\Resource;
+namespace Magento\Authorization\Model\Resource;
/**
* Resource Setup Model
@@ -34,49 +34,49 @@ class Setup extends \Magento\Framework\Module\Setup
/**
* Role model factory
*
- * @var \Magento\User\Model\RoleFactory
+ * @var \Magento\Authorization\Model\RoleFactory
*/
protected $_roleCollectionFactory;
/**
- * Factory for user rules model
+ * Factory for rules model
*
- * @var \Magento\User\Model\RulesFactory
+ * @var \Magento\Authorization\Model\RulesFactory
*/
protected $_rulesCollectionFactory;
/**
* Role model factory
*
- * @var \Magento\User\Model\RoleFactory
+ * @var \Magento\Authorization\Model\RoleFactory
*/
protected $_roleFactory;
/**
* Rules model factory
*
- * @var \Magento\User\Model\RulesFactory
+ * @var \Magento\Authorization\Model\RulesFactory
*/
protected $_rulesFactory;
/**
* @param \Magento\Framework\Module\Setup\Context $context
* @param string $resourceName
- * @param \Magento\User\Model\Resource\Role\CollectionFactory $roleCollectionFactory
- * @param \Magento\User\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory
- * @param \Magento\User\Model\RoleFactory $roleFactory
- * @param \Magento\User\Model\RulesFactory $rulesFactory
+ * @param \Magento\Authorization\Model\Resource\Role\CollectionFactory $roleCollectionFactory
+ * @param \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory
+ * @param \Magento\Authorization\Model\RoleFactory $roleFactory
+ * @param \Magento\Authorization\Model\RulesFactory $rulesFactory
* @param string $moduleName
* @param string $connectionName
*/
public function __construct(
\Magento\Framework\Module\Setup\Context $context,
$resourceName,
- \Magento\User\Model\Resource\Role\CollectionFactory $roleCollectionFactory,
- \Magento\User\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory,
- \Magento\User\Model\RoleFactory $roleFactory,
- \Magento\User\Model\RulesFactory $rulesFactory,
- $moduleName = 'Magento_User',
+ \Magento\Authorization\Model\Resource\Role\CollectionFactory $roleCollectionFactory,
+ \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory,
+ \Magento\Authorization\Model\RoleFactory $roleFactory,
+ \Magento\Authorization\Model\RulesFactory $rulesFactory,
+ $moduleName = 'Magento_Authorization',
$connectionName = \Magento\Framework\Module\Updater\SetupInterface::DEFAULT_SETUP_CONNECTION
) {
$this->_roleCollectionFactory = $roleCollectionFactory;
@@ -89,7 +89,7 @@ public function __construct(
/**
* Creates role collection
*
- * @return \Magento\User\Model\Resource\Role\Collection
+ * @return \Magento\Authorization\Model\Resource\Role\Collection
*/
public function createRoleCollection()
{
@@ -99,7 +99,7 @@ public function createRoleCollection()
/**
* Creates rules collection
*
- * @return \Magento\User\Model\Resource\Rules\Collection
+ * @return \Magento\Authorization\Model\Resource\Rules\Collection
*/
public function createRulesCollection()
{
@@ -109,7 +109,7 @@ public function createRulesCollection()
/**
* Creates role model
*
- * @return \Magento\User\Model\Role
+ * @return \Magento\Authorization\Model\Role
*/
public function createRole()
{
@@ -119,7 +119,7 @@ public function createRole()
/**
* Creates rules model
*
- * @return \Magento\User\Model\Rules
+ * @return \Magento\Authorization\Model\Rules
*/
public function createRules()
{
diff --git a/app/code/Magento/User/Model/Role.php b/app/code/Magento/Authorization/Model/Role.php
similarity index 58%
rename from app/code/Magento/User/Model/Role.php
rename to app/code/Magento/Authorization/Model/Role.php
index ae3bc63f6346a..68d9f92763122 100644
--- a/app/code/Magento/User/Model/Role.php
+++ b/app/code/Magento/Authorization/Model/Role.php
@@ -21,57 +21,49 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\User\Model;
+namespace Magento\Authorization\Model;
/**
* Admin Role Model
*
- * @method \Magento\User\Model\Resource\Role _getResource()
- * @method \Magento\User\Model\Resource\Role getResource()
+ * @method \Magento\Authorization\Model\Resource\Role _getResource()
+ * @method \Magento\Authorization\Model\Resource\Role getResource()
* @method int getParentId()
- * @method \Magento\User\Model\Role setParentId(int $value)
+ * @method \Magento\Authorization\Model\Role setParentId(int $value)
* @method int getTreeLevel()
- * @method \Magento\User\Model\Role setTreeLevel(int $value)
+ * @method \Magento\Authorization\Model\Role setTreeLevel(int $value)
* @method int getSortOrder()
- * @method \Magento\User\Model\Role setSortOrder(int $value)
+ * @method \Magento\Authorization\Model\Role setSortOrder(int $value)
* @method string getRoleType()
- * @method \Magento\User\Model\Role setRoleType(string $value)
+ * @method \Magento\Authorization\Model\Role setRoleType(string $value)
* @method int getUserId()
- * @method \Magento\User\Model\Role setUserId(int $value)
+ * @method \Magento\Authorization\Model\Role setUserId(int $value)
* @method string getUserType()
- * @method \Magento\User\Model\Role setUserType(string $value)
+ * @method \Magento\Authorization\Model\Role setUserType(string $value)
* @method string getRoleName()
- * @method \Magento\User\Model\Role setRoleName(string $value)
+ * @method \Magento\Authorization\Model\Role setRoleName(string $value)
*/
class Role extends \Magento\Framework\Model\AbstractModel
{
/**
* @var string
*/
- protected $_eventPrefix = 'admin_roles';
-
- /**
- * @var \Magento\User\Model\Resource\Role\User\CollectionFactory
- */
- protected $_userRolesFactory;
+ protected $_eventPrefix = 'authorization_roles';
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
- * @param Resource\Role\User\CollectionFactory $userRolesFactory
- * @param Resource\Role $resource
- * @param Resource\Role\Collection $resourceCollection
+ * @param \Magento\Authorization\Model\Resource\Role $resource
+ * @param \Magento\Authorization\Model\Resource\Role\Collection $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
- \Magento\User\Model\Resource\Role\User\CollectionFactory $userRolesFactory,
- \Magento\User\Model\Resource\Role $resource,
- \Magento\User\Model\Resource\Role\Collection $resourceCollection,
+ \Magento\Authorization\Model\Resource\Role $resource,
+ \Magento\Authorization\Model\Resource\Role\Collection $resourceCollection,
array $data = array()
) {
- $this->_userRolesFactory = $userRolesFactory;
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
@@ -81,7 +73,7 @@ public function __construct(
public function __sleep()
{
$properties = parent::__sleep();
- return array_diff($properties, array('_userRolesFactory', '_resource', '_resourceCollection'));
+ return array_diff($properties, array('_resource', '_resourceCollection'));
}
/**
@@ -91,9 +83,8 @@ public function __wakeup()
{
parent::__wakeup();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
- $this->_userRolesFactory = $objectManager->get('Magento\User\Model\Resource\Role\User\CollectionFactory');
- $this->_resource = $objectManager->get('Magento\User\Model\Resource\Role');
- $this->_resourceCollection = $objectManager->get('Magento\User\Model\Resource\Role\Collection');
+ $this->_resource = $objectManager->get('Magento\Authorization\Model\Resource\Role');
+ $this->_resourceCollection = $objectManager->get('Magento\Authorization\Model\Resource\Role\Collection');
}
/**
@@ -103,7 +94,7 @@ public function __wakeup()
*/
protected function _construct()
{
- $this->_init('Magento\User\Model\Resource\Role');
+ $this->_init('Magento\Authorization\Model\Resource\Role');
}
/**
@@ -117,16 +108,6 @@ public function update()
return $this;
}
- /**
- * Retrieve users collection
- *
- * @return \Magento\User\Model\Resource\Role\User\Collection
- */
- public function getUsersCollection()
- {
- return $this->_userRolesFactory->create();
- }
-
/**
* Return users for role
*
diff --git a/app/code/Magento/User/Model/Rules.php b/app/code/Magento/Authorization/Model/Rules.php
similarity index 68%
rename from app/code/Magento/User/Model/Rules.php
rename to app/code/Magento/Authorization/Model/Rules.php
index abfa69254f888..8418ffaa3ff64 100644
--- a/app/code/Magento/User/Model/Rules.php
+++ b/app/code/Magento/Authorization/Model/Rules.php
@@ -21,23 +21,24 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\User\Model;
+
+namespace Magento\Authorization\Model;
/**
* Admin Rules Model
*
- * @method \Magento\User\Model\Resource\Rules _getResource()
- * @method \Magento\User\Model\Resource\Rules getResource()
+ * @method \Magento\Authorization\Model\Resource\Rules _getResource()
+ * @method \Magento\Authorization\Model\Resource\Rules getResource()
* @method int getRoleId()
- * @method \Magento\User\Model\Rules setRoleId(int $value)
+ * @method \Magento\Authorization\Model\Rules setRoleId(int $value)
* @method string getResourceId()
- * @method \Magento\User\Model\Rules setResourceId(string $value)
+ * @method \Magento\Authorization\Model\Rules setResourceId(string $value)
* @method string getPrivileges()
- * @method \Magento\User\Model\Rules setPrivileges(string $value)
+ * @method \Magento\Authorization\Model\Rules setPrivileges(string $value)
* @method int getAssertId()
- * @method \Magento\User\Model\Rules setAssertId(int $value)
+ * @method \Magento\Authorization\Model\Rules setAssertId(int $value)
* @method string getPermission()
- * @method \Magento\User\Model\Rules setPermission(string $value)
+ * @method \Magento\Authorization\Model\Rules setPermission(string $value)
*/
class Rules extends \Magento\Framework\Model\AbstractModel
{
@@ -46,15 +47,15 @@ class Rules extends \Magento\Framework\Model\AbstractModel
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
- * @param Resource\Rules $resource
- * @param Resource\Permissions\Collection $resourceCollection
+ * @param \Magento\Authorization\Model\Resource\Rules $resource
+ * @param \Magento\Authorization\Model\Resource\Permissions\Collection $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
- \Magento\User\Model\Resource\Rules $resource,
- \Magento\User\Model\Resource\Permissions\Collection $resourceCollection,
+ \Magento\Authorization\Model\Resource\Rules $resource,
+ \Magento\Authorization\Model\Resource\Permissions\Collection $resourceCollection,
array $data = array()
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
@@ -67,7 +68,7 @@ public function __construct(
*/
protected function _construct()
{
- $this->_init('Magento\User\Model\Resource\Rules');
+ $this->_init('Magento\Authorization\Model\Resource\Rules');
}
/**
diff --git a/app/code/Magento/Authz/Model/UserLocatorInterface.php b/app/code/Magento/Authorization/Model/UserContextInterface.php
similarity index 76%
rename from app/code/Magento/Authz/Model/UserLocatorInterface.php
rename to app/code/Magento/Authorization/Model/UserContextInterface.php
index 361e62e09cebd..948eb755390f2 100644
--- a/app/code/Magento/Authz/Model/UserLocatorInterface.php
+++ b/app/code/Magento/Authorization/Model/UserContextInterface.php
@@ -21,24 +21,34 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\Authz\Model;
+
+namespace Magento\Authorization\Model;
/**
* Interface for current user identification.
*/
-interface UserLocatorInterface
+interface UserContextInterface
{
+ /**#@+
+ * User type
+ */
+ const USER_TYPE_INTEGRATION = 1;
+ const USER_TYPE_ADMIN = 2;
+ const USER_TYPE_CUSTOMER = 3;
+ const USER_TYPE_GUEST = 4;
+ /**#@-*/
+
/**
* Identify current user ID.
*
- * @return int
+ * @return int|null
*/
public function getUserId();
/**
- * Retrieve current user type (Admin, Customer, Guest, Integration).
+ * Retrieve current user type.
*
- * @return string
+ * @return int|null
*/
public function getUserType();
}
diff --git a/app/code/Magento/Authorization/composer.json b/app/code/Magento/Authorization/composer.json
new file mode 100644
index 0000000000000..a00c08d4b68de
--- /dev/null
+++ b/app/code/Magento/Authorization/composer.json
@@ -0,0 +1,20 @@
+{
+ "name": "magento/module-authorization",
+ "description": "Authorization module provides access to Magento ACL functionality.",
+ "require": {
+ "php": "~5.4.11|~5.5.0",
+ "magento/module-backend": "0.1.0-alpha90",
+ "magento/framework": "0.1.0-alpha90",
+ "magento/magento-composer-installer": "*"
+ },
+ "type": "magento2-module",
+ "version": "0.1.0-alpha90",
+ "extra": {
+ "map": [
+ [
+ "*",
+ "Magento/Authorization"
+ ]
+ ]
+ }
+}
diff --git a/app/code/Magento/User/data/user_setup/data-install-1.6.0.0.php b/app/code/Magento/Authorization/data/authorization_setup/data-install-1.0.0.0.php
similarity index 69%
rename from app/code/Magento/User/data/user_setup/data-install-1.6.0.0.php
rename to app/code/Magento/Authorization/data/authorization_setup/data-install-1.0.0.0.php
index 013d4117f470f..483a6ee18fca6 100644
--- a/app/code/Magento/User/data/user_setup/data-install-1.6.0.0.php
+++ b/app/code/Magento/Authorization/data/authorization_setup/data-install-1.0.0.0.php
@@ -21,30 +21,22 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-use Magento\User\Model\Acl\Role\Group as RoleGroup;
+use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
+use Magento\Authorization\Model\UserContextInterface;
/**
* Save administrators group role and rules
*/
-/** @var \Magento\User\Model\Resource\Setup $this */
+/** @var \Magento\Authorization\Model\Resource\Setup $this */
-$roleCollection = $this->createRoleCollection()->addFieldToFilter(
- 'parent_id',
- 0
-)->addFieldToFilter(
- 'tree_level',
- 1
-)->addFieldToFilter(
- 'role_type',
- RoleGroup::ROLE_TYPE
-)->addFieldToFilter(
- 'user_id',
- 0
-)->addFieldToFilter(
- 'role_name',
- 'Administrators'
-);
+$roleCollection = $this->createRoleCollection()
+ ->addFieldToFilter('parent_id', 0)
+ ->addFieldToFilter('tree_level', 1)
+ ->addFieldToFilter('role_type', RoleGroup::ROLE_TYPE)
+ ->addFieldToFilter('user_id', 0)
+ ->addFieldToFilter('user_type', UserContextInterface::USER_TYPE_ADMIN)
+ ->addFieldToFilter('role_name', 'Administrators');
if ($roleCollection->count() == 0) {
$admGroupRole = $this->createRole()->setData(
@@ -54,6 +46,7 @@
'sort_order' => 1,
'role_type' => RoleGroup::ROLE_TYPE,
'user_id' => 0,
+ 'user_type' => UserContextInterface::USER_TYPE_ADMIN,
'role_name' => 'Administrators'
)
)->save();
@@ -64,13 +57,9 @@
}
}
-$rulesCollection = $this->createRulesCollection()->addFieldToFilter(
- 'role_id',
- $admGroupRole->getId()
-)->addFieldToFilter(
- 'resource_id',
- 'all'
-);
+$rulesCollection = $this->createRulesCollection()
+ ->addFieldToFilter('role_id', $admGroupRole->getId())
+ ->addFieldToFilter('resource_id', 'all');
if ($rulesCollection->count() == 0) {
$this->createRules()->setData(
@@ -82,7 +71,7 @@
)
)->save();
} else {
- /** @var \Magento\User\Model\Rules $rule */
+ /** @var \Magento\Authorization\Model\Rules $rule */
foreach ($rulesCollection as $rule) {
$rule->setData('resource_id', 'Magento_Adminhtml::all')->save();
}
diff --git a/app/code/Magento/Authorization/etc/di.xml b/app/code/Magento/Authorization/etc/di.xml
new file mode 100644
index 0000000000000..afd3f40acd4f9
--- /dev/null
+++ b/app/code/Magento/Authorization/etc/di.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+ Magento\Framework\Acl\RootResource\Proxy
+ Magento\Framework\Acl\Cache\Proxy
+
+
+
+
+
+ Magento\Authorization\Model\Resource\Setup
+
+
+
+
+
+ Magento\Authorization\Model\Acl\Loader\Rule
+ Magento\Authorization\Model\Acl\Loader\Role
+
+
+
diff --git a/app/code/Magento/Authz/etc/di.xml b/app/code/Magento/Authorization/etc/module.xml
similarity index 80%
rename from app/code/Magento/Authz/etc/di.xml
rename to app/code/Magento/Authorization/etc/module.xml
index 324792fc21e25..4224828dc06f4 100644
--- a/app/code/Magento/Authz/etc/di.xml
+++ b/app/code/Magento/Authorization/etc/module.xml
@@ -23,7 +23,10 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
-
-
-
+
+
+
+
+
+
diff --git a/app/code/Magento/Authorization/sql/authorization_setup/install-1.0.0.0.php b/app/code/Magento/Authorization/sql/authorization_setup/install-1.0.0.0.php
new file mode 100644
index 0000000000000..eb6661c9dc29a
--- /dev/null
+++ b/app/code/Magento/Authorization/sql/authorization_setup/install-1.0.0.0.php
@@ -0,0 +1,171 @@
+startSetup();
+
+if ($installer->getConnection()->isTableExists($installer->getTable('admin_role'))) {
+ /**
+ * Rename existing 'admin_role' table into 'authorization_role' (to avoid forcing Magento re-installation)
+ * TODO: This conditional logic can be removed some time after pull request is delivered to the mainline
+ */
+ $installer->getConnection()->renameTable(
+ $installer->getTable('admin_role'),
+ $installer->getTable('authorization_role')
+ );
+
+} else if (!$installer->getConnection()->isTableExists($installer->getTable('authorization_role'))) {
+ /**
+ * Create table 'authorization_role'
+ */
+ $table = $installer->getConnection()->newTable(
+ $installer->getTable('authorization_role')
+ )->addColumn(
+ 'role_id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
+ null,
+ array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true),
+ 'Role ID'
+ )->addColumn(
+ 'parent_id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
+ null,
+ array('unsigned' => true, 'nullable' => false, 'default' => '0'),
+ 'Parent Role ID'
+ )->addColumn(
+ 'tree_level',
+ \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
+ null,
+ array('unsigned' => true, 'nullable' => false, 'default' => '0'),
+ 'Role Tree Level'
+ )->addColumn(
+ 'sort_order',
+ \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
+ null,
+ array('unsigned' => true, 'nullable' => false, 'default' => '0'),
+ 'Role Sort Order'
+ )->addColumn(
+ 'role_type',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 1,
+ array('nullable' => false, 'default' => '0'),
+ 'Role Type'
+ )->addColumn(
+ 'user_id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
+ null,
+ array('unsigned' => true, 'nullable' => false, 'default' => '0'),
+ 'User ID'
+ )->addColumn(
+ 'user_type',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 16,
+ array('nullable' => true, 'default' => null),
+ 'User Type'
+ )->addColumn(
+ 'role_name',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 50,
+ array('nullable' => true, 'default' => null),
+ 'Role Name'
+ )->addIndex(
+ $installer->getIdxName('authorization_role', array('parent_id', 'sort_order')),
+ array('parent_id', 'sort_order')
+ )->addIndex(
+ $installer->getIdxName('authorization_role', array('tree_level')),
+ array('tree_level')
+ )->setComment(
+ 'Admin Role Table'
+ );
+ $installer->getConnection()->createTable($table);
+}
+
+if ($installer->getConnection()->isTableExists($installer->getTable('admin_rule'))) {
+ /**
+ * Rename existing 'admin_rule' table into 'authorization_rule' (to avoid forcing Magento re-installation)
+ * TODO: This conditional logic can be removed some time after pull request is delivered to the mainline
+ */
+ $installer->getConnection()->renameTable(
+ $installer->getTable('admin_rule'),
+ $installer->getTable('authorization_rule')
+ );
+
+} else if (!$installer->getConnection()->isTableExists($installer->getTable('authorization_rule'))) {
+ /**
+ * Create table 'authorization_rule'
+ */
+ $table = $installer->getConnection()->newTable(
+ $installer->getTable('authorization_rule')
+ )->addColumn(
+ 'rule_id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
+ null,
+ array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true),
+ 'Rule ID'
+ )->addColumn(
+ 'role_id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
+ null,
+ array('unsigned' => true, 'nullable' => false, 'default' => '0'),
+ 'Role ID'
+ )->addColumn(
+ 'resource_id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 255,
+ array('nullable' => true, 'default' => null),
+ 'Resource ID'
+ )->addColumn(
+ 'privileges',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 20,
+ array('nullable' => true),
+ 'Privileges'
+ )->addColumn(
+ 'permission',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 10,
+ array(),
+ 'Permission'
+ )->addIndex(
+ $installer->getIdxName('authorization_rule', array('resource_id', 'role_id')),
+ array('resource_id', 'role_id')
+ )->addIndex(
+ $installer->getIdxName('authorization_rule', array('role_id', 'resource_id')),
+ array('role_id', 'resource_id')
+ )->addForeignKey(
+ $installer->getFkName('authorization_rule', 'role_id', 'authorization_role', 'role_id'),
+ 'role_id',
+ $installer->getTable('authorization_role'),
+ 'role_id',
+ \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
+ \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ )->setComment(
+ 'Admin Rule Table'
+ );
+ $installer->getConnection()->createTable($table);
+}
+
+$installer->endSetup();
diff --git a/app/code/Magento/Authorizenet/Helper/Data.php b/app/code/Magento/Authorizenet/Helper/Data.php
index 8bcfa32014dec..0398481a245a2 100644
--- a/app/code/Magento/Authorizenet/Helper/Data.php
+++ b/app/code/Magento/Authorizenet/Helper/Data.php
@@ -197,39 +197,10 @@ public function convertMessagesToMessage($messages)
* @param \Magento\Framework\Object $card
* @param bool|float $amount
* @param bool|string $exception
+ * @param bool|string $additionalMessage
* @return bool|string
*/
public function getTransactionMessage(
- $payment,
- $requestType,
- $lastTransactionId,
- $card,
- $amount = false,
- $exception = false
- ) {
- return $this->getExtendedTransactionMessage(
- $payment,
- $requestType,
- $lastTransactionId,
- $card,
- $amount,
- $exception
- );
- }
-
- /**
- * Return message for gateway transaction request
- *
- * @param \Magento\Payment\Model\Info $payment
- * @param string $requestType
- * @param string $lastTransactionId
- * @param \Magento\Framework\Object $card
- * @param bool|float $amount
- * @param bool|string $exception
- * @param bool|string $additionalMessage
- * @return bool|mixed
- */
- public function getExtendedTransactionMessage(
$payment,
$requestType,
$lastTransactionId,
@@ -238,40 +209,27 @@ public function getExtendedTransactionMessage(
$exception = false,
$additionalMessage = false
) {
+ $message[] = __('Credit Card: xxxx-%1', $card->getCcLast4());
+ if ($amount) {
+ $message[] = __('amount %1', $this->_formatPrice($payment, $amount));
+ }
$operation = $this->_getOperation($requestType);
-
if (!$operation) {
return false;
- }
-
- if ($amount) {
- $amount = __('amount %1', $this->_formatPrice($payment, $amount));
- }
-
- if ($exception) {
- $result = __('failed');
} else {
- $result = __('successful');
+ $message[] = $operation;
}
-
- $card = __('Credit Card: xxxx-%1', $card->getCcLast4());
-
- $pattern = '%s %s %s - %s.';
- $texts = array($card, $amount, $operation, $result);
-
+ $message[] = ($exception) ? '- ' . __('failed.') : '- ' . __('successful.');
if (!is_null($lastTransactionId)) {
- $pattern .= ' %s.';
- $texts[] = __('Authorize.Net Transaction ID %1', $lastTransactionId);
+ $message[] = __('Authorize.Net Transaction ID %1.', $lastTransactionId);
}
-
if ($additionalMessage) {
- $pattern .= ' %s.';
- $texts[] = $additionalMessage;
+ $message[] = $additionalMessage;
}
- $pattern .= ' %s';
- $texts[] = $exception;
-
- return call_user_func_array('__', array_merge(array($pattern), $texts));
+ if ($exception) {
+ $message[] = $exception;
+ }
+ return implode(' ', $message);
}
/**
diff --git a/app/code/Magento/Authorizenet/Model/Authorizenet.php b/app/code/Magento/Authorizenet/Model/Authorizenet.php
index cf5b2a3bf553d..df8c1202f6eb2 100644
--- a/app/code/Magento/Authorizenet/Model/Authorizenet.php
+++ b/app/code/Magento/Authorizenet/Model/Authorizenet.php
@@ -1054,14 +1054,14 @@ protected function _voidCardTransaction($payment, $card)
'parent_transaction_id' => $authTransactionId
),
array(),
- $this->_authorizenetData->getExtendedTransactionMessage(
+ $this->_authorizenetData->getTransactionMessage(
$payment,
self::REQUEST_TYPE_VOID,
null,
$card,
false,
false,
- __('Parent Authorize.Net transaction (ID %1) expired', $realAuthTransactionId)
+ __('Parent Authorize.Net transaction (ID %1) expired.', $realAuthTransactionId)
)
);
}
diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php
index ef24c34cdb2df..9d3f76530f6b2 100644
--- a/app/code/Magento/Authorizenet/Model/Directpost.php
+++ b/app/code/Magento/Authorizenet/Model/Directpost.php
@@ -23,6 +23,8 @@
*/
namespace Magento\Authorizenet\Model;
+use Magento\Sales\Model\Order\Email\Sender\OrderSender;
+
/**
* Authorize.net DirectPost payment method model.
*/
@@ -90,6 +92,11 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet
*/
protected $_helper;
+ /**
+ * @var OrderSender
+ */
+ protected $orderSender;
+
/**
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Payment\Helper\Data $paymentData
@@ -110,6 +117,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet
* @param \Magento\Authorizenet\Model\Directpost\RequestFactory $directRequestFactory
* @param \Magento\Authorizenet\Model\Directpost\Response $response
* @param \Magento\Authorizenet\Helper\HelperInterface $helper
+ * @param OrderSender $orderSender
* @param array $data
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -134,6 +142,7 @@ public function __construct(
\Magento\Authorizenet\Model\Directpost\RequestFactory $directRequestFactory,
\Magento\Authorizenet\Model\Directpost\Response $response,
\Magento\Authorizenet\Helper\HelperInterface $helper,
+ OrderSender $orderSender,
array $data = array()
) {
parent::__construct(
@@ -158,6 +167,7 @@ public function __construct(
$this->_requestFactory = $directRequestFactory;
$this->_response = $response;
$this->_helper = $helper;
+ $this->orderSender = $orderSender;
}
/**
@@ -705,7 +715,7 @@ protected function _authOrder(\Magento\Sales\Model\Order $order)
try {
if (!$response->hasOrderSendConfirmation() || $response->getOrderSendConfirmation()) {
- $order->sendNewOrderEmail();
+ $this->orderSender->send($order);
}
$this->_quoteFactory->create()->load($order->getQuoteId())->setIsActive(false)->save();
diff --git a/app/code/Magento/Authorizenet/composer.json b/app/code/Magento/Authorizenet/composer.json
index 83732fee6399d..6b8835ccde63b 100644
--- a/app/code/Magento/Authorizenet/composer.json
+++ b/app/code/Magento/Authorizenet/composer.json
@@ -2,20 +2,20 @@
"name": "magento/module-authorizenet",
"description": "N/A",
"require": {
- "php": "5.4.*|5.5.*",
- "magento/module-store": "0.1.0-alpha89",
- "magento/module-sales": "0.1.0-alpha89",
- "magento/module-checkout": "0.1.0-alpha89",
- "magento/module-backend": "0.1.0-alpha89",
- "magento/module-core": "0.1.0-alpha89",
- "magento/module-payment": "0.1.0-alpha89",
- "magento/module-centinel": "0.1.0-alpha89",
- "magento/module-catalog": "0.1.0-alpha89",
- "magento/framework": "0.1.0-alpha89",
+ "php": "~5.4.11|~5.5.0",
+ "magento/module-store": "0.1.0-alpha90",
+ "magento/module-sales": "0.1.0-alpha90",
+ "magento/module-checkout": "0.1.0-alpha90",
+ "magento/module-backend": "0.1.0-alpha90",
+ "magento/module-core": "0.1.0-alpha90",
+ "magento/module-payment": "0.1.0-alpha90",
+ "magento/module-centinel": "0.1.0-alpha90",
+ "magento/module-catalog": "0.1.0-alpha90",
+ "magento/framework": "0.1.0-alpha90",
"magento/magento-composer-installer": "*"
},
"type": "magento2-module",
- "version": "0.1.0-alpha89",
+ "version": "0.1.0-alpha90",
"extra": {
"map": [
[
diff --git a/app/code/Magento/Authz/Model/UserIdentifier.php b/app/code/Magento/Authz/Model/UserIdentifier.php
deleted file mode 100644
index 999a7f259c84f..0000000000000
--- a/app/code/Magento/Authz/Model/UserIdentifier.php
+++ /dev/null
@@ -1,135 +0,0 @@
-getUserType();
- $userId = isset($userId) ? $userId : $userLocator->getUserId();
- if ($userType == self::USER_TYPE_GUEST && $userId) {
- throw new \LogicException('Guest user must not have user ID set.');
- }
- $this->_setUserId($userId);
- $this->_setUserType($userType);
- }
-
- /**
- * Get user ID. Null is possible when user type is 'guest'.
- *
- * @return int
- */
- public function getUserId()
- {
- return $this->_userId;
- }
-
- /**
- * Retrieve user type (admin, customer, guest, web API integration).
- *
- * @return string
- */
- public function getUserType()
- {
- return $this->_userType;
- }
-
- /**
- * Set user ID.
- *
- * @param int $userId
- * @return $this
- * @throws \LogicException
- */
- protected function _setUserId($userId)
- {
- $userId = is_numeric($userId) ? (int)$userId : $userId;
- if (!is_integer($userId) || $userId < 0) {
- throw new \LogicException("Invalid user ID: '{$userId}'.");
- }
- $this->_userId = $userId;
- return $this;
- }
-
- /**
- * Set user type.
- *
- * @param string $userType
- * @return $this
- * @throws \LogicException
- */
- protected function _setUserType($userType)
- {
- $availableTypes = array(
- self::USER_TYPE_GUEST,
- self::USER_TYPE_CUSTOMER,
- self::USER_TYPE_ADMIN,
- self::USER_TYPE_INTEGRATION
- );
- if (!in_array($userType, $availableTypes)) {
- throw new \LogicException(
- "Invalid user type: '{$userType}'. Allowed types: " . implode(", ", $availableTypes)
- );
- }
- $this->_userType = $userType;
- return $this;
- }
-}
diff --git a/app/code/Magento/Authz/Service/AuthorizationV1.php b/app/code/Magento/Authz/Service/AuthorizationV1.php
deleted file mode 100644
index 216c3c56c8aca..0000000000000
--- a/app/code/Magento/Authz/Service/AuthorizationV1.php
+++ /dev/null
@@ -1,377 +0,0 @@
-_aclBuilder = $aclBuilder;
- $this->_userIdentifier = $userIdentifier;
- $this->_roleFactory = $roleFactory;
- $this->_rulesFactory = $rulesFactory;
- $this->_rulesCollectionFactory = $rulesCollectionFactory;
- $this->_roleCollectionFactory = $roleCollectionFactory;
- $this->_logger = $logger;
- $this->_rootAclResource = $rootAclResource;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isAllowed($resources, UserIdentifier $userIdentifier = null)
- {
- $resources = is_array($resources) ? $resources : [$resources];
- $userIdentifier = $userIdentifier ? $userIdentifier : $this->_userIdentifier;
- if ($this->_isAnonymousOrSelfAllowed($resources, $userIdentifier)) {
- return true;
- }
- return $this->_isUserWithRoleAllowed($resources, $userIdentifier);
- }
-
- /**
- * {@inheritdoc}
- */
- public function grantPermissions(UserIdentifier $userIdentifier, array $resources)
- {
- try {
- $role = $this->_getUserRole($userIdentifier);
- if (!$role) {
- $role = $this->_createRole($userIdentifier);
- }
- $this->_associateResourcesWithRole($role, $resources);
- } catch (\Exception $e) {
- $this->_logger->logException($e);
- throw new LocalizedException('Error happened while granting permissions. Check exception log for details.');
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function grantAllPermissions(UserIdentifier $userIdentifier)
- {
- $this->grantPermissions($userIdentifier, array($this->_rootAclResource->getId()));
- }
-
- /**
- * {@inheritdoc}
- */
- public function getAllowedResources(UserIdentifier $userIdentifier)
- {
- if ($userIdentifier->getUserType() == UserIdentifier::USER_TYPE_GUEST) {
- return [self::PERMISSION_ANONYMOUS];
- } elseif ($userIdentifier->getUserType() == UserIdentifier::USER_TYPE_CUSTOMER) {
- return [self::PERMISSION_SELF];
- }
- $allowedResources = [];
- try {
- $role = $this->_getUserRole($userIdentifier);
- if (!$role) {
- throw new AuthorizationException('The role associated with the specified user cannot be found.');
- }
- $rulesCollection = $this->_rulesCollectionFactory->create();
- $rulesCollection->getByRoles($role->getId())->load();
- $acl = $this->_aclBuilder->getAcl();
- /** @var \Magento\User\Model\Rules $ruleItem */
- foreach ($rulesCollection->getItems() as $ruleItem) {
- $resourceId = $ruleItem->getResourceId();
- if ($acl->has($resourceId) && $acl->isAllowed($role->getId(), $resourceId)) {
- $allowedResources[] = $resourceId;
- }
- }
- } catch (AuthorizationException $e) {
- throw $e;
- } catch (\Exception $e) {
- $this->_logger->logException($e);
- throw new LocalizedException(
- 'Error happened while getting a list of allowed resources. Check exception log for details.'
- );
- }
- return $allowedResources;
- }
-
- /**
- * {@inheritdoc}
- */
- public function removePermissions(UserIdentifier $userIdentifier)
- {
- try {
- $this->_deleteRole($userIdentifier);
- } catch (NoSuchEntityException $e) {
- throw $e;
- } catch (\Exception $e) {
- $this->_logger->logException($e);
- throw new LocalizedException(
- 'Error happened while deleting role and permissions. Check exception log for details.'
- );
- }
- }
-
- /**
- * Create new ACL role.
- *
- * @param UserIdentifier $userIdentifier
- * @return Role
- * @throws NoSuchEntityException
- * @throws \LogicException
- */
- protected function _createRole($userIdentifier)
- {
- $userType = $userIdentifier->getUserType();
- if (!$this->_canRoleBeCreatedForUserType($userType)) {
- throw new \LogicException("The role with user type '{$userType}' cannot be created");
- }
- $userId = $userIdentifier->getUserId();
- switch ($userType) {
- case UserIdentifier::USER_TYPE_INTEGRATION:
- $roleName = $userType . $userId;
- $roleType = \Magento\User\Model\Acl\Role\User::ROLE_TYPE;
- $parentId = 0;
- $userId = $userIdentifier->getUserId();
- break;
- default:
- throw NoSuchEntityException::singleField('userType', $userType);
- }
- $role = $this->_roleFactory->create();
- $role->setRoleName($roleName)
- ->setUserType($userType)
- ->setUserId($userId)
- ->setRoleType($roleType)
- ->setParentId($parentId)
- ->save();
- return $role;
- }
-
- /**
- * Remove an ACL role. This deletes the cascading permissions
- *
- * @param UserIdentifier $userIdentifier
- * @return Role
- * @throws NoSuchEntityException
- * @throws \LogicException
- */
- protected function _deleteRole($userIdentifier)
- {
- $userType = $userIdentifier->getUserType();
- if (!$this->_canRoleBeCreatedForUserType($userType)) {
- throw new \LogicException("The role with user type '{$userType}' cannot be created or deleted.");
- }
- $userId = $userIdentifier->getUserId();
- switch ($userType) {
- case UserIdentifier::USER_TYPE_INTEGRATION:
- $roleName = $userType . $userId;
- break;
- default:
- throw NoSuchEntityException::singleField('userType', $userType);
- }
- $role = $this->_roleFactory->create()->load($roleName, 'role_name');
- return $role->delete();
- }
-
- /**
- * Identify user role from user identifier.
- *
- * @param UserIdentifier $userIdentifier
- * @return Role|false Return false in case when no role associated with provided user was found.
- * @throws \LogicException
- */
- protected function _getUserRole($userIdentifier)
- {
- if (!$this->_canRoleBeCreatedForUserType($userIdentifier)) {
- throw new \LogicException(
- "The role with user type '{$userIdentifier->getUserType()}' does not exist and cannot be created"
- );
- }
- $roleCollection = $this->_roleCollectionFactory->create();
- $userType = $userIdentifier->getUserType();
- /** @var Role $role */
- $userId = $userIdentifier->getUserId();
- $role = $roleCollection->setUserFilter($userId, $userType)->getFirstItem();
- return $role->getId() ? $role : false;
- }
-
- /**
- * Associate resources with the specified role. All resources previously assigned to the role will be unassigned.
- *
- * @param Role $role
- * @param string[] $resources
- * @return void
- * @throws \LogicException
- */
- protected function _associateResourcesWithRole($role, array $resources)
- {
- /** @var \Magento\User\Model\Rules $rules */
- $rules = $this->_rulesFactory->create();
- $rules->setRoleId($role->getId())->setResources($resources)->saveRel();
- }
-
- /**
- * Check if there role can be associated with user having provided user type.
- *
- * Roles cannot be created for guests and customers.
- *
- * @param string $userType
- * @return bool
- */
- protected function _canRoleBeCreatedForUserType($userType)
- {
- return ($userType != UserIdentifier::USER_TYPE_CUSTOMER) && ($userType != UserIdentifier::USER_TYPE_GUEST);
- }
-
- /**
- * Check if the user has permission to access the requested resources.
- *
- * @param string[] $resources
- * @param UserIdentifier $userIdentifier
- * @return bool
- */
- protected function _isAnonymousOrSelfAllowed($resources, UserIdentifier $userIdentifier)
- {
- if (count($resources) == 1) {
- $resource = reset($resources);
- $isAnonymousAccess = ($resource == self::PERMISSION_ANONYMOUS);
- $isSelfAccess = ($userIdentifier->getUserType() == UserIdentifier::USER_TYPE_CUSTOMER)
- && ($resource == self::PERMISSION_SELF);
- if ($isAnonymousAccess || $isSelfAccess) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Check if user who has role is allowed to access requested resources.
- *
- * @param string[] $resources
- * @param UserIdentifier $userIdentifier
- * @return bool
- */
- protected function _isUserWithRoleAllowed($resources, UserIdentifier $userIdentifier)
- {
- try {
- $role = $this->_getUserRole($userIdentifier);
- if (!$role) {
- throw NoSuchEntityException::doubleField(
- 'userId',
- $userIdentifier->getUserId(),
- 'userType',
- $userIdentifier->getUserType()
- );
- }
- foreach ($resources as $resource) {
- if (!$this->_aclBuilder->getAcl()->isAllowed($role->getId(), $resource)) {
- return false;
- }
- }
- return true;
- } catch (\Exception $e) {
- $this->_logger->logException($e);
- return false;
- }
- }
-}
diff --git a/app/code/Magento/Authz/Service/AuthorizationV1Interface.php b/app/code/Magento/Authz/Service/AuthorizationV1Interface.php
deleted file mode 100644
index 9fbd2a5cc8662..0000000000000
--- a/app/code/Magento/Authz/Service/AuthorizationV1Interface.php
+++ /dev/null
@@ -1,88 +0,0 @@
-getUser()) {
- $this->regenerateId(false);
+ $this->regenerateId();
if ($this->_backendUrl->useSecretKey()) {
$this->_backendUrl->renewSecretUrls();
diff --git a/app/code/Magento/Backend/Model/Observer.php b/app/code/Magento/Backend/Model/Observer.php
index a95b840671a2a..fced5d795f618 100644
--- a/app/code/Magento/Backend/Model/Observer.php
+++ b/app/code/Magento/Backend/Model/Observer.php
@@ -85,27 +85,4 @@ public function clearCacheConfigurationFilesAccessLevelVerification()
{
return $this;
}
-
- /**
- * Set url class name for store 'admin'
- *
- * @param \Magento\Framework\Event\Observer $observer
- * @return $this
- */
- public function setUrlClassName(\Magento\Framework\Event\Observer $observer)
- {
- /** @var $storeCollection \Magento\Store\Model\Resource\Store\Collection */
- $storeCollection = $observer->getEvent()->getStoreCollection();
- /** @var $store \Magento\Store\Model\Store */
- foreach ($storeCollection as $store) {
- if ($store->getId() == 0) {
- $store->setUrlClassName('Magento\Backend\Model\UrlInterface');
- break;
- }
- }
- $this->cache->remove(
- \Magento\AdminNotification\Model\System\Message\Security::VERIFICATION_RESULT_CACHE_KEY
- );
- return $this;
- }
}
diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json
index 22d9a7215c106..2ff611ae678f2 100644
--- a/app/code/Magento/Backend/composer.json
+++ b/app/code/Magento/Backend/composer.json
@@ -2,34 +2,33 @@
"name": "magento/module-backend",
"description": "N/A",
"require": {
- "php": "5.4.*|5.5.*",
- "magento/module-store": "0.1.0-alpha89",
- "magento/module-directory": "0.1.0-alpha89",
- "magento/module-core": "0.1.0-alpha89",
- "magento/module-eav": "0.1.0-alpha89",
- "magento/module-admin-notification": "0.1.0-alpha89",
- "magento/module-cron": "0.1.0-alpha89",
- "magento/module-sendfriend": "0.1.0-alpha89",
- "magento/module-theme": "0.1.0-alpha89",
- "magento/module-weee": "0.1.0-alpha89",
- "magento/module-reports": "0.1.0-alpha89",
- "magento/module-catalog-search": "0.1.0-alpha89",
- "magento/module-sales": "0.1.0-alpha89",
- "magento/module-catalog": "0.1.0-alpha89",
- "magento/module-user": "0.1.0-alpha89",
- "magento/module-cms": "0.1.0-alpha89",
- "magento/module-backup": "0.1.0-alpha89",
- "magento/module-email": "0.1.0-alpha89",
- "magento/module-customer": "0.1.0-alpha89",
- "magento/module-tax": "0.1.0-alpha89",
- "magento/module-checkout": "0.1.0-alpha89",
- "magento/module-url-rewrite": "0.1.0-alpha89",
- "magento/module-translation": "0.1.0-alpha89",
- "magento/framework": "0.1.0-alpha89",
+ "php": "~5.4.11|~5.5.0",
+ "magento/module-store": "0.1.0-alpha90",
+ "magento/module-directory": "0.1.0-alpha90",
+ "magento/module-core": "0.1.0-alpha90",
+ "magento/module-eav": "0.1.0-alpha90",
+ "magento/module-cron": "0.1.0-alpha90",
+ "magento/module-sendfriend": "0.1.0-alpha90",
+ "magento/module-theme": "0.1.0-alpha90",
+ "magento/module-weee": "0.1.0-alpha90",
+ "magento/module-reports": "0.1.0-alpha90",
+ "magento/module-catalog-search": "0.1.0-alpha90",
+ "magento/module-sales": "0.1.0-alpha90",
+ "magento/module-catalog": "0.1.0-alpha90",
+ "magento/module-user": "0.1.0-alpha90",
+ "magento/module-cms": "0.1.0-alpha90",
+ "magento/module-backup": "0.1.0-alpha90",
+ "magento/module-email": "0.1.0-alpha90",
+ "magento/module-customer": "0.1.0-alpha90",
+ "magento/module-tax": "0.1.0-alpha90",
+ "magento/module-checkout": "0.1.0-alpha90",
+ "magento/module-url-rewrite": "0.1.0-alpha90",
+ "magento/module-translation": "0.1.0-alpha90",
+ "magento/framework": "0.1.0-alpha90",
"magento/magento-composer-installer": "*"
},
"type": "magento2-module",
- "version": "0.1.0-alpha89",
+ "version": "0.1.0-alpha90",
"extra": {
"map": [
[
diff --git a/app/code/Magento/Backend/etc/adminhtml/acl.xml b/app/code/Magento/Backend/etc/acl.xml
similarity index 98%
rename from app/code/Magento/Backend/etc/adminhtml/acl.xml
rename to app/code/Magento/Backend/etc/acl.xml
index 45f9521fd7a37..3393e749dbba1 100644
--- a/app/code/Magento/Backend/etc/adminhtml/acl.xml
+++ b/app/code/Magento/Backend/etc/acl.xml
@@ -23,7 +23,7 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
-
+
diff --git a/app/code/Magento/Backend/etc/module.xml b/app/code/Magento/Backend/etc/module.xml
index 101b83e07768a..1b15e3702c493 100644
--- a/app/code/Magento/Backend/etc/module.xml
+++ b/app/code/Magento/Backend/etc/module.xml
@@ -33,7 +33,6 @@
-
diff --git a/app/code/Magento/Backup/composer.json b/app/code/Magento/Backup/composer.json
index 8af68b4da0463..b14d724302611 100644
--- a/app/code/Magento/Backup/composer.json
+++ b/app/code/Magento/Backup/composer.json
@@ -2,17 +2,17 @@
"name": "magento/module-backup",
"description": "N/A",
"require": {
- "php": "5.4.*|5.5.*",
- "magento/module-store": "0.1.0-alpha89",
- "magento/module-core": "0.1.0-alpha89",
- "magento/module-backend": "0.1.0-alpha89",
- "magento/module-cron": "0.1.0-alpha89",
- "magento/module-index": "0.1.0-alpha89",
- "magento/framework": "0.1.0-alpha89",
+ "php": "~5.4.11|~5.5.0",
+ "magento/module-store": "0.1.0-alpha90",
+ "magento/module-core": "0.1.0-alpha90",
+ "magento/module-backend": "0.1.0-alpha90",
+ "magento/module-cron": "0.1.0-alpha90",
+ "magento/module-index": "0.1.0-alpha90",
+ "magento/framework": "0.1.0-alpha90",
"magento/magento-composer-installer": "*"
},
"type": "magento2-module",
- "version": "0.1.0-alpha89",
+ "version": "0.1.0-alpha90",
"extra": {
"map": [
[
diff --git a/app/code/Magento/Backup/etc/adminhtml/acl.xml b/app/code/Magento/Backup/etc/acl.xml
similarity index 94%
rename from app/code/Magento/Backup/etc/adminhtml/acl.xml
rename to app/code/Magento/Backup/etc/acl.xml
index eb2139dc270aa..1abed0fc99ef5 100644
--- a/app/code/Magento/Backup/etc/adminhtml/acl.xml
+++ b/app/code/Magento/Backup/etc/acl.xml
@@ -23,7 +23,7 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
-
+
diff --git a/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php b/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php
index 1a70af60d6375..678da2ceea6a0 100644
--- a/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php
+++ b/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php
@@ -33,21 +33,22 @@ class PriceBackend
/**
* @param \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject
* @param \Closure $proceed
- * @param \Magento\Catalog\Model\Product $product
+ * @param \Magento\Catalog\Model\Product|\Magento\Framework\Object $object
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundValidate(
\Magento\Catalog\Model\Product\Attribute\Backend\Price $subject,
\Closure $proceed,
- \Magento\Catalog\Model\Product $product
+ $object
) {
- if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE
- && $product->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC
+ if ($object instanceof \Magento\Catalog\Model\Product
+ && $object->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE
+ && $object->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC
) {
return true;
} else {
- return $proceed($product);
+ return $proceed($object);
}
}
}
diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php
new file mode 100644
index 0000000000000..dfb605d843b29
--- /dev/null
+++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php
@@ -0,0 +1,104 @@
+_get(self::ID);
+ }
+
+ /**
+ * Get option title
+ *
+ * @return string|null
+ */
+ public function getTitle()
+ {
+ return $this->_get(self::TITLE);
+ }
+
+ /**
+ * Get is required option
+ *
+ * @return bool|null
+ */
+ public function isRequired()
+ {
+ return $this->_get(self::REQUIRED);
+ }
+
+ /**
+ * Get input type
+ *
+ * @return string|null
+ */
+ public function getType()
+ {
+ return $this->_get(self::TYPE);
+ }
+
+ /**
+ * Get option position
+ *
+ * @return int|null
+ */
+ public function getPosition()
+ {
+ return $this->_get(self::POSITION);
+ }
+
+ /**
+ * Get product sku
+ *
+ * @return string|null
+ */
+ public function getSku()
+ {
+ return $this->_get(self::SKU);
+ }
+}
diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option/Type.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/Type.php
new file mode 100644
index 0000000000000..596a44f534326
--- /dev/null
+++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/Type.php
@@ -0,0 +1,56 @@
+_get(self::LABEL);
+ }
+
+ /**
+ * Get type code
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->_get(self::CODE);
+ }
+}
diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeBuilder.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeBuilder.php
new file mode 100644
index 0000000000000..04af6800a3106
--- /dev/null
+++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeBuilder.php
@@ -0,0 +1,54 @@
+_set(Type::LABEL, $value);
+ }
+
+ /**
+ * Set type code
+ *
+ * @param int $value
+ * @return $this
+ */
+ public function setCode($value)
+ {
+ return $this->_set(Type::CODE, $value);
+ }
+}
diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php
new file mode 100644
index 0000000000000..b64fecdbd27fc
--- /dev/null
+++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php
@@ -0,0 +1,53 @@
+builder = $builder;
+ }
+
+ /**
+ * @param array $option
+ * @return Type
+ */
+ public function createDataFromModel(array $option)
+ {
+ $this->builder->populateWithArray($option)
+ ->setCode($option['value']);
+ return $this->builder->create();
+ }
+}
diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php
new file mode 100644
index 0000000000000..398f8f1a995b0
--- /dev/null
+++ b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php
@@ -0,0 +1,98 @@
+_set(Option::ID, $value);
+ }
+
+ /**
+ * Set option title
+ *
+ * @param string $value
+ * @return $this
+ */
+ public function setTitle($value)
+ {
+ return $this->_set(Option::TITLE, $value);
+ }
+
+ /**
+ * Set is required option
+ *
+ * @param bool $value
+ * @return $this
+ */
+ public function setRequired($value)
+ {
+ return $this->_set(Option::REQUIRED, $value);
+ }
+
+ /**
+ * Set input type
+ *
+ * @param string $value
+ * @return $this
+ */
+ public function setType($value)
+ {
+ return $this->_set(Option::TYPE, $value);
+ }
+
+ /**
+ * Set option position
+ *
+ * @param int $value
+ * @return $this
+ */
+ public function setPosition($value)
+ {
+ return $this->_set(Option::POSITION, $value);
+ }
+
+ /**
+ * Set product sku
+ *
+ * @param string $value
+ * @return $this
+ */
+ public function setSku($value)
+ {
+ return $this->_set(Option::SKU, $value);
+ }
+}
diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php
new file mode 100644
index 0000000000000..b5de09c3576a2
--- /dev/null
+++ b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php
@@ -0,0 +1,99 @@
+builder = $builder;
+ $this->optionFactory = $optionFactory;
+ }
+
+ /**
+ * @param OptionModel $option
+ * @param Product $product
+ * @return Option
+ */
+ public function createDataFromModel(OptionModel $option, Product $product)
+ {
+ $this->builder->populateWithArray($option->getData())
+ ->setId($option->getId())
+ ->setTitle(is_null($option->getTitle()) ? $option->getDefaultTitle() : $option->getTitle())
+ ->setSku($product->getSku());
+ return $this->builder->create();
+ }
+
+ /**
+ * @param Option $option
+ * @param Product $product
+ * @return OptionModel
+ */
+ public function createModelFromData(Option $option, Product $product)
+ {
+ $optionModel = $this->optionFactory->create();
+ $optionModel->addData($option->__toArray())
+ ->unsetData($optionModel->getIdFieldName())
+ ->setParentId($product->getId())
+ ->setDefaultTitle($option->getTitle());
+ return $optionModel;
+ }
+
+ /**
+ * @param Option $option
+ * @param OptionModel $optionModel
+ * @return OptionModel
+ */
+ public function getModelFromData(Option $option, OptionModel $optionModel)
+ {
+ $newOptionModel = $this->optionFactory->create();
+ $newOptionModel->setData($optionModel->getData())
+ ->addData($option->__toArray())
+ ->setId($optionModel->getId())
+ ->setDefaultTitle(is_null($option->getTitle()) ? $optionModel->getTitle() : $option->getTitle());
+ return $newOptionModel;
+ }
+}
diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php
index 1218d7fcfa70a..2964310bc693c 100644
--- a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php
+++ b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php
@@ -169,7 +169,7 @@ public function removeChild($productSku, $optionId, $childSku)
$removeSelectionIds = array();
foreach ($this->getOptions($product) as $option) {
foreach ($option->getSelections() as $selection) {
- if (($selection->getSku() == $childSku) && ($selection->getOptionId() == $optionId)) {
+ if ((strcasecmp($selection->getSku(), $childSku) == 0) && ($selection->getOptionId() == $optionId)) {
$removeSelectionIds[] = $selection->getSelectionId();
continue;
}
diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php
new file mode 100644
index 0000000000000..714401d72e441
--- /dev/null
+++ b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php
@@ -0,0 +1,113 @@
+optionConverter = $optionConverter;
+ $this->productRepository = $productRepository;
+ $this->type = $type;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get($productSku, $optionId)
+ {
+ $product = $this->getProduct($productSku);
+ $optionCollection = $this->type->getOptionsCollection($product);
+ $optionCollection->setIdFilter($optionId);
+
+ /** @var \Magento\Bundle\Model\Option $option */
+ $option = $optionCollection->getFirstItem();
+ if (!$option->getId()) {
+ throw new NoSuchEntityException('Requested option doesn\'t exist');
+ }
+ return $this->optionConverter->createDataFromModel($option, $product);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getList($productSku)
+ {
+ $product = $this->getProduct($productSku);
+ $optionCollection = $this->type->getOptionsCollection($product);
+
+ /** @var \Magento\Bundle\Service\V1\Data\Product\Option[] $optionDtoList */
+ $optionDtoList = [];
+ /** @var \Magento\Bundle\Model\Option $option */
+ foreach ($optionCollection as $option) {
+ $optionDtoList[] = $this->optionConverter->createDataFromModel($option, $product);
+ }
+ return $optionDtoList;
+ }
+
+ /**
+ * @param string $productSku
+ * @return Product
+ * @throws Exception
+ */
+ private function getProduct($productSku)
+ {
+ $product = $this->productRepository->get($productSku);
+
+ if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
+ throw new Exception('Only implemented for bundle product', Exception::HTTP_FORBIDDEN);
+ }
+
+ return $product;
+ }
+}
diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/ReadServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadServiceInterface.php
new file mode 100644
index 0000000000000..14abab5ec34a5
--- /dev/null
+++ b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadServiceInterface.php
@@ -0,0 +1,48 @@
+type = $type;
+ $this->typeConverter = $typeConverter;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getTypes()
+ {
+ $optionList = $this->type->toOptionArray();
+
+ /** @var Type[] $typeDtoList */
+ $typeDtoList = [];
+ foreach ($optionList as $option) {
+ $typeDtoList[] = $this->typeConverter->createDataFromModel($option);
+ }
+ return $typeDtoList;
+ }
+}
diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceInterface.php
new file mode 100644
index 0000000000000..90fbc02a75e15
--- /dev/null
+++ b/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceInterface.php
@@ -0,0 +1,34 @@
+productRepository = $productRepository;
+ $this->type = $type;
+ $this->optionConverter = $optionConverter;
+ $this->storeManager = $storeManager;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function remove($productSku, $optionId)
+ {
+ $product = $this->getProduct($productSku);
+ $optionCollection = $this->type->getOptionsCollection($product);
+ $optionCollection->setIdFilter($optionId);
+
+ /** @var \Magento\Bundle\Model\Option $removeOption */
+ $removeOption = $optionCollection->getFirstItem();
+ if (!$removeOption->getId()) {
+ throw new NoSuchEntityException('Requested option doesn\'t exist');
+ }
+ $removeOption->delete();
+
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function add($productSku, Option $option)
+ {
+ $product = $this->getProduct($productSku);
+ $optionModel = $this->optionConverter->createModelFromData($option, $product);
+ $optionModel->setStoreId($this->storeManager->getStore()->getId());
+
+ try {
+ $optionModel->save();
+ } catch (\Exception $e) {
+ throw new CouldNotSaveException('Could not save option', [], $e);
+ }
+
+ return $optionModel->getId();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function update($productSku, $optionId, \Magento\Bundle\Service\V1\Data\Product\Option $option)
+ {
+ $product = $this->getProduct($productSku);
+ $optionCollection = $this->type->getOptionsCollection($product);
+ $optionCollection->setIdFilter($optionId);
+
+ /** @var \Magento\Bundle\Model\Option $optionModel */
+ $optionModel = $optionCollection->getFirstItem();
+ $updateOption = $this->optionConverter->getModelFromData($option, $optionModel);
+
+ if (!$updateOption->getId()) {
+ throw new NoSuchEntityException('Requested option doesn\'t exist');
+ }
+ $updateOption->setStoreId($this->storeManager->getStore()->getId());
+
+ try {
+ $updateOption->save();
+ } catch (\Exception $e) {
+ throw new CouldNotSaveException('Could not save option', [], $e);
+ }
+
+ return true;
+ }
+
+ /**
+ * @param string $productSku
+ * @return Product
+ * @throws Exception
+ */
+ private function getProduct($productSku)
+ {
+ $product = $this->productRepository->get($productSku);
+
+ if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
+ throw new Exception(
+ 'Product with specified sku: "%1" is not a bundle product',
+ Exception::HTTP_FORBIDDEN,
+ Exception::HTTP_FORBIDDEN,
+ [
+ $product->getSku()
+ ]
+ );
+ }
+
+ return $product;
+ }
+}
diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/WriteServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteServiceInterface.php
new file mode 100644
index 0000000000000..a5992eb2f7af9
--- /dev/null
+++ b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteServiceInterface.php
@@ -0,0 +1,61 @@
+
+
+
+
diff --git a/app/code/Magento/Bundle/etc/webapi.xml b/app/code/Magento/Bundle/etc/webapi.xml
index 757c74cee5b13..8e9ea1b5287af 100644
--- a/app/code/Magento/Bundle/etc/webapi.xml
+++ b/app/code/Magento/Bundle/etc/webapi.xml
@@ -43,4 +43,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml
index c66e9c8e7070c..f59849e66d53f 100644
--- a/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml
+++ b/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml
@@ -42,19 +42,19 @@
getOrderItem()->getParentItem()): ?>
getSelectionAttributes($_item) ?>
-