Register provider for resource type.

@param string         $type
@param string|Closure $schema

@return void

@SuppressWarnings(PHPMD.StaticAccess)
@SuppressWarnings(PHPMD.ElseExpression)
@SuppressWarnings(PHPMD.CyclomaticComplexity)
184905
public function register(string $type, $schema): void
    {
        if (empty($type) === true || \class_exists($type) === false) {
            throw new InvalidArgumentException(_(static::MSG_INVALID_MODEL_TYPE));
        }

        $isOk = (
            (
                \is_string($schema) === true &&
                empty($schema) === false &&
                \class_exists($schema) === true &&
                \in_array(SchemaInterface::class, \class_implements($schema)) === true
            ) ||
            \is_callable($schema) ||
            $schema instanceof SchemaInterface
        );
        if ($isOk === false) {
            throw new InvalidArgumentException(_(static::MSG_INVALID_SCHEME, $type));
        }

        if ($this->hasProviderMapping($type) === true) {
            throw new InvalidArgumentException(_(static::MSG_TYPE_REUSE_FORBIDDEN, $type));
        }

        if ($schema instanceof SchemaInterface) {
            $this->setProviderMapping($type, \get_class($schema));
            $this->setResourceToJsonTypeMapping($schema->getType(), $type);
            $this->setCreatedProvider($type, $schema);
        } else {
            $this->setProviderMapping($type, $schema);
        }
    }
860783
private function validateSchema(Schema $schema)
    {
        $this->jsonValidator->check(
            json_decode(json_encode($schema->jsonSerialize())),
            json_decode(file_get_contents($schema->getSchema()))
        );

        return $this->jsonValidator->isValid();
    }
1204666
public function postDown(Schema $schema)
    {
        if (!$this->sm->tablesExist(['typo3_flow_resource_resource'])) {
            return;
        }
        $resourcesResult = $this->connection->executeQuery('SELECT DISTINCT resourcepointer FROM typo3_flow_resource_resource');
        while ($resourceInfo = $resourcesResult->fetch(\PDO::FETCH_ASSOC)) {
            $this->connection->executeQuery(
                'INSERT INTO typo3_flow_resource_resourcepointer (hash) VALUES (?)',
                array($resourceInfo['resourcepointer'])
            );

            $resourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['resourcepointer'][0] . '/' . $resourceInfo['resourcepointer'][1] . '/' . $resourceInfo['resourcepointer'][2] . '/' . $resourceInfo['resourcepointer'][3] . '/' . $resourceInfo['resourcepointer'];
            if (!file_exists($resourcePathAndFilename)) {
                $this->write(sprintf('Error while migrating database for the old resource management: the resource file "%s" was not found.', $resourcePathAndFilename));
                continue;
            }
            $newResourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['resourcepointer'];
            $result = @rename($resourcePathAndFilename, $newResourcePathAndFilename);
            if ($result === false) {
                $this->write(sprintf('Could not move the data file of resource "%s" from its location at %s to the legacy location %s.', $resourceInfo['resourcepointer'], $resourcePathAndFilename, $newResourcePathAndFilename));
            }
            Files::removeEmptyDirectoriesOnPath(dirname($resourcePathAndFilename));
        }

        $this->connection->exec('UPDATE typo3_flow_resource_resource SET fileextension =  SUBSTRING_INDEX(filename, \'.\', -1)');
        $this->connection->exec('ALTER TABLE typo3_flow_resource_resource ADD CONSTRAINT typo3_flow_resource_resource_ibfk_1 FOREIGN KEY (resourcepointer) REFERENCES typo3_flow_resource_resourcepointer (hash)');
    }
894691
private function createTable(DBALSchema $schema, string $schemaName, TypeSchema $type)
    {
        $table = $schema->createTable($this->tableName($schemaName, $type->name()));
        $table->addColumn('id', 'guid');
        $table->setPrimaryKey(['id']);

        foreach ($type->getDefinitions(['id']) as $field => $definition) {
            $this->typeRegistry->map($schemaName, $table, $field, $definition);
        }
    }
1030582
public void register(Type<?> type) {
        jdbcTypeMapping.register(type.getSQLTypes()[0], type.getReturnedClass());
        javaTypeMapping.register(type);
    }
568464
private function work(Schema $schema, Closure $operation)
    {
        [$global, $federation] = $this->partitionSchema($schema);
        $sql                   = [];

        $this->shardManager->selectGlobal();
        $globalSql = $operation($this->synchronizer, $global);

        if ($globalSql) {
            $sql[] = "-- Work on Root Federation\nUSE FEDERATION ROOT WITH RESET;";
            $sql   = array_merge($sql, $globalSql);
        }

        $shards = $this->shardManager->getShards();

        foreach ($shards as $shard) {
            $this->shardManager->selectShard($shard['rangeLow']);

            $federationSql = $operation($this->synchronizer, $federation);
            if (! $federationSql) {
                continue;
            }

            $sql[] = '-- Work on Federation ID ' . $shard['id'] . "\n" .
                     'USE FEDERATION ' . $this->shardManager->getFederationName() . ' (' . $this->shardManager->getDistributionKey() . ' = ' . $shard['rangeLow'] . ') WITH RESET, FILTERING = OFF;';
            $sql   = array_merge($sql, $federationSql);
        }

        return $sql;
    }
879201
protected function generateDataTypes(array $schema)
    {
        $directory = $this->getMappingDirectory('DataType');
        foreach ($schema['datatypes'] as $dataType => $data) {
            $this->generateDataType($dataType, $data, $directory);
        }
    }
1295451
protected function registerTypesService(){

        $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterTypesInterface', function()
        {
            return new \designpond\newsletter\Newsletter\Repo\NewsletterTypesEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_types );
        });
    }
3808
public static <T> boolean register(Class<T> typeClass, Schema<T> schema)
    {
        if (ID_STRATEGY instanceof DefaultIdStrategy)
            return ((DefaultIdStrategy) ID_STRATEGY).registerPojo(typeClass,
                    schema);

        throw new RuntimeException(
                "RuntimeSchema.register is only supported on DefaultIdStrategy");
    }
1013664
public function register(): void
    {
        $this->app->singleton(GraphQL::class);
        $this->app->alias(GraphQL::class, 'graphql');

        $this->app->singleton(DirectiveFactory::class);
        $this->app->singleton(NodeRegistry::class);
        $this->app->singleton(TypeRegistry::class);
        $this->app->singleton(CreatesContext::class, ContextFactory::class);
        $this->app->singleton(CanStreamResponse::class, ResponseStream::class);

        $this->app->bind(CreatesResponse::class, SingleResponse::class);

        $this->app->bind(GlobalIdContract::class, GlobalId::class);

        $this->app->singleton(GraphQLRequest::class, function (Container $app): GraphQLRequest {
            /** @var \Illuminate\Http\Request $request */
            $request = $app->make('request');

            return Str::startsWith(
                $request->header('Content-Type'),
                'multipart/form-data'
            )
                ? new MultipartFormRequest($request)
                : new LighthouseRequest($request);
        });

        $this->app->singleton(SchemaSourceProvider::class, function (): SchemaStitcher {
            return new SchemaStitcher(
                config('lighthouse.schema.register', '')
            );
        });

        $this->app->bind(ProvidesResolver::class, ResolverProvider::class);
        $this->app->bind(ProvidesSubscriptionResolver::class, function (): ProvidesSubscriptionResolver {
            return new class implements ProvidesSubscriptionResolver {
                public function provideSubscriptionResolver(FieldValue $fieldValue): Closure
                {
                    throw new Exception(
                       'Add the SubscriptionServiceProvider to your config/app.php to enable subscriptions.'
                   );
                }
            };
        });

        if ($this->app->runningInConsole()) {
            $this->commands([
                ClearCacheCommand::class,
                InterfaceCommand::class,
                MutationCommand::class,
                PrintSchemaCommand::class,
                QueryCommand::class,
                ScalarCommand::class,
                SubscriptionCommand::class,
                UnionCommand::class,
                ValidateSchemaCommand::class,
            ]);
        }
    }
556968
public function registerDynamicType($typeName)
    {
        if (isset($this->bindings[$typeName])) {
            throw new \InvalidArgumentException("`$typeName` is already registerd.");
        }

        $type = new \ReflectionClass($typeName);
        $this->bindings[$typeName] = new DynamicService($type);

        return $this;
    }
716246
public function load($resource, $type = null)
    {
        $configs = Yaml::parse($resource);

        return $this->createSchemas($configs);
    }
718058
public function create(Schema $schema)
    {
        $currentDbSchema = $this->connection->getSchemaManager()->createSchema();

        $dbSchema = new DBALSchema(
            $currentDbSchema->getTables(),
            $currentDbSchema->getSequences(),
            $this->connection->getSchemaManager()->createSchemaConfig()
        );

        foreach ($schema->types() as $type) {
            $tableName = $this->tableName($schema->name(), $type->name());

            if ($dbSchema->hasTable($tableName)) {
                throw DoctrineStorageException::tableAlreadyExists($tableName);
            }

            $this->createTable($dbSchema, $schema->name(), $type);
        }

        $queries = $dbSchema->toSql($this->connection->getDatabasePlatform());

        $this->executeQueries($queries);
    }
554391
public function registerDataTypeHandler(DataTypeHandlerInterface $handler)
    {
        foreach ($handler->supports() as $name) {
            $this->handlers[$name] = $handler;
        }
    }
1263297
protected function register(
        Schema $schema,
        Result\ValidationResult $result
    ) {
        $this->results[$this->generateVisitKey($schema)] = $result;

        return $result;
    }
760129
public void registerAll(JMFSchema schema) throws JMFSchemaIdException {
    if (isPresent(schema))
      return;
    registerInternal(schema);
    registerDependents(schema.getJMFType());
  }
624156
public void registerDefinedSchema(DataSchema schema)
  {
    final ClassTemplateSpec spec = createFromDataSchema(schema);
    _schemaToClassMap.put(schema, spec);
    _classNameToSchemaMap.put(spec.getFullName(), schema);
  }