/**
  * {@inheritdoc}
  *
  * @throws ConfigurationException
  */
 public function loadContentTypes()
 {
     // Make sure to initialise by reading the data source.
     if (!$this->isInitialised()) {
         $this->parseDataSource();
     }
     $globalFields = $this->loadGlobalFields();
     $globalExtras = $this->loadGlobalExtras();
     $contentTypes = array();
     if (empty($this->config)) {
         throw new ConfigurationException("Configuration file is invalid");
     }
     if (isset($this->config['ContentTypes'])) {
         foreach ($this->config['ContentTypes'] as $contentTypeData) {
             $contentType = ContentType::parseYaml($contentTypeData, $globalFields, $globalExtras);
             $contentTypes[$contentType->getMachineName()] = $contentType;
         }
     } else {
         throw new ConfigurationException("No Drupal content types are configured");
     }
     return $contentTypes;
 }
 /**
  * Construct a ContentType by parsing yaml configuration.
  *
  * @param array $yaml
  *   Yaml in a standard format as found in contentTypes.yml.
  * @param array $fields
  *   Yaml for the global fields in a standard format as found in contentTypes.yml.
  * @param array $extras
  *   Yaml for the global extras in a standard format as found in contentTypes.yml.
  *
  * @return ContentType
  *   A fully populated ContentType object.
  */
 public static function parseYaml($yaml, $fields = array(), $extras = array())
 {
     $contentType = new ContentType();
     $contentType->setHumanName($yaml['humanName']);
     $contentType->setMachineName($yaml['machineName']);
     // Set the entity type.
     if (isset($yaml['entityType'])) {
         $contentType->setEntityType($yaml['entityType']);
     } else {
         // Use node as our default if no entity type is set.
         $contentType->setEntityType('node');
     }
     // Set all the required fields for this content type.
     foreach ($contentType->getEntityType()->getRequiredFields() as $field) {
         $contentType->setField($field);
     }
     // Set all fields on this content type as defined in the yaml.
     if (isset($yaml['fields'])) {
         foreach ($yaml['fields'] as $key => $fieldData) {
             // The 'globals' key is the old way of writing it instead of 'globalFields' which is maintained for
             // backwards compatibility.
             if ($key == 'globals' || $key == 'globalFields') {
                 // Handle the list of global fields specially.
                 $fields = Field::parseGlobalFields($fieldData, $fields);
                 $contentType->setFields($fields);
             } else {
                 // Handle a single field definition.
                 $field = Field::parseYaml($fieldData, $fields);
                 $contentType->setField($field);
             }
         }
     }
     // Set all extras on this content type as defined in the yaml.
     if (isset($yaml['extras'])) {
         foreach ($yaml['extras'] as $key => $extraData) {
             if ($key == 'globalExtras') {
                 // Handle the list of global extras specially.
                 $extras = Field::parseGlobalFields($extraData, $extras);
                 $contentType->setExtras($extras);
             } else {
                 $extra = Field::parseYaml($extraData);
                 $contentType->setExtra($extra);
             }
         }
     }
     if (isset($yaml['submit'])) {
         $contentType->setSubmitSelector($yaml['submit']);
     }
     return $contentType;
 }