예제 #1
0
 /**
  * Shortcut for the application config
  *
  * @param  string      $key     A dot-separated path to a config value
  * @param  string      $default The value to return if the key was not found
  * @return Zend_Config | mixed
  */
 public static function config($key = null, $default = null)
 {
     static $config;
     if (!$config) {
         $config = self::$_application->getOptions();
     }
     // Return the root object if no key is given
     if (empty($key)) {
         return $config;
     }
     // Find the value by following the path given
     $level = $config;
     $parts = explode('.', $key);
     foreach ($parts as $part) {
         if (isset($level[$part])) {
             $level = $level[$part];
         } else {
             if ($default === NULL) {
                 trigger_error('Unable to find config key "' . $key . '"', E_USER_NOTICE);
                 return NULL;
             } else {
                 return $default;
             }
         }
     }
     return $level;
 }
예제 #2
0
 /**
  * Constructor
  *
  * Invoke setContainerFactory, set _coantainerFactory if factory is configurated
  * Ensure FrontController resource is registered
  *
  * @param  Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
  * @return void
  */
 public function __construct($application)
 {
     $this->setContainerFactory($application->getOptions());
     parent::__construct($application);
     if (!$this->hasPluginResource('FrontController')) {
         $this->registerPluginResource('FrontController');
     }
 }
예제 #3
0
 /**
  * @group ZF-6679
  */
 public function testSetOptionsShouldProperlyMergeTwoConfigFileOptions()
 {
     $application = new Zend_Application('production', dirname(__FILE__) . '/_files/zf-6679-1.inc');
     $options = $application->getOptions();
     $this->assertEquals(array('includePaths', 'config'), array_keys($options));
 }
예제 #4
0
파일: index.php 프로젝트: Tony133/zf-web
// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production');
// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(__DIR__ . '/../app'));
if (!defined('APPLICATION_ROOT')) {
    define('APPLICATION_ROOT', realpath(__DIR__ . '/..'));
}
// Application.ini.inc cache file
defined('CONFIG_INC') || define('CONFIG_INC', APPLICATION_ROOT . '/data/cache/' . APPLICATION_ENV . '.ini.inc');
// We use default config if no cache
$configFile = CONFIG_INC;
$noConfigCache = false;
if (false === is_file(CONFIG_INC)) {
    $configFile = APPLICATION_PATH . '/config/application.ini';
    $noConfigCache = true;
}
require_once APPLICATION_PATH . '/global.php';
/** Zend_Application */
require_once 'Zend/Application.php';
require_once 'Zend/Loader/Autoloader.php';
//Zend_Session::writeClose(true); //If you will have problems with sesssions and APC
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, $configFile);
// Create the cache of config if no
// Only for production
if ($noConfigCache and 'production' == APPLICATION_ENV) {
    $configs = '<?php' . PHP_EOL . 'return ' . var_export($application->getOptions(), true) . PHP_EOL . '?>';
    file_put_contents(CONFIG_INC, $configs);
}
$application->bootstrap()->run();
예제 #5
0
파일: index.php 프로젝트: tudorfis/php-api
<?php

/* set crossdomain request */
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS");
header("Access-Control-Allow-Credentials: true");
// Define application environment
if (!isset($_REQUEST['env']) || empty($_REQUEST['env'])) {
    die;
} else {
    define('APPLICATION_DB', $_REQUEST['env']);
}
// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
/* Define application environment */
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$config = $application->getOptions();
$config['resources']['db']['params']['dbname'] = APPLICATION_DB;
$application->setOptions($config)->bootstrap()->run();
예제 #6
0
<?php

if (array_key_exists(1, $argv)) {
    $env = $argv[1];
} else {
    $env = 'production';
}
defined('BASE_PATH') || define('BASE_PATH', realpath(dirname(__FILE__) . '/..'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(BASE_PATH . '/library'), get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$config = array('config' => array(realpath(BASE_PATH . '/configs/application.ini')));
$application = new Zend_Application($env, $config);
$dbConnection = $application->getBootstrap()->bootstrap('Doctrine');
try {
    Doctrine_Core::dropDatabases();
} catch (Doctrine_Connection_Mysql_Exception $e) {
    error_log('The database did not exists');
}
Doctrine_Core::createDatabases();
$options = $application->getOptions();
$ymlPath = realpath(BASE_PATH . '/Scripts/Yaml/Schema/Koryukan.yml');
$modelsOptions = array('suffix' => '.php', 'generateTableClasses' => true, 'classPrefix' => 'Koryukan_Db_', 'classPrefixFiles' => false, 'baseClassPrefix' => 'Base', 'baseClassesDirectory' => '');
Doctrine_Core::generateModelsFromYaml($ymlPath, $options['db']['objectsPath'], $modelsOptions);
Doctrine_Core::createTablesFromModels($options['db']['objectsPath']);
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/news.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/storeItems.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/images.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/security.yml');
예제 #7
0
파일: init.php 프로젝트: knatorski/SMS
if (isset($opts->app_env)) {
    defined('APPLICATION_ENV') || define('APPLICATION_ENV', $opts->app_env);
} else {
    echo "\n\nParametr app_env jest wymagany!";
    echo "\n\n" . $opts->getUsageMessage() . "\n\n";
    exit;
}
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
Base_Controller_Action_Helper_Currentip::$_unitTestEnabled = true;
$application->bootstrap();
$application->getBootstrap()->runForCmd();
Zend_Controller_Front::getInstance()->setParam('bootstrap', $application->getBootstrap());
Zend_registry::set('config', $application->getOptions());
$user = $application->getOption('bin');
$u = new User();
$u_data = $u->fetchAll("login = '******'user'] . "'", "id DESC", 1);
if (null == $u_data) {
    throw new Exception('Brak użytkownika o podanym ID');
}
$u_data = $u_data->toArray();
$storageRow = new stdClass();
foreach ($u_data[0] as $key => $value) {
    $storageRow->{$key} = $value;
}
$auth = Zend_Auth::getInstance();
$storage = $auth->getStorage();
$o = new Branch();
$data = $o->fetchAll("branch_name = '" . $user['branch'] . "'", "id DESC", 1)->toArray();