diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 707c8ee9dae32..40156f4c1f801 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -8,6 +8,7 @@ use Magento\Framework\Filesystem; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Module\ModuleRegistryInterface; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\App\DeploymentConfig; use Magento\Setup\Model\ObjectManagerProvider; @@ -37,6 +38,9 @@ class DiCompileCommand extends Command /** @var DirectoryList */ private $directoryList; + + /** @var ModuleRegistryInterface */ + private $moduleRegistry; /** @var Filesystem */ private $filesystem; @@ -51,6 +55,7 @@ class DiCompileCommand extends Command * @param DirectoryList $directoryList * @param Manager $taskManager * @param ObjectManagerProvider $objectManagerProvider + * @param ModuleRegistryInterface $moduleRegistry * @param Filesystem $filesystem */ public function __construct( @@ -58,12 +63,14 @@ public function __construct( DirectoryList $directoryList, Manager $taskManager, ObjectManagerProvider $objectManagerProvider, + ModuleRegistryInterface $moduleRegistry, Filesystem $filesystem ) { $this->deploymentConfig = $deploymentConfig; $this->directoryList = $directoryList; $this->objectManager = $objectManagerProvider->get(); $this->taskManager = $taskManager; + $this->moduleRegistry = $moduleRegistry; $this->filesystem = $filesystem; parent::__construct(); } @@ -111,6 +118,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $compiledPathsList, $dataAttributesIncludePattern ); + + $operations = $this->addModulePathsToOperations($operations); try { $this->cleanupFilesystem( @@ -271,4 +280,33 @@ private function getOperationsConfiguration( return $operations; } + + /** + * adds Paths from module Registry to Operations Array + * + * @param array $operations + * + * @return array + */ + private function addModulePathsToOperations(array $operations) + { + $operationCodes = [ + OperationFactory::APPLICATION_CODE_GENERATOR, + OperationFactory::AREA_CONFIG_GENERATOR, + OperationFactory::INTERCEPTION_CACHE, + ]; + + $modulePaths = $this->moduleRegistry->getModulePaths(); + + foreach ($operationCodes as $operationCode) { + $operations[$operationCode] = array_merge($operations[$operationCode], $modulePaths); + } + + $operations[OperationFactory::INTERCEPTION]['intercepted_paths'] = array_merge( + $operations[OperationFactory::INTERCEPTION]['intercepted_paths'], + $modulePaths + ); + + return $operations; + } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php index 2b9381b4783a4..11e0566de5255 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php @@ -28,6 +28,9 @@ class DiCompileCommandTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject */ private $filesystem; + /** @var \Magento\Framework\Module\ModuleRegistryInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $moduleRegistry; + public function setUp() { $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); @@ -56,6 +59,10 @@ public function setUp() $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') ->disableOriginalConstructor() ->getMock(); + + $this->moduleRegistry = $this->getMock('Magento\Framework\Module\Registrar', [], [], '', false); + $this->moduleRegistry->method('getModulePaths') + ->willReturn([]); $directoryList->expects($this->exactly(3))->method('getPath'); $this->command = new DiCompileCommand( @@ -63,6 +70,7 @@ public function setUp() $directoryList, $this->manager, $objectManagerProvider, + $this->moduleRegistry, $this->filesystem ); }