Added FormatterInterface::getDefaultFileExtension()

This commit is contained in:
Matias Griese
2018-08-03 13:19:26 +03:00
parent ca3cf2ea3c
commit 34fa50fcf0
7 changed files with 70 additions and 16 deletions

View File

@@ -3,7 +3,7 @@
1. [](#new)
* Added `Uri::method()` to get current HTTP method (GET/POST etc)
* Added `FormatterInterface::getSupportedFileExtensions()` method, deprecated `getFileExtension()`
* `FormatterInterface`: Added `getSupportedFileExtensions()` and `getDefaultFileExtension()` methods
# v1.5.0-rc.1
## 07/31/2018

View File

@@ -10,6 +10,15 @@ namespace Grav\Framework\File\Formatter;
interface FormatterInterface
{
/**
* Get default file extension from current formatter (with dot).
*
* Default file extension is the first defined extension.
*
* @return string File extension (can be empty).
*/
public function getDefaultFileExtension();
/**
* Get file extensions supported by current formatter (with dot).
*

View File

@@ -25,12 +25,21 @@ class IniFormatter implements FormatterInterface
}
/**
* @deprecated
* @internal
* @deprecated 1.5 Use $formatter->getDefaultFileExtension() instead.
*/
public function getFileExtension()
{
return $this->getSupportedFileExtensions()[0];
return $this->getDefaultFileExtension();
}
/**
* {@inheritdoc}
*/
public function getDefaultFileExtension()
{
$extensions = $this->getSupportedFileExtensions();
return (string) reset($extensions);
}
/**

View File

@@ -23,12 +23,21 @@ class JsonFormatter implements FormatterInterface
}
/**
* @deprecated
* @internal
* @deprecated 1.5 Use $formatter->getDefaultFileExtension() instead.
*/
public function getFileExtension()
{
return $this->getSupportedFileExtensions()[0];
return $this->getDefaultFileExtension();
}
/**
* {@inheritdoc}
*/
public function getDefaultFileExtension()
{
$extensions = $this->getSupportedFileExtensions();
return (string) reset($extensions);
}
/**

View File

@@ -29,12 +29,21 @@ class MarkdownFormatter implements FormatterInterface
}
/**
* @deprecated
* @internal
* @deprecated 1.5 Use $formatter->getDefaultFileExtension() instead.
*/
public function getFileExtension()
{
return $this->getSupportedFileExtensions()[0];
return $this->getDefaultFileExtension();
}
/**
* {@inheritdoc}
*/
public function getDefaultFileExtension()
{
$extensions = $this->getSupportedFileExtensions();
return (string) reset($extensions);
}
/**

View File

@@ -25,12 +25,21 @@ class SerializeFormatter implements FormatterInterface
}
/**
* @deprecated
* @internal
* @deprecated 1.5 Use $formatter->getDefaultFileExtension() instead.
*/
public function getFileExtension()
{
return $this->getSupportedFileExtensions()[0];
return $this->getDefaultFileExtension();
}
/**
* {@inheritdoc}
*/
public function getDefaultFileExtension()
{
$extensions = $this->getSupportedFileExtensions();
return (string) reset($extensions);
}
/**

View File

@@ -30,12 +30,21 @@ class YamlFormatter implements FormatterInterface
}
/**
* @deprecated
* @internal
* @deprecated 1.5 Use $formatter->getDefaultFileExtension() instead.
*/
public function getFileExtension()
{
return $this->getSupportedFileExtensions()[0];
return $this->getDefaultFileExtension();
}
/**
* {@inheritdoc}
*/
public function getDefaultFileExtension()
{
$extensions = $this->getSupportedFileExtensions();
return (string) reset($extensions);
}
/**