本文整理汇总了PHP中App::config方法的典型用法代码示例。如果您正苦于以下问题:PHP App::config方法的具体用法?PHP App::config怎么用?PHP App::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createApplication
/**
* @param string $config
*
* @return \Songbird\App
*/
public static function createApplication($config = '')
{
$app = new App(require __DIR__ . '/../config/di.php');
$app->add('Config', new Config($config));
$app->add('Symfony\\Component\\HttpFoundation\\Response', new Response());
$app->add('Symfony\\Component\\HttpFoundation\\Request', Request::createFromGlobals());
$app->add('Filesystem', 'League\\Flysystem\\Filesystem')->withArgument(new CachedAdapter(new Adapter($app->config('app.paths.resources')), new CacheStore()));
$app->get('Logger')->pushHandler(new StreamHandler(vsprintf('%s/songbird-%s.log', [$app->config('app.paths.log'), date('Y-d-m')]), Logger::INFO));
$app->inflector('League\\Container\\ContainerAwareInterface')->invokeMethod('setContainer', [$app]);
$app->inflector('League\\Event\\EmitterAwareInterface')->invokeMethod('setEmitter', [$app->get('Emitter')]);
$app->inflector('Psr\\Log\\LoggerAwareInterface')->invokeMethod('setLogger', [$app->get('Logger')]);
$app->inflector('Songbird\\FilesystemAwareInterface')->invokeMethod('setFilesystem', ['Filesystem']);
$app->add('Repository', $app->get('RepositoryFactory')->createContentRepository());
return $app;
}
示例2: getConfig
public static function getConfig($key)
{
if (self::$config === null) {
self::$config = (include_once 'app/config/main.php');
}
return isset(self::$config[$key]) ? self::$config[$key] : false;
}
示例3: start
public static function start()
{
self::configuration(json_decode(App::config()->file('Sessions.sessions.json')->read(), true));
if (session_status() == PHP_SESSION_NONE) {
ini_set('session.cookie_httponly', true);
//start session
//set session name
session_name(self::$_sessionName);
session_start();
//generate key
Session::generate(self::$_userSessionsKey);
Cookie::generate(self::$_userCookiesKey);
//check initiated status
if (intval(Session::get(self::$_initiatedKey)) == 0) {
//regen
session_regenerate_id();
Session::generate(self::$_userSessionsKey);
Session::set(self::$_initiatedKey, 1);
}
//check for corresponding user agent on same session
if (Session::get(self::$_userAgentKey) !== false) {
if (Session::get(self::$_userAgentKey) != hash('sha512', $_SERVER['HTTP_USER_AGENT'] . self::$_salt)) {
//invalid user agent detected
self::destroy();
die;
}
} else {
Session::set(self::$_userAgentKey, hash('sha512', $_SERVER['HTTP_USER_AGENT'] . self::$_salt));
}
}
}
示例4: __construct
public function __construct()
{
include 'config/config.php';
include 'core/Controller.php';
self::$config = $config;
$this->route();
}
示例5: init
static function init()
{
$version_file = APP_PATH . '/../version';
if (file_exists($version_file)) {
self::$version = trim(@file_get_contents($version_file));
}
$config_file = APP_PATH . '/config/config.php';
if (!file_exists($config_file)) {
throw new Exception("No config file");
}
$config = (include $config_file);
self::$config = $config;
self::$env = $config['env'];
#self::$context = new stdClass();
self::$context = new Context();
Logger::init($config['logger']);
if (isset($config['db'])) {
Db::init($config['db']);
}
if (get_magic_quotes_gpc()) {
foreach ($_GET as $k => $v) {
$_GET[$k] = Text::stripslashes($v);
}
foreach ($_POST as $k => $v) {
$_POST[$k] = Text::stripslashes($v);
}
foreach ($_COOKIE as $k => $v) {
$_COOKIE[$k] = Text::stripslashes($v);
}
}
$_REQUEST = $_GET + $_POST + $_COOKIE;
}
示例6: run
/**
* 运行应用实例
* @access public
* @return void
*/
public function run()
{
//引入编译、缓存过的引入文件
$compiledIncFile = $this->getCompiledIncFileName();
if (App::config('compile_include_files') && is_file($compiledIncFile)) {
self::$includeFiles = (require $compiledIncFile);
}
//检测控制器文件是否存在
if (!is_file(APP_PATH . '/controller/' . self::$controller . 'Controller.class.php')) {
die("<h1>Invalid Request</h1>\nController <strong>" . self::$controller . "</strong> not found.");
}
//导入必需文件
irequire(PHPFW_PATH . '/common/common.php');
is_file(APP_PATH . '/common/common.php') && irequire(APP_PATH . '/common/common.php');
irequire(PHPFW_PATH . '/core/Controller.class.php');
irequire(APP_PATH . '/controller/' . self::$controller . 'Controller.class.php');
//实例化控制器并运行
$controllerName = self::$controller . 'Controller';
$controller = new $controllerName();
$controller->run(self::$action);
//编译、缓存 引入文件
if (App::config('compile_include_files') && !is_file($compiledIncFile)) {
$this->compileIncFiles();
}
}
示例7: create
/**
* @param DownloadTokenModel $downloadToken
* @return DownloadTokenModel
*/
public function create(models\ModelAbstract $downloadToken)
{
if (!$downloadToken instanceof DownloadTokenModel) {
throw new InvalidArgumentException('Supplied data must be a download token model');
}
$downloadToken->token = UserService::getInstance()->generatePassword(60);
$brandService = BrandService::getInstance();
$brand = $brandService->loadByOrganization(\App::getOrgUserLogged());
$router = \Zend_Controller_Front::getInstance()->getRouter();
$downloadToken->url = $brand->endPoint . $router->assemble(array('controller' => $downloadToken->controller, 'action' => $downloadToken->action, 'token' => $downloadToken->token), 'downloadToken');
$downloadToken->orgId = \App::getOrgUserLogged()->getId();
$downloadToken->expireDatetime = \App::config('downloadTokenLifeTime', "+1 day");
$ident = \Zend_Auth::getInstance()->getIdentity();
if (isset($ident['username'])) {
$downloadToken->username = $ident['username'];
}
if (isset($ident['authType'])) {
$downloadToken->authType = $ident['authType'];
}
if (isset($ident['apiId'])) {
$downloadToken->apiId = $ident['apiId'];
}
if (isset($ident['impersonation'])) {
$downloadToken->impersonation = $ident['impersonation'];
}
return parent::create($downloadToken);
}
示例8: __construct
protected function __construct($config)
{
if (count($config) != 4) {
throw new \Exception("Le nombre d'arguments n'est pas valable!");
}
self::$config = $config;
}
示例9: setUp
public function setUp()
{
$this->_watcherService = WatcherService::getInstance();
$this->_txId = uniqid('test-', true);
$user = \App::getUserLogged();
$this->_watcher = new WatcherModel();
$this->_watcher->scope = 'user';
$this->_watcher->scopeId = $user->id;
$this->_watcher->owner = $user->id;
$this->_watcher->namespace = 'connectivity';
$this->_watcher->entityType = 'transaction';
$this->_watcher->entityIds = array($this->_txId);
$this->_watcher->transport = 'popbox';
$this->_watcher->priority = WatcherModel::PRIORITY_LOW;
$this->_watcher->status = WatcherModel::STATUS_ACTIVE;
$this->_watcher->expire = strtotime(\App::config('watchers.expire', "+1 day"));
$this->_watcher->remove = strtotime(\App::config('watchers.autoremove', "+6 months"));
$this->_watcher->tags = array('context_' . $user->getOrganizationId());
$this->_watcher->maxEvents = 1;
$this->_watcher->maxEventStackSize = 1;
$this->_watcher->params = new StructConfigModel();
$this->_watcher->hiddenParams = new StructConfigModel();
$this->_event = new EventModel();
$this->_event->namespace = 'connectivity';
$this->_event->entityType = 'transaction';
$this->_event->entityId = $this->_txId;
$this->_event->created = time();
$this->_event->modified = time();
$this->_event->pushEventData = true;
}
示例10: _getConfigMaxErrorsBeforeCompress
protected function _getConfigMaxErrorsBeforeCompress()
{
if (!isset($this->_configMaxErrorsBeforeCompress)) {
$this->_configMaxErrorsBeforeCompress = \App::config('watcher.event.maxErrorsBeforeCompress', 15);
}
return $this->_configMaxErrorsBeforeCompress;
}
示例11: close
/**
* close the application, by creating a CLOSED file
* @param string $message the message to display
* @since 1.2
*/
public static function close($message = '')
{
$file = App::configPath('CLOSED');
file_put_contents($file, $message);
if (App::config()) {
chmod($file, App::config()->chmodFile);
}
}
示例12: defaultLoader
/**
* Get the default disco twig loader which enables extension-less template use.
*
*
* @param null|string|array $path The absolute path to the template directory, or an array of directories.
*
* @return \Disco\classes\TemplateLoader
*/
public static function defaultLoader($path = null)
{
if ($path === null) {
$path = \App::path() . '/' . trim(\App::config('TEMPLATE_PATH'), '/');
}
//if
return new \Disco\classes\TemplateLoader($path);
}
示例13: __construct
/**
* 构造方法
*
* @param App $app
*/
public function __construct($app)
{
$this->app = $app;
$this->appConfig = $app->config();
$this->request = $app->request();
$this->response = $app->response();
$app->controller = $this;
}
示例14: getApp
/**
* Get the app. It's a singleton.
* @param array $config The default config
* @return App
*/
public static function getApp($config)
{
if (self::$_app === null) {
self::$config = (include_once $config);
self::$_app = new App();
}
return self::$_app;
}
示例15: hash
/**
* Hash with sha512.
* If no salt is provided the salt stored in `app/config/config.php` with key `SHA512_SALT` will be used as the
* salt value.
*
*
* @param string $value Value to hash using SHA512.
* @param null|string $salt The salt to use in the hash.
*
* @return string The hashed value of $s.
*/
public function hash($value, $salt = '')
{
if ($salt === '') {
$salt = \App::config('SHA512_SALT');
}
//if
return hash('sha512', $salt . $value);
}