Esempio n. 1
0
 /**
  * Load widget XML config and merge with theme widget config
  *
  * @return array|null
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getWidgetConfigAsArray()
 {
     if ($this->_widgetConfigXml === null) {
         $this->_widgetConfigXml = $this->_widgetModel->getWidgetByClassType($this->getType());
         if ($this->_widgetConfigXml) {
             $configFile = $this->_viewFileSystem->getFilename('widget.xml', ['area' => $this->getArea(), 'theme' => $this->getThemeId(), 'module' => $this->_namespaceResolver->determineOmittedNamespace(preg_replace('/^(.+?)\\/.+$/', '\\1', $this->getType()), true)]);
             $isReadable = $configFile && $this->_directory->isReadable($this->_directory->getRelativePath($configFile));
             if ($isReadable) {
                 $config = $this->_reader->readFile($configFile);
                 $widgetName = isset($this->_widgetConfigXml['name']) ? $this->_widgetConfigXml['name'] : null;
                 $themeWidgetConfig = null;
                 if ($widgetName !== null) {
                     foreach ($config as $widget) {
                         if (isset($widget['name']) && $widgetName === $widget['name']) {
                             $themeWidgetConfig = $widget;
                             break;
                         }
                     }
                 }
                 if ($themeWidgetConfig) {
                     $this->_widgetConfigXml = array_replace_recursive($this->_widgetConfigXml, $themeWidgetConfig);
                 }
             }
         }
     }
     return $this->_widgetConfigXml;
 }
 /**
  * @param string $namespace
  * @param array $modules
  * @param string $expected
  * @param bool $asFullModuleName
  *
  * @dataProvider determineOmittedNamespaceDataProvider
  */
 public function testDetermineOmittedNamespace($namespace, $modules, $expected, $asFullModuleName)
 {
     $this->moduleListMock->expects($this->once())->method('getNames')->willReturn($modules);
     $this->assertSame($expected, $this->namespaceResolver->determineOmittedNamespace($namespace, $asFullModuleName));
 }