Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Widget.php
Go to the documentation of this file.
1 <?php
7 declare(strict_types=1);
9 
11 
15 class Widget
16 {
20  private $activeEditor;
21 
25  private $placeholderImages;
26 
30  private $assetRepo;
31 
37  public function __construct(
38  \Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor,
39  \Magento\Framework\View\Asset\Repository $assetRepo,
40  \Magento\Tinymce3\Model\Config\Widget\PlaceholderImagesPool $placeholderImages
41  ) {
42  $this->activeEditor = $activeEditor;
43  $this->placeholderImages = $placeholderImages;
44  $this->assetRepo = $assetRepo;
45  }
46 
55  \Magento\Widget\Model\Widget $subject,
56  \Closure $proceed,
57  string $type
58  ) : string {
59  if ($this->activeEditor->getWysiwygAdapterPath() !== Editor::WYSIWYG_EDITOR_CONFIG_VALUE) {
60  return $proceed($type);
61  }
62  $placeholders = $this->placeholderImages->getWidgetPlaceholders();
63  $defaultImage = $this->assetRepo->getUrl('Magento_Tinymce3::images/widget/placeholder.png');
64 
65  if (isset($placeholders[$type])) {
66  return $this->assetRepo->getUrl($placeholders[$type]);
67  }
68  return $defaultImage;
69  }
70 }
$type
Definition: item.phtml:13
aroundGetPlaceholderImageUrl(\Magento\Widget\Model\Widget $subject, \Closure $proceed, string $type)
Definition: Widget.php:54
__construct(\Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Tinymce3\Model\Config\Widget\PlaceholderImagesPool $placeholderImages)
Definition: Widget.php:37