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


PHP static::env方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @param   string|RFormatter $format      Output format ID, or formatter instance defaults to 'html'
  */
 public function __construct($format = 'html')
 {
     static $didIni = false;
     if (!$didIni) {
         $didIni = true;
         foreach (array_keys(static::$config) as $key) {
             $iniVal = get_cfg_var('ref.' . $key);
             print_r($iniVal);
             if ($iniVal !== false) {
                 static::$config[$key] = $iniVal;
             }
         }
     }
     if ($format instanceof RFormatter) {
         $this->fmt = $format;
     } else {
         $format = __NAMESPACE__ . '\\' . (isset(static::$config['formatters'][$format]) ? static::$config['formatters'][$format] : 'R' . ucfirst($format) . 'Formatter');
         if (!class_exists($format, true)) {
             throw new \Exception(sprintf('%s class not found', $format));
         }
         $this->fmt = new $format();
     }
     if (static::$env) {
         return;
     }
     static::$env = array('is54' => version_compare(PHP_VERSION, '5.4') >= 0, 'is546' => version_compare(PHP_VERSION, '5.4.6') >= 0, 'is56' => version_compare(PHP_VERSION, '5.6') >= 0, 'curlActive' => function_exists('curl_version'), 'mbStr' => function_exists('mb_detect_encoding'), 'supportsDate' => strncasecmp(PHP_OS, 'WIN', 3) !== 0 || version_compare(PHP_VERSION, '5.3.10') >= 0);
 }
开发者ID:kardagan,项目名称:PhpDevTools,代码行数:32,代码来源:ref.php

示例2: __construct

 /**
  * Instantiates this class
  *
  * @param int $id ID of the attachment
  */
 public function __construct($id)
 {
     // Check if post exists
     if (!is_string(get_post_status($id))) {
         throw new \Exception("Post does not exist");
     }
     // Check if post is an attachment
     if (get_post_type($id) != 'attachment') {
         throw new \Exception("Target post is not an attachment");
     }
     // Check if attachment have a file path to use
     $this->partial_path = get_post_meta($id, '_wp_attached_file', true);
     if (!$this->partial_path) {
         throw new \Exception("Target post does not have a file path to be used");
     }
     // Collect environment information if not already available
     if (is_null(static::$env)) {
         static::$env = static::__getEnvInfo();
     }
     // Get WordPress meta data
     $default_wordpress_meta = ['sizes' => []];
     $this->wordpress_meta = get_post_meta($id, '_wp_attachment_metadata', true) ?: $default_wordpress_meta;
     // Get plugin meta data
     $default_plugin_meta = ['sizes' => []];
     $plugin_meta_json = get_post_meta($id, Config::ATTACHMENT_META_KEY, true);
     $this->plugin_meta = $plugin_meta_json ? json_decode($plugin_meta_json, true) : $default_plugin_meta;
     // Store post id
     $this->id = $id;
 }
开发者ID:ponticlaro,项目名称:bebop-media,代码行数:34,代码来源:Image.php

示例3: loadEnv

 public static function loadEnv($filepath, array $options = [])
 {
     $loader = (new Loader($filepath))->raiseExceptions(true)->parse();
     if (!empty($options)) {
         extract($options);
     }
     if (isset($expect) && is_array($expect)) {
         $loader = $loader->expect($expect);
     }
     static::$env = $loader->toArray();
 }
开发者ID:xemoe,项目名称:php,代码行数:11,代码来源:EnvLoaderTrait.php

示例4: detectEnvironment

 /**
  * Detect environment
  *
  * By default check
  *
  * @return string env
  */
 public static function detectEnvironment($request = null)
 {
     if (!empty(static::$env)) {
         return static::$env;
     }
     $rules = self::get('env');
     $request = $request ? $request : Request::createFromGlobals();
     $host = $request->getHost();
     foreach ($rules as $env => $rule) {
         if (is_callable($rule)) {
             static::$env = $env;
         } elseif (preg_match($rule, $host)) {
             static::$env = $env;
             break;
         }
     }
     static::loadEnvironment(static::$env);
     return static::$env;
 }
开发者ID:SerdarSanri,项目名称:arx-core,代码行数:26,代码来源:Config.php

