Commit b3838aee authored by anon's avatar anon

Issue #2836324 by harsha012, anon: coding standard issue

parent c4c62fe3
......@@ -62,7 +62,7 @@ function linkit_update_8500() {
$toolbar_rows = $editor_config->get('settings.toolbar.rows');
foreach ($toolbar_rows as $row_index => $row) {
foreach ($row as $button_group_index => $button_group) {
foreach ($button_group['items'] as $item_index => $item__name) {
foreach ($button_group['items'] as $item__name) {
if ($item__name === 'Linkit') {
$old_linkit_button_path = 'settings.toolbar.rows.' . $row_index . '.' . $button_group_index . '.items';
}
......
......@@ -104,7 +104,7 @@ class OverviewForm extends FormBase {
$form['plugins'][$key]['weight'] = [
'#type' => 'weight',
'#title' => t('Weight for @title', ['@title' => (string) $plugin->getLabel()]),
'#title' => $this->t('Weight for @title', ['@title' => (string) $plugin->getLabel()]),
'#title_display' => 'invisible',
'#default_value' => $plugin->getWeight(),
'#attributes' => ['class' => ['plugin-order-weight']],
......@@ -118,7 +118,7 @@ class OverviewForm extends FormBase {
$is_configurable = $plugin instanceof ConfigurableMatcherInterface;
if ($is_configurable) {
$form['plugins'][$key]['operations']['#links']['edit'] = [
'title' => t('Edit'),
'title' => $this->t('Edit'),
'url' => Url::fromRoute('linkit.matcher.edit', [
'linkit_profile' => $this->linkitProfile->id(),
'plugin_instance_id' => $key,
......@@ -127,7 +127,7 @@ class OverviewForm extends FormBase {
}
$form['plugins'][$key]['operations']['#links']['delete'] = [
'title' => t('Delete'),
'title' => $this->t('Delete'),
'url' => Url::fromRoute('linkit.matcher.delete', [
'linkit_profile' => $this->linkitProfile->id(),
'plugin_instance_id' => $key,
......
......@@ -5,6 +5,8 @@ namespace Drupal\linkit\Form\Profile;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Base form for profile add and edit forms.
......@@ -18,6 +20,32 @@ abstract class FormBase extends EntityForm {
*/
protected $entity;
/**
* The stream wrapper manager.
*
* @var \Drupal\Core\StreamWrapper\StreamWrapperManager
*/
protected $streamWrapperManager;
/**
* Constructs a FormBase object.
*
* @param \Drupal\Core\StreamWrapper\StreamWrapperManager $stream_wrapper_manager
* The stream wrapper manager.
*/
public function __construct(StreamWrapperManager $stream_wrapper_manager) {
$this->streamWrapperManager = $stream_wrapper_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('stream_wrapper_manager')
);
}
/**
* {@inheritdoc}
*/
......@@ -55,20 +83,20 @@ abstract class FormBase extends EntityForm {
if ($this->moduleHandler->moduleExists('imce')) {
$form['imce'] = [
'#type' => 'details',
'#title' => t('IMCE integration'),
'#title' => $this->t('IMCE integration'),
'#group' => 'additional_settings',
];
$form['imce']['imce_use'] = [
'#type' => 'checkbox',
'#title' => t('Enable IMCE File Browser in the editor dialog.'),
'#title' => $this->t('Enable IMCE File Browser in the editor dialog.'),
'#default_value' => $this->entity->getThirdPartySetting('imce', 'use', FALSE),
];
$scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::READ_VISIBLE);
$scheme_options = $this->streamWrapperManager->getNames(StreamWrapperInterface::READ_VISIBLE);
$form['imce']['imce_scheme'] = [
'#type' => 'radios',
'#title' => t('Scheme'),
'#title' => $this->t('Scheme'),
'#options' => $scheme_options,
'#default_value' => $this->entity->getThirdPartySetting('imce', 'scheme', 'public'),
'#states' => [
......
......@@ -67,7 +67,7 @@ class SubstitutionManager extends DefaultPluginManager implements SubstitutionMa
* @see SubstitutionInterface::isApplicable()
*/
protected function filterPlugins($definitions, EntityTypeInterface $entity_type) {
return array_filter($definitions, function($definition) use ($entity_type) {
return array_filter($definitions, function ($definition) use ($entity_type) {
/** @var \Drupal\linkit\SubstitutionInterface $class */
$class = $definition['class'];
return $class::isApplicable($entity_type);
......
......@@ -29,7 +29,7 @@ trait AssertLinkitFilterTrait {
protected function assertLinkitFilter(EntityInterface $entity, $langcode = LanguageInterface::LANGCODE_SITE_DEFAULT) {
if ($entity->getEntityTypeId() === "file") {
/** @var \Drupal\file\Entity\File $entity */
$href = $url = file_create_url($entity->getFileUri());
$href = file_create_url($entity->getFileUri());
}
else {
$href = $entity->toUrl()->toString();
......@@ -37,7 +37,7 @@ trait AssertLinkitFilterTrait {
$input = '<a data-entity-type="' . $entity->getEntityTypeId() . '" data-entity-uuid="' . $entity->uuid() . '">Link text</a>';
$expected = '<a data-entity-type="' . $entity->getEntityTypeId() . '" data-entity-uuid="' . $entity->uuid() . '" href="' . $href . '">Link text</a>';
$this->assertIdentical($expected, $this->process($input, $langcode)->getProcessedText());
$this->assertSame($expected, $this->process($input, $langcode)->getProcessedText());
}
/**
......@@ -51,7 +51,7 @@ trait AssertLinkitFilterTrait {
protected function assertLinkitFilterWithTitle(EntityInterface $entity, $langcode = LanguageInterface::LANGCODE_SITE_DEFAULT) {
if ($entity->getEntityTypeId() === "file") {
/** @var \Drupal\file\Entity\File $entity */
$href = $url = file_create_url($entity->getFileUri());
$href = file_create_url($entity->getFileUri());
}
else {
$href = $entity->toUrl()->toString();
......@@ -59,7 +59,7 @@ trait AssertLinkitFilterTrait {
$input = '<a data-entity-type="' . $entity->getEntityTypeId() . '" data-entity-uuid="' . $entity->uuid() . '">Link text</a>';
$expected = '<a data-entity-type="' . $entity->getEntityTypeId() . '" data-entity-uuid="' . $entity->uuid() . '" href="' . $href . '" title="' . Html::decodeEntities($entity->label()) . '">Link text</a>';
$this->assertIdentical($expected, $this->process($input, $langcode)->getProcessedText());
$this->assertSame($expected, $this->process($input, $langcode)->getProcessedText());
}
/**
......
......@@ -106,4 +106,5 @@ class FileMatcherTest extends LinkitKernelTestBase {
$this->assertNotContains('[file:field_with_no_value]', $suggestion->getDescription(), 'Raw token "[file:field_with_no_value]" is not present in the description');
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment