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


PHP Environment类代码示例

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


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

示例1: createDirectory

 public static function createDirectory($original_path, $type, Environment $environment)
 {
     $paths = pathinfo($original_path);
     $dirname = realpath($paths['dirname']);
     if (!$dirname || !is_dir($dirname) || !is_readable($dirname)) {
         if (@mkdir($original_path, 0777, true) === true) {
             $realpath = $original_path;
         } else {
             return $environment->set_error(ucfirst($type) . " parent path '{$paths['dirname']}' does not exist.  Please correct the path or create the directory.");
         }
     }
     $path = $dirname . '/' . $paths['basename'];
     $realpath = realpath($path);
     if ($realpath === false || !file_exists($realpath)) {
         if (@mkdir($path, 0777, true) === true) {
             $realpath = $path;
         } else {
             return $environment->set_error("Unable to create directory '{$path}'.  Please make the directory manually or check the permissions of the parent directory.");
         }
     } elseif (!is_readable($realpath) || !is_writable($realpath)) {
         @chmod($realpath, 0777);
     }
     if (substr($realpath, -1) != '/') {
         $realpath .= '/';
     }
     if (is_dir($realpath) && is_readable($realpath) && is_writable($realpath)) {
         return $realpath;
     } else {
         return $environment->set_error("Path to directory for {$type} is not valid.  Please correct the path or create the directory and check that is readable and writable.");
     }
 }
开发者ID:sbuberl,项目名称:fSQL,代码行数:31,代码来源:Utilities.php

示例2: setDefaultEnv

 public function setDefaultEnv($environment)
 {
     $env = new Environment();
     if (is_object($env->add($environment))) {
         $this->currentEnviroment = $environment;
     }
 }
开发者ID:leal32b,项目名称:project0,代码行数:7,代码来源:DefineEnvironment.php

示例3: changeEnvironmentRole

 /**
  * Change the user's environment-level role.
  *
  * @param Environment $environment
  * @param string      $newRole The new role ('admin', 'contributor',
  *                             or 'viewer').
  */
 public function changeEnvironmentRole(Environment $environment, $newRole)
 {
     if (!in_array($newRole, ['admin', 'contributor', 'viewer'])) {
         throw new \InvalidArgumentException("Invalid role: {$newRole}");
     }
     $this->sendRequest($environment->getUri() . '/access/' . $this->id, 'patch', ['json' => ['role' => $newRole]]);
 }
开发者ID:CompanyOnTheWorld,项目名称:platformsh-client-php,代码行数:14,代码来源:ProjectUser.php

示例4: testGet

 public function testGet()
 {
     $get = array('n' => 'v');
     $env = new Environment($get, array(), array());
     $this->assertEquals('v', $env->get('n'));
     $this->assertNull($env->get('not-existed-param'));
 }
开发者ID:yperevoznikov,项目名称:earlycache,代码行数:7,代码来源:EnvironmentTest.php

示例5: getAssetsOutput

 /**
  * Proxy method that handles return of assets instead of instant output.
  *
  * @param  Environment $env
  * @param  string $method
  * @param  string|null $options Assets CollectionName
  * @return string
  */
 protected function getAssetsOutput(Environment $env, $method, $options = null)
 {
     $env->getDi()->get('assets')->useImplicitOutput(false);
     $result = $env->getDi()->get('assets')->{$method}($options);
     $env->getDi()->get('assets')->useImplicitOutput(true);
     return $result;
 }
开发者ID:broklyngagah,项目名称:orbit,代码行数:15,代码来源:CoreExtension.php

示例6: setEnvironment

 function setEnvironment(Environment $env)
 {
     $this->environment = $env;
     $env->setLoader($this);
     Controller::setEnvironment($env);
     return $this;
 }
开发者ID:CHH,项目名称:Simple-CMS,代码行数:7,代码来源:StandardLoader.php

示例7: testUsesEnvironmentVariables

 /**
  * Test that the parser gets its values from the $_SERVER and $_ENV environment variables
  */
 public function testUsesEnvironmentVariables()
 {
     $_SERVER['foo'] = 'bar';
     $_ENV['test'] = 'example';
     $configuration = $this->parser->parse();
     $this->assertArrayHasKey('foo', $configuration);
     $this->assertArrayHasKey('test', $configuration);
 }
开发者ID:kabudu,项目名称:silex-config-service-provider,代码行数:11,代码来源:EnvironmentTest.php

示例8: saveCachedEnvironmentObject

 public static function saveCachedEnvironmentObject()
 {
     if (!file_exists(DIR_FILES_CACHE . '/' . FILENAME_ENVIRONMENT_CACHE)) {
         $env = new Environment();
         $env->getOverrides();
         @file_put_contents(DIR_FILES_CACHE . '/' . FILENAME_ENVIRONMENT_CACHE, serialize($env));
     }
 }
开发者ID:Zyqsempai,项目名称:amanet,代码行数:8,代码来源:environment.php

示例9: init

 static function init($ApiKey, Environment $env)
 {
     if ($env->getBaseUrl() != Environment::PROD and $env->getBaseUrl() != Environment::TEST and $env->getBaseUrl() != Environment::DEV) {
         throw new \InvalidArgumentException('$env must be Apruve\\Environment::PROD or Apruve\\Environment::TEST to be valid.');
     }
     ClientStorage::setEnvironment($env);
     ClientStorage::setApiKey($ApiKey);
     return new Client();
 }
开发者ID:apruve,项目名称:apruve-php,代码行数:9,代码来源:Client.php

示例10: register

 public function register(Environment $environment)
 {
     $env = $environment->getEnv();
     foreach ($env['packages'] as $k => $e) {
         if ($k !== "Syph") {
             $this->app_container_config[$k] = array("app_path_conf" => $e . DS . "Config" . DS . "config.php");
         }
     }
 }
开发者ID:rodrigoul,项目名称:syph-framework,代码行数:9,代码来源:AppBuilder.php

示例11: createFromEnvironment

 /**
  * Create a normalized tree of UploadedFile instances from the Environment.
  *
  * @param Environment $env The environment
  *
  * @return array|null A normalized tree of UploadedFile instances or null if none are provided.
  */
 public static function createFromEnvironment(Environment $env)
 {
     if (is_array($env['slim.files']) && $env->has('slim.files')) {
         return $env['slim.files'];
     } elseif (isset($_FILES)) {
         return static::parseUploadedFiles($_FILES);
     }
     return [];
 }
开发者ID:geggleto,项目名称:Slim-Http,代码行数:16,代码来源:UploadedFile.php

示例12: testModuleActivation

 /**
  * Tests if module was activated.
  *
  * @dataProvider providerModuleActivation
  *
  * @param array  $aInstallModules
  * @param string $sModule
  * @param array  $aResultToAsserts
  */
 public function testModuleActivation($aInstallModules, $sModule, $aResultToAsserts)
 {
     $oEnvironment = new Environment();
     $oEnvironment->prepare($aInstallModules);
     $oModule = oxNew('oxModule');
     $oModule->load($sModule);
     $this->deactivateModule($oModule);
     $this->activateModule($oModule);
     $this->runAsserts($aResultToAsserts);
 }
开发者ID:Alpha-Sys,项目名称:oxideshop_ce,代码行数:19,代码来源:ModuleActivationTest.php

示例13: checkConnectionMode

 /**
  * Checks the site's mode and suggests SFTP if it is not set.
  *
  * @param Environment $environment Environment object to check mode of
  * @return void
  */
 protected function checkConnectionMode($environment)
 {
     if ($environment->getConnectionMode() != 'sftp') {
         $message = 'Note: This environment is in read-only Git mode. If you ';
         $message .= 'want to make changes to the codebase of this site ';
         $message .= '(e.g. updating modules or plugins), you will need to ';
         $message .= 'toggle into read/write SFTP mode first.';
         $this->log()->warning($message);
     }
 }
开发者ID:sammys,项目名称:terminus,代码行数:16,代码来源:CommandWithSSH.php

示例14: testModulesWithoutMetadataShouldBeAddToCleanupAllModulesWithMetadata

 public function testModulesWithoutMetadataShouldBeAddToCleanupAllModulesWithMetadata()
 {
     // modules to be activated during test preparation
     $aInstallModules = array('extending_1_class');
     $oEnvironment = new Environment();
     $oEnvironment->prepare($aInstallModules);
     $oModuleList = oxNew('oxModuleList');
     $aGarbage = $oModuleList->getDeletedExtensions();
     $this->assertSame(array(), $aGarbage);
 }
开发者ID:Crease29,项目名称:oxideshop_ce,代码行数:10,代码来源:modulewithnometadatasupportTest.php

示例15: run

 /**
  * {@inheritdoc}
  *
  * @throws \Icicle\File\Exception\FileException
  * @throws \Icicle\Exception\InvalidArgumentError
  */
 public function run(Environment $environment)
 {
     if ('f' === $this->operation[0]) {
         if ('fopen' === $this->operation) {
             $file = new File($this->args[0], $this->args[1]);
             $id = $file->getId();
             $environment->set($this->makeId($id), $file);
             return [$id, $file->stat()['size'], $file->inAppendMode()];
         }
         if (null === $this->id) {
             throw new FileException('No file ID provided.');
         }
         if (!$environment->exists($this->id)) {
             throw new FileException('No file handle with the given ID has been opened on the worker.');
         }
         if (!($file = $environment->get($this->id)) instanceof File) {
             throw new FileException('File storage found in inconsistent state.');
         }
         switch ($this->operation) {
             case 'fread':
             case 'fwrite':
             case 'fseek':
             case 'fstat':
             case 'ftruncate':
                 return [$file, substr($this->operation, 1)](...$this->args);
             case 'fclose':
                 $environment->delete($this->id);
                 return true;
             default:
                 throw new InvalidArgumentError('Invalid operation.');
         }
     }
     switch ($this->operation) {
         case 'stat':
         case 'unlink':
         case 'rename':
         case 'copy':
         case 'link':
         case 'symlink':
         case 'readlink':
         case 'isfile':
         case 'isdir':
         case 'mkdir':
         case 'lsdir':
         case 'rmdir':
         case 'chmod':
         case 'chown':
         case 'chgrp':
             return [$this, $this->operation](...$this->args);
         default:
             throw new InvalidArgumentError('Invalid operation.');
     }
 }
开发者ID:sternt,项目名称:filesystem,代码行数:59,代码来源:FileTask.php


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