public static function bootstrapAutoloading()
 {
     if (!self::$bootstrapped) {
         self::$bootstrapped = true;
         require_once __DIR__ . '/../vendor/doctrine-orm/lib/Doctrine/ORM/Tools/Setup.php';
         \Doctrine\ORM\Tools\Setup::registerAutoloadGit(__DIR__ . '/../vendor/doctrine-orm/');
         \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . "/../vendor/doctrine-orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
     }
 }
예제 #2
0
 /**
  * Setup system, not included in benchmark.
  */
 public function setUp()
 {
     require_once $this->rootPath . "/lib/Doctrine/ORM/Version.php";
     if (version_compare(\Doctrine\ORM\Version::VERSION, '2.3.99') > 0) {
         require_once $this->rootPath . "/vendor/autoload.php";
         $config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/Orm"));
     } else {
         if (version_compare(\Doctrine\ORM\Version::VERSION, '2.2.99') > 0) {
             require_once $this->rootPath . "/lib/Doctrine/ORM/Tools/Setup.php";
             \Doctrine\ORM\Tools\Setup::registerAutoloadGit($this->rootPath);
             $config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/Orm"));
         } else {
             require_once $this->rootPath . "/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php";
             $loader = new \Doctrine\Common\ClassLoader("Doctrine\\ORM", $this->rootPath . "/lib/");
             $loader->register();
             $loader = new \Doctrine\Common\ClassLoader("Doctrine\\DBAL", $this->rootPath . "/lib/vendor/doctrine-dbal/lib");
             $loader->register();
             $loader = new \Doctrine\Common\ClassLoader("Doctrine\\Common", $this->rootPath . "/lib/vendor/doctrine-common/lib");
             $loader->register();
             $config = new \Doctrine\ORM\Configuration();
             $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(__DIR__ . "/Orm"));
         }
     }
     $cache = new \Doctrine\Common\Cache\ArrayCache();
     $this->queryCount = new DbalQueryCountLogger();
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     // not sql query cache, but dql query parsing cache.
     $config->setProxyDir(__DIR__ . "/proxies");
     $config->setProxyNamespace('Proxies');
     $config->setAutoGenerateProxyClasses(false);
     $config->setSQLLogger($this->queryCount);
     $dbParams = array('driver' => 'pdo_sqlite', 'memory' => true);
     $this->em = \Doctrine\ORM\EntityManager::create($dbParams, $config);
     $classes = $this->em->getMetadataFactory()->getAllMetadata();
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     try {
         $schemaTool->dropSchema($classes);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     $schemaTool->createSchema($classes);
     $this->em->getProxyFactory()->generateProxyClasses($classes, __DIR__ . '/proxies');
 }
예제 #3
0
파일: SetupTest.php 프로젝트: rfc1483/padel
 public function testGitAutoload()
 {
     Setup::registerAutoloadGit(__DIR__ . "/../../../../../");
     $this->assertEquals($this->originalAutoloaderCount + 4, count(spl_autoload_functions()));
 }
<?php

$vendorOrm = __DIR__ . '/../vendor/doctrine-orm';
require_once $vendorOrm . '/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
require_once $vendorOrm . '/lib/Doctrine/ORM/Tools/Setup.php';
\Doctrine\ORM\Tools\Setup::registerAutoloadGit($vendorOrm);
/**
 * Typo3, Extbase and Extension Autoloading
 */
spl_autoload_register(function ($class) {
    if (strpos($class, 'Tx_Extbase') === 0) {
        $class = str_replace('Tx_Extbase_', '', $class);
        $dir = __DIR__ . '/../vendor/extbase/Classes';
    } else {
        if (strpos($class, 'Tx_Doctrine2_Tests') === 0) {
            $class = str_replace('Tx_Doctrine2_Tests_', '', $class);
            $dir = __DIR__;
        } else {
            if (strpos($class, 'Tx_Doctrine2') === 0) {
                $class = str_replace('Tx_Doctrine2_', '', $class);
                $dir = __DIR__ . '/../Classes';
            }
        }
    }
    if (isset($class) && isset($dir)) {
        require $dir . '/' . str_replace("_", "/", $class) . '.php';
    }
});
Tx_Doctrine2_Manager::setDevMode(true);
// "Mocking" TYPO3
define('PATH_site', __DIR__);
<?php

// bootstrap.php
use Doctrine\ORM\Tools\Setup, Doctrine\ORM\EntityManager, Doctrine\ORM\Configuration, Doctrine\Common\Cache\ArrayCache as Cache, Doctrine\Common\Annotations\AnnotationRegistry, Doctrine\Common\ClassLoader;
//autoloading
require_once __DIR__ . '/library/doctrine-orm/lib/Doctrine/ORM/Tools/Setup.php';
Setup::registerAutoloadGit(__DIR__ . '/library/doctrine-orm');
$loader = new ClassLoader('Entity', __DIR__ . '/library');
$loader->register();
$loader = new ClassLoader('EntityProxy', __DIR__ . '/library');
$loader->register();
//configuration
$config = new Configuration();
$cache = new Cache();
$config->setQueryCacheImpl($cache);
$config->setProxyDir(__DIR__ . '/library/EntityProxy');
$config->setProxyNamespace('EntityProxy');
$config->setAutoGenerateProxyClasses(true);
//mapping (example uses annotations, could be any of XML/YAML or plain PHP)
AnnotationRegistry::registerFile(__DIR__ . '/library/doctrine-orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
$driver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver(new Doctrine\Common\Annotations\AnnotationReader(), array(__DIR__ . '/library/Entity'));
$config->setMetadataDriverImpl($driver);
$config->setMetadataCacheImpl($cache);
//getting the EntityManager
$em = EntityManager::create(array('driver' => 'pdo_sqlite', 'path' => 'database.sqlite'), $config);
예제 #6
0
<?php

namespace ru\nazarov\sitebase\custom;

$privatePath = $_SERVER['DOCUMENT_ROOT'] . '/../private/';
require_once $privatePath . 'doctrine/lib/Doctrine/ORM/Tools/Setup.php';
\Doctrine\ORM\Tools\Setup::registerAutoloadGit($privatePath . 'doctrine');
class CustomFactory
{
    protected static $_instance;
    protected function __construct()
    {
    }
    public function createView()
    {
        return new SmartyView();
    }
    public function createAjaxView()
    {
        return new AjaxView();
    }
    public function createEntityManager(\stdClass $conf)
    {
        $emConf = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array($conf->entitiesPath), true, $conf->proxiesPath);
        $conn = array('driver' => $conf->dbDriver, 'host' => $conf->dbHost, 'dbname' => $conf->dbName, 'user' => $conf->dbUser, 'password' => $conf->dbPass);
        return \Doctrine\ORM\EntityManager::create($conn, $emConf);
    }
    public static function instance()
    {
        if (self::$_instance == null) {
            self::$_instance = new self();