Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function validateEmbed(EmbeddedPropMetadata $embed)
 {
     if (true === $this->hasAttribute($embed->getKey())) {
         throw MetadataException::fieldKeyInUse('embed', 'attribute', $embed->getKey(), $this->name);
     }
 }
Example #2
0
 /**
  * Loads a has-many embed collection.
  *
  * @param   EmbeddedPropMetadata    $relMeta
  * @param   array|null              $embedDocs
  * @return  Collections\EmbedCollection
  */
 public function createEmbedCollection(EmbeddedPropMetadata $embededPropMeta, array $embedDocs = null)
 {
     if (empty($embedDocs)) {
         $embedDocs = [];
     }
     if (false === $this->isSequentialArray($embedDocs)) {
         throw StoreException::badRequest(sprintf('Improper has-many data detected for embed "%s" - a sequential array is required.', $embededPropMeta->getKey()));
     }
     $embeds = [];
     foreach ($embedDocs as $embedDoc) {
         $embeds[] = $this->loadEmbed($embededPropMeta->embedMeta, $embedDoc);
     }
     return new Collections\EmbedCollection($embededPropMeta->embedMeta, $this, $embeds);
 }