for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Maketok\DataMigration\Action\Type;
use Maketok\DataMigration\Action\ActionInterface;
use Maketok\DataMigration\Action\Exception\WrongContextException;
use Maketok\DataMigration\Unit\ImportDbUnitInterface;
use Maketok\DataMigration\Unit\ImportFileUnitInterface;
use Maketok\DataMigration\Unit\UnitBagInterface;
use Maketok\DataMigration\Workflow\ResultInterface;
/**
* Move data data from tmp table to main table
*/
class Move extends AbstractDbAction implements ActionInterface
{
* @var UnitBagInterface|ImportDbUnitInterface[]|ImportFileUnitInterface[]
protected $bag;
* {@inheritdoc}
* @throws WrongContextException
public function process(ResultInterface $result)
$result->setActionStartTime($this->getCode(), new \DateTime());
foreach ($this->bag as $unit) {
if ($unit->getTmpTable() === null) {
throw new WrongContextException(sprintf(
"Action can not be used for current unit %s. Tmp table is missing.",
$unit->getCode()
));
}
$moved = $this->resource->move($unit->getTmpTable(), $unit->getTable(), array_keys($unit->getMapping()));
$result->incrementActionProcessed($this->getCode(), $moved);
$result->setActionEndTime($this->getCode(), new \DateTime());
public function getCode()
return 'move';