コード例 #1
0
 /**
  * @param \Magento\Framework\View\DesignInterface $design
  * @param \Magento\Framework\View\Asset\GroupedCollection $assets
  * @param \Magento\Framework\View\Asset\Repository $assetRepo
  * @param \Psr\Log\LoggerInterface $logger
  */
 public function __construct(\Magento\Framework\View\DesignInterface $design, \Magento\Framework\View\Asset\GroupedCollection $assets, \Magento\Framework\View\Asset\Repository $assetRepo, \Psr\Log\LoggerInterface $logger)
 {
     $this->currentTheme = $design->getDesignTheme();
     $this->pageAssets = $assets;
     $this->assetRepo = $assetRepo;
     $this->logger = $logger;
 }
コード例 #2
0
ファイル: Media.php プロジェクト: CompassPointMedia/magento2
 /**
  * @param ConfigInterface $configInterface
  * @param DesignInterface $designInterface
  * @param Context $context
  */
 public function __construct(ConfigInterface $configInterface, DesignInterface $designInterface, Context $context)
 {
     parent::__construct($context);
     $this->viewConfig = $configInterface;
     $this->currentTheme = $designInterface->getDesignTheme();
     $this->initConfig();
 }
コード例 #3
0
 /**
  * Retrieve design theme instance
  *
  * @return Design\ThemeInterface
  */
 public function getDesignTheme()
 {
     $theme = $this->design->getDesignTheme();
     $theme->setCode('Magento/plushe');
     $theme->setThemePath('Magento/plushe');
     $theme->setId(8);
     return $this->getPhysicalTheme($theme);
 }
コード例 #4
0
 /**
  * Get theme model based on the information from asset
  *
  * @param LocalInterface $asset
  * @return \Magento\Framework\View\Design\ThemeInterface
  */
 protected function getTheme(LocalInterface $asset)
 {
     $context = $asset->getContext();
     if ($context instanceof FallbackContext) {
         return $this->themeList->getThemeByFullPath($context->getAreaCode() . '/' . $context->getThemePath());
     }
     return $this->design->getDesignTheme();
 }
コード例 #5
0
 /**
  * Retrieve instance of a theme currently used in an area
  *
  * @return \Magento\Framework\View\Design\ThemeInterface
  */
 public function get()
 {
     $area = $this->appState->getAreaCode();
     if ($this->design->getDesignTheme()->getArea() == $area || $this->design->getArea() == $area) {
         return $this->design->getDesignTheme();
     }
     /** @var \Magento\Theme\Model\ResourceModel\Theme\Collection $themeCollection */
     $themeCollection = $this->themeFactory->create();
     $themeIdentifier = $this->design->getConfigurationDesignTheme($area);
     if (is_numeric($themeIdentifier)) {
         $result = $themeCollection->getItemById($themeIdentifier);
     } else {
         $themeFullPath = $area . \Magento\Framework\View\Design\ThemeInterface::PATH_SEPARATOR . $themeIdentifier;
         $result = $themeCollection->getThemeByFullPath($themeFullPath);
     }
     return $result;
 }
コード例 #6
0
 /**
  * Collect files
  *
  * @param string|null $searchPattern
  * @return array
  * @throws \Exception
  */
 public function collectFiles($searchPattern = null)
 {
     $result = [];
     if ($searchPattern === null) {
         $searchPattern = $this->searchPattern;
     }
     if ($searchPattern === null) {
         throw new \Exception('Search pattern cannot be empty.');
     }
     $files = $this->collectorAggregated->getFiles($this->design->getDesignTheme(), $searchPattern);
     $fileReader = $this->filesystem->getDirectoryRead(DirectoryList::ROOT);
     foreach ($files as $file) {
         $filePath = $fileReader->getRelativePath($file->getFilename());
         $result[sprintf('%x', crc32($filePath))] = $fileReader->readFile($filePath);
     }
     return $result;
 }
コード例 #7
0
 /**
  * Get theme model based on the information from asset
  *
  * @param LocalInterface $asset
  * @return \Magento\Framework\View\Design\ThemeInterface
  */
 protected function getTheme(LocalInterface $asset)
 {
     $context = $asset->getContext();
     if ($context instanceof FallbackContext) {
         return $this->themeProvider->getThemeModel($context->getThemePath(), $context->getAreaCode());
     }
     return $this->design->getDesignTheme();
 }
