Register a new collector

@param string $name
@param string $class
@param string $description
@param array $options
359508
public function register(string $name, string $class, string $description, array $options = [])
    {
        $name = strtolower($name);

        $this->app->getConfig()->write('collectors.' . $name, [
            'class' => $class,
            'description' => $description,
            'options' => $options,
        ]);
        $this->container->singleton($class);
        $this->container->alias($name, $class);
    }
715260
protected function registerAdapter($name, $classOrFactory)
    {
        $this
            ->define($name, function($config = []) use($classOrFactory) {
                $factory = is_object($classOrFactory) ? $classOrFactory : new $classOrFactory();

                return $factory->create([ $config ]);
            })
        ;
    }
938538
public function addTaskDefinition($name, $class, $classpath = null)
    {
        ComponentHelper::getComponentHelper($this)->addTaskDefinition($name, $class, $classpath);
    }
120993
public static function createForClass(
        $class,
        $name,
        $title = null,
        \SS_List $items = null
    )
    {
        $folderName = self::getFolderForClass($class, $name);

        $inst = new static($name, $title, $items);
        $inst->setFolderName($folderName . '/' . $name);
        return $inst;
    }
929337
public function registerCollectorClass($className)
    {
        /** @var CollectorInterface $collector */
        $collector = new $className($this->context->getProcess(), $this->datasource);
        $this->registerCollector($collector);
    }
258612
def register(self, collector):
        
        if not isinstance(collector, Collector):
            raise TypeError(
                "Can't register instance, not a valid type of collector")

        if collector.name in self.collectors:
            raise ValueError("Collector already exists or name colision")

        with mutex:
            self.collectors[collector.name] = collector
324222
public function register( $name, $controller, array $options = [] )
	{
		if ( isset( $options['parameters'] ) && !isset( $this->parameters ) )
			$this->parameters = $options['parameters'];

		// If the resource name contains a slash, we will assume the developer wishes to
		// register these resource routes with a prefix so we will set that up out of
		// the box so they don't have to mess with it. Otherwise, we will continue.
		if ( Str::contains( $name, '/' ) )
		{
			$this->prefixedResource( $name, $controller, $options );

			return;
		}

		// We need to extract the base resource from the resource name. Nested resources
		// are supported in the framework, but we need to know what name to use for a
		// place-holder on the route parameters, which should be the base resources.
		$base = $this->getResourceWildcard( last( explode( '.', $name ) ) );

		$defaults = $this->resourceDefaults;

		foreach ( $this->getResourceMethods( $defaults, $options ) as $m )
			$this->{'addResource' . ucfirst( $m )}( $name, $base, $controller, $options );
	}
1211439
public function addCustomField($name, $class)
    {
        if ($this->rebuilding && $this->formHelper->hasCustomField($name)) {
            return $this;
        }

        $this->formHelper->addCustomField($name, $class);
    }
1274724
public function add($name, $title, $properties, $controllerClass)
    {

        register_widget(new Widget($name, $title, $properties, $this->plugin, $controllerClass));
    }
284049
public void registerSingleton(String name, Class<?> clazz) throws BeansException {
        GenericBeanDefinition bd = new GenericBeanDefinition();
        bd.setBeanClass(clazz);
        getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
    }
1137156
public function Identify($name, $class)
    {
        $method = 'make'.lcfirst($name);
        if(method_exists($this, $method))
            $this->{$name}($class);
    }
959612
public function addCollector($collector, $name = null, array $params = null) {
		// Collector instance
		if ($collector instanceof CollectorInterface) {
			if ($name === null) {
				$class = get_class($collector);
				$name  = substr($class, strrpos($class, '\\') + 1);
			}
		}
		// String definition
		else if (is_string($collector)) {
			if ($name === null) {
				$name = $collector;
			}

			$collector = $this->loadCollector($collector, $params);
		}
		// Array definition
		else if (is_array($collector)) {
			$type = isset($collector['type']) ? $collector['type'] : $collector[0];

			// Define a name
			switch (true) {
				case $name !== null:
					break;

				case isset($collector['name']):
					$name = $collector['name'];
					break;

				case count($collector) > 2:
					$name = $collector[1];
					break;

				default:
					$name = $type;
			}

			// Define a params
			switch (true) {
				case isset($collector['params']):
					$collectorParams = $collector['params'];
					break;

				case count($collector) > 2:
					$collectorParams = $collector[2];
					break;

				default:
					$collectorParams = $collector[1];
			}

			if ($params !== null) {
				$collectorParams += $params;
			}

			$collector = $this->loadCollector($type, $collectorParams);
		}
		
		// Name collision handling
		while (isset($this->collectors[$name])) {
			if (preg_match('/[0-9]+$/', $name, $matches)) {
				$name = preg_replace_callback('/([0-9]+)$/', function($match) {
					return ((int) $match[1]) + 1;
				}, $name);
			} else {
				$name .= 2;
			}
		}
		
		if ($collector !== null) {
			$this->collectors[$name] = $collector;
		}
		
		return $collector;
	}
1276357
public static function registerExtensionClass(string $name, string $class): bool
    {
        if (class_exists($class) === false) {
            return false;
        }
        if (self::$extension_classes === null) {
            self::$extension_classes = [];
        }
        $check = new ReflectionClass($class);
        if ($check->implementsInterface("TheCMSThread\\Classes\\Extension") === true) {
            self::$extension_classes[$name] = $class;
            return true;
        } else {
            return false;
        }
    }
109330
public function addType($name, $class)
    {
        if (!Type::hasType($name)) {
            Type::addType($name, $class);
        } else {
            Type::overrideType($name, $class);
        }
    }
464300
public function create(
        string $name = 'windwalker',
        string $storage = 'array',
        string $serializer = 'php',
        array $options = []
    ): CacheInterface {
        $storage    = $storage ?: 'array';
        $serializer = $serializer ?: 'php';

        ksort($options);

        $hash = sha1($name . $storage . $serializer . serialize($options));

        if (!empty(static::$caches[$hash])) {
            return static::$caches[$hash];
        }

        $storage = $this->getStorage($storage, $options, $name);
        $handler = $this->getSerializer($serializer);

        $class = $this->cacheClass;
        $cache = $this->container->newInstance(
            $class,
            [$storage, $handler]
        );

        return static::$caches[$hash] = $cache;
    }
42536
public function createCollection($collection, $options = [])
    {
        if (is_array($collection)) {
            list($database, $collectionName) = $collection;
        } else {
            $database = null;
            $collectionName = $collection;
        }
        $this->beginProfile($token = "    > create collection " . $this->composeCollectionLogName($collection) . " ...");
        $this->db->getDatabase($database)->createCollection($collectionName, $options);
        $this->endProfile($token);
    }
1262597
public void register(Collector m) {
    List<String> names = collectorNames(m);
    synchronized (collectorsToNames) {
      for (String name : names) {
        if (namesToCollectors.containsKey(name)) {
          throw new IllegalArgumentException("Collector already registered that provides name: " + name);
        }
      }
      for (String name : names) {
        namesToCollectors.put(name, m);
      }
      collectorsToNames.put(m, names);
    }
  }