Skip to content

Commit

Permalink
Merge branch '2.4-develop' into framework-EnumLookup
Browse files Browse the repository at this point in the history
  • Loading branch information
atwixfirster authored Sep 2, 2020
2 parents c68c447 + edc018c commit d2bc662
Show file tree
Hide file tree
Showing 75 changed files with 1,959 additions and 758 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* See COPYING.txt for license details.
*/

/**
* @deprecated see Magento/Ui/view/base/web/js/grid/filters/elements/ui-select.js
*/
define([
'Magento_Ui/js/form/element/ui-select',
'jquery',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,63 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images;

class OnInsert extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
use Magento\Backend\App\Action\Context;
use Magento\Cms\Controller\Adminhtml\Wysiwyg\Images;
use Magento\Cms\Model\Wysiwyg\Images\GetInsertImageContent;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\Result\RawFactory;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Registry;

class OnInsert extends Images implements HttpPostActionInterface
{
/**
* @var \Magento\Framework\Controller\Result\RawFactory
* @var RawFactory
*/
protected $resultRawFactory;

/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
* @var GetInsertImageContent
*/
private $getInsertImageContent;

/**
* @param Context $context
* @param Registry $coreRegistry
* @param RawFactory $resultRawFactory
* @param GetInsertImageContent $getInsertImageContent
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory
Context $context,
Registry $coreRegistry,
RawFactory $resultRawFactory,
?GetInsertImageContent $getInsertImageContent = null
) {
$this->resultRawFactory = $resultRawFactory;
parent::__construct($context, $coreRegistry);
$this->getInsertImageContent = $getInsertImageContent ?: $this->_objectManager
->get(GetInsertImageContent::class);
}

/**
* Fire when select image
* Return a content (just a link or an html block) for inserting image to the content
*
* @return \Magento\Framework\Controller\ResultInterface
* @return ResultInterface
*/
public function execute()
{
$imagesHelper = $this->_objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class);
$request = $this->getRequest();

$storeId = $request->getParam('store');

$filename = $request->getParam('filename');
$filename = $imagesHelper->idDecode($filename);

$asIs = $request->getParam('as_is');

$forceStaticPath = $request->getParam('force_static_path');

$this->_objectManager->get(\Magento\Catalog\Helper\Data::class)->setStoreId($storeId);
$imagesHelper->setStoreId($storeId);

if ($forceStaticPath) {
$image = parse_url($imagesHelper->getCurrentUrl() . $filename, PHP_URL_PATH);
} else {
$image = $imagesHelper->getImageHtmlDeclaration($filename, $asIs);
}

/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
$resultRaw = $this->resultRawFactory->create();
return $resultRaw->setContents($image);
$data = $this->getRequest()->getParams();
return $this->resultRawFactory->create()->setContents(
$this->getInsertImageContent->execute(
$data['filename'],
$data['force_static_path'],
$data['as_is'],
isset($data['store']) ? (int) $data['store'] : null
)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Cms\Model\Wysiwyg\Images;

use Magento\Catalog\Helper\Data as CatalogHelper;
use Magento\Cms\Helper\Wysiwyg\Images as ImagesHelper;

class GetInsertImageContent
{
/**
* @var ImagesHelper
*/
private $imagesHelper;

/**
* @var CatalogHelper
*/
private $catalogHelper;

/**
* @param ImagesHelper $imagesHelper
* @param CatalogHelper $catalogHelper
*/
public function __construct(ImagesHelper $imagesHelper, CatalogHelper $catalogHelper)
{
$this->imagesHelper = $imagesHelper;
$this->catalogHelper = $catalogHelper;
}

/**
* Create a content (just a link or an html block) for inserting image to the content
*
* @param string $encodedFilename
* @param bool $forceStaticPath
* @param bool $renderAsTag
* @param int|null $storeId
* @return string
*/
public function execute(
string $encodedFilename,
bool $forceStaticPath,
bool $renderAsTag,
?int $storeId = null
): string {
$filename = $this->imagesHelper->idDecode($encodedFilename);

$this->catalogHelper->setStoreId($storeId);
$this->imagesHelper->setStoreId($storeId);

if ($forceStaticPath) {
// phpcs:ignore Magento2.Functions.DiscouragedFunction
return parse_url($this->imagesHelper->getCurrentUrl() . $filename, PHP_URL_PATH);
}

return $this->imagesHelper->getImageHtmlDeclaration($filename, $renderAsTag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

namespace Magento\MediaContentSynchronization\Console\Command;

use Magento\Framework\App\Area;
use Magento\Framework\App\State;
use Magento\Framework\Console\Cli;
use Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface;
use Symfony\Component\Console\Command\Command;
Expand All @@ -25,21 +23,13 @@ class Synchronize extends Command
*/
private $synchronizeContent;

/**
* @var State $state
*/
private $state;

/**
* @param SynchronizeInterface $synchronizeContent
* @param State $state
*/
public function __construct(
SynchronizeInterface $synchronizeContent,
State $state
SynchronizeInterface $synchronizeContent
) {
$this->synchronizeContent = $synchronizeContent;
$this->state = $state;
parent::__construct();
}

Expand All @@ -58,12 +48,7 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Synchronizing content with assets...');
$this->state->emulateAreaCode(
Area::AREA_ADMINHTML,
function () {
$this->synchronizeContent->execute();
}
);
$this->synchronizeContent->execute();
$output->writeln('Completed content synchronization.');
return Cli::RETURN_SUCCESS;
}
Expand Down
5 changes: 1 addition & 4 deletions app/code/Magento/MediaGallery/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="media_gallery_asset" resource="default" engine="innodb" comment="Media Gallery Asset">
<column xsi:type="int" name="id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
<column xsi:type="varchar" name="path" length="255" nullable="true" comment="Path"/>
<column xsi:type="text" name="path" nullable="true" comment="Path"/>
<column xsi:type="varchar" name="title" length="255" nullable="true" comment="Title"/>
<column xsi:type="text" name="description" nullable="true" comment="Description"/>
<column xsi:type="varchar" name="source" length="255" nullable="true" comment="Source"/>
Expand All @@ -25,9 +25,6 @@
<index referenceId="MEDIA_GALLERY_ID" indexType="btree">
<column name="id"/>
</index>
<constraint xsi:type="unique" referenceId="MEDIA_GALLERY_ID_PATH_TITLE_CONTENT_TYPE_WIDTH_HEIGHT">
<column name="path"/>
</constraint>
<index referenceId="MEDIA_GALLERY_ASSET_TITLE" indexType="fulltext">
<column name="title"/>
</index>
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/MediaGallery/etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"MEDIA_GALLERY_ASSET_TITLE": true
},
"constraint": {
"MEDIA_GALLERY_ID_PATH_TITLE_CONTENT_TYPE_WIDTH_HEIGHT": true,
"PRIMARY": true,
"MEDIA_GALLERY_ASSET_PATH": true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\MediaGalleryCatalogUi\Controller\Adminhtml\Product;

use Magento\Framework\Controller\ResultInterface;
use Magento\Backend\App\Action\Context;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Backend\App\Action;

/**
* Returns selected product by product id. for ui-select filter
*/
class GetSelected extends Action implements HttpGetActionInterface
{
/**
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'Magento_Catalog::products';

/**
* @var JsonFactory
*/
private $resultJsonFactory;

/**
* @var ProductRepositoryInterface
*/
private $productRepository;

/**
* GetSelected constructor.
*
* @param JsonFactory $jsonFactory
* @param ProductRepositoryInterface $productRepository
* @param Context $context
*/
public function __construct(
JsonFactory $jsonFactory,
ProductRepositoryInterface $productRepository,
Context $context
) {
$this->resultJsonFactory = $jsonFactory;
$this->productRepository = $productRepository;
parent::__construct($context);
}

/**
* Return selected products options
*
* @return ResultInterface
*/
public function execute() : ResultInterface
{
$productIds = $this->getRequest()->getParam('ids');
$options = [];

if (!is_array($productIds)) {
return $this->resultJsonFactory->create()->setData('parameter ids must be type of array');
}
foreach ($productIds as $id) {
try {
$product = $this->productRepository->getById($id);
$options[] = [
'value' => $product->getId(),
'label' => $product->getName(),
'is_active' => $product->getSatus(),
'path' => $product->getSku()
];
} catch (\Exception $e) {
continue;
}
}

return $this->resultJsonFactory->create()->setData($options);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminSearchCategoryGridPageByCategoryNameActionGroup">
<annotations>
<description>Fills 'Search by category name' on Category Grid page. Clicks on Submit Search.</description>
</annotations>
<arguments>
<argument name="categoryName"/>
</arguments>

<conditionalClick selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.clearFilters}}" dependentSelector="{{AdminMediaGalleryCatalogUiCategoryGridSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
<fillField selector="{{AdminMediaGalleryCatalogUiCategoryGridSearchSection.searchInput}}" userInput="{{categoryName}}" stepKey="fillKeywordSearchField"/>
<click selector="{{AdminMediaGalleryCatalogUiCategoryGridSearchSection.submitSearch}}" stepKey="clickKeywordSearch"/>
<waitForLoadingMaskToDisappear stepKey="waitingForLoading" />
</actionGroup>
</actionGroups>
Loading

0 comments on commit d2bc662

Please sign in to comment.