custom/plugins/SheTinyMce/src/SheTinyMce.php line 13

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace She\TinyMce;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  6. use Shopware\Core\Framework\Plugin;
  7. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  8. use Shopware\Core\Framework\Uuid\Uuid;
  9. class SheTinyMce extends Plugin
  10. {
  11.     public function activate(ActivateContext $activateContext): void
  12.     {
  13.         $repository $this->container->get('tiny_config.repository');
  14.         if (!$repository instanceof EntityRepository) {
  15.             return;
  16.         }
  17.         $result $repository->search(new Criteria(), $activateContext->getContext());
  18.         if (!== $result->count()) {
  19.             return;
  20.         }
  21.         $repository->create([[
  22.             'id' => Uuid::randomHex(),
  23.             'plugins' => [
  24.                 'advlist',
  25.                 'anchor',
  26.                 'autolink',
  27.                 'code',
  28.                 'emoticons',
  29.                 'fullscreen',
  30.                 'help',
  31.                 'image',
  32.                 'link',
  33.                 'lists',
  34.                 'media',
  35.                 'quickbars',
  36.                 'table',
  37.                 'wordcount',
  38.             ],
  39.             'premiumPlugins' => [
  40.                 'a11ychecker',
  41.                 'advtable',
  42.                 'casechange',
  43.                 'checklist',
  44.                 'linkchecker',
  45.                 'pageembed',
  46.                 'export',
  47.                 'tableofcontents',
  48.             ],
  49.             'toolbar' => [
  50.                 'undo',
  51.                 'redo',
  52.                 'alignleft',
  53.                 'aligncenter',
  54.                 'alignright',
  55.                 'alignjustify',
  56.                 'copy',
  57.                 'cut',
  58.                 'paste',
  59.                 'fontfamily',
  60.                 'fontsize',
  61.                 'bold',
  62.                 'italic',
  63.                 'underline',
  64.                 'selectall',
  65.                 'bullist',
  66.                 'numlist',
  67.                 'link',
  68.                 'anchor',
  69.                 'image',
  70.                 'fullscreen',
  71.                 'emoticons',
  72.                 'help',
  73.             ],
  74.             'premiumToolbar' => [
  75.                 'a11ycheck',
  76.                 'advtablerownumbering',
  77.                 'casechange',
  78.                 'checklist',
  79.                 'export',
  80.                 'tableofcontents',
  81.             ],
  82.             'skin' => 'oxide',
  83.             'spellcheck' => true,
  84.             'relativeUrls' => false,
  85.             'convertUrls' => true,
  86.             'removeScriptHost' => true,
  87.             'cleanup' => true,
  88.             'styleFormats' => '[
  89.   {
  90.     "title": "Red text",
  91.     "inline": "span",
  92.     "styles": {
  93.       "color": "#ff0000"
  94.     }
  95.   },
  96.   {
  97.     "title": "Black text",
  98.     "inline": "span",
  99.     "styles": {
  100.       "color": "#000000"
  101.     }
  102.   }
  103. ]
  104. ',
  105.         ]], $activateContext->getContext());
  106.     }
  107. }