Skip to content
Open
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
22 changes: 18 additions & 4 deletions .github/workflows/backend-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ jobs:
php:
- '8.1'
steps:
- uses: actions/create-github-app-token@v2
id: generate_token
with:
app-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
private-key: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
owner: ${{ github.repository_owner }}

- uses: actions/checkout@v4

- name: Setup PHP Action
Expand All @@ -29,11 +36,11 @@ jobs:
- name: Add composer keys for private packagist
run: |
composer config http-basic.updates.ibexa.co $SATIS_NETWORK_KEY $SATIS_NETWORK_TOKEN
composer config github-oauth.github.com $TRAVIS_GITHUB_TOKEN
composer config github-oauth.github.com $GITHUB_TOKEN
env:
SATIS_NETWORK_KEY: ${{ secrets.SATIS_NETWORK_KEY }}
SATIS_NETWORK_TOKEN: ${{ secrets.SATIS_NETWORK_TOKEN }}
TRAVIS_GITHUB_TOKEN: ${{ secrets.TRAVIS_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

- uses: ramsey/composer-install@v3
with:
Expand All @@ -56,6 +63,13 @@ jobs:
- '8.3'

steps:
- uses: actions/create-github-app-token@v2
id: generate_token
with:
app-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
private-key: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
owner: ${{ github.repository_owner }}

- uses: actions/checkout@v4

- name: Setup PHP Action
Expand All @@ -69,11 +83,11 @@ jobs:
- name: Add composer keys for private packagist
run: |
composer config http-basic.updates.ibexa.co $SATIS_NETWORK_KEY $SATIS_NETWORK_TOKEN
composer config github-oauth.github.com $TRAVIS_GITHUB_TOKEN
composer config github-oauth.github.com $GITHUB_TOKEN
env:
SATIS_NETWORK_KEY: ${{ secrets.SATIS_NETWORK_KEY }}
SATIS_NETWORK_TOKEN: ${{ secrets.SATIS_NETWORK_TOKEN }}
TRAVIS_GITHUB_TOKEN: ${{ secrets.TRAVIS_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

- uses: ramsey/composer-install@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/vendor
node_modules/
yarn.lock
/.php_cs.cache
package-lock.json
.phpunit.result.cache
Expand Down
21 changes: 21 additions & 0 deletions ignore-by-php-version.neon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

$includes = [];
if (PHP_VERSION_ID >= 8_00_00) {
$includes[] = __DIR__ . '/ignore-gte-php8.0-errors.neon';
}

if (PHP_VERSION_ID < 7_99_00) {
$includes[] = __DIR__ . '/ignore-php7.4-php.neon';
}

$config = [];
$config['includes'] = $includes;

return $config;
7 changes: 7 additions & 0 deletions ignore-gte-php8.0-errors.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
ignoreErrors:
-
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(mixed\)\: bool\)\|null, Closure\(mixed\)\: array given\.$#'
identifier: argument.type
count: 1
path: src/bundle/DependencyInjection/IbexaAutomatedTranslationExtension.php
7 changes: 7 additions & 0 deletions ignore-php7.4-php.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
ignoreErrors:
-
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(mixed\)\: bool\)\|null, Closure\(mixed\)\: \(array\|null\) given\.$#'
identifier: argument.type
count: 1
path: src/bundle/DependencyInjection/IbexaAutomatedTranslationExtension.php
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "automated-translation",
"repository": "[email protected]:ibexa/automated-translation.git",
"private": true,
"prettier": "eslint-config-ibexa/prettier",
"dependencies": {},
"devDependencies": {
"eslint-config-ibexa": "https://github.com/ibexa/eslint-config-ibexa.git#~v1.1.1"
},
"scripts": {
"test": "yarn prettier-test && yarn eslint-test",
"fix": "yarn prettier-test --write && yarn eslint-test --fix",
"eslint-test": "eslint \"./src/bundle/Resources/**/*.js\"",
"prettier-test": "yarn prettier \"./src/bundle/Resources/**/*.{js,scss}\" --check"
}
}
7 changes: 0 additions & 7 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
parameters:
ignoreErrors:
-
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(mixed\)\: bool\)\|null, Closure\(mixed\)\: \(array\|null\) given\.$#'
identifier: argument.type
count: 1
path: src/bundle/DependencyInjection/IbexaAutomatedTranslationExtension.php

-
message: '#^Access to protected property Ibexa\\AdminUi\\Form\\Data\\ContentTranslationData\:\:\$content\.$#'
identifier: property.protected
Expand Down Expand Up @@ -53,4 +47,3 @@ parameters:
identifier: method.unresolvableReturnType
count: 2
path: tests/lib/EncoderTest.php

2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- ignore-by-php-version.neon.php
- phpstan-baseline.neon

parameters:
level: 8
paths:
- src
- tests

31 changes: 17 additions & 14 deletions src/bundle/Resources/public/admin/js/ibexa-automated-translation.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
((doc) => {
const TRANSLATOR_SELECT_SELECTOR = '#add-translation_translatorAlias';
const BASE_LANGUAGE_SELECT_SELECTOR = '#add-translation_base_language';
const translationModals = doc.querySelectorAll('.ibexa-translation');

const translatorSelect = doc.querySelector(TRANSLATOR_SELECT_SELECTOR);
const baseLanguageSelect = doc.querySelector(BASE_LANGUAGE_SELECT_SELECTOR);
if (baseLanguageSelect && translatorSelect) {
baseLanguageSelect.addEventListener('change', () => {
translatorSelect.disabled = !baseLanguageSelect.value;
translationModals.forEach((modal) => {
const translatorSelect = modal.querySelector('.ibexa-automated-translation-services-container__input');
const baseLanguageSelect = modal.querySelector('.ibexa-translation__language-wrapper--base-language');

const translationSelectWrapper = translatorSelect.closest('.ibexa-dropdown');
if (translationSelectWrapper) {
translationSelectWrapper.classList.toggle('ibexa-dropdown--disabled', !baseLanguageSelect.value);
}
});
}
}) (document);
if (baseLanguageSelect && translatorSelect) {
baseLanguageSelect.addEventListener('change', () => {
translatorSelect.disabled = !baseLanguageSelect.value;

const translationSelectWrapper = translatorSelect.closest('.ibexa-dropdown');

if (translationSelectWrapper) {
translationSelectWrapper.classList.toggle('ibexa-dropdown--disabled', !baseLanguageSelect.value);
}
});
}
});
})(document);
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
<label class="ibexa-label form-label">
{{ 'tab.translations.remote.translation.service'|trans()|desc('Use automatic translation') }}
</label>
{{ form_widget(form.translatorAlias) }}
{{ form_widget(form.translatorAlias, { attr: { class: "ibexa-automated-translation-services-container__input" } }) }}
{% else %}
{# that is a checkbox - then one provider #}
{{ form_widget(form.translatorAlias, {
label: 'tab.translations.remote.translation.service.with'|trans({"%alias%": form.translatorAlias.vars.label })|desc('Use automatic translation with %alias%'),
attr: { class: "ibexa-automated-translation-services-container__input" },
}) }}
{% endif %}
</div>
Expand Down
11 changes: 9 additions & 2 deletions src/lib/Encoder/Field/PageBuilderFieldEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public function encode(Field $field): string
$page = $value->getPage();
$blocks = [];

foreach ($page->getBlockIterator() as $block) {
$blockIterable = $page === null ? [] : $page->getBlockIterator();

foreach ($blockIterable as $block) {
$blockDefinition = $this->blockDefinitionFactory->getBlockDefinition($block->getType());
$attrs = [];
$attributes = $blockDefinition->getAttributes();
Expand Down Expand Up @@ -105,7 +107,12 @@ public function decode(string $value, $previousFieldValue): APIValue
);

/** @var \Ibexa\FieldTypePage\FieldType\LandingPage\Value $previousFieldValue */
$page = clone $previousFieldValue->getPage();
$page = $previousFieldValue->getPage();
if ($page === null) {
return new Value();
}

$page = clone $page;
$decodeArray = $encoder->decode($data, XmlEncoder::FORMAT);

if (!is_array($decodeArray)) {
Expand Down
Loading