diff --git a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php index 5caaee480d5d2c4053c393f0d659905c37ec7435..ef12f5923113029098a59de061d595b81c2943ae 100644 --- a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php +++ b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php @@ -8,7 +8,9 @@ namespace Magento\Setup\Console\Command; use Magento\Framework\App\ResourceConnection; use Magento\Framework\Mview\View\CollectionInterface; +use Magento\Setup\Fixtures\ConfigsApplyFixture; use Magento\Setup\Fixtures\FixtureModel; +use Magento\Setup\Fixtures\IndexersStatesApplyFixture; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -84,7 +86,7 @@ class GenerateFixturesCommand extends Command } /** @var \Magento\Setup\Fixtures\ConfigsApplyFixture $configFixture */ - $configFixture = $fixtureModel->getConfigurationFixture(); + $configFixture = $fixtureModel->getFixtureByName(ConfigsApplyFixture::class); $configFixture && $this->executeFixture($configFixture, $output); /** @var $config \Magento\Indexer\Model\Config */ @@ -106,7 +108,7 @@ class GenerateFixturesCommand extends Command $this->clearChangelog(); /** @var \Magento\Setup\Fixtures\IndexersStatesApplyFixture $indexerFixture */ - $indexerFixture = $this->fixtureModel->getIndexerFixture(); + $indexerFixture = $fixtureModel->getFixtureByName(IndexersStatesApplyFixture::class); $indexerFixture && $this->executeFixture($indexerFixture, $output); if (!$input->getOption(self::SKIP_REINDEX_OPTION)) { diff --git a/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php b/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php index 144ac5d7625faab8477f0da74542864ba09a61a7..6c6fdbd9fa6f8aaaf1e909f565fe7742bc816630 100644 --- a/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php +++ b/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php @@ -14,7 +14,7 @@ class ConfigsApplyFixture extends Fixture /** * @var int */ - protected $priority = 0; + protected $priority = -1; /** * {@inheritdoc} diff --git a/setup/src/Magento/Setup/Fixtures/FixtureModel.php b/setup/src/Magento/Setup/Fixtures/FixtureModel.php index c26f6fd3779425acd01777e4df074b3ab4091012..96c4025ac1871cb54dd7ad28d3c9c593eef6afc0 100644 --- a/setup/src/Magento/Setup/Fixtures/FixtureModel.php +++ b/setup/src/Magento/Setup/Fixtures/FixtureModel.php @@ -10,6 +10,7 @@ namespace Magento\Setup\Fixtures; use Magento\Indexer\Console\Command\IndexerReindexCommand; +use Magento\Setup\Exception; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; @@ -47,6 +48,13 @@ class FixtureModel */ protected $fixtures = []; + /** + * List of fixtures indexed by class names + * + * @var \Magento\Setup\Fixtures\Fixture[] + */ + private $fixturesByNames = []; + /** * Parameters labels * @@ -65,14 +73,6 @@ class FixtureModel */ private $config; - private $configurationFixtureInstanceClassName = \Magento\Setup\Fixtures\ConfigsApplyFixture::class; - - private $configurationFixture; - - private $indexerFixtureInstanceClassName = \Magento\Setup\Fixtures\IndexersStatesApplyFixture::class; - - private $indexerFixture; - /** * Constructor * @@ -118,22 +118,17 @@ class FixtureModel ] ); - if ($fixture instanceof $this->configurationFixtureInstanceClassName) { - $this->configurationFixture = $fixture; - continue; - } - - if ($fixture instanceof $this->indexerFixtureInstanceClassName) { - $this->indexerFixture = $fixture; - continue; - } - if (isset($this->fixtures[$fixture->getPriority()])) { throw new \InvalidArgumentException( sprintf('Duplicate priority %d in fixture %s', $fixture->getPriority(), $type) ); } - $this->fixtures[$fixture->getPriority()] = $fixture; + + if ($fixture->getPriority() >= 0) { + $this->fixtures[$fixture->getPriority()] = $fixture; + } + + $this->fixturesByNames[get_class($fixture)] = $fixture; } ksort($this->fixtures); @@ -162,23 +157,21 @@ class FixtureModel } /** - * Returns configuration fixture - * @return \Magento\Setup\Fixtures\ConfigsApplyFixture + * Returns fixture by name + * @param $name string + * @return \Magento\Setup\Fixtures\Fixture + * @throws \Magento\Setup\Exception */ - public function getConfigurationFixture() + public function getFixtureByName($name) { - return $this->configurationFixture; - } + if (!array_key_exists($name, $this->fixturesByNames)) { + throw new Exception('Wrong fixture name'); + } - /** - * Returns indexer fixture - * @return \Magento\Setup\Fixtures\IndexersStatesApplyFixture - */ - public function getIndexerFixture() - { - return $this->indexerFixture; + return $this->fixturesByNames[$name]; } + /** * Get object manager * diff --git a/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php b/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php index 949bd8a24f51e69b845c6cccb090eb6192a38d1a..b07ce33089814db2de4994c01ef9dd3805c37a9e 100644 --- a/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php +++ b/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php @@ -14,7 +14,7 @@ class IndexersStatesApplyFixture extends Fixture /** * @var int */ - protected $priority = 170; + protected $priority = -1; /** * {@inheritdoc}