You are here

class WysiwygConfigurationHandler in Configuration Management 7.3

Hierarchy

Expanded class hierarchy of WysiwygConfigurationHandler

File

src/Handlers/WysiwygConfigurationHandler.php, line 9

Namespace

Configuration\Handlers
View source
class WysiwygConfigurationHandler extends ConfigurationHandler {
  public static function getSupportedTypes() {
    return array(
      'wysiwyg',
    );
  }
  public function getIdentifiers() {
    $profiles = array();
    $formats = filter_formats();
    foreach (array_keys($this->configuration_manager
      ->drupal()
      ->wysiwyg_profile_load_all()) as $format) {

      // Text format may vanish without deleting the wysiwyg profile.
      if (isset($formats[$format])) {
        $profiles[$format] = $format;
      }
    }
    return $profiles;
  }
  public function loadFromDatabase($identifier) {
    $name = $this
      ->getInternalId($identifier);
    $configuration = new Configuration();
    $configuration
      ->setIdentifier($identifier);
    $profile = $this->configuration_manager
      ->drupal()
      ->wysiwyg_get_profile($name);
    if (empty($profile)) {
      $profile = new \StdClass();
      $profile->editor = '';
      $profile->format = $name;
      $profile->settings = array();
    }
    $configuration
      ->setData($profile);
    $this->configuration_manager
      ->newDependency($configuration, 'text_format.' . $name);
    $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);
    $profile_array = $event->configuration
      ->getData();
    $profile = new \StdClass();
    $profile->format = $profile_array["format"];
    $profile->editor = $profile_array["editor"];
    $profile->settings = $profile_array["settings"];
    $this->configuration_manager
      ->drupal()
      ->wysiwyg_saveProfile($profile);
    $this->configuration_manager
      ->drupal()
      ->wysiwyg_profile_cache_clear();
  }
  public function removeFromDatabase(Configuration $configuration) {
    $name = $this
      ->getInternalId($configuration
      ->getIdentifier());
    $event = $this
      ->triggerEvent('remove_from_database', $configuration);
    $this->configuration_manager
      ->drupal()
      ->wysiwyg_profile_delete($name);
  }
  public static function getSubscribedEvents() {
    return array(
      'load_from_database.text_format' => array(
        'onTextFormatLoad',
        0,
      ),
    );
  }
  public function onTextFormatLoad($event) {

    // Check if this format is used by any wysiwyg profile
    $name = $this
      ->getInternalId($event->configuration
      ->getIdentifier());
    $profile = $this->configuration_manager
      ->drupal()
      ->wysiwyg_get_profile($name);
    if (!empty($profile)) {
      $this->configuration_manager
        ->newPart($event->configuration, 'wysiwyg.' . $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
WysiwygConfigurationHandler::getIdentifiers public function Returns the configuration identifiers handled by this instance. Overrides ConfigurationHandler::getIdentifiers
WysiwygConfigurationHandler::getSubscribedEvents public static function Overrides ConfigurationHandler::getSubscribedEvents
WysiwygConfigurationHandler::getSupportedTypes public static function Returns the types of configurations that this class can handle. Overrides ConfigurationHandler::getSupportedTypes
WysiwygConfigurationHandler::jsonAsArray protected function Overrides ConfigurationHandler::jsonAsArray
WysiwygConfigurationHandler::loadFromDatabase public function Loads the configuration from the database. Overrides ConfigurationHandler::loadFromDatabase
WysiwygConfigurationHandler::onTextFormatLoad public function
WysiwygConfigurationHandler::removeFromDatabase public function Deletes a configuration from the database. Overrides ConfigurationHandler::removeFromDatabase
WysiwygConfigurationHandler::writeToDatabase public function Saves the given configuration into the database. Overrides ConfigurationHandler::writeToDatabase