/** * Test the getGeographicalQueryAnnotation method of the AnnotationDriver. */ public function testGetGeographicalQueryAnnotation() { $this->geographicalQueryAnnotation->expects($this->once())->method('getMethod')->will($this->returnValue('getAddress')); $this->reader->expects($this->once())->method('getMethodAnnotation')->with($this->isInstanceOf('\\ReflectionMethod'), $this->equalTo('Vich\\GeographicalBundle\\Annotation\\GeographicalQuery'))->will($this->returnValue($this->geographicalQueryAnnotation)); $annot = $this->driver->getGeographicalQueryAnnotation($this->geographicalEntity); $this->assertNotNull($annot); $this->assertEquals('getAddress', $annot->getMethod()); }
/** * Update coordinates on objects being updated before update * if they require changing * * @param PreUpdateEventArgs $args The event arguments */ public function preUpdate(PreUpdateEventArgs $args) { $obj = $args->getEntity(); $geographical = $this->driver->getGeographicalAnnotation($obj); if ($geographical && $geographical->getOn() === Geographical::ON_UPDATE) { $geographicalQuery = $this->driver->getGeographicalQueryAnnotation($obj); if ($geographicalQuery) { $this->queryCoordinates($obj, $geographical, $geographicalQuery); } } }