Skip to content
Snippets Groups Projects
Commit 8b9a1ec8 authored by Andrey Tymchuk's avatar Andrey Tymchuk Committed by A.Tymchuk
Browse files

Issue #3423280 by WalkingDexter: Fix PHPStan errors

parent 96ca1630
No related branches found
No related tags found
No related merge requests found
Pipeline #101841 failed
......@@ -45,9 +45,7 @@ class SimpleSitemapViewsController extends ControllerBase {
* A render array.
*/
public function content(): array {
$table = &$build['simple_sitemap_views'];
$table = [
$build['simple_sitemap_views'] = [
'#type' => 'table',
'#header' => [
$this->t('View'),
......@@ -58,6 +56,8 @@ class SimpleSitemapViewsController extends ControllerBase {
'#empty' => $this->t('No view displays are set to be indexed yet. <a href="@url">Edit a view.</a>', ['@url' => Url::fromRoute('entity.view.collection')->toString()]),
];
$table = &$build['simple_sitemap_views'];
if (empty($this->sitemapViews->getSitemaps())) {
$table['#empty'] = $this->t('Please configure at least one <a href="@sitemaps_url">sitemap</a> to be of a <a href="@types_url">type</a> that implements the views URL generator.', [
'@sitemaps_url' => Url::fromRoute('entity.simple_sitemap.collection')->toString(),
......
parameters:
ignoreErrors:
-
message: """
#^Call to deprecated function watchdog_exception\\(\\)\\:
in drupal\\:10\\.1\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use
Use \\\\Drupal\\\\Core\\\\Utility\\\\Error\\:\\:logException\\(\\) instead\\.$#
"""
count: 1
path: modules/simple_sitemap_engines/src/Submitter/SubmitterBase.php
-
message: "#^\\\\Drupal calls should be avoided in classes, use dependency injection instead$#"
count: 1
path: src/Controller/SimpleSitemapController.php
-
message: "#^\\\\Drupal calls should be avoided in classes, use dependency injection instead$#"
count: 2
path: src/Manager/Generator.php
-
message: "#^\\\\Drupal calls should be avoided in classes, use dependency injection instead$#"
count: 1
path: src/Plugin/simple_sitemap/UrlGenerator/SitemapIndexUrlGenerator.php
-
message: """
#^Call to deprecated function watchdog_exception\\(\\)\\:
in drupal\\:10\\.1\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use
Use \\\\Drupal\\\\Core\\\\Utility\\\\Error\\:\\:logException\\(\\) instead\\.$#
"""
count: 1
path: src/Queue/QueueWorker.php
-
message: "#^\\\\Drupal calls should be avoided in classes, use dependency injection instead$#"
count: 2
path: src/SimpleSitemapListBuilder.php
includes:
- phpstan-baseline.neon
parameters:
level: 0
paths:
- .
excludePaths:
- tests/scripts/performance_test.php
ignoreErrors:
# new static() is a best practice in Drupal, so we cannot fix that.
- "#^Unsafe usage of new static#"
# The paragraphs module is not required.
- '#^Class Drupal\\paragraphs\\ParagraphInterface not found\.$#'
......@@ -108,7 +108,9 @@ class SimpleSitemapEntityForm extends EntityForm {
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
if ($this->entity->save() === SAVED_UPDATED) {
$return = $this->entity->save();
if ($return === SAVED_UPDATED) {
$this->messenger()->addStatus($this->t('Sitemap %label has been updated.', ['%label' => $this->entity->label()]));
}
else {
......@@ -116,6 +118,7 @@ class SimpleSitemapEntityForm extends EntityForm {
}
$form_state->setRedirectUrl($this->entity->toUrl('collection'));
return $return;
}
}
......@@ -129,7 +129,9 @@ class SimpleSitemapTypeEntityForm extends EntityForm {
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
if ($this->entity->save() === SAVED_UPDATED) {
$return = $this->entity->save();
if ($return === SAVED_UPDATED) {
$this->messenger()->addStatus($this->t('Sitemap type %label has been updated.', ['%label' => $this->entity->label()]));
}
else {
......@@ -137,6 +139,7 @@ class SimpleSitemapTypeEntityForm extends EntityForm {
}
$form_state->setRedirectUrl($this->entity->toUrl('collection'));
return $return;
}
}
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