In Drupal, the class for a service defined in a module .services.yml file doesn't need to implement `create(ContainerInterface $container)`. It's not even requested to implement a specific PHP interface. See one of the services Drupal core implements, for example the [*path_alias.manager*][1] service. ```yaml path_alias.manager: class: Drupal\path_alias\AliasManager arguments: - '@path_alias.repository' - '@path_alias.whitelist' - '@language_manager' - '@cache.data' ``` The [`AliasManager`][2] class that implements that service doesn't implement any `create()` method; it just implement the [constructor][3], with the parameters defined in the same order the service arguments are listed. ```php public function __construct($alias_repository, AliasWhitelistInterface $whitelist, LanguageManagerInterface $language_manager, CacheBackendInterface $cache) { $this->pathAliasRepository = $alias_repository; $this->languageManager = $language_manager; $this->whitelist = $whitelist; $this->cache = $cache; } ``` The classes that implement `create(ContainerInterface $container)` and which implement [`ContainerInjectionInterface`][4], for example the [`CronForm`][5] class, don't return a closure from `create(ContainerInterface $container)`; they actually only return an instance of themselves. See [`CronForm::create()`][6]. ```php public static function create(ContainerInterface $container) { return new static($container->get('config.factory'), $container->get('state'), $container->get('cron'), $container->get('date.formatter'), $container->get('module_handler') ); } ``` If you want to implement a factory service in Drupal, you should take the [*cache_factory*][7] service as example to write your code. ```yaml cache_factory: class: Drupal\Core\Cache\CacheFactory arguments: - '@settings' - '%cache_default_bin_backends%' calls: - [setContainer, ['@service_container']] ``` A service that uses that service as factory is, for example, the [*cache.render*][8] service. ```yaml cache.render: class: Drupal\Core\Cache\CacheBackendInterface tags: - { name: cache.bin } factory: - '@cache_factory' - get arguments: - render ``` The *factory* key defines which service is the factory service and which method is called for that factory service; the *arguments* key define the arguments passed to that method. In this case, it's telling Drupal to instantiate the *cache.render* service by instantiating the *cache_factory* service and calling `get('render')` on that object. [1]: https://api.drupal.org/api/drupal/core%21modules%21path_alias%21path_alias.services.yml/service/path_alias.manager/9.2.x [2]: https://api.drupal.org/api/drupal/core%21modules%21path_alias%21src%21AliasManager.php/class/AliasManager/9.2.x [3]: https://api.drupal.org/api/drupal/core%21modules%21path_alias%21src%21AliasManager.php/function/AliasManager%3A%3A__construct/9.2.x [4]: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21DependencyInjection%21ContainerInjectionInterface.php/interface/ContainerInjectionInterface/9.2.x [5]: https://api.drupal.org/api/drupal/core%21modules%21system%21src%21Form%21CronForm.php/class/CronForm/9.2.x [6]: https://api.drupal.org/api/drupal/core%21modules%21system%21src%21Form%21CronForm.php/function/CronForm%3A%3Acreate/9.2.x [7]: https://api.drupal.org/api/drupal/core%21core.services.yml/service/cache_factory/9.2.x [8]: https://api.drupal.org/api/drupal/core%21core.services.yml/service/cache.render/9.2.x