dev-master
9999999-devEntity Manager Generator bundle for Symfony 2
MIT
The Requires
by Ludovic Bouguerra
doctrine entity manager
Entity Manager Generator bundle for Symfony 2
Entity Manager Generator for Symfony 2, (*2)
Works only with bundles with a services.xml config file. Next release will support the other format., (*3)
Installation :, (*4)
Add this line on your composer.json require, (*5)
"activpik/entity-manager-generator-bundle": "dev-master"
Update your deps with composer, (*6)
php composer.phar update
Update your AppKernel File :, (*7)
$bundles = array( ... new Activpik\EntityManagerGeneratorBundle\ActivpikEntityManagerGeneratorBundle(), ... );
Usage, (*8)
php app/console doctrine:generate:entitymanager ActivpikManagerBundle:Video
This command generates an VideoManager class in the same directory of your Video Entity., (*9)
Calling the entity manager in a controller :, (*10)
$this->get("activpik_manager.video_manager");
Get the Doctrine Entity Repository, (*11)
$this->get("activpik_manager.video_manager")->getRepository();
What is generated by this tool : A Basic Entity Manager in the Entity Directory, (*12)
For our previous sample the result is : In src/Activpik/ManagerBundle/Entity/VideoManager.php, (*13)
<?php namespace Activpik\ManagerBundle\Entity; use Doctrine\ORM\EntityManager; class VideoManager { protected $em; public function __construct(EntityManager $em) { $this->em = $em; } public function save(Video $entity){ $this->em->persist($entity); $this->em->flush(); } public function getRepository(){ return $this->em->getRepository('ActivpikManagerBundle:Video'); } }
In service.xml we add theses line, (*14)
<parameters> ... <parameter key="activpik_manager.video_manager.class">Activpik\ManagerBundle\Entity\VideoManager</parameter> ... </parameters> <services> ... <service id="activpik_manager.video_manager" class="%activpik_manager.video_manager.class%"><argument type="service" id="doctrine.orm.entity_manager"/></service> ... </services>
Entity Manager Generator bundle for Symfony 2
MIT
doctrine entity manager