diff --git a/app/code/Magento/MediaGalleryIntegration/Plugin/NewMediaGalleryOpenDialogUrl.php b/app/code/Magento/MediaGalleryIntegration/Plugin/NewMediaGalleryOpenDialogUrl.php new file mode 100644 index 0000000000000..f076aa43b6f96 --- /dev/null +++ b/app/code/Magento/MediaGalleryIntegration/Plugin/NewMediaGalleryOpenDialogUrl.php @@ -0,0 +1,43 @@ +config = $config; + } + + /** + * @param OpenDialogUrl $subject + * @param string $result + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @return string + */ + public function afterGet(OpenDialogUrl $subject, string $result) + { + $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/newmediagalleryplugin.log'); + $logger = new \Zend\Log\Logger(); + $logger->addWriter($writer); + $logger->debug(__METHOD__); + $logger->debug("PASSING HERE!"); + return $this->config->isEnabled() ? 'media_gallery/index/index' : $result; + } +} diff --git a/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/OpenDialogUrlProviderTest.php b/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/OpenDialogUrlTest.php similarity index 80% rename from app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/OpenDialogUrlProviderTest.php rename to app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/OpenDialogUrlTest.php index 7a3316f293879..90f363d6d792b 100644 --- a/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/OpenDialogUrlProviderTest.php +++ b/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/OpenDialogUrlTest.php @@ -9,16 +9,16 @@ namespace Magento\MediaGalleryIntegration\Test\Integration\Model; use Magento\Framework\ObjectManagerInterface; -use Magento\MediaGalleryIntegration\Model\OpenDialogUrlProvider; use Magento\MediaGalleryUiApi\Api\ConfigInterface; use Magento\TestFramework\Helper\Bootstrap; +use Magento\Ui\Component\Form\Element\DataType\Media\OpenDialogUrl; use PHPUnit\Framework\TestCase; /** * Provide tests cover getting correct url based on the config settings. * @magentoAppArea adminhtml */ -class OpenDialogUrlProviderTest extends TestCase +class OpenDialogUrlTest extends TestCase { /** * @var ObjectManagerInterface @@ -26,9 +26,9 @@ class OpenDialogUrlProviderTest extends TestCase private $objectManger; /** - * @var OpenDialogUrlProvider + * @var OpenDialogUrl */ - private $openDialogUrlProvider; + private $openDialogUrl; /** * @inheritdoc @@ -37,8 +37,8 @@ protected function setUp(): void { $this->objectManger = Bootstrap::getObjectManager(); $config = $this->objectManger->create(ConfigInterface::class); - $this->openDialogUrlProvider = $this->objectManger->create( - OpenDialogUrlProvider::class, + $this->openDialogUrl = $this->objectManger->create( + OpenDialogUrl::class, ['config' => $config] ); } @@ -49,7 +49,7 @@ protected function setUp(): void */ public function testWithEnhancedMediaGalleryDisabled(): void { - self::assertEquals('cms/wysiwyg_images/index', $this->openDialogUrlProvider->getUrl()); + self::assertEquals('cms/wysiwyg_images/index', $this->openDialogUrl->get()); } /** @@ -58,6 +58,6 @@ public function testWithEnhancedMediaGalleryDisabled(): void */ public function testWithEnhancedMediaGalleryEnabled(): void { - self::assertEquals('media_gallery/index/index', $this->openDialogUrlProvider->getUrl()); + self::assertEquals('media_gallery/index/index', $this->openDialogUrl->get()); } } diff --git a/app/code/Magento/MediaGalleryIntegration/etc/adminhtml/di.xml b/app/code/Magento/MediaGalleryIntegration/etc/adminhtml/di.xml index 1559a6d7dfcd5..08e83ce6cad88 100644 --- a/app/code/Magento/MediaGalleryIntegration/etc/adminhtml/di.xml +++ b/app/code/Magento/MediaGalleryIntegration/etc/adminhtml/di.xml @@ -7,9 +7,7 @@ --> - - Magento\MediaGalleryIntegration\Model\OpenDialogUrlProvider - + diff --git a/app/code/Magento/Ui/Component/Form/Element/DataType/Media/OpenDialogUrl.php b/app/code/Magento/Ui/Component/Form/Element/DataType/Media/OpenDialogUrl.php index 27370cbfbd68c..cd116a6f1bff8 100644 --- a/app/code/Magento/Ui/Component/Form/Element/DataType/Media/OpenDialogUrl.php +++ b/app/code/Magento/Ui/Component/Form/Element/DataType/Media/OpenDialogUrl.php @@ -8,10 +8,8 @@ namespace Magento\Ui\Component\Form\Element\DataType\Media; -use Magento\Framework\DataObject; - /** - * Basic configuration for OdenDialogUrl + * Basic configuration for OpenDialogUrl */ class OpenDialogUrl { @@ -22,14 +20,6 @@ class OpenDialogUrl */ private $openDialogUrl; - /** - * @param DataObject $url - */ - public function __construct(DataObject $url = null) - { - $this->openDialogUrl = $url; - } - /** * Returns open dialog url for media browser * @@ -38,7 +28,7 @@ public function __construct(DataObject $url = null) public function get(): string { if ($this->openDialogUrl) { - return $this->openDialogUrl->getUrl(); + return $this->openDialogUrl; } return self::DEFAULT_OPEN_DIALOG_URL; }