mirror of
https://github.com/flextype/flextype.git
synced 2025-08-10 07:06:45 +02:00
refactor(entries-fields): code cleanup
This commit is contained in:
@@ -9,13 +9,13 @@ declare(strict_types=1);
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : 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_path));
|
||||
});
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
if (isset($flextype->entries->entry_create_data['created_at'])) {
|
||||
$flextype->entries->entry_create_data['created_at'] = $flextype->entries->entry_create_data['created_at'];
|
||||
} else {
|
||||
|
@@ -7,7 +7,7 @@ declare(strict_types=1);
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
if (isset($flextype->entries->entry_create_data['created_by'])) {
|
||||
$flextype->entries->entry_create_data['created_by'] = $flextype->entries->entry_create_data['created_by'];
|
||||
} else {
|
||||
|
@@ -9,6 +9,6 @@ declare(strict_types=1);
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['modified_at'] = (int) Filesystem::getTimestamp($flextype->entries->getFileLocation($flextype->entries->entry_path));
|
||||
});
|
||||
|
@@ -7,14 +7,13 @@ declare(strict_types=1);
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use Flextype\Component\Arrays\Arrays;
|
||||
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
processParsersField($flextype);
|
||||
});
|
||||
|
||||
function processParsersField($flextype)
|
||||
function processParsersField($flextype) : void
|
||||
{
|
||||
$cache = isset($flextype->entries->entry['cache']['enabled']) ?
|
||||
$flextype->entries->entry['cache']['enabled'] :
|
||||
|
@@ -9,13 +9,13 @@ declare(strict_types=1);
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : 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_path));
|
||||
});
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
if (isset($flextype->entries->entry_create_data['published_at'])) {
|
||||
$flextype->entries->entry_create_data['published_at'] = $flextype->entries->entry_create_data['published_at'];
|
||||
} else {
|
||||
|
@@ -7,7 +7,7 @@ declare(strict_types=1);
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
if (isset($flextype->entries->entry_create_data['published_by'])) {
|
||||
$flextype->entries->entry_create_data['published_by'] = $flextype->entries->entry_create_data['published_by'];
|
||||
} else {
|
||||
|
@@ -7,15 +7,14 @@ declare(strict_types=1);
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['routable'] = isset($flextype->entries->entry['routable']) ?
|
||||
(bool) $flextype->entries->entry['routable'] :
|
||||
true;
|
||||
});
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : 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'];
|
||||
} else {
|
||||
|
@@ -7,8 +7,7 @@ declare(strict_types=1);
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['slug'] = isset($flextype->entries->entry['slug']) ? (string) $flextype->entries->entry['slug'] : (string) ltrim(rtrim($flextype->entries->entry_path, '/'), '/');
|
||||
});
|
||||
|
@@ -7,10 +7,9 @@ declare(strict_types=1);
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) {
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
if (isset($flextype->entries->entry_create_data['uuid'])) {
|
||||
$flextype->entries->entry_create_data['uuid'] = $flextype->entries->entry_create_data['uuid'];
|
||||
} else {
|
||||
|
@@ -7,7 +7,6 @@ declare(strict_types=1);
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
$visibility = [
|
||||
'draft' => 'draft',
|
||||
@@ -15,7 +14,7 @@ $visibility = [
|
||||
'visible' => 'visible',
|
||||
];
|
||||
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype, $visibility) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype, $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']];
|
||||
} else {
|
||||
@@ -23,7 +22,7 @@ $flextype->emitter->addListener('onEntryAfterInitialized', function () use ($fle
|
||||
}
|
||||
});
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype, $visibility) {
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype, $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'];
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user