Skip to content

Commit 320fdc1

Browse files
committed
Implement reviewer comments
1 parent d43bc7c commit 320fdc1

File tree

9 files changed

+15
-46
lines changed

9 files changed

+15
-46
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ tools/php-cs-fixer/vendor
99
node_modules/
1010
.yarn
1111
yarn.lock
12+
get-pip.py

code_samples/back_office/images/config/bundles.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

code_samples/back_office/images/config/services.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ services:
77
- '@ibexa.field_type.ezbinaryfile.io_service'
88
- '@Ibexa\Core\Helper\TranslationHelper'
99

10-
WikimediaCommonsConnector\Handler\WikimediaCommonsHandler:
10+
App\Connector\Dam\Handler\WikimediaCommonsHandler:
1111
arguments:
1212
$httpClient: '@http_client'
1313
tags:
1414
- { name: 'ibexa.platform.connector.dam.handler', source: 'commons' }
1515

16-
WikimediaCommonsConnector\Transformation\TransformationFactory:
16+
App\Connector\Dam\Transformation\TransformationFactory:
1717
arguments:
1818
$httpClient: '@http_client'
1919
tags:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare(strict_types=1);
22

3-
namespace WikimediaCommonsConnector\Handler;
3+
namespace App\Connector\Dam\Handler;
44

55
use Ibexa\Platform\Contracts\Connector\Dam\Asset;
66
use Ibexa\Platform\Contracts\Connector\Dam\AssetCollection;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php declare(strict_types=1);
22

3-
namespace WikimediaCommonsConnector\Transformation;
3+
namespace App\Connector\Dam\Transformation;
44

55
use Ibexa\Platform\Contracts\Connector\Dam\Variation\Transformation;
66
use Ibexa\Platform\Contracts\Connector\Dam\Variation\TransformationFactory as TransformationFactoryInterface;
77

8-
class TransformationFactory implements TransformationFactoryInterface
8+
class WikimediaCommonsTransformationFactory implements TransformationFactoryInterface
99
{
1010
public function build(?string $transformationName = null, array $transformationParameters = []): Transformation
1111
{

code_samples/back_office/images/src/WikimediaCommonsConnector/WikimediaCommonsConnector.php

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends '@ezdesign/ui/field_type/image_asset_view.html.twig' %}
1+
{% extends '@ibexadesign/ui/field_type/image_asset_view.html.twig' %}
22

33
{% block asset_preview %}
44
{{ parent() }}

docs/content_management/images/add_image_asset_from_dam.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -86,36 +86,20 @@ For more information about block customization (defined templates, variations),
8686

8787
## Extend DAM support by adding custom connector
8888

89-
To extend the DAM support built into [= product_name =], you must create a custom Symfony bundle.
89+
To extend the DAM support built into [= product_name =], you must create a custom handler and transformation factory.
9090

9191
!!! note "Wikimedia Commons licensing"
9292

9393
Before you use Wikimedia Commons assets in a production environment, ensure that you comply with their [license requirements](https://commons.wikimedia.org/wiki/Commons:Reusing_content_outside_Wikimedia#How_to_comply_with_a_file's_license_requirements).
9494

95-
### Create bundle structure
96-
97-
In your project's `src` directory, create a folder for the new bundle, for example, `WikimediaCommonsConnector`.
98-
99-
In that folder, create the main class file `WikimediaCommonsConnector.php` for the bundle:
100-
101-
```php
102-
[[= include_file('code_samples/back_office/images/src/WikimediaCommonsConnector/WikimediaCommonsConnector.php') =]]
103-
```
104-
105-
Then, in `config/bundles.php`, at the end of an array with a list of bundles, add the following line:
106-
107-
```php
108-
[[= include_file('code_samples/back_office/images/config/bundles.php') =]]
109-
```
110-
11195
### Create DAM handler
11296

11397
This class handles searching through Wikimedia Commons for images and fetching assets.
11498

115-
In `src\WikimediaCommonsConnector\Handler` folder, create the `WikimediaHandler.php` file that resembles the following example, which uses `search()` and `fetchAsset()` functions to query the server for images and return asset objects, respectively:
99+
In `src\Connector\Dam\Handler` folder, create the `WikimediaCommonsHandler.php` file that resembles the following example, which uses `search()` and `fetchAsset()` functions to query the server for images and return asset objects, respectively:
116100

117101
```php
118-
[[= include_file('code_samples/back_office/images/src/WikimediaCommonsConnector/Handler/WikimediaCommonsHandler.php') =]]
102+
[[= include_file('code_samples/back_office/images/src/Connector/Dam/Handler/WikimediaCommonsHandler.php') =]]
119103
```
120104

121105
Then, in `config\services.yaml`, register the handler as a service:
@@ -124,16 +108,15 @@ Then, in `config\services.yaml`, register the handler as a service:
124108
[[= include_file('code_samples/back_office/images/config/services.yaml', 9, 14) =]]
125109
```
126110

127-
128111
### Create transformation factory
129112

130113
The transformation factory transforms image variations coming from Wikimedia Commons to the ones used by [= product_name =].
131114

132-
In `src\WikimediaCommonsConnector\Transformation` folder, create the `TransformationFactory.php` file that resembles the following example:
115+
In `src\Connector\Dam\Transformation` folder, create the `WikimediaCommonsTransformationFactory.php` file that resembles the following example:
133116

134117

135118
```php
136-
[[= include_file('code_samples/back_office/images/src/WikimediaCommonsConnector/Transformation/TransformationFactory.php') =]]
119+
[[= include_file('code_samples/back_office/images/src/Connector/Dam/Transformation/WikimediaCommonsTransformationFactory.php') =]]
137120
```
138121

139122
Then register the transformation factory as a service:
@@ -145,7 +128,7 @@ Then register the transformation factory as a service:
145128
### Register variations generator
146129

147130
The variation generator applies map parameters coming from the transformation factory to build a fetch request to the DAM.
148-
The `WikimediaCommonsConnector` uses the built-in `URLBasedVariationGenerator` class, which adds all the map elements as query parameters of the request.
131+
The solution uses the built-in `URLBasedVariationGenerator` class, which adds all the map elements as query parameters of the request.
149132

150133
For example, the handler generates the following URL with `new AssetUri()`:
151134

@@ -168,13 +151,13 @@ The template deffines how images that come from Wikimedia Commons appear in the
168151
In `templates/bundles/WikimediaCommonsConnector/`, add the `commons_asset_view.html.twig` file that resembles the following example:
169152

170153
```html+twig
171-
[[= include_file('code_samples/back_office/images/src/WikimediaCommonsConnector/Resources/views/themes/standard/commons_asset_view.html.twig') =]]
154+
[[= include_file('code_samples/back_office/images/templates/themes/standard/commons_asset_view.html.twig') =]]
172155
```
173156

174157
Then, register the template in configuration files:
175158

176159
```yaml
177-
[[= include_file('code_samples/back_office/images/config/views.yaml') =]]
160+
[[= include_file('code_samples/back_office/images/config/packages/views.yaml') =]]
178161
```
179162

180163
### Add Wikimedia Commons connection to DAM configuration

0 commit comments

Comments
 (0)