-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.4-develop' into framework-EnumLookup
- Loading branch information
Showing
75 changed files
with
1,959 additions
and
758 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 36 additions & 35 deletions
71
app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/OnInsert.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
app/code/Magento/Cms/Model/Wysiwyg/Images/GetInsertImageContent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
app/code/Magento/MediaGalleryCatalogUi/Controller/Adminhtml/Product/GetSelected.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
...aGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertCategoryGridPageDetailsActionGroup.xml
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...yCatalogUi/Test/Mftf/ActionGroup/AdminSearchCategoryGridPageByCategoryNameActionGroup.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.