From ca3cf2ea3c3c448dc28f1acc6cb3b2d3bab17337 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 3 Aug 2018 13:03:51 +0300 Subject: [PATCH] Added `FormatterInterface::getSupportedFileExtensions()` method, deprecated `getFileExtension()` --- CHANGELOG.md | 1 + .../Framework/File/Formatter/FormatterInterface.php | 6 +++--- .../Grav/Framework/File/Formatter/IniFormatter.php | 13 +++++++++++-- .../Grav/Framework/File/Formatter/JsonFormatter.php | 13 +++++++++++-- .../Framework/File/Formatter/MarkdownFormatter.php | 13 +++++++++++-- .../Framework/File/Formatter/SerializeFormatter.php | 13 +++++++++++-- .../Grav/Framework/File/Formatter/YamlFormatter.php | 13 +++++++++++-- 7 files changed, 59 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2576e0eb18..a727c20a34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 1. [](#new) * Added `Uri::method()` to get current HTTP method (GET/POST etc) + * Added `FormatterInterface::getSupportedFileExtensions()` method, deprecated `getFileExtension()` # v1.5.0-rc.1 ## 07/31/2018 diff --git a/system/src/Grav/Framework/File/Formatter/FormatterInterface.php b/system/src/Grav/Framework/File/Formatter/FormatterInterface.php index 84af00b63e..35ceccfde1 100644 --- a/system/src/Grav/Framework/File/Formatter/FormatterInterface.php +++ b/system/src/Grav/Framework/File/Formatter/FormatterInterface.php @@ -11,11 +11,11 @@ interface FormatterInterface { /** - * Get file extension with dot. + * Get file extensions supported by current formatter (with dot). * - * @return string + * @return string[] */ - public function getFileExtension(); + public function getSupportedFileExtensions(); /** * Encode data into a string. diff --git a/system/src/Grav/Framework/File/Formatter/IniFormatter.php b/system/src/Grav/Framework/File/Formatter/IniFormatter.php index e7ad2833c5..15d67c4e20 100644 --- a/system/src/Grav/Framework/File/Formatter/IniFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/IniFormatter.php @@ -25,11 +25,20 @@ public function __construct(array $config = []) } /** - * {@inheritdoc} + * @deprecated + * @internal */ public function getFileExtension() { - return $this->config['file_extension']; + return $this->getSupportedFileExtensions()[0]; + } + + /** + * {@inheritdoc} + */ + public function getSupportedFileExtensions() + { + return (array) $this->config['file_extension']; } /** diff --git a/system/src/Grav/Framework/File/Formatter/JsonFormatter.php b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php index 12c2450169..bd01b83079 100644 --- a/system/src/Grav/Framework/File/Formatter/JsonFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php @@ -23,11 +23,20 @@ public function __construct(array $config = []) } /** - * {@inheritdoc} + * @deprecated + * @internal */ public function getFileExtension() { - return $this->config['file_extension']; + return $this->getSupportedFileExtensions()[0]; + } + + /** + * {@inheritdoc} + */ + public function getSupportedFileExtensions() + { + return (array) $this->config['file_extension']; } /** diff --git a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php index 7269c2fe73..c38f691f1c 100644 --- a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php @@ -29,11 +29,20 @@ public function __construct(array $config = [], FormatterInterface $headerFormat } /** - * {@inheritdoc} + * @deprecated + * @internal */ public function getFileExtension() { - return $this->config['file_extension']; + return $this->getSupportedFileExtensions()[0]; + } + + /** + * {@inheritdoc} + */ + public function getSupportedFileExtensions() + { + return (array) $this->config['file_extension']; } /** diff --git a/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php index 3c581efa5c..95744104c2 100644 --- a/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php @@ -25,11 +25,20 @@ public function __construct(array $config = []) } /** - * {@inheritdoc} + * @deprecated + * @internal */ public function getFileExtension() { - return $this->config['file_extension']; + return $this->getSupportedFileExtensions()[0]; + } + + /** + * {@inheritdoc} + */ + public function getSupportedFileExtensions() + { + return (array) $this->config['file_extension']; } /** diff --git a/system/src/Grav/Framework/File/Formatter/YamlFormatter.php b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php index 9a5d602787..ee18061ea6 100644 --- a/system/src/Grav/Framework/File/Formatter/YamlFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php @@ -30,11 +30,20 @@ public function __construct(array $config = []) } /** - * {@inheritdoc} + * @deprecated + * @internal */ public function getFileExtension() { - return $this->config['file_extension']; + return $this->getSupportedFileExtensions()[0]; + } + + /** + * {@inheritdoc} + */ + public function getSupportedFileExtensions() + { + return (array) $this->config['file_extension']; } /**