/**
  * Return a list of available configuration options.
  *
  * @param Collection $availableTypes Collection of Injector\InjectorInterface::TYPE_*
  *     constants indicating valid package types that could be injected.
  * @param string $projectRoot Path to the project root; assumes PWD by
  *     default.
  * @return Collection Collection of ConfigOption instances.
  */
 public function getAvailableConfigOptions(Collection $availableTypes, $projectRoot = '')
 {
     // Create an initial collection to which we'll append.
     // This approach is used to ensure indexes are sane.
     $discovered = new Collection([new ConfigOption('Do not inject', new Injector\NoopInjector())]);
     Collection::create($this->discovery)->map(function ($discoveryClass) use($projectRoot) {
         if (is_array($discoveryClass)) {
             return new ConfigDiscovery\DiscoveryChain($discoveryClass, $projectRoot);
         }
         return new $discoveryClass($projectRoot);
     })->filter(function ($discovery) {
         return $discovery->locate();
     })->map(function ($discovery, $file) use($projectRoot, $availableTypes) {
         // Look up the injector based on the file type
         $injectorClass = $this->injectors[$file];
         if (is_array($injectorClass)) {
             return new Injector\ConfigInjectorChain($injectorClass, $discovery, $availableTypes, $projectRoot);
         }
         return new $injectorClass($projectRoot);
     })->filter(function ($injector) use($availableTypes) {
         return $availableTypes->reduce(function ($flag, $type) use($injector) {
             return $flag || $injector->registersType($type);
         }, false);
     })->each(function ($injector, $file) use($discovered) {
         $discovered[] = new ConfigOption($file, $injector);
     });
     return 1 === $discovered->count() ? new Collection([]) : $discovered;
 }
Example #2
0
 /**
  * Get all the participants who have contributed to this ticket by
  * examining each event in the timeline for the person who created it.
  *
  * @return Collection
  */
 public function getParticipants()
 {
     return $this->getWithCaching('participants', function () {
         return array_unique($this->timeline->reduce(function ($participants, $event) {
             $participants[] = $event->getWorker();
             return $participants;
         }, []));
     });
 }