Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorder parameters #531

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions modules/tide_site/src/AliasManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ class AliasManager extends CoreAliasManager {
/**
* {@inheritdoc}
*/
public function __construct(AliasRepositoryInterface $repository, AliasWhitelistInterface $whitelist, LanguageManagerInterface $language_manager, CacheBackendInterface $cache, protected ?TimeInterface $time = NULL, AliasStorageHelper $alias_helper) {
public function __construct(AliasRepositoryInterface $repository, AliasWhitelistInterface $whitelist, LanguageManagerInterface $language_manager, CacheBackendInterface $cache, protected ?TimeInterface $time = NULL)
{
parent::__construct($repository, $whitelist, $language_manager, $cache, $time);
$this->aliasHelper = $alias_helper;
$this->aliasHelper = \Drupal::service('tide_site.alias_storage_helper');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using $this->aliasHelper = \Drupal::service('tide_site.alias_storage_helper') isn’t ideal because it bypasses dependency injection, making the code harder to test.

The original error,

      8192: Optional parameter $time declared before required parameter $alias_helper is implicitly treated as a required parameter in docroot/modules/contrib/tide_core/modules/tide_site/src/AliasManager.php line 29 (Drupal\Core\Entity\EntityStorageException)

happened because required parameters must come before optional ones.
try to move AliasStorageHelper $alias_helper before $time

Copy link
Contributor Author

@yeniatencio yeniatencio Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using $this->aliasHelper = \Drupal::service('tide_site.alias_storage_helper') isn’t ideal because it bypasses dependency injection, making the code harder to test.

The original error,

      8192: Optional parameter $time declared before required parameter $alias_helper is implicitly treated as a required parameter in docroot/modules/contrib/tide_core/modules/tide_site/src/AliasManager.php line 29 (Drupal\Core\Entity\EntityStorageException)

happened because required parameters must come before optional ones. try to move AliasStorageHelper $alias_helper before $time

@vincent-gao , That was my first thought too. You can see in the first commit I have done what you are suggesting and it doesn't fix the issue. 16c32f8

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

}

/**
Expand Down
Loading