Skip to content
Snippets Groups Projects
Commit e431bdb9 authored by Pravin Gaikwad's avatar Pravin Gaikwad Committed by Rodrigo Gonçalves
Browse files

Issue #3223553 by andregp, Rajeshreeputra, victoria-marina: PHPCS Issues to be fixed

parent 5ffcf66d
No related branches found
No related tags found
No related merge requests found
Pipeline #18263 passed with warnings
......@@ -6,7 +6,8 @@ page.
This module helps when you have a content that needs to have access restriction
by Drupal language.
This module detects the content language based on the settings defined on Config -> Languages -> Detection and selection
This module detects the content language based on the settings defined on
Config -> Languages -> Detection and selection
Example
------------
......@@ -35,7 +36,9 @@ Just enable it. No initial configuration required.
Configuration
------------
Additional settings (for example, to allow content from an expecified list of languages to be accessed from a language detected) can be set on Config -> Content language access
Additional settings (for example, to allow content from an expecified list of
languages to be accessed from a language detected) can be set on Config ->
Content language access
Author
------
......
......@@ -3,8 +3,10 @@
namespace Drupal\content_language_access\Form;
use Drupal\content_language_access\ContentLanguageAccessConfigManager;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Render\Element;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -27,10 +29,19 @@ class ContentLanguageAccessAdminForm extends ConfigFormBase {
*/
private $contentLanguageAccessConfigSettings;
/**
* Drupal\Core\Language\LanguageManagerInterface definition.
*
* @var Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* {@inheritDoc}
*/
public function __construct(ContentLanguageAccessConfigManager $content_language_access_config_manager) {
public function __construct(ConfigFactoryInterface $config_factory, LanguageManagerInterface $languageManager, ContentLanguageAccessConfigManager $content_language_access_config_manager) {
$this->setConfigFactory($config_factory);
$this->languageManager = $languageManager;
$this->contentLanguageAccessConfigManager = $content_language_access_config_manager;
$this->contentLanguageAccessConfigSettings = $this->config('content_language_access.settings');
}
......@@ -40,6 +51,8 @@ class ContentLanguageAccessAdminForm extends ConfigFormBase {
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('language_manager'),
$container->get('content_language_access.config_manager')
);
}
......@@ -94,7 +107,7 @@ class ContentLanguageAccessAdminForm extends ConfigFormBase {
'#open' => TRUE,
];
$languages = \Drupal::languageManager()->getLanguages();
$languages = $this->languageManager->getLanguages();
foreach ($languages as $language) {
if (!$language->isLocked()) {
$form['content_language_access'][$language->getId()] = [
......
......@@ -2,6 +2,8 @@
namespace Drupal\content_language_access\Tests;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Test the features with content language detection enabled.
*
......@@ -9,6 +11,8 @@ namespace Drupal\content_language_access\Tests;
*/
class ContentLanguageAccessContentDetectionEnabledTest extends ContentLanguageAccessTestBase {
use StringTranslationTrait;
/**
* Modules to install.
*
......@@ -32,7 +36,7 @@ class ContentLanguageAccessContentDetectionEnabledTest extends ContentLanguageAc
'language_content[enabled][language-interface]' => FALSE,
];
$this->drupalGet('admin/config/regional/language/detection');
$this->submitForm($edit, t('Save settings'));
$this->submitForm($edit, $this->t('Save settings'));
}
/**
......
......@@ -5,6 +5,7 @@ namespace Drupal\content_language_access\Tests;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Test the features of content_language_access module.
......@@ -13,6 +14,8 @@ use Drupal\Tests\BrowserTestBase;
*/
abstract class ContentLanguageAccessTestBase extends BrowserTestBase {
use StringTranslationTrait;
/**
* Drupal installation profile to use.
*
......@@ -96,13 +99,13 @@ abstract class ContentLanguageAccessTestBase extends BrowserTestBase {
$this->contentType = $this->drupalCreateContentType();
// Set the content type to use multilingual support.
$this->drupalGet("admin/structure/types/manage/{$this->contentType->id()}");
$this->assertSession()->pageTextContains(t('Language settings'));
$this->assertSession()->pageTextContains($this->t('Language settings'));
$edit = [
'language_configuration[language_alterable]' => TRUE,
];
$this->drupalGet("admin/structure/types/manage/{$this->contentType->id()}");
$this->submitForm($edit, t('Save content type'));
$this->assertSession()->responseContains(t('The content type %type has been updated.', ['%type' => $this->contentType->label()]));
$this->submitForm($edit, $this->t('Save content type'));
$this->assertSession()->responseContains($this->t('The content type %type has been updated.', ['%type' => $this->contentType->label()]));
}
/**
......@@ -166,7 +169,7 @@ abstract class ContentLanguageAccessTestBase extends BrowserTestBase {
'direction' => LanguageInterface::DIRECTION_LTR,
];
$this->drupalGet('admin/config/regional/language/add');
$this->submitForm($edit, t('Add custom language'));
$this->submitForm($edit, $this->t('Add custom language'));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment