コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     list($old_visibility, $pages, $roles) = $value;
     $visibility = array();
     // If the block is assigned to specific roles, add the user_role condition.
     if ($roles) {
         $visibility['user_role'] = array('id' => 'user_role', 'roles' => array(), 'context_mapping' => array('user' => '@user.current_user_context:current_user'), 'negate' => FALSE);
         foreach ($roles as $key => $role_id) {
             $roles[$key] = $this->migrationPlugin->transform($role_id, $migrate_executable, $row, $destination_property);
         }
         $visibility['user_role']['roles'] = array_combine($roles, $roles);
     }
     if ($pages) {
         // 2 == BLOCK_VISIBILITY_PHP in Drupal 6 and 7.
         if ($old_visibility == 2) {
             // If the PHP module is present, migrate the visibility code unaltered.
             if ($this->moduleHandler->moduleExists('php')) {
                 $visibility['php'] = array('id' => 'php', 'negate' => FALSE, 'php' => $pages);
             } elseif ($this->skipPHP) {
                 throw new MigrateSkipRowException();
             }
         } else {
             $paths = preg_split("(\r\n?|\n)", $pages);
             foreach ($paths as $key => $path) {
                 $paths[$key] = $path === '<front>' ? $path : '/' . ltrim($path, '/');
             }
             $visibility['request_path'] = array('id' => 'request_path', 'negate' => !$old_visibility, 'pages' => implode("\n", $paths));
         }
     }
     return $visibility;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection)
 {
     foreach ($collection as $name => $route) {
         if ($route->hasRequirement('_module_dependencies')) {
             $modules = $route->getRequirement('_module_dependencies');
             $explode_and = $this->explodeString($modules, '+');
             if (count($explode_and) > 1) {
                 foreach ($explode_and as $module) {
                     // If any moduleExists() call returns FALSE, remove the route and
                     // move on to the next.
                     if (!$this->moduleHandler->moduleExists($module)) {
                         $collection->remove($name);
                         continue 2;
                     }
                 }
             } else {
                 // OR condition, exploding on ',' character.
                 foreach ($this->explodeString($modules, ',') as $module) {
                     if ($this->moduleHandler->moduleExists($module)) {
                         continue 2;
                     }
                 }
                 // If no modules are found, and we get this far, remove the route.
                 $collection->remove($name);
             }
         }
     }
 }
コード例 #3
0
ファイル: ConfigForm.php プロジェクト: shahinam/drupal8devel
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('xhprof.config');
     $extension_loaded = $this->profiler->isLoaded();
     if ($extension_loaded) {
         $help = $this->t('Profile requests with the XHProf or uprofiler php extension.');
     } else {
         $help = $this->t('You must enable the !xhprof or !uprofiler php extension.', ['!xhprof' => $this->l('XHProf', Url::fromUri('https://www.drupal.org/node/946182')), '!uprofiler' => $this->l('uprofiler', Url::fromUri('https://github.com/FriendsOfPHP/uprofiler'))]);
     }
     $form['help'] = array('#type' => 'inline_template', '#template' => '<span class="warning">{{ help }}</span>', '#context' => array('help' => $help));
     $form['enabled'] = array('#type' => 'checkbox', '#title' => $this->t('Enable profiling of page views.'), '#default_value' => $extension_loaded & $config->get('enabled'), '#disabled' => !$extension_loaded);
     $form['settings'] = array('#title' => $this->t('Profiling settings'), '#type' => 'details', '#open' => TRUE, '#states' => array('invisible' => array('input[name="enabled"]' => array('checked' => FALSE))));
     $form['settings']['extension'] = array('#type' => 'select', '#title' => $this->t('Extension'), '#options' => $this->profiler->getExtensions(), '#default_value' => $config->get('extension'), '#description' => $this->t('Choose the extension to use for profiling. The recommended extension is !uprofiler because it is actively maintained.', ['!uprofiler' => $this->l('uprofiler', Url::fromUri('https://github.com/FriendsOfPHP/uprofiler'))]));
     $form['settings']['exclude'] = array('#type' => 'textarea', '#title' => $this->t('Exclude'), '#default_value' => $config->get('exclude'), '#description' => $this->t('Path to exclude for profiling. One path per line.'));
     $form['settings']['interval'] = array('#type' => 'number', '#title' => 'Profiling interval', '#min' => 0, '#default_value' => $config->get('interval'), '#description' => $this->t('The approximate number of requests between XHProf samples. Leave zero to profile all requests.'));
     $flags = array('FLAGS_CPU' => $this->t('Cpu'), 'FLAGS_MEMORY' => $this->t('Memory'), 'FLAGS_NO_BUILTINS' => $this->t('Exclude PHP builtin functions'));
     $form['settings']['flags'] = array('#type' => 'checkboxes', '#title' => 'Profile', '#options' => $flags, '#default_value' => $config->get('flags'), '#description' => $this->t('Flags to choose what profile.'));
     $form['settings']['exclude_indirect_functions'] = array('#type' => 'checkbox', '#title' => 'Exclude indirect functions', '#default_value' => $config->get('exclude_indirect_functions'), '#description' => $this->t('Exclude functions like %call_user_func and %call_user_func_array.', array('%call_user_func' => 'call_user_func', '%call_user_func_array' => 'call_user_func_array')));
     $options = $this->storageManager->getStorages();
     $form['settings']['storage'] = array('#type' => 'radios', '#title' => $this->t('Profile storage'), '#default_value' => $config->get('storage'), '#options' => $options, '#description' => $this->t('Choose the storage class.'));
     if ($this->moduleHandler->moduleExists('webprofiler')) {
         $form['webprofiler'] = array('#title' => $this->t('Webprofiler integration'), '#type' => 'details', '#open' => TRUE, '#states' => array('invisible' => array('input[name="enabled"]' => array('checked' => FALSE))));
         $form['webprofiler']['show_summary_toolbar'] = array('#type' => 'checkbox', '#title' => $this->t('Show summary data in toolbar.'), '#default_value' => $config->get('show_summary_toolbar'), '#description' => $this->t('Show data from the overall summary directly into the Webprofiler toolbar. May slow down the toolbar rendering.'));
     }
     return parent::buildForm($form, $form_state);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function enhance(array $defaults, Request $request)
 {
     if (!$this->moduleHandler->moduleExists('ctools')) {
         $defaults['_controller'] = '\\Drupal\\entity_browser\\Controllers\\CtoolsFallback::displayMessage';
     }
     return $defaults;
 }
コード例 #5
0
ファイル: MetatagToken.php プロジェクト: k-zafar/barney_river
 /**
  * Gatekeeper function to direct to either the core or contributed Token.
  *
  * @return array
  *   If token module is installed, a popup browser plus a help text. If not
  *   only the help text.
  */
 public function tokenBrowser()
 {
     $form = array();
     $form['intro_text'] = array('#markup' => '<p>' . t('Configure the meta tags below. Use tokens to avoid redundant meta data and search engine penalization. For example, a \'keyword\' value of "example" will be shown on all content using this configuration, whereas using the [node:field_keywords] automatically inserts the "keywords" values from the current entity (node, term, etc).') . '</p>');
     if ($this->moduleHandler->moduleExists('token')) {
         $form['tokens'] = array('#theme' => 'token_tree_link', '#token_types' => 'all', '#global_types' => TRUE, '#click_insert' => TRUE, '#show_restricted' => FALSE, '#recursion_limit' => 3, '#text' => t('Browse available tokens'));
     }
     return $form;
 }
コード例 #6
0
ファイル: MetatagToken.php プロジェクト: dmyerson/d8ecs
 /**
  * Gatekeeper function to direct to either the core or contributed Token.
  *
  * @return mixed
  */
 public function tokenBrowser()
 {
     // @TODO: Make these optionally return rendered HTML instead of an an array.
     if ($this->moduleHandler->moduleExists('token')) {
         return $this->contribBrowser();
     } else {
         return $this->coreBrowser();
     }
 }
コード例 #7
0
 function __construct(EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler)
 {
     $this->entityManger = $entity_manager;
     $this->moduleHandler = $module_handler;
     if ($this->entityManger && $this->moduleHandler->moduleExists('taxonomy')) {
         $this->termStorage = $this->entityManger->getStorage('taxonomy_term');
         $this->vocabularyStorage = $this->entityManger->getStorage('taxonomy_vocabulary');
     }
 }
コード例 #8
0
 /**
  * An example of a controller method.
  *
  * @return array
  *   A string or render array to be processed by the rendering engine.
  */
 public function foobarPage()
 {
     if ($this->moduleHandler->moduleExists('devel')) {
         $build = array('#markup' => t('This is the developers demo foobar page, yay!'));
     } else {
         $build = array('#markup' => t('This is the demo foobar page.'));
     }
     return $build;
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->config('statistics.settings')->set('count_content_views', $form_state->getValue('statistics_count_content_views'))->save();
     // The popular statistics block is dependent on these settings, so clear the
     // block plugin definitions cache.
     if ($this->moduleHandler->moduleExists('block')) {
         \Drupal::service('plugin.manager.block')->clearCachedDefinitions();
     }
     parent::submitForm($form, $form_state);
 }
コード例 #10
0
 /**
  * Initializes devel module requirements.
  */
 public function onRequest(GetResponseEvent $event)
 {
     if (!devel_silent()) {
         if ($this->account->hasPermission('access devel information')) {
             devel_set_handler(devel_get_handlers());
             // We want to include the class early so that anyone may call krumo()
             // as needed. See http://krumo.sourceforge.net/
             has_krumo();
             // See http://www.firephp.org/HQ/Install.htm
             $path = NULL;
             if (@(include_once 'fb.php') || @(include_once 'FirePHPCore/fb.php')) {
                 // FirePHPCore is in include_path. Probably a PEAR installation.
                 $path = '';
             } elseif ($this->moduleHandler->moduleExists('libraries')) {
                 // Support Libraries API - http://drupal.org/project/libraries
                 $firephp_path = libraries_get_path('FirePHPCore');
                 $firephp_path = $firephp_path ? $firephp_path . '/lib/FirePHPCore/' : '';
                 $chromephp_path = libraries_get_path('chromephp');
             } else {
                 $firephp_path = DRUPAL_ROOT . '/libraries/FirePHPCore/lib/FirePHPCore/';
                 $chromephp_path = './' . drupal_get_path('module', 'devel') . '/chromephp';
             }
             // Include FirePHP if it exists.
             if (!empty($firephp_path) && file_exists($firephp_path . 'fb.php')) {
                 include_once $firephp_path . 'fb.php';
                 include_once $firephp_path . 'FirePHP.class.php';
             }
             // Include ChromePHP if it exists.
             if (!empty($chromephp_path) && file_exists($chromephp_path .= '/ChromePhp.php')) {
                 include_once $chromephp_path;
             }
         }
     }
     if ($this->config->get('rebuild_theme')) {
         drupal_theme_rebuild();
         // Ensure that the active theme object is cleared.
         $theme_name = \Drupal::theme()->getActiveTheme()->getName();
         \Drupal::state()->delete('theme.active_theme.' . $theme_name);
         \Drupal::theme()->resetActiveTheme();
         /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler*/
         $theme_handler = \Drupal::service('theme_handler');
         $theme_handler->refreshInfo();
         // @todo This is not needed after https://www.drupal.org/node/2330755
         $list = $theme_handler->listInfo();
         $theme_handler->addTheme($list[$theme_name]);
         if (\Drupal::service('flood')->isAllowed('devel.rebuild_theme_warning', 1)) {
             \Drupal::service('flood')->register('devel.rebuild_theme_warning');
             if (!devel_silent() && $this->account->hasPermission('access devel information')) {
                 drupal_set_message(t('The theme information is being rebuilt on every request. Remember to <a href="@url">turn off</a> this feature on production websites.', array('@url' => $this->urlGenerator->generateFromRoute('devel.admin_settings'))));
             }
         }
     }
     drupal_register_shutdown_function('devel_shutdown');
 }
コード例 #11
0
 /**
  * {@inheritdoc}
  */
 public function installDependencies()
 {
     $modules = ['migrate', 'migrate_drupal'];
     foreach ($modules as $i => $module) {
         if ($this->moduleHandler->moduleExists($module)) {
             unset($modules[$i]);
         }
     }
     if (!empty($modules)) {
         $this->moduleInstaller->install($modules, TRUE);
     }
     return $this;
 }
コード例 #12
0
 /**
  * Initializes devel module requirements.
  */
 public function onRequest(GetResponseEvent $event)
 {
     if (!devel_silent()) {
         if ($this->config->get('memory')) {
             global $memory_init;
             $memory_init = memory_get_usage();
         }
         if (devel_query_enabled()) {
             Database::startLog('devel');
         }
         if ($this->account->hasPermission('access devel information')) {
             devel_set_handler(devel_get_handlers());
             // We want to include the class early so that anyone may call krumo()
             // as needed. See http://krumo.sourceforge.net/
             has_krumo();
             // See http://www.firephp.org/HQ/Install.htm
             $path = NULL;
             if (@(include_once 'fb.php') || @(include_once 'FirePHPCore/fb.php')) {
                 // FirePHPCore is in include_path. Probably a PEAR installation.
                 $path = '';
             } elseif ($this->moduleHandler->moduleExists('libraries')) {
                 // Support Libraries API - http://drupal.org/project/libraries
                 $firephp_path = libraries_get_path('FirePHPCore');
                 $firephp_path = $firephp_path ? $firephp_path . '/lib/FirePHPCore/' : '';
                 $chromephp_path = libraries_get_path('chromephp');
             } else {
                 $firephp_path = DRUPAL_ROOT . '/libraries/FirePHPCore/lib/FirePHPCore/';
                 $chromephp_path = './' . drupal_get_path('module', 'devel') . '/chromephp';
             }
             // Include FirePHP if it exists.
             if (!empty($firephp_path) && file_exists($firephp_path . 'fb.php')) {
                 include_once $firephp_path . 'fb.php';
                 include_once $firephp_path . 'FirePHP.class.php';
             }
             // Include ChromePHP if it exists.
             if (!empty($chromephp_path) && file_exists($chromephp_path .= '/ChromePhp.php')) {
                 include_once $chromephp_path;
             }
         }
     }
     if ($this->config->get('rebuild_theme_registry')) {
         drupal_theme_rebuild();
         if (\Drupal::service('flood')->isAllowed('devel.rebuild_registry_warning', 1)) {
             \Drupal::service('flood')->register('devel.rebuild_registry_warning');
             if (!devel_silent() && $this->account->hasPermission('access devel information')) {
                 drupal_set_message(t('The theme registry is being rebuilt on every request. Remember to <a href="!url">turn off</a> this feature on production websites.', array("!url" => url('admin/config/development/devel'))));
             }
         }
     }
     drupal_register_shutdown_function('devel_shutdown');
 }
コード例 #13
0
 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     $row['label'] = $this->getLabel($entity);
     if ($this->moduleHandler->moduleExists('language')) {
         if (isset($entity->context['language'])) {
             $language = $this->languageManager->getLanguage($entity->context['language']);
             $row['language'] = $language->getName();
         } else {
             $row['language'] = $this->t('Undefined');
         }
     }
     $row['id'] = $entity->id();
     // You probably want a few more properties here...
     return $row + parent::buildRow($entity);
 }
コード例 #14
0
 /**
  * Initializes and returns a package or profile array.
  *
  * @param string $machine_name
  *   Machine name of the package.
  * @param string $name
  *   (optional) Human readable name of the package.
  * @param string $description
  *   (optional) Description of the package.
  * @param string $type
  *   (optional) Type of project.
  * @param \Drupal\features\FeaturesBundleInterface $bundle
  *   (optional) Bundle to use to add profile directories to the scan.
  * @param \Drupal\Core\Extension\Extension $extension
  *   (optional) An Extension object.
  *
  * @return \Drupal\features\Package
  *   An array of package properties; see
  *   FeaturesManagerInterface::getPackages().
  */
 protected function getPackageObject($machine_name, $name = NULL, $description = '', $type = 'module', FeaturesBundleInterface $bundle = NULL, Extension $extension = NULL)
 {
     if (!isset($bundle)) {
         $bundle = $this->getAssigner()->getBundle();
     }
     $package = new Package($machine_name, ['name' => isset($name) ? $name : ucwords(str_replace(['_', '-'], ' ', $machine_name)), 'description' => $description, 'type' => $type, 'core' => Drupal::CORE_COMPATIBILITY, 'dependencies' => [], 'themes' => [], 'config' => [], 'status' => FeaturesManagerInterface::STATUS_DEFAULT, 'version' => '', 'state' => FeaturesManagerInterface::STATE_DEFAULT, 'directory' => $machine_name, 'files' => [], 'bundle' => $bundle->isDefault() ? '' : $bundle->getMachineName(), 'extension' => NULL, 'info' => [], 'configOrig' => []]);
     // If no extension was passed in, look for a match.
     if (!isset($extension)) {
         $module_list = $this->getFeaturesModules($bundle);
         $full_name = $bundle->getFullName($package->getMachineName());
         if (isset($module_list[$full_name])) {
             $extension = $module_list[$full_name];
         }
     }
     // If there is an extension, set extension-specific properties.
     if (isset($extension)) {
         $info = $this->getExtensionInfo($extension);
         $features_info = $this->getFeaturesInfo($extension);
         $package->setExtension($extension);
         $package->setInfo($info);
         $package->setFeaturesInfo($features_info);
         $package->setConfigOrig($this->listExtensionConfig($extension));
         $package->setStatus($this->moduleHandler->moduleExists($extension->getName()) ? FeaturesManagerInterface::STATUS_INSTALLED : FeaturesManagerInterface::STATUS_UNINSTALLED);
         $package->setVersion(isset($info['version']) ? $info['version'] : '');
     }
     return $package;
 }
コード例 #15
0
  /**
   * Helper function.
   *
   * Get the image styles mapping plugin which dependencies are enabled.
   */
  public function getActiveImageStylesMappingPlugins() {
    $active_image_styles_mapping_plugins = array();

    // Get the plugins.
    $image_styles_mapping_plugins_definitions = $this->imageStylesMappingPluginManager->getDefinitions();
    foreach ($image_styles_mapping_plugins_definitions as $plugin_id => $plugin_definition) {
      $dependencies = TRUE;
      // Instantiate the plugin.
      $plugin = $this->imageStylesMappingPluginManager->createInstance($plugin_id, array());
      // Check dependencies.
      foreach ($plugin->getDependencies() as $module_name) {
        if (!$this->moduleHandler->moduleExists($module_name)) {
          $dependencies = FALSE;
          break;
        }
      }

      // Add the plugin if all dependencies are satisfied.
      if ($dependencies) {
        $active_image_styles_mapping_plugins[] = $plugin;
      }
    }

    return $active_image_styles_mapping_plugins;
  }
コード例 #16
0
 /**
  * Overrides \Drupal\block\BlockBase::blockSubmit().
  */
 public function blockSubmit($form, FormStateInterface $form_state)
 {
     $this->configuration['search_box'] = array('label_visibility' => $form_state->getValue(array('search_box', 'label_visibility')), 'label' => $form_state->getValue(array('search_box', 'label')), 'placeholder' => $form_state->getValue(array('search_box', 'placeholder')), 'title' => $form_state->getValue(array('search_box', 'title')), 'size' => $form_state->getValue(array('search_box', 'size')), 'max_length' => $form_state->getValue(array('search_box', 'max_length')), 'weight' => $form_state->getValue(array('order', 'table', 'search_box', 'weight')), 'region' => $form_state->getValue(array('order', 'table', 'search_box', 'region')));
     $this->configuration['submit'] = array('text' => $form_state->getValue(array('submit', 'text')), 'weight' => $form_state->getValue(array('order', 'table', 'submit', 'weight')), 'region' => $form_state->getValue(array('order', 'table', 'submit', 'region')));
     // If the user uploaded a new submit image, save it to a permanent location.
     if ($this->moduleHandler->moduleExists('file')) {
         // If the user entered a path relative to the system files directory for the submit image,
         // store a public:// URI so the theme system can handle it.
         if (!$form_state->isValueEmpty(array('submit', 'image_path'))) {
             $this->configuration['submit']['image_path'] = $this->validatePath($form_state->getValue(array('submit', 'image_path')));
         }
     }
     $this->configuration['content'] = array('page' => $form_state->getValue(array('content', 'page')), 'types' => $form_state->getValue(array('content', 'types')), 'other' => $form_state->getValue(array('content', 'other')), 'selector' => array('type' => $form_state->getValue(array('content', 'selector', 'type')), 'label_visibility' => $form_state->getValue(array('content', 'selector', 'label_visibility')), 'label' => $form_state->getValue(array('content', 'selector', 'label'))), 'any' => array('text' => $form_state->getValue(array('content', 'any', 'text')), 'restricts' => $form_state->getValue(array('content', 'any', 'restricts')), 'force' => $form_state->getValue(array('content', 'any', 'force'))), 'excluded' => $form_state->getValue(array('content', 'excluded')), 'weight' => $form_state->getValue(array('order', 'table', 'content', 'weight')), 'region' => $form_state->getValue(array('order', 'table', 'content', 'region')));
     $vocabularies = entity_load_multiple('taxonomy_vocabulary');
     if (count($vocabularies)) {
         foreach ($vocabularies as $voc) {
             $vocId = $voc->id();
             $this->configuration['taxonomy'][$vocId] = array('type' => $form_state->getValue(array('taxonomy', $vocId, 'type')), 'depth' => $form_state->getValue(array('taxonomy', $vocId, 'depth')), 'label_visibility' => $form_state->getValue(array('taxonomy', $vocId, 'label_visibility')), 'label' => $form_state->getValue(array('taxonomy', $vocId, 'label')), 'all_text' => $form_state->getValue(array('taxonomy', $vocId, 'all_text')), 'weight' => $form_state->getValue(array('order', 'table', 'voc-' . $vocId, 'weight')), 'region' => $form_state->getValue(array('order', 'table', 'voc-' . $vocId, 'region')));
         }
     }
     $this->configuration['criteria'] = array('or' => array('display' => $form_state->getValue(array('criteria', 'or', 'display')), 'label' => $form_state->getValue(array('criteria', 'or', 'label')), 'weight' => $form_state->getValue(array('order', 'table', 'or', 'weight')), 'region' => $form_state->getValue(array('order', 'table', 'or', 'region'))), 'phrase' => array('display' => $form_state->getValue(array('criteria', 'phrase', 'display')), 'label' => $form_state->getValue(array('criteria', 'phrase', 'label')), 'weight' => $form_state->getValue(array('order', 'table', 'phrase', 'weight')), 'region' => $form_state->getValue(array('order', 'table', 'phrase', 'region'))), 'negative' => array('display' => $form_state->getValue(array('criteria', 'negative', 'display')), 'label' => $form_state->getValue(array('criteria', 'negative', 'label')), 'weight' => $form_state->getValue(array('order', 'table', 'negative', 'weight')), 'region' => $form_state->getValue(array('order', 'table', 'negative', 'region'))));
     if ($this->moduleHandler->moduleExists('search_api_page')) {
         $this->configuration['searchapi']['page'] = $form_state->getValue(array('searchapi', 'page'));
     }
     $this->configuration['languages'] = array('languages' => $form_state->getValue(array('languages', 'languages')), 'selector' => array('type' => $form_state->getValue(array('languages', 'selector', 'type')), 'label_visibility' => $form_state->getValue(array('languages', 'selector', 'label_visibility')), 'label' => $form_state->getValue(array('languages', 'selector', 'label'))), 'any' => array('text' => $form_state->getValue(array('languages', 'any', 'text')), 'restricts' => $form_state->getValue(array('languages', 'any', 'restricts')), 'force' => $form_state->getValue(array('languages', 'any', 'force'))), 'weight' => $form_state->getValue(array('order', 'table', 'languages', 'weight')), 'region' => $form_state->getValue(array('order', 'table', 'languages', 'region')));
     $this->configuration['paths'] = array('list' => $form_state->getValue(array('paths', 'list')), 'selector' => array('type' => $form_state->getValue(array('paths', 'selector', 'type')), 'label_visibility' => $form_state->getValue(array('paths', 'selector', 'label_visibility')), 'label' => $form_state->getValue(array('paths', 'selector', 'label'))), 'separator' => $form_state->getValue(array('paths', 'separator')), 'weight' => $form_state->getValue(array('order', 'table', 'paths', 'weight')), 'region' => $form_state->getValue(array('order', 'table', 'paths', 'region')));
 }
