2017 © Pedro Peláez
 

symfony-bundle entity-manager-generator-bundle

Entity Manager Generator bundle for Symfony 2

image

activpik/entity-manager-generator-bundle

Entity Manager Generator bundle for Symfony 2

  • Friday, September 13, 2013
  • by ludovic-bouguerra
  • Repository
  • 2 Watchers
  • 0 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

EntityManagerGeneratorBundle

Build Status, (*1)

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>

The Versions

13/09 2013

dev-master

9999999-dev

Entity Manager Generator bundle for Symfony 2

  Sources   Download

MIT

The Requires

 

by Ludovic Bouguerra

doctrine entity manager