Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 130 lines (121 sloc) 4.595 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
<?php

namespace Gedmo;

use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\ORM\Mapping\Driver as DriverORM;
use Doctrine\ODM\MongoDB\Mapping\Driver as DriverMongodbODM;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Cache\ArrayCache;

/**
* Version class allows to checking the dependencies required
* and the current version of doctrine extensions
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @subpackage DoctrineExtensions
* @package Gedmo
* @link http://www.gediminasm.org
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
final class DoctrineExtensions
{
    /**
* Current version of extensions
*/
    const VERSION = '2.3.0-DEV';

    /**
* Flag if annotations were included into registry
* allready
*
* @var boolean
*/
    private static $autoloaded = false;

    /**
* Hooks all extensions metadata mapping drivers
* into given $driverChain of drivers for ORM
*
* @param \Doctrine\ORM\Mapping\Driver\DriverChain $driverChain
* @param \Doctrine\Common\Annotations\Reader $reader
*/
    public static function registerMappingIntoDriverChainORM(DriverORM\DriverChain $driverChain, Reader $reader = null)
    {
        self::registerAnnotations();
        if (!$reader) {
            $reader = new CachedReader(new AnnotationReader, new ArrayCache);
        }
        $annotationDriver = new DriverORM\AnnotationDriver($reader, array(
            __DIR__.'/Translatable/Entity',
            __DIR__.'/Loggable/Entity',
            __DIR__.'/Tree/Entity',
        ));
        $driverChain->addDriver($annotationDriver, 'Gedmo');
    }

    /**
* Hooks only superclass metadata mapping drivers
* into given $driverChain of drivers for ORM
*
* @param \Doctrine\ORM\Mapping\Driver\DriverChain $chain
* @param \Doctrine\Common\Annotations\Reader $reader
*/
    public static function registerAbstractMappingIntoDriverChainORM(DriverORM\DriverChain $driverChain, Reader $reader = null)
    {
        self::registerAnnotations();
        if (!$reader) {
            $reader = new CachedReader(new AnnotationReader, new ArrayCache);
        }
        $annotationDriver = new DriverORM\AnnotationDriver($reader, array(
            __DIR__.'/Translatable/Entity/MappedSuperclass',
            __DIR__.'/Loggable/Entity/MappedSuperclass',
            __DIR__.'/Tree/Entity/MappedSuperclass',
        ));
        $driverChain->addDriver($annotationDriver, 'Gedmo');
    }

    /**
* Hooks all extensions metadata mapping drivers
* into given $driverChain of drivers for ODM MongoDB
*
* @param \Doctrine\ODM\MongoDB\Mapping\Driver\DriverChain $driverChain
* @param \Doctrine\Common\Annotations\Reader $reader
*/
    public static function registerMappingIntoDriverChainMongodbODM(DriverMongodbODM\DriverChain $driverChain, Reader $reader = null)
    {
        self::registerAnnotations();
        if (!$reader) {
            $reader = new CachedReader(new AnnotationReader, new ArrayCache);
        }
        $annotationDriver = new DriverMongodbODM\AnnotationDriver($reader, array(
            __DIR__.'/Translatable/Document',
            __DIR__.'/Loggable/Document',
        ));
        $driverChain->addDriver($annotationDriver, 'Gedmo');
    }

    /**
* Hooks only superclass metadata mapping drivers
* into given $driverChain of drivers for ODM MongoDB
*
* @param \Doctrine\ODM\MongoDB\Mapping\Driver\DriverChain $driverChain
* @param \Doctrine\Common\Annotations\Reader $reader
*/
    public static function registerAbstractMappingIntoDriverChainMongodbODM(DriverMongodbODM\DriverChain $driverChain, Reader $reader = null)
    {
        self::registerAnnotations();
        if (!$reader) {
            $reader = new CachedReader(new AnnotationReader, new ArrayCache);
        }
        $annotationDriver = new DriverMongodbODM\AnnotationDriver($reader, array(
            __DIR__.'/Translatable/Document/MappedSuperclass',
            __DIR__.'/Loggable/Document/MappedSuperclass',
        ));
        $driverChain->addDriver($annotationDriver, 'Gedmo');
    }

    /**
* Includes all extension annotations once
*/
    public static function registerAnnotations()
    {
        if (!self::$autoloaded) {
            AnnotationRegistry::registerFile(__DIR__.'/Mapping/Annotation/All.php');
            self::$autoloaded = true;
        }
    }
}
Something went wrong with that request. Please try again.