Пример #1
0
 /**
  * Tests toArray method
  *
  * @author kjdev
  * @since  2013-07-18
  */
 public function testConfigToArray()
 {
     $this->specify("Transform Config to the array does not returns the expected result", function () {
         $expected = ['test' => ['parent' => ['property' => 1, 'property2' => 'yeah', 'property3' => ['baseuri' => '/phalcon/'], 'property4' => ['models' => ['metadata' => 'memory']], 'property5' => ['database' => ['adapter' => 'mysql', 'host' => 'localhost', 'username' => 'user', 'password' => 'passwd', 'name' => 'demo']], 'property6' => ['test' => ['a', 'b', 'c']]]]];
         $config = new Ini(PATH_DATA . 'config/directive.ini');
         expect($config->toArray())->equals($expected);
     });
 }
Пример #2
0
 /**
  * Registers services related to the module
  *
  * @param DiInterface $di
  */
 public function registerServices(DiInterface $di)
 {
     /**
      * Read configuration
      */
     $config = new Ini(APP_PATH . "/apps/admin/config/config.ini");
     /**
      * Setting up the view component
      */
     $di['view'] = function () {
         $view = new View();
         $view->setViewsDir(__DIR__ . '/views/');
         return $view;
     };
     /**
      * Database connection is created based in the parameters defined in the configuration file
      */
     $di['db'] = function () use($config) {
         return new DbAdapter($config->toArray());
     };
 }
Пример #3
0
 public function initializeServices()
 {
     $this->set(ServiceManager::CONFIG, function () {
         $files = array('dirs' => CORE_PATH . 'config/dirs.ini.php', 'db' => CORE_PATH . 'config/db.ini.php', 'smtp' => CORE_PATH . 'config/smtp.ini.php');
         $app = new ConfigIni(CORE_PATH . 'config/app.ini.php');
         foreach ($files as $file) {
             if (file_exists($file)) {
                 $c = new ConfigIni($file);
                 $app->merge($c);
             }
         }
         $this->set(ServiceManager::VIEW_JS, function () {
             $simple = new \Phalcon\Mvc\View\Simple();
             $simple->registerEngines(array(".js" => "Thunderhawk\\API\\Mvc\\View\\Engine\\VoltJs"));
             return $simple;
         }, true);
         //$dirs = new ConfigIni ( $files['dirs'] );
         //$db = new ConfigIni ( CORE_PATH . 'config/db.ini.php' );
         //$smtp = new ConfigIni ( CORE_PATH . 'config/smtp.ini.php' );
         if (file_exists(CORE_PATH . 'config/modules.ser')) {
             $modulesInstalled = unserialize(file_get_contents(CORE_PATH . 'config/modules.ser'));
         } else {
             require CORE_PATH . 'config/modules.php';
         }
         $modules = new ConfigArray($modulesInstalled);
         //file_put_contents(CORE_PATH.'config/modules.ser', serialize($modulesInstalled));
         //$app->merge ( $dirs );
         //$app->merge ( $db );
         $app->merge($modules);
         //$app->merge ( $smtp );
         return $app;
     }, true);
     //require CORE_PATH . 'core/config/services.php';
     require CORE_PATH . 'config/services.php';
     foreach ($services as $service => $function) {
         $this->set($service, $function, true);
     }
 }
Пример #4
0
<?php

error_reporting(E_ALL);
$_GET['_url'] = $_SERVER['REQUEST_URI'];
use Phalcon\Mvc\Application;
use Phalcon\Config\Adapter\Ini as ConfigIni;
try {
    define('APP_PATH', realpath('..') . '/');
    /**
     * Read the configuration
     */
    $config = new ConfigIni(APP_PATH . 'app/config/config.ini');
    if (is_readable(APP_PATH . 'app/config/config.ini.dev')) {
        $override = new ConfigIni(APP_PATH . 'app/config/config.ini.dev');
        $config->merge($override);
    }
    /**
     * Auto-loader configuration
     */
    require APP_PATH . 'app/config/loader.php';
    /**
     * Load application services
     */
    require APP_PATH . 'app/config/services.php';
    $application = new Application($di);
    echo $application->handle()->getContent();
} catch (Exception $e) {
    echo $e->getMessage() . '<br>';
    echo '<pre>' . $e->getTraceAsString() . '</pre>';
}
Пример #5
0
 /**
  * @expectedException \Phalcon\Acl\Exception
  * @expectedExceptionMessage Role "user" cannot inherit non-existent role "nonexistentrole".
  * Either such role does not exist or it is set to be inherited before it is actually defined.
  */
 public function testFactoryShouldThrowExceptionIfNonExistentInheritRoleIsSet()
 {
     $config = new Ini(INCUBATOR_FIXTURES . 'Acl/acl.ini');
     $config->acl->role->user->inherit = 'nonexistentrole';
     $factory = new MemoryFactory();
     $factory->create($config->get('acl'));
 }