• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Environment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: compileTwigMoreHaml

 static function compileTwigMoreHaml($hamlstr, $options, $moreOptions = null)
 {
     static $env;
     if (!is_null($options)) {
         $env = new Environment('twig_more', $options);
     }
     if ($env) {
         return $env->compileString($hamlstr, $moreOptions);
     } else {
         throw new Exception\MoreException('plz supply 2nd arg when calling this func first time');
     }
 }
开发者ID:scil,项目名称:mthaml-more,代码行数:12,代码来源:Entry.php


示例17: testModuleActivateWithSimilarName

 /**
  * Test check shop environment after activation of module with similar name as deactivated module
  *
  * @dataProvider providerModuleReactivation
  *
  * @param array  $installModules
  * @param string $sReactivateModule
  * @param array  $aResultToAssert
  */
 public function testModuleActivateWithSimilarName($installModules, $sReactivateModule, $aResultToAssert)
 {
     $environment = new Environment();
     $environment->prepare($installModules);
     foreach ($installModules as $sModule) {
         $oModule = oxNew('oxModule');
         $this->deactivateModule($oModule, $sModule);
     }
     $oModule = oxNew('oxModule');
     $this->activateModule($oModule, $sReactivateModule);
     $this->runAsserts($aResultToAssert);
 }
开发者ID:Alpha-Sys,项目名称:oxideshop_ce,代码行数:21,代码来源:ModuleActivateWithSimilarNameTest.php


示例18: testModulesWithMissingFiles

 public function testModulesWithMissingFiles()
 {
     $this->markTestSkipped('Currently we are not checking module files.');
     // modules to be activated during test preparation
     $aInstallModules = array('with_1_extension', 'with_2_files');
     $oEnvironment = new Environment();
     $oEnvironment->prepare($aInstallModules);
     $oModuleList = oxNew('oxModuleList');
     $aGarbage = $oModuleList->getDeletedExtensions();
     $aExpect = array('with_1_extension' => array('extensions' => array('oxarticle' => 'with_1_extension/mybaseclass')), 'with_2_files' => array('files' => array('myexception' => 'with_2_files/core/exception/myexception.php', 'myconnection' => 'with_2_files/core/exception/myconnection.php')));
     $this->assertSame($aExpect, $aGarbage);
 }
开发者ID:Alpha-Sys,项目名称:oxideshop_ce,代码行数:12,代码来源:ModuleWithNoMetadataSupportTest.php


示例19: testModuleDeactivationInSubShop

 /**
  * Test check shop environment after module deactivation in subshop.
  *
  * @dataProvider providerModuleDeactivation
  *
  * @param array  $aInstallModules
  * @param string $sModuleId
  * @param array  $aResultToAssert
  */
 public function testModuleDeactivationInSubShop($aInstallModules, $sModuleId, $aResultToAssert)
 {
     if ($this->getTestConfig()->getShopEdition() != 'EE') {
         $this->markTestSkipped("This test case is only actual when SubShops are available.");
     }
     $oModule = oxNew('oxModule');
     $oEnvironment = new Environment();
     $oEnvironment->prepare($aInstallModules);
     $oEnvironment->setShopId(2);
     $oEnvironment->activateModules($aInstallModules);
     $this->deactivateModule($oModule, $sModuleId);
     $this->runAsserts($aResultToAssert);
 }
开发者ID:Alpha-Sys,项目名称:oxideshop_ce,代码行数:22,代码来源:ModuleDeactivationTest.php


示例20: testModuleDeactivate

 /**
  * Test check shop module deactivation
  */
 public function testModuleDeactivate()
 {
     $oConfig = oxRegistry::getConfig();
     $sState = $oConfig->getConfigParam('sTestDeactivateEvent');
     $this->assertSame(null, $sState, 'No events should have been executed till now');
     $oEnvironment = new Environment();
     $oEnvironment->prepare(array('with_events'));
     $oModule = oxNew('oxModule');
     $oModule->load('with_events');
     $this->deactivateModule($oModule);
     $sState = $oConfig->getConfigParam('sTestDeactivateEvent');
     $this->assertEquals("Deactivate", $sState, 'onDeactivate event was not called.');
 }
开发者ID:Crease29,项目名称:oxideshop_ce,代码行数:16,代码来源:moduleeventsTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP EpiCurl类代码示例发布时间:2022-05-23
下一篇:
PHP EnvUtil类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap