Exemple #1
0
 function __construct()
 {
     /** @var Config $config */
     $config = ContainerEnvironment::get('config');
     $config = $config->get('database');
     $this->pdo = new PDO("mysql:dbname={$config['dbname']};host=localhost", $config['user'], $config['password']);
 }
 public function __construct()
 {
     /** @var Environment $env */
     $env = ContainerEnvironment::get('env');
     $loader = new Twig_Loader_Filesystem($env->getRoot() . '/Resources/views');
     /** @var Config $config */
     $config = $env->getContainer()->get('config')->get('twig');
     if ($config['cache'] === true) {
         $twig = new Twig_Environment($loader, array('cache' => $env->getRoot() . '/cache/twig'));
     } else {
         $twig = new Twig_Environment($loader);
     }
     $this->setTwig($twig);
 }
 private function parseFromDirectory()
 {
     /** @var Finder $finder */
     $finder = ContainerEnvironment::get('symfony.finder', true);
     /** @var Environment $env */
     $env = ContainerEnvironment::get('env');
     $finder->files()->in($env->getRoot() . '/Repository')->name('*.php');
     /** @var SplFileInfo $file */
     foreach ($finder as $file) {
         $className = 'Repository\\' . str_replace('.php', '', $file->getFilename());
         $repository = $this->repositoryFactory->create($className, $this);
         self::$repositories[$repository->getName()] = $repository;
     }
     return self::$repositories;
 }
Exemple #4
0
 /**
  * @return $this
  */
 public function setup()
 {
     $this->container = new ContainerEnvironment();
     $this->container->register($this, 'env');
     $this->container->register(new Finder(), 'symfony.finder');
     $this->container->register(new Parser(), 'symfony.yaml');
     /** @var Config $config */
     $config = $this->container->register(new Config());
     $config->loadEnvironmentConfig();
     /** @var Connection $connection */
     $connection = $this->container->register(new Connection());
     /** @var RepositoryBuilder $repositoryBuilder */
     $repositoryBuilder = $this->container->register(new RepositoryBuilder($connection));
     $repositoryBuilder->buildRepositories();
     $this->container->register(new TemplateEngine());
     //        TODO Create routing component
     if (!is_dir($this->root)) {
         throw new \InvalidArgumentException("The directory '{$this->root}' does not exist.");
     }
     return $this;
 }
Exemple #5
0
 public function loadEnvironmentConfig()
 {
     /** @var Environment $env */
     $env = ContainerEnvironment::get('env');
     /** @var Finder $finder */
     $finder = $env->getContainer()->get('symfony.finder');
     /** @var Parser $parser */
     $parser = $env->getContainer()->get('symfony.yaml');
     $finder->files()->in($env->getRoot() . 'Resources/config')->name('*.yml');
     /** @var SplFileInfo $file */
     foreach ($finder as $file) {
         $config = $parser->parse($file->getContents());
         if (!empty($config)) {
             foreach ($config as $key => $var) {
                 $this->storage[$key] = $var;
             }
         }
     }
 }
Exemple #6
0
 public function getRepository($name)
 {
     return $this->container->get('repository_builder')->getRepository($name);
 }