Beispiel #1
0
 /**
  * Make sure the aggregated configuration is materialized
  *
  * By default write the file if it doesn't exist, but in developer mode always do it.
  *
  * @param string $relPath
  * @return void
  */
 private function ensureSourceFile($relPath)
 {
     $dir = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR);
     if ($this->appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER || !$dir->isExist($relPath)) {
         $dir->writeFile($relPath, $this->config->getConfig());
     }
 }
Beispiel #2
0
 /**
  * Publish the asset
  *
  * @param Asset\LocalInterface $asset
  * @return bool
  */
 private function publishAsset(Asset\LocalInterface $asset)
 {
     $dir = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR);
     $rootDir = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $source = $rootDir->getRelativePath($asset->getSourceFile());
     $destination = $asset->getPath();
     return $rootDir->copyFile($source, $destination, $dir);
 }
Beispiel #3
0
 /**
  * Set base dir
  *
  * @param \Magento\Core\Model\EntityFactory $entityFactory
  * @param \Magento\Framework\App\Filesystem $filesystem
  */
 public function __construct(\Magento\Core\Model\EntityFactory $entityFactory, \Magento\Framework\App\Filesystem $filesystem)
 {
     parent::__construct($entityFactory);
     $this->filesystem = $filesystem;
     $this->connectDirectory = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
     $this->connectDirectory->create('connect');
     $this->addTargetDir($this->connectDirectory->getAbsolutePath('connect'));
 }
Beispiel #4
0
 /**
  * Constructor
  *
  * @param \Magento\Framework\Convert\ConvertArray $convertArray
  * @param \Magento\Framework\App\Filesystem           $filesystem
  * @param Session                       $session
  * @param \Magento\Framework\Logger               $logger
  * @param array                         $data
  */
 public function __construct(\Magento\Framework\Convert\ConvertArray $convertArray, \Magento\Framework\App\Filesystem $filesystem, \Magento\Connect\Model\Session $session, \Magento\Framework\Logger $logger, array $data = array())
 {
     $this->_convertArray = $convertArray;
     $this->_session = $session;
     $this->filesystem = $filesystem;
     $this->writeDirectory = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
     $this->logger = $logger;
     parent::__construct($data);
 }
Beispiel #5
0
 /**
  * Turn off store maintenance mode
  *
  * @return bool
  */
 public function turnOff()
 {
     try {
         $this->filesystem->getDirectoryWrite(self::FLAG_DIR)->delete(self::FLAG_FILENAME);
     } catch (\Exception $e) {
         return false;
     }
     return true;
 }
Beispiel #6
0
 /**
  * @param \Magento\Core\Helper\Data $helper
  * @param \Magento\Framework\App\State $appState
  * @param \Magento\Framework\Logger $logger
  * @param \Magento\Framework\App\Filesystem $filesystem
  */
 public function __construct(\Magento\Core\Helper\Data $helper, \Magento\Framework\App\State $appState, \Magento\Framework\Logger $logger, \Magento\Framework\App\Filesystem $filesystem)
 {
     $this->_coreHelper = $helper;
     $this->_appState = $appState;
     $this->_logger = $logger;
     $this->_filesystem = $filesystem;
     $this->directoryWrite = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
     $this->registerShutdownFunction();
 }
Beispiel #7
0
 /**
  * @param Database $coreFileStorageDb
  * @param Storage $coreFileStorage
  * @param NotProtectedExtension $validator
  * @param Filesystem $filesystem
  * @param LinkConfig $linkConfig
  * @param SampleConfig $sampleConfig
  */
 public function __construct(Database $coreFileStorageDb, Storage $coreFileStorage, NotProtectedExtension $validator, Filesystem $filesystem, LinkConfig $linkConfig, SampleConfig $sampleConfig)
 {
     $this->_validator = $validator;
     $this->_coreFileStorage = $coreFileStorage;
     $this->_coreFileStorageDb = $coreFileStorageDb;
     $this->mediaDirectory = $filesystem->getDirectoryWrite(Filesystem::MEDIA_DIR);
     $this->systemTmpDirectory = $filesystem->getDirectoryWrite(Filesystem::SYS_TMP_DIR);
     $this->linkConfig = $linkConfig;
     $this->sampleConfig = $sampleConfig;
 }
