Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
- 8.5
symfony:
- 6.4.*
- 7.*
- 7.4.*
# - 8.*
dependencies: [ lowest, highest ]
name: 'PHP ${{ matrix.php }} + Symfony ${{ matrix.symfony }} + ${{ matrix.dependencies }} dependencies'
steps:
Expand Down
30 changes: 15 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
"ext-dom": "*",
"azjezz/psl": "^2.9.1 || ^3.0.0 || ^4.0.0",
"easycorp/easyadmin-bundle": "~4.25.0",
"symfony/asset": "^6.4 || ^7.2",
"symfony/cache": "^6.4 || ^7.2",
"symfony/config": "^6.4 || ^7.2",
"symfony/dependency-injection": "^6.4 || ^7.2",
"symfony/dom-crawler": "^6.4 || ^7.2",
"symfony/event-dispatcher": "^6.4 || ^7.2",
"symfony/filesystem": "^6.4 || ^7.2",
"symfony/form": "^6.4 || ^7.2",
"symfony/framework-bundle": "^6.4 || ^7.2",
"symfony/http-foundation": "^6.4 || ^7.2",
"symfony/http-kernel": "^6.4 || ^7.2",
"easycorp/easyadmin-bundle": "~4.27.5",
"symfony/asset": "^6.4 || ^7.4",
"symfony/cache": "^6.4 || ^7.4",
"symfony/config": "^6.4 || ^7.4",
"symfony/dependency-injection": "^6.4 || ^7.4",
"symfony/dom-crawler": "^6.4 || ^7.4",
"symfony/event-dispatcher": "^6.4 || ^7.4",
"symfony/filesystem": "^6.4 || ^7.4",
"symfony/form": "^6.4 || ^7.4",
"symfony/framework-bundle": "^6.4 || ^7.4",
"symfony/http-foundation": "^6.4 || ^7.4",
"symfony/http-kernel": "^6.4 || ^7.4",
"symfony/polyfill-php83": "^1.29",
"symfony/property-access": "^6.4 || ^7.2",
"symfony/property-access": "^6.4 || ^7.4",
"symfony/service-contracts": "^2.4 || ^3.0",
"symfony/translation": "^6.4 || ^7.2",
"symfony/twig-bundle": "^6.4 || ^7.2"
"symfony/translation": "^6.4 || ^7.4",
"symfony/twig-bundle": "^6.4 || ^7.4"
},
"require-dev": {
"doctrine/coding-standard": "^14.0.0",
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment"/>
<exclude name="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion.RequiredConstructorPropertyPromotion"/>
<exclude name="SlevomatCodingStandard.PHP.RequireExplicitAssertion.RequiredExplicitAssertion"/>
</rule>
<!-- inherit rules from: -->
<rule ref="Generic.Files.LineLength">
Expand Down
50 changes: 29 additions & 21 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.13.1@1e3b7f0a8ab32b23197b91107adc0a7ed8a05b51">
<files psalm-version="6.14.2@bbd217fc98c0daa0a13aea2a7f119d03ba3fc9a0">
<file src="src/Controller/BaseCrudController.php">
<ArgumentTypeCoercion>
<code><![CDATA[$apply]]></code>
Expand Down Expand Up @@ -109,45 +109,53 @@
<ArgumentTypeCoercion>
<code><![CDATA[$targetCrudControllerFqcn]]></code>
</ArgumentTypeCoercion>
<InvalidArrayAccess>
<code><![CDATA[$fieldMapping['type']]]></code>
<code><![CDATA[$fieldMapping['type']]]></code>
</InvalidArrayAccess>
<InvalidOperand>
<code><![CDATA[0 + $queryTerm]]></code>
</InvalidOperand>
<MixedArgument>
<code><![CDATA[$entityDto->getClassMetadata()->getAssociationMapping($sortProperty)['mappedBy']]]></code>
<code><![CDATA[$entityFqcn]]></code>
<code><![CDATA[$entityName]]></code>
<code><![CDATA[$entityName]]></code>
<code><![CDATA[$entityName]]></code>
<code><![CDATA[$entityName]]></code>
<code><![CDATA[$entityName]]></code>
<code><![CDATA[$idClassName]]></code>
<code><![CDATA[$metadata->get('mappedBy')]]></code>
<code><![CDATA[$metadata->get('targetEntity')]]></code>
<code><![CDATA[$propertyConfig['property_name']]]></code>
<code><![CDATA[$propertyConfig['property_name']]]></code>
<code><![CDATA[$propertyConfig['property_name']]]></code>
<code><![CDATA[$propertyConfig['property_name']]]></code>
<code><![CDATA[$propertyConfig['property_name']]]></code>
<code><![CDATA[$targetEntity]]></code>
<code><![CDATA[$targetEntityFqcn]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$submittedData]]></code>
</MixedArgumentTypeCoercion>
<MixedMethodCall>
<code><![CDATA[getFqcn]]></code>
</MixedMethodCall>
<PossiblyNullArgument>
<code><![CDATA[$targetEntityFqcn]]></code>
</PossiblyNullArgument>
<PossiblyNullOperand>
<code><![CDATA[$entityDto->getPrimaryKeyName()]]></code>
</PossiblyNullOperand>
<MixedOperand>
<code><![CDATA[$associationSortProperty]]></code>
</MixedOperand>
<MixedReturnTypeCoercion>
<code><![CDATA[$searchablePropertiesConfig]]></code>
<code><![CDATA[array<array{
* entity_name: string,
* property_data_type: string,
* property_name: string,
* is_boolean: bool,
* is_small_integer: bool,
* is_integer: bool,
* is_numeric: bool,
* is_text: bool,
* is_guid: bool,
* is_ulid: bool,
* is_json: bool,
* }>]]></code>
</MixedReturnTypeCoercion>
<PossiblyNullReference>
<code><![CDATA[getRequest]]></code>
</PossiblyNullReference>
<PossiblyUndefinedMethod>
<code><![CDATA[getName]]></code>
</PossiblyUndefinedMethod>
<TypeDoesNotContainType>
<code><![CDATA[is_array($fieldMapping)]]></code>
<code><![CDATA[is_array($fieldMapping)]]></code>
</TypeDoesNotContainType>
</file>
<file src="src/Test/Controller/AdminControllerWebTestCase.php">
<InvalidArgument>
Expand Down
11 changes: 0 additions & 11 deletions src/Controller/BaseCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,6 @@ protected function addConfirmationForAction(
return $action;
}

