1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-12 16:14:16 +02:00

Flextype Core: Entries - new method create() - added.

This commit is contained in:
Awilum
2019-02-07 16:46:10 +03:00
parent 27837fe711
commit 31666b6b97

View File

@@ -282,6 +282,38 @@ class Entries
}
}
/**
* Create entry
*
* @param string $entry Entry
* @param string $data Data
* @return bool
*/
public static create(string $entry, string $data) : bool
{
$entry_dir = PATH['entries'] . '/' . $entry;
// Check if new entry directory exists
if (!Filesystem::has($entry_dir)) {
// Try to create directory for new entry
if (Filesystem::createDir($entry_dir)) {
$entry_file = $entry_dir . '/entry.html';
// Check if new entry file exists
if (!Filesystem::has($entry_file)) {
return Filesystem::write($entry_file, $data);
}
} else {
return false;
}
} else {
return false;
}
}
/**
* Delete entry.
*