Beispiel #8
0
 /**
  * Prepare file for uploading
  *
  * @return string
  */
 protected function _prepareFileForUploading()
 {
     /**
      * Copy file to writable directory.
      * Uploader can copy(upload) and then remove this temporary file.
      */
     $fileName = __DIR__ . '/_files/simple-js-file.js';
     $varDir = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
     $rootDir = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $destinationFilePath = 'simple-js-file.js';
     $rootDir->copyFile($rootDir->getRelativePath($fileName), $destinationFilePath, $varDir);
     return $varDir->getAbsolutePath($destinationFilePath);
 }
Beispiel #9
0
 /**
  * Initialize dependencies
  *
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Theme\Helper\Storage $helper
  * @param \Magento\Framework\ObjectManager $objectManager
  * @param \Magento\Framework\Image\AdapterFactory $imageFactory
  */
 public function __construct(\Magento\Framework\App\Filesystem $filesystem, \Magento\Theme\Helper\Storage $helper, \Magento\Framework\ObjectManager $objectManager, \Magento\Framework\Image\AdapterFactory $imageFactory)
 {
     $this->mediaWriteDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     $this->_helper = $helper;
     $this->_objectManager = $objectManager;
     $this->_imageFactory = $imageFactory;
 }
Beispiel #10
0
 /**
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\View\Asset\Repository $assetRepo
  * @param \Magento\Framework\Less\PreProcessor\Instruction\MagentoImport $magentoImportProcessor
  * @param \Magento\Framework\Less\PreProcessor\Instruction\Import $importProcessor
  */
 public function __construct(\Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\Less\PreProcessor\Instruction\MagentoImport $magentoImportProcessor, \Magento\Framework\Less\PreProcessor\Instruction\Import $importProcessor)
 {
     $this->tmpDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
     $this->assetRepo = $assetRepo;
     $this->magentoImportProcessor = $magentoImportProcessor;
     $this->importProcessor = $importProcessor;
 }
Beispiel #11
0
 /**
  * @param \Magento\Framework\Logger $logger
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\Logger\AdapterFactory $adapterFactory
  * @param array $data
  */
 public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\Logger\AdapterFactory $adapterFactory, array $data = array())
 {
     $this->_logger = $logger;
     $this->_varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
     $this->_adapterFactory = $adapterFactory;
     parent::__construct($data);
 }
Beispiel #12
0
 /**
  * Return newly created cache frontend instance
  *
  * @param array $options
  * @return \Magento\Framework\Cache\FrontendInterface
  */
 public function create(array $options)
 {
     $options = $this->_getExpandedOptions($options);
     foreach (array('backend_options', 'slow_backend_options') as $section) {
         if (!empty($options[$section]['cache_dir'])) {
             $directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
             $directory->create($options[$section]['cache_dir']);
             $options[$section]['cache_dir'] = $directory->getAbsolutePath($options[$section]['cache_dir']);
         }
     }
     $this->_backendOptions['cache_dir'] = $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::CACHE_DIR);
     $idPrefix = isset($options['id_prefix']) ? $options['id_prefix'] : '';
     if (!$idPrefix && isset($options['prefix'])) {
         $idPrefix = $options['prefix'];
     }
     if (empty($idPrefix)) {
         $idPrefix = substr(md5($this->_filesystem->getPath(\Magento\Framework\App\Filesystem::CONFIG_DIR)), 0, 3) . '_';
     }
     $options['frontend_options']['cache_id_prefix'] = $idPrefix;
     $backend = $this->_getBackendOptions($options);
     $frontend = $this->_getFrontendOptions($options);
     // Start profiling
     $profilerTags = array('group' => 'cache', 'operation' => 'cache:create', 'frontend_type' => $frontend['type'], 'backend_type' => $backend['type']);
     \Magento\Framework\Profiler::start('cache_frontend_create', $profilerTags);
     /** @var $result \Magento\Framework\Cache\Frontend\Adapter\Zend */
     $result = $this->_objectManager->create('Magento\\Framework\\Cache\\Frontend\\Adapter\\Zend', array('frontend' => \Zend_Cache::factory($frontend['type'], $backend['type'], $frontend, $backend['options'], true, true, true)));
     $result = $this->_applyDecorators($result);
     // stop profiling
     \Magento\Framework\Profiler::stop('cache_frontend_create');
     return $result;
 }
