Skip to content

Commit

Permalink
Merge branch '2.1-develop' of https://github.com/magento/magento2ce i…
Browse files Browse the repository at this point in the history
…nto MAGETWO-70329-2
  • Loading branch information
dhorytskyi committed Apr 19, 2018
2 parents e9550f6 + 70bd853 commit c85abb4
Show file tree
Hide file tree
Showing 22 changed files with 135 additions and 51 deletions.
18 changes: 16 additions & 2 deletions app/code/Magento/Checkout/CustomerData/DefaultItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Magento\Checkout\CustomerData;

use Magento\Framework\App\ObjectManager;

/**
* Default item
*/
Expand Down Expand Up @@ -36,26 +38,36 @@ class DefaultItem extends AbstractItem
*/
protected $checkoutHelper;

/**
* Escaper
*
* @var \Magento\Framework\Escaper
*/
private $escaper;

/**
* @param \Magento\Catalog\Helper\Image $imageHelper
* @param \Magento\Msrp\Helper\Data $msrpHelper
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool
* @param \Magento\Checkout\Helper\Data $checkoutHelper
* @param \Magento\Framework\Escaper|null $escaper
* @codeCoverageIgnore
*/
public function __construct(
\Magento\Catalog\Helper\Image $imageHelper,
\Magento\Msrp\Helper\Data $msrpHelper,
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool,
\Magento\Checkout\Helper\Data $checkoutHelper
\Magento\Checkout\Helper\Data $checkoutHelper,
\Magento\Framework\Escaper $escaper = null
) {
$this->configurationPool = $configurationPool;
$this->imageHelper = $imageHelper;
$this->msrpHelper = $msrpHelper;
$this->urlBuilder = $urlBuilder;
$this->checkoutHelper = $checkoutHelper;
$this->escaper = $escaper ?: ObjectManager::getInstance()->get(\Magento\Framework\Escaper::class);
}

/**
Expand All @@ -64,14 +76,16 @@ public function __construct(
protected function doGetItemData()
{
$imageHelper = $this->imageHelper->init($this->getProductForThumbnail(), 'mini_cart_product_thumbnail');
$productName = $this->escaper->escapeHtml($this->item->getProduct()->getName());

return [
'options' => $this->getOptionList(),
'qty' => $this->item->getQty() * 1,
'item_id' => $this->item->getId(),
'configure_url' => $this->getConfigureUrl(),
'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(),
'product_id' => $this->item->getProduct()->getId(),
'product_name' => $this->item->getProduct()->getName(),
'product_name' => $productName,
'product_sku' => $this->item->getProduct()->getSku(),
'product_url' => $this->getProductUrl(),
'product_has_url' => $this->hasProductUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</span>
</a>
<?php if ($block->getIsNeedToDisplaySideBar()): ?>
<div class="block block-minicart empty"
<div class="block block-minicart"
data-role="dropdownDialog"
data-mage-init='{"dropdownDialog":{
"appendTo":"[data-block=minicart]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="product-item-details">
<strong class="product-item-name">
<!-- ko if: product_has_url -->
<a data-bind="attr: {href: product_url}, text: product_name"></a>
<a data-bind="attr: {href: product_url}, html: product_name"></a>
<!-- /ko -->
<!-- ko ifnot: product_has_url -->
<!-- ko text: product_name --><!-- /ko -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@ class ConfigurableItem extends DefaultItem
* @param \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool
* @param \Magento\Checkout\Helper\Data $checkoutHelper
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Escaper|null $escaper
*/
public function __construct(
\Magento\Catalog\Helper\Image $imageHelper,
\Magento\Msrp\Helper\Data $msrpHelper,
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool,
\Magento\Checkout\Helper\Data $checkoutHelper,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Escaper $escaper = null
) {
parent::__construct(
$imageHelper,
$msrpHelper,
$urlBuilder,
$configurationPool,
$checkoutHelper
$checkoutHelper,
$escaper
);
$this->_scopeConfig = $scopeConfig;
}
Expand Down
7 changes: 5 additions & 2 deletions app/code/Magento/GroupedProduct/CustomerData/GroupedItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ class GroupedItem extends DefaultItem
* @param \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool
* @param \Magento\Checkout\Helper\Data $checkoutHelper
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Escaper|null $escaper
*/
public function __construct(
\Magento\Catalog\Helper\Image $imageHelper,
\Magento\Msrp\Helper\Data $msrpHelper,
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool,
\Magento\Checkout\Helper\Data $checkoutHelper,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Escaper $escaper = null
) {
parent::__construct(
$imageHelper,
$msrpHelper,
$urlBuilder,
$configurationPool,
$checkoutHelper
$checkoutHelper,
$escaper
);
$this->_scopeConfig = $scopeConfig;
}
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Review/Controller/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ protected function loadProduct($productId)

