Class 'Drupal\path_alias\AliasStorage' not found in Drupal\multiple_registration\Controller\MultipleRegistrationController->getRegisterAliasStorage() while submitting the Registration page form.

Comments

pradeepjha’s picture

Assigned: Unassigned » pradeepjha
TommasoArmadillo’s picture

Hi! I had the same issue after I applied the patch given in
https://www.drupal.org/project/multiple_registration/issues/3136321
In order to solve this in the file modules/multiple_registration/src/Controller/MultipleRegistrationController.php I changed line 7-8

use Drupal\path_alias\AliasManager;
use Drupal\path_alias\AliasStorage;

to

use Drupal\Core\Path\AliasManager;
use Drupal\Core\Path\AliasStorage;

and this worked for me! Sorry but I'm quite a beginner so I don't know how to write a patch

pradeepjha’s picture

StatusFileSize
new2 KB

Re-produce Error:
After filling all required value in multiple registration form, on submitting registration form this error will show.

So attached patch will resolve this issue.

AliasStorage class is deprecated in Drupal-8.8.x version. So you have to use the "path_alias.repository" service instead. Ref- https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Path%21Al....

pradeepjha’s picture

Assigned: pradeepjha » Unassigned
Status: Active » Needs review
StatusFileSize
new1.99 KB

Minor change in patch.

Rkumar’s picture

ysamoylenko’s picture

Status: Needs review » Needs work

Hello @pradeepjha,

Thank you for your patch.

As you are implementing your functionality in the controller you should avoid using \Drupal::service('service_name') construction.
Use dependency injection instead.

Also, as I see you've changed configuration placeholder from ''multiple_registration_url_' . $rid' to ''multiple_registration_path_' . $rid'
This is not a good idea because it will break module functionality for users which will switch from an older version of the module to the new one.

Their aliases will lose in this case and we can't do that.

Also, if you removing some of the class references from the codebase, don't forget to remove them from use statements to keep the code clear.

pradeepjha’s picture

Assigned: Unassigned » pradeepjha
pradeepjha’s picture

Assigned: pradeepjha » Unassigned
Status: Needs work » Needs review
StatusFileSize
new4.33 KB

Hi @ysamoylenko,
I've updated patch.

  • Used dependency injection.
  • I've changed ''multiple_registration_url_' . $rid' to ''multiple_registration_path_' . $rid' because it gives registration path alias. ''multiple_registration_url_' . $rid' gives source path which I don't need here. Please suggest.
  • I've also removed use statement which is no more used.
pradeepjha’s picture

StatusFileSize
new4.44 KB

Parameter is added.

ysamoylenko’s picture

StatusFileSize
new25.28 KB

Hello @pradeepjha,
Yes, you are right, now we should use just an alias instead of conditions like previously.
But, according to API reference:
https://www.drupal.org/node/3013865

We can't use 'path.alias_storage' service for now, because it is deprecated:

So, you may use entity type manager reference to the entity and remove aliases, in a pretty similar way as your variant or use 'path_alias.repository' which is also still uses deprecated core functionality inside.

I suggest using the first option with an injection of entity type manager and use the structure like:

$this->entityTypeManager->getStorage('path_alias')->delete(['alias' => $path_alias])
ysamoylenko’s picture

Status: Needs review » Needs work
pradeepjha’s picture

Assigned: Unassigned » pradeepjha
pradeepjha’s picture

Status: Needs work » Needs review
StatusFileSize
new2.66 KB

Thanks @ysamoylenko
I've used injection of entitytype. I've removed all deprecated service.
Same like previous version, instead of deleting path alias we can delete source path (System path) alias. Which works fine. Please apply the patch and test it.

driverok’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that #14 works well for me - while submitting the Registration page form there is no errors.

With #14 applied drupal-check, rector, and upgrade-status return no errors.

Also I've checked #14 with drupal 9.0.0-beta3 - works well.

so RTBCing.

ysamoylenko’s picture

Hello everyone,

I've tested #14 with D8.8.6 core and everything works as expected.

Thanks all contributors for your efforts.
The patch will be committed soon.

ysamoylenko’s picture

Status: Reviewed & tested by the community » Fixed
nikolas.tatianenko’s picture

Issue tags: +epam-contrib

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.