lyssal / simple-location-bundle
The simple location bundle permits create dynamic typed locations (countries, cities, etc).
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ~8
- doctrine/collections: ^2
- doctrine/dbal: ^3
- lyssal/doctrine-extra-bundle: ^0.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
README
The simple location bundle permits create dynamic typed locations.
Installation
composer require lyssal/simple-location-bundle
Usage
Create your Location entity
namespace App\Entity\Location; use Doctrine\ORM\Mapping as ORM; use Lyssal\SimpleLocationBundle\Doctrine\Repository\LocationRepository; use Lyssal\SimpleLocationBundle\Entity\Location as LyssalLocation; #[ORM\Entity(repositoryClass: LocationRepository::class)] class Location extends LyssalLocation { // If you want to add properties }
Exemples of use
$continent = (new LocationType())->setName('Continent'); $country = (new LocationType())->setName('Country')->addParent($continent); $city = (new LocationType())->setName('City')->addParent($country); $europa = (new Location())->setName('Europe')->setType($continent); $america = (new Location())->setName('America')->setType($continent); $asia = (new Location())->setName('Asia')->setType($continent); $france = (new Location())->setName('France')->setType($country)->addParent($europa); $italy = (new Location())->setName('Italy')->setType($country)->addParent($europa); $sovietUnion = (new Location())->setName('Soviet Union')->setType($country)->addParent($europa)->addParent($asia); $paris = (new Location())->setName('Paris')->setType($city)->addParent($france); $countrySet = (new LocationType())->setName('Country set')->addChild($country); $northAmerica = (new Location())->setName('North America')->setType($countrySet)->addParent($america); $usa = (new Location())->setName('United States of America')->setType($country)->addParent($america)->addParent($northAmerica); $europeanUnion = (new Location())->setName('European Union')->setType($countrySet)->addParent($europa)->addChild($france)->addChild($italy); $germany = (new Location())->setName('Germany')->setType($country)->addParent($europa)->addParent($europeanUnion); $westGermany = (new Location())->setName('Federal Republic of Germany')->setType($country)->addParent($germany)->addParent($europa)->addParent($europeanUnion); $eastGermany = (new Location())->setName('German Democratic Republic')->setType($country)->addParent($sovietUnion)->addParent($germany)->addParent($europa);