Skip to content

Commit

Permalink
Merge pull request #303 from magento-dragons/MAGETWO-37551
Browse files Browse the repository at this point in the history
[Extensibility + Nord] MAGETWO-37551  Merge pull requests (#294, #297)
  • Loading branch information
Klymenko, Volodymyr(vklymenko) committed May 16, 2015
2 parents 7ae9152 + a5d057a commit 7b66d72
Show file tree
Hide file tree
Showing 36 changed files with 842 additions and 219 deletions.
1 change: 0 additions & 1 deletion app/code/Magento/Catalog/Block/Adminhtml/Rss/Grid/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

/**
* Class Link
* @package Magento\Review\Block\Adminhtml\Grid\Rss
*/
class Link extends \Magento\Framework\View\Element\Template
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase
protected $_objectManagerMock;

/**
* @var \Magento\Newsletter\Model\Template\Filter\Factory
* @var \Magento\Catalog\Model\Template\Filter\Factory
*/
protected $_factory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

/**
* Interface StockCollectionInterface
* @api
*/
interface StockCollectionInterface extends SearchResultsInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* Interface Stock
* @api
*/
interface StockInterface extends ExtensibleDataInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* Interface StockItemCollectionInterface
* @package Magento\CatalogInventory\Api\Data
* @api
*/
interface StockItemCollectionInterface extends SearchResultsInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* Interface StockItem
* @api
*/
interface StockItemInterface extends ExtensibleDataInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* Stock Status collection interface
* @api
*/
interface StockStatusCollectionInterface extends SearchResultsInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* Interface StockStatusInterface
* @api
*/
interface StockStatusInterface extends ExtensibleDataInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockConfigurationInterface
* @api
*/
interface StockConfigurationInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockCriteriaInterface
* @api
*/
interface StockCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockIndexInterface
* @api
*/
interface StockIndexInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockItemCriteriaInterface
* @api
*/
interface StockItemCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockItemRepository
* @api
*/
interface StockItemRepositoryInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockManagementInterface
* @api
*/
interface StockManagementInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockRegistryInterface
* @api
*/
interface StockRegistryInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockRepositoryInterface
* @api
*/
interface StockRepositoryInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockStateInterface
* @api
*/
interface StockStateInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockStatusCriteriaInterface
* @api
*/
interface StockStatusCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Interface StockStatusRepositoryInterface
* @api
*/
interface StockStatusRepositoryInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

/**
* CatalogInventory Stock Indexer Interface
*
* @author Magento Core Team <core@magentocommerce.com>
* @api
*/
interface StockInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/***
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Cms\Test\Unit\Ui\Component\Listing\Column;

class PageActionsTest extends \PHPUnit_Framework_TestCase
{
public function testPrepareItemsByPageId()
{
// Create Mocks and SUT
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
/** @var \PHPUnit_Framework_MockObject_MockObject $urlBuilderMock */
$urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface')
->disableOriginalConstructor()
->getMock();
$inputUrl = 'href/url/for/edit/action';

/** @var \Magento\Cms\Ui\Component\Listing\Column\PageActions $model */
$model = $objectManager->getObject(
'Magento\Cms\Ui\Component\Listing\Column\PageActions',
[
'urlBuilder' => $urlBuilderMock,
'url' => $inputUrl
]
);

// Define test input and expectations
$items = [['page_id' => 1]];
$fullUrl = 'full-url-including-base.com/href/url/for/edit/action';
$name = 'item_name';

$editArray = [
'href' => $fullUrl,
'label' => __('Edit'),
'hidden' => true
];
$expectedItems = [
[
'page_id' => 1,
$name => ['edit' => $editArray]
]
];

// Configure mocks and object data
$urlBuilderMock->expects($this->once())
->method('getUrl')
->with($inputUrl, ['page_id' => 1])
->willReturn($fullUrl);

$model->setName($name);
// Run test
$this->assertEquals(
$expectedItems,
$model->prepareItems($items)
);
}
}
26 changes: 12 additions & 14 deletions app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,40 @@
*/
class PageActions extends Column
{
/**
* Url path
*/
const URL_PATH = 'cms/page/edit';
/** Url path */
const CMS_URL_PATH = 'cms/page/edit';

/**
* @var UrlBuilder
*/
/** @var UrlBuilder */
protected $actionUrlBuilder;

/**
* @var UrlInterface
*/
/** @var UrlInterface */
protected $urlBuilder;

/** @var string */
private $url;


/**
* Constructor
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param UrlBuilder $actionUrlBuilder
* @param UrlInterface $urlBuilder
* @param array $components
* @param array $data
* @param string $url
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
UrlBuilder $actionUrlBuilder,
UrlInterface $urlBuilder,
array $components = [],
array $data = []
array $data = [],
$url = self::CMS_URL_PATH
) {
$this->urlBuilder = $urlBuilder;
$this->actionUrlBuilder = $actionUrlBuilder;
$this->url = $url;
parent::__construct($context, $uiComponentFactory, $components, $data);
}

Expand All @@ -64,7 +62,7 @@ public function prepareItems(array & $items)
foreach ($items as & $item) {
if (isset($item['page_id'])) {
$item[$this->getData('name')]['edit'] = [
'href' => $this->urlBuilder->getUrl(static::URL_PATH, ['page_id' => $item['page_id']]),
'href' => $this->urlBuilder->getUrl($this->url, ['page_id' => $item['page_id']]),
'label' => __('Edit'),
'hidden' => true
];
Expand Down
77 changes: 15 additions & 62 deletions app/code/Magento/Newsletter/Block/Adminhtml/Queue/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,18 @@
*/
namespace Magento\Newsletter\Block\Adminhtml\Queue;

class Preview extends \Magento\Backend\Block\Widget
class Preview extends \Magento\Newsletter\Block\Adminhtml\Template\Preview
{
/**
* @var \Magento\Newsletter\Model\TemplateFactory
* {@inheritdoc}
*/
protected $_templateFactory;
protected $profilerName = "newsletter_queue_proccessing";

/**
* @var \Magento\Newsletter\Model\QueueFactory
*/
protected $_queueFactory;

/**
* @var \Magento\Newsletter\Model\SubscriberFactory
*/
protected $_subscriberFactory;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Newsletter\Model\TemplateFactory $templateFactory
Expand All @@ -38,68 +33,26 @@ class Preview extends \Magento\Backend\Block\Widget
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Newsletter\Model\TemplateFactory $templateFactory,
\Magento\Newsletter\Model\QueueFactory $queueFactory,
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
\Magento\Newsletter\Model\QueueFactory $queueFactory,
array $data = []
) {
$this->_templateFactory = $templateFactory;
$this->_queueFactory = $queueFactory;
$this->_subscriberFactory = $subscriberFactory;
parent::__construct($context, $data);
parent::__construct($context, $templateFactory, $subscriberFactory, $data);
}

/**
* Get html code
*
* @return string
* @param \Magento\Newsletter\Model\Template $template
* @param string $id
* @return $this
*/
protected function _toHtml()
protected function loadTemplate(\Magento\Newsletter\Model\Template $template, $id)
{
/* @var $template \Magento\Newsletter\Model\Template */
$template = $this->_templateFactory->create();

if ($id = (int)$this->getRequest()->getParam('id')) {
$queue = $this->_queueFactory->create()->load($id);
$template->setTemplateType($queue->getNewsletterType());
$template->setTemplateText($queue->getNewsletterText());
$template->setTemplateStyles($queue->getNewsletterStyles());
} else {
$template->setTemplateType($this->getRequest()->getParam('type'));
$template->setTemplateText($this->getRequest()->getParam('text'));
$template->setTemplateStyles($this->getRequest()->getParam('styles'));
}

$storeId = (int)$this->getRequest()->getParam('store_id');
if (!$storeId) {
$defaultStore = $this->_storeManager->getDefaultStoreView();
if (!$defaultStore) {
$allStores = $this->_storeManager->getStores();
if (isset($allStores[0])) {
$defaultStore = $allStores[0];
}
}
$storeId = $defaultStore ? $defaultStore->getId() : null;
}

\Magento\Framework\Profiler::start("newsletter_queue_proccessing");
$vars = [];

$vars['subscriber'] = $this->_subscriberFactory->create();

$template->emulateDesign($storeId);
$templateProcessed = $this->_appState->emulateAreaCode(
\Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA,
[$template, 'getProcessedTemplate'],
[$vars, true]
);
$template->revertDesign();

if ($template->isPlain()) {
$templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
}

\Magento\Framework\Profiler::stop("newsletter_queue_proccessing");

return $templateProcessed;
/** @var \Magento\Newsletter\Model\Queue $queue */
$queue = $this->_queueFactory->create()->load($id);
$template->setTemplateType($queue->getNewsletterType());
$template->setTemplateText($queue->getNewsletterText());
$template->setTemplateStyles($queue->getNewsletterStyles());
return $this;
}
}
Loading

0 comments on commit 7b66d72

Please sign in to comment.