Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
ModmanParser Class Reference
Inheritance diagram for ModmanParser:
PathTranslationParser Parser

Public Member Functions

 __construct ($moduleDir=null, $translations=array(), $pathSuffix)
 
 setModuleDir ($moduleDir)
 
 getModuleDir ()
 
 setFile ($file)
 
 getFile ()
 
 getModmanFile ()
 
 getMappings ()
 
- Public Member Functions inherited from PathTranslationParser
 __construct ($translations, $pathSuffix)
 
 translatePathMappings ($mappings)
 

Protected Member Functions

 _parseMappings ()
 
- Protected Member Functions inherited from PathTranslationParser
 createPrefixVariants ($translations)
 

Protected Attributes

 $_moduleDir = null
 
 $_file = null
 
- Protected Attributes inherited from PathTranslationParser
 $pathPrefixVariants = array('', './')
 
 $pathPrefixTranslations = array()
 
 $pathSuffix
 

Detailed Description

Parsers modman files

Definition at line 11 of file ModmanParser.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $moduleDir = null,
  $translations = array(),
  $pathSuffix 
)

Constructor

Parameters
string$moduleDir

Definition at line 28 of file ModmanParser.php.

Member Function Documentation

◆ _parseMappings()

_parseMappings ( )
protected
Exceptions

Definition at line 115 of file ModmanParser.php.

116  {
117  $map = array();
118  $line = 0;
119 
120  foreach ($this->_file as $row) {
121  $line++;
122  $row = trim($row);
123  if ('' === $row || in_array($row[0], array('#', '@'))) {
124  continue;
125  }
126  $parts = preg_split('/\s+/', $row, 2, PREG_SPLIT_NO_EMPTY);
127  if (count($parts) != 2) {
128  throw new \ErrorException(sprintf('Invalid row on line %d has %d parts, expected 2', $line, count($row)));
129  }
130  $map[] = $parts;
131  }
132  return $map;
133  }

◆ getFile()

getFile ( )
Returns
\SplFileObject

Definition at line 77 of file ModmanParser.php.

◆ getMappings()

getMappings ( )
Returns
array
Exceptions

Implements Parser.

Definition at line 98 of file ModmanParser.php.

99  {
100  $file = $this->getFile();
101 
102  if (!$file->isReadable()) {
103  throw new \ErrorException(sprintf('modman file "%s" not readable', $file->getPathname()));
104  }
105 
106  $map = $this->_parseMappings();
107  $map = $this->translatePathMappings($map);
108  return $map;
109  }

◆ getModmanFile()

getModmanFile ( )
Returns
string

Definition at line 85 of file ModmanParser.php.

86  {
87  $file = null;
88  if (!is_null($this->_moduleDir)) {
89  $file = new \SplFileObject($this->_moduleDir . '/modman');
90  }
91  return $file;
92  }

◆ getModuleDir()

getModuleDir ( )
Returns
string

Definition at line 56 of file ModmanParser.php.

◆ setFile()

setFile (   $file)
Parameters
string | SplFileObject$file
Returns
ModmanParser

Definition at line 65 of file ModmanParser.php.

66  {
67  if (is_string($file)) {
68  $file = new \SplFileObject($file);
69  }
70  $this->_file = $file;
71  return $this;
72  }

◆ setModuleDir()

setModuleDir (   $moduleDir)

Sets the module directory where to search for the modman file

Parameters
string$moduleDir
Returns
ModmanParser

Definition at line 42 of file ModmanParser.php.

43  {
44  // Remove trailing slash
45  if (!is_null($moduleDir)) {
46  $moduleDir = rtrim($moduleDir, '\\/');
47  }
48 
49  $this->_moduleDir = $moduleDir;
50  return $this;
51  }

Field Documentation

◆ $_file

$_file = null
protected

Definition at line 21 of file ModmanParser.php.

◆ $_moduleDir

$_moduleDir = null
protected

Definition at line 16 of file ModmanParser.php.


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