mirror of
https://github.com/flextype/flextype.git
synced 2025-08-09 14:46:53 +02:00
feat(core): Hide access for all core properties #467
This commit is contained in:
@@ -23,52 +23,15 @@ use function str_replace;
|
||||
class Entries
|
||||
{
|
||||
/**
|
||||
* Current entry id
|
||||
* Entries Storage
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private $entry_id = null;
|
||||
|
||||
/**
|
||||
* Current entry data array
|
||||
* Used for storing current requested entry(entries) data
|
||||
* and maybe changed on fly.
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @access public
|
||||
*/
|
||||
private $entry = [];
|
||||
|
||||
/**
|
||||
* Current entry create data array
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $entry_create_data = [];
|
||||
|
||||
/**
|
||||
* Current entry update data array
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $entry_update_data = [];
|
||||
|
||||
/**
|
||||
* Current entries data
|
||||
*
|
||||
* @var array|bool|int
|
||||
* @access private
|
||||
*/
|
||||
private $entries;
|
||||
|
||||
/**
|
||||
* Current entries id
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private $entries_id = null;
|
||||
public $storage = [];
|
||||
|
||||
/**
|
||||
* Fetch entry(entries)
|
||||
@@ -102,27 +65,27 @@ class Entries
|
||||
public function fetchSingle(string $id) : array
|
||||
{
|
||||
// Store current requested entry id
|
||||
$this->entry_id = $id;
|
||||
$this->storage['fetch_single']['id'] = $id;
|
||||
|
||||
// Get Cache ID for current requested entry
|
||||
$entry_cache_id = $this->getCacheID($this->entry_id);
|
||||
$entry_cache_id = $this->getCacheID($this->storage['fetch_single']['id']);
|
||||
|
||||
// Try to get current requested entry from cache
|
||||
if (flextype('cache')->has($entry_cache_id)) {
|
||||
// Fetch entry from cache
|
||||
$this->entry = flextype('cache')->get($entry_cache_id);
|
||||
$this->storage['fetch_single']['data'] = flextype('cache')->get($entry_cache_id);
|
||||
|
||||
// Run event: onEntryAfterCacheInitialized
|
||||
flextype('emitter')->emit('onEntryAfterCacheInitialized');
|
||||
|
||||
// Return entry from cache
|
||||
return $this->entry;
|
||||
return $this->storage['fetch_single']['data'];
|
||||
}
|
||||
|
||||
// Try to get current requested entry from filesystem
|
||||
if ($this->has($this->entry_id)) {
|
||||
if ($this->has($this->storage['fetch_single']['id'])) {
|
||||
// Get entry file location
|
||||
$entry_file = $this->getFileLocation($this->entry_id);
|
||||
$entry_file = $this->getFileLocation($this->storage['fetch_single']['id']);
|
||||
|
||||
// Try to get requested entry from the filesystem
|
||||
$entry_file_content = Filesystem::read($entry_file);
|
||||
@@ -131,22 +94,22 @@ class Entries
|
||||
}
|
||||
|
||||
// Decode entry file content
|
||||
$this->entry = flextype('frontmatter')->decode($entry_file_content);
|
||||
$this->storage['fetch_single']['data'] = flextype('frontmatter')->decode($entry_file_content);
|
||||
|
||||
// Run event: onEntryAfterInitialized
|
||||
flextype('emitter')->emit('onEntryAfterInitialized');
|
||||
|
||||
// Set cache state
|
||||
$cache = flextype('entries')->entry['cache']['enabled'] ??
|
||||
$cache = flextype('entries')->storage['fetch_single']['data']['cache']['enabled'] ??
|
||||
flextype('registry')->get('flextype.settings.cache.enabled');
|
||||
|
||||
// Save entry data to cache
|
||||
if ($cache) {
|
||||
flextype('cache')->set($entry_cache_id, $this->entry);
|
||||
flextype('cache')->set($entry_cache_id, $this->storage['fetch_single']['data']);
|
||||
}
|
||||
|
||||
// Return entry data
|
||||
return $this->entry;
|
||||
return $this->storage['fetch_single']['data'];
|
||||
}
|
||||
|
||||
// Return empty array if entry is not founded
|
||||
@@ -166,13 +129,13 @@ class Entries
|
||||
public function fetchCollection(string $id, array $filter = [])
|
||||
{
|
||||
// Init Entries object
|
||||
$this->entries = [];
|
||||
$this->storage['fetch_collection']['data'] = [];
|
||||
|
||||
// Store current requested entries id
|
||||
$this->entries_id = $this->getDirLocation($id);
|
||||
$this->storage['entries']['id'] = $this->getDirLocation($id);
|
||||
|
||||
// Find entries
|
||||
$entries_list = find_filter($this->entries_id, $filter);
|
||||
$entries_list = find_filter($this->storage['entries']['id'], $filter);
|
||||
|
||||
// If entries founded in the entries folder
|
||||
// We are checking... Whether the requested entry is an a true entry.
|
||||
@@ -185,18 +148,18 @@ class Entries
|
||||
}
|
||||
|
||||
$_id = ltrim(rtrim(str_replace(PATH['project'] . '/entries/', '', str_replace('\\', '/', $current_entry->getPath())), '/'), '/');
|
||||
$this->entries[$_id] = $this->fetchSingle($_id);
|
||||
$this->storage['fetch_collection']['data'][$_id] = $this->fetchSingle($_id);
|
||||
}
|
||||
|
||||
// Apply collection filter
|
||||
$this->entries = collect_filter($this->entries, $filter);
|
||||
$this->storage['fetch_collection']['data'] = collect_filter($this->storage['fetch_collection']['data'], $filter);
|
||||
|
||||
// Run event: onEntriesAfterInitialized
|
||||
flextype('emitter')->emit('onEntriesAfterInitialized');
|
||||
}
|
||||
|
||||
// Return entries array
|
||||
return $this->entries;
|
||||
return $this->storage['fetch_collection']['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,11 +174,14 @@ class Entries
|
||||
*/
|
||||
public function rename(string $id, string $new_id) : bool
|
||||
{
|
||||
if (! Filesystem::has($this->getDirLocation($new_id))) {
|
||||
// Run event: onEntryRename
|
||||
flextype('emitter')->emit('onEntryRename');
|
||||
$this->storage['rename']['id'] = $id;
|
||||
$this->storage['rename']['new_id'] = $new_id;
|
||||
|
||||
return rename($this->getDirLocation($id), $this->getDirLocation($new_id));
|
||||
// Run event: onEntryRename
|
||||
flextype('emitter')->emit('onEntryRename');
|
||||
|
||||
if (! $this->has($this->storage['rename']['new_id'])) {
|
||||
return rename($this->getDirLocation($this->storage['rename']['id']), $this->getDirLocation($this->storage['rename']['new_id']));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -233,19 +199,20 @@ class Entries
|
||||
*/
|
||||
public function update(string $id, array $data) : bool
|
||||
{
|
||||
$entry_file = $this->getFileLocation($id);
|
||||
// Store data
|
||||
$this->storage['update']['id'] = $id;
|
||||
$this->storage['update']['data'] = $data;
|
||||
|
||||
// Run event: onEntryUpdate
|
||||
flextype('emitter')->emit('onEntryUpdate');
|
||||
|
||||
$entry_file = $this->getFileLocation($this->storage['update']['id']);
|
||||
|
||||
if (Filesystem::has($entry_file)) {
|
||||
$body = Filesystem::read($entry_file);
|
||||
$entry = flextype('frontmatter')->decode($body);
|
||||
|
||||
// Store data in the entry_update_data
|
||||
$this->entry_update_data = $data;
|
||||
|
||||
// Run event: onEntryUpdate
|
||||
flextype('emitter')->emit('onEntryUpdate');
|
||||
|
||||
return Filesystem::write($entry_file, flextype('frontmatter')->encode(array_merge($entry, $this->entry_update_data)));
|
||||
return Filesystem::write($entry_file, flextype('frontmatter')->encode(array_merge($entry, $this->storage['update']['data'])));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -263,21 +230,23 @@ class Entries
|
||||
*/
|
||||
public function create(string $id, array $data) : bool
|
||||
{
|
||||
$entry_dir = $this->getDirLocation($id);
|
||||
// Store data
|
||||
$this->storage['create']['id'] = $id;
|
||||
$this->storage['create']['data'] = $data;
|
||||
|
||||
// Run event: onEntryCreate
|
||||
flextype('emitter')->emit('onEntryCreate');
|
||||
|
||||
$entry_dir = $this->getDirLocation($this->storage['create']['id']);
|
||||
|
||||
if (! Filesystem::has($entry_dir)) {
|
||||
// Try to create directory for new entry
|
||||
if (Filesystem::createDir($entry_dir)) {
|
||||
// Check if new entry file exists
|
||||
if (! Filesystem::has($entry_file = $entry_dir . '/entry' . '.' . flextype('registry')->get('flextype.settings.entries.extension'))) {
|
||||
// Store data in the entry_create_data
|
||||
$this->entry_create_data = $data;
|
||||
|
||||
// Run event: onEntryCreate
|
||||
flextype('emitter')->emit('onEntryCreate');
|
||||
|
||||
// Create a new entry!
|
||||
return Filesystem::write($entry_file, flextype('frontmatter')->encode($this->entry_create_data));
|
||||
return Filesystem::write($entry_file, flextype('frontmatter')->encode($this->storage['create']['data']));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -298,10 +267,13 @@ class Entries
|
||||
*/
|
||||
public function delete(string $id) : bool
|
||||
{
|
||||
// Store data
|
||||
$this->storage['delete']['id'] = $id;
|
||||
|
||||
// Run event: onEntryDelete
|
||||
flextype('emitter')->emit('onEntryDelete');
|
||||
|
||||
return Filesystem::deleteDir($this->getDirLocation($id));
|
||||
return Filesystem::deleteDir($this->getDirLocation($this->storage['delete']['id']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,10 +289,15 @@ class Entries
|
||||
*/
|
||||
public function copy(string $id, string $new_id, bool $deep = false) : ?bool
|
||||
{
|
||||
// Store data
|
||||
$this->storage['copy']['id'] = $id;
|
||||
$this->storage['copy']['new_id'] = $new_id;
|
||||
$this->storage['copy']['deep'] = $deep;
|
||||
|
||||
// Run event: onEntryRename
|
||||
flextype('emitter')->emit('onEntryCopy');
|
||||
|
||||
return Filesystem::copy($this->getDirLocation($id), $this->getDirLocation($new_id), $deep);
|
||||
return Filesystem::copy($this->getDirLocation($this->storage['copy']['id']), $this->getDirLocation($this->storage['copy']['new_id']), $this->storage['copy']['deep']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -334,7 +311,13 @@ class Entries
|
||||
*/
|
||||
public function has(string $id) : bool
|
||||
{
|
||||
return Filesystem::has($this->getFileLocation($id));
|
||||
// Store data
|
||||
$this->storage['has']['id'] = $id;
|
||||
|
||||
// Run event: onEntryHas
|
||||
flextype('emitter')->emit('onEntryHas');
|
||||
|
||||
return Filesystem::has($this->getFileLocation($this->storage['has']['id']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,27 +371,4 @@ class Entries
|
||||
|
||||
return md5('entry' . $entry_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically access entries properties.
|
||||
*
|
||||
* @param string $key Key
|
||||
* @return mixed
|
||||
*/
|
||||
public function &__get(string $key)
|
||||
{
|
||||
return $this->$key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically set entries properties.
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param mixed $value Value
|
||||
* @return void
|
||||
*/
|
||||
public function __set(string $key, $value): void
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
@@ -11,16 +11,16 @@ use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.created_at.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
|
||||
flextype('entries')->entry['created_at'] = isset(flextype('entries')->entry['created_at']) ?
|
||||
(int) strtotime(flextype('entries')->entry['created_at']) :
|
||||
(int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->entry_id));
|
||||
flextype('entries')->storage['fetch_single']['data']['created_at'] = isset(flextype('entries')->storage['fetch_single']['data']['created_at']) ?
|
||||
(int) strtotime(flextype('entries')->storage['fetch_single']['data']['created_at']) :
|
||||
(int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->storage['fetch_single']['id']));
|
||||
});
|
||||
|
||||
flextype('emitter')->addListener('onEntryCreate', static function () : void {
|
||||
if (isset(flextype('entries')->entry_create_data['created_at'])) {
|
||||
flextype('entries')->entry_create_data['created_at'] = flextype('entries')->entry_create_data['created_at'];
|
||||
if (isset(flextype('entries')->storage['create']['data']['created_at'])) {
|
||||
flextype('entries')->storage['create']['data']['created_at'] = flextype('entries')->storage['create']['data']['created_at'];
|
||||
} else {
|
||||
flextype('entries')->entry_create_data['created_at'] = date(flextype('registry')->get('flextype.settings.date_format'), time());
|
||||
flextype('entries')->storage['create']['data']['created_at'] = date(flextype('registry')->get('flextype.settings.date_format'), time());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ declare(strict_types=1);
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.created_by.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryCreate', static function () : void {
|
||||
if (isset(flextype('entries')->entry_create_data['created_by'])) {
|
||||
flextype('entries')->entry_create_data['created_by'] = flextype('entries')->entry_create_data['created_by'];
|
||||
if (isset(flextype('entries')->storage['create']['data']['created_by'])) {
|
||||
flextype('entries')->storage['create']['data']['created_by'] = flextype('entries')->storage['create']['data']['created_by'];
|
||||
} else {
|
||||
flextype('entries')->entry_create_data['created_by'] = '';
|
||||
flextype('entries')->storage['create']['data']['created_by'] = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -9,6 +9,6 @@ declare(strict_types=1);
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.id.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
|
||||
flextype('entries')->entry['id'] = isset(flextype('entries')->entry['id']) ? (string) flextype('entries')->entry['id'] : (string) ltrim(rtrim(flextype('entries')->entry_id, '/'), '/');
|
||||
flextype('entries')->storage['fetch_single']['data']['id'] = isset(flextype('entries')->storage['fetch_single']['data']['id']) ? (string) flextype('entries')->storage['fetch_single']['data']['id'] : (string) ltrim(rtrim(flextype('entries')->storage['fetch_single']['id'], '/'), '/');
|
||||
});
|
||||
}
|
||||
|
@@ -11,6 +11,6 @@ use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.modified_at.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
|
||||
flextype('entries')->entry['modified_at'] = (int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->entry_id));
|
||||
flextype('entries')->storage['fetch_single']['data']['modified_at'] = (int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->storage['fetch_single']['id']));
|
||||
});
|
||||
}
|
||||
|
@@ -17,38 +17,38 @@ if (flextype('registry')->get('flextype.settings.entries.fields.parsers.enabled'
|
||||
|
||||
function processParsersField() : void
|
||||
{
|
||||
$cache = flextype('entries')->entry['cache']['enabled'] ??
|
||||
$cache = flextype('entries')->storage['fetch_single']['data']['cache']['enabled'] ??
|
||||
flextype('registry')->get('flextype.settings.cache.enabled');
|
||||
|
||||
if (! isset(flextype('entries')->entry['parsers'])) {
|
||||
if (! isset(flextype('entries')->storage['fetch_single']['data']['parsers'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (flextype('entries')->entry['parsers'] as $parser_name => $parser_data) {
|
||||
foreach (flextype('entries')->storage['fetch_single']['data']['parsers'] as $parser_name => $parser_data) {
|
||||
if (! in_array($parser_name, ['markdown', 'shortcode'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset(flextype('entries')->entry['parsers'][$parser_name]['enabled']) || flextype('entries')->entry['parsers'][$parser_name]['enabled'] !== true) {
|
||||
if (! isset(flextype('entries')->storage['fetch_single']['data']['parsers'][$parser_name]['enabled']) || flextype('entries')->storage['fetch_single']['data']['parsers'][$parser_name]['enabled'] !== true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset(flextype('entries')->entry['parsers'][$parser_name]['fields'])) {
|
||||
if (! isset(flextype('entries')->storage['fetch_single']['data']['parsers'][$parser_name]['fields'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_array(flextype('entries')->entry['parsers'][$parser_name]['fields'])) {
|
||||
if (! is_array(flextype('entries')->storage['fetch_single']['data']['parsers'][$parser_name]['fields'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (flextype('entries')->entry['parsers'][$parser_name]['fields'] as $field) {
|
||||
foreach (flextype('entries')->storage['fetch_single']['data']['parsers'][$parser_name]['fields'] as $field) {
|
||||
if (in_array($field, flextype('registry')->get('flextype.settings.entries.fields'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($parser_name === 'markdown') {
|
||||
if (Arrays::has(flextype('entries')->entry, $field)) {
|
||||
Arrays::set(flextype('entries')->entry, $field, flextype('markdown')->parse(Arrays::get(flextype('entries')->entry, $field), $cache));
|
||||
if (Arrays::has(flextype('entries')->storage['fetch_single']['data'], $field)) {
|
||||
Arrays::set(flextype('entries')->storage['fetch_single']['data'], $field, flextype('markdown')->parse(Arrays::get(flextype('entries')->storage['fetch_single']['data'], $field), $cache));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ function processParsersField() : void
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! Arrays::has(flextype('entries')->entry, $field)) {
|
||||
if (! Arrays::has(flextype('entries')->storage['fetch_single']['data'], $field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Arrays::set(flextype('entries')->entry, $field, flextype('shortcode')->parse(Arrays::get(flextype('entries')->entry, $field), $cache));
|
||||
Arrays::set(flextype('entries')->storage['fetch_single']['data'], $field, flextype('shortcode')->parse(Arrays::get(flextype('entries')->storage['fetch_single']['data'], $field), $cache));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,16 +11,16 @@ use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.published_at.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
|
||||
flextype('entries')->entry['published_at'] = isset(flextype('entries')->entry['published_at']) ?
|
||||
(int) strtotime(flextype('entries')->entry['published_at']) :
|
||||
(int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->entry_id));
|
||||
flextype('entries')->storage['fetch_single']['data']['published_at'] = isset(flextype('entries')->storage['fetch_single']['data']['published_at']) ?
|
||||
(int) strtotime(flextype('entries')->storage['fetch_single']['data']['published_at']) :
|
||||
(int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->storage['fetch_single']['id']));
|
||||
});
|
||||
|
||||
flextype('emitter')->addListener('onEntryCreate', static function () : void {
|
||||
if (isset(flextype('entries')->entry_create_data['published_at'])) {
|
||||
flextype('entries')->entry_create_data['published_at'] = flextype('entries')->entry_create_data['published_at'];
|
||||
if (isset(flextype('entries')->storage['create']['data']['published_at'])) {
|
||||
flextype('entries')->storage['create']['data']['published_at'] = flextype('entries')->storage['create']['data']['published_at'];
|
||||
} else {
|
||||
flextype('entries')->entry_create_data['published_at'] = date(flextype('registry')->get('flextype.settings.date_format'), time());
|
||||
flextype('entries')->storage['create']['data']['published_at'] = date(flextype('registry')->get('flextype.settings.date_format'), time());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ declare(strict_types=1);
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.published_by.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryCreate', static function () : void {
|
||||
if (isset(flextype('entries')->entry_create_data['published_by'])) {
|
||||
flextype('entries')->entry_create_data['published_by'] = flextype('entries')->entry_create_data['published_by'];
|
||||
if (isset(flextype('entries')->storage['create']['data']['published_by'])) {
|
||||
flextype('entries')->storage['create']['data']['published_by'] = flextype('entries')->storage['create']['data']['published_by'];
|
||||
} else {
|
||||
flextype('entries')->entry_create_data['published_by'] = '';
|
||||
flextype('entries')->storage['create']['data']['published_by'] = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -10,16 +10,16 @@ declare(strict_types=1);
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.routable.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
|
||||
flextype('entries')->entry['routable'] = isset(flextype('entries')->entry['routable']) ?
|
||||
(bool) flextype('entries')->entry['routable'] :
|
||||
flextype('entries')->storage['fetch_single']['data']['routable'] = isset(flextype('entries')->storage['fetch_single']['data']['routable']) ?
|
||||
(bool) flextype('entries')->storage['fetch_single']['data']['routable'] :
|
||||
true;
|
||||
});
|
||||
|
||||
flextype('emitter')->addListener('onEntryCreate', static function () : void {
|
||||
if (isset(flextype('entries')->entry_create_data['routable']) && is_bool(flextype('entries')->entry_create_data['routable'])) {
|
||||
flextype('entries')->entry_create_data['routable'] = flextype('entries')->entry_create_data['routable'];
|
||||
if (isset(flextype('entries')->storage['create']['data']['routable']) && is_bool(flextype('entries')->storage['create']['data']['routable'])) {
|
||||
flextype('entries')->storage['create']['data']['routable'] = flextype('entries')->storage['create']['data']['routable'];
|
||||
} else {
|
||||
flextype('entries')->entry_create_data['routable'] = true;
|
||||
flextype('entries')->storage['create']['data']['routable'] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ declare(strict_types=1);
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.slug.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
|
||||
|
||||
$parts = explode('/', ltrim(rtrim(flextype('entries')->entry_id, '/'), '/'));
|
||||
flextype('entries')->entry['slug'] = isset(flextype('entries')->entry['slug']) ? (string) flextype('entries')->entry['slug'] : (string) end($parts);
|
||||
$parts = explode('/', ltrim(rtrim(flextype('entries')->storage['fetch_single']['id'], '/'), '/'));
|
||||
flextype('entries')->storage['fetch_single']['data']['slug'] = 'ads';//isset(flextype('entries')->storage['fetch_single']['data']['slug']) ? (string) flextype('entries')->storage['fetch_single']['data']['slug']: (string) end($parts);
|
||||
});
|
||||
}
|
||||
|
@@ -11,10 +11,10 @@ use Ramsey\Uuid\Uuid;
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.uuid.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryCreate', static function () : void {
|
||||
if (isset(flextype('entries')->entry_create_data['uuid'])) {
|
||||
flextype('entries')->entry_create_data['uuid'] = flextype('entries')->entry_create_data['uuid'];
|
||||
if (isset(flextype('entries')->storage['create']['data']['uuid'])) {
|
||||
flextype('entries')->storage['create']['data']['uuid'] = flextype('entries')->storage['create']['data']['uuid'];
|
||||
} else {
|
||||
flextype('entries')->entry_create_data['uuid'] = Uuid::uuid4()->toString();
|
||||
flextype('entries')->storage['create']['data']['uuid'] = Uuid::uuid4()->toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -15,18 +15,18 @@ if (flextype('registry')->get('flextype.settings.entries.fields.visibility.enabl
|
||||
];
|
||||
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function () use ($visibility) : void {
|
||||
if (isset(flextype('entries')->entry['visibility']) && in_array(flextype('entries')->entry['visibility'], $visibility)) {
|
||||
flextype('entries')->entry['visibility'] = (string) $visibility[flextype('entries')->entry['visibility']];
|
||||
if (isset(flextype('entries')->storage['fetch_single']['data']['visibility']) && in_array(flextype('entries')->storage['fetch_single']['data']['visibility'], $visibility)) {
|
||||
flextype('entries')->storage['fetch_single']['data']['visibility'] = (string) $visibility[flextype('entries')->storage['fetch_single']['data']['visibility']];
|
||||
} else {
|
||||
flextype('entries')->entry['visibility'] = (string) $visibility['visible'];
|
||||
flextype('entries')->storage['fetch_single']['data']['visibility'] = (string) $visibility['visible'];
|
||||
}
|
||||
});
|
||||
|
||||
flextype('emitter')->addListener('onEntryCreate', static function () use ($visibility) : void {
|
||||
if (isset(flextype('entries')->entry_create_data['visibility']) && in_array(flextype('entries')->entry_create_data['visibility'], $visibility)) {
|
||||
flextype('entries')->entry_create_data['visibility'] = flextype('entries')->entry_create_data['visibility'];
|
||||
if (isset(flextype('entries')->storage['create']['data']['visibility']) && in_array(flextype('entries')->storage['create']['data']['visibility'], $visibility)) {
|
||||
flextype('entries')->storage['create']['data']['visibility'] = flextype('entries')->storage['create']['data']['visibility'];
|
||||
} else {
|
||||
flextype('entries')->entry_create_data['visibility'] = 'visible';
|
||||
flextype('entries')->storage['create']['data']['visibility'] = 'visible';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user