Skip to content
Snippets Groups Projects
Commit 2086c829 authored by Alberto Paderno's avatar Alberto Paderno
Browse files

Merge branch '3473079-fix-phpcs-issues' into '1.0.x'

Issue #3473079: Fix the issues reported by PHP_CodeSniffer

See merge request !2
parents f30e90e3 9a796508
No related branches found
No related tags found
No related merge requests found
Pipeline #278877 passed with warnings
################
# GitLabCI template for Drupal projects.
#
# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification.
# It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained.
# As long as you include the project, ref and three files below, any future updates added by the Drupal Association will be used in your
# pipelines automatically. However, you can modify this template if you have additional needs for your project.
# The full documentation is on https://project.pages.drupalcode.org/gitlab_templates/
################
# For information on alternative values for 'ref' see https://project.pages.drupalcode.org/gitlab_templates/info/templates-version/
# To test a Drupal 7 project, change the first include filename from .main.yml to .main-d7.yml
include:
- project: $_GITLAB_TEMPLATES_REPO
ref: $_GITLAB_TEMPLATES_REF
file:
- "/includes/include.drupalci.main.yml"
- "/includes/include.drupalci.variables.yml"
- "/includes/include.drupalci.workflows.yml"
################
# Pipeline configuration variables are defined with default values and descriptions in the file
# https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.variables.yml
# Uncomment the lines below if you want to override any of the variables. The following is just an example.
################
# variables:
# SKIP_ESLINT: '1'
# OPT_IN_TEST_NEXT_MAJOR: '1'
# _CURL_TEMPLATES_REF: 'main'
# Capdata RDF Connector # Capdata RDF Connector
CapData RDF est un composant clé du projet CapData Opéra - France 2030, CapData RDF est un composant clé du projet CapData Opéra - France 2030,
porté par la Réunion des Opéras de France dans le cadre du programme France 2030. porté par la Réunion des Opéras de France dans le cadre
Ce module vise à faciliter l'alignement et l'exposition des données au format RDF, du programme France 2030. Ce module vise à faciliter
l'alignement et l'exposition des données au format RDF,
essentiel pour l'interopérabilité et le partage des données culturelles. essentiel pour l'interopérabilité et le partage des données culturelles.
Pour une description complète du module, veuillez visiter la Pour une description complète du module, veuillez visiter la
...@@ -14,4 +15,5 @@ Page de configuration propre au module: `admin/config/services/capdata-mapping`. ...@@ -14,4 +15,5 @@ Page de configuration propre au module: `admin/config/services/capdata-mapping`.
## Génération du fichier d'export ## Génération du fichier d'export
Commande drush pour générer le fichier d'export: `drush capdata-rdf-export --uri=https://opera-exemple.com` Commande drush pour générer le fichier d'export:
\ No newline at end of file `drush capdata-rdf-export --uri=https://opera-exemple.com`
...@@ -3,4 +3,4 @@ type: module ...@@ -3,4 +3,4 @@ type: module
description: 'Export des données du site Drupal dans un fichier au format RDF.' description: 'Export des données du site Drupal dans un fichier au format RDF.'
core_version_requirement: ^9 || ^10 core_version_requirement: ^9 || ^10
package: CapData Opéra package: CapData Opéra
configure: capdata_connector.admin_settings configure: capdata_connector.admin_settings
\ No newline at end of file
capdata_settingsstyles: capdata_settingsstyles:
css: css:
theme: theme:
css/capdataconnector-settings-form.css: {} css/capdataconnector-settings-form.css: {}
\ No newline at end of file
...@@ -2,4 +2,4 @@ capdata_connector.admin_settings: ...@@ -2,4 +2,4 @@ capdata_connector.admin_settings:
title: 'Capdata Connector Settings' title: 'Capdata Connector Settings'
route_name: capdata_connector.admin_settings route_name: capdata_connector.admin_settings
description: 'Configurer les paramètres du Capdata Connector' description: 'Configurer les paramètres du Capdata Connector'
parent: system.admin_config_services parent: system.admin_config_services
\ No newline at end of file
...@@ -11,11 +11,11 @@ use Drupal\Core\Routing\RouteMatchInterface; ...@@ -11,11 +11,11 @@ use Drupal\Core\Routing\RouteMatchInterface;
* Implements hook_help(). * Implements hook_help().
*/ */
function capdata_connector_help(string $route_name, RouteMatchInterface $route_match) : string { function capdata_connector_help(string $route_name, RouteMatchInterface $route_match) : string {
$help = ''; $help = '';
switch ($route_name) { switch ($route_name) {
case 'help.page.capdata_connector': case 'help.page.capdata_connector':
$help = '<p>' . t('Ce module permet de gérer le mapping des différentes classes et propriétés de l\'ontologie aux structures de données de Drupal.') . '</p>'; $help = '<p>' . t("Ce module permet de gérer le mapping des différentes classes et propriétés de l'ontologie aux structures de données de Drupal.") . '</p>';
break; break;
} }
return $help; return $help;
} }
\ No newline at end of file
...@@ -12,4 +12,5 @@ capdata_connector.capdata_export: ...@@ -12,4 +12,5 @@ capdata_connector.capdata_export:
_controller: '\Drupal\capdata_connector\Controller\RofExportController::capdataRdfExport' _controller: '\Drupal\capdata_connector\Controller\RofExportController::capdataRdfExport'
_title: 'ROF' _title: 'ROF'
requirements: requirements:
_access: 'TRUE' # Needs to be accessed by an anonymous user.
\ No newline at end of file _access: 'TRUE'
...@@ -7,4 +7,4 @@ services: ...@@ -7,4 +7,4 @@ services:
- '@config.factory' - '@config.factory'
- '@request_stack' - '@request_stack'
- '@file_url_generator' - '@file_url_generator'
- '@module_handler' - '@module_handler'
\ No newline at end of file
.single-capdata-property-fieldset .fieldset__wrapper{ .single-capdata-property-fieldset .fieldset__wrapper {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
\ No newline at end of file
This diff is collapsed.
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
namespace Drupal\capdata_connector\Commands; namespace Drupal\capdata_connector\Commands;
use Drush\Commands\DrushCommands;
use Drupal\capdata_connector\CapDataConnectorManager; use Drupal\capdata_connector\CapDataConnectorManager;
use Drush\Commands\DrushCommands;
/** /**
* A Drush commandfile. * A Drush commandfile.
...@@ -16,55 +16,55 @@ use Drupal\capdata_connector\CapDataConnectorManager; ...@@ -16,55 +16,55 @@ use Drupal\capdata_connector\CapDataConnectorManager;
* - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php * - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php
* - http://cgit.drupalcode.org/devel/tree/drush.services.yml * - http://cgit.drupalcode.org/devel/tree/drush.services.yml
*/ */
class CapdataConnectorCommands extends DrushCommands class CapdataConnectorCommands extends DrushCommands {
{
/** /**
* The CapData Connector manager. * The CapData Connector manager.
* *
* @var \Drupal\capdata_connector\CapDataConnectorManager * @var \Drupal\capdata_connector\CapDataConnectorManager
*/ */
protected $capdataConnectorManager; protected $capdataConnectorManager;
/** /**
* CapdataConnectorCommands constructor. * CapdataConnectorCommands constructor.
* *
* @param \Drupal\capdata_connector\CapDataConnectorManager $capdata_connector_manager * @param \Drupal\capdata_connector\CapDataConnectorManager $capdata_connector_manager
* The CapData Connector manager. * The CapData Connector manager.
*/ */
public function __construct(CapDataConnectorManager $capdata_connector_manager) { public function __construct(CapDataConnectorManager $capdata_connector_manager) {
$this->capdataConnectorManager = $capdata_connector_manager; $this->capdataConnectorManager = $capdata_connector_manager;
} }
/**
* Generate RDF data export file (capdata-export.rdf).
*
* @command capdata_connector:rdf-export
* @aliases capdata-rdf-export
*/
public function rdfExport() {
$this->logger()->notice('Starting export.');
/** $data = $this->capdataConnectorManager->dataExport();
* Generate RDF data export file (capdata-export.rdf). $file = getcwd() . '/.well-known/capdata-export.rdf';
* $compressedFile = $file . '.gz';
* @command capdata_connector:rdf-export
* @aliases capdata-rdf-export
*/
public function rdfExport()
{
$this->logger()->notice('Starting export.');
$data = $this->capdataConnectorManager->dataExport(); if (file_put_contents($file, $data)) {
$file = getcwd() . '/.well-known/capdata-export.rdf'; $this->logger()->notice('File capdata-export.rdf generated.');
$compressedFile = $file . '.gz';
if (file_put_contents($file, $data)) { // Open the gz file (w9 is the highest compression)
$this->logger()->notice('File capdata-export.rdf generated.'); $fp = gzopen($compressedFile, 'w9');
// Open the gz file (w9 is the highest compression)
$fp = gzopen($compressedFile, 'w9');
// Compress the file
gzwrite($fp, file_get_contents($file));
// Close the gz file
gzclose($fp);
$this->logger()->notice('File capdata-export.rdf compressed.'); // Compress the file.
} else { gzwrite($fp, file_get_contents($file));
$this->logger()->error('File capdata-export.rdf could not be generated.');
} // Close the gz file.
gzclose($fp);
$this->logger()->notice('File capdata-export.rdf compressed.');
} }
else {
$this->logger()->error('File capdata-export.rdf could not be generated.');
}
}
} }
...@@ -2,73 +2,74 @@ ...@@ -2,73 +2,74 @@
namespace Drupal\capdata_connector\Controller; namespace Drupal\capdata_connector\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\capdata_connector\CapDataConnectorManager; use Drupal\capdata_connector\CapDataConnectorManager;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\HeaderUtils; use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\HttpFoundation\Response;
/** /**
* Returns responses for rof export routes. * Returns responses for rof export routes.
*/ */
class RofExportController extends ControllerBase { class RofExportController extends ControllerBase {
/** /**
* The CapData Connector manager. * The CapData Connector manager.
* *
* @var \Drupal\capdata_connector\CapDataConnectorManager * @var \Drupal\capdata_connector\CapDataConnectorManager
*/ */
protected $capdataConnectorManager; protected $capdataConnectorManager;
/** /**
* RofExportController constructor. * RofExportController constructor.
* *
* @param \Drupal\capdata_connector\CapDataConnectorManager $capdata_connector_manager * @param \Drupal\capdata_connector\CapDataConnectorManager $capdata_connector_manager
* The CapData Connector manager. * The CapData Connector manager.
*/ */
public function __construct(CapDataConnectorManager $capdata_connector_manager) { public function __construct(CapDataConnectorManager $capdata_connector_manager) {
$this->capdataConnectorManager = $capdata_connector_manager; $this->capdataConnectorManager = $capdata_connector_manager;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The Drupal service container. * The Drupal service container.
* *
* @return static * @return static
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('capdata_connector.capdata_manager') $container->get('capdata_connector.capdata_manager')
); );
} }
/** /**
* Builds the RDF export response. * Builds the RDF export response.
*/ */
public function capdataRdfExport() { public function capdataRdfExport() {
$data = ''; $data = '';
$file = getcwd() . '/.well-known/capdata-export.rdf'; $file = getcwd() . '/.well-known/capdata-export.rdf';
if (file_exists($file)) { if (file_exists($file)) {
$data = file_get_contents($file); $data = file_get_contents($file);
} }
if (empty($data)) { if (empty($data)) {
$data = $this->capdataConnectorManager->dataExport(); $data = $this->capdataConnectorManager->dataExport();
} }
$response = new Response(); $response = new Response();
$response->setContent($data); $response->setContent($data);
$response->headers->set('Content-Type', 'application/rdf+xml'); $response->headers->set('Content-Type', 'application/rdf+xml');
$disposition = HeaderUtils::makeDisposition( $disposition = HeaderUtils::makeDisposition(
HeaderUtils::DISPOSITION_ATTACHMENT, HeaderUtils::DISPOSITION_ATTACHMENT,
'capdata-export.rdf' 'capdata-export.rdf'
); );
$response->headers->set('Content-Disposition', $disposition); $response->headers->set('Content-Disposition', $disposition);
return $response; return $response;
} }
}
\ No newline at end of file }
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment