Commit cd951ddb authored by renatog's avatar renatog Committed by renatog
Browse files

Issue #3268347 by RenatoG, pgn5qs: Fix the Dependency Injection at ModalPageService::__construct(),

parent 632308a5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
services:
  modal_page.modals:
    class: Drupal\modal_page\Service\ModalPageService
    arguments: ['@language_manager', '@entity_type.manager', '@config.factory', '@database', '@request_stack', '@path.matcher', '@uuid', '@current_user', '@path_alias.manager', '@module_handler', '@path.current', '@entity.repository']
    arguments: ['@language_manager', '@entity_type.manager', '@config.factory', '@database', '@request_stack', '@path.matcher', '@uuid', '@current_user', '@path_alias.manager', '@module_handler', '@path.current']
  modal_page.helper:
    class: Drupal\modal_page\Service\ModalPageHelperService
    arguments: ['@language_manager', '@current_user', '@entity_type.manager']
+3 −11
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ use Drupal\Component\Utility\Html;
use Drupal\path_alias\AliasManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityStorageException;

/**
@@ -103,17 +102,10 @@ class ModalPageService {
   */
  protected $projectHandler;

  /**
   * Drupal\Core\Entity\EntityRepositoryInterface service.
   *
   * @var \Drupal\Core\Entity\EntityRepositoryInterface
   */
  protected $entityRepository;

  /**
   * Construct of Modal Page 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, ModuleHandlerInterface $project_handler, 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, AccountProxyInterface $current_user, AliasManagerInterface $alias_manager, ModuleHandlerInterface $project_handler, CurrentPathStack $current_path) {
    $this->languageManager = $language_manager;
    $this->entityTypeManager = $entity_manager;
    $this->pathMatcher = $path_matcher;
@@ -125,7 +117,6 @@ class ModalPageService {
    $this->aliasManager = $alias_manager;
    $this->projectHandler = $project_handler;
    $this->currentPath = $current_path;
    $this->entityRepository = $entityRepository;
  }

  /**
@@ -642,7 +633,8 @@ class ModalPageService {
  public function recordFileUsage(array $uuids) {
    try {
      foreach ($uuids as $uuid) {
        if ($file = $this->entityRepository->loadEntityByUuid('file', $uuid)) {
        // We're not using DI to avoid issues on construct.
        if ($file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid)) {
          if ($file->status !== FILE_STATUS_PERMANENT) {
            $file->status = FILE_STATUS_PERMANENT;
            $file->save();