foreverglory / doctrine-manager

doctrine 管理器

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

This package is not auto-updated.

Last update: 2024-09-14 19:58:27 UTC


README

用法

require composer.json

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

添加服务

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

添加类名

//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']]);

    }
}

黑名单代码

$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();