class Variable in Service Container 7
Same name in this branch
- 7 src/Variable.php \Drupal\service_container\Variable
- 7 lib/Drupal/Component/Utility/Variable.php \Drupal\Component\Utility\Variable
- 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Variable.php \Symfony\Component\DependencyInjection\Variable
Same name and namespace in other branches
- 7.2 src/Variable.php \Drupal\service_container\Variable
Provides a injectable version of variable_set() / variable_get().
Note: The main reason why this is not mapped to config is that config has a different thought process: configs + variables inside each config file.
In order to port code from d7 to d8, you would need additional effort here anyway.
@codeCoverageIgnore
Hierarchy
- class \Drupal\service_container\Variable
Expanded class hierarchy of Variable
1 file declares its use of Variable
- Account.php in src/
Session/ Account.php - Contains \Drupal\service_container\Session\Account.
File
- src/
Variable.php, line 23 - Contains \Drupal\service_container\Variable.
Namespace
Drupal\service_containerView source
class Variable {
/**
* The Drupal7 service.
*
* @var \Drupal\service_container\Legacy\Drupal7
*/
protected $drupal7;
/**
* Constructs a new Variable instance.
*
* @param \Drupal\service_container\Legacy\Drupal7 $drupal7
* The Drupal7 service.
*/
public function __construct(Drupal7 $drupal7) {
$this->drupal7 = $drupal7;
}
public function get($name, $default = NULL) {
return $this->drupal7
->variable_get($name, $default);
}
public function set($name, $value) {
$this->drupal7
->variable_set($name, $value);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Variable:: |
protected | property | The Drupal7 service. | |
Variable:: |
public | function | ||
Variable:: |
public | function | ||
Variable:: |
public | function | Constructs a new Variable instance. |