Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@

namespace App\Query\Criterion\Elasticsearch;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Contracts\Elasticsearch\Query\CriterionVisitor;
use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;

final class CameraManufacturerVisitor implements CriterionVisitor
{
public function supports(Criterion $criterion, LanguageFilter $languageFilter): bool
public function supports(CriterionInterface $criterion, LanguageFilter $languageFilter): bool
{
return $criterion instanceof CameraManufacturerCriterion;
}

public function visit(CriterionVisitor $dispatcher, Criterion $criterion, LanguageFilter $languageFilter): array
public function visit(CriterionVisitor $dispatcher, CriterionInterface $criterion, LanguageFilter $languageFilter): array
{
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion */
return [
'terms' => [
'exif_camera_manufacturer_id' => (array)$criterion->value,
'exif_camera_manufacturer_id' => property_exists($criterion, 'value') ? (array)$criterion->value : [],
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@

namespace App\Query\Criterion\Solr;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Contracts\Solr\Query\CriterionVisitor;

final class CameraManufacturerVisitor extends CriterionVisitor
{
public function canVisit(Criterion $criterion)
public function canVisit(CriterionInterface $criterion)
{
return $criterion instanceof CameraManufacturerCriterion;
}

public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null)
{
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion */
$expressions = array_map(
function ($value): string {
return 'exif_camera_manufacturer_id:"' . $this->escapeQuote((string) $value) . '"';
},
$criterion->value
property_exists($criterion, 'value') ? (array)$criterion->value : []
);

return '(' . implode(' OR ', $expressions) . ')';
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,6 @@ parameters:
count: 1
path: code_samples/search/solr/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php

-
message: "#^Parameter \\#2 \\$array of function array_map expects array, array\\<bool\\|float\\|int\\|string\\>\\|bool\\|float\\|int\\|string given\\.$#"
count: 1
path: code_samples/search/solr/src/Query/Criterion/Solr/CameraManufacturerVisitor.php

-
message: "#^Call to an undefined method Ibexa\\\\FieldTypePage\\\\FieldType\\\\Page\\\\Block\\\\Renderer\\\\RenderRequestInterface\\:\\:getParameters\\(\\)\\.$#"
count: 1
Expand Down
15 changes: 13 additions & 2 deletions tools/code_samples/code_samples_usage.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ function getBlockContents(array $block): array
$rawBlockCodeLines = [];
$oneBasedBlockCodeLines = [];
$includedFilesLines = [];
foreach ($block as $blockSourceLine) {
$skip = false;
foreach ($block as $blockSourceLineIndex => $blockSourceLine) {
if (preg_match('@```.* hl_lines="([^"]+)"@', $blockSourceLine, $matches)) {
$rawHighlightedLines = explode(' ', $matches[1]);
foreach ($rawHighlightedLines as $rawHighlightedLine) {
Expand Down Expand Up @@ -171,7 +172,17 @@ function getBlockContents(array $block): array
$solvedLine = str_replace($matchString, implode(PHP_EOL . $matches['glue'][$matchIndex], $sample) . PHP_EOL, $solvedLine);
}
$rawBlockCodeLines = array_merge($rawBlockCodeLines, explode(PHP_EOL, $solvedLine));
} elseif (!str_contains($blockSourceLine, '```')) {
} elseif (str_contains($blockSourceLine, '--8<--')) {
if (!$skip) {
$includedFilePath = trim($block[$blockSourceLineIndex+1]);
$includedFilesLines[$includedFilePath] = file($includedFilePath, FILE_IGNORE_NEW_LINES);
if (!is_array($includedFilesLines[$includedFilePath])) {
throw new RuntimeException("The following included file can't be opened: $includedFilePath");
}
$rawBlockCodeLines = array_merge($rawBlockCodeLines, $includedFilesLines[$includedFilePath]);
}
$skip = !$skip;
} elseif (!str_contains($blockSourceLine, '```') && !$skip) {
$rawBlockCodeLines[] = $blockSourceLine;
}
}
Expand Down
Loading