当前位置: 首页>>代码示例>>PHP>>正文


PHP Environment::set方法代码示例

本文整理汇总了PHP中lithium\core\Environment::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::set方法的具体用法?PHP Environment::set怎么用?PHP Environment::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lithium\core\Environment的用法示例。


在下文中一共展示了Environment::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testEnvironmentalDefaults

 public function testEnvironmentalDefaults()
 {
     $artist = Artists::create(['ja.name' => 'Richard Japper', 'ja.profile' => 'Dreaded Rasta Nihon', 'en.name' => 'Richard', 'en.profile' => 'Dreaded Rasta', 'something_else' => 'Something']);
     Environment::set('test', ['locales' => ['en' => 'English', 'es' => 'Espanol']]);
     $artist->_actsAs = ['Translatable' => ['default' => 'ja', 'fields' => ['name', 'profile']]];
     $this->assertTrue($artist->save());
     $artist = Artists::first();
 }
开发者ID:davidpersson,项目名称:li3_translate,代码行数:8,代码来源:TranslatableTest.php

示例2: set

 public static function set($key, $productionValue, $testValue = null, $developmentValue = null)
 {
     $testValue = $testValue ?: $productionValue;
     $developmentValue = $developmentValue ?: $testValue;
     Environment::set('development', array($key => $developmentValue));
     Environment::set('test', array($key => $testValue));
     Environment::set('production', array($key => $productionValue));
 }
开发者ID:qujian,项目名称:rwe,代码行数:8,代码来源:Constant.php

示例3: _init

 protected function _init()
 {
     parent::_init();
     Environment::set($this->env);
     if (file_exists($this->_config['routes'])) {
         return require $this->_config['routes'];
     }
     $this->error("The routes file for this library doesn't exist or can't be found.");
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:9,代码来源:Route.php

示例4: run

 /**
  * Runs a test group or a specific test file based on the passed
  * parameters.
  *
  * @param string $group If set, this test group is run. If not set, a group test may
  *        also be run by passing the 'group' option to the $options parameter.
  * @param array $options Options array for the test run. Valid options are:
  *        - 'case': The fully namespaced test case to be run.
  *        - 'group': The fully namespaced test group to be run.
  *        - 'filters': An array of filters that the test output should be run through.
  * @return array A compact array of the title, an array of the results, as well
  *         as an additional array of the results after the $options['filters']
  *         have been applied.
  * @filter
  */
 public static function run($group = null, array $options = array())
 {
     $defaults = array('title' => $group, 'filters' => array(), 'reporter' => 'text');
     $options += $defaults;
     $isCase = is_string($group) && preg_match('/Test$/', $group);
     $items = $isCase ? array(new $group()) : (array) $group;
     $options['filters'] = Set::normalize($options['filters']);
     $group = static::_group($items);
     $report = static::_report($group, $options);
     return static::_filter(__FUNCTION__, compact('report'), function ($self, $params, $chain) {
         $environment = Environment::get();
         Environment::set('test');
         $params['report']->run();
         Environment::set($environment);
         return $params['report'];
     });
 }
开发者ID:nashadalam,项目名称:lithium,代码行数:32,代码来源:Dispatcher.php

示例5: run

 /**
  * Dispatches a request based on a request object (an instance of `lithium\console\Request`).
  *  If `$request` is `null`, a new request object is instantiated based on the value of the
  * `'request'` key in the `$_classes` array.
  *
  * @param object $request An instance of a request object with console request information.  If
  *        `null`, an instance will be created.
  * @param array $options
  * @return object The command action result which is an instance of `lithium\console\Response`.
  * @filter
  */
 public static function run($request = null, $options = array())
 {
     $defaults = array('request' => array());
     $options += $defaults;
     $classes = static::$_classes;
     $params = compact('request', 'options');
     return static::_filter(__FUNCTION__, $params, function ($self, $params) use($classes) {
         $request = $params['request'];
         $options = $params['options'];
         $router = $classes['router'];
         $request = $request ?: new $classes['request']($options['request']);
         $request->params = $router::parse($request);
         $params = $self::applyRules($request->params);
         Environment::set($request);
         try {
             $callable = $self::invokeMethod('_callable', array($request, $params, $options));
             return $self::invokeMethod('_call', array($callable, $request, $params));
         } catch (UnexpectedValueException $e) {
             return (object) array('status' => $e->getMessage() . "\n");
         }
     });
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:33,代码来源:Dispatcher.php

示例6: array

/**
 * The routes file is where you define your URL structure, which is an important part of the
 * [information architecture](http://en.wikipedia.org/wiki/Information_architecture) of your
 * application. Here, you can use _routes_ to match up URL pattern strings to a set of parameters,
 * usually including a controller and action to dispatch matching requests to. For more information,
 * see the `Router` and `Route` classes.
 *
 * @see lithium\net\http\Router
 * @see lithium\net\http\Route
 */
use lithium\net\http\Router;
use lithium\core\Environment;
use lithium\action\Dispatcher;
// Set the evironment
if ($_SERVER['HTTP_HOST'] == 'li3bootstrap.dev.local' || $_SERVER['HTTP_HOST'] == 'li3bootstrap.local' || $_SERVER['HTTP_HOST'] == 'localhost') {
    Environment::set('development');
}
/**
 * Dispatcher rules to rewrite admin actions.
 */
Dispatcher::config(array('rules' => array('admin' => array('action' => 'admin_{:action}'))));
/**
 * "/admin" is the prefix for all Lithium Bootstrap admin routes.
 * Any "plugin" or library written for use with Lithium Bootstrap can utilize these routes
 * without needing to write any additional routes in most cases as this handles the basic CRUD.
 * It also handles pagination.
 *
 * Admin pages can be added to the main app's "/views/_libraries/li3b_core/pages" directory
 * and are accessible viw /admin/page/{:args}
 *
 * NOTE: li3b_core has no controller other than the pages controller. Other libraries and the
开发者ID:tmaiaroto,项目名称:li3b_core,代码行数:31,代码来源:routes.php

示例7: testEnvironmentAsset2

 /**
  * Create environment prefix location using `lihtium\net\http\Media::location`
  * Check if `lihtium\net\http\Media::asset` return the correct URL
  * for the test environement
  */
 public function testEnvironmentAsset2()
 {
     Media::attach('appcdn', array('production' => array('absolute' => true, 'path' => null, 'scheme' => 'http://', 'host' => 'my.cdnapp.com', 'prefix' => 'assets'), 'test' => array('absolute' => true, 'path' => null, 'scheme' => 'http://', 'host' => 'my.cdntest.com', 'prefix' => 'assets')));
     $env = Environment::get();
     Environment::set('test');
     $result = Media::asset('style', 'css', array('scope' => 'appcdn'));
     $expected = 'http://my.cdntest.com/assets/css/style.css';
     $this->assertEqual($expected, $result);
     Environment::is($env);
 }
开发者ID:jianoll,项目名称:lithium,代码行数:15,代码来源:MediaTest.php

示例8: function

use lithium\action\Dispatcher;
/**
 * This filter intercepts the `run()` method of the `Dispatcher`, and first passes the `'request'`
 * parameter (an instance of the `Request` object) to the `Environment` class to detect which
 * environment the application is running in. Then, loads all application routes in all plugins,
 * loading the default application routes last.
 *
 * Change this code if plugin routes must be loaded in a specific order (i.e. not the same order as
 * the plugins are added in your bootstrap configuration), or if application routes must be loaded
 * first (in which case the default catch-all routes should be removed).
 *
 * If `Dispatcher::run()` is called multiple times in the course of a single request, change the
 * `include`s to `include_once`.
 *
 * @see lithium\action\Request
 * @see lithium\core\Environment
 * @see lithium\net\http\Router
 */
Dispatcher::applyFilter('run', function ($self, $params, $chain) {
    Environment::set($params['request']);
    foreach (array_reverse(Libraries::get()) as $name => $config) {
        if ($name === 'lithium') {
            continue;
        }
        $file = "{$config['path']}/config/routes.php";
        file_exists($file) ? call_user_func(function () use($file) {
            include $file;
        }) : null;
    }
    return $chain->next($self, $params, $chain);
});
开发者ID:nilamdoc,项目名称:OxOPDF,代码行数:31,代码来源:action.php

示例9: array

Environment::set('test', array('locale' => 'en', 'locales' => array('en' => 'English')));
/**
 * Effective/Request Locale
 *
 * Intercepts dispatching processes in order to set the effective locale by using
 * the locale of the request or if that is not available retrieving a locale preferred
 * by the client.
 *
 * @see lithium\g11n\Message
 * @see lithium\core\Environment
 */
$setLocale = function ($self, $params, $chain) {
    if (!$params['request']->locale()) {
        $params['request']->locale(Locale::preferred($params['request']));
    }
    Environment::set(true, array('locale' => $params['request']->locale()));
    return $chain->next($self, $params, $chain);
};
ActionDispatcher::applyFilter('_callable', $setLocale);
ConsoleDispatcher::applyFilter('_callable', $setLocale);
/**
 * Resources
 *
 * Globalization (g11n) catalog configuration.  The catalog allows for obtaining and
 * writing globalized data. Each configuration can be adjusted through the following settings:
 *
 *   - `'adapter'` _string_: The name of a supported adapter. The builtin adapters are `Memory` (a
 *     simple adapter good for runtime data and testing), `Php`, `Gettext`, `Cldr` (for
 *     interfacing with Unicode's common locale data repository) and `Code` (used mainly for
 *     extracting message templates from source code).
 *
开发者ID:newmight2015,项目名称:Blockchain-2,代码行数:31,代码来源:g11n.php

示例10: _call

	/**
	 * Call class method
	 *
	 * @param string $callable
	 * @param string $request
	 * @param string $params
	 * @return void
	 * @filter
	 */
	protected static function _call($callable, $request, $params) {
		$params = compact('callable', 'request', 'params');
		Environment::set($request);
		return static::_filter(__FUNCTION__, $params, function($self, $params) {
			if (is_callable($callable = $params['callable'])) {
				$request = $params['request'];
				$params = $params['params'];

				if (!method_exists($callable, $params['action'])) {
					array_unshift($params['args'], $request->params['action']);
					$params['action'] = 'run';
				}
				$isHelp = (
					!empty($params['help']) || !empty($params['h'])
					|| !method_exists($callable, $params['action'])
				);
				if ($isHelp) {
					$params['action'] = '_help';
				}
				return $callable($params['action'], $params['args']);
			}
			throw new UnexpectedValueException("Callable `{$callable}` is actually not callable.");
		});
	}
开发者ID:niel,项目名称:lithium,代码行数:33,代码来源:Dispatcher.php

示例11: tearDown

 public function tearDown()
 {
     Catalog::reset();
     Catalog::config($this->_backup['catalogConfig']);
     Environment::set('test', $this->_backup['environment']);
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:6,代码来源:MessageTest.php

示例12: function

});
/**
 * Integration with `Validator`. You can load locale dependent rules into the `Validator`
 * by specifying them manually or retrieving them with the `Catalog` class.
 */
foreach (array('phone', 'postalCode', 'ssn') as $name) {
    Validator::add($name, Catalog::read(true, "validation.{$name}", 'en_US'));
}
/**
 * Intercepts dispatching processes in order to set the effective locale by using
 * the locale of the request or if that is not available retrieving a locale preferred
 * by the client.
 */
ActionDispatcher::applyFilter('_callable', function ($self, $params, $chain) {
    $request = $params['request'];
    $controller = $chain->next($self, $params, $chain);
    if (!$request->locale) {
        $request->params['locale'] = Locale::preferred($request);
    }
    Environment::set(Environment::get(), array('locale' => $request->locale));
    return $controller;
});
ConsoleDispatcher::applyFilter('_callable', function ($self, $params, $chain) {
    $request = $params['request'];
    $command = $chain->next($self, $params, $chain);
    if (!$request->locale) {
        $request->params['locale'] = Locale::preferred($request);
    }
    Environment::set(Environment::get(), array('locale' => $request->locale));
    return $command;
});
开发者ID:EHER,项目名称:chegamos,代码行数:31,代码来源:g11n.php

示例13: execute

 /**
  * Executes a given task with the given set of arguments.
  * Called by li3_gearman deamon
  *
  * @param string $task Fully qualified task name
  * @param array $args Arguments for the call
  * @param array $env Environment settings to merge on $_SERVER
  * @param array $workload Full workload
  * @return mixed Returned value
  */
 public function execute($task, array $args = [], array $env = [], array $workload = [])
 {
     if (!is_callable($task)) {
         throw new RuntimeException("Invalid task {$task}");
     }
     $workload += ['id' => null, 'background' => false];
     try {
         $status = $this->getStatus($workload['id']);
     } catch (Exception $e) {
     }
     if (!empty($status) && $status != static::STATUS_PENDING) {
         throw new Exception("Job #{$workload['id']} not on pending status. Status: {$status}");
     }
     if (array_key_exists('environment', $env)) {
         Environment::set($env['environment']);
         unset($env['environment']);
     }
     if (!empty($env)) {
         $_SERVER = $env + $_SERVER;
     }
     $result = null;
     try {
         $this->setStatus($workload['id'], static::STATUS_RUNNING);
         if (isset($this->_config['beforeExecute']) && is_callable($this->_config['beforeExecute'])) {
             call_user_func_array($this->_config['beforeExecute'], [$task, $args]);
         }
         $result = call_user_func_array($task, $args);
         $this->setStatus($workload['id'], static::STATUS_FINISHED);
         if (isset($this->_config['afterExecute']) && is_callable($this->_config['afterExecute'])) {
             call_user_func_array($this->_config['afterExecute'], [$task, $args]);
         }
     } catch (Exception $e) {
         error_log('[' . date('r') . '] ' . $e->getMessage());
         $this->setStatus($workload['id'], static::STATUS_ERROR);
         if (isset($this->_config['afterExecute']) && is_callable($this->_config['afterExecute'])) {
             call_user_func_array($this->_config['afterExecute'], [$task, $args]);
         }
         if (isset($this->_config['onException']) && is_callable($this->_config['onException'])) {
             call_user_func_array($this->_config['onException'], [$task, $args, $e]);
         }
         if (!empty($workload['retries']) && !empty($workload['retries']['maximum']) && $workload['retry'] < $workload['retries']['maximum']) {
             $this->run($task, $args, ['schedule' => new DateTime('now +' . $workload['retries']['increment'][$workload['retry']], new DateTimeZone('UTC')), 'retry' => $workload['retry'] + 1, 'retries' => $workload['retries']] + array_intersect_key($workload, ['configName' => null, 'env' => null, 'background' => null]));
         }
         throw $e;
     }
     return $result;
 }
开发者ID:Robert-Christopher,项目名称:li3_gearman,代码行数:57,代码来源:Job.php

示例14: _scaffold

 /**
  * Generates different variations of the configured $this->model property name
  *
  * If no model is configured (i.e. `null`) - it automatically detects the corresponding
  * model for this Controller via Inflection and `Libraries::locate()`.
  *
  * @see lithium\core\Libraries::locate()
  * @param string $field defines, what variation of the default you want to have
  *               available are 'class', 'model', 'singular', 'plural' and 'table' and 'human'.
  *               if omitted, returns array containing all of them.
  * @return array|string
  **/
 protected function _scaffold($field = null)
 {
     if (is_null($this->model)) {
         $this->model = (string) Libraries::locate('models', $this->request->controller);
     }
     if (is_null($this->scaffold)) {
         $class = basename(str_replace('\\', '/', $this->model));
         $base = !empty($this->library) ? array('controller' => $this->controller, 'library' => $this->library) : array('controller' => $this->controller);
         $this->scaffold = array('base' => Router::match($base, $this->request), 'controller' => strtolower($this->controller), 'library' => $this->library, 'class' => $class, 'model' => $this->model, 'slug' => Inflector::underscore($class), 'singular' => Inflector::singularize($class), 'plural' => Inflector::pluralize($class), 'table' => Inflector::tableize($class), 'human' => Inflector::humanize($class));
     }
     if (!is_null($field)) {
         return isset($this->scaffold[$field]) ? $this->scaffold[$field] : false;
     }
     Environment::set(true, array('scaffold' => $this->scaffold));
     return $this->scaffold;
 }
开发者ID:bruensicke,项目名称:radium,代码行数:28,代码来源:ScaffoldController.php

示例15: _init

 protected function _init()
 {
     parent::_init();
     Environment::set($this->env);
 }
开发者ID:nervetattoo,项目名称:li3-request-signing,代码行数:5,代码来源:Users.php


注:本文中的lithium\core\Environment::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。