-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SonataExtraBundle] BatchIterator for batch action
- Loading branch information
Showing
12 changed files
with
342 additions
and
123 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
66 changes: 0 additions & 66 deletions
66
packages/sonata-extra-bundle/ActionableAdmin/Action/BatchAction.php
This file was deleted.
Oops, something went wrong.
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
56 changes: 56 additions & 0 deletions
56
packages/sonata-extra-bundle/ActionableAdmin/ArgumentResolver/BatchIteratorValueResolver.php
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,56 @@ | ||
<?php | ||
|
||
namespace Draw\Bundle\SonataExtraBundle\ActionableAdmin\ArgumentResolver; | ||
|
||
use Draw\Bundle\SonataExtraBundle\ActionableAdmin\BatchIterator; | ||
use Sonata\AdminBundle\Request\AdminFetcherInterface; | ||
use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; | ||
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; | ||
|
||
class BatchIteratorValueResolver implements ValueResolverInterface | ||
{ | ||
public function __construct( | ||
private AdminFetcherInterface $adminFetcher, | ||
private BatchIterator $batchIterator | ||
) { | ||
} | ||
|
||
public function resolve(Request $request, ArgumentMetadata $argument): iterable | ||
{ | ||
$type = $argument->getType(); | ||
|
||
if (null === $type) { | ||
return []; | ||
} | ||
|
||
if (BatchIterator::class !== $type && !is_subclass_of($type, BatchIterator::class)) { | ||
return []; | ||
} | ||
|
||
try { | ||
$admin = $this->adminFetcher->get($request); | ||
} catch (\InvalidArgumentException) { | ||
return []; | ||
} | ||
|
||
$action = $request->request->get('action'); | ||
|
||
if (null === $action) { | ||
return []; | ||
} | ||
|
||
foreach ($request->attributes as $attribute) { | ||
if ($attribute instanceof ProxyQuery) { | ||
return [$this->batchIterator->initialize( | ||
query: $attribute, | ||
admin: $admin, | ||
action: $action, | ||
)]; | ||
} | ||
} | ||
|
||
return []; | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
packages/sonata-extra-bundle/ActionableAdmin/BatchActionInterface.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.