foreverglory/doctrine-manager

v1.0.1 2016-07-30 16:36 UTC

This package is not auto-updated.

Last update: 2024-11-09 20:56:08 UTC


README

Usage

require composer.json

{
    "require": {
        "foreverglory/doctrine-manager": "~1.0"
    }
}

add service

services:
    doctrine.manager.example:
        class: Glory\DoctrineManager\DoctrineManager
        arguments: ['@doctrine']

add ClassName

//src:DependencyInjection/AppExtension.php
namespace AppBundle\DependencyInjection;

class AppExtension extends Extension
{

    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        //通过配置参数,设置manager的class
        $container->getDefinition('doctrine.manager.example')
                ->addMethodCall('setClass', [$config['app_class']]);

    }
}

black code

$this->get('doctrine.manager.example')->find($id);
$this->get('doctrine.manager.example')->findAll();
$this->get('doctrine.manager.example')->findOneBy($criteria);
$this->get('doctrine.manager.example')->findBy($criteria);
$this->get('doctrine.manager.example')->create($properties);
$this->get('doctrine.manager.example')->update($properties);
$this->get('doctrine.manager.example')->delete($properties);
$this->get('doctrine.manager.example')->getManager();
$this->get('doctrine.manager.example')->getRepository();