Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ClassMap.php
Go to the documentation of this file.
1 <?php
9 
10 class ClassMap
11 {
17  protected $_baseDir;
18 
28  protected $_map = [];
29 
36  public function __construct($baseDir)
37  {
38  $this->_baseDir = realpath($baseDir);
39  if (!$this->_baseDir || !is_dir($this->_baseDir)) {
40  throw new \InvalidArgumentException("Specified path is not a valid directory: '{$baseDir}'");
41  }
42  }
43 
50  public function getFile($class)
51  {
52  if (isset($this->_map[$class])) {
53  return $this->_baseDir . '/' . $this->_map[$class];
54  }
55  return false;
56  }
57 
64  public function addMap(array $map)
65  {
66  $this->_map = array_merge($this->_map, $map);
67  return $this;
68  }
69 
76  public function load($class)
77  {
78  $file = $this->getFile($class);
79  if (file_exists($file)) {
80  include $file;
81  }
82  }
83 }
$baseDir
Definition: autoload.php:9
$_option $_optionId $class
Definition: date.phtml:13