예제 #1
0
 /**
  * Parses configuration options from YAML configuration files related to the
  * configurable object.
  *
  * This method throws the SearchEvents::CONFIG_LOAD event. If configurations
  * are loaded during this event, processing stops and the directories are
  * not scanned for configuration files.
  *
  * @return array
  *   An associative array of options.
  *
  * @throws ParseException
  */
 public function load()
 {
     $log = $this->_agent->getLogger();
     $context = array('collection' => $this->_collection->getId());
     // Allow the schema to be loaded from another source.
     $event = new SchemaLoaderEvent($this->_agent, $this->_collection);
     $this->_agent->dispatchEvent(SearchEvents::SCHEMA_LOAD, $event);
     if (!($options = $event->getOptions())) {
         if ($conf_dir = $this->getConfDir()) {
             $filename = $this->_collection->getConfigBasename() . '.yml';
             $filepath = $conf_dir . '/' . $filename;
             $context['filepath'] = $filepath;
             $log->debug('Attempting to parse schema configuration file', $context);
             $options = Yaml::parse($filepath);
             $log->debug('Schema options parsed from configuration file', $context);
         } else {
             $log->notice('Path to conf directory could not be resolved', $context);
         }
     } else {
         $log->debug('Schema configuration loaded from an external source.', $context);
     }
     $schema = new Schema();
     $schema->build($options);
     return $schema;
 }