[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\HttpKernel\Config; 13 14 use Symfony\Component\Config\Resource\SelfCheckingResourceInterface; 15 16 /** 17 * EnvParametersResource represents resources stored in prefixed environment variables. 18 * 19 * @author Chris Wilkinson <chriswilkinson84@gmail.com> 20 */ 21 class EnvParametersResource implements SelfCheckingResourceInterface, \Serializable 22 { 23 /** 24 * @var string 25 */ 26 private $prefix; 27 28 /** 29 * @var string 30 */ 31 private $variables; 32 33 /** 34 * @param string $prefix 35 */ 36 public function __construct($prefix) 37 { 38 $this->prefix = $prefix; 39 $this->variables = $this->findVariables(); 40 } 41 42 /** 43 * {@inheritdoc} 44 */ 45 public function __toString() 46 { 47 return serialize($this->getResource()); 48 } 49 50 /** 51 * {@inheritdoc} 52 */ 53 public function getResource() 54 { 55 return array('prefix' => $this->prefix, 'variables' => $this->variables); 56 } 57 58 /** 59 * {@inheritdoc} 60 */ 61 public function isFresh($timestamp) 62 { 63 return $this->findVariables() === $this->variables; 64 } 65 66 public function serialize() 67 { 68 return serialize(array('prefix' => $this->prefix, 'variables' => $this->variables)); 69 } 70 71 public function unserialize($serialized) 72 { 73 $unserialized = unserialize($serialized); 74 75 $this->prefix = $unserialized['prefix']; 76 $this->variables = $unserialized['variables']; 77 } 78 79 private function findVariables() 80 { 81 $variables = array(); 82 83 foreach ($_SERVER as $key => $value) { 84 if (0 === strpos($key, $this->prefix)) { 85 $variables[$key] = $value; 86 } 87 } 88 89 ksort($variables); 90 91 return $variables; 92 } 93 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |