예제 #1
0
 /**
  * Returns the Document instance defined by the arguments 'database' and 'identifier' and will throw an exception if
  * none is found and graceful is FALSE
  *
  * @param InputInterface $input
  * @param bool           $graceful
  * @return DocumentInterface
  */
 protected function findDataInstanceFromInput(InputInterface $input, $graceful = FALSE)
 {
     $objectIdentifier = $input->getArgument('identifier');
     GeneralUtility::assertDataIdentifier($objectIdentifier);
     $database = $this->findDatabaseInstanceFromInput($input);
     $document = $database->findByIdentifier($objectIdentifier);
     if (!$document && !$graceful) {
         throw new InvalidDataException(sprintf('Object with ID "%s" not found in database %s', $objectIdentifier, $database->getIdentifier()));
     }
     return $document;
 }
예제 #2
0
 /**
  * Create a new RequestInfo object
  *
  * @param Request $request
  * @param string $dataIdentifier
  * @param string $databaseIdentifier
  * @param string $method
  * @param string $specialHandlerAction
  */
 function __construct($request, $dataIdentifier, $databaseIdentifier, $method, $specialHandlerAction = NULL)
 {
     if ($method) {
         GeneralUtility::assertRequestMethod($method);
     }
     if ($dataIdentifier) {
         GeneralUtility::assertDataIdentifier($dataIdentifier);
     }
     if ($databaseIdentifier) {
         GeneralUtility::assertDatabaseIdentifier($databaseIdentifier);
     }
     $this->method = $method;
     $this->dataIdentifier = $dataIdentifier;
     $this->databaseIdentifier = $databaseIdentifier;
     $this->specialHandlerAction = $specialHandlerAction ?: NULL;
     $this->request = $request;
 }
예제 #3
0
 /**
  * @test
  */
 public function assertDataIdentifierTest()
 {
     GeneralUtility::assertDataIdentifier('daniel');
     GeneralUtility::assertDataIdentifier('*****@*****.**');
     GeneralUtility::assertDataIdentifier('543fb69d448766d1eeb2c62a');
     $crashed = FALSE;
     try {
         GeneralUtility::assertDataIdentifier('');
     } catch (InvalidDataIdentifierException $exception) {
         $crashed = TRUE;
     }
     $this->assertTrue($crashed);
     $crashed = FALSE;
     try {
         GeneralUtility::assertDataIdentifier('_543fb69d448766d1eeb2c62a');
     } catch (InvalidDataIdentifierException $exception) {
         $crashed = TRUE;
     }
     $this->assertTrue($crashed);
     $crashed = FALSE;
     try {
         GeneralUtility::assertDataIdentifier('@543fb69d448766d1eeb2c62a');
     } catch (InvalidDataIdentifierException $exception) {
         $crashed = TRUE;
     }
     $this->assertTrue($crashed);
     $crashed = FALSE;
     try {
         GeneralUtility::assertDataIdentifier('.543fb69d448766d1eeb2c62a');
     } catch (InvalidDataIdentifierException $exception) {
         $crashed = TRUE;
     }
     $this->assertTrue($crashed);
     $crashed = FALSE;
     try {
         GeneralUtility::assertDataIdentifier('-543fb69d448766d1eeb2c62a');
     } catch (InvalidDataIdentifierException $exception) {
         $crashed = TRUE;
     }
     $this->assertTrue($crashed);
     $crashed = FALSE;
     try {
         GeneralUtility::assertDataIdentifier('_543fb69d448766d1eeb2c62a');
     } catch (InvalidDataIdentifierException $exception) {
         $crashed = TRUE;
     }
     $this->assertTrue($crashed);
     $crashed = FALSE;
     try {
         GeneralUtility::assertDataIdentifier('ä43fbä69d448766d1eeb2c62a');
     } catch (InvalidDataIdentifierException $exception) {
         $crashed = TRUE;
     }
     $this->assertTrue($crashed);
     $crashed = FALSE;
     try {
         GeneralUtility::assertDataIdentifier('43fbä69d448766d1eeb2c62a');
     } catch (InvalidDataIdentifierException $exception) {
         $crashed = TRUE;
     }
     $this->assertTrue($crashed);
 }