/**
  * @param EntityManager $subject
  * @param \Closure $proceed
  * @param string $entityType
  * @param object $entity
  * @param string $identifier
  * @return null|object
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundLoad(EntityManager $subject, \Closure $proceed, $entityType, $entity, $identifier)
 {
     $object = $this->entityRegistry->retrieve($entityType, $identifier);
     if (!$object) {
         $object = $proceed($entityType, $entity, $identifier);
         $this->entityRegistry->register($entityType, $identifier, $object);
     }
     return $object;
 }
示例#2
0
 public function testRegister()
 {
     $entity = new \stdClass();
     $entity->test = 1;
     $entityType = "Test";
     $identifier = 42;
     $this->assertNull($this->entityRegistry->retrieve($entityType, $identifier));
     $this->entityRegistry->register($entityType, $identifier, $entity);
     $this->assertEquals($entity, $this->entityRegistry->retrieve($entityType, $identifier));
     $this->assertTrue($this->entityRegistry->remove($entityType, $identifier));
     $this->assertNull($this->entityRegistry->retrieve($entityType, $identifier));
 }