public function onFlush(OnFlushEventArgs $eventArgs)
 {
     $this->em = $eventArgs->getEntityManager();
     $this->conn = $this->em->getConnection();
     $this->uow = $this->em->getUnitOfWork();
     $this->platform = $this->conn->getDatabasePlatform();
     $this->revisionId = null;
     // reset revision
     foreach ($this->uow->getScheduledEntityDeletions() as $entity) {
         $class = $this->em->getClassMetadata(get_class($entity));
         if (!$this->metadataFactory->isAudited($class->name)) {
             continue;
         }
         $entityData = array_merge($this->getOriginalEntityData($entity), $this->uow->getEntityIdentifier($entity));
         $this->saveRevisionEntityData($class, $entityData, 'DEL');
     }
 }
 /**
  * Extract a slice of $length elements starting at position $offset from the Collection.
  *
  * If $length is null it returns all elements from $offset to the end of the Collection.
  * Keys have to be preserved by this method. Calling this method will only return the
  * selected slice and NOT change the elements contained in the collection slice is called on.
  *
  * @param int $offset
  * @param int $length
  * @return array
  */
 public function slice($offset, $length = null)
 {
     if (!$this->initialized && $this->association['fetch'] == Mapping\ClassMetadataInfo::FETCH_EXTRA_LAZY) {
         return $this->em->getUnitOfWork()->getCollectionPersister($this->association)->slice($this, $offset, $length);
     }
     $this->initialize();
     return $this->coll->slice($offset, $length);
 }
 /**
  * Ob onFlush dogodku dobimo vse spremembe polj in kolekcij ter
  * jih zapišemo v revizije
  *
  * @param \Doctrine\ORM\Event\OnFlushEventArgs $eventArgs
  */
 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     $this->em = $eventArgs->getEntityManager();
     $this->conn = $this->em->getConnection();
     $this->uow = $this->em->getUnitOfWork();
     $this->platform = $this->conn->getDatabasePlatform();
     $changes = $this->getChanges();
     $this->saveChanges($changes);
 }
Exemple #4
0
 /**
  * Get renditions names used by packages
  *
  * @return array
  */
 private function getPackageRenditionNames()
 {
     $names = array();
     foreach ($this->orm->createQuery('SELECT p FROM Newscoop\\Package\\Package p')->getResult() as $package) {
         $id = $this->orm->getUnitOfWork()->getEntityIdentifier($package->getRendition());
         $names[] = $id['name'];
     }
     return $names;
 }
 /**
  * {@inheritdoc}
  */
 public function clear()
 {
     $this->_initialize();
     $result = $this->_coll->clear();
     if ($this->_association->isOwningSide) {
         $this->_changed();
         $this->_em->getUnitOfWork()->scheduleCollectionDeletion($this);
     }
     return $result;
 }
 /**
  * @group orm
  */
 public function testORMNewInstance()
 {
     $fileManager = new FileManager($this->ormStorage, self::ENTITY_FILE_CLASS, $this->rootDir);
     $manager = new TransUnitManager($this->ormStorage, $fileManager, $this->rootDir);
     $transUnit = $manager->newInstance();
     $this->assertEquals(ORMUnitOfWork::STATE_NEW, $this->em->getUnitOfWork()->getEntityState($transUnit));
     $this->assertEquals(0, $transUnit->getTranslations()->count());
     $transUnit = $manager->newInstance(array('fr', 'en'));
     $this->assertEquals(ORMUnitOfWork::STATE_NEW, $this->em->getUnitOfWork()->getEntityState($transUnit));
     $this->assertEquals('fr', $transUnit->getTranslations()->get(0)->getLocale());
     $this->assertEquals('en', $transUnit->getTranslations()->get(1)->getLocale());
 }
 /**
  * {@inheritdoc}
  */
 public function clear()
 {
     if ($this->initialized && $this->isEmpty()) {
         return;
     }
     if ($this->association->isOneToMany() && $this->association->orphanRemoval) {
         foreach ($this->coll as $element) {
             $this->em->getUnitOfWork()->scheduleOrphanRemoval($element);
         }
     }
     $this->coll->clear();
     if ($this->association->isOwningSide) {
         $this->changed();
         $this->em->getUnitOfWork()->scheduleCollectionDeletion($this);
         $this->takeSnapshot();
     }
 }
 /**
  * {@inheritdoc}
  */
 public function clear()
 {
     if ($this->initialized && $this->isEmpty()) {
         return;
     }
     if ($this->association['type'] == ClassMetadata::ONE_TO_MANY && $this->association['orphanRemoval']) {
         foreach ($this->coll as $element) {
             $this->em->getUnitOfWork()->scheduleOrphanRemoval($element);
         }
     }
     $this->coll->clear();
     if ($this->association['isOwningSide']) {
         $this->changed();
         $this->em->getUnitOfWork()->scheduleCollectionDeletion($this);
         $this->takeSnapshot();
     }
 }