You are here

public function TextFormatConfigurationHandler::onPermissionLoad in Configuration Management 7.3

File

src/Handlers/TextFormatConfigurationHandler.php, line 82

Class

TextFormatConfigurationHandler

Namespace

Configuration\Handlers

Code

public function onPermissionLoad($event) {

  // Search for permissions that match: 'use text format ' . $format->format
  $permission = $event->configuration
    ->getData();
  if (strpos($permission['permission'], 'user text format') !== FALSE) {
    foreach ($this->configuration_manager
      ->drupal()
      ->filter_formats() as $format) {
      $permission = $this->configuration_manager
        ->drupal()
        ->filter_permission_name($format);
      if (!empty($permission)) {
        $data = $event->configuration
          ->getData();
        if ($permission == $data['permission']) {
          $this->configuration_manager
            ->newDependency($event->configuration, 'text_format.' . $format->format);

          // Match found, no other text format will match.
          break;
        }
      }
    }
  }
}