Problem/Motivation

AdminContext has no interface, yet it is a service with a public method.
Adding an interface will allow this service to be cleanly decorated.

Proposed resolution

Add an interface
Change typehints where BC-safe

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A, this is only used as a typehint in constructors.

Data model changes

N/A

Comments

tim.plunkett created an issue. See original summary.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

geek-merlin’s picture

Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new10.6 KB

OK, so this largely was an IDE nobrainer, except for
* @var FQN namespaces,
* @inheritdoc
* removing unused import statements

(Any hints how to tweak PHPStorm settings to automate these?)

Patch flying in.

Setting major as this blocks stable contrib release of tim's initial work in #2621536: [admin_theme] Administration theme

tim.plunkett’s picture

Wait, me Tim? Did I work on that? I don't remember that, nor this being a hard blocker...

geek-merlin’s picture

Yeah, i often want to do stuff just to find i already did in my repo... Git says that's your code:

/**
 * Decorates the core AdminContext to check custom admin paths.
 *
 * @todo Do not extend the decorated class, implement an interface after
 *   https://www.drupal.org/node/2708599.
 */
class AdminThemeAdminContext extends AdminContext {

Well OK it may not be a hard blocker, just a kittenkiller...

borisson_’s picture

Status: Needs review » Needs work

Some nits. According to $ ag AdminContext you did replace all the instances.

  1. +++ b/core/lib/Drupal/Core/Routing/AdminContext.php
    @@ -5,9 +5,9 @@
     /**
    - * Provides a helper class to determine whether the route is an admin one.
    + * {@inheritdoc}
      */
    

    Oh, wow.

    Does this work? I don't think we do this but I can't seem to find any documentation about it.

  2. +++ b/core/lib/Drupal/Core/Routing/AdminContextInterface.php
    @@ -0,0 +1,24 @@
    +use Symfony\Component\Routing\Route;
    +
    +
    +/**
    

    Should be only one newline

  3. +++ b/core/lib/Drupal/Core/Routing/AdminContextInterface.php
    @@ -0,0 +1,24 @@
    + * Provides a helper class to determine whether the route is an admin one.
    

    I don't think this comment is correct, this is the interface, not the class.

  4. +++ b/core/lib/Drupal/Core/Routing/AdminContextInterface.php
    @@ -0,0 +1,24 @@
    +  public function isAdminRoute(Route $route = NULL);
    +}
    \ No newline at end of file
    

    Needs a newline at the end of the file and a newline before the closing bracket of the class.

  5. +++ b/core/modules/user/src/Theme/AdminNegotiator.php
    @@ -38,7 +38,7 @@ class AdminNegotiator implements ThemeNegotiatorInterface {
    -   * @var \Drupal\Core\Routing\AdminContext
    +   * @var AdminContextInterface
    

    Should be the FQN.

geek-merlin’s picture

Thanks for the nits! I'll incorporate them.

5. FQN => MEMO to me, weed out how to make phpstorm do this by itself...

1. inheritdoc => in fact it's the rule:
https://www.drupal.org/docs/develop/coding-standards/api-documentation-a...
(other projects have the rule to leave this as it's just visual clutter and don't add info, but drupal decided for it, i guess api.drupal.org uses it)

borisson_’s picture

#9, that documentation page talks about methods, not classes. I was talking about the class documentation there.

tim.plunkett’s picture

{@inheritdoc} on a class makes no sense.

+++ b/core/lib/Drupal/Core/Routing/AdminContextInterface.php
@@ -0,0 +1,24 @@
+ * Provides a helper class to determine whether the route is an admin one.

This bit should move back to the class, and the interface needs its own docblock explaining the generic concept of determining the admin-ness of a route.

The single implementation that we have is not a "helper class". It's one implementation of the interface that specifically checks for the route option of _admin_route, and could explain that.

geek-merlin’s picture

Status: Needs work » Needs review
StatusFileSize
new10.53 KB
new2.11 KB

Ah yes i see. Here we go. New patch with nits 1-5.

Status: Needs review » Needs work

The last submitted patch, 12: drupal-2708599-12-AdminContextInterface.patch, failed testing. View results

geek-merlin’s picture

Status: Needs work » Needs review

Exception: Warning: apcu_store(): Unable to allocate memory for pool.

Looks like a CI problem.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Nits were resolved. This looks good to go.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: drupal-2708599-12-AdminContextInterface.patch, failed testing. View results

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

borisson_’s picture

It still doesn't have an interface, so if we still want interfaces for all classes, I'm sure we can revive this. However I am not sure what the current policy is about that.

borisson_’s picture

Discussed this a bit in slack with catch, we don't think this would ever need to be decorated or swapped out for another implementation.
https://drupal.slack.com/archives/C08HS1S71H7/p1772090051771109

I think we can close this issue.

borisson_’s picture

Priority: Major » Normal

At the very least, we can mark this as normal