Loading csv_serialization.info.yml +2 −3 Original line number Diff line number Diff line name: 'Serialization (CSV)' type: module description: 'Provides CSV as a serialization format.' core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9.3 || ^10 package: Web services dependencies: - drupal:serialization (>=8.0.4) - drupal:serialization src/Encoder/CsvEncoder.php +4 −4 Original line number Diff line number Diff line Loading @@ -106,14 +106,14 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { /** * {@inheritdoc} */ public function supportsEncoding($format) { public function supportsEncoding(string $format):bool { return $format == static::$format; } /** * {@inheritdoc} */ public function supportsDecoding($format) { public function supportsDecoding(string $format):bool { return $format == static::$format; } Loading @@ -122,7 +122,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { * * Uses HTML-safe strings, with several characters escaped. */ public function encode($data, $format, array $context = []) { public function encode($data, string $format, array $context = []):string { switch (gettype($data)) { case "array": break; Loading Loading @@ -290,7 +290,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { * @throws \League\Csv\Exception * @throws \League\Csv\Exception */ public function decode($data, $format, array $context = []) { public function decode($data, string $format, array $context = []) { $csv = Reader::createFromString($data); $csv->setDelimiter($this->delimiter); $csv->setEnclosure($this->enclosure); Loading src/EventSubscriber/CsvSubscriber.php +3 −3 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ namespace Drupal\csv_serialization\EventSubscriber; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** Loading @@ -14,10 +14,10 @@ class CsvSubscriber implements EventSubscriberInterface { /** * Register content type formats on the request object. * * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event * The Event to process. */ public function onKernelRequest(GetResponseEvent $event) { public function onKernelRequest(RequestEvent $event) { $event->getRequest()->setFormat('csv', ['text/csv']); } Loading Loading
csv_serialization.info.yml +2 −3 Original line number Diff line number Diff line name: 'Serialization (CSV)' type: module description: 'Provides CSV as a serialization format.' core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9.3 || ^10 package: Web services dependencies: - drupal:serialization (>=8.0.4) - drupal:serialization
src/Encoder/CsvEncoder.php +4 −4 Original line number Diff line number Diff line Loading @@ -106,14 +106,14 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { /** * {@inheritdoc} */ public function supportsEncoding($format) { public function supportsEncoding(string $format):bool { return $format == static::$format; } /** * {@inheritdoc} */ public function supportsDecoding($format) { public function supportsDecoding(string $format):bool { return $format == static::$format; } Loading @@ -122,7 +122,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { * * Uses HTML-safe strings, with several characters escaped. */ public function encode($data, $format, array $context = []) { public function encode($data, string $format, array $context = []):string { switch (gettype($data)) { case "array": break; Loading Loading @@ -290,7 +290,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { * @throws \League\Csv\Exception * @throws \League\Csv\Exception */ public function decode($data, $format, array $context = []) { public function decode($data, string $format, array $context = []) { $csv = Reader::createFromString($data); $csv->setDelimiter($this->delimiter); $csv->setEnclosure($this->enclosure); Loading
src/EventSubscriber/CsvSubscriber.php +3 −3 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ namespace Drupal\csv_serialization\EventSubscriber; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** Loading @@ -14,10 +14,10 @@ class CsvSubscriber implements EventSubscriberInterface { /** * Register content type formats on the request object. * * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event * The Event to process. */ public function onKernelRequest(GetResponseEvent $event) { public function onKernelRequest(RequestEvent $event) { $event->getRequest()->setFormat('csv', ['text/csv']); } Loading