mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
update the address fixture by adding some points
This commit is contained in:
parent
e9d142f3e8
commit
c5faa0b99d
@ -29,6 +29,7 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Doctrine\Model\Point;
|
||||
|
||||
/**
|
||||
* Load people into database
|
||||
@ -226,8 +227,24 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
||||
echo "add person'".$p->__toString()."'\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creata a random address
|
||||
* Create a random point
|
||||
*
|
||||
* @return Point
|
||||
*/
|
||||
private function getRandomPoint()
|
||||
{
|
||||
$lonBrussels = 4.35243;
|
||||
$latBrussels = 50.84676;
|
||||
$lon = $lonBrussels + 0.01 * rand(-5, 5);
|
||||
$lat = $latBrussels + 0.01 * rand(-5, 5);
|
||||
return Point::fromLonLat($lon, $lat);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a random address
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
@ -238,6 +255,9 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
||||
->setStreetAddress2(
|
||||
rand(0,9) > 5 ? $this->faker->streetAddress : ''
|
||||
)
|
||||
->setPoint(
|
||||
rand(0,9) > 5 ? $this->getRandomPoint() : NULL
|
||||
)
|
||||
->setPostcode($this->getReference(
|
||||
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]
|
||||
))
|
||||
|
Loading…
x
Reference in New Issue
Block a user