示例#1
0
文件: File.php 项目: malapronta/mplog
 /**
  * Tries to get a mapping for a given class
  *
  * @param  $className
  * @return null|array|object
  */
 protected function _getMapping($className)
 {
     //try loading mapping from original driver first
     $mapping = null;
     if (!is_null($this->_originalDriver)) {
         if ($this->_originalDriver instanceof FileDriver || $this->_originalDriver instanceof AbstractFileDriver) {
             $mapping = $this->_originalDriver->getElement($className);
         }
     }
     //if no mapping found try to load mapping file again
     if (is_null($mapping)) {
         $yaml = $this->_loadMappingFile($this->locator->findMappingFile($className));
         $mapping = $yaml[$className];
     }
     return $mapping;
 }
 /**
  * {@inheritDoc}
  */
 public function getAllClassNames()
 {
     if ($this->classCache === null) {
         $this->initialize();
     }
     if (!$this->classCache) {
         return (array) $this->locator->getAllClassNames($this->globalBasename);
     }
     return array_merge(array_keys($this->classCache), (array) $this->locator->getAllClassNames($this->globalBasename));
 }
示例#3
0
 /**
  * {@inheritDoc}
  */
 public function getAllClassNames()
 {
     if ($this->classCache === null) {
         $this->initialize();
     }
     $classNames = (array) $this->locator->getAllClassNames($this->globalBasename);
     if ($this->classCache) {
         $classNames = array_merge(array_keys($this->classCache), $classNames);
     }
     return $classNames;
 }
示例#4
0
 /**
  * Initialize the class cache from all the global files.
  *
  * Using this feature adds a substantial performance hit to file drivers as
  * more metadata has to be loaded into memory than might actually be
  * necessary. This may not be relevant to scenarios where caching of
  * metadata is in place, however hits very hard in scenarios where no
  * caching is used.
  *
  * @return void
  */
 protected function initialize()
 {
     $this->classCache = array();
     if (null !== $this->globalBasename) {
         foreach ($this->locator->getPaths() as $path) {
             $file = $path . '/' . $this->globalBasename . $this->locator->getFileExtension();
             if (is_file($file)) {
                 $this->classCache = array_merge($this->classCache, $this->loadMappingFile($file));
             }
         }
     }
 }