mirror of
https://github.com/flextype/flextype.git
synced 2025-08-12 16:14:16 +02:00
feat(core): Flextype Solid Core - next round #458
This commit is contained in:
@@ -10,13 +10,13 @@ declare(strict_types=1);
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
if ($flextype->container('registry')->get('flextype.settings.entries.fields.created_at.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->container('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_id));
|
||||
});
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
$flextype->container('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 {
|
||||
|
@@ -8,7 +8,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
|
||||
if ($flextype->container('registry')->get('flextype.settings.entries.fields.created_by.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
$flextype->container('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 {
|
||||
|
@@ -8,7 +8,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
|
||||
if ($flextype->container('registry')->get('flextype.settings.entries.fields.id.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->container('emitter')->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['id'] = isset($flextype->entries->entry['id']) ? (string) $flextype->entries->entry['id'] : (string) ltrim(rtrim($flextype->entries->entry_id, '/'), '/');
|
||||
});
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ declare(strict_types=1);
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
if ($flextype->container('registry')->get('flextype.settings.entries.fields.modified_at.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->container('emitter')->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['modified_at'] = (int) Filesystem::getTimestamp($flextype->entries->getFileLocation($flextype->entries->entry_id));
|
||||
});
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ declare(strict_types=1);
|
||||
use Flextype\Component\Arrays\Arrays;
|
||||
|
||||
if ($flextype->container('registry')->get('flextype.settings.entries.fields.parsers.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->container('emitter')->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
processParsersField($flextype);
|
||||
});
|
||||
}
|
||||
|
@@ -10,13 +10,13 @@ declare(strict_types=1);
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
if ($flextype->container('registry')->get('flextype.settings.entries.fields.published_at.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->container('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_id));
|
||||
});
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
$flextype->container('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 {
|
||||
|
@@ -8,7 +8,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
|
||||
if ($flextype->container('registry')->get('flextype.settings.entries.fields.published_by.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
$flextype->container('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 {
|
||||
|
@@ -9,13 +9,13 @@ declare(strict_types=1);
|
||||
|
||||
|
||||
if ($flextype->container('registry')->get('flextype.settings.entries.fields.routable.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->container('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) : void {
|
||||
$flextype->container('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 {
|
||||
|
@@ -8,7 +8,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
|
||||
if ($flextype->container('registry')->get('flextype.settings.entries.fields.slug.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->container('emitter')->addListener('onEntryAfterInitialized', function () use ($flextype) : 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);
|
||||
});
|
||||
|
@@ -10,7 +10,7 @@ declare(strict_types=1);
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
if ($flextype->container('registry')->get('flextype.settings.entries.fields.uuid.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
$flextype->container('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 {
|
||||
|
@@ -14,7 +14,7 @@ if ($flextype->container('registry')->get('flextype.settings.entries.fields.visi
|
||||
'visible' => 'visible',
|
||||
];
|
||||
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype, $visibility) : void {
|
||||
$flextype->container('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 {
|
||||
@@ -22,7 +22,7 @@ if ($flextype->container('registry')->get('flextype.settings.entries.fields.visi
|
||||
}
|
||||
});
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype, $visibility) : void {
|
||||
$flextype->container('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 {
|
||||
|
@@ -373,7 +373,7 @@ class Plugins
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function includeEnabledPlugins($flextype, $flextype) : void
|
||||
private function includeEnabledPlugins($flextype) : void
|
||||
{
|
||||
if (! is_array($this->flextype->container('registry')->get('plugins')) || count($this->flextype->container('registry')->get('plugins')) <= 0) {
|
||||
return;
|
||||
|
@@ -18,11 +18,6 @@ class Shortcode
|
||||
*/
|
||||
protected $flextype;
|
||||
|
||||
/**
|
||||
* Application
|
||||
*/
|
||||
protected $flextype;
|
||||
|
||||
/**
|
||||
* Shortcode Fasade
|
||||
*/
|
||||
@@ -35,8 +30,7 @@ class Shortcode
|
||||
*/
|
||||
public function __construct($flextype, $shortcode)
|
||||
{
|
||||
$this->flextype = $flextype;
|
||||
$this->container = $flextype->getContainer();
|
||||
$this->flextype = $flextype;
|
||||
$this->shortcode = $shortcode;
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ use Flextype\Component\Arrays\Arrays;
|
||||
if ($flextype->container('registry')->get('flextype.settings.shortcode.shortcodes.entries.enabled')) {
|
||||
|
||||
// Shortcode: [entries_fetch id="entry-id" field="field-name" default="default-value"]
|
||||
$flextype['shortcode']->addHandler('entries_fetch', function (ShortcodeInterface $s) use ($flextype) {
|
||||
$flextype->container('shortcode')->addHandler('entries_fetch', function (ShortcodeInterface $s) use ($flextype) {
|
||||
return Arrays::get($flextype['entries']->fetch($s->getParameter('id')), $s->getParameter('field'), $s->getParameter('default'));
|
||||
});
|
||||
}
|
||||
|
@@ -14,9 +14,9 @@ use Thunder\Shortcode\Events;
|
||||
if ($flextype->container('registry')->get('flextype.settings.shortcode.shortcodes.raw.enabled')) {
|
||||
|
||||
// Shortcode: [raw]
|
||||
$flextype['shortcode']->addHandler('raw', function (ShortcodeInterface $s) use ($flextype) {
|
||||
$flextype->container('shortcode')->addHandler('raw', function (ShortcodeInterface $s) use ($flextype) {
|
||||
return $s->getContent();
|
||||
});
|
||||
|
||||
$flextype['shortcode']->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(['raw']));
|
||||
$flextype->container('shortcode')->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(['raw']));
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
if ($flextype->container('registry')->get('flextype.settings.shortcode.shortcodes.registry.enabled')) {
|
||||
|
||||
// Shortcode: [registry_get name="item-name" default="default-value"]
|
||||
$flextype['shortcode']->addHandler('registry_get', function (ShortcodeInterface $s) use ($flextype) {
|
||||
$flextype->container('shortcode')->addHandler('registry_get', function (ShortcodeInterface $s) use ($flextype) {
|
||||
return $flextype['registry']->get($s->getParameter('name'), $s->getParameter('default'));
|
||||
});
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ use Slim\Http\Uri;
|
||||
if ($flextype->container('registry')->get('flextype.settings.shortcode.shortcodes.url.enabled')) {
|
||||
|
||||
// Shortcode: [url]
|
||||
$flextype['shortcode']->addHandler('url', function () use ($flextype) {
|
||||
$flextype->container('shortcode')->addHandler('url', function () use ($flextype) {
|
||||
if ($flextype['registry']->has('flextype.settings.url') && $flextype['registry']->get('flextype.settings.url') !== '') {
|
||||
return $flextype['registry']->get('flextype.settings.url');
|
||||
}
|
||||
|
@@ -26,11 +26,6 @@ class Frontmatter
|
||||
*/
|
||||
protected $flextype;
|
||||
|
||||
/**
|
||||
* Application
|
||||
*/
|
||||
protected $flextype;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -38,8 +33,7 @@ class Frontmatter
|
||||
*/
|
||||
public function __construct($flextype)
|
||||
{
|
||||
$this->flextype = $flextype;
|
||||
$this->container = $flextype->getContainer();
|
||||
$this->flextype = $flextype;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,10 +82,10 @@ class Frontmatter
|
||||
if (isset($input['content'])) {
|
||||
$content = $input['content'];
|
||||
Arrays::delete($input, 'content');
|
||||
$matter = $this->container['yaml']->encode($input);
|
||||
$matter = $this->flextype->container('yaml')->encode($input);
|
||||
} else {
|
||||
$content = '';
|
||||
$matter = $this->container['yaml']->encode($input);
|
||||
$matter = $this->flextype->container('yaml')->encode($input);
|
||||
}
|
||||
|
||||
$encoded = '---' . "\n" .
|
||||
@@ -120,7 +114,7 @@ class Frontmatter
|
||||
return ['content' => trim($input)];
|
||||
}
|
||||
|
||||
return $this->container['yaml']->decode(trim($parts[1]), false) + ['content' => trim(implode(PHP_EOL . '---' . PHP_EOL, array_slice($parts, 2)))];
|
||||
return $this->flextype->container('yaml')->decode(trim($parts[1]), false) + ['content' => trim(implode(PHP_EOL . '---' . PHP_EOL, array_slice($parts, 2)))];
|
||||
}
|
||||
|
||||
protected function getCacheID($input)
|
||||
|
@@ -32,11 +32,6 @@ class Json
|
||||
*/
|
||||
protected $flextype;
|
||||
|
||||
/**
|
||||
* Application
|
||||
*/
|
||||
protected $flextype;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -44,8 +39,7 @@ class Json
|
||||
*/
|
||||
public function __construct($flextype)
|
||||
{
|
||||
$this->flextype = $flextype;
|
||||
$this->container = $flextype->getContainer();
|
||||
$this->flextype = $flextype;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -37,11 +37,6 @@ class Yaml
|
||||
*/
|
||||
protected $flextype;
|
||||
|
||||
/**
|
||||
* Application
|
||||
*/
|
||||
protected $flextype;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -50,7 +45,6 @@ class Yaml
|
||||
public function __construct($flextype)
|
||||
{
|
||||
$this->flextype = $flextype;
|
||||
$this->container = $flextype->getContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user