Example #1
0
 /**
  * Iterate over deleted aggregate root objects and process them
  *
  * @return void
  */
 protected function processDeletedObjects()
 {
     foreach ($this->deletedObjects as $object) {
         $this->removeObject($object);
         $this->identityMap->unregisterObject($object);
     }
     $this->deletedObjects = new Tx_Extbase_Persistence_ObjectStorage();
 }
Example #2
0
 /**
  * Maps a single row on an object of the given class
  *
  * @param string $className The name of the target class
  * @param array $row A single array with field_name => value pairs
  * @return object An object of the given class
  */
 protected function mapSingleRow($className, array $row)
 {
     if ($this->identityMap->hasIdentifier($row['uid'], $className)) {
         $object = $this->identityMap->getObjectByIdentifier($row['uid'], $className);
     } else {
         $object = $this->createEmptyObject($className);
         $this->identityMap->registerObject($object, $row['uid']);
         $this->thawProperties($object, $row);
         $object->_memorizeCleanState();
         $this->persistenceSession->registerReconstitutedObject($object);
     }
     return $object;
 }
Example #3
0
 /**
  * Finds an object matching the given identifier.
  *
  * @param int $uid The identifier of the object to find
  * @return object The matching object if found, otherwise NULL
  * @api
  */
 public function findByUid($uid)
 {
     if ($this->identityMap->hasIdentifier($uid, $this->objectType)) {
         $object = $this->identityMap->getObjectByIdentifier($uid, $this->objectType);
     } else {
         $query = $this->createQuery();
         $query->getQuerySettings()->setRespectSysLanguage(FALSE);
         $query->getQuerySettings()->setRespectStoragePage(FALSE);
         $object = $query->matching($query->equals('uid', $uid))->execute()->getFirst();
         if ($object !== NULL) {
             $this->identityMap->registerObject($object, $uid);
         }
     }
     return $object;
 }
 /**
  * @test
  */
 public function findByUidQueriesObjectAndRegistersItIfItWasNotFoundInIdentityMap()
 {
     $fakeUid = '123';
     $object = new stdClass();
     $this->repository->_set('objectType', 'someObjectType');
     $mockQuerySettings = $this->getMock('Tx_Extbase_Persistence_QuerySettingsInterface');
     $this->mockQuery->expects($this->atLeastOnce())->method('getQuerySettings')->will($this->returnValue($mockQuerySettings));
     $mockQueryResult = $this->getMock('Tx_Extbase_Persistence_QueryResultInterface');
     $this->mockQuery->expects($this->once())->method('equals')->with('uid', $fakeUid)->will($this->returnValue('matchingConstraint'));
     $this->mockQuery->expects($this->once())->method('matching')->with('matchingConstraint')->will($this->returnValue($this->mockQuery));
     $this->mockQuery->expects($this->once())->method('execute')->will($this->returnValue($mockQueryResult));
     $mockQueryResult->expects($this->once())->method('getFirst')->will($this->returnValue($object));
     $this->mockIdentityMap->expects($this->once())->method('hasIdentifier')->with($fakeUid, 'someObjectType')->will($this->returnValue(FALSE));
     $this->mockIdentityMap->expects($this->once())->method('registerObject')->with($object, $fakeUid);
     $this->mockQueryFactory->expects($this->once())->method('create')->with('someObjectType')->will($this->returnValue($this->mockQuery));
     $expectedResult = $object;
     $actualResult = $this->repository->findByUid($fakeUid);
     $this->assertSame($expectedResult, $actualResult);
 }