You are here

class MenuConfigurationHandler in Configuration Management 7.3

Hierarchy

Expanded class hierarchy of MenuConfigurationHandler

File

src/Handlers/MenuConfigurationHandler.php, line 9

Namespace

Configuration\Handlers
View source
class MenuConfigurationHandler extends ConfigurationHandler {
  public static function getSupportedTypes() {
    return array(
      'menu',
    );
  }
  public function getIdentifiers() {
    return $this->configuration_manager
      ->drupal()
      ->menu_getIdentifiers();
  }
  public function loadFromDatabase($identifier) {
    $name = $this
      ->getInternalId($identifier);
    $menu = $this->configuration_manager
      ->drupal()
      ->menu_load(str_replace('_', '-', $name));
    $configuration = new Configuration();
    $configuration
      ->setIdentifier($identifier);
    $configuration
      ->setData($menu);
    $event = $this
      ->triggerEvent('load_from_database', $configuration);
    return $event->configuration;
  }
  public function writeToDatabase(Configuration $configuration) {
    $name = $this
      ->getInternalId($configuration
      ->getIdentifier());
    $event = $this
      ->triggerEvent('write_to_database', $configuration);
    $this->configuration_manager
      ->drupal()
      ->menu_save($event->configuration
      ->getData());
  }
  public function removeFromDatabase(Configuration $configuration) {
    $name = $this
      ->getInternalId($configuration
      ->getIdentifier());
    $event = $this
      ->triggerEvent('remove_from_database', $configuration);
    $this->configuration_manager
      ->drupal()
      ->menu_delete($event->configuration
      ->getData());
  }
  public static function getSubscribedEvents() {
    return array(
      'load_from_database.menu_link' => array(
        'onMenuLinkLoad',
        0,
      ),
    );
  }
  public function onMenuLinkLoad($event) {
    $menu_link = $event->configuration
      ->getData();

    // Only for menu links in the parent level
    if (empty($menu_link['plid'])) {
      $menu_name = 'menu.' . str_replace('-', '_', $menu_link['menu_name']);
      $this->configuration_manager
        ->newDependency($event->configuration, $menu_name);
    }
  }
  protected function jsonAsArray() {
    return TRUE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurationHandler::$configuration_manager protected property
ConfigurationHandler::$type protected property
ConfigurationHandler::export public function Generates the JSON representation of this configuration.
ConfigurationHandler::exportToJson protected function
ConfigurationHandler::getExportPath public function
ConfigurationHandler::getInternalId protected function
ConfigurationHandler::getType public function
ConfigurationHandler::getTypeFromId protected function
ConfigurationHandler::import public function
ConfigurationHandler::importFromJson public function
ConfigurationHandler::importFromJsonAsArray protected function 1
ConfigurationHandler::registerProcessors protected function 2
ConfigurationHandler::triggerEvent protected function
ConfigurationHandler::__construct public function 1
MenuConfigurationHandler::getIdentifiers public function Returns the configuration identifiers handled by this instance. Overrides ConfigurationHandler::getIdentifiers
MenuConfigurationHandler::getSubscribedEvents public static function Overrides ConfigurationHandler::getSubscribedEvents
MenuConfigurationHandler::getSupportedTypes public static function Returns the types of configurations that this class can handle. Overrides ConfigurationHandler::getSupportedTypes
MenuConfigurationHandler::jsonAsArray protected function Overrides ConfigurationHandler::jsonAsArray
MenuConfigurationHandler::loadFromDatabase public function Loads the configuration from the database. Overrides ConfigurationHandler::loadFromDatabase
MenuConfigurationHandler::onMenuLinkLoad public function
MenuConfigurationHandler::removeFromDatabase public function Deletes a configuration from the database. Overrides ConfigurationHandler::removeFromDatabase
MenuConfigurationHandler::writeToDatabase public function Saves the given configuration into the database. Overrides ConfigurationHandler::writeToDatabase