Skip to content

add modules outside of app/code directory to DiCompile #1659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions setup/src/Magento/Setup/Console/Command/DiCompileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -37,6 +38,9 @@ class DiCompileCommand extends Command

/** @var DirectoryList */
private $directoryList;

/** @var ModuleRegistryInterface */
private $moduleRegistry;

/** @var Filesystem */
private $filesystem;
Expand All @@ -51,19 +55,22 @@ class DiCompileCommand extends Command
* @param DirectoryList $directoryList
* @param Manager $taskManager
* @param ObjectManagerProvider $objectManagerProvider
* @param ModuleRegistryInterface $moduleRegistry
* @param Filesystem $filesystem
*/
public function __construct(
DeploymentConfig $deploymentConfig,
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();
}
Expand Down Expand Up @@ -111,6 +118,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$compiledPathsList,
$dataAttributesIncludePattern
);

$operations = $this->addModulePathsToOperations($operations);

try {
$this->cleanupFilesystem(
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -56,13 +59,18 @@ 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(
$this->deploymentConfig,
$directoryList,
$this->manager,
$objectManagerProvider,
$this->moduleRegistry,
$this->filesystem
);
}
Expand Down