Skip to content
Snippets Groups Projects

Issue #3333841: Drupal Coding Standards Issues | phpcs

Open Issue #3333841: Drupal Coding Standards Issues | phpcs
1 unresolved thread
Open Charchil Khandelwal requested to merge issue/token_filter-3333841:2.x into 2.x
1 unresolved thread
2 files
+ 31
12
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -4,13 +4,13 @@ namespace Drupal\token_filter\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginConfigurableInterface;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Extension\ExtensionList;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Url;
use Drupal\Core\Access\CsrfTokenGenerator;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\editor\Entity\Editor;
use Drupal\token\Token;
@@ -29,6 +29,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* )
*/
class TokenBrowser extends CKEditorPluginBase implements ContainerFactoryPluginInterface, CKEditorPluginConfigurableInterface {
use StringTranslationTrait;
Please register or sign in to reply
/**
* The CSRF token manager service.
@@ -61,16 +62,29 @@ class TokenBrowser extends CKEditorPluginBase implements ContainerFactoryPluginI
/**
* {@inheritdoc}
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param string $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Access\CsrfTokenGenerator $csrf_token_service
* Generates and validates CSRF tokens.
* @param \Drupal\token\Token $token_service
* Returns the token service.
* @param \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator
* Generates file URLs for a stream to an external or local file.
* @param \Drupal\Core\Extension\ModuleExtensionList $module_extension_list
* Provides available extensions.
*/
public function __construct(
array $configuration,
array $configuration,
$plugin_id,
$plugin_definition,
CsrfTokenGenerator $csrf_token_service,
Token $token_service,
CsrfTokenGenerator $csrf_token_service,
Token $token_service,
FileUrlGeneratorInterface $file_url_generator,
ModuleExtensionList $module_extension_list) {
ModuleExtensionList $module_extension_list) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->csrfTokenService = $csrf_token_service;
@@ -79,6 +93,9 @@ class TokenBrowser extends CKEditorPluginBase implements ContainerFactoryPluginI
$this->moduleExtensionList = $module_extension_list;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
@@ -102,7 +119,7 @@ class TokenBrowser extends CKEditorPluginBase implements ContainerFactoryPluginI
return [
'tokenbrowser' => [
'id' => 'tokenbrowser',
'label' => t('Token browser'),
'label' => $this->t('Token browser'),
'image' => $this->fileUrlGenerator->generateAbsoluteString($this->getImage()),
'link' => $this->getUrl($token_types)->toString(),
],
@@ -112,10 +129,10 @@ class TokenBrowser extends CKEditorPluginBase implements ContainerFactoryPluginI
/**
* Fetches the URL.
*
* @return \Drupal\Core\Url The URL.
* @return \Drupal\Core\Url
* The URL.
*
* @see TokenTreeController::outputTree().
* @see TokenTreeController::outputTree()
*/
protected function getUrl($token_types = NULL): Url {
$url = Url::fromRoute('token.tree');
@@ -133,7 +150,7 @@ class TokenBrowser extends CKEditorPluginBase implements ContainerFactoryPluginI
* @return array
* The list of query options.
*
* @see TreeBuilderInterface::buildRenderable() for option definitions.
* @see TreeBuilderInterface::buildRenderable()
*/
protected function getQueryOptions($token_types = NULL): array {
@@ -209,8 +226,8 @@ class TokenBrowser extends CKEditorPluginBase implements ContainerFactoryPluginI
// Get parent token type names, keyed by machine name.
$parent_token_types = array_filter($this->tokenService
->getInfo()['types'], function ($v) {
return empty($v['nested']);
});
return empty($v['nested']);
});
$parent_token_types = array_map(function ($v) {
return $v['name'];
}, $parent_token_types);
@@ -227,4 +244,5 @@ class TokenBrowser extends CKEditorPluginBase implements ContainerFactoryPluginI
return $form;
}
}
Loading