filterByFlag example

return $parentDefinition;
    }

    public function isVersionAware(): bool
    {
        return $this->getParentDefinition()->isVersionAware();
    }

    public function hasRequiredField(): bool
    {
        return $this->getFields()
                ->filterByFlag(Required::class)
                ->filter(function DField $field) {
                    return !(
                        $field instanceof FkField
                        || $field instanceof CreatedAtField
                        || $field instanceof UpdatedAtField
                    );
                })
                ->count()
            > 0;
    }

    


    /** * @param array<mixed> $resolved */
    private function addSetNullOnDeletesCommands(WriteCommandQueue $queue, EntityDefinition $definition, WriteContext $writeContext, array $resolved): void
    {
        if ($definition instanceof MappingEntityDefinition) {
            return;
        }

        $setNullFields = $definition->getFields()->filterByFlag(SetNullOnDelete::class);

        $setNulls = $this->foreignKeyResolver->getAffectedSetNulls($definition$resolved$writeContext->getContext());

        foreach ($setNulls as $affectedDefinitionClass => $restrictions) {
            [$entity$field] = explode('.', $affectedDefinitionClass);

            $affectedDefinition = $this->registry->getByEntityName($entity);

            /** @var AssociationField $associationField */
            $associationField = $setNullFields
                ->filter(fn (Field $setNullField) => $setNullField instanceof AssociationField && $setNullField->getReferenceField() === $field)
                
$ranking * $part->getScore() * 0.5
                );
            }
        }

        return $queries;
    }

    private function getQueryFields(EntityDefinition $definition, Context $context): FieldCollection
    {
        /** @var FieldCollection $fields */
        $fields = $definition->getFields()->filterByFlag(SearchRanking::class);

        // exclude read protected fields which are not allowed for the current scope         $fields = $fields->filter(function DField $field) use ($context) {
            /** @var ApiAware|null $flag */
            $flag = $field->getFlag(ApiAware::class);
            if ($flag === null) {
                return false;
            }

            return $flag->isSourceAllowed($context->getSource()::class);
        });

        


    private function escape(string $string): string
    {
        return EntityDefinitionQueryHelper::escape($string);
    }

    private function getAssociationFields(): CompiledFieldCollection
    {
        return $this->definition
            ->getFields()
            ->filterByFlag(RuleAreas::class);
    }

    /** * @return FkField[] */
    private function getForeignKeyFields(EntityDefinition $definition): array
    {
        /** @var FkField[] $fields */
        $fields = $definition->getFields()->filterInstance(FkField::class)->filter(fn (FkField $fk): bool => $fk->getReferenceDefinition()->getEntityName() === $this->definition->getEntityName())->getElements();

        return $fields;
    }


        $this->queryHelper->addIdCondition($criteria$definition$query);

        $table = $definition->getEntityName();

        if (\count($scoreCriteria->getQueries()) > 0) {
            $escapedTable = EntityDefinitionQueryHelper::escape($table);
            $scoreQuery = new QueryBuilder($this->connection);

            $scoreQuery = $this->criteriaQueryBuilder->build($scoreQuery$definition$scoreCriteria$context$paths);
            $pks = $definition->getFields()->filterByFlag(PrimaryKey::class)->map(fn (StorageAware $f) => $f->getStorageName());

            $join = '';
            foreach ($pks as $pk) {
                $scoreQuery->addGroupBy($pk);

                $pk = EntityDefinitionQueryHelper::escape($pk);
                $scoreQuery->addSelect($escapedTable . '.' . $pk);

                $join .= \sprintf('score_table.%s = %s.%s AND ', $pk$escapedTable$pk);
            }

            
Home | Imprint | This part of the site doesn't use cookies.