Add an id generator.

@param string $name  The name.
@param string $class The class.

@throws \InvalidArgumentException If the id generator already exists.
@throws \InvalidArgumentException If the class is not a subclass of Mongator\Id\IdGenerator.
359620
public static function add($name, $class)
    {
        if (static::has($name)) {
            throw new \InvalidArgumentException(sprintf('The id generator "%s" already exists.', $name));
        }

        $r = new \ReflectionClass($class);
        if (!$r->isSubclassOf('Mongator\Id\BaseIdGenerator')) {
            throw new \InvalidArgumentException(sprintf('The class "%s" is not a subclass of Mongator\Id\BaseIdGenerator.', $class));
        }

        static::$map[$name] = $class;
    }
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);
    }
505951
public function setIdentifier($identifier)
    {
        if (is_string($identifier) === false || empty($identifier) === true) {
            throw new InvalidArgumentException(
                "The 'identifier' argument must be a non-empty string."
            );
        }
        
        $this->identifier = $identifier;
    }
916556
private static function generateResult(\Generator $data, $class)
    {
        foreach ($data as $key => $value) {
            yield $key => self::create($value, $class);
        }
    }
143578
protected function addInterface(string $name, string $class)
    {
        if (!$this->hasInterface($name)) {
            $this->interfaces[$name] = $class;
            return;
        }
        $interfaces = $this->getInterface($name);

        if (!is_array($interfaces)) {
            $interfaces = [$interfaces];
        }

        if (!in_array($class, $interfaces)) {
            $interfaces[] = $class;
            $this->interfaces[$name] = $interfaces;
        }
    }
220237
public function addCustomNodeClass(string $name, string $class): self{
        if(!is_subclass_of($class, NodeInterface::class)){
            throw new \InvalidArgumentException();
        }

        $this->customNodes[$name]   = $class;

        return $this;
    }
401776
public static function addAvailableNamingStrategy($name, $className)
    {
        $ref = new \ReflectionClass($className);
        if (!$ref->isSubclassOf(NamingStrategy::class)) {
            throw new \InvalidArgumentException($className);
        }
        self::$strategies[$name] = $ref->getName();
    }
543179
public function createResource($class, $name)
    {
        $entity = new $class();

        if ($entity instanceof AbstractResource) {
            $entity->setName($name);

            return $entity;
        }

        throw new WrongClassException(
            "{$class} doesn't extend Claroline\\CoreBundle\\Entity\\Resource\\AbstractResource."
        );
    }
925024
public function registerFormatter($name, $class)
    {
        $name = strtolower(is_array($name) ? implode('-', $name) : $name);
        if (array_key_exists($name, static::$formatters)) {
            throw new \RuntimeException(sprintf('Formatter %s already registered.', $class));
        }
        static::$formatters[$name] = $class;

        return $this;
    }
109330
public function addType($name, $class)
    {
        if (!Type::hasType($name)) {
            Type::addType($name, $class);
        } else {
            Type::overrideType($name, $class);
        }
    }
1202860
public function registerResponseClass($name, $class)
    {
        $this->responseClasses[$name] = $class;
        // set retrospectively if method already encountered
        if ($this->serviceDescription !== null
            && $this->hasOperation($name) === true
        ) {
            throw new \LogicException(
                "Too late to add new response class, {$name} operation has already been defined. "
                .'If you want to add a new response class, call reset() method first, add new response class '
                .'and run build again.'
            );
        }
        return $this;
    }
157123
public static function create($class, $name)
    {
        $actor = Pool::getInstance()->get($class);
        $actor->initialization($name);
        return $actor;
    }
1053723
private function populateIdentifier(array $data, string $class): array
    {
        $identifier = $this->identifierExtractor->getIdentifierFromResourceClass($class);
        $identifier = null === $this->nameConverter ? $identifier : $this->nameConverter->normalize($identifier, $class, self::FORMAT);

        if (!isset($data['_source'][$identifier])) {
            $data['_source'][$identifier] = $data['_id'];
        }

        return $data;
    }
700281
public function addDiscriminatorMapClass($name, string $className) : void
    {
        $this->discriminatorMap[$name] = $className;

        if ($this->className === $className) {
            $this->discriminatorValue = $name;

            return;
        }

        if (! (class_exists($className) || interface_exists($className))) {
            throw MappingException::invalidClassInDiscriminatorMap($className, $this->className);
        }

        if (is_subclass_of($className, $this->className) && ! in_array($className, $this->subClasses, true)) {
            $this->subClasses[] = $className;
        }
    }
616089
public static function add($name, $class, $action) {
        if (!$action) {
            $action = "on" . ucfirst($name);
        }
        $info = array('name' => $name, 'class' => $class, "action" => $action);
        if (!key_exists($name, static::$events)) {
            static::$events[ $name ] = array();
        }
        static::$events[ $name ][] = $info;
    }
91646
public function createResource($class, $name)
    {
        $entity = $this->om->factory($class);

        if ($entity instanceof \Claroline\CoreBundle\Entity\Resource\AbstractResource) {
            $entity->setName($name);

            return $entity;
        }

        throw new WrongClassException(
            "{$class} doesn't extend Claroline\CoreBundle\Entity\Resource\AbstractResource."
        );
    }
591054
public function addProvider($name, ReindexProviderInterface $provider)
    {
        if (isset($this->providers[$name])) {
            throw new \InvalidArgumentException(sprintf(
                'Reindex provider with name "%s" has already been registered.',
                $name
            ));
        }

        $this->providers[$name] = $provider;
    }