Your project must not contain invalid function or method calls 18
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_call
- }
- try {
- if (\interface_exists(TranslatableInterface::class) && $entity instanceof TranslatableInterface && $locale) {
- $translatedEntity = $entity->translate($locale, false);
- if (method_exists($translatedEntity, $setterName)) {
- $translatedEntity->$setterName($value);
- } else {
- $translatedEntity->$propertyName = $value;
- }
- } elseif (!$locale) {
- }
- protected function dispatchEvents(): void
- {
- foreach ($this->updatedEntities as $entity) {
- $identifierValues = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
- $this->eventDispatcher->dispatch(
- new RecordImportedSuccessfullyEvent($this->getEntityClassName(), (string) \reset($identifierValues)),
- );
- }
- }
- private function parseValueForArrayType(FormFieldDefinition $fieldDefinition, ?string $value): array
- {
- return $value
- ? explode($fieldDefinition->getOptions()['separator'] ?? ArrayTextType::DEFAULT_SEPARATOR, $value)
- : [];
- }
- }
- }
- #[Assert\Callback]
- public function validateExtensions(ExecutionContextInterface $context): void
- {
- $extensions = array_map(strtolower(...), $this->allowedExtensions);
- if (!in_array(strtolower($this->file->getClientOriginalExtension()), $extensions, true)) {
- $context->buildViolation('validation.file.extension', ['%extensions' => implode(', ', $extensions)])->addViolation();
- }
- }
- }
- #[Assert\Callback]
- public function validateExtensions(ExecutionContextInterface $context): void
- {
- $extensions = array_map(strtolower(...), $this->allowedExtensions);
- if (!in_array(strtolower($this->file->getClientOriginalExtension()), $extensions, true)) {
- $context->buildViolation('validation.file.extension', ['%extensions' => implode(', ', $extensions)])->addViolation();
- }
- }
- }
- public function __construct(array $header = [], array $recordsData = [])
- {
- $this->header = $this->clearHeader($header);
- foreach ($recordsData as $data) {
- $clearedData = $this->clearRecordData($data);
- if ($clearedData) {
- $this->records[] = new MatrixRecord($clearedData, $this->getEntityIdValue($data));
- }
- }
- }
- $this->header = $this->clearHeader($header);
- foreach ($recordsData as $data) {
- $clearedData = $this->clearRecordData($data);
- if ($clearedData) {
- $this->records[] = new MatrixRecord($clearedData, $this->getEntityIdValue($data));
- }
- }
- }
- public function getHeader(): array
- {
- $info = [];
- $checker = new PropertyExistenceChecker($className);
- foreach ($this->header as $name) {
- $info[$name] = $checker->propertyExists($name);
- }
- return $info;
- }
- }
- private function clearHeader(array $header): array
- {
- $header = array_values(
- array_filter($header, $this->isColumnNameValid(...)),
- );
- return \array_map(static fn (string $name): string => \str_replace(' ', '_', $name), $header);
- }
- {
- $header = array_values(
- array_filter($header, $this->isColumnNameValid(...)),
- );
- return \array_map(static fn (string $name): string => \str_replace(' ', '_', $name), $header);
- }
- private function clearRecordData(array $data): array
- {
- return array_filter($data, $this->isColumnNameValid(...), ARRAY_FILTER_USE_KEY);
- $reader = self::getReader($file);
- $spreadsheet = $reader->load($file->getPathname());
- $data = $spreadsheet->getActiveSheet()->toArray();
- $header = array_shift($data);
- self::addKeysToRows($header, $data);
- return new Matrix($header, $data);
- }
- public static function createFromPostData(array $data): Matrix
- return new Matrix($header, $data);
- }
- public static function createFromPostData(array $data): Matrix
- {
- return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();
- }
- private static function addKeysToRows(array $header, array &$data): void
- {
- array_walk(
- private static function addKeysToRows(array $header, array &$data): void
- {
- array_walk(
- $data,
- static function (array &$row) use ($header): void {
- $row = array_combine($header, $row);
- },
- );
- }
- private static function addKeysToRows(array $header, array &$data): void
- {
- array_walk(
- $data,
- static function (array &$row) use ($header): void {
- $row = array_combine($header, $row);
- },
- );
- }
- private static function getReader(UploadedFile $file): BaseReader
- foreach ($delimiters as $delimiter) {
- $delimiterCount[$delimiter] = substr_count($csvContent, (string) $delimiter);
- }
- return array_search(max($delimiterCount), $delimiterCount, true);
- }
- }
- */
- public function __construct(string $entityClass)
- {
- $this->reflectionClass = new ReflectionClass($entityClass);
- if (\interface_exists(TranslatableInterface::class) && is_subclass_of($entityClass, TranslatableInterface::class)) {
- $this->translationReflectionClass = new ReflectionClass($this->reflectionClass->newInstanceWithoutConstructor()->translate());
- }
- }
- public function propertyExists(string $name): bool
- {
- }
- private function getHashedMatrixRecordsDataForDuplicationCheck(array $records, array $fieldsUsedInDuplicationCheck): array
- {
- return array_map(
- fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),
- $records
- );
- }
- private function getMatrixRecordDataForDuplicationCheck(MatrixRecord $matrixRecord, array $fieldsUsedInDuplicationCheck): array
- );
- }
- private function getMatrixRecordDataForDuplicationCheck(MatrixRecord $matrixRecord, array $fieldsUsedInDuplicationCheck): array
- {
- return array_intersect_key($matrixRecord->getData(), array_flip($fieldsUsedInDuplicationCheck));
- }
- }
Your project should not use invalid parameter and return typehints 32
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_typehint
- }
- $this->save();
- }
- protected function prepareRecord(MatrixRecord $record, array $headerInfo): void
- {
- $entity = $this->getEntity($record);
- $data = $record->getData();
- $fieldDefinitions = $this->getFieldsDefinitions();
- {
- #[Assert\File]
- #[Assert\NotNull]
- private ?UploadedFile $file = null;
- public function __construct(private readonly array $allowedExtensions = [])
- {
- }
- public function getFile(): ?UploadedFile
- {
- new Assert\Type(MatrixRecord::class),
- ])]
- #[Assert\NotBlank]
- private array $records = [];
- public function __construct(array $header = [], array $recordsData = [])
- {
- $this->header = $this->clearHeader($header);
- foreach ($recordsData as $data) {
- $clearedData = $this->clearRecordData($data);
- new Assert\Type(MatrixRecord::class),
- ])]
- #[Assert\NotBlank]
- private array $records = [];
- public function __construct(array $header = [], array $recordsData = [])
- {
- $this->header = $this->clearHeader($header);
- foreach ($recordsData as $data) {
- $clearedData = $this->clearRecordData($data);
- }
- return $info;
- }
- private function getEntityIdValue(array $data): int|string|null
- {
- foreach ($data as $name => $value) {
- if (self::RESERVED_ENTITY_ID_COLUMN_NAME === $name) {
- return $value;
- }
- }
- return null;
- }
- private function clearHeader(array $header): array
- {
- $header = array_values(
- array_filter($header, $this->isColumnNameValid(...)),
- );
- );
- return \array_map(static fn (string $name): string => \str_replace(' ', '_', $name), $header);
- }
- private function clearRecordData(array $data): array
- {
- return array_filter($data, $this->isColumnNameValid(...), ARRAY_FILTER_USE_KEY);
- }
- private function isColumnNameValid(?string $name): bool
- self::addKeysToRows($header, $data);
- return new Matrix($header, $data);
- }
- public static function createFromPostData(array $data): Matrix
- {
- return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();
- }
- private static function addKeysToRows(array $header, array &$data): void
- public static function createFromPostData(array $data): Matrix
- {
- return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();
- }
- private static function addKeysToRows(array $header, array &$data): void
- {
- array_walk(
- $data,
- static function (array &$row) use ($header): void {
- $row = array_combine($header, $row);
- public static function createFromPostData(array $data): Matrix
- {
- return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();
- }
- private static function addKeysToRows(array $header, array &$data): void
- {
- array_walk(
- $data,
- static function (array &$row) use ($header): void {
- $row = array_combine($header, $row);
- private function translationPropertyExists(string $name): bool
- {
- return $this->translationReflectionClass instanceof ReflectionClass && $this->isPropertyWritable($this->translationReflectionClass, $name);
- }
- private function isPropertyWritable(ReflectionClass $entity, string $name): bool
- {
- $setterName = ColumnNameHelper::getSetterName($name);
- return ($entity->hasProperty($name) && $entity->getProperty($name)->isPublic())
- || ($entity->hasMethod($setterName) && $entity->getMethod($setterName)->isPublic());
- }
- parent::validateArguments($value, $constraint);
- }
- private function getHashedMatrixRecordsDataForDuplicationCheck(array $records, array $fieldsUsedInDuplicationCheck): array
- {
- return array_map(
- fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),
- $records
- );
- }
- parent::validateArguments($value, $constraint);
- }
- private function getHashedMatrixRecordsDataForDuplicationCheck(array $records, array $fieldsUsedInDuplicationCheck): array
- {
- return array_map(
- fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),
- $records
- );
- fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),
- $records
- );
- }
- private function getMatrixRecordDataForDuplicationCheck(MatrixRecord $matrixRecord, array $fieldsUsedInDuplicationCheck): array
- {
- return array_intersect_key($matrixRecord->getData(), array_flip($fieldsUsedInDuplicationCheck));
- }
- }
- }
- parent::validateArguments($value, $constraint);
- }
- private function getMatrixRecordDataToCompare(MatrixRecord $matrixRecord, array $fields): array
- {
- $data = [];
- foreach ($fields as $field) {
- $data[$field] = $matrixRecord->$field;
- }
- }
- return $data;
- }
- private function isDuplicate(array $matrixDataToCompare): bool
- {
- return array_key_exists($this->getHash($matrixDataToCompare), $this->duplicatedRecords);
- }
- private function isCorrectRecord(array $matrixDataToCompare): bool
- private function isDuplicate(array $matrixDataToCompare): bool
- {
- return array_key_exists($this->getHash($matrixDataToCompare), $this->duplicatedRecords);
- }
- private function isCorrectRecord(array $matrixDataToCompare): bool
- {
- return array_key_exists($this->getHash($matrixDataToCompare), $this->correctRecords);
- }
- private function addDuplicate(array $matrixDataToCompare): void
- private function isCorrectRecord(array $matrixDataToCompare): bool
- {
- return array_key_exists($this->getHash($matrixDataToCompare), $this->correctRecords);
- }
- private function addDuplicate(array $matrixDataToCompare): void
- {
- $this->duplicatedRecords[$this->getHash($matrixDataToCompare)] = true;
- }
- private function markAsCorrectRecord(array $matrixDataToCompare): void
- private function addDuplicate(array $matrixDataToCompare): void
- {
- $this->duplicatedRecords[$this->getHash($matrixDataToCompare)] = true;
- }
- private function markAsCorrectRecord(array $matrixDataToCompare): void
- {
- $this->correctRecords[$this->getHash($matrixDataToCompare)] = true;
- }
- private function buildCriteria(MatrixRecord $matrixRecord, array $matrixDataToCompare): array
- private function markAsCorrectRecord(array $matrixDataToCompare): void
- {
- $this->correctRecords[$this->getHash($matrixDataToCompare)] = true;
- }
- private function buildCriteria(MatrixRecord $matrixRecord, array $matrixDataToCompare): array
- {
- $criteria = [];
- foreach ($matrixDataToCompare as $fieldName => $value) {
- $criteria[ColumnNameHelper::toCamelCase($fieldName)][] = ['=', $value];
- }
- }
- return $criteria;
- }
- private function addCriteriaToOmitEntity(array &$criteria, object $entityToOverride): void
- {
- $primaryKeyData = $this->entityManager->getUnitOfWork()->getEntityIdentifier($entityToOverride);
- foreach ($primaryKeyData as $primaryKeyName => $primaryValue) {
- $criteria[$primaryKeyName][] = ['!=', $primaryValue];
- foreach ($primaryKeyData as $primaryKeyName => $primaryValue) {
- $criteria[$primaryKeyName][] = ['!=', $primaryValue];
- }
- }
- private function isRecordDuplicatedInDatabase(EntityManagerInterface $em, string $class, array $criteria): bool
- {
- $query = $em->createQuery($this->buildDQL($class, $criteria));
- $this->passParametersToQuery($query, $criteria);
- return !empty($query->getArrayResult());
- $this->passParametersToQuery($query, $criteria);
- return !empty($query->getArrayResult());
- }
- private function buildDQL(string $class, array $criteria): string
- {
- $sql = /* @lang DQL */
- "SELECT c FROM $class c";
- $nmb = 0;
- }
- return $sql;
- }
- private function passParametersToQuery(AbstractQuery $query, array $criteria): void
- {
- $nmb = 0;
- foreach ($criteria as $data) {
- foreach ($data as [$operator, $value]) {
- $query->setParameter('param_' . $nmb++, $value);
- use Twig\TwigFunction;
- use UnexpectedValueException;
- class TemplateExtension extends AbstractExtension
- {
- public function __construct(private readonly array $availableTemplates = [])
- {
- }
- public function getFunctions(): array
- {
- $container
- ->registerForAutoconfiguration(ImportConfigurationAutoInjectInterface::class)
- ->addTag('batch_entity_import.controller');
- }
- private function setParameters(array $configs, ContainerBuilder $container): void
- {
- $processor = new Processor();
- $configuration = new Configuration();
- $config = $processor->processConfiguration($configuration, $configs);
- $this->addTemplatesConfig($rootNode->children());
- return $treeBuilder;
- }
- private function addTemplatesConfig(NodeBuilder $parentBuilder): void
- {
- $builder = $parentBuilder->arrayNode('templates')->addDefaultsIfNotSet()->children();
- $this->addNodeConfig($builder, 'select_file', '@BatchEntityImport/select_file.html.twig');
- $this->addNodeConfig($builder, 'edit_matrix', '@BatchEntityImport/edit_matrix.html.twig');
- $this->addNodeConfig($builder, 'select_file', '@BatchEntityImport/select_file.html.twig');
- $this->addNodeConfig($builder, 'edit_matrix', '@BatchEntityImport/edit_matrix.html.twig');
- $this->addNodeConfig($builder, 'layout', '@BatchEntityImport/layout.html.twig');
- }
- private function addNodeConfig(NodeBuilder $builder, string $name, string $value): void
- {
- $builder
- ->scalarNode($name)
- ->defaultValue($value)
- ->cannotBeEmpty()
- namespace JG\BatchEntityImportBundle\Model\Form;
- class FormFieldDefinition
- {
- public function __construct(private readonly string $class, private readonly array $options = [])
- {
- }
- public function getClass(): string
- {
- class MatrixRecord
- {
- private ?object $entity = null;
- private array $data = [];
- public function __construct(array $data = [], public readonly int|string|null $entityId = null)
- {
- foreach ($data as $name => $value) {
- if (!empty(\trim((string) $name))) {
- $this->data[\str_replace(' ', '_', (string) $name)] = $value;
- }
- protected function prepareContext(): void
- {
- $this->context->setNode($this->context->getValue(), $this->context->getObject(), $this->context->getMetadata(), '');
- }
- protected function addErrorToMatrixRecord(MatrixRecord $record, MatrixRecordUnique|DatabaseEntityUnique $constraint, int $index, array $fields): void
- {
- $this->context
- ->buildViolation($constraint->message, ['%fields%' => implode(', ', $fields)])
- ->atPath("children[records][$index][{$constraint->fields[0]}]")
- ->setInvalidValue($record)
- ->atPath("children[records][$index][{$constraint->fields[0]}]")
- ->setInvalidValue($record)
- ->addViolation();
- }
- protected function getHash(array $data): string
- {
- return md5(implode('--', $data));
- }
- }
Your project should use return types 19
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.missing_return_typehint
- public function getEntityTranslationRelationName(): ?string
- {
- return null;
- }
- public function getMatrixConstraints(): array
- {
- return [];
- }
- public function import(Matrix $matrix): void
- public function allowOverrideEntity(): bool
- {
- return true;
- }
- public function getAllowedFileExtensions(): array
- {
- return ['csv', 'xls', 'xlsx', 'ods'];
- }
- private function parseValueForArrayType(FormFieldDefinition $fieldDefinition, ?string $value): array
- public function getAllowedFileExtensions(): array
- {
- return ['csv', 'xls', 'xlsx', 'ods'];
- }
- private function parseValueForArrayType(FormFieldDefinition $fieldDefinition, ?string $value): array
- {
- return $value
- ? explode($fieldDefinition->getOptions()['separator'] ?? ArrayTextType::DEFAULT_SEPARATOR, $value)
- : [];
- }
- $this->records[] = new MatrixRecord($clearedData, $this->getEntityIdValue($data));
- }
- }
- }
- public function getHeader(): array
- {
- return $this->header;
- }
- /**
- public function getRecords(): array
- {
- return $this->records;
- }
- public function getHeaderInfo(string $className): array
- {
- $info = [];
- $checker = new PropertyExistenceChecker($className);
- foreach ($this->header as $name) {
- }
- return null;
- }
- private function clearHeader(array $header): array
- {
- $header = array_values(
- array_filter($header, $this->isColumnNameValid(...)),
- );
- );
- return \array_map(static fn (string $name): string => \str_replace(' ', '_', $name), $header);
- }
- private function clearRecordData(array $data): array
- {
- return array_filter($data, $this->isColumnNameValid(...), ARRAY_FILTER_USE_KEY);
- }
- private function isColumnNameValid(?string $name): bool
- }
- parent::validateArguments($value, $constraint);
- }
- private function getHashedMatrixRecordsDataForDuplicationCheck(array $records, array $fieldsUsedInDuplicationCheck): array
- {
- return array_map(
- fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),
- $records
- );
- fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),
- $records
- );
- }
- private function getMatrixRecordDataForDuplicationCheck(MatrixRecord $matrixRecord, array $fieldsUsedInDuplicationCheck): array
- {
- return array_intersect_key($matrixRecord->getData(), array_flip($fieldsUsedInDuplicationCheck));
- }
- }
- }
- parent::validateArguments($value, $constraint);
- }
- private function getMatrixRecordDataToCompare(MatrixRecord $matrixRecord, array $fields): array
- {
- $data = [];
- foreach ($fields as $field) {
- $data[$field] = $matrixRecord->$field;
- }
- private function markAsCorrectRecord(array $matrixDataToCompare): void
- {
- $this->correctRecords[$this->getHash($matrixDataToCompare)] = true;
- }
- private function buildCriteria(MatrixRecord $matrixRecord, array $matrixDataToCompare): array
- {
- $criteria = [];
- foreach ($matrixDataToCompare as $fieldName => $value) {
- $criteria[ColumnNameHelper::toCamelCase($fieldName)][] = ['=', $value];
- }
- public function getClass(): string
- {
- return $this->class;
- }
- public function getOptions(): array
- {
- return $this->options;
- }
- }
- public function setEntity(?object $entity): void
- {
- $this->entity = $entity;
- }
- public function getData(): array
- {
- return $this->data;
- }
- public function __isset(string $name): bool
- enum CsvDelimiterEnum: string
- {
- case SEMICOLON = ';';
- case COMMA = ',';
- public static function asValues(): array
- {
- return [
- self::SEMICOLON->value,
- self::COMMA->value,
- ];
- }
- return implode($this->separator, $value);
- }
- public function reverseTransform(mixed $value): array
- {
- if (!is_string($value)) {
- throw new UnexpectedValueException('Only strings are allowed');
- }
- public function getEntityTranslationRelationName(): ?string;
- /**
- * Use this method to pass constraints to the main Matrix form.
- */
- public function getMatrixConstraints(): array;
- /**
- * Use this method to set allowed file extensions.
- */
- public function getAllowedFileExtensions(): array;
- public function getMatrixConstraints(): array;
- /**
- * Use this method to set allowed file extensions.
- */
- public function getAllowedFileExtensions(): array;
- /**
- * Import data from matrix to database.
- */
- public function import(Matrix $matrix): void;
- public function getDefaultOption(): string
- {
- return 'entityClassName';
- }
- public function getRequiredOptions(): array
- {
- return ['entityClassName', 'fields'];
- }
- }
- public function getDefaultOption(): string
- {
- return 'fields';
- }
- public function getRequiredOptions(): array
- {
- return ['fields'];
- }
- }
Your project should not use invalid return types 4
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_return_typehint
- private function getEntityIdValue(array $data): int|string|null
- {
- foreach ($data as $name => $value) {
- if (self::RESERVED_ENTITY_ID_COLUMN_NAME === $name) {
- return $value;
- }
- }
- return null;
- }
- $reader->setDelimiter($detectedDelimiter->value);
- } elseif ($reader instanceof Xls || $reader instanceof Xlsx) {
- $reader->setIgnoreRowsWithNoCells(true);
- }
- return $reader;
- }
- }
- foreach ($delimiters as $delimiter) {
- $delimiterCount[$delimiter] = substr_count($csvContent, (string) $delimiter);
- }
- return array_search(max($delimiterCount), $delimiterCount, true);
- }
- }
- }
- public function getTemplate(string $name): string
- {
- if (array_key_exists($name, $this->availableTemplates)) {
- return $this->availableTemplates[$name];
- }
- throw new UnexpectedValueException("Template $name not found.");
- }
- }
Your project must not contain invalid instantiations 3
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_instantiation
- $data = $spreadsheet->getActiveSheet()->toArray();
- $header = array_shift($data);
- self::addKeysToRows($header, $data);
- return new Matrix($header, $data);
- }
- public static function createFromPostData(array $data): Matrix
- {
- return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();
- /**
- * @throws ReflectionException
- */
- public function __construct(string $entityClass)
- {
- $this->reflectionClass = new ReflectionClass($entityClass);
- if (\interface_exists(TranslatableInterface::class) && is_subclass_of($entityClass, TranslatableInterface::class)) {
- $this->translationReflectionClass = new ReflectionClass($this->reflectionClass->newInstanceWithoutConstructor()->translate());
- }
- }
- */
- public function __construct(string $entityClass)
- {
- $this->reflectionClass = new ReflectionClass($entityClass);
- if (\interface_exists(TranslatableInterface::class) && is_subclass_of($entityClass, TranslatableInterface::class)) {
- $this->translationReflectionClass = new ReflectionClass($this->reflectionClass->newInstanceWithoutConstructor()->translate());
- }
- }
- public function propertyExists(string $name): bool
- {
Your project should only use iterable types in foreach loops 3
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_foreach_iterable
- {
- /** @var MatrixRecord $entity */
- $entity = $form->getData();
- $selectedValue = $entity->entityId;
- foreach ($view['entity']->vars['choices'] ?? [] as $index => $choice) {
- if ($choice->value === $selectedValue) {
- $view['entity']->vars['choices'][$index]->attr['selected'] = 'selected';
- }
- }
- }
- $sql = /* @lang DQL */
- "SELECT c FROM $class c";
- $nmb = 0;
- foreach ($criteria as $fieldName => $data) {
- foreach ($data as [$operator, $value]) {
- $sql .= $nmb > 0 ? ' AND' : ' WHERE';
- $sql .= " c.$fieldName $operator :param_" . $nmb++;
- }
- }
- private function passParametersToQuery(AbstractQuery $query, array $criteria): void
- {
- $nmb = 0;
- foreach ($criteria as $data) {
- foreach ($data as [$operator, $value]) {
- $query->setParameter('param_' . $nmb++, $value);
- }
- }
- }
- }