/**
  * @param ModelMetadata $metadata    The object metadata, where to find the object's
  *     source configuration.
  * @param string|null   $sourceIdent Optional. Custom source ident to load.
  *     If NULL, the default (from metadata) will be used.
  * @throws Exception If the source is not defined in the model's metadata.
  * @return SourceInterface
  */
 private function createSource(ModelMetadata $metadata, $sourceIdent = null)
 {
     if ($sourceIdent === null) {
         $sourceIdent = $metadata->defaultSource();
     }
     $sourceConfig = $metadata->source($sourceIdent);
     if (!$sourceConfig) {
         throw new Exception(sprintf('Can not create %s source: "%s" is not defined in metadata.', get_class($this), $sourceIdent));
     }
     $sourceType = isset($sourceConfig['type']) ? $sourceConfig['type'] : self::DEFAULT_SOURCE_TYPE;
     $source = $this->sourceFactory->create($sourceType);
     $source->setData($sourceConfig);
     return $source;
 }