<?php
declare(strict_types=1);
namespace She\TinyMce;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Uuid\Uuid;
class SheTinyMce extends Plugin
{
public function activate(ActivateContext $activateContext): void
{
$repository = $this->container->get('tiny_config.repository');
if (!$repository instanceof EntityRepository) {
return;
}
$result = $repository->search(new Criteria(), $activateContext->getContext());
if (0 !== $result->count()) {
return;
}
$repository->create([[
'id' => Uuid::randomHex(),
'plugins' => [
'advlist',
'anchor',
'autolink',
'code',
'emoticons',
'fullscreen',
'help',
'image',
'link',
'lists',
'media',
'quickbars',
'table',
'wordcount',
],
'premiumPlugins' => [
'a11ychecker',
'advtable',
'casechange',
'checklist',
'linkchecker',
'pageembed',
'export',
'tableofcontents',
],
'toolbar' => [
'undo',
'redo',
'alignleft',
'aligncenter',
'alignright',
'alignjustify',
'copy',
'cut',
'paste',
'fontfamily',
'fontsize',
'bold',
'italic',
'underline',
'selectall',
'bullist',
'numlist',
'link',
'anchor',
'image',
'fullscreen',
'emoticons',
'help',
],
'premiumToolbar' => [
'a11ycheck',
'advtablerownumbering',
'casechange',
'checklist',
'export',
'tableofcontents',
],
'skin' => 'oxide',
'spellcheck' => true,
'relativeUrls' => false,
'convertUrls' => true,
'removeScriptHost' => true,
'cleanup' => true,
'styleFormats' => '[
{
"title": "Red text",
"inline": "span",
"styles": {
"color": "#ff0000"
}
},
{
"title": "Black text",
"inline": "span",
"styles": {
"color": "#000000"
}
}
]
',
]], $activateContext->getContext());
}
}