GithubHelp home page GithubHelp logo

entitymanagergeneratorbundle's Introduction

EntityManagerGeneratorBundle

Build Status

Entity Manager Generator for Symfony 2

Works only with bundles with a services.xml config file. Next release will support the other format.

Installation :

Add this line on your composer.json require

        "activpik/entity-manager-generator-bundle": "dev-master"

Update your deps with composer

	php composer.phar update

Update your AppKernel File :

$bundles = array(
...
new Activpik\EntityManagerGeneratorBundle\ActivpikEntityManagerGeneratorBundle(),
...
);

Usage

php app/console doctrine:generate:entitymanager ActivpikManagerBundle:Video

This command generates an VideoManager class in the same directory of your Video Entity.

Calling the entity manager in a controller :

$this->get("activpik_manager.video_manager");

Get the Doctrine Entity Repository

$this->get("activpik_manager.video_manager")->getRepository();

What is generated by this tool : A Basic Entity Manager in the Entity Directory

For our previous sample the result is : In src/Activpik/ManagerBundle/Entity/VideoManager.php

<?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

<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>

entitymanagergeneratorbundle's People

Contributors

ludovic-bouguerra avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

dprolife

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.