Skip to content

Commit

Permalink
Merge pull request #236 from maximehuran/feature/html-no-wysiwyg
Browse files Browse the repository at this point in the history
Remove Sun Editor from Html UI Element
  • Loading branch information
maximehuran authored Aug 21, 2024
2 parents 17c9b8f + 01c6f1d commit ee199d3
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ COMPOSER=symfony composer
CONSOLE=${SYMFONY} console
export COMPOSE_PROJECT_NAME=rich-editor
PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin
COMPOSE=docker-compose
COMPOSE=docker compose
YARN=yarn

###
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: max
level: 8
paths:
- %rootDir%/src/

Expand Down
6 changes: 3 additions & 3 deletions src/Controller/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ private function convertFormDataForRequest(array $formData, string $prefix = '')
foreach ($formData as $key => $value) {
if (\is_array($value)) {
if (empty($prefix)) {
$items = array_merge($items, $this->convertFormDataForRequest($value, sprintf('%s', $key)));
$items = array_merge($items, $this->convertFormDataForRequest($value, \sprintf('%s', $key)));
} else {
$items = array_merge($items, $this->convertFormDataForRequest($value, sprintf('%s[%s]', $prefix, $key)));
$items = array_merge($items, $this->convertFormDataForRequest($value, \sprintf('%s[%s]', $prefix, $key)));
}
} else {
$items[sprintf('%s[%s]', $prefix, $key)] = $value;
$items[\sprintf('%s[%s]', $prefix, $key)] = $value;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/UiElementRegistryPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function validateUiElementResource(string $class): void
$interfaces = (array) class_implements($class);

if (!\in_array(UiElementInterface::class, $interfaces, true)) {
throw new InvalidArgumentException(sprintf('Class "%s" must implement "%s" to be registered as a UiElement resource.', $class, UiElementInterface::class));
throw new InvalidArgumentException(\sprintf('Class "%s" must implement "%s" to be registered as a UiElement resource.', $class, UiElementInterface::class));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/UiElementNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ final class UiElementNotFoundException extends Exception
*/
public function __construct(string $code, ?Exception $previous = null)
{
parent::__construct(sprintf('UiElement with code "%s" could not be found!', $code), 0, $previous);
parent::__construct(\sprintf('UiElement with code "%s" could not be found!', $code), 0, $previous);
}
}
6 changes: 2 additions & 4 deletions src/Form/Type/UiElement/HtmlType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@

namespace MonsieurBiz\SyliusRichEditorPlugin\Form\Type\UiElement;

use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\WysiwygType;
use MonsieurBiz\SyliusRichEditorPlugin\WysiwygEditor\EditorInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;

class HtmlType extends AbstractType
Expand All @@ -26,9 +25,8 @@ class HtmlType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('content', WysiwygType::class, [
->add('content', TextareaType::class, [
'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.html.field.content',
'editor_toolbar_type' => EditorInterface::TOOLBAR_TYPE_FULL,
])
;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Maker/UiElementMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$uiElementFormClassNameDetails->getFullName(),
__DIR__ . '/../Resources/skeleton/UiElementFormType.tpl.php',
[
'code' => sprintf('%s.%s', $codePrefix, $code),
'code' => \sprintf('%s.%s', $codePrefix, $code),
'icon' => 'map pin',
'tags' => json_encode([]),
]
);

// Generate templates
$generator->generateTemplate(
sprintf('Admin/UiElement/%s.html.twig', $code),
\sprintf('Admin/UiElement/%s.html.twig', $code),
__DIR__ . '/../Resources/skeleton/UiElementTemplate.tpl.php',
[
'code' => $code,
]
);
$generator->generateTemplate(
sprintf('Shop/UiElement/%s.html.twig', $code),
\sprintf('Shop/UiElement/%s.html.twig', $code),
__DIR__ . '/../Resources/skeleton/UiElementTemplate.tpl.php',
[
'code' => $code,
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/RichEditorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function convertYoutubeEmbeddedLink(string $url): ?string
return null;
}

return sprintf('https://www.youtube.com/embed/%s', $id);
return \sprintf('https://www.youtube.com/embed/%s', $id);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/UiElement/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function isEnabled(): bool
public function getParameter(string $name)
{
if (!$this->hasParameter($name)) {
throw new InvalidArgumentException(sprintf('Parameter "%s" is not configured for resource "%s".', $name, $this->getCode()));
throw new InvalidArgumentException(\sprintf('Parameter "%s" is not configured for resource "%s".', $name, $this->getCode()));
}

return $this->parameters[$name];
Expand Down Expand Up @@ -112,7 +112,7 @@ public function getParameters(): array
public function getClass(string $name): string
{
if (!$this->hasClass($name)) {
throw new InvalidArgumentException(sprintf('Class "%s" is not configured for resource "%s".', $name, $this->getCode()));
throw new InvalidArgumentException(\sprintf('Class "%s" is not configured for resource "%s".', $name, $this->getCode()));
}

return $this->parameters['classes'][$name];
Expand All @@ -132,7 +132,7 @@ public function hasClass(string $name): bool
public function getTemplate(string $name): string
{
if (!$this->hasTemplate($name)) {
throw new InvalidArgumentException(sprintf('Template "%s" is not configured for resource "%s".', $name, $this->getCode()));
throw new InvalidArgumentException(\sprintf('Template "%s" is not configured for resource "%s".', $name, $this->getCode()));
}

return $this->parameters['templates'][$name];
Expand All @@ -153,7 +153,7 @@ public function getServiceId(string $serviceName): string
{
$code = explode('.', $this->code);

return sprintf('%s.%s.%s', $code[0], $serviceName, $code[1]);
return \sprintf('%s.%s.%s', $code[0], $serviceName, $code[1]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/UiElement/Metadata/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class Registry implements RegistryInterface
public function get(string $code): MetadataInterface
{
if (!\array_key_exists($code, $this->metadata)) {
throw new InvalidArgumentException(sprintf('Resource "%s" does not exist.', $code));
throw new InvalidArgumentException(\sprintf('Resource "%s" does not exist.', $code));
}

return $this->metadata[$code];
Expand Down
1 change: 0 additions & 1 deletion src/Validator/Constraints/YoutubeUrlValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function validate(mixed $value, Constraint $constraint): void
throw new UnexpectedTypeException($constraint, YoutubeUrl::class);
}

/** @phpstan-ignore-next-line */
$value = (string) $value;

if (!preg_match(self::YOUTUBE_REGEX_VALIDATOR, $value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/WysiwygEditor/EditorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public function getEditor(string $type): EditorInterface
return $this->editors[$type];
}

throw new DomainException(sprintf('There is no editor with %s type', $type));
throw new DomainException(\sprintf('There is no editor with %s type', $type));
}
}

0 comments on commit ee199d3

Please sign in to comment.