Пример #1
0
 /**
  * Gets the metadata mapping information from the YAML file.
  *
  * @param   string  $metaType   The metadata type, either mixin or model.
  * @param   string  $key        The metadata key name, either the mixin name or model type.
  * @param   string  $file       The YAML file location.
  * @return  array
  * @throws  MetadataException
  */
 private function getMapping($metaType, $key, $file)
 {
     if (isset($this->mappings[$metaType][$key])) {
         // Set to array cache to prevent multiple gets/parses.
         return $this->mappings[$metaType][$key];
     }
     $contents = Yaml::parse(file_get_contents($file));
     if (!isset($contents[$key])) {
         throw MetadataException::fatalDriverError($key, sprintf('No mapping key was found at the beginning of the YAML file. Expected "%s"', $key));
     }
     return $this->mappings[$metaType][$key] = $this->setDefaults($metaType, $contents[$key]);
 }
 /**
  * Returns the file path for an entity type or mixin name.
  *
  * @param   string  $metaType   The type of metadata, either model or mixin.
  * @param   string  $key        The file key name, either the model type or the mixin name.
  * @return  string
  * @throws  MetadataException
  */
 protected function getFilePath($metaType, $key)
 {
     $method = 'mixin' === $metaType ? 'findFileForMixin' : 'findFileForType';
     $path = $this->fileLocator->{$method}($key, $this->getExtension());
     if (null === $path) {
         throw MetadataException::fatalDriverError($key, sprintf('No mapping file was found.', $path));
     }
     return $path;
 }