コード例 #17
0
 /**
  * Build the default links (reply, edit, delete …) for a comment.
  *
  * @param \Drupal\comment\CommentInterface $entity
  *   The comment object.
  * @param \Drupal\Core\Entity\EntityInterface $commented_entity
  *   The entity to which the comment is attached.
  *
  * @return array
  *   An array that can be processed by drupal_pre_render_links().
  */
 protected function buildLinks(CommentInterface $entity, EntityInterface $commented_entity)
 {
     $links = array();
     $status = $commented_entity->get($entity->getFieldName())->status;
     if ($status == CommentItemInterface::OPEN) {
         if ($entity->access('delete')) {
             $links['comment-delete'] = array('title' => t('Delete'), 'url' => $entity->urlInfo('delete-form'));
         }
         if ($entity->access('update')) {
             $links['comment-edit'] = array('title' => t('Edit'), 'url' => $entity->urlInfo('edit-form'));
         }
         if ($entity->access('create')) {
             $links['comment-reply'] = array('title' => t('Reply'), 'url' => Url::fromRoute('comment.reply', ['entity_type' => $entity->getCommentedEntityTypeId(), 'entity' => $entity->getCommentedEntityId(), 'field_name' => $entity->getFieldName(), 'pid' => $entity->id()]));
         }
         if (!$entity->isPublished() && $entity->access('approve')) {
             $links['comment-approve'] = array('title' => t('Approve'), 'url' => Url::fromRoute('comment.approve', ['comment' => $entity->id()]));
         }
         if (empty($links) && $this->currentUser->isAnonymous()) {
             $links['comment-forbidden']['title'] = $this->commentManager->forbiddenMessage($commented_entity, $entity->getFieldName());
         }
     }
     // Add translations link for translation-enabled comment bundles.
     if ($this->moduleHandler->moduleExists('content_translation') && $this->access($entity)->isAllowed()) {
         $links['comment-translations'] = array('title' => t('Translate'), 'url' => $entity->urlInfo('drupal:content-translation-overview'));
     }
     return array('#theme' => 'links__comment__comment', '#links' => $links, '#attributes' => array('class' => array('links', 'inline')));
 }
コード例 #18
0
 /**
  * {@inheritdoc}
  */
 public function submit(array &$element, array &$form, FormStateInterface $form_state)
 {
     $media_entities = [];
     $upload = $form_state->getValue('upload');
     if (isset($upload['uploaded_files']) && is_array($upload['uploaded_files'])) {
         $config = $this->getConfiguration();
         $user = $this->currentUser;
         /** @var \Drupal\media_entity\MediaBundleInterface $bundle */
         $bundle = $this->entityManager->getStorage('media_bundle')->load($this->configuration['media_entity_bundle']);
         // First save the file.
         foreach ($upload['uploaded_files'] as $uploaded_file) {
             $file = $this->dropzoneJsUploadSave->saveFile($uploaded_file['path'], $config['settings']['upload_location'], $config['settings']['extensions'], $user);
             if ($file) {
                 $file->setPermanent();
                 $file->save();
                 // Now save the media entity.
                 if ($this->moduleHandler->moduleExists('media_entity')) {
                     /** @var \Drupal\media_entity\MediaInterface $media_entity */
                     $media_entity = $this->entityManager->getStorage('media')->create(['bundle' => $bundle->id(), $bundle->getTypeConfiguration()['source_field'] => $file, 'uid' => $user->id(), 'status' => TRUE, 'type' => $bundle->getType()->getPluginId()]);
                     $event = $this->eventDispatcher->dispatch(Events::MEDIA_ENTITY_CREATE, new DropzoneMediaEntityCreateEvent($media_entity, $file, $form, $form_state, $element));
                     $media_entity = $event->getMediaEntity();
                     $media_entity->save();
                     $media_entities[] = $media_entity;
                 } else {
                     drupal_set_message(t('The media entity was not saved, because the media_entity module is not enabled.'));
                 }
             }
         }
     }
     if (!empty(array_filter($media_entities))) {
         $this->selectEntities($media_entities, $form_state);
         $this->clearFormValues($element, $form_state);
     }
 }
コード例 #19
0
 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     /** @var \Drupal\rng\EventTypeInterface $event_type */
     $event_type = $this->getEntity();
     if ($event_type->isNew()) {
         if ($this->moduleHandler->moduleExists('node') && $form_state->getValue('entity_type') == 'node') {
             $node_type = $this->createContentType('event');
             $t_args = ['%label' => $node_type->label(), ':url' => $node_type->toUrl()->toString()];
             drupal_set_message(t('The content type <a href=":url">%label</a> has been added.', $t_args));
             $event_type->setEventEntityTypeId($node_type->getEntityType()->getBundleOf());
             $event_type->setEventBundle($node_type->id());
         } else {
             $bundle = explode('.', $form_state->getValue('bundle'));
             $event_type->setEventEntityTypeId($bundle[0]);
             $event_type->setEventBundle($bundle[1]);
         }
     }
     // Set to the access operation for event.
     $op = $form_state->getValue('mirror_update') ? 'update' : '';
     $event_type->setEventManageOperation($op);
     $status = $event_type->save();
     $message = $status == SAVED_UPDATED ? '%label event type updated.' : '%label event type added.';
     $url = $event_type->urlInfo();
     $t_args = ['%label' => $event_type->id(), 'link' => $this->l(t('Edit'), $url)];
     drupal_set_message($this->t($message, $t_args));
     $this->logger('rng')->notice($message, $t_args);
     $form_state->setRedirect('rng.event_type.overview');
 }
コード例 #20
0
 /**
  * {@inheritdoc}
  */
 public function getCountNewComments(EntityInterface $entity, $field_name = NULL, $timestamp = 0)
 {
     // @todo Replace module handler with optional history service injection
     //   after http://drupal.org/node/2081585
     if ($this->currentUser->isAuthenticated() && $this->moduleHandler->moduleExists('history')) {
         // Retrieve the timestamp at which the current user last viewed this entity.
         if (!$timestamp) {
             if ($entity->getEntityTypeId() == 'node') {
                 $timestamp = history_read($entity->id());
             } else {
                 $function = $entity->getEntityTypeId() . '_last_viewed';
                 if (function_exists($function)) {
                     $timestamp = $function($entity->id());
                 } else {
                     // Default to 30 days ago.
                     // @todo Remove once http://drupal.org/node/1029708 lands.
                     $timestamp = COMMENT_NEW_LIMIT;
                 }
             }
         }
         $timestamp = $timestamp > HISTORY_READ_LIMIT ? $timestamp : HISTORY_READ_LIMIT;
         // Use the timestamp to retrieve the number of new comments.
         $query = $this->queryFactory->get('comment')->condition('entity_type', $entity->getEntityTypeId())->condition('entity_id', $entity->id())->condition('created', $timestamp, '>')->condition('status', CommentInterface::PUBLISHED);
         if ($field_name) {
             // Limit to a particular field.
             $query->condition('field_name', $field_name);
         }
         return $query->count()->execute();
     }
     return FALSE;
 }
