mirror of
https://github.com/JBDevLabs/ezmigrationbundle.git
synced 2026-03-24 08:52:16 +01:00
38 lines
912 B
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);
|
|
}
|
|
|
|
}
|