Example #1
0
 /**
  * Retrieve full path to a directory of certain type within a module
  *
  * @param string $moduleName Fully-qualified module name
  * @param string $type Type of module's directory to retrieve
  * @return string
  * @throws \InvalidArgumentException
  */
 public function getDir($moduleName, $type = '')
 {
     if (null === ($path = $this->moduleRegistry->getModulePath($moduleName))) {
         $relativePath = $this->_string->upperCaseWords($moduleName, '_', '/');
         $path = $this->_modulesDirectory->getAbsolutePath($relativePath);
     }
     if ($type) {
         if (!in_array($type, [self::MODULE_ETC_DIR, self::MODULE_I18N_DIR, self::MODULE_VIEW_DIR, self::MODULE_CONTROLLER_DIR])) {
             throw new \InvalidArgumentException("Directory type '{$type}' is not recognized.");
         }
         $path .= '/' . $type;
     }
     return $path;
 }
Example #2
0
 /**
  * Returns module config data and a path to the module.xml file.
  *
  * Example of data returned by generator:
  * <code>
  *     [ 'vendor/module/etc/module.xml', '<xml>contents</xml>' ]
  * </code>
  *
  * @return \Traversable
  *
  * @author Josh Di Fabio <*****@*****.**>
  */
 private function getModuleConfigs()
 {
     $modulesDir = $this->filesystem->getDirectoryRead(DirectoryList::MODULES);
     foreach ($modulesDir->search('*/*/etc/module.xml') as $filePath) {
         (yield [$filePath, $modulesDir->readFile($filePath)]);
     }
     foreach ($this->moduleRegistry->getModulePaths() as $modulePath) {
         $filePath = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, "{$modulePath}/etc/module.xml");
         (yield [$filePath, $this->filesystemDriver->fileGetContents($filePath)]);
     }
 }
Example #3
0
 public function testGetDirModuleRootFromResolver()
 {
     $this->moduleRegistryMock->expects($this->once())->method('getModulePath')->with('Test_Module2')->will($this->returnValue('/path/to/module'));
     $this->assertEquals('/path/to/module', $this->_model->getDir('Test_Module2'));
 }
Example #4
0
 public function getPathByKey($key)
 {
     $themePaths = $this->moduleRegistry->getThemesPaths();
     return isset($themePaths[$key]) ? $themePaths[$key] : null;
 }