Пример #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;
 }
Пример #2
0
 /**
  * Get the list of files and directory paths from magento-base extra/map section.
  *
  * @return string []
  * @throws \Magento\Setup\Exception
  */
 public function getPaths()
 {
     // Locate composer.json for magento2-base module
     $filesPathList = [];
     $vendorDir = (require VENDOR_PATH);
     $basePackageComposerFilePath = $vendorDir . '/' . self::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE;
     if (!$this->reader->isExist($basePackageComposerFilePath)) {
         throw new \Magento\Setup\Exception('Could not locate ' . self::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE . ' file.');
     }
     if (!$this->reader->isReadable($basePackageComposerFilePath)) {
         throw new \Magento\Setup\Exception('Could not read ' . self::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE . ' file.');
     }
     // Fill array with list of files and directories from extra/map section
     $composerJsonFileData = json_decode($this->reader->readFile($basePackageComposerFilePath), true);
     if (!isset($composerJsonFileData[self::COMPOSER_KEY_EXTRA][self::COMPOSER_KEY_MAP])) {
         return $filesPathList;
     }
     $extraMappings = $composerJsonFileData[self::COMPOSER_KEY_EXTRA][self::COMPOSER_KEY_MAP];
     foreach ($extraMappings as $map) {
         $filesPathList[] = $map[1];
     }
     return $filesPathList;
 }
Пример #3
0
 /**
  * Simple check if file is image
  *
  * @param array|string $fileInfo - either file data from \Zend_File_Transfer or file path
  * @return boolean
  * @see \Magento\Catalog\Model\Product\Option\Type\File::_isImage
  */
 protected function isImage($fileInfo)
 {
     // Maybe array with file info came in
     if (is_array($fileInfo)) {
         return strstr($fileInfo['type'], 'image/');
     }
     // File path came in - check the physical file
     if (!$this->rootDirectory->isReadable($this->rootDirectory->getRelativePath($fileInfo))) {
         return false;
     }
     $imageInfo = getimagesize($fileInfo);
     if (!$imageInfo) {
         return false;
     }
     return true;
 }
Пример #4
0
 /**
  * Quote item to order item copy process
  *
  * @return $this
  */
 public function copyQuoteToOrder()
 {
     $quoteOption = $this->getConfigurationItemOption();
     try {
         $value = unserialize($quoteOption->getValue());
         if (!isset($value['quote_path'])) {
             throw new \Exception();
         }
         $quotePath = $value['quote_path'];
         $orderPath = $value['order_path'];
         if (!$this->_rootDirectory->isFile($quotePath) || !$this->_rootDirectory->isReadable($quotePath)) {
             throw new \Exception();
         }
         $this->_coreFileStorageDatabase->copyFile($this->_rootDirectory->getAbsolutePath($quotePath), $this->_rootDirectory->getAbsolutePath($orderPath));
     } catch (\Exception $e) {
         return $this;
     }
     return $this;
 }
Пример #5
0
 /**
  * Retrieve available Data install/upgrade files for current module
  *
  * @param string $actionType
  * @param string $fromVersion
  * @param string $toVersion
  * @return array
  */
 protected function _getAvailableDataFiles($actionType, $fromVersion, $toVersion)
 {
     $modName = (string) $this->_moduleConfig['name'];
     $files = [];
     $filesDir = $this->_modulesReader->getModuleDir('data', $modName) . '/' . $this->_resourceName;
     $modulesDirPath = $this->modulesDir->getRelativePath($filesDir);
     if ($this->modulesDir->isDirectory($modulesDirPath) && $this->modulesDir->isReadable($modulesDirPath)) {
         $regExp = sprintf('#%s-(.*)\\.php$#i', $actionType);
         foreach ($this->modulesDir->read($modulesDirPath) as $file) {
             $matches = [];
             if (preg_match($regExp, $file, $matches)) {
                 $files[$matches[1]] = $this->modulesDir->getAbsolutePath($file);
             }
         }
     }
     if (empty($files)) {
         return [];
     }
     return $this->_getModifySqlFiles($actionType, $fromVersion, $toVersion, $files);
 }