Media AV Portal adds the European Audiovisual Services as a supported media provider.
Only 3 media assets types from AV Portal are currently supported:
- PHOTO (resources like https://audiovisual.ec.europa.eu/en/photo/P-038924).
- VIDEO (resources like https://audiovisual.ec.europa.eu/en/video/I-183993).
- REPORTAGE (resources like https://audiovisual.ec.europa.eu/en/photo/P-038924~2F00-15).
The project also comes with a test module that provides a mock to the remote AV Portal service. Meaning that tests do not have to be run against the remote service but local resources are used.
Enable the media_avportal_mock
inside a given test and all HTTP requests going to AV Portal API will be intercepted automatically. These, then, will return predefined responses that can be inspected in the responses
folder of the mock module.
By default, there are 3 types of requests that are mocked:
- A default request with no options
- A request for a given resource (the options contain the
ref
key) - A request that searches for a given term (the options contain the
kwgg
key)
Additionally, any request to a resource thumbnail will return a local thumbnail image.
If another module needs to test interactions that require more responses, these can be provided via an event subscriber (to the AvPortalMockEvent
event).
In the subscriber, 3 types of responses (in JSON format) can be provided:
- Individual resources
- Search results for a given term
- A default response to replace the existing one
As an example, you can see the subscriber that provides the default resources, AvPortalMockEventSubscriber
.
Table of contents:
The recommended way of installing the module is via Composer.
composer require drupal/media_avportal
In order to enable the module in your project run:
./vendor/bin/drush en media_avportal -y
The project contains all the necessary code and tools for an effective development process, such as:
- All PHP development dependencies (Drupal core included) are required by composer.json
- Project setup and installation can be easily handled thanks to the integration with the Task Runner project.
- All system requirements are containerized using Docker Composer
Download all required PHP code by running:
composer install
This will build a fully functional Drupal test site in the ./build
directory that can be used to develop and showcase
the module's functionality.
Before setting up and installing the site make sure to customize default configuration values by copying runner.yml.dist
to ./runner.yml
and overriding relevant properties.
This will also:
- Symlink the theme in
./build/modules/custom/media_avportal
so that it's available for the test site - Setup Drush and Drupal's settings using values from
./runner.yml.dist
. This includes adding parameters for EULogin - Setup PHPUnit and Behat configuration files using values from
./runner.yml.dist
Please note: project files and directories are symlinked within the test site by using the OpenEuropa Task Runner's Drupal project symlink command.
If you add a new file or directory in the root of the project, you need to re-run drupal:site-setup
in order to make
sure they are be correctly symlinked.
If you don't want to re-run a full site setup for that, you can simply run:
$ ./vendor/bin/run drupal:symlink-project
After a successful setup install the site by running:
./vendor/bin/run drupal:site-install
This will:
- Install the test site
- Enable the Media AV Portal module
For Drupal 10.2, the drupal/remote_stream_wrapper (issue 3437974) patch needs to be removed.
If you require this module in Drupal 10.2 you must unset the patch in your composer.json.
You can do this with the following command:
composer config --merge --json "extra.patches-ignore.drupal/media_avportal" '{"drupal/remote_stream_wrapper": {"Drupal 10.3.x only - see media_avportal/README.md for 10.2.x - https://www.drupal.org/project/remote_stream_wrapper/issues/3437974": "https://www.drupal.org/files/issues/2024-06-21/drupal_10_3_deliver_signature_change-3437974-2_0_0-18.patch"}}'
Alternatively, you can build a development site using Docker and Docker Compose with the provided configuration.
Docker provides the necessary services and tools such as a web server and a database server to get the site running, regardless of your local host configuration.
By default, Docker Compose reads two files, a docker-compose.yml
and an optional docker-compose.override.yml
file.
By convention, the docker-compose.yml
contains your base configuration and it's provided by default.
The override file, as its name implies, can contain configuration overrides for existing services or entirely new
services.
If a service is defined in both files, Docker Compose merges the configurations.
Find more information on Docker Compose extension mechanism on the official Docker Compose documentation.
To start, run:
docker-compose up
It's advised to not daemonize docker-compose
so you can turn it off (CTRL+C
) quickly when you're done working.
However, if you'd like to daemonize it, you have to add the flag -d
:
docker-compose up -d
Then:
docker-compose exec web composer install
docker-compose exec web ./vendor/bin/run drupal:site-install
Using default configuration, the development site files should be available in the build
directory and the development site
should be available at: http://127.0.0.1:8080/build.
To run the grumphp checks:
docker-compose exec web ./vendor/bin/grumphp run
To run the phpunit tests:
docker-compose exec web ./vendor/bin/phpunit
To enable step debugging from the command line, pass the XDEBUG_SESSION
environment variable with any value to
the container:
docker-compose exec -e XDEBUG_SESSION=1 web <your command>
Please note that, starting from XDebug 3, a connection error message will be outputted in the console if the variable is set but your client is not listening for debugging connections. The error message will cause false negatives for PHPUnit tests.
To initiate step debugging from the browser, set the correct cookie using a browser extension or a bookmarklet like the ones generated at https://www.jetbrains.com/phpstorm/marklets/.
Manually disabling Drupal 8 caching is a laborious process that is well described here.
Alternatively you can use the following Drupal Console commands to disable/enable Drupal 8 caching:
./vendor/bin/drupal site:mode dev # Disable all caches.
./vendor/bin/drupal site:mode prod # Enable all caches.
Note: to fully disable Twig caching the following additional manual steps are required:
- Open
./build/sites/default/services.yml
- Set
cache: false
intwig.config:
property. E.g.:
parameters:
twig.config:
cache: false
- Rebuild Drupal cache:
./vendor/bin/drush cr
This is due to the following Drupal Console issue.
Please read the full documentation for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the available versions, see the tags on this repository.