-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop building show/list/form when accessing fieldDescription (#6148)
* Update interface * Use state to avoid infinite loop * Add test
- Loading branch information
1 parent
c2ec317
commit 5386609
Showing
5 changed files
with
131 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,18 +33,19 @@ | |
/** | ||
* @author Thomas Rabaix <[email protected]> | ||
* | ||
* @method array configureActionButtons(string $action, ?object $object = null) | ||
* @method string getSearchResultLink(object $object) | ||
* @method void showMosaicButton(bool $isShown) | ||
* @method bool isDefaultFilter(string $name) | ||
* @method bool isCurrentRoute(string $name, ?string $adminCode) | ||
* @method bool canAccessObject(string $action, object $object) | ||
* @method mixed getPersistentParameter(string $name) | ||
* @method array getExportFields | ||
* @method array getSubClasses | ||
* @method AdminInterface getRoot | ||
* @method string getRootCode | ||
* @method array getActionButtons(string $action, ?object $object) | ||
* @method array configureActionButtons(string $action, ?object $object = null) | ||
* @method string getSearchResultLink(object $object) | ||
* @method void showMosaicButton(bool $isShown) | ||
* @method bool isDefaultFilter(string $name) | ||
* @method bool isCurrentRoute(string $name, ?string $adminCode) | ||
* @method bool canAccessObject(string $action, object $object) | ||
* @method mixed getPersistentParameter(string $name) | ||
* @method array getExportFields() | ||
* @method array getSubClasses() | ||
* @method AdminInterface getRoot() | ||
* @method string getRootCode() | ||
* @method array getActionButtons(string $action, ?object $object) | ||
* @method FieldDescriptionCollection|null getList() | ||
*/ | ||
interface AdminInterface extends AccessRegistryInterface, FieldDescriptionRegistryInterface, LifecycleHookProviderInterface, MenuBuilderInterface, ParentAdminInterface, UrlGeneratorInterface | ||
{ | ||
|
@@ -270,6 +271,9 @@ public function getValidator(); | |
*/ | ||
public function getShow(); | ||
|
||
// NEXT_MAJOR: uncomment this method in 4.0 | ||
// public function getList(): ?FieldDescriptionCollection; | ||
|
||
public function setFormTheme(array $formTheme); | ||
|
||
/** | ||
|
@@ -360,6 +364,8 @@ public function setSubject($subject); | |
public function getSubject(); | ||
|
||
/** | ||
* NEXT_MAJOR: Remove this method, since it's already in FieldDescriptionRegistryInterface. | ||
* | ||
* Returns a list FieldDescription. | ||
* | ||
* @param string $name | ||
|
@@ -369,6 +375,8 @@ public function getSubject(); | |
public function getListFieldDescription($name); | ||
|
||
/** | ||
* NEXT_MAJOR: Remove this method, since it's already in FieldDescriptionRegistryInterface. | ||
* | ||
* Returns true if the list FieldDescription exists. | ||
* | ||
* @param string $name | ||
|
@@ -378,6 +386,8 @@ public function getListFieldDescription($name); | |
public function hasListFieldDescription($name); | ||
|
||
/** | ||
* NEXT_MAJOR: Remove this method, since it's already in FieldDescriptionRegistryInterface. | ||
* | ||
* Returns the collection of list FieldDescriptions. | ||
* | ||
* @return array | ||
|
@@ -542,13 +552,17 @@ public function setShowGroups(array $showGroups); | |
public function reorderShowGroup($group, array $keys); | ||
|
||
/** | ||
* NEXT_MAJOR: Remove this method, since it's already in FieldDescriptionRegistryInterface. | ||
* | ||
* add a FieldDescription. | ||
* | ||
* @param string $name | ||
*/ | ||
public function addFormFieldDescription($name, FieldDescriptionInterface $fieldDescription); | ||
|
||
/** | ||
* NEXT_MAJOR: Remove this method, since it's already in FieldDescriptionRegistryInterface. | ||
* | ||
* Remove a FieldDescription. | ||
* | ||
* @param string $name | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sonata\AdminBundle\Tests\Fixtures\Admin; | ||
|
||
use Sonata\AdminBundle\Admin\AbstractAdmin; | ||
use Sonata\AdminBundle\Datagrid\DatagridMapper; | ||
use Sonata\AdminBundle\Datagrid\ListMapper; | ||
use Sonata\AdminBundle\Form\FormMapper; | ||
use Sonata\AdminBundle\Show\ShowMapper; | ||
|
||
final class AvoidInfiniteLoopAdmin extends AbstractAdmin | ||
{ | ||
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void | ||
{ | ||
$this->getFilterFieldDescriptions(); | ||
$this->hasFilterFieldDescription('help'); | ||
} | ||
|
||
protected function configureListFields(ListMapper $listMapper): void | ||
{ | ||
$this->getListFieldDescriptions(); | ||
$this->hasFilterFieldDescription('help'); | ||
} | ||
|
||
protected function configureFormFields(FormMapper $formMapper): void | ||
{ | ||
$this->getFormFieldDescriptions(); | ||
$this->hasFilterFieldDescription('help'); | ||
} | ||
|
||
protected function configureShowFields(ShowMapper $showMapper): void | ||
{ | ||
$this->getShowFieldDescriptions(); | ||
$this->hasFilterFieldDescription('help'); | ||
} | ||
} |