- it allows easilly to iterate through selected records by users
- service:
Imatic\Bundle\DataBundle\Data\Driver\DoctrineDBAL\Command\RecordIterator - methods
each- iterates through records
eachIdentifier- iterates through identifiers of records
- each method takes RecordIteratorArgs as argument
- argument to the methods of RecordIterator
- has 3 arguments
$command- command of the handler
$queryObject- query object user selected records from
$callback- callable with 1 argument based on called method
eachpasses recordeachIdentifierpasses identifier of the record
- callable with 1 argument based on called method
- has 1 method
setLimit- overwrites default limit per page
<?php
use Imatic\Bundle\DataBundle\Data\Command\CommandInterface;
use Imatic\Bundle\DataBundle\Data\Command\CommandResult;
use Imatic\Bundle\DataBundle\Data\Command\HandlerInterface;
use Imatic\Bundle\DataBundle\Data\Driver\DoctrineDBAL\Command\Recorditerator;
use Imatic\Bundle\DataBundle\Data\Driver\DoctrineDBAL\Command\RecordIteratorArgs;
DeactivateUsersHandler implements HandlerInterface
{
private $recordIterator;
public function __construct(RecordIterator $recordIterator)
{
$this->recordIterator = $recordIterator;
}
public function handle(CommandInterface $command)
{
$recordIteratorArgs = new RecordIteratorArgs(
$command,
new UserListQuery(),
function (array $user) {
deactivate($user);
return CommandResult::success();
}
);
$this->recordIterator->execute($recordIteratorArgs);
}
}