try {
$product = $this->productRepository->getById($productId);

if (!in_array($this->storeManager->getStore()->getWebsiteId(), $product->getWebsiteIds())) {
throw new NoSuchEntityException();
}

if (!$product->isVisibleInCatalog() || !$product->isVisibleInSiteVisibility()) {
throw new NoSuchEntityException();
}
Expand Down
16 changes: 14 additions & 2 deletions app/code/Magento/Review/Test/Unit/Controller/Product/PostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ protected function setUp()
$ratingFactory->expects($this->once())->method('create')->willReturn($this->rating);
$this->messageManager = $this->getMock('\Magento\Framework\Message\ManagerInterface');

$this->store = $this->getMock('\Magento\Store\Model\Store', ['getId'], [], '', false);
$this->store = $this->getMock(
'\Magento\Store\Model\Store',
['getId', 'getWebsiteId'],
[],
'',
false
);
$storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface');
$storeManager->expects($this->any())->method('getStore')->willReturn($this->store);

Expand Down Expand Up @@ -242,7 +248,7 @@ public function testExecute()
->willReturn(1);
$product = $this->getMock(
'Magento\Catalog\Model\Product',
['__wakeup', 'isVisibleInCatalog', 'isVisibleInSiteVisibility', 'getId'],
['__wakeup', 'isVisibleInCatalog', 'isVisibleInSiteVisibility', 'getId', 'getWebsiteIds'],
[],
'',
false
Expand All @@ -253,6 +259,10 @@ public function testExecute()
$product->expects($this->once())
->method('isVisibleInSiteVisibility')
->willReturn(true);
$product->expects($this->once())
->method('getWebsiteIds')
->willReturn([1]);

$this->productRepository->expects($this->any())->method('getById')
->with(1)
->willReturn($product);
Expand Down Expand Up @@ -288,6 +298,8 @@ public function testExecute()
$this->review->expects($this->once())->method('setCustomerId')->with($customerId)->willReturnSelf();
$this->store->expects($this->exactly(2))->method('getId')
->willReturn($storeId);
$this->store->expects($this->once())->method('getWebsiteId')
->willReturn(1);
$this->review->expects($this->once())->method('setStoreId')
->with($storeId)
->willReturnSelf();
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ protected function _drawItem(\Magento\Framework\DataObject $item, \Zend_Pdf_Page
protected function _setFontRegular($object, $size = 7)
{
$font = \Zend_Pdf_Font::fontWithPath(
$this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_Re-4.4.1.ttf')
$this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerif.ttf')
);
$object->setFont($font, $size);
return $font;
Expand All @@ -867,7 +867,7 @@ protected function _setFontRegular($object, $size = 7)
protected function _setFontBold($object, $size = 7)
{
$font = \Zend_Pdf_Font::fontWithPath(
$this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_Bd-2.8.1.ttf')
$this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerifBold.ttf')
);
$object->setFont($font, $size);
return $font;
Expand All @@ -883,7 +883,7 @@ protected function _setFontBold($object, $size = 7)
protected function _setFontItalic($object, $size = 7)
{
$font = \Zend_Pdf_Font::fontWithPath(
$this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_It-2.8.2.ttf')
$this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerifItalic.ttf')
);
$object->setFont($font, $size);
return $font;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public function getItemOptions()
protected function _setFontRegular($size = 7)
{
$font = \Zend_Pdf_Font::fontWithPath(
$this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_Re-4.4.1.ttf')
$this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerif.ttf')
);
$this->getPage()->setFont($font, $size);
return $font;
Expand All @@ -350,7 +350,7 @@ protected function _setFontRegular($size = 7)
protected function _setFontBold($size = 7)
{
$font = \Zend_Pdf_Font::fontWithPath(
$this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_Bd-2.8.1.ttf')
$this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerifBold.ttf')
);
$this->getPage()->setFont($font, $size);
return $font;
Expand All @@ -365,7 +365,7 @@ protected function _setFontBold($size = 7)
protected function _setFontItalic($size = 7)
{
$font = \Zend_Pdf_Font::fontWithPath(
$this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_It-2.8.2.ttf')
$this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerifItalic.ttf')
);
$this->getPage()->setFont($font, $size);
return $font;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@
.product-item-pricing {
.label {
display: inline-block;
width: 4.5rem;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@
}
}

.media-width(@extremum, @break) when (@extremum = 'max') and (@break = (@screen__m + 1)) {
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
.abs-checkout-tooltip-content-position-top-mobile {
@abs-checkout-tooltip-content-position-top();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@
.product-item-pricing {
.label {
display: inline-block;
width: 4.5rem;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@
}
}

.media-width(@extremum, @break) when (@extremum = 'max') and (@break = (@screen__m + 1)) {
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
.abs-checkout-tooltip-content-position-top-mobile {
@abs-checkout-tooltip-content-position-top();
}
Expand Down
Binary file added lib/internal/GnuFreeFont/FreeSerif.ttf
Binary file not shown.
Binary file added lib/internal/GnuFreeFont/FreeSerifBold.ttf
Binary file not shown.
Binary file added lib/internal/GnuFreeFont/FreeSerifItalic.ttf
Binary file not shown.
61 changes: 42 additions & 19 deletions lib/internal/Magento/Framework/Console/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Magento\Framework\Shell\ComplexParameter;
use Magento\Setup\Console\CompilerPreparation;
use \Magento\Framework\App\ProductMetadata;
use Magento\Framework\App\State;

/**
* Magento 2 CLI Application. This is the hood for all command line tools supported by Magento
Expand Down Expand Up @@ -47,6 +48,11 @@ class Cli extends SymfonyApplication
*/
private $initException;

/**
* @var \Magento\Framework\ObjectManagerInterface
*/
private $objectManager;

/**
* @param string $name application name
* @param string $version application version
Expand All @@ -56,15 +62,7 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
{
$this->serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')
->getServiceManager();
$generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager);
if (!$generationDirectoryAccess->check()) {
$output = new ConsoleOutput();
$output->writeln(
'<error>Command line user does not have read and write permissions on var/generation directory. Please'
. ' address this issue before using Magento command line.</error>'
);
exit(0);
}

/**
* Temporary workaround until the compiler is able to clear the generation directory
* @todo remove after MAGETWO-44493 resolved
Expand All @@ -74,6 +72,21 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
$compilerPreparation->handleCompilerEnvironment();
}

$bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP);
$params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER);
$params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
$bootstrap = Bootstrap::create(BP, $params);
$this->objectManager = $bootstrap->getObjectManager();

if ($this->checkGenerationDirectoryAccess()) {
$output = new ConsoleOutput();
$output->writeln(
'<error>Command line user does not have read and write permissions on var/generation directory. Please'
. ' address this issue before using Magento command line.</error>'
);
exit(0);
}

if ($version == 'UNKNOWN') {
$directoryList = new DirectoryList(BP);
$composerJsonFinder = new ComposerJsonFinder($directoryList);
Expand All @@ -83,6 +96,22 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
parent::__construct($name, $version);
}

/**
* Check generation directory access.
*
* Skip and return true if production mode is enabled.
*
* @return bool
*/
private function checkGenerationDirectoryAccess()
{
$generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager);
/** @var State $state */
$state = $this->objectManager->create(State::class);

return $state->getMode() !== State::MODE_PRODUCTION && !$generationDirectoryAccess->check();
}

/**
* Process an error happened during initialization of commands, if any
*
Expand Down Expand Up @@ -121,31 +150,25 @@ protected function getApplicationCommands()
{
$commands = [];
try {
$bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP);
$params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER);
$params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();

// Specialized setup command list available before and after M2 install
if (class_exists('Magento\Setup\Console\CommandList')
&& class_exists('Magento\Setup\Model\ObjectManagerProvider')
) {
/** @var \Magento\Setup\Model\ObjectManagerProvider $omProvider */
$omProvider = $this->serviceManager->get(\Magento\Setup\Model\ObjectManagerProvider::class);
$omProvider->setObjectManager($objectManager);
$omProvider->setObjectManager($this->objectManager);
$setupCommandList = new \Magento\Setup\Console\CommandList($this->serviceManager);
$commands = array_merge($commands, $setupCommandList->getCommands());
}

// Allowing instances of all modular commands only after M2 install
if ($objectManager->get(\Magento\Framework\App\DeploymentConfig::class)->isAvailable()) {
if ($this->objectManager->get(\Magento\Framework\App\DeploymentConfig::class)->isAvailable()) {
/** @var \Magento\Framework\Console\CommandListInterface $commandList */
$commandList = $objectManager->create(\Magento\Framework\Console\CommandListInterface::class);
$commandList = $this->objectManager->create(\Magento\Framework\Console\CommandListInterface::class);
$commands = array_merge($commands, $commandList->getCommands());
}

$commands = array_merge($commands, $this->getVendorCommands($objectManager));
$commands = array_merge($commands, $this->getVendorCommands($this->objectManager));
} catch (\Exception $e) {
$this->initException = $e;
}
Expand Down
Loading

0 comments on commit c85abb4

Please sign in to comment.