コード例 #8
0
ファイル: Observer.php プロジェクト: aiesh/magento2
 /**
  * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
  * @param \Magento\Framework\View\DesignInterface $design
  * @param \Magento\Framework\View\Asset\GroupedCollection $assets
  * @param \Magento\Framework\App\Config\ReinitableConfigInterface $config
  * @param \Magento\Framework\View\Asset\Repository $assetRepo
  * @param Theme\Registration $registration
  * @param \Magento\Framework\Logger $logger
  */
 public function __construct(\Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\View\Asset\GroupedCollection $assets, \Magento\Framework\App\Config\ReinitableConfigInterface $config, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Core\Model\Theme\Registration $registration, \Magento\Framework\Logger $logger)
 {
     $this->_cacheFrontendPool = $cacheFrontendPool;
     $this->_currentTheme = $design->getDesignTheme();
     $this->_pageAssets = $assets;
     $this->_assetRepo = $assetRepo;
     $this->_registration = $registration;
     $this->_logger = $logger;
 }
コード例 #9
0
 /**
  * @param Reader $moduleReader
  * @param FileIteratorFactory $iteratorFactory
  * @param DesignInterface $designInterface
  * @param DirectoryList $directoryList
  * @param Filesystem $filesystem
  * @param ResolverInterface $resolver
  */
 public function __construct(Reader $moduleReader, FileIteratorFactory $iteratorFactory, DesignInterface $designInterface, DirectoryList $directoryList, Filesystem $filesystem, ResolverInterface $resolver)
 {
     $this->directoryList = $directoryList;
     $this->iteratorFactory = $iteratorFactory;
     $this->moduleReader = $moduleReader;
     $this->currentTheme = $designInterface->getDesignTheme();
     $this->area = $designInterface->getArea();
     $this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
     $this->resolver = $resolver;
 }
コード例 #10
0
 /**
  * Collect files
  *
  * @param string|null $searchPattern
  * @return array
  * @throws \Exception
  */
 public function collectFiles($searchPattern = null)
 {
     $result = [];
     if ($searchPattern === null) {
         $searchPattern = $this->searchPattern;
     }
     if ($searchPattern === null) {
         throw new \Exception('Search pattern cannot be empty.');
     }
     $files = $this->collectorAggregated->getFiles($this->design->getDesignTheme(), $searchPattern);
     foreach ($files as $file) {
         $fullFileName = $file->getFileName();
         $fileDir = dirname($fullFileName);
         $fileName = basename($fullFileName);
         $dirRead = $this->readFactory->create($fileDir);
         $result[$fullFileName] = $dirRead->readFile($fileName);
     }
     return $result;
 }
コード例 #11
0
ファイル: Config.php プロジェクト: vasiljok/magento2
 /**
  * Get aggregated distributed configuration
  *
  * @return string
  */
 public function getConfig()
 {
     $distributedConfig = '';
     $baseConfig = $this->getBaseConfig();
     $customConfigFiles = $this->fileSource->getFiles($this->design->getDesignTheme(), self::CONFIG_FILE_NAME);
     foreach ($customConfigFiles as $file) {
         $config = $this->baseDir->readFile($this->baseDir->getRelativePath($file->getFilename()));
         $distributedConfig .= str_replace(['%config%', '%context%'], [$config, $file->getModule()], self::PARTIAL_CONFIG_TEMPLATE);
     }
     $fullConfig = str_replace(['%function%', '%base%', '%usages%'], [$distributedConfig, $baseConfig], self::FULL_CONFIG_TEMPLATE);
     return $fullConfig;
 }
