コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function register(MVC $mvc)
 {
     $this->pdo = new PDO($this->options['dsn'], $this->options['user'], $this->options['passwd'], $this->options['driverOptions']);
     if (!$mvc->hasCvpp('pdo')) {
         $mvc->setCvpp('pdo', $this->pdo);
     }
 }
コード例 #2
0
 /**
  * Register the properties of the Doctrine DBAL Provider
  * @access public
  * @param MVC $mvc
  * @return void
  */
 public function register(MVC $mvc)
 {
     if (!$mvc->hasCvpp('dbal')) {
         $mvc->setCvpp('dbal', $this->connection);
     }
     $config = new Configuration();
     $this->connection = DriverManager::getConnection($this->options, $config);
 }
コード例 #3
0
 /**
  * Register the properties of the Twig Framework Provider
  * @access public
  * @param MVC $mvc
  * @return void
  */
 public function register(MVC $mvc)
 {
     $defaultOptions = array('charset' => $mvc->getSetting('charset'), 'debug' => $mvc->getSetting('debug'), 'strict_variables' => $mvc->getSetting('debug'), 'templates_path' => array($mvc->getSetting('templates_path')));
     $options = array_merge($defaultOptions, $this->options);
     $mvc->setCvpp('twig.loader.filesystem', new \Twig_Loader_Filesystem($options['path']));
     $mvc->setCvpp('twig.loader.array', new \Twig_Loader_Array($options['templates_path']));
     # Register templates path modules
     foreach ($mvc->getModules() as $module) {
         $module->registerTemplatesPathTwig($mvc);
     }
     $mvc->setCvpp('twig.loader', new \Twig_Loader_Chain(array($mvc->getCvpp('twig.loader.array'), $mvc->getCvpp('twig.loader.filesystem'))));
     $twig = new \Twig_Environment($mvc->getCvpp('twig.loader'), $options);
     $twig->addGlobal('mvc', $mvc);
     if ($options['debug']) {
         $twig->addExtension(new \Twig_Extension_Debug());
     }
     $mvc->setCvpp('twig', $twig);
 }
コード例 #4
0
 /**
  * Register the properties of the Monolog Provider
  * @access public
  * @param MVC $mvc
  * @return void
  */
 public function register(MVC $mvc)
 {
     $defaultOptions = array('log_file' => $mvc->getAppDir() . '/logs/app_name.log', 'log_name' => 'app_name');
     $options = array_merge($defaultOptions, $this->options);
     $logger = new Logger($options['log_name']);
     $logger->pushHandler(new StreamHandler($options['log_file']));
     if (!$mvc->hasCvpp('monolog')) {
         $mvc->setCvpp('monolog', $logger);
     }
 }
コード例 #5
0
 /**
  * Register the Console Symfony
  *
  * @access public
  * @param MVC $mvc
  */
 public function register(MVC $mvc)
 {
     $application = new Application('Simple PHP MVC', '1.5');
     if (!$mvc->hasCvpp('symfony.console')) {
         $mvc->setCvpp('symfony.console', $application);
     }
     foreach ($this->modules as $module) {
         $module->registerCommands($mvc->getCvpp('symfony.console'));
     }
 }
コード例 #6
0
 /**
  * Register the properties of the Doctrine ORM Provider
  * 
  * @access public
  * @param MVC $mvc
  * @return void
  */
 public function register(MVC $mvc)
 {
     $default_options = array('params' => array('charset' => null, 'driver' => 'pdo_mysql', 'dbname' => null, 'host' => 'localhost', 'user' => 'root', 'password' => null, 'port' => null), 'dev_mode' => false, 'etities_type' => 'annotations', 'path_entities' => array(), 'proxy_dir' => null);
     $options = array_merge($default_options, $this->options);
     if (empty($options['path_entities']) || !is_array($options['path_entities'])) {
         throw new \Exception('Option path_entities should be an array of path files entities.');
     }
     if ($options['etities_type'] == 'annotations') {
         $config = Setup::createAnnotationMetadataConfiguration($options['path_entities'], $options['dev_mode'], $options['proxy_dir']);
     } elseif ($options['etities_type'] == 'yaml' || $options['etities_type'] == 'yml') {
         $config = Setup::createYAMLMetadataConfiguration($options['path_entities'], $options['dev_mode'], $options['proxy_dir']);
     } elseif ($options['etities_type'] == 'xml') {
         $config = Setup::createXMLMetadataConfiguration($options['path_entities'], $options['dev_mode'], $options['proxy_dir']);
     }
     if ($mvc->hasCvpp('dbal')) {
         $entityManager = EntityManager::create($mvc->getCvpp('dbal'), $config);
     } else {
         $entityManager = EntityManager::create($options['params'], $config);
     }
     if (!$mvc->hasCvpp('dbal')) {
         $mvc->setCvpp('dbal', $entityManager->getConnection());
     }
     $mvc->setCvpp('em', $entityManager);
 }