3 namespace Drupal\environment_indicator\Entity;
5 use Drupal\Core\Config\Entity\ConfigEntityBase;
6 use Drupal\Core\Config\Entity\ConfigEntityInterface;
7 use Drupal\Core\Entity\Annotation\EntityType;
8 use Drupal\Core\Annotation\Translation;
11 * Defines a Environment configuration entity.
14 * id = "environment_indicator",
15 * label = @Translation("Environment Switcher"),
17 * "storage" = "Drupal\Core\Config\Entity\ConfigEntityStorage",
18 * "access" = "Drupal\environment_indicator\EnvironmentIndicatorAccessControlHandler",
19 * "list_builder" = "Drupal\environment_indicator\EnvironmentIndicatorListBuilder",
21 * "default" = "Drupal\environment_indicator\EnvironmentIndicatorForm",
22 * "delete" = "Drupal\Core\Entity\EntityDeleteForm"
25 * admin_permission = "administer environment indicator settings",
26 * config_prefix = "switcher",
27 * static_cache = TRUE,
30 * "label" = "human_name",
34 * "edit-form" = "/admin/config/development/environment-indicator/manage/{environment_indicator}",
35 * "edit-permissions-form" = "/admin/people/permissions/{user_role}",
36 * "delete-form" = "/admin/config/development/environment-indicator/manage/{environment_indicator}/delete",
37 * "collection" = "/admin/config/development/environment-indicator"
41 class EnvironmentIndicator extends ConfigEntityBase implements ConfigEntityInterface {
44 * The machine-readable ID for the configurable.
51 * The human-readable label for the configurable.
58 * The URL to switch to.
65 * The color code for the indicator.
72 * The color code for the indicator.
82 public function id() {
83 return $this->get('machine');
89 public function label($langcode = NULL) {
90 return $this->get('name');
98 public function getUrl() {
99 return $this->get('url');
103 * Gets the foreground color.
107 public function getFgColor() {
108 return $this->get('fg_color');
112 * Gets the background color.
116 public function getBgColor() {
117 return $this->get('bg_color');
121 * Gets the machine name.
123 * @param string $machine
125 public function setMachine($machine) {
126 $this->set('machine', $machine);
132 * @param string $name
134 public function setName($name) {
135 $this->set('name', $name);
143 public function setUrl($url) {
144 $this->set('url', $url);
148 * Sets the foreground color.
150 * @param string $fg_color
152 public function setFgColor($fg_color) {
153 $this->set('fg_color', $fg_color);
157 * Sets the background color.
159 * @param string $bg_color
161 public function setBgColor($bg_color) {
162 $this->set('bg_color', $bg_color);