protected function renderInDropdown(Action $action, bool $shouldRenderInDropdown): Action
{
$action
->getAsDto()
->addHtmlAttributes(
['data-protung-easyadmin-plus-extension-action-render-in-dropdown' => $shouldRenderInDropdown ? '1' : '-1'],
);

return $action;
}

protected function currentAdminContext(): AdminContext
{
$currentAdminContext = $this->getContext();
Expand Down
11 changes: 6 additions & 5 deletions src/Controller/BaseCrudDtoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityUpdatedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException;
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException;
use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory;
use EasyCorp\Bundle\EasyAdminBundle\Factory\ActionFactory;
use EasyCorp\Bundle\EasyAdminBundle\Factory\FieldFactory;
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use Override;
Expand Down Expand Up @@ -114,9 +115,9 @@ public function edit(AdminContext $context): KeyValueStore|Response
throw new InsufficientEntityPermissionException($context);
}

$this->container->get(EntityFactory::class)->processFields($context->getEntity(), FieldCollection::new($this->configureFields(Crud::PAGE_EDIT)));
$this->container->get(FieldFactory::class)->processFields($context->getEntity(), FieldCollection::new($this->configureFields(Crud::PAGE_EDIT)), Crud::PAGE_EDIT);
$context->getCrud()->setFieldAssets($this->getFieldAssets($context->getEntity()->getFields()));
$this->container->get(EntityFactory::class)->processActions($context->getEntity(), $context->getCrud()->getActionsConfig());
$this->container->get(ActionFactory::class)->processEntityActions($context->getEntity(), $context->getCrud()->getActionsConfig());
/** @var TDto $dto */
$dto = $context->getEntity()->getInstance();

Expand Down Expand Up @@ -217,9 +218,9 @@ public function new(AdminContext $context): KeyValueStore|Response

