Register a class

@param string $type See {@see $default} for names
@param string $class Class name, must subclass the corresponding default
@param bool $legacy Whether to enable legacy support for this class
@return bool Successfulness
324598
public function register($type, $class, $legacy = false)
	{
		if (!@is_subclass_of($class, $this->default[$type]))
		{
			return false;
		}

		$this->classes[$type] = $class;

		if ($legacy)
		{
			$this->legacy[] = $class;
		}

		return true;
	}
471760
public function addType(Type $type)
    {
        $name = $type->getName();

        if (!Type::hasType($name)) {
            Type::addType($name, get_class($type));
        }

        $this->types[$name] = $type;
    }
150486
public function addCallable($class, callable $provider, $type='default')
    {
        if (!isset($this->_callables[$type])) {
            $this->_callables[$type] = [];
        }
        $this->_callables[$type][$class] = $provider;
        return $this;
    }
263923
public static function registerAdminClass(string $name, string $class): bool
    {
        if (class_exists($class) === false) {
            return false;
        }
        if (self::$admin_classes === null) {
            self::$admin_classes = [];
        }
        $check = new ReflectionClass($class);
        if ($check->implementsInterface("TheCMSThread\\Classes\\Admin") === true) {
            self::$admin_classes[$name] = $class;
            return true;
        } else {
            return false;
        }
    }
842223
public static function resolve_plugininfo_class($type) {
        $plugintypes = core_component::get_plugin_types();
        if (!isset($plugintypes[$type])) {
            return '\core\plugininfo\orphaned';
        }

        $parent = core_component::get_subtype_parent($type);

        if ($parent) {
            $class = '\\'.$parent.'\plugininfo\\' . $type;
            if (class_exists($class)) {
                $plugintypeclass = $class;
            } else {
                if ($dir = core_component::get_component_directory($parent)) {
                    // BC only - use namespace instead!
                    if (file_exists("$dir/adminlib.php")) {
                        global $CFG;
                        include_once("$dir/adminlib.php");
                    }
                    if (class_exists('plugininfo_' . $type)) {
                        $plugintypeclass = 'plugininfo_' . $type;
                        debugging('Class "'.$plugintypeclass.'" is deprecated, migrate to "'.$class.'"', DEBUG_DEVELOPER);
                    } else {
                        debugging('Subplugin type "'.$type.'" should define class "'.$class.'"', DEBUG_DEVELOPER);
                        $plugintypeclass = '\core\plugininfo\general';
                    }
                } else {
                    $plugintypeclass = '\core\plugininfo\general';
                }
            }
        } else {
            $class = '\core\plugininfo\\' . $type;
            if (class_exists($class)) {
                $plugintypeclass = $class;
            } else {
                debugging('All standard types including "'.$type.'" should have plugininfo class!', DEBUG_DEVELOPER);
                $plugintypeclass = '\core\plugininfo\general';
            }
        }

        if (!in_array('core\plugininfo\base', class_parents($plugintypeclass))) {
            throw new coding_exception('Class ' . $plugintypeclass . ' must extend \core\plugininfo\base');
        }

        return $plugintypeclass;
    }
1070711
private function getTypeClassInstance(string $type)
    {
        $classname = isset($this->classesMap[$type]) ? $this->classesMap[$type]['class'] : false;

        return $classname ? new $classname() : false;
    }
1087886
public static function registerThemeClass(string $class): bool
    {
        if (class_exists($class) === false) {
            return false;
        }
        $check = new ReflectionClass($class);
        if ($check->implementsInterface("TheCMSThread\\Classes\\Theme") === true) {
            self::$theme_class = $class;
            return true;
        } else {
            return false;
        }
    }
684534
protected function registerComponent($class)
    {
        $component = $this->app->make($class);
        if (! ($component instanceof ComponentInterface)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Class "%s" must be instanced of "%s".',
                    $component,
                    ComponentInterface::class
                )
            );
        }

        if ($component instanceof Initializable) {
            $component->initialize();
        }

        $component->addToNavigation();

        $this->app['admin.components']->put($component->getName(), $component);
    }
