Skip to content

Commit df92455

Browse files
committed
feat: Adds Doctrine attributes to map common Location properties
Adds additionnal attributes to be able to automatically map them to Doctrine entities.
1 parent c463452 commit df92455

17 files changed

Lines changed: 342 additions & 17 deletions

src/Doctrine/ORM/GeocodeEntityListener.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ private function geocodeEntity(ClassMetadata $metadata, object $entity): void
107107
$result = $results->first();
108108
$metadata->latitudeProperty?->setValue($entity, $result->getCoordinates()->getLatitude());
109109
$metadata->longitudeProperty?->setValue($entity, $result->getCoordinates()->getLongitude());
110+
$metadata->northProperty?->setValue($entity, $result->getBounds()?->getNorth());
111+
$metadata->southProperty?->setValue($entity, $result->getBounds()?->getSouth());
112+
$metadata->eastProperty?->setValue($entity, $result->getBounds()?->getEast());
113+
$metadata->westProperty?->setValue($entity, $result->getBounds()?->getWest());
114+
$metadata->streetNumberProperty?->setValue($entity, $result->getStreetNumber());
115+
$metadata->streetNameProperty?->setValue($entity, $result->getStreetName());
116+
$metadata->localityProperty?->setValue($entity, $result->getLocality());
117+
$metadata->postalCodeProperty?->setValue($entity, $result->getPostalCode());
118+
$metadata->subLocalityProperty?->setValue($entity, $result->getSubLocality());
119+
$metadata->countryProperty?->setValue($entity, $result->getCountry());
110120
}
111121
}
112122

src/Mapping/Attributes/Country.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class Country
15+
{
16+
}

src/Mapping/Attributes/East.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class East
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class Locality
15+
{
16+
}

src/Mapping/Attributes/North.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class North
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class PostalCode
15+
{
16+
}

src/Mapping/Attributes/South.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class South
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class StreetName
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class StreetNumber
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BazingaGeocoderBundle package.
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @license MIT License
9+
*/
10+
11+
namespace Bazinga\GeocoderBundle\Mapping\Attributes;
12+
13+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14+
class SubLocality
15+
{
16+
}

0 commit comments

Comments
 (0)