-
-
-
-
-
-
+
+
+
+
+
-
-
+
+
diff --git a/app/code/Magento/Backend/view/adminhtml/layout/popup.xml b/app/code/Magento/Backend/view/adminhtml/layout/popup.xml
index 17da4d9b56eb7..e6f59c729501d 100644
--- a/app/code/Magento/Backend/view/adminhtml/layout/popup.xml
+++ b/app/code/Magento/Backend/view/adminhtml/layout/popup.xml
@@ -7,7 +7,7 @@
-->
-
-
+
+
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php
index 9e15c4246cc04..6d444009f5a77 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php
@@ -73,9 +73,10 @@ public function dispatch(\Magento\Framework\App\RequestInterface $request)
}
/**
+ * @param \Magento\Framework\Phrase|null $title
* @return \Magento\Backend\Model\View\Result\Page
*/
- protected function createActionPage()
+ protected function createActionPage($title = null)
{
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
@@ -91,6 +92,9 @@ protected function createActionPage()
$resultPage->addBreadcrumb(__('Catalog'), __('Catalog'))
->addBreadcrumb(__('Manage Product Attributes'), __('Manage Product Attributes'))
->setActiveMenu('Magento_Catalog::catalog_attributes_attributes');
+ if (!empty($title)) {
+ $resultPage->addBreadcrumb($title, $title);
+ }
}
$resultPage->getConfig()->getTitle()->prepend(__('Product Attributes'));
return $resultPage;
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Edit.php
index f149ff2506a6c..8aa19c8c91110 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Edit.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Edit.php
@@ -52,9 +52,8 @@ public function execute()
$item = $id ? __('Edit Product Attribute') : __('New Product Attribute');
- $resultPage = $this->createActionPage();
+ $resultPage = $this->createActionPage($item);
$resultPage->getConfig()->getTitle()->prepend($id ? $model->getName() : __('New Product Attribute'));
- $resultPage->addBreadcrumb($item, $item);
$resultPage->getLayout()
->getBlock('attribute_edit_js')
->setIsPopup((bool)$this->getRequest()->getParam('popup'));
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php
index 8e1dd606e5e19..b37fed05c1e54 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php
@@ -57,7 +57,7 @@ public function _validateMassStatus(array $productIds, $status)
*/
public function execute()
{
- $productIds = (array) $this->getRequest()->getParam('product');
+ $productIds = (array) $this->getRequest()->getParam('selected');
$storeId = (int) $this->getRequest()->getParam('store', 0);
$status = (int) $this->getRequest()->getParam('status');
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php
new file mode 100644
index 0000000000000..294860b66a912
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php
@@ -0,0 +1,255 @@
+request = $this->getMockBuilder('Magento\Framework\App\RequestInterface')->getMock();
+
+ $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface')->getMock();
+
+ $this->eavAttribute = $this->getMock(
+ 'Magento\Catalog\Model\Resource\Eav\Attribute',
+ ['setEntityTypeId', 'load', 'getId', 'getEntityTypeId', 'addData', 'getName'],
+ [],
+ '',
+ false
+ );
+
+ $this->registry = $this->getMock('Magento\Framework\Registry', [], [], '', false);
+
+ $this->resultPage = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page')
+ ->disableOriginalConstructor()
+ ->setMethods(['setActiveMenu', 'getConfig', 'addBreadcrumb', 'addHandle', 'getLayout'])
+ ->getMock();
+
+ $this->resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory')
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+
+ $this->resultLayout = $this->getMockBuilder('Magento\Framework\View\Result\Layout')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->pageConfig = $this->getMockBuilder('Magento\Framework\View\Page\Config')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->pageTitle = $this->getMockBuilder('Magento\Framework\View\Page\Title')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->layout = $this->getMock('Magento\Framework\View\Layout', ['getBlock'], [], '', false);
+
+ $this->session = $this->getMockBuilder('Magento\Backend\Model\Session')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->blockTemplate = $this->getMockBuilder('Magento\Backend\Block\Template')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->context = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false);
+ $this->context->expects($this->any())->method('getRequest')->willReturn($this->request);
+ $this->context->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
+ $this->context->expects($this->any())->method('getResultPageFactory')->willReturn($this->resultPageFactory);
+ $this->context->expects($this->any())->method('getSession')->willReturn($this->session);
+
+ $this->objectManager = new ObjectManager($this);
+ $this->editController = $this->objectManager->getObject(
+ 'Magento\Catalog\Controller\Adminhtml\Product\Attribute\Edit',
+ [
+ 'context' => $this->context,
+ 'resultPageFactory' => $this->resultPageFactory
+ ]
+ );
+ }
+
+ public function testExecutePopup()
+ {
+ $attributesData = ['frontend_label' => ''];
+
+ $this->request->expects($this->any())->method('getParam')->willReturnMap(
+ [
+ ['attribute_id', null, null],
+ ['attribute', null, $attributesData],
+ ['popup', null, '1'],
+ ['product_tab', null, null]
+ ]
+ );
+
+ $this->objectManagerMock->expects($this->any())->method('create')
+ ->with('Magento\Catalog\Model\Resource\Eav\Attribute')
+ ->willReturn($this->eavAttribute);
+ $this->objectManagerMock->expects($this->any())->method('get')
+ ->with('Magento\Backend\Model\Session')
+ ->willReturn($this->session);
+
+ $this->eavAttribute->expects($this->once())->method('setEntityTypeId')->willReturnSelf();
+ $this->eavAttribute->expects($this->once())->method('addData')->with($attributesData)->willReturnSelf();
+ $this->eavAttribute->expects($this->any())->method('getName')->willReturn(null);
+
+ $this->registry->expects($this->any())
+ ->method('register')
+ ->with('entity_attribute', $this->eavAttribute);
+
+ $this->resultPage->expects($this->once())
+ ->method('addHandle')
+ ->with(['popup', 'catalog_product_attribute_edit_popup'])
+ ->willReturnSelf();
+ $this->resultPage->expects($this->any())->method('getConfig')->willReturn($this->pageConfig);
+ $this->resultPage->expects($this->once())->method('getLayout')->willReturn($this->layout);
+
+ $this->resultPageFactory->expects($this->atLeastOnce())
+ ->method('create')
+ ->willReturn($this->resultPage);
+
+ $this->pageConfig->expects($this->any())->method('addBodyClass')->willReturnSelf();
+ $this->pageConfig->expects($this->any())->method('getTitle')->willReturn($this->pageTitle);
+
+ $this->pageTitle->expects($this->any())->method('prepend')->willReturnSelf();
+
+ $this->layout->expects($this->once())->method('getBlock')->willReturn($this->blockTemplate);
+
+ $this->blockTemplate->expects($this->any())->method('setIsPopup')->willReturnSelf();
+
+ $this->assertSame($this->resultPage, $this->editController->execute());
+ }
+
+ public function testExecuteNoPopup()
+ {
+ $attributesData = ['frontend_label' => ''];
+
+ $this->request->expects($this->any())->method('getParam')->willReturnMap(
+ [
+ ['attribute_id', null, null],
+ ['attribute', null, $attributesData],
+ ['popup', null, false],
+ ]
+ );
+
+ $this->objectManagerMock->expects($this->any())->method('create')
+ ->with('Magento\Catalog\Model\Resource\Eav\Attribute')
+ ->willReturn($this->eavAttribute);
+ $this->objectManagerMock->expects($this->any())->method('get')
+ ->with('Magento\Backend\Model\Session')
+ ->willReturn($this->session);
+
+ $this->eavAttribute->expects($this->once())->method('setEntityTypeId')->willReturnSelf();
+ $this->eavAttribute->expects($this->once())->method('addData')->with($attributesData)->willReturnSelf();
+
+ $this->registry->expects($this->any())
+ ->method('register')
+ ->with('entity_attribute', $this->eavAttribute);
+
+ $this->resultPage->expects($this->any())->method('addBreadcrumb')->willReturnSelf();
+ $this->resultPage->expects($this->once())
+ ->method('setActiveMenu')
+ ->with('Magento_Catalog::catalog_attributes_attributes')
+ ->willReturnSelf();
+ $this->resultPage->expects($this->any())->method('getConfig')->willReturn($this->pageConfig);
+ $this->resultPage->expects($this->once())->method('getLayout')->willReturn($this->layout);
+
+ $this->resultPageFactory->expects($this->atLeastOnce())
+ ->method('create')
+ ->willReturn($this->resultPage);
+
+ $this->pageConfig->expects($this->any())->method('getTitle')->willReturn($this->pageTitle);
+
+ $this->pageTitle->expects($this->any())->method('prepend')->willReturnSelf();
+
+ $this->eavAttribute->expects($this->any())->method('getName')->willReturn(null);
+
+ $this->layout->expects($this->once())->method('getBlock')->willReturn($this->blockTemplate);
+
+ $this->blockTemplate->expects($this->any())->method('setIsPopup')->willReturnSelf();
+
+ $this->assertSame($this->resultPage, $this->editController->execute());
+ }
+}
diff --git a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_attribute_edit_popup.xml b/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_attribute_edit_popup.xml
old mode 100644
new mode 100755
index 82899deca4005..3e99afa0dbeac
--- a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_attribute_edit_popup.xml
+++ b/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_attribute_edit_popup.xml
@@ -5,9 +5,11 @@
* See COPYING.txt for license details.
*/
-->
-
+
-
+
+
+
diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml
index c375e94de8ca2..26e38498375f6 100644
--- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml
+++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml
@@ -210,12 +210,12 @@
enableEnable
- catalog/product/massEnable
+ catalog/product/massStatus/status/1disableDisable
- catalog/product/massDisable
+ catalog/product/massStatus/status/2
diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_gallery.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_gallery.xml
old mode 100644
new mode 100755
index d29b981fd47cb..3eba65002e1a2
--- a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_gallery.xml
+++ b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_gallery.xml
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
diff --git a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/AddQuantityFilterToCollection.php b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/AddQuantityFilterToCollection.php
index d1b14ad2b21b6..0c4617dac08eb 100644
--- a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/AddQuantityFilterToCollection.php
+++ b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/AddQuantityFilterToCollection.php
@@ -19,16 +19,16 @@ class AddQuantityFilterToCollection implements AddFilterToCollectionInterface
*/
public function addFilter(Collection $collection, $field, $condition = null)
{
- if (isset($condition['from'])) {
+ if (isset($condition['gteq'])) {
$collection->getSelect()->where(
AbstractCollection::ATTRIBUTE_TABLE_ALIAS_PREFIX . 'qty.qty >= ?',
- (float)$condition['from']
+ (float)$condition['gteq']
);
}
- if ($condition['to']) {
+ if (isset($condition['lteq'])) {
$collection->getSelect()->where(
AbstractCollection::ATTRIBUTE_TABLE_ALIAS_PREFIX . 'qty.qty <= ?',
- (float)$condition['to']
+ (float)$condition['lteq']
);
}
}
diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml
index be5917f36ba62..500a2459192ea 100644
--- a/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml
+++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml
@@ -411,6 +411,6 @@
-
+
diff --git a/app/code/Magento/Cms/Model/Resource/AbstractCollection.php b/app/code/Magento/Cms/Model/Resource/AbstractCollection.php
index 5d4f961877c59..48188c96b7706 100644
--- a/app/code/Magento/Cms/Model/Resource/AbstractCollection.php
+++ b/app/code/Magento/Cms/Model/Resource/AbstractCollection.php
@@ -5,132 +5,159 @@
*/
namespace Magento\Cms\Model\Resource;
-use Magento\Framework\Data\AbstractSearchResult;
-use Magento\Store\Model\StoreManagerInterface;
-use Magento\Framework\Data\SearchResultProcessorFactory;
-use Magento\Framework\Data\SearchResultProcessor;
-use Magento\Framework\DB\QueryInterface;
-use Magento\Framework\Data\Collection\EntityFactoryInterface;
-use Magento\Framework\Event\ManagerInterface;
-use Magento\Framework\Data\SearchResultIteratorFactory;
-
/**
- * CMS block model
+ * Abstract collection of CMS pages and blocks
*/
-class AbstractCollection extends AbstractSearchResult
+abstract class AbstractCollection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection
{
/**
+ * Store manager
+ *
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $storeManager;
/**
- * @var SearchResultProcessor
+ * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
+ * @param \Psr\Log\LoggerInterface $logger
+ * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
+ * @param \Magento\Framework\Event\ManagerInterface $eventManager
+ * @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
+ * @param \Magento\Framework\Model\Resource\Db\AbstractDb|null $resource
*/
- protected $searchResultProcessor;
+ public function __construct(
+ \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
+ \Psr\Log\LoggerInterface $logger,
+ \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
+ \Magento\Framework\Event\ManagerInterface $eventManager,
+ \Magento\Store\Model\StoreManagerInterface $storeManager,
+ \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
+ \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null
+ ) {
+ parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
+ $this->storeManager = $storeManager;
+ }
/**
- * Table which links CMS entity to stores
+ * Perform operations after collection load
*
- * @var string
+ * @param string $tableName
+ * @param string $columnName
+ * @return void
*/
- protected $storeTableName;
+ protected function performAfterLoad($tableName, $columnName)
+ {
+ $items = $this->getColumnValues($columnName);
+ if (count($items)) {
+ $connection = $this->getConnection();
+ $select = $connection->select()->from(['cms_entity_store' => $this->getTable($tableName)])
+ ->where('cms_entity_store.' . $columnName . ' IN (?)', $items);
+ $result = $connection->fetchPairs($select);
+ if ($result) {
+ foreach ($this as $item) {
+ $entityId = $item->getData($columnName);
+ if (!isset($result[$entityId])) {
+ continue;
+ }
+ if ($result[$entityId] == 0) {
+ $stores = $this->storeManager->getStores(false, true);
+ $storeId = current($stores)->getId();
+ $storeCode = key($stores);
+ } else {
+ $storeId = $result[$item->getData($columnName)];
+ $storeCode = $this->storeManager->getStore($storeId)->getCode();
+ }
+ $item->setData('_first_store_id', $storeId);
+ $item->setData('store_code', $storeCode);
+ $item->setData('store_id', [$result[$entityId]]);
+ }
+ }
+ }
+ }
/**
- * @var string
+ * Add field filter to collection
+ *
+ * @param array|string $field
+ * @param string|int|array|null $condition
+ * @return $this
*/
- protected $linkFieldName;
+ public function addFieldToFilter($field, $condition = null)
+ {
+ if ($field === 'store_id') {
+ return $this->addStoreFilter($condition, false);
+ }
+
+ return parent::addFieldToFilter($field, $condition);
+ }
/**
- * @param QueryInterface $query
- * @param EntityFactoryInterface $entityFactory
- * @param ManagerInterface $eventManager
- * @param SearchResultIteratorFactory $resultIteratorFactory
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- * @param SearchResultProcessorFactory $searchResultProcessorFactory
+ * Add filter by store
+ *
+ * @param int|array|\Magento\Store\Model\Store $store
+ * @param bool $withAdmin
+ * @return $this
*/
- public function __construct(
- QueryInterface $query,
- EntityFactoryInterface $entityFactory,
- ManagerInterface $eventManager,
- SearchResultIteratorFactory $resultIteratorFactory,
- StoreManagerInterface $storeManager,
- SearchResultProcessorFactory $searchResultProcessorFactory
- ) {
- $this->storeManager = $storeManager;
- $this->searchResultProcessor = $searchResultProcessorFactory->create($this);
- parent::__construct($query, $entityFactory, $eventManager, $resultIteratorFactory);
- }
+ abstract public function addStoreFilter($store, $withAdmin = true);
/**
+ * Perform adding filter by store
+ *
+ * @param int|array|\Magento\Store\Model\Store $store
+ * @param bool $withAdmin
* @return void
*/
- protected function init()
+ protected function performAddStoreFilter($store, $withAdmin = true)
{
- $this->query->addCountSqlSkipPart(\Magento\Framework\DB\Select::GROUP, true);
+ if ($store instanceof \Magento\Store\Model\Store) {
+ $store = [$store->getId()];
+ }
+
+ if (!is_array($store)) {
+ $store = [$store];
+ }
+
+ if ($withAdmin) {
+ $store[] = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
+ }
+
+ $this->addFilter('store', ['in' => $store], 'public');
}
/**
- * @return array
+ * Join store relation table if there is store filter
+ *
+ * @param string $tableName
+ * @param string $columnName
+ * @return void
*/
- public function toOptionIdArray()
+ protected function joinStoreRelationTable($tableName, $columnName)
{
- $res = [];
- $existingIdentifiers = [];
- foreach ($this->getItems() as $item) {
- /** @var \Magento\Cms\Model\Block|\Magento\Cms\Model\Page $item */
- $identifier = $item->getIdentifier();
-
- $data['value'] = $identifier;
- $data['label'] = $item->getTitle();
-
- if (in_array($identifier, $existingIdentifiers)) {
- $data['value'] .= '|' . $item->getId();
- } else {
- $existingIdentifiers[] = $identifier;
- }
- $res[] = $data;
+ if ($this->getFilter('store')) {
+ $this->getSelect()->join(
+ ['store_table' => $this->getTable($tableName)],
+ 'main_table.' . $columnName . ' = store_table.' . $columnName,
+ []
+ )->group(
+ 'main_table.' . $columnName
+ );
}
- return $res;
+ parent::_renderFiltersBefore();
}
/**
- * Perform operations after collection load
+ * Get SQL for get record count
*
- * @return void
+ * Extra GROUP BY strip added.
+ *
+ * @return \Magento\Framework\DB\Select
*/
- protected function afterLoad()
+ public function getSelectCountSql()
{
- if ($this->getSearchCriteria()->getPart('first_store_flag')) {
- $items = $this->searchResultProcessor->getColumnValues($this->linkFieldName);
+ $countSelect = parent::getSelectCountSql();
+ $countSelect->reset(\Magento\Framework\DB\Select::GROUP);
- $connection = $this->getQuery()->getConnection();
- $resource = $this->getQuery()->getResource();
- if (count($items)) {
- $select = $connection->select()->from(['cps' => $resource->getTable($this->storeTableName)])
- ->where("cps.{$this->linkFieldName} IN (?)", $items);
- $result = $connection->fetchPairs($select);
- if ($result) {
- foreach ($this->getItems() as $item) {
- /** @var BlockInterface $item */
- if (!isset($result[$item->getId()])) {
- continue;
- }
- if ($result[$item->getId()] == 0) {
- $stores = $this->storeManager->getStores(false, true);
- $storeId = current($stores)->getId();
- $storeCode = key($stores);
- } else {
- $storeId = $result[$item->getId()];
- $storeCode = $this->storeManager->getStore($storeId)->getCode();
- }
- $item->setData('_first_store_id', $storeId);
- $item->setData('store_code', $storeCode);
- $item->setData('store_id', [$result[$item->getId()]]);
- }
- }
- }
- }
- parent::afterLoad();
+ return $countSelect;
}
}
diff --git a/app/code/Magento/Cms/Model/Resource/Block/Collection.php b/app/code/Magento/Cms/Model/Resource/Block/Collection.php
index bb7657bdb357f..2a355ca47bcd6 100644
--- a/app/code/Magento/Cms/Model/Resource/Block/Collection.php
+++ b/app/code/Magento/Cms/Model/Resource/Block/Collection.php
@@ -1,16 +1,16 @@
walk('afterLoad');
- parent::_afterLoad();
- }
+ $this->performAfterLoad('cms_block_store', 'block_id');
- /**
- * @param string|array $field
- * @param string|int|array|null $condition
- * @return \Magento\Cms\Model\Resource\Block\Collection
- */
- public function addFieldToFilter($field, $condition = null)
- {
- if ($field == 'store_id') {
- return $this->addStoreFilter($condition, false);
- }
- return parent::addFieldToFilter($field, $condition);
+ return parent::_afterLoad();
}
/**
@@ -63,44 +53,17 @@ public function toOptionArray()
/**
* Add filter by store
*
- * @param int|\Magento\Store\Model\Store $store
+ * @param int|array|\Magento\Store\Model\Store $store
* @param bool $withAdmin
* @return $this
*/
public function addStoreFilter($store, $withAdmin = true)
{
- if ($store instanceof \Magento\Store\Model\Store) {
- $store = [$store->getId()];
- }
-
- if (!is_array($store)) {
- $store = [$store];
- }
-
- if ($withAdmin) {
- $store[] = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
- }
-
- $this->addFilter('store', ['in' => $store], 'public');
+ $this->performAddStoreFilter($store, $withAdmin);
return $this;
}
- /**
- * Get SQL for get record count.
- * Extra GROUP BY strip added.
- *
- * @return \Magento\Framework\DB\Select
- */
- public function getSelectCountSql()
- {
- $countSelect = parent::getSelectCountSql();
-
- $countSelect->reset(\Magento\Framework\DB\Select::GROUP);
-
- return $countSelect;
- }
-
/**
* Join store relation table if there is store filter
*
@@ -108,15 +71,6 @@ public function getSelectCountSql()
*/
protected function _renderFiltersBefore()
{
- if ($this->getFilter('store')) {
- $this->getSelect()->join(
- ['store_table' => $this->getTable('cms_block_store')],
- 'main_table.block_id = store_table.block_id',
- []
- )->group(
- 'main_table.block_id'
- );
- }
- parent::_renderFiltersBefore();
+ $this->joinStoreRelationTable('cms_block_store', 'block_id');
}
}
diff --git a/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php b/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php
index 7d8193c4bab99..6f3759681ab8e 100644
--- a/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php
+++ b/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php
@@ -10,8 +10,7 @@
use Magento\Cms\Model\Resource\Block\Collection as BlockCollection;
/**
- * Class Collection
- * Collection for displaying grid of sales documents
+ * Collection for displaying grid of cms blocks
*/
class Collection extends BlockCollection implements SearchResultInterface
{
@@ -25,8 +24,9 @@ class Collection extends BlockCollection implements SearchResultInterface
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
* @param \Magento\Framework\Event\ManagerInterface $eventManager
- * @param null|\Zend_Db_Adapter_Abstract $mainTable
- * @param \Magento\Framework\Model\Resource\Db\AbstractDb $eventPrefix
+ * @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param string $mainTable
+ * @param string $eventPrefix
* @param string $eventObject
* @param string $resourceModel
* @param string $model
@@ -40,6 +40,7 @@ public function __construct(
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
\Magento\Framework\Event\ManagerInterface $eventManager,
+ \Magento\Store\Model\StoreManagerInterface $storeManager,
$mainTable,
$eventPrefix,
$eventObject,
@@ -53,6 +54,7 @@ public function __construct(
$logger,
$fetchStrategy,
$eventManager,
+ $storeManager,
$connection,
$resource
);
diff --git a/app/code/Magento/Cms/Model/Resource/Page/Collection.php b/app/code/Magento/Cms/Model/Resource/Page/Collection.php
index b8eadc87623f8..8ef01de72f127 100644
--- a/app/code/Magento/Cms/Model/Resource/Page/Collection.php
+++ b/app/code/Magento/Cms/Model/Resource/Page/Collection.php
@@ -5,12 +5,12 @@
*/
namespace Magento\Cms\Model\Resource\Page;
+use \Magento\Cms\Model\Resource\AbstractCollection;
+
/**
* CMS page collection
- *
- * Class Collection
*/
-class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection
+class Collection extends AbstractCollection
{
/**
* @var string
@@ -24,35 +24,6 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
*/
protected $_previewFlag;
- /**
- * Store manager
- *
- * @var \Magento\Store\Model\StoreManagerInterface
- */
- protected $_storeManager;
-
- /**
- * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
- * @param \Psr\Log\LoggerInterface $logger
- * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
- * @param \Magento\Framework\Event\ManagerInterface $eventManager
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- * @param mixed $connection
- * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource
- */
- public function __construct(
- \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
- \Psr\Log\LoggerInterface $logger,
- \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
- \Magento\Framework\Event\ManagerInterface $eventManager,
- \Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
- \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null
- ) {
- parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
- $this->_storeManager = $storeManager;
- }
-
/**
* Define resource model
*
@@ -105,45 +76,17 @@ public function setFirstStoreFlag($flag = false)
return $this;
}
- /**
- * Add field filter to collection
- *
- * @param string|array $field
- * @param string|int|array|null $condition
- * @return \Magento\Cms\Model\Resource\Block\Collection
- */
- public function addFieldToFilter($field, $condition = null)
- {
- if ($field === 'store_id') {
- return $this->addStoreFilter($condition, false);
- }
-
- return parent::addFieldToFilter($field, $condition);
- }
-
/**
* Add filter by store
*
- * @param int|\Magento\Store\Model\Store $store
+ * @param int|array|\Magento\Store\Model\Store $store
* @param bool $withAdmin
* @return $this
*/
public function addStoreFilter($store, $withAdmin = true)
{
if (!$this->getFlag('store_filter_added')) {
- if ($store instanceof \Magento\Store\Model\Store) {
- $store = [$store->getId()];
- }
-
- if (!is_array($store)) {
- $store = [$store];
- }
-
- if ($withAdmin) {
- $store[] = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
- }
-
- $this->addFilter('store', ['in' => $store], 'public');
+ $this->performAddStoreFilter($store, $withAdmin);
}
return $this;
}
@@ -155,67 +98,19 @@ public function addStoreFilter($store, $withAdmin = true)
*/
protected function _afterLoad()
{
- $items = $this->getColumnValues('page_id');
- if (count($items)) {
- $connection = $this->getConnection();
- $select = $connection->select()->from(['cps' => $this->getTable('cms_page_store')])
- ->where('cps.page_id IN (?)', $items);
- $result = $connection->fetchPairs($select);
- if ($result) {
- foreach ($this as $item) {
- $pageId = $item->getData('page_id');
- if (!isset($result[$pageId])) {
- continue;
- }
- if ($result[$pageId] == 0) {
- $stores = $this->_storeManager->getStores(false, true);
- $storeId = current($stores)->getId();
- $storeCode = key($stores);
- } else {
- $storeId = $result[$item->getData('page_id')];
- $storeCode = $this->_storeManager->getStore($storeId)->getCode();
- }
- $item->setData('_first_store_id', $storeId);
- $item->setData('store_code', $storeCode);
- $item->setData('store_id', [$result[$pageId]]);
- }
- }
- }
-
+ $this->performAfterLoad('cms_page_store', 'page_id');
$this->_previewFlag = false;
+
return parent::_afterLoad();
}
/**
- * Join store relation table if there is store filter
+ * Perform operations before rendering filters
*
* @return void
*/
protected function _renderFiltersBefore()
{
- if ($this->getFilter('store')) {
- $this->getSelect()->join(
- ['store_table' => $this->getTable('cms_page_store')],
- 'main_table.page_id = store_table.page_id',
- []
- )->group(
- 'main_table.page_id'
- );
- }
- parent::_renderFiltersBefore();
- }
-
- /**
- * Get SQL for get record count.
- * Extra GROUP BY strip added.
- *
- * @return \Magento\Framework\DB\Select
- */
- public function getSelectCountSql()
- {
- $countSelect = parent::getSelectCountSql();
- $countSelect->reset(\Magento\Framework\DB\Select::GROUP);
-
- return $countSelect;
+ $this->joinStoreRelationTable('cms_page_store', 'page_id');
}
}
diff --git a/app/code/Magento/Cms/Test/Unit/Model/Resource/AbstractCollectionTest.php b/app/code/Magento/Cms/Test/Unit/Model/Resource/AbstractCollectionTest.php
new file mode 100644
index 0000000000000..0f091388cc785
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Unit/Model/Resource/AbstractCollectionTest.php
@@ -0,0 +1,51 @@
+select = $this->getMockBuilder('Magento\Framework\DB\Select')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->connection = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->connection->expects($this->any())->method('select')->willReturn($this->select);
+
+ $this->resource = $this->getMockBuilder('Magento\Framework\Model\Resource\Db\AbstractDb')
+ ->disableOriginalConstructor()
+ ->setMethods(['getConnection', 'getMainTable', 'getTable'])
+ ->getMockForAbstractClass();
+ $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection);
+ $this->resource->expects($this->any())->method('getMainTable')->willReturn('table_test');
+ $this->resource->expects($this->any())->method('getTable')->willReturn('test');
+
+ $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ }
+}
diff --git a/app/code/Magento/Cms/Test/Unit/Model/Resource/Block/CollectionTest.php b/app/code/Magento/Cms/Test/Unit/Model/Resource/Block/CollectionTest.php
new file mode 100644
index 0000000000000..b87c29ca44249
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Unit/Model/Resource/Block/CollectionTest.php
@@ -0,0 +1,63 @@
+collection = $this->objectManager->getObject(
+ 'Magento\Cms\Model\Resource\Block\Collection',
+ [
+ 'resource' => $this->resource,
+ 'connection' => $this->connection
+ ]
+ );
+ }
+
+ public function testAddFieldToFilterStore()
+ {
+ $storeId = 1;
+
+ $expectedFilter = new DataObject(
+ [
+ 'field' => 'store',
+ 'value' => ['in' => [1]],
+ 'type' => 'public'
+ ]
+ );
+
+ $this->assertSame($this->collection, $this->collection->addFieldToFilter('store_id', $storeId));
+ // addition call to make sure that correct value was set to filter
+ $this->assertEquals($expectedFilter, $this->collection->getFilter('store'));
+ }
+
+ public function testAddFieldToFilter()
+ {
+ $field = 'title';
+ $value = 'test_filter';
+ $searchSql = 'sql query';
+
+ $this->connection->expects($this->any())->method('quoteIdentifier')->willReturn($searchSql);
+ $this->connection->expects($this->any())->method('prepareSqlCondition')->willReturn($searchSql);
+
+ $this->select->expects($this->once())
+ ->method('where')
+ ->with($searchSql, null, \Magento\Framework\DB\Select::TYPE_CONDITION);
+
+ $this->assertSame($this->collection, $this->collection->addFieldToFilter($field, $value));
+ }
+}
diff --git a/app/code/Magento/Cms/Test/Unit/Model/Resource/Block/Grid/CollectionTest.php b/app/code/Magento/Cms/Test/Unit/Model/Resource/Block/Grid/CollectionTest.php
deleted file mode 100644
index c320124de3624..0000000000000
--- a/app/code/Magento/Cms/Test/Unit/Model/Resource/Block/Grid/CollectionTest.php
+++ /dev/null
@@ -1,89 +0,0 @@
-select = $this->getMockBuilder('Magento\Framework\DB\Select')
- ->disableOriginalConstructor()
- ->getMock();
-
- $connection = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql')
- ->disableOriginalConstructor()
- ->getMock();
- $connection->expects($this->any())
- ->method('select')
- ->will($this->returnValue($this->select));
-
- $resource = $this->getMockBuilder('Magento\Framework\Model\Resource\Db\AbstractDb')
- ->disableOriginalConstructor()
- ->setMethods(['__wakeup', 'getConnection'])
- ->getMockForAbstractClass();
- $resource->expects($this->any())
- ->method('getConnection')
- ->will($this->returnValue($connection));
-
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $arguments = $objectManagerHelper->getConstructArguments(
- 'Magento\Cms\Model\Resource\Block\Collection',
- ['resource' => $resource, 'connection' => $connection]
- );
-
- $this->collection = $this->getMockBuilder('Magento\Cms\Model\Resource\Block\Collection')
- ->setConstructorArgs($arguments)
- ->setMethods(['addFilter', '_translateCondition', 'getMainTable'])
- ->getMock();
- }
-
- public function testAddFieldToFilterSore()
- {
- $storeId = 1;
- $this->collection->expects($this->once())
- ->method('addFilter')
- ->with(
- $this->equalTo('store'),
- $this->equalTo(['in' => [$storeId]]),
- $this->equalTo('public')
- );
- $this->collection->addFieldToFilter('store_id', $storeId);
- }
-
- public function testAddFieldToFilter()
- {
- $field = 'title';
- $value = 'test_filter';
- $searchSql = 'sql query';
-
- $this->collection->expects($this->once())
- ->method('_translateCondition')
- ->with($field, $value)
- ->will($this->returnValue($searchSql));
-
- $this->select->expects($this->once())
- ->method('where')
- ->with(
- $this->equalTo($searchSql),
- $this->equalTo(null),
- $this->equalTo(\Magento\Framework\DB\Select::TYPE_CONDITION)
- );
-
- $this->collection->addFieldToFilter($field, $value);
- }
-}
diff --git a/app/code/Magento/Cms/Test/Unit/Model/Resource/Page/CollectionTest.php b/app/code/Magento/Cms/Test/Unit/Model/Resource/Page/CollectionTest.php
new file mode 100644
index 0000000000000..3ed7babaf1062
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Unit/Model/Resource/Page/CollectionTest.php
@@ -0,0 +1,63 @@
+collection = $this->objectManager->getObject(
+ 'Magento\Cms\Model\Resource\Page\Collection',
+ [
+ 'resource' => $this->resource,
+ 'connection' => $this->connection
+ ]
+ );
+ }
+
+ public function testAddFieldToFilterStore()
+ {
+ $storeId = 1;
+
+ $expectedFilter = new DataObject(
+ [
+ 'field' => 'store',
+ 'value' => ['in' => [1]],
+ 'type' => 'public'
+ ]
+ );
+
+ $this->assertSame($this->collection, $this->collection->addFieldToFilter('store_id', $storeId));
+ // addition call to make sure that correct value was set to filter
+ $this->assertEquals($expectedFilter, $this->collection->getFilter('store'));
+ }
+
+ public function testAddFieldToFilter()
+ {
+ $field = 'title';
+ $value = 'test_filter';
+ $searchSql = 'sql query';
+
+ $this->connection->expects($this->any())->method('quoteIdentifier')->willReturn($searchSql);
+ $this->connection->expects($this->any())->method('prepareSqlCondition')->willReturn($searchSql);
+
+ $this->select->expects($this->once())
+ ->method('where')
+ ->with($searchSql, null, \Magento\Framework\DB\Select::TYPE_CONDITION);
+
+ $this->assertSame($this->collection, $this->collection->addFieldToFilter($field, $value));
+ }
+}
diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/Cms/OptionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/Cms/OptionsTest.php
new file mode 100644
index 0000000000000..37e2e54c25c16
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/Cms/OptionsTest.php
@@ -0,0 +1,123 @@
+systemStoreMock = $this->getMockBuilder('Magento\Store\Model\System\Store')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->websiteMock = $this->getMock(
+ 'Magento\Store\Model\Website',
+ ['getId', 'getName'],
+ [],
+ '',
+ false
+ );
+
+ $this->groupMock = $this->getMock('Magento\Store\Model\Group', [], [], '', false);
+
+ $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
+
+ $this->escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false);
+
+ $this->options = $objectManager->getObject(
+ 'Magento\Cms\Ui\Component\Listing\Column\Cms\Options',
+ [
+ 'systemStore' => $this->systemStoreMock,
+ 'escaper' => $this->escaperMock
+ ]
+ );
+ }
+
+ public function testToOptionArray()
+ {
+ $websiteCollection = [$this->websiteMock];
+ $groupCollection = [$this->groupMock];
+ $storeCollection = [$this->storeMock];
+
+ $expectedOptions = [
+ [
+ 'label' => __('All Store Views'),
+ 'value' => '0'
+ ],
+ [
+ 'label' => 'Main Website',
+ 'value' => [
+ [
+ 'label' => ' Main Website Store',
+ 'value' => [
+ [
+ 'label' => ' Default Store View',
+ 'value' => '1'
+ ]
+ ]
+ ]
+ ]
+ ]
+ ];
+
+ $this->systemStoreMock->expects($this->once())->method('getWebsiteCollection')->willReturn($websiteCollection);
+ $this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn($groupCollection);
+ $this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn($storeCollection);
+
+ $this->websiteMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
+ $this->websiteMock->expects($this->any())->method('getName')->willReturn('Main Website');
+
+ $this->groupMock->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn('1');
+ $this->groupMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
+ $this->groupMock->expects($this->atLeastOnce())->method('getName')->willReturn('Main Website Store');
+
+ $this->storeMock->expects($this->atLeastOnce())->method('getGroupId')->willReturn('1');
+ $this->storeMock->expects($this->atLeastOnce())->method('getName')->willReturn('Default Store View');
+ $this->storeMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
+
+ $this->escaperMock->expects($this->atLeastOnce())->method('escapeHtml')->willReturnMap(
+ [
+ ['Default Store View', null, 'Default Store View'],
+ ['Main Website Store', null, 'Main Website Store'],
+ ['Main Website', null, 'Main Website']
+ ]
+ );
+
+ $this->assertEquals($expectedOptions, $this->options->toOptionArray());
+ }
+}
diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/Cms/Options.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/Cms/Options.php
new file mode 100644
index 0000000000000..f94376305c255
--- /dev/null
+++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/Cms/Options.php
@@ -0,0 +1,40 @@
+options !== null) {
+ return $this->options;
+ }
+
+ $this->currentOptions['All Store Views']['label'] = __('All Store Views');
+ $this->currentOptions['All Store Views']['value'] = self::ALL_STORE_VIEWS;
+
+ $this->generateCurrentOptions();
+
+ $this->options = array_values($this->currentOptions);
+
+ return $this->options;
+ }
+}
diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml
index c1e9dad73c743..ff1d8285d9c23 100644
--- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml
+++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml
@@ -147,7 +147,7 @@
- Magento\Store\Ui\Component\Listing\Column\Store\Options
+ Magento\Cms\Ui\Component\Listing\Column\Cms\Options
@@ -370,9 +370,10 @@
- Magento_Ui/js/grid/columns/select
+ Magento_Ui/js/grid/columns/column
+ ui/grid/cells/htmlfalsetextleft
diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml
index 7c027f465769f..230203c34299a 100644
--- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml
+++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml
@@ -159,7 +159,7 @@
- Magento\Store\Ui\Component\Listing\Column\Store\Options
+ Magento\Cms\Ui\Component\Listing\Column\Cms\Options
diff --git a/app/code/Magento/CmsUrlRewrite/etc/setup/events.xml b/app/code/Magento/CmsUrlRewrite/etc/setup/events.xml
new file mode 100644
index 0000000000000..5403719ab7318
--- /dev/null
+++ b/app/code/Magento/CmsUrlRewrite/etc/setup/events.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_attribute_edit_product_tab_variations_popup.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_attribute_edit_product_tab_variations_popup.xml
old mode 100644
new mode 100755
index 5f979c8085927..8ffec72e74e4a
--- a/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_attribute_edit_product_tab_variations_popup.xml
+++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_attribute_edit_product_tab_variations_popup.xml
@@ -5,6 +5,6 @@
* See COPYING.txt for license details.
*/
-->
-
+
diff --git a/app/code/Magento/Deploy/Console/Command/SetModeCommand.php b/app/code/Magento/Deploy/Console/Command/SetModeCommand.php
new file mode 100644
index 0000000000000..0d6e790c593cc
--- /dev/null
+++ b/app/code/Magento/Deploy/Console/Command/SetModeCommand.php
@@ -0,0 +1,115 @@
+objectManager = $objectManager;
+ parent::__construct();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $description = 'Displays current application mode.';
+
+ $this->setName('deploy:mode:set')
+ ->setDescription($description)
+ ->setDefinition([
+ new InputArgument(
+ self::MODE_ARGUMENT,
+ InputArgument::REQUIRED,
+ 'The application mode to set. Available options are "developer" or "production"'
+ ),
+ new InputOption(
+ self::SKIP_COMPILATION_OPTION,
+ 's',
+ InputOption::VALUE_NONE,
+ 'Skips the clearing and regeneration of static content (generated code, preprocessed CSS, '
+ . 'and assets in pub/static/)'
+ )
+ ]);
+ parent::configure();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ try {
+ /** @var \Magento\Deploy\Model\Mode $modeController */
+ $modeController = $this->objectManager->create(
+ 'Magento\Deploy\Model\Mode',
+ [
+ 'input' => $input,
+ 'output' => $output,
+ ]
+ );
+ $toMode = $input->getArgument(self::MODE_ARGUMENT);
+ $skipCompilation = $input->getOption(self::SKIP_COMPILATION_OPTION);
+ switch($toMode) {
+ case State::MODE_DEVELOPER:
+ $modeController->enableDeveloperMode();
+ break;
+ case State::MODE_PRODUCTION:
+ if ($skipCompilation) {
+ $modeController->enableProductionModeMinimal();
+ } else {
+ $modeController->enableProductionMode();
+ }
+ break;
+ default:
+ throw new LocalizedException(__('Cannot switch into given mode "%1"', $toMode));
+ }
+ $output->writeln('Enabled ' . $toMode . ' mode.');
+ } catch (\Exception $e) {
+ $output->writeln('' . $e->getMessage() . '');
+ if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
+ $output->writeln($e->getTraceAsString());
+ }
+ return;
+ }
+ }
+}
diff --git a/app/code/Magento/Deploy/Console/Command/ShowModeCommand.php b/app/code/Magento/Deploy/Console/Command/ShowModeCommand.php
new file mode 100644
index 0000000000000..b9bfddf5f0b03
--- /dev/null
+++ b/app/code/Magento/Deploy/Console/Command/ShowModeCommand.php
@@ -0,0 +1,74 @@
+objectManager = $objectManager;
+ parent::__construct();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $description = 'Displays current application mode.';
+
+ $this->setName('deploy:mode:show')->setDescription($description);
+ parent::configure();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ try {
+ /** @var \Magento\Deploy\Model\Mode $mode */
+ $mode = $this->objectManager->create(
+ 'Magento\Deploy\Model\Mode',
+ [
+ 'input' => $input,
+ 'output' => $output,
+ ]
+ );
+ $currentMode = $mode->getMode() ?: State::MODE_DEFAULT;
+ $output->writeln("Current application mode: $currentMode.");
+ } catch (\Exception $e) {
+ $output->writeln('' . $e->getMessage() . '');
+ if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
+ $output->writeln($e->getTraceAsString());
+ }
+ return;
+ }
+ }
+}
diff --git a/app/code/Magento/Deploy/LICENSE.txt b/app/code/Magento/Deploy/LICENSE.txt
new file mode 100644
index 0000000000000..49525fd99da9c
--- /dev/null
+++ b/app/code/Magento/Deploy/LICENSE.txt
@@ -0,0 +1,48 @@
+
+Open Software License ("OSL") v. 3.0
+
+This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Open Software License version 3.0
+
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
+
+ 4. to perform the Original Work publicly; and
+
+ 5. to display the Original Work publicly.
+
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+ 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
\ No newline at end of file
diff --git a/app/code/Magento/Deploy/LICENSE_AFL.txt b/app/code/Magento/Deploy/LICENSE_AFL.txt
new file mode 100644
index 0000000000000..87943b95d43a5
--- /dev/null
+++ b/app/code/Magento/Deploy/LICENSE_AFL.txt
@@ -0,0 +1,48 @@
+
+Academic Free License ("AFL") v. 3.0
+
+This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Academic Free License version 3.0
+
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License;
+
+ 4. to perform the Original Work publicly; and
+
+ 5. to display the Original Work publicly.
+
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+ 16. Modification of This License. This License is Copyright 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
\ No newline at end of file
diff --git a/app/code/Magento/Deploy/Model/Mode.php b/app/code/Magento/Deploy/Model/Mode.php
new file mode 100644
index 0000000000000..38fecde0b480c
--- /dev/null
+++ b/app/code/Magento/Deploy/Model/Mode.php
@@ -0,0 +1,372 @@
+input = $input;
+ $this->output = $output;
+ $this->writer = $writer;
+ $this->reader = $reader;
+ $this->objectManager = $objectManager;
+ $this->filesystem = $filesystem;
+ $this->directoryList = $directoryList;
+ $this->driverFile = $driverFile;
+ $this->storeView = $storeView;
+ $this->shell = $shell;
+ $this->maintenanceMode = $maintenanceMode;
+ $this->functionCallPath = 'php -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento ';
+ }
+
+ /**
+ * Enable production mode
+ *
+ * @return void
+ */
+ public function enableProductionMode()
+ {
+ $this->enableMaintenanceMode($this->output);
+ // Сlean up /var/generation, /var/di/, /var/view_preprocessed and /pub/static directories
+ $this->cleanupFilesystem(
+ [
+ DirectoryList::CACHE,
+ DirectoryList::GENERATION,
+ DirectoryList::DI,
+ DirectoryList::TMP_MATERIALIZATION_DIR,
+ DirectoryList::STATIC_VIEW,
+ ]
+ );
+ // Trigger static assets compilation and deployment
+ $this->deployStaticContent($this->output);
+ $this->deployCss($this->output);
+ // Trigger code generation
+ $this->compile($this->output);
+ $this->disableMaintenanceMode($this->output);
+ $this->lockStaticResources();
+ $this->setStoreMode(State::MODE_PRODUCTION);
+ }
+
+ /**
+ * Only lock static resource locations and set store mode, without handling static content
+ *
+ * @return void
+ */
+ public function enableProductionModeMinimal()
+ {
+ $this->lockStaticResources();
+ $this->setStoreMode(State::MODE_PRODUCTION);
+ }
+
+ /**
+ * Enable Developer mode
+ *
+ * @return void
+ */
+ public function enableDeveloperMode()
+ {
+ $this->cleanupFilesystem(
+ [
+ DirectoryList::CACHE,
+ DirectoryList::GENERATION,
+ DirectoryList::DI,
+ DirectoryList::TMP_MATERIALIZATION_DIR,
+ DirectoryList::STATIC_VIEW,
+ ]
+ );
+ $this->setStoreMode(State::MODE_DEVELOPER);
+ }
+
+ /**
+ * Get current mode information
+ *
+ * @return string
+ * @throws \Exception
+ */
+ public function getMode()
+ {
+ $env = $this->reader->load(ConfigFilePool::APP_ENV);
+ return isset($env[State::PARAM_MODE]) ? $env[State::PARAM_MODE] : null;
+ }
+
+ /**
+ * Store mode in env.php
+ *
+ * @param string $mode
+ * @return void
+ */
+ protected function setStoreMode($mode)
+ {
+ $data = [
+ ConfigFilePool::APP_ENV => [
+ State::PARAM_MODE => $mode
+ ]
+ ];
+ $this->writer->saveConfig($data);
+ }
+
+ /**
+ * Enable maintenance mode
+ *
+ * @param OutputInterface $output
+ * @return void
+ */
+ protected function enableMaintenanceMode(OutputInterface $output)
+ {
+ $this->maintenanceMode->set(true);
+ $output->writeln('Enabled maintenance mode');
+ }
+
+ /**
+ * Disable maintenance mode
+ *
+ * @param OutputInterface $output
+ * @return void
+ */
+ protected function disableMaintenanceMode(OutputInterface $output)
+ {
+ $this->maintenanceMode->set(false);
+ $output->writeln('Disabled maintenance mode');
+ }
+
+ /**
+ * Deploy CSS
+ *
+ * @param OutputInterface $output
+ * @return void
+ */
+ private function deployCss(OutputInterface $output)
+ {
+ $themeLocalePairs = $this->storeView->retrieveThemeLocalePairs();
+ foreach ($themeLocalePairs as $themeLocalePair) {
+ $theme = $themeLocalePair['theme'] ?: self::DEFAULT_THEME;
+ $cmd = $this->functionCallPath . 'dev:css:deploy less'
+ . ' --' . CssDeployCommand::THEME_OPTION . '="' . $theme . '"'
+ . ' --' . CssDeployCommand::LOCALE_OPTION . '="' . $themeLocalePair['locale'] . '"';
+
+ /**
+ * @todo build a solution that does not depend on exec
+ */
+ $execOutput = $this->shell->execute($cmd);
+ $output->writeln($execOutput);
+ }
+ $output->writeln('CSS deployment complete');
+ }
+
+ /**
+ * Deploy static content
+ *
+ * @param OutputInterface $output
+ * @return void
+ * @throws \Exception
+ */
+ private function deployStaticContent(OutputInterface $output)
+ {
+ $cmd = $this->functionCallPath . 'setup:static-content:deploy '
+ . implode(' ', $this->storeView->retrieveLocales());
+
+ /**
+ * @todo build a solution that does not depend on exec
+ */
+ $execOutput = $this->shell->execute($cmd);
+ $output->writeln($execOutput);
+ $output->writeln('Static content deployment complete');
+ }
+
+ /**
+ * Runs code multi-tenant compiler to generate code and DI information
+ *
+ * @param OutputInterface $output
+ * @return void
+ */
+ private function compile(OutputInterface $output)
+ {
+ $this->cleanupFilesystem(
+ [
+ DirectoryList::CACHE,
+ DirectoryList::GENERATION,
+ DirectoryList::DI,
+ ]
+ );
+ $cmd = $this->functionCallPath . 'setup:di:compile-multi-tenant';
+
+ /**
+ * exec command is necessary for now to isolate the autoloaders in the compiler from the memory state
+ * of this process, which would prevent some classes from being generated
+ *
+ * @todo build a solution that does not depend on exec
+ */
+ $execOutput = $this->shell->execute($cmd);
+ $output->writeln($execOutput);
+ $output->writeln('Compilation complete');
+ }
+
+ /**
+ * Deletes specified directories by code
+ *
+ * @param array $directoryCodeList
+ * @return void
+ */
+ private function cleanupFilesystem($directoryCodeList)
+ {
+ $excludePatterns = ['#.htaccess#', '#deployed_version.txt#'];
+ foreach ($directoryCodeList as $code) {
+ if ($code == DirectoryList::STATIC_VIEW) {
+ $directoryPath = $this->directoryList->getPath(DirectoryList::STATIC_VIEW);
+ if ($this->driverFile->isExists($directoryPath)) {
+ $files = $this->driverFile->readDirectory($directoryPath);
+ foreach ($files as $file) {
+ foreach ($excludePatterns as $pattern) {
+ if (preg_match($pattern, $file)) {
+ continue 2;
+ }
+ }
+ if ($this->driverFile->isFile($file)) {
+ $this->driverFile->deleteFile($file);
+ } else {
+ $this->driverFile->deleteDirectory($file);
+ }
+ }
+ }
+ } else {
+ $this->filesystem->getDirectoryWrite($code)
+ ->delete();
+ }
+ }
+ }
+
+ /**
+ * Change permissions for directories by their code
+ *
+ * @param array $directoryCodeList
+ * @param int $dirPermissions
+ * @param int $filePermissions
+ * @return void
+ */
+ private function changePermissions($directoryCodeList, $dirPermissions, $filePermissions)
+ {
+ foreach ($directoryCodeList as $code) {
+ $directoryPath = $this->directoryList->getPath($code);
+ if ($this->driverFile->isExists($directoryPath)) {
+ $this->filesystem->getDirectoryWrite($code)
+ ->changePermissionsRecursively('', $dirPermissions, $filePermissions);
+ } else {
+ $this->driverFile->createDirectory($directoryPath, $dirPermissions);
+ }
+ }
+ }
+
+ /**
+ * Chenge permissions on static resources
+ *
+ * @return void
+ */
+ private function lockStaticResources()
+ {
+ // Lock /var/generation, /var/di/ and /var/view_preprocessed directories
+ $this->changePermissions(
+ [
+ DirectoryList::GENERATION,
+ DirectoryList::DI,
+ DirectoryList::TMP_MATERIALIZATION_DIR,
+ ],
+ self::PERMISSIONS_DIR,
+ self::PERMISSIONS_FILE
+ );
+ }
+}
diff --git a/app/code/Magento/Deploy/README.md b/app/code/Magento/Deploy/README.md
new file mode 100644
index 0000000000000..c263e8a5ee949
--- /dev/null
+++ b/app/code/Magento/Deploy/README.md
@@ -0,0 +1,8 @@
+Deploy module contains 2 commands that allows switching between application modes (for instance from development to
+production) and show current application mode. To change the mode run "bin/magento setup:mode:set [mode]".
+Where mode can be one of the following:
+ - development
+ - production
+When switching to production mode, you can pass optional parameter skip-compilation to do not compile static files, CSS
+and do not run the compilation process.
+
diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php
new file mode 100644
index 0000000000000..58d7fc7efd15e
--- /dev/null
+++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php
@@ -0,0 +1,91 @@
+objectManagerMock = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface');
+ $this->modeMock = $this->getMock('Magento\Deploy\Model\Mode', [], [], '', false);
+
+ $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->command = $objectManager->getObject(
+ 'Magento\Deploy\Console\Command\SetModeCommand',
+ ['objectManager' => $this->objectManagerMock]
+ );
+
+ $this->objectManagerMock->expects($this->once())->method('create')->willReturn($this->modeMock);
+ }
+
+ public function testSetProductionMode()
+ {
+ $this->modeMock->expects($this->once())->method('enableProductionMode');
+
+ $tester = new CommandTester($this->command);
+ $tester->execute(['mode' => 'production']);
+ $this->assertContains(
+ "production mode",
+ $tester->getDisplay()
+ );
+ }
+
+ public function testSetDeveloperMode()
+ {
+ $this->modeMock->expects($this->once())->method('enableDeveloperMode');
+
+ $tester = new CommandTester($this->command);
+ $tester->execute(['mode' => 'developer']);
+ $this->assertContains(
+ "developer mode",
+ $tester->getDisplay()
+ );
+ }
+
+ public function testSetProductionSkipCompilation()
+ {
+ $this->modeMock->expects($this->once())->method('enableProductionModeMinimal');
+
+ $tester = new CommandTester($this->command);
+ $tester->execute(['mode' => 'production', '--skip-compilation' => true]);
+ $this->assertContains(
+ "production mode",
+ $tester->getDisplay()
+ );
+ }
+
+ public function testSetInvalidMode()
+ {
+ $tester = new CommandTester($this->command);
+ $tester->execute(['mode' => 'invalid-mode']);
+ $this->assertContains(
+ "Cannot switch into given mode",
+ $tester->getDisplay()
+ );
+ }
+}
diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/ShowModeCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/ShowModeCommandTest.php
new file mode 100644
index 0000000000000..ea1e99562e1b2
--- /dev/null
+++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/ShowModeCommandTest.php
@@ -0,0 +1,58 @@
+objectManagerMock = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface');
+ $this->modeMock = $this->getMock('Magento\Deploy\Model\Mode', [], [], '', false);
+
+ $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->command = $objectManager->getObject(
+ 'Magento\Deploy\Console\Command\ShowModeCommand',
+ ['objectManager' => $this->objectManagerMock]
+ );
+
+ $this->objectManagerMock->expects($this->once())->method('create')->willReturn($this->modeMock);
+ }
+
+ public function testExecute()
+ {
+ $currentMode = 'application-mode';
+ $this->modeMock->expects($this->once())->method('getMode')->willReturn($currentMode);
+
+ $tester = new CommandTester($this->command);
+ $tester->execute([]);
+ $this->assertContains(
+ $currentMode,
+ $tester->getDisplay()
+ );
+ }
+}
diff --git a/app/code/Magento/Deploy/composer.json b/app/code/Magento/Deploy/composer.json
new file mode 100644
index 0000000000000..796a530b9fa20
--- /dev/null
+++ b/app/code/Magento/Deploy/composer.json
@@ -0,0 +1,25 @@
+{
+ "name": "magento/module-deploy",
+ "description": "N/A",
+ "require": {
+ "php": "~5.5.0|~5.6.0",
+ "magento/framework": "1.0.0-beta",
+ "magento/magento-composer-installer": "*",
+ "magento/module-developer": "1.0.0-beta",
+ "magento/module-store": "1.0.0-beta"
+ },
+ "type": "magento2-module",
+ "version": "1.0.0-beta",
+ "license": [
+ "OSL-3.0",
+ "AFL-3.0"
+ ],
+ "extra": {
+ "map": [
+ [
+ "*",
+ "Magento/Deploy"
+ ]
+ ]
+ }
+}
diff --git a/app/code/Magento/Deploy/etc/di.xml b/app/code/Magento/Deploy/etc/di.xml
new file mode 100644
index 0000000000000..d9dc3ba171138
--- /dev/null
+++ b/app/code/Magento/Deploy/etc/di.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Magento\Deploy\Console\Command\SetModeCommand
+ Magento\Deploy\Console\Command\ShowModeCommand
+
+
+
+
diff --git a/app/code/Magento/Deploy/etc/module.xml b/app/code/Magento/Deploy/etc/module.xml
new file mode 100644
index 0000000000000..c44117227dcd3
--- /dev/null
+++ b/app/code/Magento/Deploy/etc/module.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/DesignEditor/view/adminhtml/layout/adminhtml_system_design_editor_files_index.xml b/app/code/Magento/DesignEditor/view/adminhtml/layout/adminhtml_system_design_editor_files_index.xml
index 047a056d28d84..aab19bee1d1ae 100644
--- a/app/code/Magento/DesignEditor/view/adminhtml/layout/adminhtml_system_design_editor_files_index.xml
+++ b/app/code/Magento/DesignEditor/view/adminhtml/layout/adminhtml_system_design_editor_files_index.xml
@@ -7,7 +7,7 @@
-->
-
+
diff --git a/app/code/Magento/DesignEditor/view/adminhtml/layout/adminhtml_system_design_editor_launch.xml b/app/code/Magento/DesignEditor/view/adminhtml/layout/adminhtml_system_design_editor_launch.xml
index a9f502b6433b2..e39ca884c8c3f 100644
--- a/app/code/Magento/DesignEditor/view/adminhtml/layout/adminhtml_system_design_editor_launch.xml
+++ b/app/code/Magento/DesignEditor/view/adminhtml/layout/adminhtml_system_design_editor_launch.xml
@@ -13,7 +13,7 @@
-
+
diff --git a/app/code/Magento/Developer/Console/Command/CssDeployCommand.php b/app/code/Magento/Developer/Console/Command/CssDeployCommand.php
index 05bbd689d9be6..27f5c8658ca02 100644
--- a/app/code/Magento/Developer/Console/Command/CssDeployCommand.php
+++ b/app/code/Magento/Developer/Console/Command/CssDeployCommand.php
@@ -226,7 +226,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
[
'asset' => $asset,
'origContent' => $content,
- 'origContentType' => $asset->getContentType()
+ 'origContentType' => $asset->getContentType(),
+ 'origAssetPath' => $asset->getFilePath()
]
);
diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
index 9e0415b9858e5..574a73dbfa352 100644
--- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
+++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
@@ -1262,6 +1262,7 @@ protected function _collectSaveData($newObject)
if (!$attribute->isInSet($newObject->getAttributeSetId()) && !in_array($k, $staticFields)) {
$this->_aggregateDeleteData($delete, $attribute, $newObject);
+ continue;
}
$attrId = $attribute->getAttributeId();
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php
index 28c5f3c742393..2cb9a8951fcfb 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php
@@ -239,7 +239,6 @@ public function testSave($attributeCode, $attributeSetId, $productData, $product
'getAffectedFields',
'isStatic',
'getEntityValueId',
- 'getEntityIdField'
]
);
@@ -255,14 +254,6 @@ public function testSave($attributeCode, $attributeSetId, $productData, $product
$backendModel->expects($this->never())->method('getEntityValueId');
- $backendModel->expects(
- isset($productData['entity_id']) ? $this->never() : $this->once()
- )->method(
- 'getEntityIdField'
- )->will(
- $this->returnValue('entity_id')
- );
-
$backendModel->setAttribute($attribute);
$attribute->expects($this->any())->method('getBackend')->will($this->returnValue($backendModel));
$attribute->setId(222);
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/AbstractEntityTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/AbstractEntityTest.php
index a04caf7cdc878..70467e503d08f 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/AbstractEntityTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/AbstractEntityTest.php
@@ -88,7 +88,6 @@ public function testSave($attributeCode, $attributeSetId, $productData, $product
'getAffectedFields',
'isStatic',
'getEntityValueId',
- 'getEntityIdField'
]
);
@@ -102,14 +101,6 @@ public function testSave($attributeCode, $attributeSetId, $productData, $product
$backendModel->expects($this->any())->method('isStatic')->will($this->returnValue(false));
$backendModel->expects($this->never())->method('getEntityValueId');
- $backendModel->expects(
- isset($productData['entity_id']) ? $this->never() : $this->once()
- )->method(
- 'getEntityIdField'
- )->will(
- $this->returnValue('entity_id')
- );
-
$backendModel->setAttribute($attribute);
$attribute->expects($this->any())->method('getBackend')->will($this->returnValue($backendModel));
diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_view_type_grouped.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_view_type_grouped.xml
index d8ba9118949b9..1cfe367c7d69c 100644
--- a/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_view_type_grouped.xml
+++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_view_type_grouped.xml
@@ -10,6 +10,6 @@
-
+
diff --git a/app/code/Magento/Integration/Api/AdminTokenServiceInterface.php b/app/code/Magento/Integration/Api/AdminTokenServiceInterface.php
index 3c2999851a9db..02e2c85d8b34c 100644
--- a/app/code/Magento/Integration/Api/AdminTokenServiceInterface.php
+++ b/app/code/Magento/Integration/Api/AdminTokenServiceInterface.php
@@ -6,10 +6,6 @@
namespace Magento\Integration\Api;
-use Magento\Framework\Exception\AuthenticationException;
-use Magento\Framework\Exception\InputException;
-use Magento\Framework\Exception\LocalizedException;
-
/**
* Interface providing token generation for Admins
*
@@ -23,9 +19,9 @@ interface AdminTokenServiceInterface
* @param string $username
* @param string $password
* @return string Token created
- * @throws InputException For invalid input
- * @throws AuthenticationException
- * @throws LocalizedException
+ * @throws \Magento\Framework\Exception\InputException For invalid input
+ * @throws \Magento\Framework\Exception\AuthenticationException
+ * @throws \Magento\Framework\Exception\LocalizedException
*/
public function createAdminAccessToken($username, $password);
diff --git a/app/code/Magento/Integration/Api/CustomerTokenServiceInterface.php b/app/code/Magento/Integration/Api/CustomerTokenServiceInterface.php
index 245d39bc4a63e..218a6f0d4acba 100644
--- a/app/code/Magento/Integration/Api/CustomerTokenServiceInterface.php
+++ b/app/code/Magento/Integration/Api/CustomerTokenServiceInterface.php
@@ -6,8 +6,6 @@
namespace Magento\Integration\Api;
-use Magento\Framework\Exception\AuthenticationException;
-
/**
* Interface providing token generation for Customers
*
@@ -21,7 +19,7 @@ interface CustomerTokenServiceInterface
* @param string $username
* @param string $password
* @return string Token created
- * @throws AuthenticationException
+ * @throws \Magento\Framework\Exception\AuthenticationException
*/
public function createCustomerAccessToken($username, $password);
diff --git a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_queue_preview.xml b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_queue_preview.xml
index cb7ac6cb26d42..f4b996bcaa12d 100644
--- a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_queue_preview.xml
+++ b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_queue_preview.xml
@@ -9,7 +9,7 @@
-
+
diff --git a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_template_preview.xml b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_template_preview.xml
index d468c2a843414..5d6173d564e20 100644
--- a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_template_preview.xml
+++ b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_template_preview.xml
@@ -9,7 +9,7 @@
-
+
diff --git a/app/code/Magento/Newsletter/view/frontend/layout/customer_account.xml b/app/code/Magento/Newsletter/view/frontend/layout/customer_account.xml
index b2c17400a81e5..e009e753a8bd0 100644
--- a/app/code/Magento/Newsletter/view/frontend/layout/customer_account.xml
+++ b/app/code/Magento/Newsletter/view/frontend/layout/customer_account.xml
@@ -15,6 +15,5 @@
-
diff --git a/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_ordersgrid.xml b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_ordersgrid.xml
index 2798a934f1915..78e295bb5557f 100644
--- a/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_ordersgrid.xml
+++ b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_ordersgrid.xml
@@ -15,8 +15,8 @@
-
-
+
+
diff --git a/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_view.xml b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_view.xml
index d1a23150b2983..2ea45b4fc1ffb 100644
--- a/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_view.xml
+++ b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_view.xml
@@ -18,8 +18,8 @@
-
-
+
+
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_transaction_child_block.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_transaction_child_block.xml
index f6281eb9fd04a..f937a16420e78 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_transaction_child_block.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_transaction_child_block.xml
@@ -59,6 +59,6 @@
-
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Sales/view/frontend/layout/checkout_index_index.xml
index a9d1349d10f68..a61c83d274f16 100644
--- a/app/code/Magento/Sales/view/frontend/layout/checkout_index_index.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/checkout_index_index.xml
@@ -7,6 +7,6 @@
-->
-
+
diff --git a/app/code/Magento/Store/Model/Config/StoreView.php b/app/code/Magento/Store/Model/Config/StoreView.php
new file mode 100644
index 0000000000000..8b564b5ac5ab0
--- /dev/null
+++ b/app/code/Magento/Store/Model/Config/StoreView.php
@@ -0,0 +1,112 @@
+scopeConfig = $scopeConfig;
+ $this->storeManager = $storeManager;
+ $this->themeProvider = $themeProvider;
+ }
+
+ /**
+ * Retrieves a unique list of pairs representing the theme/locale for each store view
+ *
+ * @return array
+ */
+ public function retrieveThemeLocalePairs()
+ {
+ $stores = $this->storeManager->getStores();
+ $localeThemeData = [];
+
+ /** @var \Magento\Store\Api\Data\StoreInterface $store */
+ foreach ($stores as $store) {
+ $code = $store->getCode();
+ $themeId = $this->scopeConfig->getValue(
+ DesignInterface::XML_PATH_THEME_ID,
+ ScopeInterface::SCOPE_STORE,
+ $code
+ );
+ $localeThemeData[] = [
+ 'theme' => $this->themeProvider->getThemeById($themeId)->getCode(),
+ 'locale' => $this->scopeConfig->getValue(
+ Data::XML_PATH_DEFAULT_LOCALE,
+ ScopeInterface::SCOPE_STORE,
+ $code
+ )
+ ];
+ }
+
+ return $this->removeDuplicates($localeThemeData);
+ }
+
+ /**
+ * Retrieves a unique list of locales that are used by store views
+ *
+ * @return array
+ */
+ public function retrieveLocales()
+ {
+ $stores = $this->storeManager->getStores();
+ $locales = [];
+
+ /** @var \Magento\Store\Api\Data\StoreInterface $store */
+ foreach ($stores as $store) {
+ $locales[] = $this->scopeConfig->getValue(
+ Data::XML_PATH_DEFAULT_LOCALE,
+ ScopeInterface::SCOPE_STORE,
+ $store->getCode()
+ );
+ }
+
+ return $this->removeDuplicates($locales);
+ }
+
+ /**
+ * Remove duplicate entries in an array
+ *
+ * @param array $arr
+ * @return array
+ */
+ private function removeDuplicates($arr)
+ {
+ $len = count($arr);
+ for ($out = 0; $out < $len; $out++) {
+ $outVal = $arr[$out];
+ for ($in = $out + 1; $in < $len; $in++) {
+ $inVal = $arr[$in];
+ if ($outVal === $inVal) {
+ unset($arr[$out]);
+ }
+ }
+ }
+ return $arr;
+ }
+}
diff --git a/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php b/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php
index 4cbef52f9fc6c..d55c1f620f007 100644
--- a/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php
+++ b/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php
@@ -33,6 +33,11 @@ class Options implements OptionSourceInterface
*/
protected $options;
+ /**
+ * @var array
+ */
+ protected $currentOptions = [];
+
/**
* Constructor
*
@@ -55,11 +60,24 @@ public function toOptionArray()
if ($this->options !== null) {
return $this->options;
}
+
+ $this->generateCurrentOptions();
+
+ $this->options = array_values($this->currentOptions);
+
+ return $this->options;
+ }
+
+ /**
+ * Generate current options
+ *
+ * @return void
+ */
+ protected function generateCurrentOptions()
+ {
$websiteCollection = $this->systemStore->getWebsiteCollection();
$groupCollection = $this->systemStore->getGroupCollection();
$storeCollection = $this->systemStore->getStoreCollection();
-
- $currentOptions = [];
/** @var \Magento\Store\Model\Website $website */
foreach ($websiteCollection as $website) {
$groups = [];
@@ -84,12 +102,9 @@ public function toOptionArray()
}
if (!empty($groups)) {
$name = $this->escaper->escapeHtml($website->getName());
- $currentOptions[$name]['label'] = $name;
- $currentOptions[$name]['value'] = array_values($groups);
+ $this->currentOptions[$name]['label'] = $name;
+ $this->currentOptions[$name]['value'] = array_values($groups);
}
}
- $this->options = array_values($currentOptions);
-
- return $this->options;
}
}
diff --git a/app/code/Magento/Swagger/Controller/Index/Index.php b/app/code/Magento/Swagger/Controller/Index/Index.php
new file mode 100644
index 0000000000000..b898836ccf37d
--- /dev/null
+++ b/app/code/Magento/Swagger/Controller/Index/Index.php
@@ -0,0 +1,43 @@
+pageConfig = $pageConfig;
+ $this->pageFactory = $pageFactory;
+ }
+
+ /**
+ * @return \Magento\Framework\View\Result\Page
+ */
+ public function execute()
+ {
+ $this->pageConfig->addBodyClass('swagger-section');
+ return $this->pageFactory->create();
+ }
+}
diff --git a/app/code/Magento/Swagger/LICENSE.txt b/app/code/Magento/Swagger/LICENSE.txt
new file mode 100644
index 0000000000000..49525fd99da9c
--- /dev/null
+++ b/app/code/Magento/Swagger/LICENSE.txt
@@ -0,0 +1,48 @@
+
+Open Software License ("OSL") v. 3.0
+
+This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Open Software License version 3.0
+
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
+
+ 4. to perform the Original Work publicly; and
+
+ 5. to display the Original Work publicly.
+
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+ 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
\ No newline at end of file
diff --git a/app/code/Magento/Swagger/LICENSE_AFL.txt b/app/code/Magento/Swagger/LICENSE_AFL.txt
new file mode 100644
index 0000000000000..87943b95d43a5
--- /dev/null
+++ b/app/code/Magento/Swagger/LICENSE_AFL.txt
@@ -0,0 +1,48 @@
+
+Academic Free License ("AFL") v. 3.0
+
+This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Academic Free License version 3.0
+
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License;
+
+ 4. to perform the Original Work publicly; and
+
+ 5. to display the Original Work publicly.
+
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+ 16. Modification of This License. This License is Copyright 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
\ No newline at end of file
diff --git a/app/code/Magento/Swagger/README.md b/app/code/Magento/Swagger/README.md
new file mode 100644
index 0000000000000..e2ab6d10fdf2d
--- /dev/null
+++ b/app/code/Magento/Swagger/README.md
@@ -0,0 +1,3 @@
+The Magento_Swagger module provides access to a page generated using the swagger-ui package. The swagger-ui can be viewed
+[on Github](https://github.com/swagger-api/swagger-ui). It accesses the JSON Schema describing Magento's REST APIs,
+and displays it in a user-friendly, navigable format.
diff --git a/app/code/Magento/Swagger/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Swagger/Test/Unit/Controller/Index/IndexTest.php
new file mode 100644
index 0000000000000..0143601c8995d
--- /dev/null
+++ b/app/code/Magento/Swagger/Test/Unit/Controller/Index/IndexTest.php
@@ -0,0 +1,34 @@
+getMockBuilder('Magento\Framework\View\Page\Config')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $pageConfigMock->expects($this->once())->method('addBodyClass')->with('swagger-section');
+ $resultPageFactory->expects($this->once())->method('create');
+
+ $model = $objectManager->getObject(
+ 'Magento\Swagger\Controller\Index\Index',
+ [
+ 'pageConfig' => $pageConfigMock,
+ 'pageFactory' => $resultPageFactory
+ ]
+ );
+ $model->execute();
+ }
+}
diff --git a/app/code/Magento/Swagger/composer.json b/app/code/Magento/Swagger/composer.json
new file mode 100644
index 0000000000000..1e0f8840199d4
--- /dev/null
+++ b/app/code/Magento/Swagger/composer.json
@@ -0,0 +1,23 @@
+{
+ "name": "magento/module-swagger",
+ "description": "N/A",
+ "require": {
+ "php": "~5.5.0|~5.6.0",
+ "magento/framework": "1.0.0-beta",
+ "magento/magento-composer-installer": "*"
+ },
+ "type": "magento2-module",
+ "version": "1.0.0-beta",
+ "license": [
+ "OSL-3.0",
+ "AFL-3.0"
+ ],
+ "extra": {
+ "map": [
+ [
+ "*",
+ "Magento/Swagger"
+ ]
+ ]
+ }
+}
diff --git a/app/code/Magento/Swagger/etc/frontend/routes.xml b/app/code/Magento/Swagger/etc/frontend/routes.xml
new file mode 100644
index 0000000000000..02b9256427512
--- /dev/null
+++ b/app/code/Magento/Swagger/etc/frontend/routes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Swagger/etc/module.xml b/app/code/Magento/Swagger/etc/module.xml
new file mode 100644
index 0000000000000..06e6a83b6b213
--- /dev/null
+++ b/app/code/Magento/Swagger/etc/module.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/app/code/Magento/Swagger/view/frontend/layout/swagger_index_index.xml b/app/code/Magento/Swagger/view/frontend/layout/swagger_index_index.xml
new file mode 100644
index 0000000000000..a43a5c7885a96
--- /dev/null
+++ b/app/code/Magento/Swagger/view/frontend/layout/swagger_index_index.xml
@@ -0,0 +1,48 @@
+
+
+
+
+ Swagger UI
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/LICENSE.txt b/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/LICENSE.txt
new file mode 100644
index 0000000000000..542991f955026
--- /dev/null
+++ b/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/LICENSE.txt
@@ -0,0 +1,11 @@
+Copyright 2015 SmartBear Software
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml b/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml
new file mode 100644
index 0000000000000..b847b929a25e4
--- /dev/null
+++ b/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml
@@ -0,0 +1,102 @@
+getBaseUrl(), '/') . '/rest/default/schema?services=all';
+?>
+
+
+
+
+
+