1175350
public function registerService($service, $class)
    {
        $this[$service] = function ($app) use ($class) {
                $inst = new $class;
                if ($inst instanceof FactoryInterface) {
                    return $inst->create($app);
                } else {
                    return $inst;
                }
            };
    }
960105
public function addClass(PhpClass $class)
    {
        if ($this->classExists($class->getIdentifier())) {
            throw new Exception('A class of the name (' . $class->getIdentifier() . ') does already exist.');
        }

        $this->classes[$class->getIdentifier()] = $class;
    }
38477
public static function registerModulesClass(string $class): bool
    {
        if (class_exists($class) === false) {
            return false;
        }
        $check = new ReflectionClass($class);
        if ($check->implementsInterface("TheCMSThread\\Classes\\Modules") === true) {
            self::$modules_class = $class;
            return true;
        } else {
            return false;
        }
    }
1365761
public function getModule(string $class) : Module
    {
        foreach ($this->modules as $module) {
            if ($module instanceof $class) {
                return $module;
            }
        }

        throw new \InvalidArgumentException("No register module modules with class '%s'", get_class($class));
    }
441468
protected function registerObserver($class)
    {
        $className = is_string($class) ? $class : get_class($class);

        foreach ($this->getObservableEvents() as $event) {
            if (method_exists($class, $event)) {
                static::registerModelEvent($event, $className . '@' . $event);
            }
        }
    }
843568
public static function overrideType($name, $class, $phpTypeName = null)
    {
        if (!is_subclass_of($class, static::class)) {
            throw new BadArgumentException('Class :class should been subclass of :subClass', [
                'class' => $class, 'subClass' => static::class,
            ]);
        }
        
        if (null !== $phpTypeName) {
            static::$phpNamesMap[$name] = $phpTypeName;
        }
        
        static::$typesMap[$name] = $class;
    }
929867
function registerType($typeIdentifier, \Plasma\Types\TypeExtensionInterface $type): void {
        if(isset($this->regularTypes[$typeIdentifier]) || isset($this->classTypes[$typeIdentifier])) {
            throw new \Plasma\Exception('Type identifier is already in use');
        }
        
        if(\in_array($typeIdentifier, static::PHP_TYPES, true)) {
            $this->regularTypes[$typeIdentifier] = $type;
        } else {
            $this->classTypes[$typeIdentifier] = $type;
        }
    }
926293
public static function register($targetClass, $listener)
    {
        if (!is_subclass_of($targetClass, 'Windwalker\Event\DispatcherAwareInterface')) {
            throw new \InvalidArgumentException('Target class should be a DispatcherInterface.');
        }

        $targetClass = strtolower(trim($targetClass, '\\'));

        if (is_string($listener) && class_exists($listener)) {
            $listener = new $listener();
        }

        if (!is_object($listener) || is_callable($listener)) {
            throw new \InvalidArgumentException('Listener is not an object or callable.');
        }

        if (!isset(static::$maps[$targetClass])) {
            static::$maps[$targetClass] = [];
        }

        static::$maps[$targetClass][] = $listener;

        return true;
    }
215787
private function registerAnnotation($class)
    {
        /** @var CustomField $annotation */
        if ($annotation = $this->annotationReader->getClassAnnotation(
            new \ReflectionClass($class),
            'Lullabot\Mpx\DataService\Annotation\CustomField'
        )) {
            if (!is_subclass_of($class, CustomFieldInterface::class)) {
                throw new \RuntimeException(sprintf('%s must implement %s.', $class, CustomFieldInterface::class));
            }

            $this->customFields[$annotation->service][$annotation->objectType][$annotation->namespace] = new DiscoveredCustomField(
                $class, $annotation
            );
        }
    }