Gets the json schema of a class.

@param string $class

@return \stdClass
548659
public function getSchema($class)
    {
        $serializer = $this->get($class);

        if (method_exists($serializer, 'getSchema')) {
            $url = $serializer->getSchema();
            $path = explode('/', $url);
            $absolutePath = $this->rootDir.'/vendor/claroline/distribution/'
            .$path[1].'/'.$path[2].'/Resources/schemas/'.$path[3];

            return $this->loadSchema($absolutePath);
        }
    }
1132640
public function dsql($class = null)
    {
        $obj = parent::dsql($class);
        if (!$obj instanceof DB_dsql_prefixed) {
            throw $this->exception('Specified class must be descendant of DB_dsql_prefixed')
            ->addMoreInfo('class', $class);
        }
        if ($this->table_prefix) {
            $obj->prefix($this->table_prefix);
        }

        return $obj;
    }
960897
public function getReflection($class)
    {
        $isObject = is_object($class);
        $identity = $isObject
            ? ObjectIdentity::createFromObject($class)
            : new ObjectIdentity(sprintf('%s@%s', \ReflectionClass::class, $class));
        
        if (!$this->hasShared($identity->getIdentifier())) {
            $reflection = $isObject ? new \ReflectionObject($class) : new \ReflectionClass($class);
            $this->setShared($identity->getIdentifier(), $reflection);
        }
        
        return $this->getShared($identity->getIdentifier());
    }
634424
public static function getNamespace($class)
    {
        if (is_object($class) === true) {
            $class = get_class($class);
        }
        foreach (['\\', '_'] as $separator) {
            $pos = strrpos($class, $separator);
            if ($pos !== false) {
                return ltrim(substr($class, 0, $pos), $separator);
            }
        }
        return '';
    }
