Files
ezmigrationbundle/Core/Executor/IgnorableStepExecutorTrait.php

38 lines
912 B
PHP

<?php
namespace Kaliop\eZMigrationBundle\Core\Executor;
use Kaliop\eZMigrationBundle\API\Value\MigrationStep;
use Kaliop\eZMigrationBundle\API\Exception\MigrationStepSkippedException;
trait IgnorableStepExecutorTrait
{
protected $referenceMatcher;
public function setReferenceMatcher($referenceMatcher)
{
$this->referenceMatcher = $referenceMatcher;
}
/**
* @param MigrationStep $step
* @return void
* @throws MigrationStepSkippedException
*/
protected function skipStepIfNeeded(MigrationStep $step)
{
if (isset($step->dsl['if'])) {
if (!$this->matchConditions($step->dsl['if'])) {
throw new MigrationStepSkippedException();
}
}
}
protected function matchConditions($conditions)
{
$match = $this->referenceMatcher->match($conditions);
return reset($match);
}
}