Возвращает класс для объекта коллекции.
@param ICollection $collection коллекция
@param IObjectType $objectType тип объекта
@return string
552931
private function getObjectClass(ICollection $collection, IObjectType $objectType)
    {
        if (null != ($objectClass = $objectType->getObjectClass())) {
            return $objectClass;
        } elseif ($collection instanceof IHierarchicCollection || $collection instanceof ICommonHierarchy) {
            return $this->defaultHierarchicObjectClass;
        } else {
            return $this->defaultObjectClass;
        }
    }
1332070
public function batchReadByConst(array $objectTypeConsts) {
        $requests = [];

        foreach ($objectTypeConsts as $objectTypeConst) {
            $requests[] = [
                'method' => 'cmdb.object_type_categories.read',
                'params' => [
                    'type' => $objectTypeConst
                ]
            ];
        }

        return $this->api->batchRequest($requests);
    }
1342239
private function forEachChunk(ObjectManager $objectManager, array $entities, $operation)
    {
        $batch = [];
        foreach (array_chunk($entities, $this->configuration['batchSize']) as $chunk) {
            $searchableEntitiesChunk = [];
            foreach ($chunk as $entity) {
                $entityClassName = ClassUtils::getClass($entity);

                $searchableEntitiesChunk[] = new SearchableEntity(
                    $this->getFullIndexName($entityClassName),
                    $entity,
                    $objectManager->getClassMetadata($entityClassName),
                    $this->normalizer,
                    ['useSerializerGroup' => $this->canUseSerializerGroup($entityClassName)]
                );
            }

            $batch[] = $operation($searchableEntitiesChunk);
        }

        return $this->formatBatchResponse($batch);
    }
610216
public function search($objectType, $query = [])
    {
        $results = [];
        if ($this->isSearchable($objectType)) {
            foreach ($this->get($objectType) as $line) {
                foreach ($query as $field => $needle) {
                    if (isset($line[$field])) {
                        if (stripos($line[$field], $needle) !== false) {
                            $results[] = $line;
                        }
                    }
                }
            }
        }

        return new Iterator($results);
    }
238122
protected function getSelectObjectIdentityIdSql(ObjectIdentityInterface $oid)
    {
        $query = <<<QUERY
            SELECT o.id
            FROM %s o
            INNER JOIN %s c ON c.id = o.class_id
            WHERE o.object_identifier = %s AND c.class_type = %s
QUERY;

        return sprintf(
            $query,
            $this->options['oid_table_name'],
            $this->options['class_table_name'],
            $this->connection->quote((string) $oid->getIdentifier()),
            $this->connection->quote((string) $oid->getType())
        );
    }
673703
public function getFieldType($object, $field)
	{
		$metadata  = $this->manager->getClassMetadata(get_class($object));

		if ($metadata->hasField($field)) {
			return $metadata->getTypeOfField($field);
		} else if ($metadata->hasAssociation($field) && $metadata->isSingleValuedAssociation($field)) {
			return self::ASSOCIATION_TO_ONE;
		} else if ($metadata->hasAssociation($field) && $metadata->isCollectionValuedAssociation($field)) {
			return self::ASSOCIATION_TO_MANY;
		}

		return null;
	}
263882
protected function getObjectFromSchema(array $schema, $objectType)
    {
        $objectSchema = null;
        foreach ($schema['objects'] as $ldapObject) {
            if (array_key_exists('type', $ldapObject) && strtolower($ldapObject['type']) == strtolower($objectType)) {
                $objectSchema = $ldapObject;
            }
        }
        if (is_null($objectSchema)) {
            throw new SchemaParserException(sprintf('Cannot find object type "%s" in schema.', $objectType));
        }

        return $objectSchema;
    }
323437
protected function completeObjectValue(
        ObjectType $returnType,
        array $fieldNodes,
        ResolveInfo $info,
        array $path,
        &$result
    ) {
        // If there is an isTypeOfCallback predicate function, call it with the
        // current result. If isTypeOfCallback returns false, then raise an error rather
        // than continuing execution.
        if ($returnType->hasIsTypeOfCallback()) {
            $isTypeOf = $returnType->isTypeOf($result, $this->context->getContextValue(), $info);

            if ($isTypeOf instanceof PromiseInterface) {
                return $isTypeOf->then(function ($resolvedIsTypeOf) use ($returnType, $result, $fieldNodes, $path) {
                    if (true === $resolvedIsTypeOf) {
                        return $this->executeSubFields($returnType, $fieldNodes, $path, $result);
                    }

                    throw new InvalidReturnTypeException($returnType, $result, $fieldNodes);
                });
            }

            if (false === $isTypeOf) {
                throw new InvalidReturnTypeException($returnType, $result, $fieldNodes);
            }
        }

        return $this->executeSubFields($returnType, $fieldNodes, $path, $result);
    }
999971
public static function from(ITypedCollection $collection, callable $objectLoaderCallback) : ILazyCollection
    {
        if (method_exists($collection, 'createLazyCollection')) {
            return $collection->createLazyCollection($objectLoaderCallback);
        }

        if ($collection instanceof EntityCollection) {
            return new LazyEntityCollection($collection->getEntityType(), $objectLoaderCallback);
        }

        if ($collection instanceof EntityIdCollection) {
            return new LazyEntityIdCollection($objectLoaderCallback);
        }

        if ($collection instanceof ValueObjectCollection) {
            return new LazyValueObjectCollection($collection->getObjectType(), $objectLoaderCallback);
        }

        if ($collection instanceof ObjectCollection) {
            return new LazyObjectCollection($collection->getObjectType(), $objectLoaderCallback);
        }

        throw InvalidArgumentException::format(
            'Invalid call to %s: unsupported collection type %s given',
            __METHOD__, get_class($collection)
        );
    }
1212344
public function toCollection($collection, $resultSetType = null)
    {
        $resultSetType = $resultSetType ?: $this->resultSetType;

        if ($resultSetType && false !== strpos($resultSetType, '\\')) {
            $collection = new $resultSetType($collection);
        } else {
            $collection = new ModelCollection($collection);
        }

        return $collection;
    }
1186752
public function joinTablesOnCollectionByType($collection, $type)
    {
        if ($type == \Dotdigitalgroup\Email\Model\Rules::ABANDONED) {
            $collection->getSelect()
                ->joinLeft(
                    ['quote_address' => $this->getTable('quote_address')],
                    'main_table.entity_id = quote_address.quote_id',
                    ['shipping_method', 'country_id', 'city', 'region_id']
                )->joinLeft(
                    ['quote_payment' => $this->getTable('quote_payment')],
                    'main_table.entity_id = quote_payment.quote_id',
                    ['method']
                )->where('address_type = ?', 'shipping');
        } elseif ($type == \Dotdigitalgroup\Email\Model\Rules::REVIEW) {
            $collection->getSelect()
                ->join(
                    ['order_address' => $this->getTable('sales_order_address')],
                    'main_table.entity_id = order_address.parent_id',
                    ['country_id', 'city', 'region_id']
                )->join(
                    ['order_payment' => $this->getTable('sales_order_payment')],
                    'main_table.entity_id = order_payment.parent_id',
                    ['method']
                )->where('order_address.address_type = ?', 'shipping');
        }

        return $collection;
    }
241713
public function createManyToManySelector(
        IObject $object,
        ManyToManyRelationField $manyToManyRelationField,
        ICollection $targetCollection
    )
    {
        $manyToManyObjectSet = $this->objectSetFactory->createManyToManyObjectSet($object, $manyToManyRelationField);

        return $this->getSelectorInstance($targetCollection, $manyToManyObjectSet);
    }
680113
private function getObjectTitle($type, $objectId)
    {
        $objectModel = $this->getObjectModel($type);
        $objectModel->load($objectId);

        $fieldName = $this->getObjectTitleFieldName($type);
        $field = $objectModel->$fieldName;

        return $field->value;
    }
587676
private function getPhpType(string $doctrineType): ?string
    {
        switch ($doctrineType) {
            case MongoDbType::INTEGER:
            case MongoDbType::INT:
            case MongoDbType::INTID:
            case MongoDbType::KEY:
                return Type::BUILTIN_TYPE_INT;
            case MongoDbType::FLOAT:
                return Type::BUILTIN_TYPE_FLOAT;
            case MongoDbType::STRING:
            case MongoDbType::ID:
            case MongoDbType::OBJECTID:
            case MongoDbType::TIMESTAMP:
            case MongoDbType::BINDATA:
            case MongoDbType::BINDATABYTEARRAY:
            case MongoDbType::BINDATACUSTOM:
            case MongoDbType::BINDATAFUNC:
            case MongoDbType::BINDATAMD5:
            case MongoDbType::BINDATAUUID:
            case MongoDbType::BINDATAUUIDRFC4122:
                return Type::BUILTIN_TYPE_STRING;
            case MongoDbType::BOOLEAN:
            case MongoDbType::BOOL:
                return Type::BUILTIN_TYPE_BOOL;
        }

        return null;
    }
1301692
final public function getObjectsListCount($objectType, $properties = array(), $objectURI = NULL, $objectId = NULL)
    {
        if (empty($properties)):
            if (!empty($this->propertyModel))
                $properties = array_keys($this->propertyModel);
        endif;
        $query = $this->getObjectCountQuery($properties, "?{$this->valueGroup}property_values", $objectId, $objectType, $objectURI);
        //echo($this->withConditions) ;
        $query .= "\nGROUP BY o.object_id";
        $query .= $this->getListLookUpConditionsClause();
        $query .= $this->getListOrderByStatement();
        $cquery = "SELECT COUNT(total_objects) as count FROM ($query) AS total_entities";
        $results = $this->database->prepare($cquery)->execute();
        $count = 0;
        while ($row = $results->fetchAssoc()) {
            $count = $row['count'];
        }
        return $count;
    }
774922
final public function getObjectsList($objectType, $properties = array(), $objectURI = NULL, $objectId = NULL)
    {

        if (empty($properties)):
            if (!empty($this->propertyModel))
                $properties = array_keys($this->propertyModel);
        endif;

        $query = static::getObjectQuery($properties, "?{$this->valueGroup}property_values", NULL, $objectType, $objectURI, $objectId);

        //echo($this->withConditions) ;
        $query .= "\nGROUP BY o.object_id";
        $query .= $this->getListLookUpConditionsClause();
        $query .= $this->getListOrderByStatement();
        $query .= $this->getLimitClause();

        $total = $this->getObjectsListCount($objectType, $properties, $objectURI, $objectId); //Count first
        $results = $this->database->prepare($query)->execute();
        //Could use SQL_CALC_FOUND here but just the same as just using a second query really;
        //$queries = $this->database->getQueryLog();
        $this->resetListLookUpConditions();
        $this->setListTotal($total);

        return $results;
    }
843819
public function readOne($objectType) {
        $result = $this->api->request(
            'cmdb.object_types',
            [
                'filter' => [
                    'id' => $objectType
                ],
                'countobjects' => true
            ]
        );

        return end($result);
    }