コード例 #21
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $options = array();
     $types = NodeType::loadMultiple();
     $comment_fields = $this->commentManager ? $this->commentManager->getFields('node') : array();
     $map = array($this->t('Hidden'), $this->t('Closed'), $this->t('Open'));
     foreach ($types as $type) {
         $options[$type->id()] = array('type' => array('#markup' => $this->t($type->label())));
         if ($this->commentManager) {
             $fields = array();
             foreach ($comment_fields as $field_name => $info) {
                 // Find all comment fields for the bundle.
                 if (in_array($type->id(), $info['bundles'])) {
                     $instance = FieldConfig::loadByName('node', $type->id(), $field_name);
                     $default_mode = reset($instance->default_value);
                     $fields[] = SafeMarkup::format('@field: !state', array('@field' => $instance->label(), '!state' => $map[$default_mode['status']]));
                 }
             }
             // @todo Refactor display of comment fields.
             if (!empty($fields)) {
                 $options[$type->id()]['comments'] = array('data' => array('#theme' => 'item_list', '#items' => $fields));
             } else {
                 $options[$type->id()]['comments'] = $this->t('No comment fields');
             }
         }
     }
     if (empty($options)) {
         $create_url = $this->urlGenerator->generateFromRoute('node.type_add');
         $this->setMessage($this->t('You do not have any content types that can be generated. <a href="@create-type">Go create a new content type</a> already!</a>', array('@create-type' => $create_url)), 'error', FALSE);
         return;
     }
     $header = array('type' => $this->t('Content type'));
     if ($this->commentManager) {
         $header['comments'] = array('data' => $this->t('Comments'), 'class' => array(RESPONSIVE_PRIORITY_MEDIUM));
     }
     $form['node_types'] = array('#type' => 'tableselect', '#header' => $header, '#options' => $options);
     $form['kill'] = array('#type' => 'checkbox', '#title' => $this->t('<strong>Delete all content</strong> in these content types before generating new content.'), '#default_value' => $this->getSetting('kill'));
     $form['num'] = array('#type' => 'textfield', '#title' => $this->t('How many nodes would you like to generate?'), '#default_value' => $this->getSetting('num'), '#size' => 10);
     $options = array(1 => $this->t('Now'));
     foreach (array(3600, 86400, 604800, 2592000, 31536000) as $interval) {
         $options[$interval] = \Drupal::service('date.formatter')->formatInterval($interval, 1) . ' ' . $this->t('ago');
     }
     $form['time_range'] = array('#type' => 'select', '#title' => $this->t('How far back in time should the nodes be dated?'), '#description' => $this->t('Node creation dates will be distributed randomly from the current time, back to the selected time.'), '#options' => $options, '#default_value' => 604800);
     $form['max_comments'] = array('#type' => $this->moduleHandler->moduleExists('comment') ? 'textfield' : 'value', '#title' => $this->t('Maximum number of comments per node.'), '#description' => $this->t('You must also enable comments for the content types you are generating. Note that some nodes will randomly receive zero comments. Some will receive the max.'), '#default_value' => $this->getSetting('max_comments'), '#size' => 3, '#access' => $this->moduleHandler->moduleExists('comment'));
     $form['title_length'] = array('#type' => 'textfield', '#title' => $this->t('Maximum number of words in titles'), '#default_value' => $this->getSetting('title_length'), '#size' => 10);
     $form['add_alias'] = array('#type' => 'checkbox', '#disabled' => !$this->moduleHandler->moduleExists('path'), '#description' => $this->t('Requires path.module'), '#title' => $this->t('Add an url alias for each node.'), '#default_value' => FALSE);
     $form['add_statistics'] = array('#type' => 'checkbox', '#title' => $this->t('Add statistics for each node (node_counter table).'), '#default_value' => TRUE, '#access' => $this->moduleHandler->moduleExists('statistics'));
     $options = array();
     // We always need a language
     $languages = \Drupal::languageManager()->getLanguages(LanguageInterface::STATE_ALL);
     foreach ($languages as $langcode => $language) {
         $options[$langcode] = $language->getName();
     }
     $default_language = \Drupal::service('language.default')->get();
     $default_langcode = $default_language->getId();
     $form['add_language'] = array('#type' => 'select', '#title' => $this->t('Set language on nodes'), '#multiple' => TRUE, '#description' => $this->t('Requires locale.module'), '#options' => $options, '#default_value' => array($default_langcode));
     $form['submit'] = array('#type' => 'submit', '#value' => $this->t('Generate'), '#tableselect' => TRUE);
     $form['#redirect'] = FALSE;
     return $form;
 }
コード例 #22
0
 /**
  * @return mixed
  */
 private function getCommentCount()
 {
     if (!$this->moduleHandler->moduleExists('comment')) {
         return 0;
     }
     $entityQuery = $this->entityQuery->get('comment')->count();
     $comments = $entityQuery->execute();
     return $comments;
 }