609252
public function getSchemaFromMetadata(array $classes)
    {
        // Reminder for processed classes, used for hierarchies
        $processedClasses       = array();
        $eventManager           = $this->em->getEventManager();
        $schemaManager          = $this->em->getConnection()->getSchemaManager();
        $metadataSchemaConfig   = $schemaManager->createSchemaConfig();

        $metadataSchemaConfig->setExplicitForeignKeyIndexes(false);
        $schema = new Schema(array(), array(), $metadataSchemaConfig);

        $addedFks = array();
        $blacklistedFks = array();

        foreach ($classes as $class) {
            /** @var \Doctrine\ORM\Mapping\ClassMetadata $class */
            if ($this->processingNotRequired($class, $processedClasses)) {
                continue;
            }

            $table = $schema->createTable($this->quoteStrategy->getTableName($class, $this->platform));

            if ($class->isInheritanceTypeSingleTable()) {
                $this->gatherColumns($class, $table);
                $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks);

                // Add the discriminator column
                $this->addDiscriminatorColumnDefinition($class, $table);

                // Aggregate all the information from all classes in the hierarchy
                foreach ($class->parentClasses as $parentClassName) {
                    // Parent class information is already contained in this class
                    $processedClasses[$parentClassName] = true;
                }

                foreach ($class->subClasses as $subClassName) {
                    $subClass = $this->em->getClassMetadata($subClassName);
                    $this->gatherColumns($subClass, $table);
                    $this->gatherRelationsSql($subClass, $table, $schema, $addedFks, $blacklistedFks);
                    $processedClasses[$subClassName] = true;
                }
            } elseif ($class->isInheritanceTypeJoined()) {
                // Add all non-inherited fields as columns
                $pkColumns = array();
                foreach ($class->fieldMappings as $fieldName => $mapping) {
                    if ( ! isset($mapping['inherited'])) {
                        $columnName = $this->quoteStrategy->getColumnName(
                            $mapping['fieldName'],
                            $class,
                            $this->platform
                        );
                        $this->gatherColumn($class, $mapping, $table);

                        if ($class->isIdentifier($fieldName)) {
                            $pkColumns[] = $columnName;
                        }
                    }
                }

                $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks);

                // Add the discriminator column only to the root table
                if ($class->name == $class->rootEntityName) {
                    $this->addDiscriminatorColumnDefinition($class, $table);
                } else {
                    // Add an ID FK column to child tables
                    $inheritedKeyColumns = array();
                    foreach ($class->identifier as $identifierField) {
                        $idMapping = $class->fieldMappings[$identifierField];
                        if (isset($idMapping['inherited'])) {
                            $this->gatherColumn($class, $idMapping, $table);
                            $columnName = $this->quoteStrategy->getColumnName(
                                $identifierField,
                                $class,
                                $this->platform
                            );
                            // TODO: This seems rather hackish, can we optimize it?
                            $table->getColumn($columnName)->setAutoincrement(false);

                            $pkColumns[] = $columnName;
                            $inheritedKeyColumns[] = $columnName;
                        }
                    }
                    if (!empty($inheritedKeyColumns)) {
                        // Add a FK constraint on the ID column
                        $table->addForeignKeyConstraint(
                            $this->quoteStrategy->getTableName(
                                $this->em->getClassMetadata($class->rootEntityName),
                                $this->platform
                            ),
                            $inheritedKeyColumns,
                            $inheritedKeyColumns,
                            array('onDelete' => 'CASCADE')
                        );
                    }

                }

                $table->setPrimaryKey($pkColumns);

            } elseif ($class->isInheritanceTypeTablePerClass()) {
                throw ORMException::notSupported();
            } else {
                $this->gatherColumns($class, $table);
                $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks);
            }

            $pkColumns = array();
            foreach ($class->identifier as $identifierField) {
                if (isset($class->fieldMappings[$identifierField])) {
                    $pkColumns[] = $this->quoteStrategy->getColumnName($identifierField, $class, $this->platform);
                } elseif (isset($class->associationMappings[$identifierField])) {
                    /* @var $assoc \Doctrine\ORM\Mapping\OneToOne */
                    $assoc = $class->associationMappings[$identifierField];
                    foreach ($assoc['joinColumns'] as $joinColumn) {
                        $pkColumns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
                    }
                }
            }

            if ( ! $table->hasIndex('primary')) {
                $table->setPrimaryKey($pkColumns);
            }

            if (isset($class->table['indexes'])) {
                foreach ($class->table['indexes'] as $indexName => $indexData) {
                    if( ! isset($indexData['flags'])) {
                        $indexData['flags'] = array();
                    }

                    $table->addIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName, (array)$indexData['flags'], isset($indexData['options']) ? $indexData['options'] : array());
                }
            }

            if (isset($class->table['uniqueConstraints'])) {
                foreach ($class->table['uniqueConstraints'] as $indexName => $indexData) {
                    $table->addUniqueIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName, isset($indexData['options']) ? $indexData['options'] : array());
                }
            }

            if (isset($class->table['options'])) {
                foreach ($class->table['options'] as $key => $val) {
                    $table->addOption($key, $val);
                }
            }

            $processedClasses[$class->name] = true;

            if ($class->isIdGeneratorSequence() && $class->name == $class->rootEntityName) {
                $seqDef     = $class->sequenceGeneratorDefinition;
                $quotedName = $this->quoteStrategy->getSequenceName($seqDef, $class, $this->platform);
                if ( ! $schema->hasSequence($quotedName)) {
                    $schema->createSequence(
                        $quotedName,
                        $seqDef['allocationSize'],
                        $seqDef['initialValue']
                    );
                }
            }

            if ($eventManager->hasListeners(ToolEvents::postGenerateSchemaTable)) {
                $eventManager->dispatchEvent(
                    ToolEvents::postGenerateSchemaTable,
                    new GenerateSchemaTableEventArgs($class, $schema, $table)
                );
            }
        }

        if ( ! $this->platform->supportsSchemas() && ! $this->platform->canEmulateSchemas() ) {
            $schema->visit(new RemoveNamespacedAssets());
        }

        if ($eventManager->hasListeners(ToolEvents::postGenerateSchema)) {
            $eventManager->dispatchEvent(
                ToolEvents::postGenerateSchema,
                new GenerateSchemaEventArgs($this->em, $schema)
            );
        }

        return $schema;
    }
735082
public function fetchFirstObj(string $class = null)
    {
        if (!$this->wasExecuted()) {
            $this->exec();
        }

        $data = $this->fetchFirst();

        if ($data === null) {
            return null;
        }

        if ($class == null) {
            $obj = new \stdClass();

            foreach ($data as $field => $value) {
                $obj->$field = $value;
            }

            return $obj;
        } else {
            return new $class($data);
        }
    }
1202028
public function getClassMetadata($class)
    {
        $class = ltrim($class, '\\');
        $metadataIndex = $this->getCacheId($class);

        if (isset($this->loadedMetadata[$metadataIndex])) {
            return $this->loadedMetadata[$metadataIndex];
        }

        if (isset($this->cache)) {
            if (false !== ($metadata = $this->cache->fetch($metadataIndex))) {
                return $metadata;
            }
        }

        $metadata = new $this->metadataClassName($class);

        $parentClasses = array_reverse(class_parents($class));
        foreach ($parentClasses as $parentClass) {
            $metadata->setClassName($parentClass);
            $this->driver->loadClassMetadata($metadata);
        }

        $metadata->setClassName($class);
        $this->driver->loadClassMetadata($metadata);

        if (isset($this->cache)) {
            $this->cache->save($metadataIndex, $metadata);
        }
        $this->loadedMetadata[$metadataIndex] = $metadata;

        return $metadata;
    }