示例5: dataFixtures

 /**
  * Generate data for ApiTestCaseV2
  *
  * @param string $fixtures patch to fixtures directory
  * @return array
  * @throws \Scalr\System\Config\Exception\YamlException
  */
 public static function dataFixtures($fixtures)
 {
     // set config
     static::$testUserId = \Scalr::config('scalr.phpunit.userid');
     static::$user = User::findPk(static::$testUserId);
     static::$testEnvId = \Scalr::config('scalr.phpunit.envid');
     static::$env = Environment::findPk(static::$testEnvId);
     $data = [];
     foreach (new DirectoryIterator($fixtures) as $fileInfo) {
         if ($fileInfo->isFile()) {
             $class = __NAMESPACE__ . '\\' . ucfirst($fileInfo->getBasename('.yaml'));
             if (class_exists($class)) {
                 /* @var $object TestDataFixtures */
                 $object = new $class(Yaml::load($fileInfo->getPathname())->toArray());
                 $object->prepareTestData();
                 $data = array_merge($data, $object->preparePathInfo());
             }
         }
     }
     return $data;
 }
开发者ID:mheydt,项目名称:scalr,代码行数:28,代码来源:TestDataFixtures.php

示例6: init

 /**
  * Initializes the framework.  This can only be called once.
  *
  * @access	public
  * @return	void
  */
 public static function init($config)
 {
     if (static::$initialized) {
         throw new \Exception("You can't initialize Fuel more than once.");
     }
     register_shutdown_function('fuel_shutdown_handler');
     set_exception_handler('fuel_exception_handler');
     set_error_handler('fuel_error_handler');
     // Start up output buffering
     ob_start();
     static::$profiling = isset($config['profiling']) ? $config['profiling'] : false;
     if (static::$profiling) {
         \Profiler::init();
         \Profiler::mark(__METHOD__ . ' Start');
     }
     static::$cache_dir = isset($config['cache_dir']) ? $config['cache_dir'] : APPPATH . 'cache/';
     static::$caching = isset($config['caching']) ? $config['caching'] : false;
     static::$cache_lifetime = isset($config['cache_lifetime']) ? $config['cache_lifetime'] : 3600;
     if (static::$caching) {
         static::$path_cache = static::cache('Fuel::path_cache');
     }
     \Config::load($config);
     static::$_paths = array_merge(\Config::get('module_paths', array()), array(APPPATH, COREPATH));
     static::$is_cli = (bool) (php_sapi_name() == 'cli');
     if (!static::$is_cli) {
         if (\Config::get('base_url') === null) {
             \Config::set('base_url', static::generate_base_url());
         }
         \Uri::detect();
     }
     // Run Input Filtering
     \Security::clean_input();
     static::$env = \Config::get('environment');
     static::$locale = \Config::get('locale');
     //Load in the packages
     foreach (\Config::get('always_load.packages', array()) as $package) {
         static::add_package($package);
     }
     // Set some server options
     setlocale(LC_ALL, static::$locale);
     // Always load classes, config & language set in always_load.php config
     static::always_load();
     static::$initialized = true;
     if (static::$profiling) {
         \Profiler::mark(__METHOD__ . ' End');
     }
 }
开发者ID:huglester,项目名称:fuel-uploadify,代码行数:53,代码来源:fuel.php

示例7: detectEnvironment

 /**
  *
  */
 private function detectEnvironment()
 {
     static::$env = ['developing' => env('APP_ENV', 'PRODUCTION') !== 'PRODUCTION', 'app_key' => env('APP_KEY', '[set me]'), 'debugging' => env('DEBUG', FALSE), 'testing' => env('TESTING', FALSE)];
 }
开发者ID:formula9,项目名称:framework,代码行数:7,代码来源:ConsoleFactory.php

