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

IBX-2335: Changes after rebranding review #3

Merged
merged 5 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/vendor
/.php_cs.cache
package-lock.json
.DS_Store
.phpunit.result.cache
.php-cs-fixer.cache
composer.lock
17 changes: 2 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
# Ibexa Automated Translation Bundle
# Ibexa Automated Translation

## Features

[Features](src/bundle/Resources/doc/FEATURES.md)

## Usage and installation instructions

[Usage](src/bundle/Resources/doc/USAGE.md)

[Installation](src/bundle/Resources/doc/INSTALL.md)

Changelog
------------------

[Changelog](src/bundle/Resources/doc/CHANGELOG.md)
Learn more about [Ibexa DXP](https://www.ibexa.co/products).

## COPYRIGHT
Copyright (C) 1999-2021 Ibexa AS (formerly eZ Systems AS). All rights reserved.
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@
},
"autoload": {
"psr-4": {
"EzSystems\\EzPlatformAutomatedTranslation\\": "lib",
"EzSystems\\EzPlatformAutomatedTranslationBundle\\": "bundle",
"Ibexa\\AutomatedTranslation\\": "src/lib/",
"Ibexa\\Bundle\\AutomatedTranslation\\": "src/bundle/",
"Ibexa\\Contracts\\AutomatedTranslation\\": "src/contracts/"
"Ibexa\\Contracts\\AutomatedTranslation\\": "src/contracts/",
"EzSystems\\EzPlatformAutomatedTranslation\\": "src/lib/",
"EzSystems\\EzPlatformAutomatedTranslationBundle\\": "src/bundle/"
}
},
"autoload-dev": {
"psr-4": {
"EzSystems\\EzPlatformAutomatedTranslation\\Tests\\": "tests/lib/",
"EzSystems\\EzPlatformAutomatedTranslationBundle\\Tests\\": "tests/bundle/",
"Ibexa\\Tests\\AutomatedTranslation\\": "tests/lib/",
"Ibexa\\Tests\\Bundle\\AutomatedTranslation\\": "tests/bundle/"
"Ibexa\\Tests\\Bundle\\AutomatedTranslation\\": "tests/bundle/",
"EzSystems\\EzPlatformAutomatedTranslation\\Tests\\": "tests/lib/",
"EzSystems\\EzPlatformAutomatedTranslationBundle\\Tests\\": "tests/bundle/"
}
},
"scripts": {
Expand Down
52 changes: 52 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
parameters:
ignoreErrors:
-
message: "#^Access to protected property Ibexa\\\\AdminUi\\\\Form\\\\Data\\\\ContentTranslationData\\:\\:\\$content\\.$#"
count: 4
path: src/bundle/Form/Extension/ContentEditType.php

-
message: "#^Call to method getBlockDefinition\\(\\) on an unknown class Ibexa\\\\FieldTypePage\\\\FieldType\\\\Page\\\\Block\\\\Definition\\\\BlockDefinitionFactory\\.$#"
count: 1
path: src/lib/Encoder/Field/PageBuilderFieldEncoder.php

-
message: "#^Call to method getPage\\(\\) on an unknown class Ibexa\\\\FieldTypePage\\\\FieldType\\\\LandingPage\\\\Value\\.$#"
count: 2
path: src/lib/Encoder/Field/PageBuilderFieldEncoder.php

-
message: "#^Instantiated class Ibexa\\\\FieldTypePage\\\\FieldType\\\\LandingPage\\\\Value not found\\.$#"
count: 1
path: src/lib/Encoder/Field/PageBuilderFieldEncoder.php

-
message: "#^Method Ibexa\\\\AutomatedTranslation\\\\Encoder\\\\Field\\\\PageBuilderFieldEncoder\\:\\:decode\\(\\) should return Ibexa\\\\Core\\\\FieldType\\\\Value but returns Ibexa\\\\FieldTypePage\\\\FieldType\\\\LandingPage\\\\Value\\.$#"
count: 1
path: src/lib/Encoder/Field/PageBuilderFieldEncoder.php

-
message: "#^PHPDoc tag @var for variable \\$previousFieldValue contains unknown class Ibexa\\\\FieldTypePage\\\\FieldType\\\\LandingPage\\\\Value\\.$#"
count: 1
path: src/lib/Encoder/Field/PageBuilderFieldEncoder.php

-
message: "#^PHPDoc tag @var for variable \\$value contains unknown class Ibexa\\\\FieldTypePage\\\\FieldType\\\\LandingPage\\\\Value\\.$#"
count: 1
path: src/lib/Encoder/Field/PageBuilderFieldEncoder.php

-
message: "#^Parameter \\$blockDefinitionFactory of method Ibexa\\\\AutomatedTranslation\\\\Encoder\\\\Field\\\\PageBuilderFieldEncoder\\:\\:__construct\\(\\) has invalid type Ibexa\\\\FieldTypePage\\\\FieldType\\\\Page\\\\Block\\\\Definition\\\\BlockDefinitionFactory\\.$#"
count: 1
path: src/lib/Encoder/Field/PageBuilderFieldEncoder.php

-
message: "#^Property Ibexa\\\\AutomatedTranslation\\\\Encoder\\\\Field\\\\PageBuilderFieldEncoder\\:\\:\\$blockDefinitionFactory has unknown class Ibexa\\\\FieldTypePage\\\\FieldType\\\\Page\\\\Block\\\\Definition\\\\BlockDefinitionFactory as its type\\.$#"
count: 1
path: src/lib/Encoder/Field/PageBuilderFieldEncoder.php

-
message: "#^Parameter \\#1 \\$function of function call_user_func_array expects callable\\(\\)\\: mixed, array\\{Ibexa\\\\Bundle\\\\AutomatedTranslation\\\\DependencyInjection\\\\IbexaAutomatedTranslationExtension, mixed\\} given\\.$#"
count: 1
path: tests/bundle/DependencyInjection/IbexaAutomatedTranslationExtensionTest.php

Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

if (empty($config['system'])) {
return;
}

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
// always needed because of Bundle extension.
$loader->load('services_override.yml');
$loader->load('services_override.yaml');

$container->registerForAutoconfiguration(FieldEncoderInterface::class)
->addTag('ibexa.automated_translation.field_encoder');

$container->registerForAutoconfiguration(BlockAttributeEncoderInterface::class)
->addTag('ibexa.automated_translation.block_attribute_encoder');

if (empty($config['system'])) {
return;
}

if (!$this->hasConfiguredClients($config, $container)) {
return;
}

$loader->load('adminui.yml');
$loader->load('default_settings.yml');
$loader->load('services.yml');
$loader->load('admin_ui.yaml');
$loader->load('default_settings.yaml');
$loader->load('services.yaml');

$processor = new ConfigurationProcessor($container, $this->getAlias());
$processor->mapSetting('configurations', $config);
Expand Down
4 changes: 2 additions & 2 deletions src/bundle/Form/Data/TranslationAddData.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class TranslationAddData extends BaseTranslationAddData
/** @var string|bool */
protected $translatorAlias;

/** @return mixed */
/** @return string|bool */
damianz5 marked this conversation as resolved.
Show resolved Hide resolved
public function getTranslatorAlias()
{
return $this->translatorAlias;
}

/** @param mixed $translatorAlias */
/** @param string|bool $translatorAlias */
public function setTranslatorAlias($translatorAlias): void
{
$this->translatorAlias = $translatorAlias;
Expand Down
4 changes: 4 additions & 0 deletions src/bundle/Form/Extension/ContentEditType.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ function (FormEvent $event) {
);
foreach ($data->content->getFieldsByLanguage() as $field) {
$fieldDef = $contentType->getFieldDefinition($field->fieldDefIdentifier);
if (null === $fieldDef) {
continue;
}

$fieldValue = $translatedFields[$fieldDef->identifier] ??
$data->content->getFieldValue($fieldDef->identifier, $fromLanguageCode);
$data->addFieldData(
Expand Down
8 changes: 3 additions & 5 deletions src/bundle/Form/TranslationAddDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ class TranslationAddDataTransformer implements DataTransformerInterface
*
* @return \Ibexa\Bundle\AutomatedTranslation\Form\Data\TranslationAddData
*/
public function transform($value)
public function transform($value): BaseTranslationAddData
{
/* @var BaseTranslationAddData $value */
return new TranslationAddData($value->getLocation(), $value->getLanguage(), $value->getBaseLanguage());
}

/**
* @param mixed $value
*
* @return mixed
* @param \Ibexa\Bundle\AutomatedTranslation\Form\Data\TranslationAddData $value
*/
public function reverseTransform($value)
public function reverseTransform($value): TranslationAddData
{
return $value;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
services:

ibexa.automated_translate.adminui.component.javascripts:
ibexa.automated_translation.adminui.component.javascripts:
parent: Ibexa\AdminUi\Component\TwigComponent
public: false
arguments:
Expand Down
6 changes: 6 additions & 0 deletions src/bundle/Resources/config/default_settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
ibexa.automated_translation.site_access.config.default.configurations: ~
ibexa.automated_translation.site_access.config.default.non_translatable_characters: []
ibexa.automated_translation.site_access.config.default.non_translatable_tags: []
ibexa.automated_translation.site_access.config.default.non_translatable_self_closed_tags: []
ibexa.automated_translation.site_access.config.default.non_valid_attribute_tags: []
6 changes: 0 additions & 6 deletions src/bundle/Resources/config/default_settings.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ services:

_instanceof:
Ibexa\Contracts\AutomatedTranslation\Encoder\Field\FieldEncoderInterface:
tags: [ 'ibexa.automated_translation.field_encoder' ]
tags: [ ibexa.automated_translation.field_encoder ]

Ibexa\Contracts\AutomatedTranslation\Encoder\BlockAttribute\BlockAttributeEncoderInterface:
tags: [ 'ibexa.automated_translation.block_attribute_encoder' ]
tags: [ ibexa.automated_translation.block_attribute_encoder ]

# field encoder
Ibexa\AutomatedTranslation\Encoder\Field\TextLineFieldEncoder: ~
Expand All @@ -26,7 +26,7 @@ services:
# field encoder manager
Ibexa\AutomatedTranslation\Encoder\Field\FieldEncoderManager:
arguments:
$fieldEncoders: !tagged_iterator 'ibexa.automated_translation.field_encoder'
$fieldEncoders: !tagged_iterator ibexa.automated_translation.field_encoder

# block attribute
Ibexa\AutomatedTranslation\Encoder\BlockAttribute\TextBlockAttributeEncoder: ~
Expand All @@ -38,7 +38,7 @@ services:
# block attribute encoder manager
Ibexa\AutomatedTranslation\Encoder\BlockAttribute\BlockAttributeEncoderManager:
arguments:
$blockAttributeEncoders: !tagged_iterator 'ibexa.automated_translation.block_attribute_encoder'
$blockAttributeEncoders: !tagged_iterator ibexa.automated_translation.block_attribute_encoder

# RichText encoder
Ibexa\AutomatedTranslation\Encoder\RichText\RichTextEncoder:
Expand All @@ -53,14 +53,12 @@ services:

Ibexa\AutomatedTranslation\Client\:
resource: '../../../lib/Client'
tags: ['ibexa.automated_translation.client']
tags: [ ibexa.automated_translation.client ]

Ibexa\AutomatedTranslation\ClientProvider:
arguments: [!tagged ibexa.automated_translation.client]

Ibexa\Bundle\AutomatedTranslation\Command\:
resource: '../../Command/*'
tags: ['console.command']
Ibexa\Bundle\AutomatedTranslation\Command\TranslateContentCommand: ~

Ibexa\Bundle\AutomatedTranslation\Form\Extension\TranslationAddType:
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ services:
decorates: Ibexa\Bundle\AdminUi\Controller\TranslationController
autoconfigure: true
autowire: true
tags: ['controller.service_arguments']
tags: ['controller.service_arguments']
4 changes: 0 additions & 4 deletions src/bundle/Resources/doc/CHANGELOG.md

This file was deleted.

18 changes: 0 additions & 18 deletions src/bundle/Resources/doc/FEATURES.md

This file was deleted.

27 changes: 0 additions & 27 deletions src/bundle/Resources/doc/INSTALL.md

This file was deleted.

19 changes: 0 additions & 19 deletions src/bundle/Resources/doc/USAGE.md

This file was deleted.

8 changes: 4 additions & 4 deletions src/lib/Encoder/RichText/RichTextEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ public function __construct(
) {
$tags = $configResolver->getParameter(
'non_translatable_tags',
'ibexa.automated_translation'
'ibexa.automated_translation.site_access.config'
);

$selfClosedTags = $configResolver->getParameter(
'non_translatable_self_closed_tags',
'ibexa.automated_translation'
'ibexa.automated_translation.site_access.config'
);

$chars = $configResolver->getParameter(
'non_translatable_characters',
'ibexa.automated_translation'
'ibexa.automated_translation.site_access.config'
);

$attributes = $configResolver->getParameter(
'non_valid_attribute_tags',
'ibexa.automated_translation'
'ibexa.automated_translation.site_access.config'
);

$this->nonTranslatableTags = ['ezvalue', 'ezconfig', 'ezembed'] + $tags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

class IbexaAutomatedTranslationExtensionTest extends TestCase
{
/**
* @return array{array{array{system: array{default: array{configurations: array{}}}}, bool}}
*/
public function clientConfigurationDataProvider(): array
{
return [
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/Encoder/RichText/RichTextEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public function setUp(): void
->expects($this->atLeastOnce())
->method('getParameter')
->withConsecutive(
[$this->equalTo('non_translatable_tags'), $this->equalTo('ibexa.automated_translation')],
[$this->equalTo('non_translatable_self_closed_tags'), $this->equalTo('ibexa.automated_translation')],
[$this->equalTo('non_translatable_characters'), $this->equalTo('ibexa.automated_translation')],
[$this->equalTo('non_valid_attribute_tags'), $this->equalTo('ibexa.automated_translation')]
[$this->equalTo('non_translatable_tags'), $this->equalTo('ibexa.automated_translation.site_access.config')],
[$this->equalTo('non_translatable_self_closed_tags'), $this->equalTo('ibexa.automated_translation.site_access.config')],
[$this->equalTo('non_translatable_characters'), $this->equalTo('ibexa.automated_translation.site_access.config')],
[$this->equalTo('non_valid_attribute_tags'), $this->equalTo('ibexa.automated_translation.site_access.config')]
)
->willReturnOnConsecutiveCalls([], [], [], []);
}
Expand Down