#2273381: Convert ContextAwarePluginBase to traits calls for the deprecation of passing contexts via configuration. This issue is a placeholder to remove the code relating to this deprecation.

The following items require attention:

  1. Remove the entire \Drupal\Core\Plugin\ContextAwarePluginBase class and file.
  2. Remove this snippet in \Drupal\Core\Plugin\ContextAwarePluginTrait::getContext():
        if (!$this->context) {
          if ($this instanceof ConfigurableInterface) {
            $configuration = $this->getConfiguration();
          }
          else {
            $reflection = new \ReflectionProperty($this, 'configuration');
            $reflection->setAccessible(TRUE);
            $configuration = $reflection->getValue($this);
          }
    
          if (isset($configuration['context'])) {
            @trigger_error('Passing context values to plugins via configuration is deprecated in drupal:9.1.0 and will be removed before drupal:10.0.0. Instead, call ::setContextValue() on the plugin itself. See https://www.drupal.org/node/3120980', E_USER_DEPRECATED);
            foreach ($configuration['context'] as $key => $value) {
              $context_definition = $this->getContextDefinition($key);
              $this->context[$key] = new Context($context_definition, $value);
            }
          }
        }
    

Issue fork drupal-3153956

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

clayfreeman created an issue. See original summary.

andregp’s picture

Is this issue still postponed?

longwave’s picture

Status: Postponed » Active

This issue can be worked on now for removing this code in 10.0.x.

clayfreeman’s picture

Status: Active » Needs review

While the component base class wasn't explicitly marked as deprecated (which was an oversight in my opinion), it was sufficiently deprecated in a change record so I'm removing it here also.

I think this is all that's needed for follow-up. Setting to Needs Review assuming tests will pass.

longwave’s picture

longwave’s picture

Status: Needs review » Reviewed & tested by the community

MR looks good, I don't see any remaining code that needs to be removed after applying the patch.

catch’s picture

I think we might want a 9.4.x/9.5.x patch here as well to fix the documentation on the component class.

longwave’s picture

catch’s picture

Title: Remove code related to "context from configuration" that was deprecated in Drupal 9 » [PP-1] Remove code related to "context from configuration" that was deprecated in Drupal 9
Status: Reviewed & tested by the community » Postponed
catch’s picture

Title: [PP-1] Remove code related to "context from configuration" that was deprecated in Drupal 9 » Remove code related to "context from configuration" that was deprecated in Drupal 9
Status: Postponed » Needs work
Issue tags: +Drupal 10 beta blocker

Blocked is in.

Spokje made their first commit to this issue’s fork.

andypost made their first commit to this issue’s fork.

andypost’s picture

Status: Needs work » Needs review

Rebased on current 10.0.x

spokje’s picture

Status: Needs review » Needs work

Cross-committing to an MR is going to be big in 2022 :)

andypost’s picture

Status: Needs work » Needs review

I'm so sorry for that, just prefer to rebase to keep history clean)

The valid status

spokje’s picture

Sorry, didn't mean to change the status.

just prefer to rebase to keep history clean)

I hear you, but somehow when I do a rebase on a MR with deleted files I always end up with the files returning into the MR.
Just my crappy Git-skills...

clayfreeman’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me; RTBC.

  • catch committed 9d6aed9 on 10.0.x
    Issue #3153956 by clayfreeman, Spokje, andypost, longwave: Remove code...
  • catch committed 3b4a427 on 10.1.x
    Issue #3153956 by clayfreeman, Spokje, andypost, longwave: Remove code...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.1.x and cherry-picked to 10.0.x, thanks!

Status: Fixed » Closed (fixed)

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