1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 22:26:46 +02:00

refactor(entries-fields): update code according to coding doctrine coding standard

This commit is contained in:
Awilum
2020-09-07 20:53:54 +03:00
parent 57181fa764
commit 3bd087da81
11 changed files with 18 additions and 19 deletions

View File

@@ -10,13 +10,13 @@ declare(strict_types=1);
use Flextype\Component\Filesystem\Filesystem;
if (flextype('registry')->get('flextype.settings.entries.fields.created_at.enabled')) {
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
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 {
flextype('emitter')->addListener('onEntryCreate', static function (): void {
if (isset(flextype('entries')->storage['create']['data']['created_at'])) {
flextype('entries')->storage['create']['data']['created_at'] = flextype('entries')->storage['create']['data']['created_at'];
} else {

View File

@@ -8,7 +8,7 @@ declare(strict_types=1);
*/
if (flextype('registry')->get('flextype.settings.entries.fields.created_by.enabled')) {
flextype('emitter')->addListener('onEntryCreate', static function () : void {
flextype('emitter')->addListener('onEntryCreate', static function (): void {
if (isset(flextype('entries')->storage['create']['data']['created_by'])) {
flextype('entries')->storage['create']['data']['created_by'] = flextype('entries')->storage['create']['data']['created_by'];
} else {

View File

@@ -8,7 +8,7 @@ declare(strict_types=1);
*/
if (flextype('registry')->get('flextype.settings.entries.fields.id.enabled')) {
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
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'], '/'), '/');
});
}

View File

@@ -10,7 +10,7 @@ declare(strict_types=1);
use Flextype\Component\Filesystem\Filesystem;
if (flextype('registry')->get('flextype.settings.entries.fields.modified_at.enabled')) {
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
flextype('entries')->storage['fetch_single']['data']['modified_at'] = (int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->storage['fetch_single']['id']));
});
}

View File

@@ -10,12 +10,12 @@ declare(strict_types=1);
use Flextype\Component\Arrays\Arrays;
if (flextype('registry')->get('flextype.settings.entries.fields.parsers.enabled')) {
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
processParsersField();
});
}
function processParsersField() : void
function processParsersField(): void
{
$cache = flextype('entries')->storage['fetch_single']['data']['cache']['enabled'] ??
flextype('registry')->get('flextype.settings.cache.enabled');

View File

@@ -10,13 +10,13 @@ declare(strict_types=1);
use Flextype\Component\Filesystem\Filesystem;
if (flextype('registry')->get('flextype.settings.entries.fields.published_at.enabled')) {
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
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 {
flextype('emitter')->addListener('onEntryCreate', static function (): void {
if (isset(flextype('entries')->storage['create']['data']['published_at'])) {
flextype('entries')->storage['create']['data']['published_at'] = flextype('entries')->storage['create']['data']['published_at'];
} else {

View File

@@ -8,7 +8,7 @@ declare(strict_types=1);
*/
if (flextype('registry')->get('flextype.settings.entries.fields.published_by.enabled')) {
flextype('emitter')->addListener('onEntryCreate', static function () : void {
flextype('emitter')->addListener('onEntryCreate', static function (): void {
if (isset(flextype('entries')->storage['create']['data']['published_by'])) {
flextype('entries')->storage['create']['data']['published_by'] = flextype('entries')->storage['create']['data']['published_by'];
} else {

View File

@@ -9,13 +9,13 @@ declare(strict_types=1);
if (flextype('registry')->get('flextype.settings.entries.fields.routable.enabled')) {
flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void {
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
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 {
flextype('emitter')->addListener('onEntryCreate', static function (): void {
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 {

View File

@@ -8,9 +8,8 @@ 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')->storage['fetch_single']['id'], '/'), '/'));
flextype('entries')->storage['fetch_single']['data']['slug'] = isset(flextype('entries')->storage['fetch_single']['data']['slug']) ? (string) flextype('entries')->storage['fetch_single']['data']['slug']: (string) end($parts);
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
$parts = explode('/', ltrim(rtrim(flextype('entries')->storage['fetch_single']['id'], '/'), '/'));
flextype('entries')->storage['fetch_single']['data']['slug'] = isset(flextype('entries')->storage['fetch_single']['data']['slug']) ? (string) flextype('entries')->storage['fetch_single']['data']['slug'] : (string) end($parts);
});
}

View File

@@ -10,7 +10,7 @@ declare(strict_types=1);
use Ramsey\Uuid\Uuid;
if (flextype('registry')->get('flextype.settings.entries.fields.uuid.enabled')) {
flextype('emitter')->addListener('onEntryCreate', static function () : void {
flextype('emitter')->addListener('onEntryCreate', static function (): void {
if (isset(flextype('entries')->storage['create']['data']['uuid'])) {
flextype('entries')->storage['create']['data']['uuid'] = flextype('entries')->storage['create']['data']['uuid'];
} else {

View File

@@ -14,7 +14,7 @@ if (flextype('registry')->get('flextype.settings.entries.fields.visibility.enabl
'visible' => 'visible',
];
flextype('emitter')->addListener('onEntryAfterInitialized', static function () use ($visibility) : void {
flextype('emitter')->addListener('onEntryAfterInitialized', static function () use ($visibility): void {
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 {
@@ -22,7 +22,7 @@ if (flextype('registry')->get('flextype.settings.entries.fields.visibility.enabl
}
});
flextype('emitter')->addListener('onEntryCreate', static function () use ($visibility) : void {
flextype('emitter')->addListener('onEntryCreate', static function () use ($visibility): void {
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 {