Loading core/lib/Drupal.php +4 −2 Original line number Diff line number Diff line Loading @@ -359,10 +359,12 @@ public static function cache($bin = 'default') { * One common use case is to provide a class which contains the actual code * of a hook implementation, without having to create a service. * * @param string $class * @param class-string<T>|null $class * (optional) A class name to instantiate. * * @return \Drupal\Core\DependencyInjection\ClassResolverInterface|object * @template T of object * * @return ($class is class-string<T> ? T : \Drupal\Core\DependencyInjection\ClassResolverInterface) * The class resolver or if $class is provided, a class instance with a * given class definition. * Loading core/lib/Drupal/Core/DependencyInjection/ClassResolverInterface.php +4 −2 Original line number Diff line number Diff line Loading @@ -12,10 +12,12 @@ interface ClassResolverInterface { * * In contrast to controllers you don't specify a method. * * @param string $definition * @param class-string<T>|string $definition * A class name or service name. * * @return object * @template T of object * * @return ($definition is class-string<T> ? T : object) * The instance of the class. * * @throws \InvalidArgumentException Loading core/modules/layout_builder/src/Hook/LayoutBuilderHooks.php +4 −12 Original line number Diff line number Diff line Loading @@ -201,9 +201,7 @@ public function entityBuildDefaultsAlter(array &$build, EntityInterface $entity, #[Hook('entity_presave')] public function entityPresave(EntityInterface $entity): void { if (\Drupal::moduleHandler()->moduleExists('block_content')) { /** @var \Drupal\layout_builder\InlineBlockEntityOperations $entity_operations */ $entity_operations = \Drupal::classResolver(InlineBlockEntityOperations::class); $entity_operations->handlePreSave($entity); \Drupal::classResolver(InlineBlockEntityOperations::class)->handlePreSave($entity); } } Loading @@ -213,9 +211,7 @@ public function entityPresave(EntityInterface $entity): void { #[Hook('entity_delete')] public function entityDelete(EntityInterface $entity): void { if (\Drupal::moduleHandler()->moduleExists('block_content')) { /** @var \Drupal\layout_builder\InlineBlockEntityOperations $entity_operations */ $entity_operations = \Drupal::classResolver(InlineBlockEntityOperations::class); $entity_operations->handleEntityDelete($entity); \Drupal::classResolver(InlineBlockEntityOperations::class)->handleEntityDelete($entity); } } Loading @@ -233,9 +229,7 @@ public function entityUpdate(EntityInterface $entity): void { // If an entity's field values change, and it also has a layout override // in the tempstore, the tempstore must be updated to reflect those new // values. /** @var \Drupal\layout_builder\LayoutOverrideFieldHelper $override_field_helper */ $override_field_helper = \Drupal::classResolver(LayoutOverrideFieldHelper::class); $override_field_helper->updateTempstoreEntityContext($entity); \Drupal::classResolver(LayoutOverrideFieldHelper::class)->updateTempstoreEntityContext($entity); } } Loading @@ -245,9 +239,7 @@ public function entityUpdate(EntityInterface $entity): void { #[Hook('cron')] public function cron(): void { if (\Drupal::moduleHandler()->moduleExists('block_content')) { /** @var \Drupal\layout_builder\InlineBlockEntityOperations $entity_operations */ $entity_operations = \Drupal::classResolver(InlineBlockEntityOperations::class); $entity_operations->removeUnused(); \Drupal::classResolver(InlineBlockEntityOperations::class)->removeUnused(); } } Loading Loading
core/lib/Drupal.php +4 −2 Original line number Diff line number Diff line Loading @@ -359,10 +359,12 @@ public static function cache($bin = 'default') { * One common use case is to provide a class which contains the actual code * of a hook implementation, without having to create a service. * * @param string $class * @param class-string<T>|null $class * (optional) A class name to instantiate. * * @return \Drupal\Core\DependencyInjection\ClassResolverInterface|object * @template T of object * * @return ($class is class-string<T> ? T : \Drupal\Core\DependencyInjection\ClassResolverInterface) * The class resolver or if $class is provided, a class instance with a * given class definition. * Loading
core/lib/Drupal/Core/DependencyInjection/ClassResolverInterface.php +4 −2 Original line number Diff line number Diff line Loading @@ -12,10 +12,12 @@ interface ClassResolverInterface { * * In contrast to controllers you don't specify a method. * * @param string $definition * @param class-string<T>|string $definition * A class name or service name. * * @return object * @template T of object * * @return ($definition is class-string<T> ? T : object) * The instance of the class. * * @throws \InvalidArgumentException Loading
core/modules/layout_builder/src/Hook/LayoutBuilderHooks.php +4 −12 Original line number Diff line number Diff line Loading @@ -201,9 +201,7 @@ public function entityBuildDefaultsAlter(array &$build, EntityInterface $entity, #[Hook('entity_presave')] public function entityPresave(EntityInterface $entity): void { if (\Drupal::moduleHandler()->moduleExists('block_content')) { /** @var \Drupal\layout_builder\InlineBlockEntityOperations $entity_operations */ $entity_operations = \Drupal::classResolver(InlineBlockEntityOperations::class); $entity_operations->handlePreSave($entity); \Drupal::classResolver(InlineBlockEntityOperations::class)->handlePreSave($entity); } } Loading @@ -213,9 +211,7 @@ public function entityPresave(EntityInterface $entity): void { #[Hook('entity_delete')] public function entityDelete(EntityInterface $entity): void { if (\Drupal::moduleHandler()->moduleExists('block_content')) { /** @var \Drupal\layout_builder\InlineBlockEntityOperations $entity_operations */ $entity_operations = \Drupal::classResolver(InlineBlockEntityOperations::class); $entity_operations->handleEntityDelete($entity); \Drupal::classResolver(InlineBlockEntityOperations::class)->handleEntityDelete($entity); } } Loading @@ -233,9 +229,7 @@ public function entityUpdate(EntityInterface $entity): void { // If an entity's field values change, and it also has a layout override // in the tempstore, the tempstore must be updated to reflect those new // values. /** @var \Drupal\layout_builder\LayoutOverrideFieldHelper $override_field_helper */ $override_field_helper = \Drupal::classResolver(LayoutOverrideFieldHelper::class); $override_field_helper->updateTempstoreEntityContext($entity); \Drupal::classResolver(LayoutOverrideFieldHelper::class)->updateTempstoreEntityContext($entity); } } Loading @@ -245,9 +239,7 @@ public function entityUpdate(EntityInterface $entity): void { #[Hook('cron')] public function cron(): void { if (\Drupal::moduleHandler()->moduleExists('block_content')) { /** @var \Drupal\layout_builder\InlineBlockEntityOperations $entity_operations */ $entity_operations = \Drupal::classResolver(InlineBlockEntityOperations::class); $entity_operations->removeUnused(); \Drupal::classResolver(InlineBlockEntityOperations::class)->removeUnused(); } } Loading