コード例 #23
0
 /**
  * Overrides Drupal\Core\Entity\EntityViewBuilder::buildComponents().
  *
  * In addition to modifying the content key on entities, this implementation
  * will also set the comment entity key which all comments carry.
  *
  * @throws \InvalidArgumentException
  *   Thrown when a comment is attached to an entity that no longer exists.
  */
 public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL)
 {
     /** @var \Drupal\comment\CommentInterface[] $entities */
     if (empty($entities)) {
         return;
     }
     // Pre-load associated users into cache to leverage multiple loading.
     $uids = array();
     foreach ($entities as $entity) {
         $uids[] = $entity->getOwnerId();
     }
     $this->entityManager->getStorage('user')->loadMultiple(array_unique($uids));
     parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
     // Load all the entities that have comments attached.
     $commented_entity_ids = array();
     $commented_entities = array();
     foreach ($entities as $entity) {
         $commented_entity_ids[$entity->getCommentedEntityTypeId()][] = $entity->getCommentedEntityId();
     }
     // Load entities in bulk. This is more performant than using
     // $comment->getCommentedEntity() as we can load them in bulk per type.
     foreach ($commented_entity_ids as $entity_type => $entity_ids) {
         $commented_entities[$entity_type] = $this->entityManager->getStorage($entity_type)->loadMultiple($entity_ids);
     }
     foreach ($entities as $id => $entity) {
         if (isset($commented_entities[$entity->getCommentedEntityTypeId()][$entity->getCommentedEntityId()])) {
             $commented_entity = $commented_entities[$entity->getCommentedEntityTypeId()][$entity->getCommentedEntityId()];
         } else {
             throw new \InvalidArgumentException(t('Invalid entity for comment.'));
         }
         $build[$id]['#entity'] = $entity;
         $build[$id]['#theme'] = 'comment__' . $entity->getFieldName() . '__' . $commented_entity->bundle();
         $callback = '\\Drupal\\comment\\CommentViewBuilder::renderLinks';
         $context = array('comment_entity_id' => $entity->id(), 'view_mode' => $view_mode, 'langcode' => $langcode, 'commented_entity_type' => $commented_entity->getEntityTypeId(), 'commented_entity_id' => $commented_entity->id(), 'in_preview' => !empty($entity->in_preview));
         $placeholder = drupal_render_cache_generate_placeholder($callback, $context);
         $build[$id]['links'] = array('#post_render_cache' => array($callback => array($context)), '#markup' => $placeholder);
         $account = comment_prepare_author($entity);
         if (\Drupal::config('user.settings')->get('signatures') && $account->getSignature()) {
             $build[$id]['signature'] = array('#type' => 'processed_text', '#text' => $account->getSignature(), '#format' => $account->getSignatureFormat(), '#langcode' => $entity->language()->getId());
             // The signature will only be rendered in the theme layer, which means
             // its associated cache tags will not bubble up. Work around this for
             // now by already rendering the signature here.
             // @todo remove this work-around, see https://drupal.org/node/2273277
             drupal_render($build[$id]['signature'], TRUE);
         }
         if (!isset($build[$id]['#attached'])) {
             $build[$id]['#attached'] = array();
         }
         $build[$id]['#attached']['library'][] = 'comment/drupal.comment-by-viewer';
         if ($this->moduleHandler->moduleExists('history') && \Drupal::currentUser()->isAuthenticated()) {
             $build[$id]['#attached']['library'][] = 'comment/drupal.comment-new-indicator';
             // Embed the metadata for the comment "new" indicators on this node.
             $build[$id]['#post_render_cache']['history_attach_timestamp'] = array(array('node_id' => $commented_entity->id()));
         }
     }
 }
コード例 #24
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form['ds_fields_error'] = array('#type' => 'fieldset', '#title' => $this->t('Fields error'));
     $form['ds_fields_error']['disable'] = array('#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('In case you get an error after configuring a layout printing a message like "Fatal error: Unsupported operand types", you can temporarily disable adding fields from DS. You probably are trying to render an node inside a node, for instance through a view, which is simply not possible. See <a href="http://drupal.org/node/1264386">http://drupal.org/node/1264386</a>.'));
     $form['ds_fields_error']['submit'] = array('#type' => 'submit', '#value' => $this->state->get('ds.disabled', FALSE) ? t('Enable attaching fields') : t('Disable attaching fields'), '#submit' => array('::submitFieldAttach'), '#weight' => 1);
     if ($this->moduleHandler->moduleExists('ds_extras')) {
         $region_blocks = $this->config('ds_extras.settings')->get('region_blocks');
         if (!empty($region_blocks)) {
             $region_blocks_options = array();
             foreach ($region_blocks as $key => $info) {
                 $region_blocks_options[$key] = $info['title'];
             }
             $form['region_to_block'] = array('#type' => 'fieldset', '#title' => $this->t('Block regions'));
             $form['region_to_block']['remove_block_region'] = array('#type' => 'checkboxes', '#options' => $region_blocks_options, '#description' => $this->t('In case you renamed a content type, you will not see the configured block regions anymore, however the block on the block settings page is still available. On this screen you can remove orphaned block regions.'));
             $form['region_to_block']['submit'] = array('#type' => 'submit', '#value' => $this->t('Remove block regions'), '#submit' => array('::submitRegionToBlock'), '#weight' => 1);
         }
     }
     return $form;
 }
コード例 #25
0
 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $message_text = $this->token->replace($this->getMessageText(), array('payment' => $this->getPayment()), array('clear' => TRUE));
     if ($this->moduleHandler->moduleExists('filter')) {
         $elements['message'] = array('#type' => 'processed_text', '#text' => $message_text, '#format' => $this->getMessageTextFormat());
     } else {
         $elements['message'] = array('#type' => 'markup', '#markup' => $message_text);
     }
     return $elements;
 }
コード例 #26
0
 /**
  * Utility submit function to show the contents of $_SESSION.
  */
 public function handleShowSession(array &$form, FormStateInterface $form_state)
 {
     $form_values = $form_state->getValues();
     // If the devel module is installed, use it's nicer message format.
     if ($this->moduleHandler->moduleExists('devel')) {
         dsm($this->getStoredData(), $this->t('Entire $_SESSION["file_example"]'));
     } else {
         drupal_set_message('<pre>' . print_r($this->getStoredData(), TRUE) . '</pre>');
     }
 }
コード例 #27
0
 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     if ($this->moduleHandler->moduleExists('file')) {
         // Handle file uploads.
         $validators = array('file_validate_is_image' => array());
         // Check for a new uploaded logo.
         $file = file_save_upload('logo_upload', $validators, FALSE, 0);
         if (isset($file)) {
             // File upload was attempted.
             if ($file) {
                 // Put the temporary file in form_values so we can save it on submit.
                 $form_state->setValue('logo_upload', $file);
             } else {
                 // File upload failed.
                 $form_state->setErrorByName('logo_upload', $this->t('The logo could not be uploaded.'));
             }
         }
         $validators = array('file_validate_extensions' => array('ico png gif jpg jpeg apng svg'));
         // Check for a new uploaded favicon.
         $file = file_save_upload('favicon_upload', $validators, FALSE, 0);
         if (isset($file)) {
             // File upload was attempted.
             if ($file) {
                 // Put the temporary file in form_values so we can save it on submit.
                 $form_state->setValue('favicon_upload', $file);
             } else {
                 // File upload failed.
                 $form_state->setErrorByName('favicon_upload', $this->t('The favicon could not be uploaded.'));
             }
         }
         // When intending to use the default logo, unset the logo_path.
         if ($form_state->getValue('default_logo')) {
             $form_state->unsetValue('logo_path');
         }
         // When intending to use the default favicon, unset the favicon_path.
         if ($form_state->getValue('default_favicon')) {
             $form_state->unsetValue('favicon_path');
         }
         // If the user provided a path for a logo or favicon file, make sure a file
         // exists at that path.
         if ($form_state->getValue('logo_path')) {
             $path = $this->validatePath($form_state->getValue('logo_path'));
             if (!$path) {
                 $form_state->setErrorByName('logo_path', $this->t('The custom logo path is invalid.'));
             }
         }
         if ($form_state->getValue('favicon_path')) {
             $path = $this->validatePath($form_state->getValue('favicon_path'));
             if (!$path) {
                 $form_state->setErrorByName('favicon_path', $this->t('The custom favicon path is invalid.'));
             }
         }
     }
 }
