Elgg  Version master
ServiceFacade.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Traits\Di;
4 
5 use DI\NotFoundException;
6 
11 
17  abstract public static function name(): string;
18 
25  final public static function instance(): static {
26  $name = static::name();
27 
28  return elgg()->{$name} ?? throw new NotFoundException("No entry or class found for '{$name}'");
29  }
30 
36  final public static function call(): mixed {
37  $arguments = func_get_args();
38  $method = array_shift($arguments);
39 
40  return elgg()->call([self::instance(), $method], $arguments);
41  }
42 }
$site name
Definition: settings.php:14
if(! $user||! $user->canDelete()) $name
Definition: delete.php:22
elgg()
Bootstrapping and helper procedural code available for use in Elgg core and plugins.
Definition: elgglib.php:12
trait ServiceFacade
Utility trait that can be used by public services to provide better IDE support and type-hinting.