Get Discriminator Values

@param string[] $classNames

@throws InvalidArgumentException If the number of found collections > 1.
166391
private function getDiscriminatorValues($classNames) : array
    {
        $discriminatorValues = [];
        $collections         = [];
        foreach ($classNames as $className) {
            $class                 = $this->dm->getClassMetadata($className);
            $discriminatorValues[] = $class->discriminatorValue;
            $key                   = $this->dm->getDocumentDatabase($className)->getDatabaseName() . '.' . $class->getCollection();
            $collections[$key]     = $key;
        }
        if (count($collections) > 1) {
            throw new InvalidArgumentException('Documents involved are not all mapped to the same database collection.');
        }
        return $discriminatorValues;
    }
94270
public function removeMultiple(array $classNames)
    {
        $this->parseClassAttribute();

        foreach ($classNames as $className) {
            if (!is_string($className)) {
                throw new InvalidArgumentException(sprintf('Class name must be a string, %s given', (is_object($className) ? get_class($className) : gettype($className))));
            }

            $classIndex = array_search($className, $this->classes);

            if ($classIndex === false) {
                continue;
            }

            unset($this->classes[$classIndex]);
        }

        $this->updateClassAttribute();

        return $this;
    }
1371096
public function setParentClasses(array $classNames)
    {
        $this->parentClasses = $classNames;

        if (count($classNames) > 0) {
            $this->rootDocumentName = array_pop($classNames);
        }
    }
1214331
public static function groupModelsAndIdentifiersByType($models)
    {
        $groups = (new Collection($models))->groupBy(function ($model) {
            if (is_numeric($model)) {
                return 'integers';
            } else if (is_string($model)) {
                return 'strings';
            } else if ($model instanceof Model) {
                return 'models';
            }

            throw new InvalidArgumentException('Invalid model identifier');
        })->map(function ($items) {
            return $items->all();
        })->all();

        return static::fillMissingKeys($groups, [], ['integers', 'strings', 'models']);
    }
106379
protected function buildClassificationsFromConfiguration($configuredMappedClasses) : array
    {
        $classifications = [];
        foreach ($configuredMappedClasses as $class) {
            if ( (empty($class['patterns']) && empty($class['matchPatterns'])) || empty($class['class'])) {
                throw new \InvalidArgumentException('A class configuration in SOLR_CLASSIFCATION needs to have a pattern and a class configured. Given configuration: ' . serialize($class));
            }

                // @todo deprecate patterns configuration
            $patterns = empty($class['patterns']) ? [] : GeneralUtility::trimExplode(',', $class['patterns']);
            $matchPatterns = empty($class['matchPatterns']) ? [] : GeneralUtility::trimExplode(',', $class['matchPatterns']);
            $matchPatterns = $matchPatterns + $patterns;
            $unMatchPatters = empty($class['unmatchPatterns']) ? [] : GeneralUtility::trimExplode(',', $class['unmatchPatterns']);

            $className = $class['class'];
            $classifications[] = GeneralUtility::makeInstance(
                ClassificationItem::class,
                /** @scrutinizer ignore-type */ $matchPatterns,
                /** @scrutinizer ignore-type */ $unMatchPatters,
                /** @scrutinizer ignore-type */ $className
            );
        }

        return $classifications;
    }
353870
protected function sortEntitiesByValueClass($entities)
    {
        $entitiesByValueClassByIds = [];
        foreach ($entities as $entity) {
            if (null === $entity) {
                continue;
            }
            if (!$entity instanceof DataInterface) {
                throw new \InvalidArgumentException(self::E_MSG);
            }
            $entitiesByValueClassByIds[$entity->getFamily()->getValueClass()][$entity->getId()] = $entity;
        }

        return $entitiesByValueClassByIds;
    }
269806
public function setParentClassNames(array $classNames)
    {
        $this->parentClassNames = $classNames;

        if (count($classNames) > 0) {
            $this->rootDocumentName = array_pop($classNames);
        }
    }
154041
private function classGetter($className, $types)
    {
        if (!class_exists($className)) {
            return;
        }

        $obj = $this->get($className);

        foreach ($types as $type) {
            if ($obj instanceof $type) {
                return $obj;
            }
        }
    }
25848
protected function _findClasses($class_names)
    {
        if (!is_array($class_names)) {
            $class_names = array($class_names);
        }
        foreach ($class_names as $_cls) {
            if (true===class_exists($_cls)) {
                return $_cls;
            }
        }
        return false;
    }
929766
private function getCustomSortingNames(string $className): array
    {
        $this->fillCache($className);

        return array_keys($this->customSortings[$className]);
    }
1160000
public function setParentClasses(array $classNames)
    {
        $this->parentClasses = $classNames;
        if (count($classNames) > 0) {
            $this->rootEntityName = array_pop($classNames);
        }
    }
183906
protected function getClasses()
    {
        $class = $this->argument('class');

        // set classes
        if ($class) {
            if (class_exists($class)) {
                $classes = [$class];
            } elseif (class_exists($this->config['models_namespace'] . '\\' . $class)) {
                $classes = [$this->config['models_namespace'] . '\\' . $class];
            } else {
                throw new UnexpectedValueException('Classname is not valid.');
            }
        } else {
            $classes = $this->finder->getClassesFromNamespace($this->config['models_namespace']);
        }

        return $classes;
    }
397283
public function getDiscriminators($exclude = array())
    {

        // prefilter discriminators by subclasses
        $subclasses = $this->meta->subClasses;

        $discriminators = array_filter(
            $this->meta->discriminatorMap,
            function($class) use ($subclasses)
            {
                return in_array($class, $subclasses);
            }
        );


        // filter discriminators by exlude array
        return array_diff(array_keys($discriminators), $exclude);
    }
1203593
public function getAuthenticateData(array $registrations)
    {
        $sigs = array();
        $challenge = $this->createChallenge();
        foreach ($registrations as $reg) {
            if( !is_object( $reg ) ) {
                throw new \InvalidArgumentException('$registrations of getAuthenticateData() method only accepts array of object.');
            }
            /** @var Registration $reg */

            $sig = new SignRequest();
            $sig->appId = $this->appId;
            $sig->keyHandle = $reg->keyHandle;
            $sig->challenge = $challenge;
            $sigs[] = $sig;
        }
        return $sigs;
    }
20405
public static function setAdapterClasses(array $fullyQualifiedClassNames)
    {
        $rememberClasses = self::$adapterClasses;

        self::$adapterClasses = [];
        foreach ($fullyQualifiedClassNames as $className) {
            if (is_string($className)) {
                self::$adapterClasses[] = $className;
            } else {
                // Reset to previous value on error
                self::$adapterClasses = $rememberClasses;

                throw new InvalidArgumentException(
                    "A value in the class name array is of type '" . gettype($className) . "'. String expected."
                );
            }
        }
    }
658840
public function hasDiscriminatorValue($className)
    {
        if (array_key_exists($className, $this->discriminatorValueMap)) {
            return false !== $this->discriminatorValueMap[$className];
        }
        $this->discriminatorValueMap[$className] = $this->buildDiscriminatorValueMap($className);

        return $this->discriminatorValueMap[$className];
    }
246968
public function getFirstElementOfType($classnames)
    {
        if (!is_array($classnames)) {
            $classnames = array($classnames);
        }

        foreach (array_keys($this->_data) as $key) {
            $element = $this->getData($key);

            if (!is_object($element)) {
                continue;
            }

            foreach ($classnames as $classname) {
                if (is_a($element, $classname)) {
                    return $element;
                }
            }
        }
    }