Skip to content

Commit

Permalink
Merge remote-tracking branch 'nord/develop' into MAGETWO-36918-versio…
Browse files Browse the repository at this point in the history
…n-tab
  • Loading branch information
Volodymyr klymenko committed May 16, 2015
2 parents b39e901 + 5bf96e4 commit a5d057a
Show file tree
Hide file tree
Showing 34 changed files with 771 additions and 205 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
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;
}
}
63 changes: 45 additions & 18 deletions app/code/Magento/Newsletter/Block/Adminhtml/Template/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@

/**
* Newsletter template preview block
*
* @author Magento Core Team <core@magentocommerce.com>
*/
namespace Magento\Newsletter\Block\Adminhtml\Template;

class Preview extends \Magento\Backend\Block\Widget
{
/**
* Name for profiler
*
* @var string
*/
protected $profilerName = "newsletter_template_proccessing";

/**
* @var \Magento\Newsletter\Model\TemplateFactory
*/
Expand Down Expand Up @@ -51,34 +56,22 @@ protected function _toHtml()
$template = $this->_templateFactory->create();

if ($id = (int)$this->getRequest()->getParam('id')) {
$template->load($id);
$this->loadTemplate($template, $id);
} 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_template_proccessing");
\Magento\Framework\Profiler::start($this->profilerName);
$vars = [];

$vars['subscriber'] = $this->_subscriberFactory->create();
if ($this->getRequest()->getParam('subscriber')) {
$vars['subscriber']->load($this->getRequest()->getParam('subscriber'));
}

$template->emulateDesign($storeId);
$template->emulateDesign($this->getStoreId());
$templateProcessed = $this->_appState->emulateAreaCode(
\Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA,
[$template, 'getProcessedTemplate'],
Expand All @@ -90,8 +83,42 @@ protected function _toHtml()
$templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
}

\Magento\Framework\Profiler::stop("newsletter_template_proccessing");
\Magento\Framework\Profiler::stop($this->profilerName);

return $templateProcessed;
}

/**
* Get Store Id from request or default
*
* @return int|null
*/
protected function getStoreId()
{
$storeId = (int)$this->getRequest()->getParam('store_id');
if ($storeId) {
return $storeId;
}

$defaultStore = $this->_storeManager->getDefaultStoreView();
if (!$defaultStore) {
$allStores = $this->_storeManager->getStores();
if (isset($allStores[0])) {
$defaultStore = $allStores[0];
}
}

return $defaultStore ? $defaultStore->getId() : null;
}

/**
* @param \Magento\Newsletter\Model\Template $template
* @param string $id
* @return $this
*/
protected function loadTemplate(\Magento\Newsletter\Model\Template $template, $id)
{
$template->load($id);
return $this;
}
}
Loading

0 comments on commit a5d057a

Please sign in to comment.