update() публичный Метод

public update ( RepeatingFieldCollection $collection ) : RepeatingFieldCollection[]
$collection RepeatingFieldCollection
Результат RepeatingFieldCollection[]
Пример #1
0
 public function persist(QuerySet $queries, $entity)
 {
     $this->normalize($entity);
     $key = $this->mapping['fieldname'];
     $accessor = 'get' . ucfirst($key);
     $proposed = $entity->{$accessor}();
     $collection = new RepeatingFieldCollection($this->em, $this->mapping);
     $existingFields = $this->getExistingFields($entity) ?: [];
     foreach ($existingFields as $group => $ids) {
         $collection->addFromReferences($ids, $group);
     }
     $toDelete = $collection->update($proposed);
     $repo = $this->em->getRepository('Bolt\\Storage\\Entity\\FieldValue');
     $queries->onResult(function ($query, $result, $id) use($repo, $collection, $toDelete) {
         foreach ($collection as $entity) {
             $entity->content_id = $id;
             $repo->save($entity);
         }
         foreach ($toDelete as $entity) {
             $repo->delete($entity);
         }
     });
 }