Skip to content

Commit

Permalink
Added FormatterInterface::getDefaultFileExtension()
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Aug 3, 2018
1 parent ca3cf2e commit 34fa50f
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@

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).
*
Expand Down
15 changes: 12 additions & 3 deletions system/src/Grav/Framework/File/Formatter/IniFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ public function __construct(array $config = [])
}

/**
* @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);
}

/**
Expand Down
15 changes: 12 additions & 3 deletions system/src/Grav/Framework/File/Formatter/JsonFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,21 @@ public function __construct(array $config = [])
}

/**
* @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);
}

/**
Expand Down
15 changes: 12 additions & 3 deletions system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@ public function __construct(array $config = [], FormatterInterface $headerFormat
}

/**
* @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);
}

/**
Expand Down
15 changes: 12 additions & 3 deletions system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ public function __construct(array $config = [])
}

/**
* @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);
}

/**
Expand Down
15 changes: 12 additions & 3 deletions system/src/Grav/Framework/File/Formatter/YamlFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,21 @@ public function __construct(array $config = [])
}

/**
* @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);
}

/**
Expand Down

0 comments on commit 34fa50f

Please sign in to comment.