Skip to content
Snippets Groups Projects
Commit 56c9be6c authored by Viktor Holovachek's avatar Viktor Holovachek
Browse files

Issue #3441454 - Fix phpstan

parent 46a9fd44
No related branches found
No related tags found
1 merge request!7Issue #3441454 - Fix phpstan
Pipeline #148942 passed with warnings
# Configuration file for PHPStan static code checking.
# @see: https://git.drupalcode.org/project/drupal/-/blob/10.0.x/core/phpstan.neon.dist
parameters:
level: 1
ignoreErrors:
# new static() is a best practice in Drupal, so we cannot fix that.
# @see https://www.drupal.org/docs/develop/development-tools/phpstan/handling-unsafe-usage-of-new-static
- "#^Unsafe usage of new static#"
......@@ -3,8 +3,10 @@
namespace Drupal\panels_breadcrumbs\Form;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Class PageVariantBreadcrumbsForm.
......@@ -13,6 +15,32 @@ class PageVariantBreadcrumbsForm extends FormBase {
use PageBreadcrumbsFormTrait;
/**
* Returns the config.factory service.
*
* @var \Drupal\Core\Config\ConfigFactory
*/
protected $config;
/**
* Constructs a PageVariantBreadcrumbsForm form.
*
* @param \Drupal\Core\Config\ConfigFactory $config
* Defines the configuration object factory.
*/
public function __construct(ConfigFactory $config) {
$this->config = $config;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory')
);
}
/**
* {@inheritdoc}
*/
......@@ -55,7 +83,7 @@ class PageVariantBreadcrumbsForm extends FormBase {
$form['home_text'] = [
'#type' => 'textfield',
'#title' => $this->t('Home link title'),
'#description' => $this->t('Text will be displayed as Home link title in the breadcrumb'),
'#description' => $this->t('Text will be displayed as Home link title in the breadcrumb.'),
'#default_value' => isset($breadcrumbs_settings['home_text']) ? $breadcrumbs_settings['home_text'] : $this->t('Home'),
'#states' => [
'visible' => [
......@@ -63,7 +91,7 @@ class PageVariantBreadcrumbsForm extends FormBase {
],
],
];
if ($token_types = $this->getTypesOfTokens($page_variant)) {
if ($token_types = self::getTypesOfTokens($page_variant)) {
$form['tokens'] = [
'#theme' => 'token_tree_link',
'#token_types' => $token_types,
......@@ -85,13 +113,13 @@ class PageVariantBreadcrumbsForm extends FormBase {
$variant_settings = $page_variant->get('variant_settings');
$submitted_values = $form_state->getValues();
foreach ($this->getSettingsKeys() as $name) {
foreach (self::getSettingsKeys() as $name) {
$variant_settings['panels_breadcrumbs'][$name] = $submitted_values[$name];
}
$page_variant->set('variant_settings', $variant_settings);
// Invalidate breadcrumbs block cache.
$theme_name = \Drupal::config('system.theme')->get('default');
$theme_name = $this->config->get('system.theme')->get('default');
Cache::invalidateTags(["config:block.block.{$theme_name}_breadcrumbs"]);
}
......
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