Ejemplo n.º 1
0
 protected function __construct($directory)
 {
     $this->directory = $directory;
     $this->phpRenderer = new PhpRenderer();
     $resolver = new AggregateResolver();
     $this->phpRenderer->setResolver($resolver);
     $path = Module::getBaseDirectory() . $this->directory;
     $stack = new TemplatePathStack(array('script_paths' => array($path)));
     $resolver->attach($stack);
 }
Ejemplo n.º 2
0
 public static function getEntityManager()
 {
     if (Module::$em == null) {
         $dbconf = self::getDatabaseConfig();
         $modelLocation = __DIR__ . $dbconf["modelLocation"];
         $isDevMode = (bool) $dbconf["isDevMode"];
         $config = Setup::createAnnotationMetadataConfiguration(array($modelLocation), $isDevMode);
         $config->setProxyDir(__DIR__ . $dbconf["proxyLocation"]);
         $config->setAutoGenerateProxyClasses($isDevMode);
         $conn = $dbconf["connection"];
         Module::$em = EntityManager::create($conn, $config);
         Module::registerCustomDoctrineTypes();
     }
     return Module::$em;
 }
Ejemplo n.º 3
0
            exit(0);
        }
    }
}
echo 'The following migrators are run: ' . PHP_EOL;
$new_migrators = array();
foreach ($migrators as $migrator) {
    echo '- ' . $migrator . PHP_EOL;
    $new_migrators[] = $migrator;
}
$migrators = $new_migrators;
// Setup databases
echo "Connecting to databases...\n";
$eve_connection = \Eve\Module::getDatabaseConfig()['eve_connection'];
$evedbo_conn = new PDO($eve_connection['dsn'], $eve_connection['user'], $eve_connection['password']);
$connection = \Eve\Module::getDatabaseConfig()['connection'];
$neweve_conn = pg_connect('host=' . $connection['host'] . ' ' . 'user='******'user'] . ' ' . 'password='******'password'] . ' ' . 'dbname=neweve');
echo "Successfully connected to databases.\n";
// Do actual migrations
echo "Beginning transaction...\n";
pg_query($neweve_conn, "BEGIN TRANSACTION");
pg_query($neweve_conn, "SET CONSTRAINTS ALL DEFERRED");
$failure = false;
$result_now = pg_query($neweve_conn, "SELECT NOW()");
$now = pg_fetch_row($result_now)[0];
echo "Transaction starting time: " . $now . PHP_EOL;
if (isset($options['create-tables']) && !$options['create-tables']) {
    $source_sql_filename = '/sql/neweve.sql';
    echo 'Creating all tables...' . PHP_EOL;
    $source_sql = file_get_contents(getcwd() . $source_sql_filename);
    $failure = !pg_query($neweve_conn, $source_sql);
Ejemplo n.º 4
0
 public function __construct()
 {
     $this->em = \Eve\Module::getEntityManager();
 }
Ejemplo n.º 5
0
<?php

chdir(dirname(__DIR__));
// Setup autoloading
require_once 'init_autoloader.php';
Zend\Mvc\Application::init(require 'config/application.config.php');
use Celaeno\ORM\Types\DateTimeMsType;
use Eve\Model;
use Eve\Model\Repositories;
/** @var $em \Doctrine\ORM\EntityManager */
$em = \Eve\Module::getEntityManager();
function listAll(\Doctrine\ORM\EntityManager $em, $model_name)
{
    $repo = $em->getRepository($model_name);
    $entities = $repo->findBy(array(), array('name' => 'ASC'), 10);
    foreach ($entities as $entity) {
        echo $entity . PHP_EOL;
    }
}
// Actual testing
try {
    listAll($em, '\\Eve\\Model\\Item');
} catch (Exception $e) {
    echo $e->getMessage() . PHP_EOL;
}
echo "Done." . PHP_EOL;