Skip to content

Commit

Permalink
Code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
carakas committed Dec 17, 2023
1 parent 06c3eeb commit d05853a
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 18 deletions.
7 changes: 0 additions & 7 deletions src/Core/Domain/Form/DataGridType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,17 @@

use ForkCMS\Modules\Backend\Domain\Action\ModuleAction;
use ForkCMS\Modules\Internationalisation\Domain\Locale\Locale;
use ForkCMS\Modules\Internationalisation\Domain\Translation\TranslationKey;
use Pageon\DoctrineDataGridBundle\DataGrid\DataGrid;
use ReflectionObject;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* This form type is a workaround for showing a datagrid in a form.
*/
final class DataGridType extends AbstractType
{
public function __construct(private readonly TranslatorInterface $translator)
{
}

public function getBlockPrefix(): string
{
return 'data_grid';
Expand Down
5 changes: 3 additions & 2 deletions src/Core/Domain/Util/ArrayUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ final class ArrayUtil
public static function flatten(array $array, string $prefix = ''): array
{
$result = [];
foreach($array as $key=>$value) {
if(is_array($value)) {
foreach ($array as $key => $value) {
if (is_array($value)) {
$result += self::flatten($value, $prefix . $key . '.');
} else {
$result[$prefix . $key] = $value;
}
}

return $result;
}
}
1 change: 0 additions & 1 deletion src/Modules/Backend/tests/Backend/Actions/UserEditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public function testEditWithoutChanges(): void
{
$user = self::loadPage();
self::assertEmptyFormSubmission('user', 0, 'Save');
self::getClient()->followRedirect();
self::assertCurrentUrlEndsWith('/private/en/backend/user-index');
self::assertDataGridHasLink($user->getEmail());
self::assertResponseContains('The settings for "' . $user->getDisplayName() . '" were saved.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class ContentBlock
#[ORM\Column(type: 'integer')]
private int $id;

#[ORM\ManyToOne(targetEntity: Block::class, cascade: ['persist'], fetch: 'EAGER')]
#[ORM\ManyToOne(targetEntity: Block::class, cascade: ['persist'], fetch: 'EAGER', nullable: false)]
#[ORM\JoinColumn(nullable: false)]
private Block $widget;

#[ORM\Column(type: 'string', options: ['default' => self::DEFAULT_TEMPLATE])]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class ContentBlockDataTransferObject

public Block $widget;

public readonly int $revisionId;
public int $revisionId;

#[Assert\NotBlank(message: 'err.FieldIsRequired')]
public string $title;
Expand Down
5 changes: 3 additions & 2 deletions src/Modules/ContentBlocks/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
</authors>
<description>
<![CDATA[
The content blocks module provides the possibility to re-use content on multiple pages, wherefore the content can be managed in 1 single point, but the changes are immediately visible on all pages it occurs.
Content blocks are exceptionally well-suited for recurring content like contact details or call-to-actions.
The content blocks module provides the possibility to re-use content on multiple pages.
The content can be managed in one place and changes will affect all pages where the content block is used.
Some examples for these content blocks are: footer doormats, addresses, social media blocks, call to actions, ...
]]>
</description>
<events>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if content_block is defined and content_block.text %}
<div class="module-content-blocks widget-content-blocks-default content-block-{{ content_block.id }}" id="{{ content_block.id }}">
<div class="module-content-blocks widget-content-blocks-default content-block-{{ content_block.id }}">
{{ content_block.text|parseEditor }}
</div>
{% endif %}
3 changes: 2 additions & 1 deletion src/Modules/Frontend/Domain/Block/BlockRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/
final class BlockRepository extends SortableRepository implements ServiceEntityRepositoryInterface
{
public function __construct(EntityManagerInterface $entityManager,
public function __construct(
EntityManagerInterface $entityManager,
private readonly EventDispatcherInterface $eventDispatcher
) {
parent::__construct($entityManager, $entityManager->getClassMetadata(Block::class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function getFormResponse(Request $request): ?Response
formType: TranslationType::class,
formData: new CreateTranslation($translation),
redirectResponse: new RedirectResponse(TranslationIndex::getActionSlug()->generateRoute($this->router)),
successFlashMessageCallback: static fn (FormInterface $form) => FlashMessage::success(
successFlashMessageCallback: fn (FormInterface $form) => FlashMessage::success(
'EntityAdded',
['entity' => $this->translator->trans($form->getData()->getEntity()->getTranslatable())]
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function getFormResponse(Request $request): ?Response
formType: TranslationType::class,
formData: new ChangeTranslation($translation),
redirectResponse: new RedirectResponse(TranslationIndex::getActionSlug()->generateRoute($this->router)),
successFlashMessageCallback: static fn (FormInterface $form) => FlashMessage::success(
successFlashMessageCallback: fn (FormInterface $form) => FlashMessage::success(
'EntityEdited',
['entity' => $this->translator->trans($form->getData()->getEntity()->getTranslatable())]
),
Expand Down

0 comments on commit d05853a

Please sign in to comment.