You are here

ConfigSplitController.php in Configuration Split 8

Same filename and directory in other branches
  1. 2.0.x src/Controller/ConfigSplitController.php

File

src/Controller/ConfigSplitController.php
View source
<?php

namespace Drupal\config_split\Controller;

use Drupal\Core\Controller\ControllerBase;

/**
 * The controller for split actions.
 */
class ConfigSplitController extends ControllerBase {

  /**
   * Enable the split.
   *
   * @param string $config_split
   *   The split name.
   *
   * @return \Symfony\Component\HttpFoundation\RedirectResponse
   *   The response.
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   * @throws \Drupal\Core\Entity\EntityStorageException
   */
  public function enableEntity($config_split) {
    $entity = $this
      ->entityTypeManager()
      ->getStorage('config_split')
      ->load($config_split);
    $entity
      ->set('status', TRUE);
    $entity
      ->save();
    return $this
      ->redirect('entity.config_split.collection');
  }

  /**
   * Disable the split.
   *
   * @param string $config_split
   *   The split name.
   *
   * @return \Symfony\Component\HttpFoundation\RedirectResponse
   *   The response.
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   * @throws \Drupal\Core\Entity\EntityStorageException
   */
  public function disableEntity($config_split) {
    $entity = $this
      ->entityTypeManager()
      ->getStorage('config_split')
      ->load($config_split);
    $entity
      ->set('status', FALSE);
    $entity
      ->save();
    return $this
      ->redirect('entity.config_split.collection');
  }

}

Classes

Namesort descending Description
ConfigSplitController The controller for split actions.