Unverified Commit 5dcd0ed4 authored by git's avatar git Committed by Kingdutch

Issue #3149492 by taras.suliatitskiy, Project Update Bot, Kingdutch: Automated...

Issue #3149492 by taras.suliatitskiy, Project Update Bot, Kingdutch: Automated Drupal 9 compatibility fixes
parent 2ca5d3a4
......@@ -74,12 +74,9 @@ class YoastSeoController extends ControllerBase {
// module configuration page if he has access to do so.
if (\Drupal::currentUser()->hasPermission('administer xmlsitemap')) {
$xmlsitemap_description = $this->t(
'You can configure the XML Sitemap settings at the @url.',
'You can configure the XML Sitemap settings at the <a href="@url">configuration page</a>',
[
'@url' => \Drupal::l(
$this->t('configuration page'),
Url::fromRoute('xmlsitemap.admin_search')
),
'@url' => Url::fromRoute('xmlsitemap.admin_search')->toString(),
]
);
}
......@@ -93,12 +90,9 @@ class YoastSeoController extends ControllerBase {
// module configuration page if he has access to do so.
if (\Drupal::currentUser()->hasPermission('administer simple_sitemap')) {
$xmlsitemap_description = $this->t(
'You can configure the Simple XML Sitemap settings at the @url.',
'You can configure the Simple XML Sitemap settings at the <a href="@url">configuration page</a>.',
[
'@url' => \Drupal::l(
$this->t('configuration page'),
Url::fromRoute('simple_sitemap.settings')
),
'@url' => Url::fromRoute('simple_sitemap.settings')->toString(),
]
);
}
......@@ -133,12 +127,9 @@ class YoastSeoController extends ControllerBase {
// We do not check if the module is enabled since it is our dependency.
if (\Drupal::currentUser()->hasPermission('administer meta tags')) {
$metatag_description = $this->t(
'You can configure and override the Metatag title & description default settings at the @url.',
'You can configure and override the Metatag title & description default settings at the <a href="@url">Metatag configuration page</a>.',
[
'@url' => \Drupal::l(
$this->t('Metatag configuration page'),
Url::fromRoute('entity.metatag_defaults.collection')
),
'@url' => Url::fromRoute('entity.metatag_defaults.collection')->toString(),
]
);
}
......
......@@ -11,11 +11,6 @@ use Drupal\simpletest\WebTestBase;
*/
class YoastSeoTest extends WebTestBase {
/**
* Profile to use.
*/
protected $profile = 'testing';
/**
* Admin user.
*
......@@ -51,13 +46,20 @@ class YoastSeoTest extends WebTestBase {
'access content',
];
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
/**
* Sets the test up.
*/
protected function setUp() {
parent::setUp();
$this->adminUser = $this->drupalCreateUser($this->permissions);
$this->entityManager = \Drupal::entityManager();
$this->entityManager = \Drupal::service('entity_type.manager');
}
/**
......@@ -66,7 +68,7 @@ class YoastSeoTest extends WebTestBase {
protected function enableYoastSeo($entity_type, $bundle) {
// Configure yoast seo for the given bundle.
$this->drupalGet('admin/config/yoast_seo');
$edit = array($entity_type . '[' . $bundle . ']' => $bundle);
$edit = [$entity_type . '[' . $bundle . ']' => $bundle];
json_decode($this->drupalPostForm(NULL, $edit, t('Save')));
$this->assertFieldChecked('edit-node-page');
}
......@@ -77,7 +79,7 @@ class YoastSeoTest extends WebTestBase {
protected function disableYoastSeo($entity_type, $bundle) {
// Configure yoast seo for the given bundle.
$this->drupalGet('admin/config/yoast_seo');
$edit = array($entity_type . '[' . $bundle . ']' => FALSE);
$edit = [$entity_type . '[' . $bundle . ']' => FALSE];
json_decode($this->drupalPostForm(NULL, $edit, t('Save')));
$this->assertNoFieldChecked('edit-node-page');
}
......@@ -96,10 +98,10 @@ class YoastSeoTest extends WebTestBase {
// Given I am logged in as admin.
$this->drupalLogin($this->adminUser);
// Create a page node type.
$this->entityManager->getStorage('node_type')->create(array(
$this->entityManager->getStorage('node_type')->create([
'type' => 'page',
'name' => 'page',
))->save();
])->save();
// When I am adding an Entity Test content.
$this->drupalGet('node/add/page');
......
......@@ -45,11 +45,18 @@ class YoastSeoFieldManager {
*/
protected $logger;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entity_manager;
/**
* Constructor for YoastSeoFieldManager.
*/
public function __construct() {
$this->entity_manager = \Drupal::entityManager();
$this->entity_manager = \Drupal::service('entity_type.manager');
}
/**
......@@ -142,11 +149,15 @@ class YoastSeoFieldManager {
->create($field_values)
->save();
entity_get_form_display($entity_type, $bundle, 'default')
->setComponent($field['field_name'], array())
$this->entity_manager
->getStorage('entity_form_display')
->load($entity_type . '.' . $bundle . '.default')
->setComponent($field['field_name'], [])
->save();
entity_get_display($entity_type, $bundle, 'default')
->setComponent($field['field_name'], array())
$this->entity_manager
->getStorage('entity_view_display')
->load($entity_type . '.' . $bundle . '.default')
->setComponent($field['field_name'], [])
->save();
}
}
......
......@@ -113,10 +113,8 @@ class YoastSeoManager {
*/
public function getAvailableBundles($entity_type = 'node') {
$options = array();
$entity_manager = \Drupal::service('entity.manager');
// Retrieve the bundles the entity type contains.
$bundles = $entity_manager->getBundleInfo($entity_type);
$bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo($entity_type);
foreach ($bundles as $bundle_id => $bundle_metadata) {
$options[$bundle_id] = $bundle_metadata['label'];
}
......
name: Real-time SEO for Drupal
core_version_requirement: ^8 || ^9
description: Adds Real-time SEO page analysis and configuration
package: SEO
......
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