示例#1
0
 /**
  * Creates a new ObjectPathMapping and stores it in the repository
  *
  * @param string $pathSegment
  * @param mixed $identifier
  * @return void
  */
 protected function storeObjectPathMapping($pathSegment, $identifier)
 {
     $objectPathMapping = new \TYPO3\FLOW3\Mvc\Routing\ObjectPathMapping();
     $objectPathMapping->setObjectType($this->objectType);
     $objectPathMapping->setUriPattern($this->getUriPattern());
     $objectPathMapping->setPathSegment($pathSegment);
     $objectPathMapping->setIdentifier($identifier);
     $this->objectPathMappingRepository->add($objectPathMapping);
     // TODO can be removed, when persistence manager has some memory cache
     $this->persistenceManager->persistAll();
 }
示例#2
0
 /**
  * @test
  * @expectedException \TYPO3\FLOW3\Mvc\Exception\InfiniteLoopException
  */
 public function resolveValueThrowsInfiniteLoopExceptionIfNoUniquePathSegmentCantBeFound()
 {
     $object = new \stdClass();
     $this->mockPersistenceManager->expects($this->once())->method('getIdentifierByObject')->with($object)->will($this->returnValue('TheIdentifier'));
     $this->mockObjectPathMappingRepository->expects($this->once())->method('findOneByObjectTypeUriPatternAndIdentifier')->with('stdClass', 'SomeUriPattern', 'TheIdentifier')->will($this->returnValue(NULL));
     $existingObjectPathMapping = new \TYPO3\FLOW3\Mvc\Routing\ObjectPathMapping();
     $existingObjectPathMapping->setObjectType('stdClass');
     $existingObjectPathMapping->setUriPattern('SomeUriPattern');
     $existingObjectPathMapping->setPathSegment('The/Path/Segment');
     $existingObjectPathMapping->setIdentifier('AnotherIdentifier');
     $this->identityRoutePart->expects($this->once())->method('createPathSegmentForObject')->with($object)->will($this->returnValue('The/Path/Segment'));
     $this->mockObjectPathMappingRepository->expects($this->atLeastOnce())->method('findOneByObjectTypeUriPatternAndPathSegment')->will($this->returnValue($existingObjectPathMapping));
     $this->identityRoutePart->setObjectType('stdClass');
     $this->identityRoutePart->setUriPattern('SomeUriPattern');
     $this->identityRoutePart->_call('resolveValue', $object);
 }