Loading config/schema/environment_indicator.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,9 @@ environment_indicator.switcher.*: name: type: string label: 'Name' weight: type: string label: 'Name' url: type: uri label: 'URL' Loading environment_indicator.module +3 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ function environment_indicator_page_top(array &$page_top) { // Only add the environment indicator switcher if there are environments to // switch to. if ($items = _environment_indicator_switcher_links()) { uasort($items, 'Drupal\Component\Utility\SortArray::sortByWeightElement'); $page_top['indicator']['switcher'] = [ '#theme' => 'links', '#links' => $items, Loading Loading @@ -269,6 +270,7 @@ function _environment_indicator_switcher_toolbar_links() { if (!$items = _environment_indicator_switcher_links()) { return []; }; uasort($items, 'Drupal\Component\Utility\SortArray::sortByWeightElement'); $menu = [ '#theme' => 'links__toolbar_shortcuts', '#links' => $items, Loading Loading @@ -307,6 +309,7 @@ function _environment_indicator_switcher_links() { 'title' => t('Open in: @label', ['@label' => $entity->label()]), 'url' => Url::fromUri($entity->getUrl() . $current_path), 'type' => 'link', 'weight' => $entity->getWeight(), ]; }, array_filter( Loading src/Entity/EnvironmentIndicator.php +28 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface; * "description", * "name", * "url", * "weight", * "fg_color", * "bg_color", * } Loading Loading @@ -67,6 +68,13 @@ class EnvironmentIndicator extends ConfigEntityBase implements ConfigEntityInter */ public $url; /** * The switchers link weight. * * @var string */ public $weight; /** * The color code for the indicator. * Loading Loading @@ -105,6 +113,16 @@ class EnvironmentIndicator extends ConfigEntityBase implements ConfigEntityInter return $this->get('url'); } /** * Gets the weight. * * @return string * The weight of switcher environment. */ public function getWeight() { return $this->get('weight'); } /** * Gets the foreground color. * Loading Loading @@ -145,6 +163,16 @@ class EnvironmentIndicator extends ConfigEntityBase implements ConfigEntityInter $this->set('name', $name); } /** * Sets the weight. * * @param string $weight * The environment link weight. */ public function setWeight($weight) { $this->set('weight', $weight); } /** * Sets the URL. * Loading src/EnvironmentIndicatorForm.php +7 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,13 @@ class EnvironmentIndicatorForm extends EntityForm { '#description' => $this->t('The hostname you want to switch to.'), '#default_value' => $environment_switcher->getUrl(), ]; $form['weight'] = [ '#type' => 'textfield', '#title' => $this->t('Weight'), '#default_value' => $environment_switcher->getWeight(), ]; $form['bg_color'] = [ '#type' => 'color', '#title' => $this->t('Background Color'), Loading Loading
config/schema/environment_indicator.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,9 @@ environment_indicator.switcher.*: name: type: string label: 'Name' weight: type: string label: 'Name' url: type: uri label: 'URL' Loading
environment_indicator.module +3 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ function environment_indicator_page_top(array &$page_top) { // Only add the environment indicator switcher if there are environments to // switch to. if ($items = _environment_indicator_switcher_links()) { uasort($items, 'Drupal\Component\Utility\SortArray::sortByWeightElement'); $page_top['indicator']['switcher'] = [ '#theme' => 'links', '#links' => $items, Loading Loading @@ -269,6 +270,7 @@ function _environment_indicator_switcher_toolbar_links() { if (!$items = _environment_indicator_switcher_links()) { return []; }; uasort($items, 'Drupal\Component\Utility\SortArray::sortByWeightElement'); $menu = [ '#theme' => 'links__toolbar_shortcuts', '#links' => $items, Loading Loading @@ -307,6 +309,7 @@ function _environment_indicator_switcher_links() { 'title' => t('Open in: @label', ['@label' => $entity->label()]), 'url' => Url::fromUri($entity->getUrl() . $current_path), 'type' => 'link', 'weight' => $entity->getWeight(), ]; }, array_filter( Loading
src/Entity/EnvironmentIndicator.php +28 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface; * "description", * "name", * "url", * "weight", * "fg_color", * "bg_color", * } Loading Loading @@ -67,6 +68,13 @@ class EnvironmentIndicator extends ConfigEntityBase implements ConfigEntityInter */ public $url; /** * The switchers link weight. * * @var string */ public $weight; /** * The color code for the indicator. * Loading Loading @@ -105,6 +113,16 @@ class EnvironmentIndicator extends ConfigEntityBase implements ConfigEntityInter return $this->get('url'); } /** * Gets the weight. * * @return string * The weight of switcher environment. */ public function getWeight() { return $this->get('weight'); } /** * Gets the foreground color. * Loading Loading @@ -145,6 +163,16 @@ class EnvironmentIndicator extends ConfigEntityBase implements ConfigEntityInter $this->set('name', $name); } /** * Sets the weight. * * @param string $weight * The environment link weight. */ public function setWeight($weight) { $this->set('weight', $weight); } /** * Sets the URL. * Loading
src/EnvironmentIndicatorForm.php +7 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,13 @@ class EnvironmentIndicatorForm extends EntityForm { '#description' => $this->t('The hostname you want to switch to.'), '#default_value' => $environment_switcher->getUrl(), ]; $form['weight'] = [ '#type' => 'textfield', '#title' => $this->t('Weight'), '#default_value' => $environment_switcher->getWeight(), ]; $form['bg_color'] = [ '#type' => 'color', '#title' => $this->t('Background Color'), Loading