Skip to content

Commit

Permalink
Ez enhanced ibexa 4.0 (#90)
Browse files Browse the repository at this point in the history
* * enhanced support to ibexa 4.0
---------

Co-authored-by: mbouchaala <[email protected]>
Co-authored-by: Florian ALEXANDRE <[email protected]>
  • Loading branch information
3 people authored May 12, 2023
1 parent 3664fc9 commit 7cf6b9f
Show file tree
Hide file tree
Showing 45 changed files with 503 additions and 624 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ You can now specify the `alternativeAlias` parameter to define alternative image

```twig
{{ ez_render_field(content, fieldIdentifier, {
{{ ibexa_render_field(content, fieldIdentifier, {
parameters: {
alias: 'desktop_alias',
alternativeAlias: [
{
alias: 'mobile_alias',
media: '(max-width: 320px)'
}
]
lazyLoad: true|false // optionnal
],
lazyLoad: true|false, // optionnal
retina: true|false // optionnal
}
}) }}
Expand Down Expand Up @@ -158,11 +158,11 @@ WHERE oa.data_type_string = "ezimage" AND ca.data_type_string="enhancedimage";
## Usage
Some feature will require the following assets
```twig
<link rel="stylesheet" href="{{ asset("bundles/ezenhancedimageasset/css/enhancedimage.css") }}" />
{{ encore_entry_link_tags('enhancedimage-css', null, 'ibexa') }}
```

```twig
<script src="{{ asset("bundles/ezenhancedimageasset/js/enhancedimage.js") }}"></script>
{{ encore_entry_script_tags('enhancedimage-js', null, 'ibexa') }}
```


Expand Down
2 changes: 1 addition & 1 deletion ci-config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
install: false
install: true
test: false
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"require": {
"php": "^7.3"
"php": "^7.3 || ^8.0"
},
"autoload": {
"psr-4": {
Expand Down
43 changes: 21 additions & 22 deletions src/bundle/Command/ConvertToImageAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
use Exception;
use eZ\Publish\API\Repository\ContentService;
use eZ\Publish\API\Repository\ContentTypeService;
use eZ\Publish\API\Repository\Exceptions\BadStateException;
use eZ\Publish\API\Repository\Exceptions\ContentTypeFieldDefinitionValidationException;
use eZ\Publish\API\Repository\Exceptions\InvalidArgumentException;
use eZ\Publish\API\Repository\Exceptions\NotFoundException as APINotFoundException;
use eZ\Publish\API\Repository\Exceptions\UnauthorizedException;
use eZ\Publish\API\Repository\Repository;
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
use eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft;
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionCreateStruct;
use eZ\Publish\Core\Base\Exceptions\ContentFieldValidationException;
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue;
use eZ\Publish\Core\Base\Exceptions\NotFoundException;
use eZ\Publish\Core\FieldType\ImageAsset\Value as ImageAssetValue;
use Ibexa\Contracts\Core\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\ContentTypeService;
use Ibexa\Contracts\Core\Repository\Exceptions\BadStateException;
use Ibexa\Contracts\Core\Repository\Exceptions\ContentTypeFieldDefinitionValidationException;
use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException;
use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException as APINotFoundException;
use Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException;
use Ibexa\Contracts\Core\Repository\Repository;
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft;
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionCreateStruct;
use Ibexa\Core\Base\Exceptions\ContentFieldValidationException;
use Ibexa\Core\Base\Exceptions\InvalidArgumentValue;
use Ibexa\Core\Base\Exceptions\NotFoundException;
use Ibexa\Core\FieldType\ImageAsset\Value as ImageAssetValue;
use Novactive\EzEnhancedImageAsset\FieldValueConverter\ChainFieldValueConverter;
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -129,8 +129,7 @@ protected function configure(): void
->addArgument(
'field_identifiers',
InputArgument::IS_ARRAY | InputArgument::REQUIRED,
'content_type_identifier/field_identifier',
[]
'content_type_identifier/field_identifier'
);
}

Expand All @@ -151,7 +150,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
$this->repository->sudo(
function () use ($input) {
/** @var array $fieldIdentifiers */
$fieldIdentifiers = $input->getArgument('field_identifiers');
$fieldIdentifiers = (array) $input->getArgument('field_identifiers');
foreach ($fieldIdentifiers as $fieldIdentifier) {
[$contentTypeIdentifier, $fieldIdentifier] = explode('/', $fieldIdentifier);

Expand Down
10 changes: 5 additions & 5 deletions src/bundle/DependencyInjection/EzEnhancedImageAssetExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public function prepend(ContainerBuilder $container): void
);

$configs = [
'field_templates.yml' => 'ezpublish',
'admin_ui_forms.yml' => 'ezpublish',
'image_variations.yml' => 'ezpublish',
'field_templates.yml' => 'ibexa',
'admin_ui_forms.yml' => 'ibexa',
'image_variations.yml' => 'ibexa',
];

foreach ($configs as $fileName => $extensionName) {
Expand All @@ -77,7 +77,7 @@ public function prepend(ContainerBuilder $container): void
$container->addResource(new FileResource($configFile));
}

$configs = $container->getExtensionConfig('ezpublish');
$configs = $container->getExtensionConfig('ibexa');
$newConfig = [];
foreach ($configs as $config) {
if (!isset($config['system'])) {
Expand All @@ -104,6 +104,6 @@ public function prepend(ContainerBuilder $container): void
}
}
}
$container->prependExtensionConfig('ezpublish', $newConfig);
$container->prependExtensionConfig('ibexa', $newConfig);
}
}
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/admin_ui_forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ system:
admin_group:
admin_ui_forms:
content_edit_form_templates:
- { template: '@ezdesign/content/enhanced_image_asset_form_fields.html.twig', priority: 0 }
- { template: '@ibexadesign/content/enhanced_image_asset_form_fields.html.twig', priority: 0 }
9 changes: 5 additions & 4 deletions src/bundle/Resources/config/field_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ system:
default:
fielddefinition_settings_templates:
-
template: "@ezdesign/enhanced_image_asset/fielddefinition_settings.html.twig"
template: "@ibexadesign/content_type/enhanced_image_fielddefinition_settings_templates.html.twig"
fielddefinition_edit_templates:
-
template: "@ezdesign/enhanced_image_asset/fielddefinition_edit_templates.html.twig"
template: "@ibexadesign/content_type/enhanced_image_fielddefinition_edit_templates.html.twig"
site:
field_templates:
-
template: "@ezdesign/enhanced_image_asset/content_fields.html.twig"
template: "@ibexadesign/enhanced_image_content_fields.html.twig"
priority: 1000

admin_group:
field_templates:
-
template: "@ezdesign/enhanced_image_asset/admin_content_fields.html.twig"
template: "@ibexadesign/ui/field_type/preview/enhanced_image_content_fields.html.twig"
priority: 10000
30 changes: 14 additions & 16 deletions src/bundle/Resources/config/fieldtypes.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
services:
Novactive\EzEnhancedImageAsset\FieldType\EnhancedImage\EnhancedImageStorage:
parent: ezpublish.fieldType.ezimage.externalStorage
parent: Ibexa\Core\FieldType\Image\ImageStorage
tags:
- {name: ezplatform.field_type.external_storage_handler, alias: enhancedimage}
- {name: ibexa.field_type.storage.external.handler, alias: enhancedimage}

ezpublish.field_type.indexable.enhancedimage:
parent: ezpublish.fieldType.indexable.ezimage
class: eZ\Publish\Core\FieldType\Image\SearchField
ibexa.field_type.indexable.enhancedimage:
parent: Ibexa\Core\FieldType\Image\SearchField
class: Ibexa\Core\FieldType\Image\SearchField
tags:
- {name: ezplatform.field_type.indexable, alias: enhancedimage}
- {name: ibexa.field_type.indexable, alias: enhancedimage}

ezpublish_rest.field_type_processor.enhancedimage:
parent: ezpublish_rest.field_type_processor.ezimage
ibexa_rest.field_type_processor.enhancedimage:
parent: Ibexa\Rest\FieldTypeProcessor\ImageProcessor
tags:
- { name: ibexa.rest.field_type.processor, alias: enhancedimage }

Novactive\EzEnhancedImageAsset\FieldType\EnhancedImage\Type:
parent: ezpublish.fieldType.ezimage
parent: Ibexa\Core\FieldType\Image\Type
tags:
- {name: ezplatform.field_type, alias: enhancedimage}
- {name: ibexa.field_type, alias: enhancedimage}

Novactive\EzEnhancedImageAsset\FieldType\EnhancedImage\ValueConverter:
parent: ezpublish.fieldType.ezimage.converter
parent: Ibexa\Core\Persistence\Legacy\Content\FieldValue\Converter\ImageConverter
tags:
- {name: ezplatform.field_type.legacy_storage.converter, alias: enhancedimage}

eZ\Publish\Core\FieldType\Image\Type: '@ezpublish.fieldType.ezimage'
- {name: ibexa.field_type.storage.legacy.converter, alias: enhancedimage}

Novactive\EzEnhancedImageAsset\FieldType\EnhancedImage\FormMapper:
autoconfigure: true
autowire: true
tags:
- { name: ezplatform.field_type.form_mapper.definition, fieldType: enhancedimage }
- { name: ezplatform.field_type.form_mapper.value, fieldType: enhancedimage }
- { name: ibexa.admin_ui.field_type.form.mapper.definition, fieldType: enhancedimage }
- { name: ibexa.admin_ui.field_type.form.mapper.value, fieldType: enhancedimage }
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ services:
Novactive\EzEnhancedImageAsset\FieldHandler\EnhancedImage:
arguments:
- "$io.root_dir$"
- "@?ezpublish.core.io.prefix_url_decorator"
- "@?ibexa.core.io.prefix_url_decorator"
tags:
- { name: ez_migration_bundle.complex_field, fieldtype: enhancedimage, priority: 0 }
32 changes: 16 additions & 16 deletions src/bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ services:
public: false

bind:
$imageVariationService: '@ezpublish.fieldType.ezimage.variation_service'
$imageVariationService: '@ibexa.field_type.ezimage.variation_service'
$filterConfiguration: '@liip_imagine.filter.configuration'
$cache: "@ezpublish.cache_pool"
$cache: "@ibexa.cache_pool"
$assetExtension: '@twig.extension.assets'

Novactive\EzEnhancedImageAsset\Twig\:
Expand All @@ -21,11 +21,6 @@ services:

Novactive\EzEnhancedImageAsset\FocusPoint\FocusPointCalculator:

Novactive\EzEnhancedImageAsset\Imagine\Filter\AliasFilterManager:
arguments:
$filterManager: "@liip_imagine.filter.manager"
$filterConfiguration: "@liip_imagine.filter.configuration"

Novactive\EzEnhancedImageAsset\Imagine\Filter\Loader\FocusedThumbnailFilterLoader:
tags:
- {name: 'liip_imagine.filter.loader', loader: 'focusedThumbnail'}
Expand All @@ -43,13 +38,18 @@ services:
- { name: "liip_imagine.filter.loader", loader: 'toFormat' }

Novactive\EzEnhancedImageAsset\Imagine\FocusedImageAliasGenerator:
decorates: 'Ibexa\Bundle\Core\Imagine\Variation\ImagineAwareAliasGenerator'
arguments:
$imageVariationService: '@Novactive\EzEnhancedImageAsset\Imagine\FocusedImageAliasGenerator.inner'

ezpublish.image_alias.imagine.alias_generator:
class: Novactive\EzEnhancedImageAsset\Imagine\ImageAliasGenerator
Novactive\EzEnhancedImageAsset\Imagine\ImageAliasGenerator:
decorates: 'ibexa.image_alias.imagine.alias_generator'
decoration_priority: 10
arguments:
$dataLoader: "@ezpublish.image_alias.imagine.binary_loader"
$ioResolver: "@ezpublish.image_alias.imagine.cache_resolver"
$logger:
$dataLoader: '@Ibexa\Bundle\Core\Imagine\BinaryLoader'
$filterManager: "@liip_imagine.filter.manager"
$ioResolver: '@ibexa.image_alias.imagine.cache_resolver'
$logger: "@?logger"

Novactive\EzEnhancedImageAsset\Imagine\Filter\FilterConfiguration:
decorates: 'liip_imagine.filter.configuration'
Expand All @@ -62,13 +62,13 @@ services:

Novactive\EzEnhancedImageAsset\Imagine\ChainPlaceholderProvider:
arguments:
$providerRegistry: '@ezpublish.image_alias.imagine.placeholder_provider.registry'
$providerRegistry: '@ibexa.image_alias.imagine.placeholder_provider.registry'
tags:
- { name: 'ezpublish.placeholder_provider', type: 'chain_provider' }
- { name: 'ibexa.placeholder_provider', type: 'chain_provider' }

Novactive\EzEnhancedImageAsset\Imagine\PlaceholderProvider\RemoteProvider:
tags:
- { name: 'ezpublish.placeholder_provider', type: 'enhanced_remote' }
- { name: 'ibexa.placeholder_provider', type: 'enhanced_remote' }

Novactive\EzEnhancedImageAsset\Imagine\AliasDirectoryVariationPathGenerator:
decorates: 'ezpublish.image_alias.variation_path_generator.alias_directory'
decorates: Ibexa\Bundle\Core\Imagine\VariationPathGenerator\AliasDirectoryVariationPathGenerator
11 changes: 11 additions & 0 deletions src/bundle/Resources/encore/ibexa.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path');

module.exports = (Encore) => {
Encore
.addEntry('enhancedimage-js', [
path.resolve(__dirname, '../public/js/enhancedimage.js'),
])
.addEntry('enhancedimage-css', [
path.resolve(__dirname, '../public/css/enhancedimage.scss'),
])
};
Loading

0 comments on commit 7cf6b9f

Please sign in to comment.