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

feat(media-folder): use Atomastic Arrays for entries_fetch shortcode. #478

This commit is contained in:
Awilum
2020-10-20 22:40:10 +03:00
parent c2218e7ab9
commit 8ddc94e450

View File

@@ -7,12 +7,11 @@ declare(strict_types=1);
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
use Flextype\Component\Arrays\Arrays;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
// Shortcode: [entries_fetch id="entry-id" field="field-name" default="default-value"]
if (flextype('registry')->get('flextype.settings.shortcode.shortcodes.entries.enabled')) {
flextype('shortcode')->addHandler('entries_fetch', static function (ShortcodeInterface $s) {
return Arrays::get(flextype('entries')->fetch($s->getParameter('id')), $s->getParameter('field'), $s->getParameter('default'));
return arrays(flextype('entries')->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default'));
});
}