Commit 7eeede92 authored by Neslee Canil Pinto's avatar Neslee Canil Pinto Committed by jurriaanroelofs
Browse files

Issue #3264004 by Neslee Canil Pinto: Fix deprecated code and make this module ready for drupal 9

parent 73c49b46
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ type: module
description: Glazed Drupal CMS blog features by Sooperthemes.
package: Sooperthemes
core: 8.x
core_version_requirement: ^8 || ^9
dependencies:
  - block_class:block_class
  - cms_core:cms_core
+1 −1
Original line number Diff line number Diff line
@@ -3,5 +3,5 @@ services:
    class: Drupal\cms_blog\CmsBlogUninstallValidator
    tags:
      - { name: module_install.uninstall_validator }
    arguments: ['@entity.query']
    arguments: ['@entity_type.manager']
    lazy: true
+12 −12
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

namespace Drupal\cms_blog;

use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleUninstallValidatorInterface;

/**
@@ -11,20 +11,20 @@ use Drupal\Core\Extension\ModuleUninstallValidatorInterface;
class CmsBlogUninstallValidator implements ModuleUninstallValidatorInterface {

  /**
   * The entity query factory.
   * An instance of the entity type manager.
   *
   * @var \Drupal\Core\Entity\Query\QueryFactory
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $queryFactory;
  protected $entityTypeManager;

  /**
   * Constructs a new CmsBlogUninstallValidator.
   *
   * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory
   *   The entity query factory.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager.
   */
  public function __construct(QueryFactory $query_factory) {
    $this->queryFactory = $query_factory;
  public function __construct(EntityTypeManagerInterface $entityTypeManager) {
    $this->entityTypeManager = $entityTypeManager;
  }

  /**
@@ -59,8 +59,8 @@ class CmsBlogUninstallValidator implements ModuleUninstallValidatorInterface {
   *   TRUE if there are blog nodes, FALSE otherwise.
   */
  protected function hasBlogNodes() {
    $nodes = $this->queryFactory->get('node')
      ->condition('type', 'cms_blog')
    $query = $this->entityTypeManager->getStorage('node')->getQuery();
    $nodes = $query->condition('type', 'cms_blog')
      ->accessCheck(FALSE)
      ->range(0, 1)
      ->execute();
@@ -77,8 +77,8 @@ class CmsBlogUninstallValidator implements ModuleUninstallValidatorInterface {
   *   TRUE if there are terms for this vocabulary, FALSE otherwise.
   */
  protected function hasTerms($vid) {
    $terms = $this->queryFactory->get('taxonomy_term')
      ->condition('vid', $vid)
    $query = $this->entityTypeManager->getStorage('taxonomy_term')->getQuery();
    $terms = $query->condition('vid', $vid)
      ->accessCheck(FALSE)
      ->range(0, 1)
      ->execute();
+8 −4
Original line number Diff line number Diff line
@@ -7,15 +7,19 @@

namespace Drupal\cms_blog\ProxyClass {

    use Drupal\Core\Extension\ModuleUninstallValidatorInterface;
    use Drupal\Core\DependencyInjection\DependencySerializationTrait;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    use Drupal\Core\StringTranslation\TranslationInterface;
    /**
     * Provides a proxy class for \Drupal\cms_blog\CmsBlogUninstallValidator.
     *
     * @see \Drupal\Component\ProxyBuilder
     */
    class CmsBlogUninstallValidator implements \Drupal\Core\Extension\ModuleUninstallValidatorInterface
    class CmsBlogUninstallValidator implements ModuleUninstallValidatorInterface
    {

        use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
        use DependencySerializationTrait;

        /**
         * The id of the original proxied service.
@@ -46,7 +50,7 @@ namespace Drupal\cms_blog\ProxyClass {
         * @param string $drupal_proxy_original_service_id
         *   The service ID of the original service.
         */
        public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $drupal_proxy_original_service_id)
        public function __construct(ContainerInterface $container, $drupal_proxy_original_service_id)
        {
            $this->container = $container;
            $this->drupalProxyOriginalServiceId = $drupal_proxy_original_service_id;
@@ -78,7 +82,7 @@ namespace Drupal\cms_blog\ProxyClass {
        /**
         * {@inheritdoc}
         */
        public function setStringTranslation(\Drupal\Core\StringTranslation\TranslationInterface $translation)
        public function setStringTranslation(TranslationInterface $translation)
        {
            return $this->lazyLoadItself()->setStringTranslation($translation);
        }