Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
BasePackageInfo Class Reference

Public Member Functions

 __construct (ReadFactory $readFactory)
 
 getPaths ()
 

Data Fields

const MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE = 'magento/magento2-base/composer.json'
 
const COMPOSER_KEY_EXTRA = 'extra'
 
const COMPOSER_KEY_MAP = 'map'
 

Detailed Description

Information about the Magento base package.

Definition at line 14 of file BasePackageInfo.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ReadFactory  $readFactory)

Constructor

Parameters
ReadFactory$readFactory

Definition at line 32 of file BasePackageInfo.php.

33  {
34  $this->reader = $readFactory->create(BP);
35  }
const BP
Definition: autoload.php:14

Member Function Documentation

◆ getPaths()

getPaths ( )

Get the list of files and directory paths from magento-base extra/map section.

Returns
string []
Exceptions

Definition at line 43 of file BasePackageInfo.php.

44  {
45  // Locate composer.json for magento2-base module
46  $filesPathList = [];
47  $vendorDir = require VENDOR_PATH;
48  $basePackageComposerFilePath = $vendorDir . '/' . self::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE;
49  if (!$this->reader->isExist($basePackageComposerFilePath)) {
50  throw new \Magento\Setup\Exception(
51  'Could not locate ' . self::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE . ' file.'
52  );
53  }
54  if (!$this->reader->isReadable($basePackageComposerFilePath)) {
55  throw new \Magento\Setup\Exception(
56  'Could not read ' . self::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE . ' file.'
57  );
58  }
59 
60  // Fill array with list of files and directories from extra/map section
61  $composerJsonFileData = json_decode($this->reader->readFile($basePackageComposerFilePath), true);
62  if (!isset($composerJsonFileData[self::COMPOSER_KEY_EXTRA][self::COMPOSER_KEY_MAP])) {
63  return $filesPathList;
64  }
65  $extraMappings = $composerJsonFileData[self::COMPOSER_KEY_EXTRA][self::COMPOSER_KEY_MAP];
66  foreach ($extraMappings as $map) {
67  $filesPathList[] = $map[1];
68  }
69  return $filesPathList;
70  }
if(!file_exists(VENDOR_PATH)) $vendorDir
Definition: autoload.php:25
const VENDOR_PATH
Definition: autoload.php:16

Field Documentation

◆ COMPOSER_KEY_EXTRA

const COMPOSER_KEY_EXTRA = 'extra'

Definition at line 18 of file BasePackageInfo.php.

◆ COMPOSER_KEY_MAP

const COMPOSER_KEY_MAP = 'map'

Definition at line 20 of file BasePackageInfo.php.

◆ MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE

const MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE = 'magento/magento2-base/composer.json'

Definition at line 16 of file BasePackageInfo.php.


The documentation for this class was generated from the following file: