EventTypeRule.php in RNG - Events and Registrations 8.2
File
src/Entity/EventTypeRule.php
View source
<?php
namespace Drupal\rng\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
class EventTypeRule extends ConfigEntityBase implements EventTypeRuleInterface {
protected $entity_type;
protected $bundle;
protected $machine_name;
protected $trigger;
protected $conditions = [];
protected $actions = [];
public function id() {
return $this->entity_type . '.' . $this->bundle . '.' . $this->machine_name;
}
public function getEventEntityTypeId() {
return $this->entity_type;
}
public function getEventBundle() {
return $this->bundle;
}
public function getMachineName() {
return $this->machine_name;
}
public function getTrigger() {
return $this->trigger;
}
public function getConditions() {
return $this->conditions;
}
public function getActions() {
return $this->actions;
}
public function getCondition($name) {
return isset($this->conditions[$name]) ? $this->conditions[$name] : NULL;
}
public function getAction($name) {
return isset($this->actions[$name]) ? $this->actions[$name] : NULL;
}
public function setCondition($name, $configuration) {
$this->conditions[$name] = $configuration;
return $this;
}
public function setAction($name, $configuration) {
$this->actions[$name] = $configuration;
return $this;
}
public function removeCondition($name) {
unset($this->conditions[$name]);
return $this;
}
public function removeAction($name) {
unset($this->actions[$name]);
return $this;
}
public function calculateDependencies() {
parent::calculateDependencies();
if ($event_type = RngEventType::load($this
->getEventEntityTypeId() . '.' . $this
->getEventBundle())) {
$this
->addDependency('config', $event_type
->getConfigDependencyName());
}
return $this;
}
}