class NodeTypeConfigHandler in Node expire 7.2
NodeTypeConfigHandler class.
Defines config handler for particular node type.
Hierarchy
- class \Drupal\node_expire\Module\Config\NodeTypeConfigHandler
Expanded class hierarchy of NodeTypeConfigHandler
File
- src/
Module/ Config/ NodeTypeConfigHandler.php, line 16 - NodeTypeConfigHandler class.
Namespace
Drupal\node_expire\Module\ConfigView source
class NodeTypeConfigHandler {
/**
* Node type.
*
* @var string
*/
protected $nodeType;
/**
* Period.
*
* @var array
*/
protected $nodeTypeConfigs;
/**
* Constructs a NodeTypeConfigHandler object.
*
* @param string $node_type
* Node type.
*/
public function __construct($node_type) {
$this->nodeType = $node_type;
$this
->loadConfig();
}
/**
* Loads configuration array.
*/
protected function loadConfig() {
$this->nodeTypeConfigs = variable_get('node_expire_ntypes', array());
}
/**
* Returns default node type config.
*/
protected function getNodeTypeConfigDefault() {
$config_default = array(
// Current date.
'update_expiry_start' => 1,
// Year.
'update_expiry_interval' => 4,
'update_expiry_multiplier' => 1,
);
return $config_default;
}
/**
* Returns single node type config.
*/
public function getNodeTypeConfig() {
if (isset($this->nodeTypeConfigs[$this->nodeType]) and $n_type_config = $this->nodeTypeConfigs[$this->nodeType]) {
return $n_type_config;
}
else {
return $this
->getNodeTypeConfigDefault();
}
}
/**
* Returns update expiry start.
*/
public function getUpdateExpiryStart() {
$config = $this
->getNodeTypeConfig();
if (isset($config['update_expiry_start'])) {
return $config['update_expiry_start'];
}
else {
return 1;
}
}
/**
* Returns update expiry interval.
*/
public function getUpdateExpiryInterval() {
$config = $this
->getNodeTypeConfig();
if (isset($config['update_expiry_interval'])) {
return $config['update_expiry_interval'];
}
else {
return 4;
}
}
/**
* Returns update expiry multiplier.
*/
public function getUpdateExpiryMultiplier() {
$config = $this
->getNodeTypeConfig();
if (isset($config['update_expiry_multiplier'])) {
return $config['update_expiry_multiplier'];
}
else {
return 1;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NodeTypeConfigHandler:: |
protected | property | Node type. | |
NodeTypeConfigHandler:: |
protected | property | Period. | |
NodeTypeConfigHandler:: |
public | function | Returns single node type config. | |
NodeTypeConfigHandler:: |
protected | function | Returns default node type config. | |
NodeTypeConfigHandler:: |
public | function | Returns update expiry interval. | |
NodeTypeConfigHandler:: |
public | function | Returns update expiry multiplier. | |
NodeTypeConfigHandler:: |
public | function | Returns update expiry start. | |
NodeTypeConfigHandler:: |
protected | function | Loads configuration array. | |
NodeTypeConfigHandler:: |
public | function | Constructs a NodeTypeConfigHandler object. |