1206292
public function getClass($class)
    {
        $this->checkClass($class);

        if (null === $this->infoClass) {
            $infoClass = get_class($this).'Info';
            $this->infoClass = new $infoClass();
        }

        return $this->infoClass->{'get'.str_replace('\\', '', $class).'Class'}();
    }
1004612
public function loadMetadataForClass(\ReflectionClass $class)
    {
        $classMetadata = new ClassMetadata($class->name);
        $classMetadata->fileResources[] = $class->getFilename();

        foreach ($this->reader->getClassAnnotations($class) as $annotation) {
            if ($annotation instanceOf Schema) {
                $classMetadata->schema = $annotation->name;
            }
            if ($annotation instanceOf Inherit) {
                $classMetadata->inherit = $annotation->name;
            }
        }

        if (null !== $classMetadata->schema) {
            return $classMetadata;
        }

        return null;
    }
1192700
public static function make($class)
    {
        if (!array_key_exists(
            'class',
            $class
        )
        ) {
            throw new SchemaException(
                __CLASS__,
                __METHOD__,
                "'class' field has not been found for defining 'object' schema entry",
                400
            );
        }

        if (!class_exists($class['class'])) {
            throw new SchemaException(
                __CLASS__,
                __METHOD__,
                "class {$class['class']} has not been defined",
                400
            );
        }

        if (!method_exists(
            $class['class'],
            'make'
        )
        ) {
            throw new SchemaException(
                __CLASS__,
                __METHOD__,
                "a 'class' defined in the 'object' schema entry must have a make method",
                400
            );
        }

        $instance = new static(
            $class['class']
        );

        if (array_key_exists(
            'relationship',
            $class
        )) {
            $instance->setRelationship(Relationship::make($class['relationship']));
        }

        return $instance;
    }
687008
public static function getExterior($class = '') {
        $path = ROOT_DIR . DS . 'server' . DS . "config" . DS . $class . '.json';
        if (is_file($path)) {
            C($class, get_json($path, true, true));
            return C($class);
        } else {
            return false;
        }
    }
898902
public function getRoot(string $class)
    {
        if (!is_a($class, Hierarchy::class, true))
            throw new TypeError("Not a subclass of Hierarchy: $class");

        $root = $class::getRootName();
        return $this->getInstance($class, $root);
    }
294522
public function getMetadata($objectClass)
    {
        if (! $objectClass instanceof ObjectKey) {
            $objectClass = new ObjectKey($objectClass);
        }

        $key = $objectClass->getKey();

        return $this->classMetadataFactory->loadMetadata(
            $objectClass,
            LoadingCriteria::createFromConfiguration($this->configuration, $objectClass),
            $this->configuration
        );
    }
530809
function jsonSerialize(): \stdClass {
    $map = new \stdClass;
    $map->name = $this->getName();
    $map->source_digest = $this->getSourceDigest();
    $map->coverage = $this->getCoverage()->getArrayCopy();
    if (mb_strlen($source = $this->getSource())) $map->source = $source;
    return $map;
  }
1115378
private function getService($class)
    {
        if (!array_key_exists($class, $this->services)) {
            $this->services[$class] = new $class($this->getClient(), $this->getLogger());
        }

        return $this->services[$class];
    }
1348609
protected static function parseClass($class)
    {
        static $cache = array();

        if (array_key_exists($class, $cache) === false) {
            // Make reference for original input
            $string = $class;

            if ($string[0] === '\\') {
                $string = substr($string, 1);
            }

            if (preg_match('/^(?<namespace>.*)\\\\(?<className>.+?)$/', $string, $matches)) {
                $cache[$class] = array($matches['namespace'], $matches['className']);
            } else {
                $cache[$class] = array(null, $class);
            }
        }

        return $cache[$class];
    }
1239643
public function forClass(string $class): MetaClass
    {
        $cacheName = 'MetaForClass:' . $class;
        $meta = $this->cache->get($cacheName);

        if (!$meta instanceof MetaClass) {
            $data = $this->source->forClass($class);
            $meta = $this->asMeta($data);

            $this->cache->set($cacheName, $meta);
        }

        return $meta;
    }