Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab naming generation #6516

Open
wants to merge 6 commits into
base: 4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/ArgumentResolver/AdminContextResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace EasyCorp\Bundle\EasyAdminBundle\ArgumentResolver;

use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
Expand All @@ -15,11 +15,9 @@
if (interface_exists(ValueResolverInterface::class)) {
final class AdminContextResolver implements ValueResolverInterface
{
private AdminContextProvider $adminContextProvider;

public function __construct(AdminContextProvider $adminContextProvider)
{
$this->adminContextProvider = $adminContextProvider;
public function __construct(
private AdminContextProviderInterface $adminContextProvider
) {
}

public function resolve(Request $request, ArgumentMetadata $argument): iterable
Expand All @@ -34,11 +32,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
} else {
final class AdminContextResolver implements ArgumentValueResolverInterface
{
private AdminContextProvider $adminContextProvider;

public function __construct(AdminContextProvider $adminContextProvider)
{
$this->adminContextProvider = $adminContextProvider;
public function __construct(
private AdminContextProviderInterface $adminContextProvider
) {
}

public function supports(Request $request, ArgumentMetadata $argument): bool
Expand Down
24 changes: 9 additions & 15 deletions src/ArgumentResolver/BatchActionDtoResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA;
use EasyCorp\Bundle\EasyAdminBundle\Dto\BatchActionDto;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
Expand All @@ -17,13 +17,10 @@
if (interface_exists(ValueResolverInterface::class)) {
final class BatchActionDtoResolver implements ValueResolverInterface
{
private AdminContextProvider $adminContextProvider;
private AdminUrlGeneratorInterface $adminUrlGenerator;

public function __construct(AdminContextProvider $adminContextProvider, AdminUrlGeneratorInterface $adminUrlGenerator)
{
$this->adminContextProvider = $adminContextProvider;
$this->adminUrlGenerator = $adminUrlGenerator;
public function __construct(
private AdminContextProviderInterface $adminContextProvider,
private AdminUrlGeneratorInterface $adminUrlGenerator
) {
}

public function resolve(Request $request, ArgumentMetadata $argument): iterable
Expand Down Expand Up @@ -53,13 +50,10 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
} else {
final class BatchActionDtoResolver implements ArgumentValueResolverInterface
{
private AdminContextProvider $adminContextProvider;
private AdminUrlGeneratorInterface $adminUrlGenerator;

public function __construct(AdminContextProvider $adminContextProvider, AdminUrlGeneratorInterface $adminUrlGenerator)
{
$this->adminContextProvider = $adminContextProvider;
$this->adminUrlGenerator = $adminUrlGenerator;
public function __construct(
private AdminContextProviderInterface $adminContextProvider,
private AdminUrlGeneratorInterface $adminUrlGenerator
) {
}

public function supports(Request $request, ArgumentMetadata $argument): bool
Expand Down
13 changes: 5 additions & 8 deletions src/EventListener/CrudResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace EasyCorp\Bundle\EasyAdminBundle\EventListener;

use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ViewEvent;
Expand All @@ -14,13 +14,10 @@
*/
final class CrudResponseListener
{
private AdminContextProvider $adminContextProvider;
private Environment $twig;

public function __construct(AdminContextProvider $adminContextProvider, Environment $twig)
{
$this->adminContextProvider = $adminContextProvider;
$this->twig = $twig;
public function __construct(
private AdminContextProviderInterface $adminContextProvider,
private Environment $twig
) {
}

public function onKernelView(ViewEvent $event): void
Expand Down
16 changes: 6 additions & 10 deletions src/EventListener/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use EasyCorp\Bundle\EasyAdminBundle\Exception\BaseException;
use EasyCorp\Bundle\EasyAdminBundle\Exception\FlattenException;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Twig\Environment;
Expand All @@ -21,15 +21,11 @@
*/
final class ExceptionListener
{
private bool $kernelDebug;
private AdminContextProvider $adminContextProvider;
private Environment $twig;

public function __construct(bool $kernelDebug, AdminContextProvider $adminContextProvider, Environment $twig)
{
$this->kernelDebug = $kernelDebug;
$this->adminContextProvider = $adminContextProvider;
$this->twig = $twig;
public function __construct(
private bool $kernelDebug,
private AdminContextProviderInterface $adminContextProvider,
private Environment $twig
) {
}

public function onKernelException(ExceptionEvent $event)
Expand Down
19 changes: 7 additions & 12 deletions src/Factory/ActionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use EasyCorp\Bundle\EasyAdminBundle\Translation\TranslatableMessageBuilder;
Expand All @@ -24,17 +24,12 @@
*/
final class ActionFactory
{
private AdminContextProvider $adminContextProvider;
private AuthorizationCheckerInterface $authChecker;
private AdminUrlGeneratorInterface $adminUrlGenerator;
private ?CsrfTokenManagerInterface $csrfTokenManager;

public function __construct(AdminContextProvider $adminContextProvider, AuthorizationCheckerInterface $authChecker, AdminUrlGeneratorInterface $adminUrlGenerator, ?CsrfTokenManagerInterface $csrfTokenManager = null)
{
$this->adminContextProvider = $adminContextProvider;
$this->authChecker = $authChecker;
$this->adminUrlGenerator = $adminUrlGenerator;
$this->csrfTokenManager = $csrfTokenManager;
public function __construct(
private AdminContextProviderInterface $adminContextProvider,
private AuthorizationCheckerInterface $authChecker,
private AdminUrlGeneratorInterface $adminUrlGenerator,
private ?CsrfTokenManagerInterface $csrfTokenManager = null
) {
}

public function processEntityActions(EntityDto $entityDto, ActionConfigDto $actionsDto): void
Expand Down
19 changes: 7 additions & 12 deletions src/Factory/FieldFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TimeField;
use EasyCorp\Bundle\EasyAdminBundle\Form\Type\EaFormRowType;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

Expand Down Expand Up @@ -55,17 +55,12 @@ final class FieldFactory
Types::TIME_IMMUTABLE => TimeField::class,
];

private AdminContextProvider $adminContextProvider;
private AuthorizationCheckerInterface $authorizationChecker;
private iterable $fieldConfigurators;
private FormLayoutFactory $fieldLayoutFactory;

public function __construct(AdminContextProvider $adminContextProvider, AuthorizationCheckerInterface $authorizationChecker, iterable $fieldConfigurators, FormLayoutFactory $fieldLayoutFactory)
{
$this->adminContextProvider = $adminContextProvider;
$this->authorizationChecker = $authorizationChecker;
$this->fieldConfigurators = $fieldConfigurators;
$this->fieldLayoutFactory = $fieldLayoutFactory;
public function __construct(
private AdminContextProviderInterface $adminContextProvider,
private AuthorizationCheckerInterface $authorizationChecker,
private iterable $fieldConfigurators,
private FormLayoutFactory $fieldLayoutFactory
) {
}

public function processFields(EntityDto $entityDto, FieldCollection $fields): void
Expand Down
12 changes: 5 additions & 7 deletions src/Factory/FilterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
use EasyCorp\Bundle\EasyAdminBundle\Filter\EntityFilter;
use EasyCorp\Bundle\EasyAdminBundle\Filter\NumericFilter;
use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;

/**
* @author Yonel Ceruto <[email protected]>
* @author Javier Eguiluz <[email protected]>
*/
final class FilterFactory
{
private AdminContextProvider $adminContextProvider;
private iterable $filterConfigurators;
private static array $doctrineTypeToFilterClass = [
'json_array' => ArrayFilter::class,
Types::SIMPLE_ARRAY => ArrayFilter::class,
Expand Down Expand Up @@ -52,10 +50,10 @@ final class FilterFactory
Types::TEXT => TextFilter::class,
];

public function __construct(AdminContextProvider $adminContextProvider, iterable $filterConfigurators)
{
$this->adminContextProvider = $adminContextProvider;
$this->filterConfigurators = $filterConfigurators;
public function __construct(
private AdminContextProviderInterface $adminContextProvider,
private iterable $filterConfigurators
) {
}

public function create(FilterConfigDto $filterConfig, FieldCollection $fields, EntityDto $entityDto): FilterCollection
Expand Down
6 changes: 5 additions & 1 deletion src/Factory/FormLayoutFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ private function linearizeLayoutConfiguration(FieldCollection $fields): void

if ($fieldDto->isFormTab()) {
$isTabActive = 0 === \count($tabs);
$tabId = sprintf('tab-%s', $fieldDto->getLabel() ? $slugger->slug(strip_tags($fieldDto->getLabel()))->lower()->toString() : ++$tabsWithoutLabelCounter);
$tabId = sprintf('tab-%s-%s', $fieldDto->getLabel()
? $slugger->slug(strip_tags($fieldDto->getLabel()))->lower()->toString()
: ++$tabsWithoutLabelCounter,
uniqid(),
);
$fieldDto->setCustomOption(FormField::OPTION_TAB_ID, $tabId);
$fieldDto->setCustomOption(FormField::OPTION_TAB_IS_ACTIVE, $isTabActive);

Expand Down
22 changes: 8 additions & 14 deletions src/Factory/MenuFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Dto\MainMenuDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDto;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
Expand All @@ -24,19 +24,13 @@
*/
final class MenuFactory implements MenuFactoryInterface
{
private AdminContextProvider $adminContextProvider;
private AuthorizationCheckerInterface $authChecker;
private LogoutUrlGenerator $logoutUrlGenerator;
private AdminUrlGeneratorInterface $adminUrlGenerator;
private MenuItemMatcherInterface $menuItemMatcher;

public function __construct(AdminContextProvider $adminContextProvider, AuthorizationCheckerInterface $authChecker, LogoutUrlGenerator $logoutUrlGenerator, AdminUrlGeneratorInterface $adminUrlGenerator, MenuItemMatcherInterface $menuItemMatcher)
{
$this->adminContextProvider = $adminContextProvider;
$this->authChecker = $authChecker;
$this->logoutUrlGenerator = $logoutUrlGenerator;
$this->adminUrlGenerator = $adminUrlGenerator;
$this->menuItemMatcher = $menuItemMatcher;
public function __construct(
private AdminContextProviderInterface $adminContextProvider,
private AuthorizationCheckerInterface $authChecker,
private LogoutUrlGenerator $logoutUrlGenerator,
private AdminUrlGeneratorInterface $adminUrlGenerator,
private MenuItemMatcherInterface $menuItemMatcher
) {
}

/**
Expand Down
13 changes: 5 additions & 8 deletions src/Factory/PaginatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@

use Doctrine\ORM\QueryBuilder;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm\EntityPaginatorInterface;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;

/**
* @author Javier Eguiluz <[email protected]>
*/
final class PaginatorFactory
{
private AdminContextProvider $adminContextProvider;
private EntityPaginatorInterface $entityPaginator;

public function __construct(AdminContextProvider $adminContextProvider, EntityPaginatorInterface $entityPaginator)
{
$this->adminContextProvider = $adminContextProvider;
$this->entityPaginator = $entityPaginator;
public function __construct(
private AdminContextProviderInterface $adminContextProvider,
private EntityPaginatorInterface $entityPaginator
) {
}

public function create(QueryBuilder $queryBuilder): EntityPaginatorInterface
Expand Down
13 changes: 5 additions & 8 deletions src/Field/Configurator/CommonPostConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;
use function Symfony\Component\String\u;
use Twig\Markup;

Expand All @@ -16,13 +16,10 @@
*/
final class CommonPostConfigurator implements FieldConfiguratorInterface
{
private AdminContextProvider $adminContextProvider;
private string $charset;

public function __construct(AdminContextProvider $adminContextProvider, string $charset)
{
$this->adminContextProvider = $adminContextProvider;
$this->charset = $charset;
public function __construct(
private AdminContextProviderInterface $adminContextProvider,
private string $charset
) {
}

public function supports(FieldDto $field, EntityDto $entityDto): bool
Expand Down
10 changes: 4 additions & 6 deletions src/Form/Extension/EaCrudFormTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace EasyCorp\Bundle\EasyAdminBundle\Form\Extension;

use EasyCorp\Bundle\EasyAdminBundle\Dto\FormVarsDto;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormInterface;
Expand All @@ -18,11 +18,9 @@
*/
class EaCrudFormTypeExtension extends AbstractTypeExtension
{
private AdminContextProvider $adminContextProvider;

public function __construct(AdminContextProvider $adminContextProvider)
{
$this->adminContextProvider = $adminContextProvider;
public function __construct(
private AdminContextProviderInterface $adminContextProvider
) {
}

public function configureOptions(OptionsResolver $resolver): void
Expand Down
10 changes: 4 additions & 6 deletions src/Inspector/DataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector as BaseDataCollector;
Expand All @@ -17,11 +17,9 @@
*/
class DataCollector extends BaseDataCollector
{
private AdminContextProvider $adminContextProvider;

public function __construct(AdminContextProvider $adminContextProvider)
{
$this->adminContextProvider = $adminContextProvider;
public function __construct(
private AdminContextProviderInterface $adminContextProvider
) {
}

public function reset(): void
Expand Down
Loading