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:
@@ -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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user