Example #1
0
 /**
  * Register a new collector
  *
  * @param string $name
  * @param string $class
  * @param string $description
  */
 public function register(string $name, string $class, string $description)
 {
     $name = strtolower($name);
     config()->write('collectors.' . $name, array('class' => $class, 'description' => $description));
     $this->container->singleton($class);
     $this->container->alias($class, $name);
 }
Example #2
0
 /**
  * Get the container
  * 
  * @return  \Opis\Colibri\Container
  */
 public function container()
 {
     if ($this->container === null) {
         $app = $this->app;
         $container = new Container();
         foreach ($app->config()->read('collectors') as $type => $collector) {
             $container->alias($collector['interface'], $type);
             $container->singleton($collector['interface'], $collector['class']);
         }
         $this->container = $container;
     }
     return $this->container;
 }