Beispiel #13
0
 /**
  * Check file system full path
  *
  * @param  string $fullPath
  * @param  bool $recursive
  * @param  bool $existence
  * @return bool
  */
 protected function _checkFullPath($fullPath, $recursive, $existence)
 {
     $result = true;
     $directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $path = $directory->getRelativePath($fullPath);
     if ($recursive && $directory->isDirectory($path)) {
         $pathsToCheck = $directory->read($path);
         array_unshift($pathsToCheck, $path);
     } else {
         $pathsToCheck = array($path);
     }
     $skipFileNames = array('.svn', '.htaccess');
     foreach ($pathsToCheck as $pathToCheck) {
         if (in_array(basename($pathToCheck), $skipFileNames)) {
             continue;
         }
         if ($existence) {
             $setError = !$directory->isWritable($path);
         } else {
             $setError = $directory->isExist($path) && !$directory->isWritable($path);
         }
         if ($setError) {
             $this->messageManager->addError(__('Path "%1" must be writable.', $pathToCheck));
             $result = false;
         }
     }
     return $result;
 }
Beispiel #14
0
 /**
  * {@inheritdoc}
  */
 public function create($productSku, GalleryEntry $entry, GalleryEntryContent $entryContent, $storeId = 0)
 {
     $store = $this->storeFactory->create()->load($storeId);
     if ($store->getId() != $storeId) {
         throw new NoSuchEntityException('There is no store with provided ID.');
     }
     if (!$this->contentValidator->isValid($entryContent)) {
         throw new InputException('The image content is not valid.');
     }
     $product = $this->productLoader->load($productSku);
     $fileContent = @base64_decode($entryContent->getData(), true);
     $mediaTmpPath = $this->mediaConfig->getBaseTmpMediaPath();
     $mediaDirectory = $this->filesystem->getDirectoryWrite(Filesystem::MEDIA_DIR);
     $mediaDirectory->create($mediaTmpPath);
     $fileName = $entryContent->getName() . '.' . $this->mimeTypeExtensionMap[$entryContent->getMimeType()];
     $relativeFilePath = $mediaTmpPath . DIRECTORY_SEPARATOR . $fileName;
     $absoluteFilePath = $mediaDirectory->getAbsolutePath($relativeFilePath);
     $mediaDirectory->writeFile($relativeFilePath, $fileContent);
     /** @var $productMediaGallery \Magento\Catalog\Model\Product\Attribute\Backend\Media */
     $productMediaGallery = $this->getGalleryAttributeBackend($product);
     $imageFileUri = $productMediaGallery->addImage($product, $absoluteFilePath, $entry->getTypes(), true, $entry->isDisabled());
     // Update additional fields that are still empty after addImage call
     $productMediaGallery->updateImage($product, $imageFileUri, array('label' => $entry->getLabel(), 'position' => $entry->getPosition(), 'disabled' => $entry->isDisabled()));
     $product->setStoreId($storeId);
     $product->save();
     // Remove all temporary files
     $mediaDirectory->delete($relativeFilePath);
     // File could change its name during the move from tmp dir
     return $this->entryResolver->getEntryIdByFilePath($product, $productMediaGallery->getRenamedImage($imageFileUri));
 }
Beispiel #15
0
 /**
  * Save customized DOM of view configuration
  *
  * @param \DOMDocument $config
  * @return $this
  */
 protected function _saveViewConfiguration(\DOMDocument $config)
 {
     $targetPath = $this->_theme->getCustomization()->getCustomViewConfigPath();
     $directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $directory->writeFile($directory->getRelativePath($targetPath), $config->saveXML());
     return $this;
 }
Beispiel #16
0
 /**
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Core\Helper\File\Storage\Database $fileStorageDatabase
  * @param \Magento\Core\Model\File\Storage\DatabaseFactory $storageDatabaseFactory
  * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
  */
 public function __construct(\Magento\Framework\App\Filesystem $filesystem, \Magento\Core\Helper\File\Storage\Database $fileStorageDatabase, \Magento\Core\Model\File\Storage\DatabaseFactory $storageDatabaseFactory, \Magento\Framework\App\Response\Http\FileFactory $fileFactory)
 {
     $this->_rootDir = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $this->_fileStorageDatabase = $fileStorageDatabase;
     $this->_storageDatabaseFactory = $storageDatabaseFactory;
     $this->_fileFactory = $fileFactory;
 }
Beispiel #17
0
 /**
  * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
  * @param \Magento\Framework\Logger $logger
  * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
  * @param \Magento\Core\Helper\Data $coreData
  * @param \Magento\Core\Model\File\Validator\NotProtectedExtension $fileValidator
  * @param \Magento\Framework\App\Filesystem $filesystem
  */
 public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Logger $logger, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Core\Helper\Data $coreData, \Magento\Core\Model\File\Validator\NotProtectedExtension $fileValidator, \Magento\Framework\App\Filesystem $filesystem)
 {
     parent::__construct($localeDate, $logger, $localeResolver);
     $this->_coreData = $coreData;
     $this->_fileValidator = $fileValidator;
     $this->_directory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
 }
