1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-19 11:21:30 +02:00

Flextype Core: Add ability to work with different types of content #212 #186

This commit is contained in:
Awilum
2019-08-10 21:57:33 +03:00
parent 525ec0345c
commit f5d202c02a
2 changed files with 18 additions and 8 deletions

View File

@@ -466,15 +466,15 @@ class Entries
*/
private function _file_location(string $id)
{
$json_file = PATH['entries'] . '/' . $id . '/entry.json';
$yaml_file = PATH['entries'] . '/' . $id . '/entry.yaml';
foreach (Parser::$drivers as $driver) {
$driver_file = PATH['entries'] . '/' . $id . '/entry' . '.' . $driver['ext'];
if (Filesystem::has($json_file)) {
return ['file' => $json_file, 'driver' => 'json'];
}
if (Filesystem::has($yaml_file)) {
return ['file' => $yaml_file, 'driver' => 'yaml'];
if (Filesystem::has($driver_file)) {
return [
'file' => $driver_file,
'driver' => $driver['name'],
];
}
}
return false;

View File

@@ -11,6 +11,16 @@ namespace Flextype;
class Parser
{
public static $drivers = [
'json' => [
'name' => 'json',
'ext' => 'json',
], 'yaml' => [
'name' => 'yaml',
'ext' => 'yaml',
],
];
public static function encode($input, string $driver) : string
{
switch ($driver) {