Пример #1
0
 /**
  * Checks if the passed value is valid.
  *
  * @param mixed      $value      The value that should be validated
  * @param Constraint $constraint The constraint for the validation
  */
 public function validate($value, Constraint $constraint)
 {
     /**
      * @var LocationData $location
      */
     try {
         $location = $this->locationProvider->getLocation($value);
     } catch (EntityNotFoundException $e) {
         $location = null;
     }
     if (!$location instanceof LocationData || 'city' != $location->getType()) {
         $this->context->addViolation('Select a city');
     }
 }
Пример #2
0
 /**
  * Get the full location info given it's id.
  *
  * @return Response Data serialized in json
  */
 public function getLocationAction()
 {
     $id = $this->request->query->get('id');
     return $this->createResponseObject(function () use($id) {
         return $this->normalizeLocationData($this->locationProvider->getLocation($id));
     });
 }
 /**
  * Test get location not found
  */
 public function testGetLocationNotFound()
 {
     $this->setExpectedException('Doctrine\\ORM\\EntityNotFoundException');
     $this->locationProviderAdapter->getLocation('UNEXISTENT');
 }