ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDerivedTaskProviderMasterFactory.php
Go to the documentation of this file.
1 <?php
2 
20 
27 {
29 
33  protected array $default_provider_factories = array(
34  ilExerciseDerivedTaskProviderFactory::class,
35  ilForumDerivedTaskProviderFactory::class,
36  DerivedTaskProviderFactory::class,
37  ilBlogDerivedTaskProviderFactory::class
38  );
39 
43  protected $provider_factories = [];
44 
48  public function __construct(ilTaskService $service, $provider_factories = null)
49  {
50  if (is_null($provider_factories)) {
51  $this->provider_factories = array_map(fn ($class): ilDerivedTaskProviderFactory => new $class($service), $this->default_provider_factories);
52  } else {
53  $this->provider_factories = $provider_factories;
54  }
55  $this->service = $service;
56  }
57 
65  public function getAllProviders(bool $active_only = false, int $user_id = null): array
66  {
67  $providers = array();
68 
69  if ($user_id == 0) {
70  $user_id = $this->service->getDependencies()->user()->getId();
71  }
72 
73  foreach ($this->provider_factories as $provider_factory) {
74  foreach ($provider_factory->getProviders() as $provider) {
75  if (!$active_only || $provider->isActive()) {
76  $providers[] = $provider;
77  }
78  }
79  }
80 
81  return $providers;
82  }
83 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$provider
Definition: ltitoken.php:83
__construct(ilTaskService $service, $provider_factories=null)
Constructor.
getAllProviders(bool $active_only=false, int $user_id=null)
Get all task providers.
Task service.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...