Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove a static on multiple option expression #14

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/AkeneoBuilderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function getFunctions(): array
new WithReferenceEntitySimpleOption('withReferenceEntitySimpleOption'),
new WithSimpleOption('withSimpleOption'),
new WithMultipleOption('withMultipleOption'),
new WithProductValueMediaFile('withProductValueMediaFile'),
];
}
}
2 changes: 1 addition & 1 deletion src/WithMultipleOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private function compile(string $codes, string $attribute, string $labels, strin
(function() use(\$input) {
\$linkedData = array_map(
function (string \$code) use(\$input) {
static \$labels = {$labels};
\$labels = {$labels};

return [
'attribute' => {$attribute},
Expand Down
44 changes: 44 additions & 0 deletions src/WithProductValueMediaFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\ExpressionLanguage\Akeneo;

use Symfony\Component\ExpressionLanguage\ExpressionFunction;

final class WithProductValueMediaFile extends ExpressionFunction
{
public function __construct($name)
{
parent::__construct(
$name,
$this->compile(...)->bindTo($this),
$this->evaluate(...)->bindTo($this)
);
}

private function compile(string $code, string $attribute, string $locale = 'null', string $scope = 'null'): string
{
return <<<PHP
([
'identifier' => ({$code}),
'attribute' => ({$attribute}),
'locale' => {$locale},
'scope' => {$scope},
])
JoMessina marked this conversation as resolved.
Show resolved Hide resolved
PHP;
}

/**
* @return array<int, string>
*/
private function evaluate(array $context, string $code, string $attribute, string $locale = 'null', string $scope = 'null'): array
{
return [

Check failure on line 37 in src/WithProductValueMediaFile.php

View workflow job for this annotation

GitHub Actions / phpstan5

Method Kiboko\Component\ExpressionLanguage\Akeneo\WithProductValueMediaFile::evaluate() should return array<int, string> but returns array<string, string>.

Check failure on line 37 in src/WithProductValueMediaFile.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\ExpressionLanguage\Akeneo\WithProductValueMediaFile::evaluate() should return array<int, string> but returns array<string, string>.
'identifier' => $code,
'attribute' => $attribute,
'locale' => $locale,
'scope' => $scope,
];
}
}
Loading