示例8: setUpBeforeClass

 /**
  * Add test environment, test Acl, setups test user, environment and API key
  */
 public static function setUpBeforeClass()
 {
     if (!Scalr::getContainer()->config->defined('scalr.phpunit.apiv2')) {
         static::markTestIncomplete('phpunit apiv2 configurations is invalid');
     }
     if (Scalr::getContainer()->config->defined('scalr.phpunit.apiv2.params.max_results')) {
         static::$maxResults = Scalr::config('scalr.phpunit.apiv2.params.max_results');
     }
     static::$testUserId = Scalr::config('scalr.phpunit.apiv2.userid');
     static::$user = User::findPk(static::$testUserId);
     static::$testUserType = static::$user->type;
     static::$testEnvId = Scalr::config('scalr.phpunit.apiv2.envid');
     static::$env = Environment::findPk(static::$testEnvId);
     if (empty(static::$user) || empty(static::$env)) {
         static::markTestIncomplete('Either test environment or user is invalid.');
     }
     $apiKeyName = static::getTestName();
     $apiKeyEntity = ApiKeyEntity::findOne([['name' => $apiKeyName], ['userId' => static::$testUserId]]);
     if (empty($apiKeyEntity)) {
         $apiKeyEntity = new ApiKeyEntity(static::$testUserId);
         $apiKeyEntity->name = $apiKeyName;
         $apiKeyEntity->save();
     }
     static::$apiKeyEntity = $apiKeyEntity;
     static::$defaultAcl = Scalr::getContainer()->acl;
     static::$data = [static::$testEnvId => []];
     if (empty(static::$fullAccessAcl)) {
         static::$fullAccessAcl = new ApiTestAcl();
         static::$fullAccessAcl->setDb(Scalr::getContainer()->adodb);
         static::$fullAccessAcl->createTestAccountRole(static::$user->getAccountId(), static::getTestName(ApiFixture::ACL_FULL_ACCESS), ApiTestAcl::ROLE_ID_FULL_ACCESS);
         static::$fullAccessAcl->aclType = ApiFixture::ACL_FULL_ACCESS;
     }
     if (empty(static::$readOnlyAccessAcl)) {
         static::$readOnlyAccessAcl = new ApiTestAcl();
         static::$readOnlyAccessAcl->setDb(Scalr::getContainer()->adodb);
         static::$readOnlyAccessAcl->createTestAccountRole(static::$user->getAccountId(), static::getTestName(ApiFixture::ACL_READ_ONLY_ACCESS), ApiTestAcl::ROLE_ID_READ_ONLY_ACCESS);
         static::$readOnlyAccessAcl->aclType = ApiFixture::ACL_READ_ONLY_ACCESS;
     }
 }
开发者ID:scalr,项目名称:scalr,代码行数:42,代码来源:ApiTest.php

示例9: init

 /**
  * Initializes the framework.  This can only be called once.
  *
  * @access	public
  * @return	void
  */
 public static function init($config)
 {
     \Config::load($config);
     if (static::$initialized) {
         throw new \Fuel_Exception("You can't initialize Fuel more than once.");
     }
     register_shutdown_function('fuel_shutdown_handler');
     set_exception_handler('fuel_exception_handler');
     set_error_handler('fuel_error_handler');
     // Start up output buffering
     ob_start(\Config::get('ob_callback', null));
     static::$profiling = \Config::get('profiling', false);
     if (static::$profiling) {
         \Profiler::init();
         \Profiler::mark(__METHOD__ . ' Start');
     }
     static::$cache_dir = \Config::get('cache_dir', APPPATH . 'cache/');
     static::$caching = \Config::get('caching', false);
     static::$cache_lifetime = \Config::get('cache_lifetime', 3600);
     if (static::$caching) {
         static::$path_cache = static::cache('Fuel::path_cache');
     }
     // set a default timezone if one is defined
     static::$timezone = \Config::get('default_timezone') ?: date_default_timezone_get();
     date_default_timezone_set(static::$timezone);
     // set the encoding and locale to use
     static::$encoding = \Config::get('encoding', static::$encoding);
     static::$locale = \Config::get('locale', static::$locale);
     static::$_paths = array(APPPATH, COREPATH);
     if (!static::$is_cli) {
         if (\Config::get('base_url') === null) {
             \Config::set('base_url', static::generate_base_url());
         }
         \Uri::detect();
     }
     // Run Input Filtering
     \Security::clean_input();
     static::$env = \Config::get('environment');
     \Event::register('shutdown', 'Fuel::finish');
     //Load in the packages
     foreach (\Config::get('always_load.packages', array()) as $package => $path) {
         is_string($package) and $path = array($package => $path);
         static::add_package($path);
     }
     // Load in the routes
     \Config::load('routes', true);
     \Router::add(\Config::get('routes'));
     // Set  locale
     static::$locale and setlocale(LC_ALL, static::$locale);
     // Always load classes, config & language set in always_load.php config
     static::always_load();
     static::$initialized = true;
     if (static::$profiling) {
         \Profiler::mark(__METHOD__ . ' End');
     }
 }
开发者ID:nathanharper,项目名称:divine-economy,代码行数:62,代码来源:fuel.php

示例10: isTracking

 /**
  * Helper method to determine if track calls should be respected
  *
  * It is possible to filter tracking calls based on environment
  * and this method will make sure that is respected
  * @return bool
  **/
 protected static function isTracking()
 {
     if (($env = static::$_config['env']) && $env === '*') {
         return true;
     }
     if (!static::$env) {
         static::$env = Environment::get();
     }
     return is_array($env) ? in_array(static::$env, $env) : static::$env === $env;
 }
开发者ID:keyteqlabs,项目名称:li3_mixpanel,代码行数:17,代码来源:Mixpanel.php

示例11: __construct

 /**
  * Constructor
  *
  * @param   string|RFormatter $format      Output format ID, or formatter instance defaults to 'html'
  */
 public function __construct($format = 'html')
 {
     if ($format instanceof RFormatter) {
         $this->fmt = $format;
     } else {
         $format = isset(static::$config['formatters'][$format]) ? static::$config['formatters'][$format] : 'R' . ucfirst($format) . 'Formatter';
         if (!class_exists($format, false)) {
             throw new \Exception(sprintf('%s class not found', $format));
         }
         $this->fmt = new $format();
     }
     if (static::$env) {
         return;
     }
     static::$env = array('is54' => version_compare(PHP_VERSION, '5.4') >= 0, 'is546' => version_compare(PHP_VERSION, '5.4.6') >= 0, 'curlActive' => function_exists('curl_version'), 'mbStr' => function_exists('mb_detect_encoding'), 'supportsDate' => strncasecmp(PHP_OS, 'WIN', 3) !== 0 || version_compare(PHP_VERSION, '5.3.10') >= 0);
 }
开发者ID:jgreth,项目名称:php-ref,代码行数:21,代码来源:ref.php

示例12: detect_environment

 /**
  * **Detect and configure the environment.**
  *
  * @throws ConfigurationException
  */
 private function detect_environment()
 {
     static::$env = ['developing' => env('APP_ENV', 'PRODUCTION') !== 'PRODUCTION', 'app_key' => env('APP_KEY', '[set me]'), 'debugging' => env('DEBUG', FALSE), 'testing' => env('TESTING', FALSE)];
     // register this factory
     Forge::set([static::class, 'AppFactory'], $this);
 }
开发者ID:formula9,项目名称:framework,代码行数:11,代码来源:AppFactory.php

示例13: loadData

 /**
  * Generate data for ApiTest
  *
  * @param string $fixtures patch to fixtures directory
  * @param string $type api specifications type
  * @return array
  * @throws \Scalr\System\Config\Exception\YamlException
  */
 public static function loadData($fixtures, $type)
 {
     // set config
     static::$testUserId = \Scalr::config('scalr.phpunit.apiv2.userid');
     static::$user = User::findPk(static::$testUserId);
     static::$testEnvId = \Scalr::config('scalr.phpunit.apiv2.envid');
     static::$env = Environment::findPk(static::$testEnvId);
     $data = [];
     foreach (new ApiFixtureIterator(new DirectoryIterator($fixtures), $type) as $fileInfo) {
         $class = __NAMESPACE__ . '\\' . ucfirst($fileInfo->getBasename('.yaml'));
         try {
             /* @var $object ApiFixture */
             $object = new $class(Yaml::load($fileInfo->getPathname())->toArray(), $type);
             $object->prepareTestData();
             $pathInfo = $object->preparePathInfo();
         } catch (Exception $e) {
             $pathInfo = [array_merge([$class, $e, null, null, null], static::$defaultOperation)];
         }
         $data = array_merge($data, $pathInfo);
     }
     return $data;
 }
开发者ID:scalr,项目名称:scalr,代码行数:30,代码来源:ApiFixture.php

示例14: env

 /**
  * Get or set the system environment
  *
  * @param string $environment The system environment to be set
  * @return string
  */
 public static function env($environment = null)
 {
     if ($environment) {
         static::$env = $environment;
     }
     return static::$env;
 }
开发者ID:queued,项目名称:mavis,代码行数:13,代码来源:Kernel.php

示例15: setUpBeforeClass

 /**
  * Setups test user, environment and API key
  *
  * @beforeClass
  *
  * @throws \Scalr\Exception\ModelException
  */
 public static function setUpBeforeClass()
 {
     static::$testUserId = \Scalr::config('scalr.phpunit.userid');
     static::$user = User::findPk(static::$testUserId);
     static::$testEnvId = \Scalr::config('scalr.phpunit.envid');
     static::$env = Environment::findPk(static::$testEnvId);
     $apiKeyName = static::getTestName();
     $apiKeyEntity = ApiKeyEntity::findOne([['name' => $apiKeyName], ['userId' => static::$testUserId]]);
     if (empty($apiKeyEntity)) {
         $apiKeyEntity = new ApiKeyEntity(static::$testUserId);
         $apiKeyEntity->name = $apiKeyName;
         $apiKeyEntity->save();
     }
     static::$apiKeyEntity = $apiKeyEntity;
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:22,代码来源:ApiTestCase.php


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