apigee-edge-drupal icon indicating copy to clipboard operation
apigee-edge-drupal copied to clipboard

Error: Call to a member function isRouted() on string in apigee_kickstart_enhancement_preprocess_menu()

Open MahmoudSayed96 opened this issue 7 months ago • 5 comments

Description

After i installed apigee kickstart with composer and try to access configuration pages as admin user throw this exception.

Apigee Info

"apigee/apigee_devportal_kickstart": "^3", "drupal/core-composer-scaffold": "^10", "drupal/core-project-message": "^10", "drupal/core-recommended": "^10",

Steps to Reproduce

Actual Behavior

Error: Call to a member function isRouted() on string in apigee_kickstart_enhancement_preprocess_menu()

Expected Behavior

Portal open without any exceptions

Screenshots

If applicable, add screenshots to help explain your problem.

Notes

Add any other context about the problem here.

Version Info

apigee/apigee_devportal_kickstart : 3.0.4 drupal/core : 10.4.6

MahmoudSayed96 avatar Apr 16 '25 12:04 MahmoudSayed96

I tried this solution by add is_object($item['url']) for condition

/**
 * Implements hook_preprocess().
 */
function apigee_kickstart_enhancement_preprocess_menu(&$variables) {
  // Hide the registration link for authenticated users.
  foreach ($variables['items'] as $key => &$item) {
    if (is_object($item['url']) && $item['url']->isRouted() && $item['url']->getRouteName() === 'user.register' && \Drupal::currentUser()->isAuthenticated()) {
      unset($variables['items'][$key]);
    }
  }
}

MahmoudSayed96 avatar Apr 16 '25 12:04 MahmoudSayed96

Hi @MahmoudSayed96 Thanks for creating the ticket and updating about this issue. Did the solution worked, which you mentioned above ?

kedarkhaire avatar Apr 16 '25 15:04 kedarkhaire

Hi @kedarkhaire Yes, the issue was fixed after adding a condition to check the value of the URL.

MahmoudSayed96 avatar Apr 19 '25 17:04 MahmoudSayed96

Hi @MahmoudSayed96 Can you please create the PR for the same, we will review it. Thanks!

kedarkhaire avatar Jun 11 '25 10:06 kedarkhaire

Hi @MahmoudSayed96 Are you still facing this issue ?

kedarkhaire avatar Oct 10 '25 08:10 kedarkhaire