Beispiel #18
0
 /**
  * @param \Magento\Framework\Model\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
  * @param \Magento\Core\Model\File\UploaderFactory $uploaderFactory
  * @param \Magento\Backend\Model\Config\Backend\File\RequestData\RequestDataInterface $requestData
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\Model\Resource\AbstractResource $resource
  * @param \Magento\Framework\Data\Collection\Db $resourceCollection
  * @param array $data
  */
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Core\Model\File\UploaderFactory $uploaderFactory, \Magento\Backend\Model\Config\Backend\File\RequestData\RequestDataInterface $requestData, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array())
 {
     $this->_uploaderFactory = $uploaderFactory;
     $this->_requestData = $requestData;
     $this->_filesystem = $filesystem;
     $this->_mediaDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data);
 }
Beispiel #19
0
 /**
  * @param Resource\LogFactory $resLogFactory
  * @param \Magento\Captcha\Helper\Data $helper
  * @param \Magento\Captcha\Helper\Adminhtml\Data $adminHelper
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Store\Model\StoreManager $storeManager
  */
 public function __construct(Resource\LogFactory $resLogFactory, \Magento\Captcha\Helper\Data $helper, \Magento\Captcha\Helper\Adminhtml\Data $adminHelper, \Magento\Framework\App\Filesystem $filesystem, \Magento\Store\Model\StoreManager $storeManager)
 {
     $this->_resLogFactory = $resLogFactory;
     $this->_helper = $helper;
     $this->_adminHelper = $adminHelper;
     $this->_mediaDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     $this->_storeManager = $storeManager;
 }
Beispiel #20
0
 /**
  * Get captcha image directory
  *
  * @param mixed $website
  * @return string
  */
 public function getImgDir($website = null)
 {
     $mediaDir = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     $captchaDir = '/captcha/' . $this->_getWebsiteCode($website);
     $mediaDir->create($captchaDir);
     $mediaDir->changePermissions($captchaDir, 0775);
     return $mediaDir->getAbsolutePath($captchaDir) . '/';
 }
Beispiel #21
0
 /**
  * Remove local.xml
  *
  * @return void
  */
 protected function _removeLocalXml()
 {
     try {
         $this->_filesystem->getDirectoryWrite(AppFilesystem::CONFIG_DIR)->delete('local.xml');
     } catch (FilesystemException $e) {
         $this->fileDeleteErrors[] = $e->getMessage();
     }
 }
Beispiel #22
0
 /**
  * Add a logger by specified key
  *
  * Second argument is a file name (relative to log directory) or a PHP "wrapper"
  *
  * @param string $loggerKey
  * @param string $fileOrWrapper
  * @param string $writerClass
  * @return \Magento\Framework\Logger
  * @link http://php.net/wrappers
  */
 public function addStreamLog($loggerKey, $fileOrWrapper = '', $writerClass = '')
 {
     $file = $fileOrWrapper ?: "{$loggerKey}.log";
     if (!preg_match('#^[a-z][a-z0-9+.-]*\\://#i', $file)) {
         $logDir = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::LOG_DIR);
         $logDir->create();
         $file = $logDir->getAbsolutePath($file);
     }
     if (!$writerClass || !is_subclass_of($writerClass, 'Zend_Log_Writer_Stream')) {
         $writerClass = 'Zend_Log_Writer_Stream';
     }
     /** @var $writer \Zend_Log_Writer_Stream */
     $writer = $writerClass::factory(array('stream' => $file));
     $writer->setFormatter(new \Zend_Log_Formatter_Simple('%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL));
     $this->_loggers[$loggerKey] = new \Zend_Log($writer);
     return $this;
 }
Beispiel #23
0
 /**
  * @param \Magento\Framework\App\RequestInterface $request
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\StoreManagerInterface $storeManager
  * @param \Magento\Framework\Message\ManagerInterface $messageManager
  */
 public function __construct(\Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Message\ManagerInterface $messageManager)
 {
     $this->_request = $request;
     $this->_storeManager = $storeManager;
     $this->_filesystem = $filesystem;
     $this->_pubDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::PUB_DIR);
     $this->_configDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::CONFIG_DIR);
     $this->messageManager = $messageManager;
 }