コード例 #12
0
ファイル: Observer.php プロジェクト: shabbirvividads/magento2
 /**
  * Initialize dependencies.
  *
  * @param \Magento\Framework\View\Design\Theme\ImageFactory $themeImageFactory
  * @param \Magento\Widget\Model\Resource\Layout\Update\Collection $updateCollection
  * @param \Magento\Theme\Model\Config\Customization $themeConfig
  * @param \Magento\Framework\Event\ManagerInterface $eventDispatcher
  * @param \Magento\Framework\View\DesignInterface $design
  * @param \Magento\Framework\View\Asset\GroupedCollection $assets
  * @param \Magento\Framework\View\Asset\Repository $assetRepo
  * @param Theme\Registration $registration
  * @param \Psr\Log\LoggerInterface $logger
  */
 public function __construct(\Magento\Framework\View\Design\Theme\ImageFactory $themeImageFactory, \Magento\Widget\Model\Resource\Layout\Update\Collection $updateCollection, \Magento\Theme\Model\Config\Customization $themeConfig, \Magento\Framework\Event\ManagerInterface $eventDispatcher, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\View\Asset\GroupedCollection $assets, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Theme\Model\Theme\Registration $registration, \Psr\Log\LoggerInterface $logger)
 {
     $this->themeImageFactory = $themeImageFactory;
     $this->updateCollection = $updateCollection;
     $this->themeConfig = $themeConfig;
     $this->eventDispatcher = $eventDispatcher;
     $this->currentTheme = $design->getDesignTheme();
     $this->pageAssets = $assets;
     $this->assetRepo = $assetRepo;
     $this->registration = $registration;
     $this->logger = $logger;
 }
コード例 #13
0
 /**
  * Get aggregated distributed configuration
  *
  * @return string
  */
 public function getConfig()
 {
     $functionSource = __DIR__ . '/paths-updater.js';
     $functionDeclaration = $this->baseDir->readFile($this->baseDir->getRelativePath($functionSource));
     $distributedConfig = '';
     $customConfigFiles = $this->fileSource->getFiles($this->design->getDesignTheme(), self::CONFIG_FILE_NAME);
     foreach ($customConfigFiles as $file) {
         $config = $this->baseDir->readFile($this->baseDir->getRelativePath($file->getFilename()));
         $distributedConfig .= str_replace(array('%config%', '%context%'), array($config, $file->getModule()), self::PARTIAL_CONFIG_TEMPLATE);
     }
     $fullConfig = str_replace(array('%function%', '%usages%'), array($functionDeclaration, $distributedConfig), self::FULL_CONFIG_TEMPLATE);
     return $fullConfig;
 }
コード例 #14
0
ファイル: Translate.php プロジェクト: Atlis/docker-magento2
 /**
  * Initialize configuration
  *
  * @param   array $config
  * @return  $this
  */
 protected function setConfig($config)
 {
     $this->_config = $config;
     if (!isset($this->_config['locale'])) {
         $this->_config['locale'] = $this->getLocale();
     }
     if (!isset($this->_config['scope'])) {
         $this->_config['scope'] = $this->getScope();
     }
     if (!isset($this->_config['theme'])) {
         $this->_config['theme'] = $this->_viewDesign->getDesignTheme()->getId();
     }
     return $this;
 }
コード例 #15
0
ファイル: Config.php プロジェクト: pradeep-wagento/magento2
 /**
  * Get aggregated distributed configuration
  *
  * @return string
  */
 public function getConfig()
 {
     $distributedConfig = '';
     $customConfigFiles = $this->fileSource->getFiles($this->design->getDesignTheme(), self::CONFIG_FILE_NAME);
     foreach ($customConfigFiles as $file) {
         /** @var $fileReader \Magento\Framework\Filesystem\File\Read */
         $fileReader = $this->readFactory->create($file->getFileName(), DriverPool::FILE);
         $config = $fileReader->readAll($file->getName());
         $distributedConfig .= str_replace(['%config%', '%context%'], [$config, $file->getModule()], self::PARTIAL_CONFIG_TEMPLATE);
     }
     $fullConfig = str_replace(['%function%', '%usages%'], [$distributedConfig], self::FULL_CONFIG_TEMPLATE);
     if ($this->minification->isEnabled('js')) {
         $fullConfig = $this->minifyAdapter->minify($fullConfig);
     }
     return $fullConfig;
 }
コード例 #16
0
ファイル: FileResolver.php プロジェクト: razbakov/magento2
 /**
  * @param Reader $moduleReader
  * @param FileIteratorFactory $iteratorFactory
  * @param DesignInterface $designInterface
  * @param DirectoryList $directoryList
  * @param Filesystem $filesystem
  * @param ComponentRegistrar $componentRegistrar
  */
 public function __construct(
     Reader $moduleReader,
     FileIteratorFactory $iteratorFactory,
     DesignInterface $designInterface,
     DirectoryList $directoryList,
     Filesystem $filesystem,
     ComponentRegistrar $componentRegistrar
 ) {
     $this->directoryList = $directoryList;
     $this->iteratorFactory = $iteratorFactory;
     $this->moduleReader = $moduleReader;
     $this->currentTheme = $designInterface->getDesignTheme();
     $this->themePath = $designInterface->getThemePath($this->currentTheme);
     $this->area = $designInterface->getArea();
     $this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
     $this->componentRegistrar = $componentRegistrar;
 }