$context->getEntity()->setInstance(null);
$context->getEntity()->setInstance($this->createDto());
$this->container->get(EntityFactory::class)->processFields($context->getEntity(), FieldCollection::new($this->configureFields(Crud::PAGE_NEW)));
$this->container->get(FieldFactory::class)->processFields($context->getEntity(), FieldCollection::new($this->configureFields(Crud::PAGE_NEW)), Crud::PAGE_NEW);
$context->getCrud()->setFieldAssets($this->getFieldAssets($context->getEntity()->getFields()));
$this->container->get(EntityFactory::class)->processActions($context->getEntity(), $context->getCrud()->getActionsConfig());
$this->container->get(ActionFactory::class)->processEntityActions($context->getEntity(), $context->getCrud()->getActionsConfig());

$newForm = $this->createNewForm($context->getEntity(), $context->getCrud()->getNewFormOptions(), $context);
$newForm->handleRequest($context->getRequest());
Expand Down
2 changes: 1 addition & 1 deletion src/Field/Configurator/EntityConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $c
$field->getValue(),
);

$field->setFormTypeOptionIfNotSet('is_association', $entityDto->isAssociation($propertyName));
$field->setFormTypeOptionIfNotSet('is_association', $entityDto->getClassMetadata()->hasAssociation($propertyName));
$this->configureOnChange($field, $entityMetadata);

$associationType = Type\string()->coerce($field->getCustomOption(EntityField::OPTION_DOCTRINE_ASSOCIATION_TYPE));
Expand Down
4 changes: 1 addition & 3 deletions src/Filter/Configurator/EntityConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function configure(FilterDto $filterDto, FieldDto|null $fieldDto, EntityD

$targetEntityFqcn = Type\string()->coerce($context->getCrudControllers()->findEntityFqcnByCrudFqcn($targetCrudControllerFqcn));

if (! $entityDto->isAssociation($propertyName)) {
if (! $entityDto->getClassMetadata()->hasAssociation($propertyName)) {
$filterDto->setFormTypeOption('value_type_options.class', $targetEntityFqcn);
}

Expand All @@ -73,8 +73,6 @@ public function configure(FilterDto $filterDto, FieldDto|null $fieldDto, EntityD
$widgetMode = Type\string()->coerce($fieldDto->getCustomOption(EntityField::OPTION_WIDGET));
if ($widgetMode === EntityField::WIDGET_AUTOCOMPLETE) {
$filterDto->setFormTypeOption('value_type_options.attr.data-ea-widget', 'ea-autocomplete');
} elseif ($widgetMode === EntityField::WIDGET_NATIVE) {
$filterDto->setFormTypeOption('value_type_options.class', $targetEntityFqcn);
}

if ($autocompleteMode !== true) {
Expand Down
6 changes: 3 additions & 3 deletions src/Orm/EntityPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm\EntityPaginatorInterface;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Provider\AdminContextProviderInterface;
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\PaginatorDto;
use EasyCorp\Bundle\EasyAdminBundle\Factory\ControllerFactory;
use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface;
use Override;
use Protung\EasyAdminPlusBundle\Field\EntityField;
Expand All @@ -33,7 +33,7 @@
{
public function __construct(
private EntityPaginatorInterface $decoratedPaginator,
private AdminContextProvider $adminContextProvider,
private AdminContextProviderInterface $adminContextProvider,
private ControllerFactory $controllerFactory,
private EntityFactory $entityFactory,
private AdminUrlGeneratorInterface $adminUrlGenerator,
Expand Down Expand Up @@ -177,7 +177,7 @@ public function getResultsAsJson(): string
return $this->decoratedPaginator->getResultsAsJson();
}

$primaryKeyName = Type\string()->coerce($context->getEntity()->getPrimaryKeyName());
$primaryKeyName = $context->getEntity()->getClassMetadata()->getSingleIdentifierFieldName();
$reindexResults = Dict\reindex(
Type\vec(Type\object())->coerce($results),
fn (object $entityInstance): string => (string) $this->propertyAccessor->getValue($entityInstance, $primaryKeyName),
Expand Down
Loading