Validate a model class name.

@param $modelClass

@return void
@throws CrudModelException
490569
protected function validateModelClass($modelClass)
    {
        // Validate the expected model exists.
        if (!class_exists($modelClass)) {
            throw new CrudModelException('The related model does not exist.');
        }

        // Validate the model extends the correct base model.
        if (!is_subclass_of($modelClass, self::MICROSERVICE_BASE_MODEL_CLASS)) {
            throw new CrudModelException('The related model must extend the MicroServiceBaseModel abstract class.');
        }

        // Validate the model implements the correct interface.
        if (!in_array(self::MICROSERVICE_CRUD_MODEL_INTERFACE, class_implements($modelClass))) {
            throw new CrudModelException('The related model must implement CrudModelInterface.');
        }
    }
615782
protected function findModel($modelClass, $attributes = [])
    {
        $query = $this->getQueryBuilderFromModel($modelClass);
        foreach ($attributes as $key => $value) {
            $query->where($key, $value);
        }

        return $query->first();
    }
1088281
protected function seedModelData(string $modelClass, array $data): void
    {
        $attributeTypes = $this->getModelSchemas()->getAttributeTypes($modelClass);

        $this->seedRowData($this->getModelSchemas()->getTable($modelClass), $data, $attributeTypes);
    }
791307
private function isValidClass(PhpClass $class)
    {
        $classNames = $this->config->get('classNames');
        return (empty($classNames) || in_array(
            $class->getIdentifier(),
            $classNames
        ));
    }
141789
protected function determineTargetModelFromSource($modelClass, $source)
    {
        if ( ! is_a($modelClass, Model::class, true)) {
            // @codeCoverageIgnoreStart
            throw new UnexpectedValueException("{$modelClass} is not an Eloquent model");
            // @codeCoverageIgnoreEnd
        }

        $model = new $modelClass;

        if ( ! ($relation = $this->getNestedRelation($model, $source))) {
            // @codeCoverageIgnoreStart
            $relation = $this->resolveModelSource($model, $source);
            // @codeCoverageIgnoreEnd
        }

        if ( ! ($relation instanceof Relation)) {
            // @codeCoverageIgnoreStart
            throw new UnexpectedValueException(
                "Source {$source} on {$modelClass} does not resolve to an Eloquent relation instance"
            );
            // @codeCoverageIgnoreEnd
        }

        /** @var Relation $relation */
        return $relation->getRelated();
    }
1097279
public function validateModelClass()
    {
        if ($this->isReservedKeyword($this->modelClass)) {
            $this->addError('modelClass', 'Class name cannot be a reserved PHP keyword.');
        }
        if (substr($this->tableName, -1) !== '*' && $this->modelClass == '') {
            $this->addError('modelClass', 'Model Class cannot be blank if table name does not end with asterisk.');
        }
    }
584462
protected function validateRuntimeMetadata(ClassMetadata $class, ?ClassMetadata $parent = null) : void
    {
        if (! $class->getReflectionClass()) {
            // only validate if there is a reflection class instance
            return;
        }

        $class->validateIdentifier();
        $class->validateAssociations();
        $class->validateLifecycleCallbacks($this->getReflectionService());

        // verify inheritance
        if (! $class->isMappedSuperclass && $class->inheritanceType !== InheritanceType::NONE) {
            if (! $parent) {
                if (! $class->discriminatorMap) {
                    throw MappingException::missingDiscriminatorMap($class->getClassName());
                }

                if (! $class->discriminatorColumn) {
                    throw MappingException::missingDiscriminatorColumn($class->getClassName());
                }
            }
        } elseif (($class->discriminatorMap || $class->discriminatorColumn) && $class->isMappedSuperclass && $class->isRootEntity()) {
            // second condition is necessary for mapped superclasses in the middle of an inheritance hierarchy
            throw MappingException::noInheritanceOnMappedSuperClass($class->getClassName());
        }
    }
324786
public function addResource($modelClass)
    {
        $code = '';

        if (is_file($this->file)) {
            $code = rtrim(file_get_contents($this->file));
        }

        $parts = explode('\\', $modelClass);

        $this->renderFile('Blast.yml.twig', $this->file, array(
            'fqcn'    => $modelClass,
            'fields'  => $this->modelManager->getExportFields($modelClass),
            'entity'  => array_pop($parts),
            'oldCode' => $code,
        ));
    }
458849
public function getRouteNameForModelClass($modelClass, $prefix = false)
    {
        $modelSlug = static::MODEL_ROUTE_NAME_PREFIX
                   . $this->getRouteSlugForModelClass($modelClass);

        if ( ! $prefix) {
            return $modelSlug;
        }

        return config('cms-core.route.name-prefix')
             . config('cms-models.route.name-prefix')
             . $modelSlug;
    }
15621
private function validatePluginClass($pluginClass)
    {
        if (!class_exists($pluginClass)) {
            throw new InvalidConfigException(sprintf(
                'The plugin class %s does not exist.',
                $pluginClass
            ));
        }

        if (!in_array('Puli\Manager\Api\PuliPlugin', class_implements($pluginClass))) {
            throw new InvalidConfigException(sprintf(
                'The plugin class %s must implement PuliPlugin.',
                $pluginClass
            ));
        }
    }
1298528
protected function getCountForModel($modelClass)
    {
        if ( ! is_a($modelClass, Model::class, true)) {
            throw new UnexpectedValueException("'{$modelClass}' is not an Eloquent model class.");
        }

        return $modelClass::withoutGlobalScopes()->count() ?: 0;
    }
247464
protected function findModel($modelClass, $attributes = [])
    {
        $query = $this->buildQuery($modelClass, $attributes);

        return $query->first();
    }
618339
protected function getVerboseChildrenName($modelClass)
    {
        $info = $this->getInformationRepository()->getByModelClass($modelClass);

        if ( ! $info) {
            return cms_trans('models.list-parents.models');
        }

        return $info->labelPlural();
    }
77926
public static void resetModelClass() {
		ModelFactory.modelClass = DefaultModelImpl.class;
    	System.err.println("[INFO] Reset model-class: " + ModelFactory.modelClass.getName());
	}
306588
protected function validateModel()
    {
        parent::validateModel();

        $table = $this->getTable();

        // Check to see if any of the column constants are PHP reserved words.
        $colConstants = array();

        foreach ($table->getColumns() as $col) {
            $colConstants[] = $this->getColumnName($col);
        }

        $reservedConstants = array_map('strtoupper', ClassTools::getPhpReservedWords());

        $intersect = array_intersect($reservedConstants, $colConstants);
        if (!empty($intersect)) {
            throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with a PHP reserved word (" . implode(", ", $intersect) . ")");
        }
    }
179160
private function validateChildClass(NodeInterface $parentNode, ClassMetadata $class)
    {
        $parentClass = $this->documentClassMapper->getClassName($this->dm, $parentNode);

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

        $metadata = $this->dm->getClassMetadata($parentClass);
        $metadata->assertValidChildClass($class);
    }
312777
private function checkModelRequirements() {
        $reload = false;
        $classAnnots = $this->getAnnotations()->getClass();
        if (!empty($classAnnots[1]) && is_array($classAnnots[1])) {
            foreach ($classAnnots[1] as $desc) {
                if (strtolower(substr($desc, 0, 4)) !== 'dbs\\')
                    continue;
                $this->performClassAnnots($desc);
                $reload = true;
            }
        }

        if ($reload) {
            @session_start();
            $_SESSION['mapperSave'] = true;
            header('Location: //' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }