Beispiel #1
0
 public function testGetFilename()
 {
     $params = array('area' => 'some_area', 'themeModel' => $this->getMock('Magento\\Framework\\View\\Design\\ThemeInterface', array(), array(), '', false, false), 'module' => 'Some_Module');
     $file = 'Some_Module::some_file.ext';
     $expected = 'path/to/some_file.ext';
     $this->_fileResolution->expects($this->once())->method('getFile')->with($params['area'], $params['themeModel'], 'some_file.ext', 'Some_Module')->will($this->returnValue($expected));
     $this->_assetRepo->expects($this->any())->method('extractScope')->with($file, $params)->will($this->returnValue('some_file.ext'));
     $actual = $this->_model->getFilename($file, $params);
     $this->assertEquals($expected, $actual);
 }
Beispiel #2
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;
 }
Beispiel #3
0
    /**
     * Render view config object for current package and theme
     *
     * @param array $params
     * @return \Magento\Framework\Config\View
     */
    public function getViewConfig(array $params = [])
    {
        $this->assetRepo->updateDesignParams($params);
        /** @var $currentTheme \Magento\Framework\View\Design\ThemeInterface */
        $currentTheme = $params['themeModel'];
        $key = $currentTheme->getCode();
        if (isset($this->viewConfigs[$key])) {
            return $this->viewConfigs[$key];
        }

        $configFiles = $this->moduleReader->getConfigurationFiles(basename($this->filename))->toArray();
        $themeConfigFile = $currentTheme->getCustomization()->getCustomViewConfigPath();
        if (empty($themeConfigFile)
            || !$this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
        ) {
            $themeConfigFile = $this->viewFileSystem->getFilename($this->filename, $params);
        }
        if ($themeConfigFile
            && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
        ) {
            $configFiles[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile(
                $this->rootDirectory->getRelativePath($themeConfigFile)
            );
        }
        $config = $this->viewFactory->create($configFiles);

        $this->viewConfigs[$key] = $config;
        return $config;
    }
 /**
  * @dataProvider getFilenameDataProvider
  * @magentoAppIsolation enabled
  */
 public function testGetFilename($file, $params)
 {
     $this->_emulateFixtureTheme();
     $this->assertFileExists($this->_viewFileSystem->getFilename($file, $params));
 }