Skip to content

Commit

Permalink
continue to simplify and add templates/icons in default svg dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Nov 17, 2023
1 parent 09c68cc commit ae97614
Show file tree
Hide file tree
Showing 17 changed files with 378 additions and 366 deletions.
12 changes: 12 additions & 0 deletions packages/admin/src/AdminFormFieldManager.php
@@ -0,0 +1,12 @@
<?php

namespace Pushword\Admin;

class AdminFormFieldManager
{
/**
* Todo manage required form field for autowiring
* here
* instead in AdminTrait.
*/
}
33 changes: 18 additions & 15 deletions packages/admin/src/AdminTrait.php
Expand Up @@ -25,8 +25,6 @@ trait AdminTrait
{
protected AppPool $apps;

private ImageManager $imageManager;

/**
* @var class-string<PageInterface>
*/
Expand All @@ -39,8 +37,6 @@ trait AdminTrait

protected string $userClass;

protected Twig $twig;

protected EntityManagerInterface $em;

protected RouterInterface $router;
Expand Down Expand Up @@ -145,6 +141,9 @@ public function getEntityManager(): EntityManagerInterface
return $this->em;
}

/** Used in AbstractField::class / MediaPreviewField::class */
protected Twig $twig;

#[Required]
public function setTwig(Twig $twig): void
{
Expand Down Expand Up @@ -226,17 +225,6 @@ public function getMessagePrefix(): string
return $this->messagePrefix;
}

#[Required]
public function setImageManager(ImageManager $imageManager): void
{
$this->imageManager = $imageManager;
}

public function getImageManager(): ImageManager
{
return $this->imageManager;
}

/**
* @psalm-suppress InvalidArgument
*
Expand All @@ -255,4 +243,19 @@ protected function getFormFields(): array

return $event->getFields();
}

private ImageManager $imageManager;

public function getImageManager(): ImageManager
{
return $this->imageManager;
}

#[Required]
public function setImageManager(ImageManager $imageManager): self
{
$this->imageManager = $imageManager;

return $this;
}
}
2 changes: 1 addition & 1 deletion packages/admin/src/FormField/Event.php
Expand Up @@ -18,7 +18,7 @@ class Event extends SfEvent

/**
* @param AdminInterface<T> $admin
* @param mixed[] $fields
* @param mixed[] $fields // TODO Reduce complexity !!!
*/
public function __construct(
private readonly AdminInterface $admin,
Expand Down
11 changes: 8 additions & 3 deletions packages/admin/src/FormField/PageH1Field.php
Expand Up @@ -14,8 +14,9 @@ class PageH1Field extends AbstractField
/**
* @var string
*/
final public const DEFAULT_STYLE = 'font-size: 22px !important; border:0;'
.'font-weight: 700; padding: 10px 10px 0px 10px; margin-top:-23px; margin-bottom:-23px max-width: 640px; color:#111827';
final public const DEFAULT_STYLE = 'font-size: 22px !important; font-weight: 700; border:0; color:#111827;'
.'padding: 10px 10px 0px 10px; margin-top:-23px; margin-bottom:-23px;
max-width: 640px; ';

/**
* @param FormMapper<PageInterface> $form
Expand All @@ -29,7 +30,11 @@ public function formField(FormMapper $form, string $style = ''): FormMapper
// Todo move style to view
return $form->add('h1', TextareaType::class, [
'required' => false,
'attr' => ['class' => 'autosize textarea-no-newline ce-block__content', 'placeholder' => 'admin.page.title.label', 'style' => $style],
'attr' => [
'class' => 'autosize textarea-no-newline ce-block__content',
'placeholder' => 'admin.page.title.label',
'style' => $style,
],
'label' => ' ',
]);
}
Expand Down
13 changes: 13 additions & 0 deletions packages/admin/src/MediaAdmin.php
Expand Up @@ -11,13 +11,20 @@
use Sonata\AdminBundle\Object\Metadata;
use Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter;
use Sonata\DoctrineORMAdminBundle\Filter\ModelAutocompleteFilter;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;

/**
* @extends AbstractAdmin<MediaInterface>
*
* @implements AdminInterface<MediaInterface>
*/
#[AutoconfigureTag('sonata.admin', [
'model_class' => '%pw.entity_media%',
'manager_type' => 'orm',
'label' => 'admin.label.media',
'persist_filters' => true,
])]
final class MediaAdmin extends AbstractAdmin implements AdminInterface
{
/**
Expand All @@ -27,6 +34,12 @@ final class MediaAdmin extends AbstractAdmin implements AdminInterface

private string $messagePrefix = 'admin.media';

protected function configure(): void
{
$this->setTemplate('list', '@pwAdmin/CRUD/mosaic.html.twig');
$this->setTemplate('short_object_description', '@pwAdmin/media/short_object_description.html.twig');
}

protected function configureDefaultSortValues(array &$sortValues): void
{
$sortValues = [
Expand Down
3 changes: 3 additions & 0 deletions packages/admin/src/Menu/PageMenuProvider.php
Expand Up @@ -6,13 +6,16 @@
use Knp\Menu\FactoryInterface;
use Knp\Menu\ItemInterface;
use Sonata\AdminBundle\Event\ConfigureMenuEvent;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\Service\Attribute\Required;
use Symfony\Contracts\Translation\TranslatorInterface;

#[AutoconfigureTag('knp_menu.menu_builder', ['method' => 'getMenu', 'alias' => 'page_admin_menu'])]
#[AutoconfigureTag('knp_menu.menu_builder', ['method' => 'getRedirectionMenu', 'alias' => 'redirection_admin_menu'])]
final class PageMenuProvider implements ContainerAwareInterface
{
use ContainerAwareTrait;
Expand Down

0 comments on commit ae97614

Please sign in to comment.