Skip to content

Commit

Permalink
Process NEXT_MAJOR hints for "Add pre batch action event"
Browse files Browse the repository at this point in the history
A pre batch action event was added to 4.x through sonata-project#7579. This
processes all the NEXT_MAJOR comments for 5.x for this specific
feature
  • Loading branch information
7ochem committed Nov 26, 2021
1 parent e6d85ea commit f1390f8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
4 changes: 4 additions & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ Please read [4.x](https://github.com/sonata-project/SonataAdminBundle/tree/4.x)

See also the [diff code](https://github.com/sonata-project/SonataAdminBundle/compare/4.x...5.x).

## AdminExtension
If you have implemented a custom admin extension, which does not extend the `AbstractAdminExtension` then you should add the following methods which were newly introduced in the `AdminExtensionInterface`:
* `preBatchAction`

5 changes: 0 additions & 5 deletions src/Admin/AbstractAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ public function configureBatchActions(AdminInterface $admin, array $actions): ar
return $actions;
}

// NEXT_MAJOR: Remove the PHPDoc block as the interface will then specify the types
/**
* @param mixed[] $idx
* @phpstan-param AdminInterface<T> $admin
*/
public function preBatchAction(AdminInterface $admin, string $actionName, ProxyQueryInterface $query, array &$idx, bool $allElements): void
{
}
Expand Down
15 changes: 5 additions & 10 deletions src/Admin/AdminExtensionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
/**
* @author Thomas Rabaix <[email protected]>
*
* NEXT_MAJOR: Uncomment the actual definition of below methods inside the interface and remove these annotations.
*
* @method void preBatchAction(AdminInterface $admin, string $actionName, ProxyQueryInterface $query, array &$idx, bool $allElements)
*
* @phpstan-template T of object
*/
interface AdminExtensionInterface
Expand Down Expand Up @@ -131,12 +127,11 @@ public function getAccessMapping(AdminInterface $admin): array;
*/
public function configureBatchActions(AdminInterface $admin, array $actions): array;

// NEXT_MAJOR: Uncomment the method definition
///**
// * @param mixed[] $idx
// * @phpstan-param AdminInterface<T> $admin
// */
//public function preBatchAction(AdminInterface $admin, string $actionName, ProxyQueryInterface $query, array &$idx, bool $allElements): void;
/**
* @param mixed[] $idx
* @phpstan-param AdminInterface<T> $admin
*/
public function preBatchAction(AdminInterface $admin, string $actionName, ProxyQueryInterface $query, array &$idx, bool $allElements): void;

/**
* Get a chance to modify export fields.
Expand Down
6 changes: 1 addition & 5 deletions src/Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,7 @@ public function batchAction(Request $request): Response

$this->admin->preBatchAction($action, $query, $idx, $allElements);
foreach ($this->admin->getExtensions() as $extension) {
// NEXT_MAJOR: Remove the if-statement around the call to `$extension->preBatchAction()`
// @phpstan-ignore-next-line
if (method_exists($extension, 'preBatchAction')) {
$extension->preBatchAction($this->admin, $action, $query, $idx, $allElements);
}
$extension->preBatchAction($this->admin, $action, $query, $idx, $allElements);
}

if (\count($idx) > 0) {
Expand Down

0 comments on commit f1390f8

Please sign in to comment.