您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

29 行
735B

  1. <?php
  2. namespace common\logic;
  3. use yii\base\ErrorException;
  4. class BaseManager
  5. {
  6. protected ContainerInterface $container;
  7. public function __call($method, $args)
  8. {
  9. foreach($this->container->getServices() as $serviceClass) {
  10. if(method_exists($serviceClass, $method)) {
  11. return call_user_func_array(
  12. [new $serviceClass, $method],
  13. $args
  14. );
  15. }
  16. }
  17. throw new ErrorException('La méthode '.$method.' est introuvable dans les services du container '.get_class($this->container));
  18. }
  19. protected function setContainer(ContainerInterface $container): void
  20. {
  21. $this->container = $container;
  22. }
  23. }