コード例 #17
0
ファイル: Merge.php プロジェクト: shabbirvividads/magento2
 /**
  * Init merge model
  *
  * @param \Magento\Framework\View\DesignInterface $design
  * @param \Magento\Framework\Url\ScopeResolverInterface $scopeResolver
  * @param \Magento\Framework\View\File\CollectorInterface $fileSource
  * @param \Magento\Framework\View\File\CollectorInterface $pageLayoutFileSource
  * @param \Magento\Framework\App\State $appState
  * @param \Magento\Framework\Cache\FrontendInterface $cache
  * @param \Magento\Framework\View\Model\Layout\Update\Validator $validator
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Framework\Filesystem $filesystem
  * @param \Magento\Framework\View\Design\ThemeInterface $theme Non-injectable theme instance
  * @param string $cacheSuffix
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\View\DesignInterface $design, \Magento\Framework\Url\ScopeResolverInterface $scopeResolver, \Magento\Framework\View\File\CollectorInterface $fileSource, \Magento\Framework\View\File\CollectorInterface $pageLayoutFileSource, \Magento\Framework\App\State $appState, \Magento\Framework\Cache\FrontendInterface $cache, \Magento\Framework\View\Model\Layout\Update\Validator $validator, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\View\Design\ThemeInterface $theme = null, $cacheSuffix = '')
 {
     $this->theme = $theme ?: $design->getDesignTheme();
     $this->scope = $scopeResolver->getScope();
     $this->fileSource = $fileSource;
     $this->pageLayoutFileSource = $pageLayoutFileSource;
     $this->appState = $appState;
     $this->cache = $cache;
     $this->layoutValidator = $validator;
     $this->logger = $logger;
     $this->filesystem = $filesystem;
     $this->cacheSuffix = $cacheSuffix;
 }
コード例 #18
0
ファイル: AbstractTemplate.php プロジェクト: nja78/magento2
 /**
  * Returns the design params for the template being processed
  *
  * @return array
  */
 public function getDesignParams()
 {
     return ['area' => $this->getDesignConfig()->getArea(), 'theme' => $this->design->getDesignTheme()->getCode(), 'themeModel' => $this->design->getDesignTheme(), 'locale' => $this->design->getLocale()];
 }
コード例 #19
0
ファイル: Merge.php プロジェクト: aiesh/magento2
 /**
  * Init merge model
  *
  * @param \Magento\Framework\View\DesignInterface $design
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Framework\View\File\CollectorInterface $fileSource
  * @param \Magento\Core\Model\Resource\Layout\Update $resource
  * @param \Magento\Framework\App\State $appState
  * @param \Magento\Framework\Cache\FrontendInterface $cache
  * @param \Magento\Core\Model\Layout\Update\Validator $validator
  * @param \Magento\Framework\Logger $logger
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\View\Page\Config $pageConfig
  * @param \Magento\Framework\View\Design\ThemeInterface $theme Non-injectable theme instance
  */
 public function __construct(\Magento\Framework\View\DesignInterface $design, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\View\File\CollectorInterface $fileSource, \Magento\Core\Model\Resource\Layout\Update $resource, \Magento\Framework\App\State $appState, \Magento\Framework\Cache\FrontendInterface $cache, \Magento\Core\Model\Layout\Update\Validator $validator, \Magento\Framework\Logger $logger, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\View\Page\Config $pageConfig, \Magento\Framework\View\Design\ThemeInterface $theme = null)
 {
     $this->_theme = $theme ?: $design->getDesignTheme();
     $this->_store = $storeManager->getStore();
     $this->_fileSource = $fileSource;
     $this->_resource = $resource;
     $this->_appState = $appState;
     $this->_cache = $cache;
     $this->_layoutValidator = $validator;
     $this->_logger = $logger;
     $this->filesystem = $filesystem;
     $this->pageConfig = $pageConfig;
 }
コード例 #20
0
 public function testGetDesignTheme()
 {
     $this->assertInstanceOf('Magento\\Framework\\View\\Design\\ThemeInterface', $this->_model->getDesignTheme());
 }