Skip to content
Snippets Groups Projects
Commit 47c41f17 authored by renatog's avatar renatog Committed by renatog
Browse files

Issue #3271756 by RenatoG: Implement the configFactory with dependency...

Issue #3271756 by RenatoG: Implement the configFactory with dependency injection instead of Drupal::config
parent cebe89ed
No related branches found
No related tags found
10 merge requests!62Issue #3272848 by RenatoG: When the error appear the field is hidden and the...,!59Issue #3497768: Click JavaScript to close details causes modals to scroll unnecessarily,!35Issue #3366420: \Drupal calls should be avoided in classes,!34Issue #3366420: \Drupal calls should be avoided in classes,!29Issue #3272632 by RenatoG: Add a logic to block and disable the remove item if...,!28Issue #3272632 by RenatoG: Add a logic to block and disable the remove item if...,!23Issue #3272632 by RenatoG: Add a logic to block and disable the remove item if...,!22Issue #3272632 by RenatoG: Add a logic to block and disable the remove item if...,!20Issue #3272632 by RenatoG: Add a logic to block and disable the remove item if...,!7Issue #3320529 by justcaldwell: block_classes_stored setting only retains classes from most recently saved block
services:
block_class.helper:
class: Drupal\block_class\Service\BlockClassHelperService
arguments: ['@language_manager', '@entity_type.manager', '@config.factory', '@database', '@request_stack', '@path.matcher', '@uuid', '@current_user', '@path_alias.manager', '@path.current', '@entity.repository']
\ No newline at end of file
arguments: ['@language_manager', '@entity_type.manager', '@config.factory', '@database', '@request_stack', '@path.matcher', '@uuid', '@path_alias.manager', '@path.current', '@entity.repository', '@current_user']
\ No newline at end of file
......@@ -8,7 +8,6 @@ use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Path\PathMatcherInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\path_alias\AliasManagerInterface;
......@@ -21,6 +20,7 @@ use Drupal\block\Entity\Block;
use Drupal\Component\Utility\Html;
use Drupal\block_class\Constants\BlockClassConstants;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Session\AccountProxy;
/**
* Block Class Service Class.
......@@ -78,13 +78,6 @@ class BlockClassHelperService {
*/
protected $database;
/**
* The user current.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected $currentUser;
/**
* The path alias manager.
*
......@@ -106,10 +99,17 @@ class BlockClassHelperService {
*/
protected $entityRepository;
/**
* Drupal\Core\Session\AccountProxy definition.
*
* @var \Drupal\Core\Session\AccountProxy
*/
protected $currentUser;
/**
* Construct of Block Class service.
*/
public function __construct(LanguageManagerInterface $language_manager, EntityTypeManagerInterface $entity_manager, ConfigFactoryInterface $config_factory, Connection $database, RequestStack $request_stack, PathMatcherInterface $path_matcher, UuidInterface $uuid_service, AccountProxyInterface $current_user, AliasManagerInterface $alias_manager, CurrentPathStack $current_path, EntityRepositoryInterface $entityRepository) {
public function __construct(LanguageManagerInterface $language_manager, EntityTypeManagerInterface $entity_manager, ConfigFactoryInterface $config_factory, Connection $database, RequestStack $request_stack, PathMatcherInterface $path_matcher, UuidInterface $uuid_service, AliasManagerInterface $alias_manager, CurrentPathStack $current_path, EntityRepositoryInterface $entityRepository, AccountProxy $currentUser) {
$this->languageManager = $language_manager;
$this->entityTypeManager = $entity_manager;
$this->pathMatcher = $path_matcher;
......@@ -117,10 +117,10 @@ class BlockClassHelperService {
$this->configFactory = $config_factory;
$this->database = $database;
$this->uuidService = $uuid_service;
$this->currentUser = $current_user;
$this->aliasManager = $alias_manager;
$this->currentPath = $current_path;
$this->entityRepository = $entityRepository;
$this->currentUser = $currentUser;
}
/**
......@@ -249,8 +249,8 @@ class BlockClassHelperService {
*/
public function addAttributesOnBlock(&$block, &$variables) {
// Get config object.
$config = \Drupal::config('block_class.settings');
// Get the config object.
$config = $this->configFactory->getEditable('block_class.settings');
// If attributes isn't enabled, skip.
if (empty($config->get('enable_attributes'))) {
......@@ -294,8 +294,8 @@ class BlockClassHelperService {
// Get all classes if exists.
$classes_array = explode(' ', $classes);
// Get config object.
$config = \Drupal::config('block_class.settings');
// Get the config object.
$config = $this->configFactory->getEditable('block_class.settings');
$filter_css_identifier = [];
......@@ -330,7 +330,7 @@ class BlockClassHelperService {
public function blockClassFormAlter(&$form, &$form_state) {
// If the user don't have permission, skip that.
if (!\Drupal::currentUser()->hasPermission(BlockClassConstants::BLOCK_CLASS_PERMISSION)) {
if (!$this->currentUser->hasPermission(BlockClassConstants::BLOCK_CLASS_PERMISSION)) {
return;
}
......@@ -542,8 +542,8 @@ class BlockClassHelperService {
*/
public function blockClassFormValidate(&$form, &$form_state) {
// Get config object.
$config = \Drupal::config('block_class.settings');
// Get the config object.
$config = $this->configFactory->getEditable('block_class.settings');
// Validate dynamic items.
$this->validateDynamicClasses($form, $form_state, $config);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment