Пример #1
0
 /**
  * @param ClassMetadata $metadata
  *
  * @return string[]
  */
 private function getProperties(ClassMetadata $metadata)
 {
     return array_merge($metadata->getFieldNames(), array_map(function (array $mapping) {
         return $mapping['fieldName'];
     }, $metadata->getEmbeddedFieldsMappings()));
 }
Пример #2
0
 /**
  * Cascades the postPersist events to embedded documents.
  *
  * @param ClassMetadata $class
  * @param object $document
  */
 private function cascadePostPersist(ClassMetadata $class, $document)
 {
     foreach ($class->getEmbeddedFieldsMappings() as $mapping) {
         $value = $class->reflFields[$mapping['fieldName']]->getValue($document);
         if ($value === null) {
             continue;
         }
         $values = $mapping['type'] === ClassMetadata::ONE ? array($value) : $value;
         foreach ($values as $embeddedDocument) {
             $this->postPersist($this->dm->getClassMetadata(get_class($embeddedDocument)), $embeddedDocument);
         }
     }
 }