Beispiel #24
0
 /**
  * Construct
  *
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Backend\Helper\Data $backendData
  * @param \Magento\Core\Helper\Data $coreData
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\StoreManagerInterface $storeManager
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Backend\Helper\Data $backendData, \Magento\Core\Helper\Data $coreData, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\StoreManagerInterface $storeManager)
 {
     parent::__construct($context);
     $this->_backendData = $backendData;
     $this->_coreData = $coreData;
     $this->_storeManager = $storeManager;
     $this->_directory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     $this->_directory->create(\Magento\Cms\Model\Wysiwyg\Config::IMAGE_DIRECTORY);
 }
Beispiel #25
0
 /**
  * Remove file
  *
  * @param string $file
  * @return $this
  */
 public function removeFile($file)
 {
     $directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     $path = $directory->getRelativePath($this->getStoragePath() . '/' . $file);
     if ($directory->isExist($path)) {
         $directory->delete($path);
     }
     return $this;
 }
Beispiel #26
0
 /**
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Backend\Model\Session $session
  * @param \Magento\Framework\View\Design\Theme\FlyweightFactory $themeFactory
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Filesystem $filesystem, \Magento\Backend\Model\Session $session, \Magento\Framework\View\Design\Theme\FlyweightFactory $themeFactory)
 {
     parent::__construct($context);
     $this->filesystem = $filesystem;
     $this->_session = $session;
     $this->_themeFactory = $themeFactory;
     $this->mediaDirectoryWrite = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     $this->mediaDirectoryWrite->create($this->mediaDirectoryWrite->getRelativePath($this->getStorageRoot()));
 }
Beispiel #27
0
 /**
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\View\Design\Theme\FileFactory $fileFactory
  * @param \Magento\Core\Model\Layout\Link $link
  * @param \Magento\Core\Model\Layout\UpdateFactory $updateFactory
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Framework\View\Design\Theme\Customization\Path $customization
  */
 public function __construct(\Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\View\Design\Theme\FileFactory $fileFactory, \Magento\Core\Model\Layout\Link $link, \Magento\Core\Model\Layout\UpdateFactory $updateFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\View\Design\Theme\Customization\Path $customization)
 {
     $this->_directory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     $this->_fileFactory = $fileFactory;
     $this->_link = $link;
     $this->_updateFactory = $updateFactory;
     $this->_eventManager = $eventManager;
     $this->_customizationPath = $customization;
 }
Beispiel #28
0
 /**
  * {@inheritdoc}
  */
 public function merge(array $assetsToMerge, \Magento\Framework\View\Asset\LocalInterface $resultAsset)
 {
     $sourceDir = $this->filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $mTime = null;
     /** @var \Magento\Framework\View\Asset\MergeableInterface $asset */
     foreach ($assetsToMerge as $asset) {
         $mTime .= $sourceDir->stat($sourceDir->getRelativePath($asset->getSourceFile()))['mtime'];
     }
     if (null === $mTime) {
         return;
         // nothing to merge
     }
     $dat = $resultAsset->getPath() . '.dat';
     $targetDir = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR);
     if (!$targetDir->isExist($dat) || strcmp($mTime, $targetDir->readFile($dat)) !== 0) {
         $this->strategy->merge($assetsToMerge, $resultAsset);
         $targetDir->writeFile($dat, $mTime);
     }
 }
Beispiel #29
0
 /**
  * Print output
  *
  * @return void
  */
 public function output()
 {
     if (!$this->exists()) {
         return;
     }
     /** @var \Magento\Framework\Filesystem\Directory\ReadInterface $directory */
     $directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
     $directory = $directory->readFile($this->_getFilePath());
     echo $directory;
 }
Beispiel #30
0
 /**
  * @param PreProcessor\Cache $cache
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param PreProcessor\Pool $preProcessorPool
  * @param \Magento\Framework\View\Design\FileResolution\Fallback\StaticFile $fallback
  * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList
  */
 public function __construct(PreProcessor\Cache $cache, \Magento\Framework\App\Filesystem $filesystem, PreProcessor\Pool $preProcessorPool, \Magento\Framework\View\Design\FileResolution\Fallback\StaticFile $fallback, \Magento\Framework\View\Design\Theme\ListInterface $themeList)
 {
     $this->cache = $cache;
     $this->filesystem = $filesystem;
     $this->rootDir = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $this->varDir = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
     $this->preProcessorPool = $preProcessorPool;
     $this->fallback = $fallback;
     $this->themeList = $themeList;
 }