Problem/Motivation & Proposed resolution

The \Drupal class is all about syntactic sugar in bridging our procedural code to our object-orientated code. There's only ever one method that is likely to be called on \Drupal::classResolver() so let's make it more helpful and allow

\Drupal::classResolver(ConfigEntityUpdater::class)

as a shortcut for

\Drupal::classResolver()->getInstanceFromDefinition(ConfigEntityUpdater::class)

Remaining tasks

Write change record.

User interface changes

None

API changes

API addition

Data model changes

None

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
Issue tags: +Needs change record
StatusFileSize
new5.49 KB

Status: Needs review » Needs work

The last submitted patch, 2: 2949965-2.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new699 bytes
new5.49 KB

Whoops

lendude’s picture

Issue tags: -Needs change record

Nice little tweak this.

nittiest of nits:

+++ b/core/lib/Drupal.php
@@ -320,10 +320,20 @@ public static function cache($bin = 'default') {
+   *   The class resolver of if $class is provided, a class instance with a

of => or

added CR: https://www.drupal.org/node/2950118

alexpott’s picture

StatusFileSize
new575 bytes
new5.49 KB

@Lendude++ thanks for the review and CR!

lendude’s picture

Status: Needs review » Reviewed & tested by the community

@alexpott++ nice addition.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 0613dbf and pushed to 8.6.x. Thanks!

  • catch committed 0613dbf on 8.6.x
    Issue #2949965 by alexpott, Lendude: \Drupal::classResolver() could be...

Status: Fixed » Closed (fixed)

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