コード例 #28
0
 /**
  * Redirects forum taxonomy terms to correct forum path.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  */
 public function globalredirectForum(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($event->getRequestType() != HttpKernelInterface::MASTER_REQUEST || !$this->config->get('term_path_handler') || !$this->moduleHandler->moduleExists('forum') || !preg_match('/taxonomy\\/term\\/([0-9]+)$/', $request->getUri(), $matches)) {
         return;
     }
     $term = $this->entityManager->getStorage('taxonomy_term')->load($matches[1]);
     if (!empty($term) && $term->url() != $request->getPathInfo()) {
         $this->setResponse($event, Url::fromUri('entity:taxonomy_term/' . $term->id()));
     }
 }
コード例 #29
0
ファイル: CommentAdminOverview.php プロジェクト: brstde/gap1
 /**
  * Form constructor for the comment overview administration form.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  * @param string $type
  *   The type of the overview form ('approval' or 'new').
  *
  * @return array
  *   The form structure.
  */
 public function buildForm(array $form, FormStateInterface $form_state, $type = 'new')
 {
     // Build an 'Update options' form.
     $form['options'] = array('#type' => 'details', '#title' => $this->t('Update options'), '#open' => TRUE, '#attributes' => array('class' => array('container-inline')));
     if ($type == 'approval') {
         $options['publish'] = $this->t('Publish the selected comments');
     } else {
         $options['unpublish'] = $this->t('Unpublish the selected comments');
     }
     $options['delete'] = $this->t('Delete the selected comments');
     $form['options']['operation'] = array('#type' => 'select', '#title' => $this->t('Action'), '#title_display' => 'invisible', '#options' => $options, '#default_value' => 'publish');
     $form['options']['submit'] = array('#type' => 'submit', '#value' => $this->t('Update'));
     // Load the comments that need to be displayed.
     $status = $type == 'approval' ? CommentInterface::NOT_PUBLISHED : CommentInterface::PUBLISHED;
     $header = array('subject' => array('data' => $this->t('Subject'), 'specifier' => 'subject'), 'author' => array('data' => $this->t('Author'), 'specifier' => 'name', 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), 'posted_in' => array('data' => $this->t('Posted in'), 'class' => array(RESPONSIVE_PRIORITY_LOW)), 'changed' => array('data' => $this->t('Updated'), 'specifier' => 'changed', 'sort' => 'desc', 'class' => array(RESPONSIVE_PRIORITY_LOW)), 'operations' => $this->t('Operations'));
     $cids = $this->commentStorage->getQuery()->condition('status', $status)->tableSort($header)->pager(50)->execute();
     /** @var $comments \Drupal\comment\CommentInterface[] */
     $comments = $this->commentStorage->loadMultiple($cids);
     // Build a table listing the appropriate comments.
     $options = array();
     $destination = $this->getDestinationArray();
     $commented_entity_ids = array();
     $commented_entities = array();
     foreach ($comments as $comment) {
         $commented_entity_ids[$comment->getCommentedEntityTypeId()][] = $comment->getCommentedEntityId();
     }
     foreach ($commented_entity_ids as $entity_type => $ids) {
         $commented_entities[$entity_type] = $this->entityManager->getStorage($entity_type)->loadMultiple($ids);
     }
     foreach ($comments as $comment) {
         /** @var $commented_entity \Drupal\Core\Entity\EntityInterface */
         $commented_entity = $commented_entities[$comment->getCommentedEntityTypeId()][$comment->getCommentedEntityId()];
         $username = array('#theme' => 'username', '#account' => $comment->getOwner());
         $body = '';
         if (!empty($comment->comment_body->value)) {
             $body = $comment->comment_body->value;
         }
         $comment_permalink = $comment->permalink();
         $attributes = $comment_permalink->getOption('attributes') ?: array();
         $attributes += array('title' => Unicode::truncate($body, 128));
         $comment_permalink->setOption('attributes', $attributes);
         $options[$comment->id()] = array('title' => array('data' => array('#title' => $comment->getSubject() ?: $comment->id())), 'subject' => array('data' => array('#type' => 'link', '#title' => $comment->getSubject(), '#url' => $comment_permalink)), 'author' => drupal_render($username), 'posted_in' => array('data' => array('#type' => 'link', '#title' => $commented_entity->label(), '#access' => $commented_entity->access('view'), '#url' => $commented_entity->urlInfo())), 'changed' => $this->dateFormatter->format($comment->getChangedTime(), 'short'));
         $comment_uri_options = $comment->urlInfo()->getOptions();
         $links = array();
         $links['edit'] = array('title' => $this->t('Edit'), 'url' => Url::fromRoute('entity.comment.edit_form', ['comment' => $comment->id()], $comment_uri_options + ['query' => $destination]));
         if ($this->moduleHandler->moduleExists('content_translation') && $this->moduleHandler->invoke('content_translation', 'translate_access', array($comment))->isAllowed()) {
             $links['translate'] = array('title' => $this->t('Translate'), 'url' => Url::fromRoute('entity.comment.content_translation_overview', ['comment' => $comment->id()], $comment_uri_options + ['query' => $destination]));
         }
         $options[$comment->id()]['operations']['data'] = array('#type' => 'operations', '#links' => $links);
     }
     $form['comments'] = array('#type' => 'tableselect', '#header' => $header, '#options' => $options, '#empty' => $this->t('No comments available.'));
     $form['pager'] = array('#type' => 'pager');
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     $values = $form_state->getValues();
     $message = NestedArray::getValue($values, $form['message']['#parents']);
     if ($this->moduleHandler->moduleExists('filter')) {
         $this->setMessageText($message['value']);
         $this->setMessageTextFormat($message['format']);
     } else {
         $this->setMessageText($message);
     }
 }