| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
abstract class sfConfigHandler |
|---|
| 24 |
{ |
|---|
| 25 |
protected |
|---|
| 26 |
$parameterHolder = null; |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
* Executes this configuration handler |
|---|
| 30 |
* |
|---|
| 31 |
* @param array An array of filesystem path to a configuration file |
|---|
| 32 |
* |
|---|
| 33 |
* @return string Data to be written to a cache file |
|---|
| 34 |
* |
|---|
| 35 |
* @throws <b>sfConfigurationException</b> If a requested configuration file does not exist or is not readable |
|---|
| 36 |
* @throws <b>sfParseException</b> If a requested configuration file is improperly formatted |
|---|
| 37 |
*/ |
|---|
| 38 |
abstract public function execute($configFiles); |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
* Initializes this configuration handler. |
|---|
| 42 |
* |
|---|
| 43 |
* @param array An associative array of initialization parameters |
|---|
| 44 |
* |
|---|
| 45 |
* @return bool true, if initialization completes successfully, otherwise false |
|---|
| 46 |
* |
|---|
| 47 |
* @throws <b>sfInitializationException</b> If an error occurs while initializing this ConfigHandler |
|---|
| 48 |
*/ |
|---|
| 49 |
public function initialize($parameters = null) |
|---|
| 50 |
{ |
|---|
| 51 |
$this->parameterHolder = new sfParameterHolder(); |
|---|
| 52 |
$this->parameterHolder->add($parameters); |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
* Replaces constant identifiers in a value. |
|---|
| 57 |
* |
|---|
| 58 |
* If the value is an array replacements are made recursively. |
|---|
| 59 |
* |
|---|
| 60 |
* @param mixed The value on which to run the replacement procedure |
|---|
| 61 |
* |
|---|
| 62 |
* @return string The new value |
|---|
| 63 |
*/ |
|---|
| 64 |
public static function replaceConstants($value) |
|---|
| 65 |
{ |
|---|
| 66 |
if (is_array($value)) |
|---|
| 67 |
{ |
|---|
| 68 |
array_walk_recursive($value, create_function('&$value', '$value = sfToolkit::replaceConstants($value);')); |
|---|
| 69 |
} |
|---|
| 70 |
else |
|---|
| 71 |
{ |
|---|
| 72 |
$value = sfToolkit::replaceConstants($value); |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
return $value; |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
* Replaces a relative filesystem path with an absolute one. |
|---|
| 80 |
* |
|---|
| 81 |
* @param string A relative filesystem path |
|---|
| 82 |
* |
|---|
| 83 |
* @return string The new path |
|---|
| 84 |
*/ |
|---|
| 85 |
public static function replacePath($path) |
|---|
| 86 |
{ |
|---|
| 87 |
if (!sfToolkit::isPathAbsolute($path)) |
|---|
| 88 |
{ |
|---|
| 89 |
|
|---|
| 90 |
$path = sfConfig::get('sf_app_dir').'/'.$path; |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
return $path; |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
* Gets the parameter holder for this configuration handler. |
|---|
| 98 |
* |
|---|
| 99 |
* @return sfParameterHolder A sfParameterHolder instance |
|---|
| 100 |
*/ |
|---|
| 101 |
public function getParameterHolder() |
|---|
| 102 |
{ |
|---|
| 103 |
return $this->parameterHolder; |
|---|
| 104 |
} |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|