1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-10 07:06:45 +02:00

feat(parsers): code styles and format updates

This commit is contained in:
Awilum
2021-08-14 17:54:09 +03:00
parent 483654e134
commit 50bcf99d24
8 changed files with 30 additions and 18 deletions

View File

@@ -10,13 +10,14 @@ declare(strict_types=1);
namespace Flextype\Parsers;
use Exception;
use League\CommonMark\MarkdownConverter;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\Attributes\AttributesExtension;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\Table\TableExtension;
use League\CommonMark\MarkdownConverter;
use function flextype;
use function cache;
use function registry;
use function strings;
final class Markdown
@@ -132,4 +133,4 @@ final class Markdown
{
return strings('markdown' . $input)->hash()->toString();
}
}
}

View File

@@ -10,8 +10,6 @@ declare(strict_types=1);
namespace Flextype\Parsers;
use Atomastic\Macroable\Macroable;
use Flextype\Parsers\Shortcodes;
use Flextype\Parsers\Markdown;
class Parsers
{

View File

@@ -12,7 +12,11 @@ namespace Flextype\Parsers;
use Exception;
use Thunder\Shortcode\ShortcodeFacade;
use function flextype;
use function cache;
use function count;
use function file_exists;
use function is_array;
use function registry;
use function strings;
final class Shortcodes

View File

@@ -11,13 +11,16 @@ namespace Flextype\Parsers\Shortcodes;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
use function arrays;
use function content;
use function parsers;
use function registry;
// Shortcode: [content_fetch id="content-id" field="field-name" default="default-value"]
parsers()->shortcodes()->addHandler('content_fetch', static function (ShortcodeInterface $s) {
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.content.enabled')) {
return '';
}
return arrays(content()->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default'));
});

View File

@@ -11,13 +11,16 @@ namespace Flextype\Parsers\Shortcodes;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
use function arrays;
use function flextype;
use function parsers;
use function registry;
// Shortcode: [media_files_fetch id="media-id" field="field-name" default="default-value"]
parsers()->shortcodes()->addHandler('media_files_fetch', static function (ShortcodeInterface $s) {
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.media.enabled')) {
return '';
}
return arrays(flextype('media')->files()->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default'));
});

View File

@@ -13,10 +13,11 @@ use Thunder\Shortcode\EventHandler\FilterRawEventHandler;
use Thunder\Shortcode\Events;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
use function parsers;
// Shortcode: [raw]
parsers()->shortcodes()->addHandler('raw', static function (ShortcodeInterface $s) {
return $s->getContent();
});
parsers()->shortcodes()->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(['raw']));

View File

@@ -11,12 +11,14 @@ namespace Flextype\Parsers\Shortcodes;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
use function parsers;
use function registry;
// Shortcode: [registry_get name="item-name" default="default-value"]
parsers()->shortcodes()->addHandler('registry_get', static function (ShortcodeInterface $s) {
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.registry.enabled')) {
return '';
}
return registry()->get($s->getParameter('name'), $s->getParameter('default'));
});
});

View File

@@ -9,13 +9,13 @@ declare(strict_types=1);
namespace Flextype\Parsers\Shortcodes;
use Slim\Http\Environment;
use Slim\Http\Uri;
use function app;
use function parsers;
use function registry;
// Shortcode: [url]
parsers()->shortcodes()->addHandler('url', static function () {
if (!registry()->get('flextype.settings.parsers.shortcodes.shortcodes.url.enabled')) {
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.url.enabled')) {
return '';
}