mirror of
https://github.com/flextype/flextype.git
synced 2025-08-05 04:37:43 +02:00
refactor(core): code updates and improvements - doctrine
This commit is contained in:
@@ -6,4 +6,4 @@ use function Glowy\Filesystem\filesystem;
|
||||
|
||||
if (filesystem()->file(FLEXTYPE_PATH_PROJECT . '/bootstrap/after-plugins.php')->exists()) {
|
||||
require_once FLEXTYPE_PATH_PROJECT . '/bootstrap/after-plugins.php';
|
||||
}
|
||||
}
|
||||
|
@@ -6,4 +6,4 @@ use function Glowy\Filesystem\filesystem;
|
||||
|
||||
if (filesystem()->file(FLEXTYPE_PATH_PROJECT . '/bootstrap/before-plugins.php')->exists()) {
|
||||
require_once FLEXTYPE_PATH_PROJECT . '/bootstrap/before-plugins.php';
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -67,4 +67,4 @@ class Actions extends Collection
|
||||
public function __wakeup(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,20 +18,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Phpfastcache\Drivers\Phparray;
|
||||
|
||||
use Phpfastcache\Config\IOConfigurationOptionInterface;
|
||||
use Phpfastcache\Config\IOConfigurationOption;
|
||||
use Phpfastcache\Config\IOConfigurationOptionInterface;
|
||||
|
||||
class Config extends IOConfigurationOption implements IOConfigurationOptionInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $cacheFileExtension
|
||||
* @return self
|
||||
* @throws PhpfastcacheInvalidConfigurationException
|
||||
*/
|
||||
public function setCacheFileExtension(string $cacheFileExtension): static
|
||||
{
|
||||
$this->cacheFileExtension = 'php';
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,17 +16,25 @@ declare(strict_types=1);
|
||||
|
||||
namespace Phpfastcache\Drivers\Phparray;
|
||||
|
||||
use Exception;
|
||||
use FilesystemIterator;
|
||||
use Phpfastcache\Cluster\AggregatablePoolInterface;
|
||||
use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
|
||||
use Phpfastcache\Core\Pool\IO\IOHelperTrait;
|
||||
use Phpfastcache\Core\Item\ExtendedCacheItemInterface;
|
||||
use Phpfastcache\Core\Pool\IO\IOHelperTrait;
|
||||
use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException;
|
||||
use Phpfastcache\Exceptions\PhpfastcacheIOException;
|
||||
use Phpfastcache\Exceptions\PhpfastcacheLogicException;
|
||||
use Phpfastcache\Util\Directory;
|
||||
use Throwable;
|
||||
|
||||
use function clearstatcache;
|
||||
use function dirname;
|
||||
use function file_exists;
|
||||
use function Flextype\serializers;
|
||||
use function is_dir;
|
||||
use function is_writable;
|
||||
use function mkdir;
|
||||
use function rmdir;
|
||||
use function unlink;
|
||||
|
||||
/**
|
||||
* @method Config getConfig()
|
||||
@@ -39,8 +47,9 @@ class Driver implements AggregatablePoolInterface
|
||||
{
|
||||
use IOHelperTrait;
|
||||
|
||||
private static string $ext = 'php';
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws PhpfastcacheIOException
|
||||
* @throws PhpfastcacheInvalidArgumentException
|
||||
*/
|
||||
@@ -49,35 +58,32 @@ class Driver implements AggregatablePoolInterface
|
||||
return is_writable($this->getPath()) || mkdir($concurrentDirectory = $this->getPath(), $this->getDefaultChmod(), true) || is_dir($concurrentDirectory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function driverConnect(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ExtendedCacheItemInterface $item
|
||||
* @return ?array<string, mixed>
|
||||
*
|
||||
* @throws PhpfastcacheIOException
|
||||
*/
|
||||
protected function driverRead(ExtendedCacheItemInterface $item): ?array
|
||||
{
|
||||
$filePath = $this->getFilePath($item->getKey(), true);
|
||||
$filePath = $this->getFilePath($item->getKey(), true) . '.' . 'php';
|
||||
|
||||
try {
|
||||
$content = $this->readFile($filePath);
|
||||
} catch (PhpfastcacheIOException) {
|
||||
return null;
|
||||
}
|
||||
$value = null;
|
||||
|
||||
return $this->decode($content);
|
||||
set_error_handler(static function () {});
|
||||
|
||||
$value = include $filePath;
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
return ! is_bool($value) ? $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ExtendedCacheItemInterface $item
|
||||
* @return bool
|
||||
* @throws PhpfastcacheIOException
|
||||
* @throws PhpfastcacheInvalidArgumentException
|
||||
* @throws PhpfastcacheLogicException
|
||||
@@ -86,19 +92,17 @@ class Driver implements AggregatablePoolInterface
|
||||
{
|
||||
$this->assertCacheItemType($item, Item::class);
|
||||
|
||||
$filePath = $this->getFilePath($item->getKey());
|
||||
$data = $this->encode($this->driverPreWrap($item));
|
||||
$filePath = $this->getFilePath($item->getKey()) . '.' . 'php';
|
||||
$data = $this->driverPreWrap($item);
|
||||
|
||||
try {
|
||||
return $this->writeFile($filePath, serializers()->phparray()->encode($data), $this->getConfig()->isSecureFileManipulation(), $this->getConfig()->isSecureFileManipulation());
|
||||
} catch (Exception) {
|
||||
} catch (Throwable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ExtendedCacheItemInterface $item
|
||||
* @return bool
|
||||
* @throws PhpfastcacheIOException
|
||||
* @throws PhpfastcacheInvalidArgumentException
|
||||
*/
|
||||
@@ -106,13 +110,14 @@ class Driver implements AggregatablePoolInterface
|
||||
{
|
||||
$this->assertCacheItemType($item, Item::class);
|
||||
|
||||
$filePath = $this->getFilePath($item->getKey(), true);
|
||||
if (\file_exists($filePath) && @\unlink($filePath)) {
|
||||
\clearstatcache(true, $filePath);
|
||||
$dir = \dirname($filePath);
|
||||
if (!(new FilesystemIterator($dir))->valid()) {
|
||||
\rmdir($dir);
|
||||
$filePath = $this->getFilePath($item->getKey(), true) . '.' . 'php';;
|
||||
if (file_exists($filePath) && @unlink($filePath)) {
|
||||
clearstatcache(true, $filePath);
|
||||
$dir = dirname($filePath);
|
||||
if (! (new FilesystemIterator($dir))->valid()) {
|
||||
rmdir($dir);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -120,8 +125,7 @@ class Driver implements AggregatablePoolInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \Phpfastcache\Exceptions\PhpfastcacheIOException
|
||||
* @throws PhpfastcacheIOException
|
||||
* @throws PhpfastcacheInvalidArgumentException
|
||||
*/
|
||||
protected function driverClear(): bool
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -27,4 +27,4 @@ class Item implements ExtendedCacheItemInterface
|
||||
{
|
||||
return Driver::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -19,14 +19,19 @@ namespace Flextype\Console\Commands;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use function Thermage\breakline;
|
||||
|
||||
use function array_keys;
|
||||
use function Flextype\registry;
|
||||
use function get_loaded_extensions;
|
||||
use function implode;
|
||||
use function phpversion;
|
||||
use function Thermage\anchor;
|
||||
use function Thermage\breakline;
|
||||
use function Thermage\div;
|
||||
use function Thermage\span;
|
||||
use function Thermage\hr;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\registry;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
class AboutCommand extends Command
|
||||
{
|
||||
@@ -40,18 +45,17 @@ class AboutCommand extends Command
|
||||
{
|
||||
$output->write(
|
||||
renderToString(
|
||||
|
||||
hr('[b]Flextype[/b]', 'my-1') .
|
||||
hr('[b]Flextype[/b]', 'my-1') .
|
||||
div('[b][color=success]Version[/color][/b]: ' . registry()->get('flextype.manifest.version'), '') .
|
||||
div('[b][color=success]Author[/color][/b]', '') .
|
||||
div('[b][color=success] Name[/color][/b]: ' . registry()->get('flextype.manifest.author.name'), '') .
|
||||
div('[b][color=success] Email[/color][/b]: ' . registry()->get('flextype.manifest.author.email'), '') .
|
||||
div('[b][color=success] Url[/color][/b]: ' . anchor(registry()->get('flextype.manifest.author.url'))->href(registry()->get('flextype.manifest.author.url')), 'clearfix') . breakline() .
|
||||
|
||||
hr('[b]Plugins[/b]', 'my-1') .
|
||||
hr('[b]Plugins[/b]', 'my-1') .
|
||||
div('[b][color=success]Enabled[/color][/b]: ' . implode(', ', array_keys(registry()->get('plugins'))), '') .
|
||||
|
||||
hr('[b]Constants[/b]', 'my-1') .
|
||||
hr('[b]Constants[/b]', 'my-1') .
|
||||
div('[b][color=success]FLEXTYPE_PROJECT_NAME[/color][/b]: ' . FLEXTYPE_PROJECT_NAME, '') .
|
||||
div('[b][color=success]FLEXTYPE_ROOT_DIR[/color][/b]: ' . FLEXTYPE_ROOT_DIR, '') .
|
||||
div('[b][color=success]FLEXTYPE_PATH_PROJECT[/color][/b]: ' . FLEXTYPE_PATH_PROJECT, '') .
|
||||
@@ -61,12 +65,11 @@ class AboutCommand extends Command
|
||||
hr('[b]PHP Information[/b]', 'my-1') .
|
||||
div('[b][color=success]PHP Version[/color][/b]: ' . phpversion(), '') .
|
||||
div('[b][color=success]PHP Modules[/color][/b]: ' . implode(', ', get_loaded_extensions()), '')
|
||||
|
||||
|
||||
. PHP_EOL
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -19,10 +19,10 @@ namespace Flextype\Console\Commands\Cache;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
|
||||
class CacheClearCommand extends Command
|
||||
{
|
||||
@@ -40,16 +40,20 @@ class CacheClearCommand extends Command
|
||||
if (filesystem()->directory($path)->delete()) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('All items were successfully cleared from the cache.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'All items were successfully cleared from the cache.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache wasn\'t cleared.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Cache wasn\'t cleared.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::FAILURE;
|
||||
@@ -57,13 +61,15 @@ class CacheClearCommand extends Command
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache directory ' . $path . ' doesn\'t exist.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Cache directory ' . $path . ' doesn\'t exist.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::FAILURE;
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -19,10 +19,10 @@ namespace Flextype\Console\Commands\Cache;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
|
||||
class CacheClearConfigCommand extends Command
|
||||
{
|
||||
@@ -40,16 +40,20 @@ class CacheClearConfigCommand extends Command
|
||||
if (filesystem()->directory($configPath)->delete()) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Config were successfully cleared from the cache.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Config were successfully cleared from the cache.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Config cache wasn\'t cleared.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Config cache wasn\'t cleared.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::FAILURE;
|
||||
@@ -57,8 +61,10 @@ class CacheClearConfigCommand extends Command
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Config cache directory ' . $configPath . ' doesn\'t exist.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Config cache directory ' . $configPath . ' doesn\'t exist.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::FAILURE;
|
||||
@@ -66,4 +72,4 @@ class CacheClearConfigCommand extends Command
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,10 +20,10 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
|
||||
class CacheClearDataCommand extends Command
|
||||
{
|
||||
@@ -43,16 +43,20 @@ class CacheClearDataCommand extends Command
|
||||
if (filesystem()->directory($routesData)->delete()) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Data were successfully cleared from the cache.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Data were successfully cleared from the cache.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Data cache wasn\'t cleared.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Data cache wasn\'t cleared.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::FAILURE;
|
||||
@@ -60,8 +64,10 @@ class CacheClearDataCommand extends Command
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Data cache directory ' . $routesData . ' doesn\'t exist.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Data cache directory ' . $routesData . ' doesn\'t exist.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::FAILURE;
|
||||
@@ -69,4 +75,4 @@ class CacheClearDataCommand extends Command
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,10 +20,10 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
|
||||
class CacheClearRoutesCommand extends Command
|
||||
{
|
||||
@@ -43,16 +43,20 @@ class CacheClearRoutesCommand extends Command
|
||||
if (filesystem()->directory($routesPath)->delete()) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Routes were successfully cleared from the cache.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Routes were successfully cleared from the cache.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Routes cache wasn\'t cleared.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Routes cache wasn\'t cleared.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::FAILURE;
|
||||
@@ -60,8 +64,10 @@ class CacheClearRoutesCommand extends Command
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Routes cache directory ' . $routesPath . ' doesn\'t exist.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Routes cache directory ' . $routesPath . ' doesn\'t exist.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Command::FAILURE;
|
||||
@@ -69,4 +75,4 @@ class CacheClearRoutesCommand extends Command
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,12 +17,13 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Cache;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\cache;
|
||||
|
||||
class CacheDeleteCommand extends Command
|
||||
{
|
||||
@@ -40,19 +41,25 @@ class CacheDeleteCommand extends Command
|
||||
if (cache()->delete($key)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache item with key ' . $key . ' deleted.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Cache item with key ' . $key . ' deleted.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache item with key ' . $key . ' wasn\'t deleted.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Cache item with key ' . $key . ' wasn\'t deleted.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,13 +17,16 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Cache;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function Flextype\collectionFromString;
|
||||
use function implode;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\collectionFromString;
|
||||
use function Flextype\cache;
|
||||
use function trim;
|
||||
|
||||
class CacheDeleteMultipleCommand extends Command
|
||||
{
|
||||
@@ -37,7 +40,7 @@ class CacheDeleteMultipleCommand extends Command
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
if ($input->getArgument('keys')) {
|
||||
$keys = collectionFromString($input->getArgument('keys'), ',')->map(fn($key) => trim($key))->toArray();
|
||||
$keys = collectionFromString($input->getArgument('keys'), ',')->map(static fn ($key) => trim($key))->toArray();
|
||||
} else {
|
||||
$keys = [];
|
||||
}
|
||||
@@ -45,19 +48,25 @@ class CacheDeleteMultipleCommand extends Command
|
||||
if (cache()->deleteMultiple($keys)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache items with keys [b]' . implode('[/b], [b]', $keys) . '[/b] deleted.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Cache items with keys [b]' . implode('[/b], [b]', $keys) . '[/b] deleted.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache items with keys [b]' . implode('[/b], [b]', $keys) . '[/b] wasn\'t deleted.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Cache items with keys [b]' . implode('[/b], [b]', $keys) . '[/b] wasn\'t deleted.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,12 +17,13 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Cache;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\cache;
|
||||
|
||||
class CacheGetCommand extends Command
|
||||
{
|
||||
@@ -47,4 +48,4 @@ class CacheGetCommand extends Command
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,14 +17,14 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Cache;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function Flextype\collectionFromString;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
|
||||
class CacheGetMultipleCommand extends Command
|
||||
{
|
||||
@@ -50,7 +50,7 @@ class CacheGetMultipleCommand extends Command
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,9 +20,10 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\cache;
|
||||
|
||||
class CacheHasCommand extends Command
|
||||
{
|
||||
@@ -40,19 +41,25 @@ class CacheHasCommand extends Command
|
||||
if (cache()->has($key)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache item with key [b]' . $key . '[/b] exists.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Cache item with key [b]' . $key . '[/b] exists.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache item with key [b]' . $key . '[/b] doesn\'t exists.',
|
||||
'color-success px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Cache item with key [b]' . $key . '[/b] doesn\'t exists.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,12 +17,13 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Cache;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\cache;
|
||||
|
||||
class CacheSetCommand extends Command
|
||||
{
|
||||
@@ -44,19 +45,25 @@ class CacheSetCommand extends Command
|
||||
if (cache()->set($key, $value, $ttl)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache item with key ' . $key . ' created.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Cache item with key ' . $key . ' created.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache item with key ' . $key . ' wasn\'t created.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Cache item with key ' . $key . ' wasn\'t created.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,14 +17,18 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Cache;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use function array_keys;
|
||||
use function Flextype\cache;
|
||||
use function Flextype\serializers;
|
||||
use function Glowy\Strings\strings;
|
||||
use function implode;
|
||||
use function parse_str;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Strings\strings;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\cache;
|
||||
|
||||
class CacheSetMultipleCommand extends Command
|
||||
{
|
||||
@@ -49,19 +53,25 @@ class CacheSetMultipleCommand extends Command
|
||||
if (cache()->setMultiple($values, $ttl)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache items with keys [b]' . implode('[/b], [b]', array_keys($values)) . '[/b] created.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Cache items with keys [b]' . implode('[/b], [b]', array_keys($values)) . '[/b] created.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Cache items with keys [b]' . implode('[/b], [b]', array_keys($values)) . '[/b] wasn\'t created.',
|
||||
'color-success px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Cache items with keys [b]' . implode('[/b], [b]', array_keys($values)) . '[/b] wasn\'t created.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,10 +20,10 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\entries;
|
||||
|
||||
class EntriesCopyCommand extends Command
|
||||
{
|
||||
@@ -43,29 +43,38 @@ class EntriesCopyCommand extends Command
|
||||
if (! entries()->has($id)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
if (entries()->copy($id, $newID)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] coppied to [b]' . $newID . '[/b]',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] coppied to [b]' . $newID . '[/b]',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] wasn\'t coppied to [b]' . $newID . '[/b]',
|
||||
'color-success px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] wasn\'t coppied to [b]' . $newID . '[/b]',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,14 +17,16 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Entries;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Flextype\serializers;
|
||||
use function Glowy\Strings\strings;
|
||||
use function parse_str;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
|
||||
class EntriesCreateCommand extends Command
|
||||
{
|
||||
@@ -54,19 +56,25 @@ class EntriesCreateCommand extends Command
|
||||
if (entries()->create($id, $dataToSave)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] created.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] created.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] wasn\'t created.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] wasn\'t created.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,9 +20,10 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\entries;
|
||||
|
||||
class EntriesDeleteCommand extends Command
|
||||
{
|
||||
@@ -40,29 +41,38 @@ class EntriesDeleteCommand extends Command
|
||||
if (! entries()->has($id)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
if (entries()->delete($id)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] deleted.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] deleted.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] wasn\'t deleted.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] wasn\'t deleted.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,19 +17,23 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Entries;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use function Thermage\div;
|
||||
use function Thermage\span;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
use function array_push;
|
||||
use function count;
|
||||
use function Flextype\collection;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\collection;
|
||||
use function Glowy\Strings\strings;
|
||||
use function parse_str;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Thermage\span;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
class EntriesFetchCommand extends Command
|
||||
{
|
||||
@@ -75,7 +79,7 @@ class EntriesFetchCommand extends Command
|
||||
}
|
||||
|
||||
$input->getOption('collection') and $options['collection'] = true;
|
||||
|
||||
|
||||
if ($input->getOption('find-depth-from') || $input->getOption('find-depth-to')) {
|
||||
$options['find']['depth'] = [];
|
||||
$input->getOption('find-depth-from') and array_push($options['find']['depth'], $input->getOption('find-depth-from'));
|
||||
@@ -94,72 +98,76 @@ class EntriesFetchCommand extends Command
|
||||
$input->getOption('find-size-to') and array_push($options['find']['size'], $input->getOption('find-size-to'));
|
||||
}
|
||||
|
||||
$input->getOption('find-exclude') and $options['find']['exclude'] = $input->getOption('find-exclude');
|
||||
$input->getOption('find-contains') and $options['find']['contains'] = $input->getOption('find-contains');
|
||||
$input->getOption('find-not-contains') and $options['find']['not_contains'] = $input->getOption('find-not-contains');
|
||||
$input->getOption('find-path') and $options['find']['path'] = $input->getOption('find-path');
|
||||
$input->getOption('find-sort-by-key') and $options['find']['sort_by']['key'] = $input->getOption('find-sort-by-key');
|
||||
$input->getOption('find-exclude') and $options['find']['exclude'] = $input->getOption('find-exclude');
|
||||
$input->getOption('find-contains') and $options['find']['contains'] = $input->getOption('find-contains');
|
||||
$input->getOption('find-not-contains') and $options['find']['not_contains'] = $input->getOption('find-not-contains');
|
||||
$input->getOption('find-path') and $options['find']['path'] = $input->getOption('find-path');
|
||||
$input->getOption('find-sort-by-key') and $options['find']['sort_by']['key'] = $input->getOption('find-sort-by-key');
|
||||
$input->getOption('find-sort-by-direction') and $options['find']['sort_by']['direction'] = $input->getOption('find-sort-by-direction');
|
||||
|
||||
$input->getOption('filter-group-by') and $options['filter']['group_by'] = $input->getOption('filter-group-by');
|
||||
$input->getOption('filter-return') and $options['filter']['return'] = $input->getOption('filter-return');
|
||||
|
||||
$input->getOption('filter-return') and $options['filter']['return'] = $input->getOption('filter-return');
|
||||
|
||||
if ($input->getOption('filter-where')) {
|
||||
$filterWhere = $input->getOption('filter-where');
|
||||
|
||||
foreach ($filterWhere as $key => $value) {
|
||||
|
||||
foreach ($filterWhere as $key => $value) {
|
||||
if (strings($value)->isJson()) {
|
||||
$whereValues = serializers()->json()->decode($value);
|
||||
} else {
|
||||
parse_str($value, $whereValues);
|
||||
}
|
||||
|
||||
|
||||
$where[] = $whereValues;
|
||||
}
|
||||
|
||||
|
||||
$options['filter']['where'] = $where;
|
||||
}
|
||||
|
||||
$innerData = [];
|
||||
|
||||
$innerData = [];
|
||||
$innerDataString = '';
|
||||
|
||||
|
||||
$data = entries()->fetch($id, $options);
|
||||
|
||||
if (count($data) > 0) {
|
||||
if (isset($options['collection']) && $options['collection'] == true) {
|
||||
foreach ($data->toArray() as $item) {
|
||||
foreach(collection($item)->dot() as $key => $value) {
|
||||
$innerDataString .= renderToString(span('[b][color=success]' . $key . '[/color][/b]: ' . $value) . PHP_EOL);
|
||||
}
|
||||
$innerData[] = $innerDataString;
|
||||
$innerDataString = '';
|
||||
}
|
||||
} else {
|
||||
foreach(collection($data)->dot() as $key => $value) {
|
||||
$innerDataString .= renderToString(span('[b][color=success]' . $key . '[/color][/b]: ' . $value) . PHP_EOL);
|
||||
}
|
||||
$innerData[] = $innerDataString;
|
||||
$innerDataString = '';
|
||||
}
|
||||
|
||||
foreach ($innerData as $item) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div($item, 'px-2 border-square border-color-success')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
if (count($data) <= 0) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
if (isset($options['collection']) && $options['collection'] === true) {
|
||||
foreach ($data->toArray() as $item) {
|
||||
foreach (collection($item)->dot() as $key => $value) {
|
||||
$innerDataString .= renderToString(span('[b][color=success]' . $key . '[/color][/b]: ' . $value) . PHP_EOL);
|
||||
}
|
||||
|
||||
$innerData[] = $innerDataString;
|
||||
$innerDataString = '';
|
||||
}
|
||||
} else {
|
||||
foreach (collection($data)->dot() as $key => $value) {
|
||||
$innerDataString .= renderToString(span('[b][color=success]' . $key . '[/color][/b]: ' . $value) . PHP_EOL);
|
||||
}
|
||||
|
||||
$innerData[] = $innerDataString;
|
||||
$innerDataString = '';
|
||||
}
|
||||
|
||||
foreach ($innerData as $item) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div($item, 'px-2 border-square border-color-success')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,10 +20,10 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\entries;
|
||||
|
||||
class EntriesHasCommand extends Command
|
||||
{
|
||||
@@ -41,19 +41,25 @@ class EntriesHasCommand extends Command
|
||||
if (entries()->has($id)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] exists.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] exists.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,9 +20,10 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\entries;
|
||||
|
||||
class EntriesMoveCommand extends Command
|
||||
{
|
||||
@@ -42,29 +43,38 @@ class EntriesMoveCommand extends Command
|
||||
if (! entries()->has($id)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
if (entries()->move($id, $newID)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] moved to [b]' . $newID . '[/b]',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] moved to [b]' . $newID . '[/b]',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] wasn\'t moved to [b]' . $newID . '[/b]',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] wasn\'t moved to [b]' . $newID . '[/b]',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,11 +20,13 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Flextype\serializers;
|
||||
use function Glowy\Strings\strings;
|
||||
use function parse_str;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
|
||||
class EntriesUpdateCommand extends Command
|
||||
{
|
||||
@@ -54,29 +56,38 @@ class EntriesUpdateCommand extends Command
|
||||
if (! entries()->has($id)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
|
||||
if (entries()->update($id, $dataToSave)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] updated.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] updated.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Entry [b]' . $id . '[/b] wasn\'t updated.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Entry [b]' . $id . '[/b] wasn\'t updated.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,17 +17,19 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Tokens;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use function array_merge;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\generateToken;
|
||||
use function Flextype\generateTokenHash;
|
||||
use function Flextype\serializers;
|
||||
use function Glowy\Strings\strings;
|
||||
use function parse_str;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Strings\strings;
|
||||
use function Flextype\generateToken;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\generateTokenHash;
|
||||
|
||||
|
||||
class TokensCreateCommand extends Command
|
||||
{
|
||||
@@ -61,19 +63,25 @@ class TokensCreateCommand extends Command
|
||||
if (entries()->create('tokens/' . $token, array_merge($dataToSave, ['hashed_access_token' => $hashed_access_token]))) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token [b]' . $token . '[/b] with secret access token [b]' . $access_token . '[/b] created.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Token [b]' . $token . '[/b] with secret access token [b]' . $access_token . '[/b] created.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token wasn\'t created.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Token wasn\'t created.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,9 +20,10 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\entries;
|
||||
|
||||
class TokensDeleteCommand extends Command
|
||||
{
|
||||
@@ -40,29 +41,38 @@ class TokensDeleteCommand extends Command
|
||||
if (! entries()->has($id)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Token entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
if (entries()->delete($id)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token entry [b]' . $id . '[/b] deleted.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Token entry [b]' . $id . '[/b] deleted.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token entry [b]' . $id . '[/b] wasn\'t deleted.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Token entry [b]' . $id . '[/b] wasn\'t deleted.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,19 +17,23 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Tokens;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use function Thermage\div;
|
||||
use function Thermage\span;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Strings\strings;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\entries;
|
||||
|
||||
use function array_push;
|
||||
use function count;
|
||||
use function Flextype\collection;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\serializers;
|
||||
use function Glowy\Strings\strings;
|
||||
use function parse_str;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Thermage\span;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
class TokensFetchCommand extends Command
|
||||
{
|
||||
@@ -75,7 +79,7 @@ class TokensFetchCommand extends Command
|
||||
}
|
||||
|
||||
$input->getOption('collection') and $options['collection'] = true;
|
||||
|
||||
|
||||
if ($input->getOption('find-depth-from') || $input->getOption('find-depth-to')) {
|
||||
$options['find']['depth'] = [];
|
||||
$input->getOption('find-depth-from') and array_push($options['find']['depth'], $input->getOption('find-depth-from'));
|
||||
@@ -94,72 +98,76 @@ class TokensFetchCommand extends Command
|
||||
$input->getOption('find-size-to') and array_push($options['find']['size'], $input->getOption('find-size-to'));
|
||||
}
|
||||
|
||||
$input->getOption('find-exclude') and $options['find']['exclude'] = $input->getOption('find-exclude');
|
||||
$input->getOption('find-contains') and $options['find']['contains'] = $input->getOption('find-contains');
|
||||
$input->getOption('find-not-contains') and $options['find']['not_contains'] = $input->getOption('find-not-contains');
|
||||
$input->getOption('find-path') and $options['find']['path'] = $input->getOption('find-path');
|
||||
$input->getOption('find-sort-by-key') and $options['find']['sort_by']['key'] = $input->getOption('find-sort-by-key');
|
||||
$input->getOption('find-exclude') and $options['find']['exclude'] = $input->getOption('find-exclude');
|
||||
$input->getOption('find-contains') and $options['find']['contains'] = $input->getOption('find-contains');
|
||||
$input->getOption('find-not-contains') and $options['find']['not_contains'] = $input->getOption('find-not-contains');
|
||||
$input->getOption('find-path') and $options['find']['path'] = $input->getOption('find-path');
|
||||
$input->getOption('find-sort-by-key') and $options['find']['sort_by']['key'] = $input->getOption('find-sort-by-key');
|
||||
$input->getOption('find-sort-by-direction') and $options['find']['sort_by']['direction'] = $input->getOption('find-sort-by-direction');
|
||||
|
||||
$input->getOption('filter-group-by') and $options['filter']['group_by'] = $input->getOption('filter-group-by');
|
||||
$input->getOption('filter-return') and $options['filter']['return'] = $input->getOption('filter-return');
|
||||
|
||||
$input->getOption('filter-return') and $options['filter']['return'] = $input->getOption('filter-return');
|
||||
|
||||
if ($input->getOption('filter-where')) {
|
||||
$filterWhere = $input->getOption('filter-where');
|
||||
|
||||
foreach ($filterWhere as $key => $value) {
|
||||
|
||||
foreach ($filterWhere as $key => $value) {
|
||||
if (strings($value)->isJson()) {
|
||||
$whereValues = serializers()->json()->decode($value);
|
||||
} else {
|
||||
parse_str($value, $whereValues);
|
||||
}
|
||||
|
||||
|
||||
$where[] = $whereValues;
|
||||
}
|
||||
|
||||
|
||||
$options['filter']['where'] = $where;
|
||||
}
|
||||
|
||||
$innerData = [];
|
||||
|
||||
$innerData = [];
|
||||
$innerDataString = '';
|
||||
|
||||
|
||||
$data = entries()->fetch('tokens/' . $id, $options);
|
||||
|
||||
if (count($data) > 0) {
|
||||
if (isset($options['collection']) && $options['collection'] == true) {
|
||||
foreach ($data->toArray() as $item) {
|
||||
foreach(collection($item)->dot() as $key => $value) {
|
||||
$innerDataString .= renderToString(span('[b][color=success]' . $key . '[/color][/b]: ' . $value) . PHP_EOL);
|
||||
}
|
||||
$innerData[] = $innerDataString;
|
||||
$innerDataString = '';
|
||||
}
|
||||
} else {
|
||||
foreach(collection($data)->dot() as $key => $value) {
|
||||
$innerDataString .= renderToString(span('[b][color=success]' . $key . '[/color][/b]: ' . $value) . PHP_EOL);
|
||||
}
|
||||
$innerData[] = $innerDataString;
|
||||
$innerDataString = '';
|
||||
}
|
||||
|
||||
foreach ($innerData as $item) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div($item, 'px-2 border-square border-color-success')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
if (count($data) <= 0) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Token entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
if (isset($options['collection']) && $options['collection'] === true) {
|
||||
foreach ($data->toArray() as $item) {
|
||||
foreach (collection($item)->dot() as $key => $value) {
|
||||
$innerDataString .= renderToString(span('[b][color=success]' . $key . '[/color][/b]: ' . $value) . PHP_EOL);
|
||||
}
|
||||
|
||||
$innerData[] = $innerDataString;
|
||||
$innerDataString = '';
|
||||
}
|
||||
} else {
|
||||
foreach (collection($data)->dot() as $key => $value) {
|
||||
$innerDataString .= renderToString(span('[b][color=success]' . $key . '[/color][/b]: ' . $value) . PHP_EOL);
|
||||
}
|
||||
|
||||
$innerData[] = $innerDataString;
|
||||
$innerDataString = '';
|
||||
}
|
||||
|
||||
foreach ($innerData as $item) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div($item, 'px-2 border-square border-color-success')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,12 +17,13 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Tokens;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use function Flextype\generateToken;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\generateToken;
|
||||
|
||||
class TokensGenerateCommand extends Command
|
||||
{
|
||||
@@ -37,11 +38,13 @@ class TokensGenerateCommand extends Command
|
||||
{
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token [b]' . generateToken($input->getArgument('length') ?? 16) . '[/b] generated.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Token [b]' . generateToken($input->getArgument('length') ?? 16) . '[/b] generated.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,13 +17,14 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Tokens;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
|
||||
use function Flextype\generateToken;
|
||||
use function Flextype\generateTokenHash;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
|
||||
class TokensGenerateHashCommand extends Command
|
||||
{
|
||||
@@ -40,11 +41,13 @@ class TokensGenerateHashCommand extends Command
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Hash [b]' . generateTokenHash($token) . '[/b] for token [b]' . $token . '[/b] generated.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Hash [b]' . generateTokenHash($token) . '[/b] for token [b]' . $token . '[/b] generated.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,10 +20,10 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\entries;
|
||||
|
||||
class TokensHasCommand extends Command
|
||||
{
|
||||
@@ -41,19 +41,25 @@ class TokensHasCommand extends Command
|
||||
if (entries()->has($id)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token entry [b]' . $id . '[/b] exists.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Token entry [b]' . $id . '[/b] exists.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Token entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -20,11 +20,13 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Flextype\serializers;
|
||||
use function Glowy\Strings\strings;
|
||||
use function parse_str;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Glowy\Strings\strings;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\entries;
|
||||
|
||||
class TokensUpdateCommand extends Command
|
||||
{
|
||||
@@ -54,29 +56,38 @@ class TokensUpdateCommand extends Command
|
||||
if (! entries()->has($id)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1')
|
||||
div(
|
||||
'Token entry [b]' . $id . '[/b] doesn\'t exists.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
|
||||
if (entries()->update($id, $dataToSave)) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token entry [b]' . $id . '[/b] updated.',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Token entry [b]' . $id . '[/b] updated.',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token entry [b]' . $id . '[/b] wasn\'t updated.',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Token entry [b]' . $id . '[/b] wasn\'t updated.',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,13 +17,14 @@ declare(strict_types=1);
|
||||
namespace Flextype\Console\Commands\Tokens;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
use function dd;
|
||||
use function Flextype\verifyTokenHash;
|
||||
use function Thermage\div;
|
||||
use function Thermage\renderToString;
|
||||
use function Flextype\verifyTokenHash;
|
||||
|
||||
class TokensVerifyHashCommand extends Command
|
||||
{
|
||||
@@ -41,21 +42,25 @@ class TokensVerifyHashCommand extends Command
|
||||
if (verifyTokenHash($input->getArgument('token'), $input->getArgument('token-hash'))) {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token [b]' . $input->getArgument('token') . ' is verified',
|
||||
'color-success px-2 py-1')
|
||||
div(
|
||||
'Token [b]' . $input->getArgument('token') . ' is verified',
|
||||
'color-success px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->write(
|
||||
renderToString(
|
||||
div('Token [b]' . $input->getArgument('token') . ' isn\'t verified',
|
||||
'color-danger px-2 py-1')
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$output->write(
|
||||
renderToString(
|
||||
div(
|
||||
'Token [b]' . $input->getArgument('token') . ' isn\'t verified',
|
||||
'color-danger px-2 py-1'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,43 +16,42 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Console;
|
||||
|
||||
use Symfony\Component\Console\Application as ConsoleApplication;
|
||||
use Flextype\Console\Commands\AboutCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesCreateCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesFetchCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesUpdateCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesDeleteCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesCopyCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesMoveCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesHasCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheDeleteCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheSetCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheGetCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheGetMultipleCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheSetMultipleCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheDeleteMultipleCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheClearCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheClearRoutesCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheClearConfigCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheClearDataCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheClearRoutesCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheDeleteCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheDeleteMultipleCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheGetCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheGetMultipleCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheHasCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheSetCommand;
|
||||
use Flextype\Console\Commands\Cache\CacheSetMultipleCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesCopyCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesCreateCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesDeleteCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesFetchCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesHasCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesMoveCommand;
|
||||
use Flextype\Console\Commands\Entries\EntriesUpdateCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensCreateCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensDeleteCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensFetchCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensGenerateCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensGenerateHashCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensVerifyHashCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensCreateCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensFetchCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensUpdateCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensDeleteCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensCopyCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensMoveCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensHasCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensUpdateCommand;
|
||||
use Flextype\Console\Commands\Tokens\TokensVerifyHashCommand;
|
||||
use Symfony\Component\Console\Application as ConsoleApplication;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use function Flextype\console;
|
||||
|
||||
class FlextypeConsole extends ConsoleApplication
|
||||
{
|
||||
public function run(InputInterface $input = null, OutputInterface $output = null): int
|
||||
public function run(?InputInterface $input = null, ?OutputInterface $output = null): int
|
||||
{
|
||||
// Add Console Commands
|
||||
console()->add(new AboutCommand());
|
||||
@@ -85,4 +84,4 @@ class FlextypeConsole extends ConsoleApplication
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -21,13 +21,12 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use function array_keys;
|
||||
use function array_merge;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function is_string;
|
||||
use function password_verify;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\verifyTokenHash;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\entries;
|
||||
use function in_array;
|
||||
use function is_string;
|
||||
|
||||
class Api
|
||||
{
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -19,8 +19,8 @@ namespace Flextype\Endpoints;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function count;
|
||||
use function Flextype\entries;
|
||||
|
||||
class Entries extends Api
|
||||
{
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -19,12 +19,12 @@ namespace Flextype\Endpoints;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
use function array_merge;
|
||||
use function count;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\generateToken;
|
||||
use function Flextype\generateTokenHash;
|
||||
use function Flextype\verifyTokenHash;
|
||||
use function Flextype\entries;
|
||||
|
||||
class Tokens extends Api
|
||||
{
|
||||
@@ -68,9 +68,9 @@ class Tokens extends Api
|
||||
{
|
||||
// Get Request Parsed Body
|
||||
$requestParsedBody = $request->getParsedBody();
|
||||
|
||||
|
||||
// Validate Api Request
|
||||
if (
|
||||
if (
|
||||
count($result = $this->validateApiRequest([
|
||||
'request' => $request,
|
||||
'api' => 'tokens',
|
||||
@@ -99,9 +99,9 @@ class Tokens extends Api
|
||||
{
|
||||
// Get Request Parsed Body
|
||||
$requestParsedBody = $request->getParsedBody();
|
||||
|
||||
|
||||
// Validate Api Request
|
||||
if (
|
||||
if (
|
||||
count($result = $this->validateApiRequest([
|
||||
'request' => $request,
|
||||
'api' => 'tokens',
|
||||
@@ -225,7 +225,7 @@ class Tokens extends Api
|
||||
|
||||
// Fetch entry
|
||||
$entryData = entries()->fetch('tokens/' . $requestParsedBody['id'])->toArray();
|
||||
|
||||
|
||||
// Return response
|
||||
if (count($entryData) > 0) {
|
||||
return $this->getApiResponse($response, $entryData, 200);
|
||||
@@ -234,7 +234,6 @@ class Tokens extends Api
|
||||
return $this->getApiResponse($response, [], 404);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete token entry.
|
||||
*
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -14,15 +14,13 @@ declare(strict_types=1);
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*/
|
||||
|
||||
use Glowy\Arrays\Arrays as Collection;
|
||||
use function Flextype\emitter;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\expression;
|
||||
use function Flextype\registry;
|
||||
|
||||
// Directive: [[ ]]
|
||||
emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
|
||||
if (! registry()->get('flextype.settings.entries.directives.expressions.enabled')) {
|
||||
return;
|
||||
}
|
||||
@@ -36,13 +34,13 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
$closingTag = registry()->get('flextype.settings.entries.directives.expressions.closing_tag');
|
||||
|
||||
$field = entries()->registry()->get('methods.fetch.field');
|
||||
|
||||
|
||||
if (is_string($field['value'])) {
|
||||
$field['value'] = preg_replace_callback('/' . $selfQuote($openingTag) . ' (.*?) ' . $selfQuote($closingTag) . '/s', function($matches) {
|
||||
$field['value'] = preg_replace_callback('/' . $selfQuote($openingTag) . ' (.*?) ' . $selfQuote($closingTag) . '/s', function ($matches) {
|
||||
return expression()->evaluate($matches[1]);
|
||||
}, $field['value']);
|
||||
}
|
||||
|
||||
entries()->registry()->set('methods.fetch.field.key', $field['key']);
|
||||
entries()->registry()->set('methods.fetch.field.value', $field['value']);
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -14,23 +14,21 @@ declare(strict_types=1);
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*/
|
||||
|
||||
use Glowy\Arrays\Arrays as Collection;
|
||||
use function Glowy\Strings\strings;
|
||||
use function Flextype\emitter;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
// Directive: @markdown
|
||||
emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
|
||||
if (! registry()->get('flextype.settings.entries.directives.markdown.enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Save markdown cache state to restore it later
|
||||
$markdownCacheState = registry()->get('flextype.settings.parsers.markdown.cache');
|
||||
|
||||
|
||||
// Set markdown cache to false
|
||||
registry()->set('flextype.settings.parsers.markdown.cache', false);
|
||||
|
||||
@@ -43,10 +41,10 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
$field['value'] = parsers()->markdown()->parse($field['value']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
entries()->registry()->set('methods.fetch.field.key', $field['key']);
|
||||
entries()->registry()->set('methods.fetch.field.value', $field['value']);
|
||||
|
||||
// Restore markdown cache state
|
||||
registry()->set('flextype.settings.parsers.markdown.cache', $markdownCacheState);
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -14,15 +14,13 @@ declare(strict_types=1);
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*/
|
||||
|
||||
use Glowy\Arrays\Arrays as Collection;
|
||||
use function Glowy\Strings\strings;
|
||||
use function Flextype\emitter;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
// Directive: @php
|
||||
emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
|
||||
if (! registry()->get('flextype.settings.entries.directives.php.enabled')) {
|
||||
return;
|
||||
}
|
||||
@@ -40,7 +38,7 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
$field['value'] = ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
entries()->registry()->set('methods.fetch.field.key', $field['key']);
|
||||
entries()->registry()->set('methods.fetch.field.value', $field['value']);
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -14,28 +14,26 @@ declare(strict_types=1);
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*/
|
||||
|
||||
use Glowy\Arrays\Arrays as Collection;
|
||||
use function Glowy\Strings\strings;
|
||||
use function Flextype\emitter;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
// Directive: @shortcodes
|
||||
emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
|
||||
if (! registry()->get('flextype.settings.entries.directives.shortcodes.enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Save shortcodes cache state to restore it later
|
||||
$shortcodesCacheState = registry()->get('flextype.settings.parsers.shortcodes.cache');
|
||||
|
||||
|
||||
// Set shortcodes cache to false
|
||||
registry()->set('flextype.settings.parsers.shortcodes.cache', false);
|
||||
|
||||
$field = entries()->registry()->get('methods.fetch.field');
|
||||
|
||||
|
||||
if (is_string($field['value'])) {
|
||||
if (strings($field['value'])->contains('@shortcodes')) {
|
||||
$field['value'] = strings(parsers()->shortcodes()->parse($field['value']))->replace('@shortcodes', '')->trim()->toString();
|
||||
@@ -49,4 +47,4 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
|
||||
// Restore shortcodes cache state
|
||||
registry()->set('flextype.settings.parsers.shortcodes.cache', $shortcodesCacheState);
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -14,23 +14,21 @@ declare(strict_types=1);
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*/
|
||||
|
||||
use Glowy\Arrays\Arrays as Collection;
|
||||
use function Glowy\Strings\strings;
|
||||
use function Flextype\emitter;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
// Directive: @textile
|
||||
emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
|
||||
if (! registry()->get('flextype.settings.entries.directives.textile.enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Save textile cache state to restore it later
|
||||
$textileCacheState = registry()->get('flextype.settings.parsers.textile.cache');
|
||||
|
||||
|
||||
// Set textile cache to false
|
||||
registry()->set('flextype.settings.parsers.textile.cache', false);
|
||||
|
||||
@@ -43,10 +41,10 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
$field['value'] = parsers()->textile()->parse($field['value']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
entries()->registry()->set('methods.fetch.field.key', $field['key']);
|
||||
entries()->registry()->set('methods.fetch.field.value', $field['value']);
|
||||
|
||||
// Restore textile cache state
|
||||
registry()->set('flextype.settings.parsers.textile.cache', $textileCacheState);
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -14,22 +14,20 @@ declare(strict_types=1);
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*/
|
||||
|
||||
use Glowy\Arrays\Arrays as Collection;
|
||||
use function Glowy\Strings\strings;
|
||||
use function Flextype\collection;
|
||||
use function Flextype\collectionFromQueryString;
|
||||
use function Flextype\emitter;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\collectionFromQueryString;
|
||||
use function Flextype\collection;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
// Directive: @type[]
|
||||
emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
|
||||
if (! registry()->get('flextype.settings.entries.directives.types.enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$field = entries()->registry()->get('methods.fetch.field');
|
||||
|
||||
if (is_string($field['value'])) {
|
||||
@@ -73,4 +71,4 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void {
|
||||
|
||||
entries()->registry()->set('methods.fetch.field.key', $field['key']);
|
||||
entries()->registry()->set('methods.fetch.field.value', $field['value']);
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,14 +18,13 @@ namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\actions;
|
||||
|
||||
class ActionsExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('actions', fn() => '\Flextype\actions()', fn($arguments) => actions())
|
||||
];
|
||||
return [new ExpressionFunction('actions', static fn () => '\Flextype\actions()', static fn ($arguments) => actions())];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,11 +18,12 @@ namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\collection;
|
||||
use function Flextype\collectionFromJson;
|
||||
use function Flextype\collectionFromQueryString;
|
||||
use function Flextype\collectionFromString;
|
||||
use function Flextype\collectionWithRange;
|
||||
use function Flextype\collectionFromQueryString;
|
||||
use function Flextype\filterCollection;
|
||||
|
||||
class CollectionExpression implements ExpressionFunctionProviderInterface
|
||||
@@ -30,12 +31,12 @@ class CollectionExpression implements ExpressionFunctionProviderInterface
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('collection', fn($items = null) => '\Flextype\collection($items)', fn($arguments, $items = null) => collection($items)),
|
||||
new ExpressionFunction('collectionFromJson', fn(string $input, bool $assoc = true, int $depth = 512, int $flags = 0) => '\Flextype\ccollectionFromJson($input, $assoc, $depth, $flags)', fn($arguments, string $input, bool $assoc = true, int $depth = 512, int $flags = 0) => collectionFromJson($input, $assoc, $depth, $flags)),
|
||||
new ExpressionFunction('collectionFromString', fn(string $string, string $separator) => '\Flextype\collectionFromString($string, $separator)', fn($arguments, string $string, string $separator) => collectionFromString($string, $separator)),
|
||||
new ExpressionFunction('collectionWithRange', fn($low, $high, int $step = 1) => '\Flextype\collectionWithRange($low, $high, $step)', fn($arguments, $low, $high, int $step = 1) => collectionWithRange($low, $high, $step)),
|
||||
new ExpressionFunction('collectionFromQueryString', fn(string $string) => '\Flextype\collectionFromQueryString($string)', fn($arguments, string $string) => collectionFromQueryString($string)),
|
||||
new ExpressionFunction('filterCollection', fn($items = [], array $options = []) => '\Flextype\filterCollection($items, $options)', fn($arguments, $items = [], array $options = []) => filterCollection($items, $options)),
|
||||
new ExpressionFunction('collection', static fn ($items = null) => '\Flextype\collection($items)', static fn ($arguments, $items = null) => collection($items)),
|
||||
new ExpressionFunction('collectionFromJson', static fn (string $input, bool $assoc = true, int $depth = 512, int $flags = 0) => '\Flextype\ccollectionFromJson($input, $assoc, $depth, $flags)', static fn ($arguments, string $input, bool $assoc = true, int $depth = 512, int $flags = 0) => collectionFromJson($input, $assoc, $depth, $flags)),
|
||||
new ExpressionFunction('collectionFromString', static fn (string $string, string $separator) => '\Flextype\collectionFromString($string, $separator)', static fn ($arguments, string $string, string $separator) => collectionFromString($string, $separator)),
|
||||
new ExpressionFunction('collectionWithRange', static fn ($low, $high, int $step = 1) => '\Flextype\collectionWithRange($low, $high, $step)', static fn ($arguments, $low, $high, int $step = 1) => collectionWithRange($low, $high, $step)),
|
||||
new ExpressionFunction('collectionFromQueryString', static fn (string $string) => '\Flextype\collectionFromQueryString($string)', static fn ($arguments, string $string) => collectionFromQueryString($string)),
|
||||
new ExpressionFunction('filterCollection', static fn ($items = [], array $options = []) => '\Flextype\filterCollection($items, $options)', static fn ($arguments, $items = [], array $options = []) => filterCollection($items, $options)),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -19,12 +19,13 @@ namespace Flextype\Entries\Expressions;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function constant;
|
||||
use function defined;
|
||||
|
||||
class ConstExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('const', fn(string $const) => "defined($const) ? constant($const) : ''", fn($arguments, string $const) => defined($const) ? constant($const) : '')
|
||||
];
|
||||
return [new ExpressionFunction('const', static fn (string $const) => "defined($const) ? constant($const) : ''", static fn ($arguments, string $const) => defined($const) ? constant($const) : '')];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,14 +18,13 @@ namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\csrf;
|
||||
|
||||
class CsrfExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('csrf', fn() => '<input type="hidden" name="' . csrf()->getTokenName() . '" value="' . csrf()->getTokenValue() . '">', fn() => '<input type="hidden" name="' . csrf()->getTokenName() . '" value="' . csrf()->getTokenValue() . '">')
|
||||
];
|
||||
return [new ExpressionFunction('csrf', static fn () => '<input type="hidden" name="' . csrf()->getTokenName() . '" value="' . csrf()->getTokenValue() . '">', static fn () => '<input type="hidden" name="' . csrf()->getTokenName() . '" value="' . csrf()->getTokenValue() . '">')];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,19 +16,18 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
use Glowy\Arrays\Arrays as Collection;
|
||||
use Glowy\Macroable\Macroable;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\entries;
|
||||
|
||||
class EntriesExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('entries', fn() => '(new EntriesTwigExpressionsMethods())', fn($arguments) => (new EntriesTwigExpressionsMethods()))
|
||||
];
|
||||
return [new ExpressionFunction('entries', static fn () => '(new EntriesTwigExpressionsMethods())', static fn ($arguments) => (new EntriesTwigExpressionsMethods()))];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +41,9 @@ class EntriesTwigExpressionsMethods
|
||||
* @param string $id Unique identifier of the entry.
|
||||
* @param array $options Options array.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return self Returns instance of The Arrays class.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function fetch(string $id, array $options = []): Collection
|
||||
{
|
||||
@@ -76,4 +75,4 @@ class EntriesTwigExpressionsMethods
|
||||
{
|
||||
return entries()->entries->has($id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,14 +18,13 @@ namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\entries;
|
||||
|
||||
class FieldExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('field', fn(string $field) => "\Flextype\entries()->registry()->get('methods.fetch.result.' . $field . ')'", fn($arguments, string $field) => entries()->registry()->get('methods.fetch.result.' . $field))
|
||||
];
|
||||
return [new ExpressionFunction('field', static fn (string $field) => "\Flextype\entries()->registry()->get('methods.fetch.result.' . $field . ')'", static fn ($arguments, string $field) => entries()->registry()->get('methods.fetch.result.' . $field))];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,20 +16,18 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Glowy\Macroable\Macroable;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Glowy\Arrays\Arrays as Collection;
|
||||
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
use Glowy\Macroable\Macroable;
|
||||
|
||||
class FilesystemExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('filesystem', fn() => '(new FilesystemExpressionMethods())', fn($arguments) => (new FilesystemExpressionMethods()))
|
||||
];
|
||||
return [new ExpressionFunction('filesystem', static fn () => '(new FilesystemExpressionMethods())', static fn ($arguments) => (new FilesystemExpressionMethods()))];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,10 +117,8 @@ class FilesystemFileExpressionMethods
|
||||
* Path property
|
||||
*
|
||||
* Current file absolute path
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $path;
|
||||
public ?string $path = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -139,7 +135,7 @@ class FilesystemFileExpressionMethods
|
||||
*
|
||||
* @return string|false The file contents or false on failure.
|
||||
*/
|
||||
public function get()
|
||||
public function get(): string|false
|
||||
{
|
||||
return filesystem()->file($this->path)->get();
|
||||
}
|
||||
@@ -293,10 +289,8 @@ class FilesystemDirectoryExpressionMethods
|
||||
* Path property
|
||||
*
|
||||
* Current directory path.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $path;
|
||||
public ?string $path = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,6 +18,7 @@ namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\__;
|
||||
|
||||
class I18nExpression implements ExpressionFunctionProviderInterface
|
||||
@@ -25,8 +26,8 @@ class I18nExpression implements ExpressionFunctionProviderInterface
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('tr', fn(string $translate, array $values = [], string $locale = null) => '\Flextype\__($translate, $values, $locale)', fn($arguments, string $translate, array $values = [], string $locale = null) => __($translate, $values, $locale)),
|
||||
new ExpressionFunction('__', fn(string $translate, array $values = [], string $locale = null) => '\Flextype\__($translate, $values, $locale)', fn($arguments, string $translate, array $values = [], string $locale = null) => __($translate, $values, $locale)),
|
||||
new ExpressionFunction('tr', static fn (string $translate, array $values = [], ?string $locale = null) => '\Flextype\__($translate, $values, $locale)', static fn ($arguments, string $translate, array $values = [], ?string $locale = null) => __($translate, $values, $locale)),
|
||||
new ExpressionFunction('__', static fn (string $translate, array $values = [], ?string $locale = null) => '\Flextype\__($translate, $values, $locale)', static fn ($arguments, string $translate, array $values = [], ?string $locale = null) => __($translate, $values, $locale)),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,14 +18,13 @@ namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\parsers;
|
||||
|
||||
class ParsersExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('parsers', fn() => '\Flextype\parsers()', fn($arguments) => parsers())
|
||||
];
|
||||
return [new ExpressionFunction('parsers', static fn () => '\Flextype\parsers()', static fn ($arguments) => parsers())];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,14 +18,13 @@ namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\registry;
|
||||
|
||||
class RegistryExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('registry', fn() => '\Flextype\registry()', fn($arguments) => registry())
|
||||
];
|
||||
return [new ExpressionFunction('registry', static fn () => '\Flextype\registry()', static fn ($arguments) => registry())];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,14 +18,13 @@ namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\serializers;
|
||||
|
||||
class SerializersExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('serializers', fn() => '\Flextype\serializers()', fn($arguments) => serializers())
|
||||
];
|
||||
return [new ExpressionFunction('serializers', static fn () => '\Flextype\serializers()', static fn ($arguments) => serializers())];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,14 +18,13 @@ namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\slugify;
|
||||
|
||||
class SlugifyExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('slugify', fn() => '\Flextype\slugify()', fn($arguments) => slugify())
|
||||
];
|
||||
return [new ExpressionFunction('slugify', static fn () => '\Flextype\slugify()', static fn ($arguments) => slugify())];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,16 +16,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Entries\Expressions;
|
||||
|
||||
use function Glowy\Strings\strings;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
class StringsExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('strings', fn($str) => '\Glowy\Strings\strings($str)', fn($arguments, $str) => strings($str))
|
||||
];
|
||||
return [new ExpressionFunction('strings', static fn ($str) => '\Glowy\Strings\strings($str)', static fn ($arguments, $str) => strings($str))];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,34 +16,36 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
use function Flextype\urlFor;
|
||||
|
||||
use function Flextype\fullUrlFor;
|
||||
use function Flextype\isCurrentUrl;
|
||||
use function Flextype\getCurrentUrl;
|
||||
use function Flextype\getAbsoluteUrl;
|
||||
use function Flextype\getBasePath;
|
||||
use function Flextype\getBaseUrl;
|
||||
use function Flextype\getAbsoluteUrl;
|
||||
use function Flextype\getCurrentUrl;
|
||||
use function Flextype\getProjectUrl;
|
||||
use function Flextype\getUriString;
|
||||
use function Flextype\isCurrentUrl;
|
||||
use function Flextype\redirect;
|
||||
use function Flextype\urlFor;
|
||||
|
||||
class UrlExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('urlFor', fn(string $routeName, array $data = [], array $queryParams = []) => '\Flextype\urlFor($routeName, $data, $queryParams)', fn(string $routeName, array $data = [], array $queryParams = []) => urlFor($routeName, $data, $queryParams)),
|
||||
new ExpressionFunction('fullUrlFor', fn(\Psr\Http\Message\ServerRequestInterface $request, string $routeName, array $data = [], array $queryParams = []) => '\Flextype\fullUrlFor($request, $routeName, $data, $queryParams)', fn(\Psr\Http\Message\ServerRequestInterface $request, string $routeName, array $data = [], array $queryParams = []) => fullUrlFor($request, $routeName, $data = [], $queryParams = [])),
|
||||
new ExpressionFunction('isCurrentUrl', fn(\Psr\Http\Message\ServerRequestInterface $request, string $routeName, array $data = []) => '\Flextype\isCurrentUrl($request, $routeName, $data)', fn(\Psr\Http\Message\ServerRequestInterface $request, string $routeName, array $data = []) => isCurrentUrl($request, $routeName, $data = [])),
|
||||
new ExpressionFunction('getCurrentUrl', fn(\Psr\Http\Message\ServerRequestInterface $request, bool $withQueryString = false) => '\Flextype\getCurrentUrl($request, $withQueryString)', fn(\Psr\Http\Message\ServerRequestInterface $request, bool $withQueryString = false) => getCurrentUrl($request, $withQueryString)),
|
||||
new ExpressionFunction('getBasePath', fn() => '\Flextype\getBasePath()', fn() => getBasePath()),
|
||||
new ExpressionFunction('getBaseUrl', fn() => '\Flextype\getBaseUrl()', fn() => getBaseUrl()),
|
||||
new ExpressionFunction('getAbsoluteUrl', fn() => '\Flextype\getAbsoluteUrl()', fn() => getAbsoluteUrl()),
|
||||
new ExpressionFunction('getProjectUrl', fn() => '\Flextype\getProjectUrl()', fn() => getProjectUrl()),
|
||||
new ExpressionFunction('getUriString', fn() => '\Flextype\getUriString()', fn() => getUriString()),
|
||||
new ExpressionFunction('redirect', fn(string $routeName, array $data = [], array $queryParams = [], int $status = 301) => '\Flextype\redirect($routeName, $data, $queryParams, $status)', fn(string $routeName, array $data = [], array $queryParams = [], int $status = 301) => redirect($routeName, $data, $queryParams, $status))
|
||||
new ExpressionFunction('urlFor', static fn (string $routeName, array $data = [], array $queryParams = []) => '\Flextype\urlFor($routeName, $data, $queryParams)', static fn (string $routeName, array $data = [], array $queryParams = []) => urlFor($routeName, $data, $queryParams)),
|
||||
new ExpressionFunction('fullUrlFor', static fn (ServerRequestInterface $request, string $routeName, array $data = [], array $queryParams = []) => '\Flextype\fullUrlFor($request, $routeName, $data, $queryParams)', static fn (ServerRequestInterface $request, string $routeName, array $data = [], array $queryParams = []) => fullUrlFor($request, $routeName, $data = [], $queryParams = [])),
|
||||
new ExpressionFunction('isCurrentUrl', static fn (ServerRequestInterface $request, string $routeName, array $data = []) => '\Flextype\isCurrentUrl($request, $routeName, $data)', static fn (ServerRequestInterface $request, string $routeName, array $data = []) => isCurrentUrl($request, $routeName, $data = [])),
|
||||
new ExpressionFunction('getCurrentUrl', static fn (ServerRequestInterface $request, bool $withQueryString = false) => '\Flextype\getCurrentUrl($request, $withQueryString)', static fn (ServerRequestInterface $request, bool $withQueryString = false) => getCurrentUrl($request, $withQueryString)),
|
||||
new ExpressionFunction('getBasePath', static fn () => '\Flextype\getBasePath()', static fn () => getBasePath()),
|
||||
new ExpressionFunction('getBaseUrl', static fn () => '\Flextype\getBaseUrl()', static fn () => getBaseUrl()),
|
||||
new ExpressionFunction('getAbsoluteUrl', static fn () => '\Flextype\getAbsoluteUrl()', static fn () => getAbsoluteUrl()),
|
||||
new ExpressionFunction('getProjectUrl', static fn () => '\Flextype\getProjectUrl()', static fn () => getProjectUrl()),
|
||||
new ExpressionFunction('getUriString', static fn () => '\Flextype\getUriString()', static fn () => getUriString()),
|
||||
new ExpressionFunction('redirect', static fn (string $routeName, array $data = [], array $queryParams = [], int $status = 301) => '\Flextype\redirect($routeName, $data, $queryParams, $status)', static fn (string $routeName, array $data = [], array $queryParams = [], int $status = 301) => redirect($routeName, $data, $queryParams, $status)),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,14 +18,13 @@ namespace Flextype\Entries\Expressions;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\entries;
|
||||
|
||||
class VarExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('var', fn(string $var) => "\Flextype\entries()->registry()->get('methods.fetch.result.vars.' . $var . ')'", fn($arguments, string $var) => entries()->registry()->get('methods.fetch.result.vars.' . $var))
|
||||
];
|
||||
return [new ExpressionFunction('var', static fn (string $var) => "\Flextype\entries()->registry()->get('methods.fetch.result.vars.' . $var . ')'", static fn ($arguments, string $var) => entries()->registry()->get('methods.fetch.result.vars.' . $var))];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -31,22 +31,16 @@ final class Flextype
|
||||
|
||||
/**
|
||||
* The Flextype instance.
|
||||
*
|
||||
* @var Flextype|null
|
||||
*/
|
||||
private static Flextype|null $instance = null;
|
||||
|
||||
/**
|
||||
* The Flextype Application.
|
||||
*
|
||||
* @var App
|
||||
*/
|
||||
private static App $app;
|
||||
|
||||
/**
|
||||
* The Flextype Application Container.
|
||||
*
|
||||
* @var Container
|
||||
*/
|
||||
private static Container $container;
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,6 +16,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use function strtr;
|
||||
|
||||
class I18n
|
||||
{
|
||||
/**
|
||||
@@ -23,14 +25,12 @@ class I18n
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $dictionary = [];
|
||||
public static array $dictionary = [];
|
||||
|
||||
/**
|
||||
* Default locale
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $locale = 'en_US';
|
||||
public static string $locale = 'en_US';
|
||||
|
||||
/**
|
||||
* Add translation keys
|
||||
@@ -43,16 +43,15 @@ class I18n
|
||||
*
|
||||
* @param string $translates Translation keys and values to add
|
||||
* @param string $locale Locale
|
||||
* @return void
|
||||
*/
|
||||
public static function add(array $translates, string $locale = null) : void
|
||||
public static function add(array $translates, ?string $locale = null): void
|
||||
{
|
||||
$locale = ($locale === null) ? I18n::$locale : $locale;
|
||||
$locale ??= self::$locale;
|
||||
|
||||
if (isset(I18n::$dictionary[$locale])) {
|
||||
I18n::$dictionary[$locale] += $translates;
|
||||
if (isset(self::$dictionary[$locale])) {
|
||||
self::$dictionary[$locale] += $translates;
|
||||
} else {
|
||||
I18n::$dictionary[$locale] = $translates;
|
||||
self::$dictionary[$locale] = $translates;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,15 +65,14 @@ class I18n
|
||||
* @param string $translate Translate to find
|
||||
* @param array $values Values to replace in the translated text
|
||||
* @param string $locale Locale
|
||||
* @return string
|
||||
*/
|
||||
public static function find(string $translate, array $values = [], string $locale = null) : string
|
||||
public static function find(string $translate, array $values = [], ?string $locale = null): string
|
||||
{
|
||||
$locale = ($locale === null) ? I18n::$locale : $locale;
|
||||
$locale ??= self::$locale;
|
||||
|
||||
// Search current string to translate in the Dictionary
|
||||
if (isset(I18n::$dictionary[$locale][$translate])) {
|
||||
$translate = I18n::$dictionary[$locale][$translate];
|
||||
if (isset(self::$dictionary[$locale][$translate])) {
|
||||
$translate = self::$dictionary[$locale][$translate];
|
||||
$translate = empty($values) ? $translate : strtr($translate, $values);
|
||||
} else {
|
||||
$translate = $translate;
|
||||
@@ -83,4 +81,4 @@ class I18n
|
||||
// Return translation of a string
|
||||
return $translate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -19,6 +19,7 @@ namespace Flextype\Middlewares;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
|
||||
use Slim\Psr7\Response;
|
||||
|
||||
use function Flextype\csrf;
|
||||
|
||||
class CsrfMiddleware
|
||||
@@ -28,22 +29,21 @@ class CsrfMiddleware
|
||||
*
|
||||
* @param ServerRequest $request PSR-7 request
|
||||
* @param RequestHandler $handler PSR-15 request handler
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function __invoke(Request $request, RequestHandler $handler): Response
|
||||
{
|
||||
$response = $handler->handle($request);
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
if (isset($data[csrf()->getTokenName()])) {
|
||||
if (csrf()->isValid($data[csrf()->getTokenName()])) {
|
||||
return $response;
|
||||
} else {
|
||||
$response = new Response();
|
||||
$response->getBody()->write('This looks like a cross-site request forgery!');
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response = new Response();
|
||||
$response->getBody()->write('This looks like a cross-site request forgery!');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,15 +16,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Middlewares;
|
||||
|
||||
use Flextype\Whoops;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Flextype\Whoops;
|
||||
|
||||
class WhoopsMiddleware implements MiddlewareInterface
|
||||
class WhoopsMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
protected $settings = [];
|
||||
protected $handlers = [];
|
||||
|
||||
@@ -34,7 +33,7 @@ class WhoopsMiddleware implements MiddlewareInterface
|
||||
* @param array $settings
|
||||
* @param array $handlers
|
||||
*/
|
||||
public function __construct(array $settings = [], array $handlers = [])
|
||||
public function __construct(array $settings = [], array $handlers = [])
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->handlers = $handlers;
|
||||
@@ -42,12 +41,8 @@ class WhoopsMiddleware implements MiddlewareInterface
|
||||
|
||||
/**
|
||||
* Handle the requests
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
* @param RequestHandlerInterface $handler
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$whoopsGuard = new Whoops($this->settings);
|
||||
$whoopsGuard->setRequest($request);
|
||||
@@ -56,5 +51,4 @@ class WhoopsMiddleware implements MiddlewareInterface
|
||||
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -107,7 +107,7 @@ final class Markdown
|
||||
*
|
||||
* @return mixed The MARKDOWN converted to a PHP value
|
||||
*/
|
||||
public function parse(string $input)
|
||||
public function parse(string $input): mixed
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.parsers.markdown.cache.enabled');
|
||||
|
||||
@@ -130,7 +130,7 @@ final class Markdown
|
||||
/**
|
||||
* Get Cache ID for markdown.
|
||||
*
|
||||
* @param string $input Input.
|
||||
* @param string $input Input.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,17 +17,16 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers;
|
||||
|
||||
use Exception;
|
||||
|
||||
use Thunder\Shortcode\Parser\RegularParser;
|
||||
use Thunder\Shortcode\ShortcodeFacade;
|
||||
use Thunder\Shortcode\Syntax\Syntax;
|
||||
use Thunder\Shortcode\Parser\RegularParser;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function count;
|
||||
use function file_exists;
|
||||
use function is_array;
|
||||
use function Flextype\cache;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
use function is_array;
|
||||
|
||||
final class Shortcodes
|
||||
{
|
||||
@@ -62,15 +61,17 @@ final class Shortcodes
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
$settings = registry()->get('flextype.settings.parsers.shortcodes');
|
||||
$settings = registry()->get('flextype.settings.parsers.shortcodes');
|
||||
$this->shortcodeFacade = new ShortcodeFacade();
|
||||
$this->shortcodeFacade->setParser((new RegularParser((new Syntax($settings['opening_tag'],
|
||||
$settings['closing_tag'],
|
||||
$settings['closing_tag_marker'],
|
||||
$settings['parameter_value_separator'],
|
||||
$settings['parameter_value_delimiter'])))));
|
||||
$this->shortcodeFacade->setParser((new RegularParser((new Syntax(
|
||||
$settings['opening_tag'],
|
||||
$settings['closing_tag'],
|
||||
$settings['closing_tag_marker'],
|
||||
$settings['parameter_value_separator'],
|
||||
$settings['parameter_value_delimiter']
|
||||
)))));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the instance via lazy initialization (created on first usage).
|
||||
*/
|
||||
@@ -93,10 +94,8 @@ final class Shortcodes
|
||||
|
||||
/**
|
||||
* Init Shortcodes
|
||||
*
|
||||
*
|
||||
* @param array $shortcodes Shortcodes to init.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initShortcodes(array $shortcodes): void
|
||||
{
|
||||
@@ -193,9 +192,9 @@ final class Shortcodes
|
||||
/**
|
||||
* Get Cache ID for shortcode.
|
||||
*
|
||||
* @param string $input Input.
|
||||
* @param string $input Input.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,9 +17,10 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use function Flextype\registry;
|
||||
|
||||
use function Flextype\expression;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
|
||||
// Shortcode: calc
|
||||
// Usage: (calc:2+2)
|
||||
@@ -27,6 +28,6 @@ parsers()->shortcodes()->addHandler('calc', static function (ShortcodeInterface
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.calc.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
return expression()->evaluate(parsers()->shortcodes()->parse($s->getBBCode()));
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,11 +17,14 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use function Flextype\registry;
|
||||
|
||||
use function constant;
|
||||
use function defined;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
|
||||
// Shortcode: const
|
||||
// Usage: (const:PROJECT_DIR)
|
||||
// Usage: (const:PROJECT_DIR)
|
||||
parsers()->shortcodes()->addHandler('const', static function (ShortcodeInterface $s) {
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.const.enabled')) {
|
||||
return '';
|
||||
@@ -29,8 +32,9 @@ parsers()->shortcodes()->addHandler('const', static function (ShortcodeInterface
|
||||
|
||||
if ($s->getBBCode() !== null) {
|
||||
$const = parsers()->shortcodes()->parse($s->getBBCode());
|
||||
|
||||
return defined($const) ? constant($const) : '';
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,14 +17,15 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use Flextype\Entries\Entries;
|
||||
|
||||
use function array_keys;
|
||||
use function Flextype\collection;
|
||||
use function Flextype\collectionFromJson;
|
||||
use function Flextype\entries;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\collection;
|
||||
use function Flextype\collectionFromJson;
|
||||
use function Glowy\Strings\strings;
|
||||
use function parse_str;
|
||||
|
||||
// Shortcode: entries
|
||||
// Usage: (entries fetch:'blog/post-1' field:'title')
|
||||
@@ -35,11 +36,12 @@ parsers()->shortcodes()->addHandler('entries', static function (ShortcodeInterfa
|
||||
|
||||
$result = '';
|
||||
$params = $s->getParameters();
|
||||
|
||||
if (collection(array_keys($params))->filter(fn ($v) => $v == 'fetch')->count() > 0 &&
|
||||
isset($params['id']) &&
|
||||
registry()->get('flextype.settings.parsers.shortcodes.shortcodes.entries.fetch.enabled') === true) {
|
||||
|
||||
if (
|
||||
collection(array_keys($params))->filter(static fn ($v) => $v === 'fetch')->count() > 0 &&
|
||||
isset($params['id']) &&
|
||||
registry()->get('flextype.settings.parsers.shortcodes.shortcodes.entries.fetch.enabled') === true
|
||||
) {
|
||||
$id = parsers()->shortcodes()->parse($params['id']);
|
||||
|
||||
// Set options
|
||||
@@ -50,24 +52,25 @@ parsers()->shortcodes()->addHandler('entries', static function (ShortcodeInterfa
|
||||
}
|
||||
|
||||
// Prepare options
|
||||
$options = collection($options)->dot()->map(function($value) {
|
||||
if(strings($value)->isInteger()) {
|
||||
$options = collection($options)->dot()->map(static function ($value) {
|
||||
if (strings($value)->isInteger()) {
|
||||
$value = strings($value)->toInteger();
|
||||
} elseif(strings($value)->isFloat()) {
|
||||
} elseif (strings($value)->isFloat()) {
|
||||
$value = strings($value)->toFloat();
|
||||
} elseif(strings($value)->isBoolean()) {
|
||||
} elseif (strings($value)->isBoolean()) {
|
||||
$value = strings($value)->toBoolean();
|
||||
} elseif(strings($value)->isNull()) {
|
||||
} elseif (strings($value)->isNull()) {
|
||||
$value = strings($value)->toNull();
|
||||
} else {
|
||||
$value = (string) $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
})->undot()->toArray();
|
||||
|
||||
|
||||
// Backup current entry data
|
||||
$original = entries()->registry()['methods.fetch'];
|
||||
|
||||
|
||||
// Fetch entry
|
||||
$result = entries()->fetch($id, $options);
|
||||
|
||||
@@ -78,10 +81,10 @@ parsers()->shortcodes()->addHandler('entries', static function (ShortcodeInterfa
|
||||
$result = $result->toJson();
|
||||
|
||||
// Get specific field value
|
||||
if ($s->getParameter('field') != null) {
|
||||
$result = collectionFromJson($result)->get(parsers()->shortcodes()->parse($s->getParameter('field')), ($s->getParameter('default') != null) ? parsers()->shortcodes()->parse($s->getParameter('default')) : '');
|
||||
if ($s->getParameter('field') !== null) {
|
||||
$result = collectionFromJson($result)->get(parsers()->shortcodes()->parse($s->getParameter('field')), $s->getParameter('default') !== null ? parsers()->shortcodes()->parse($s->getParameter('default')) : '');
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,24 +17,25 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use function Flextype\registry;
|
||||
|
||||
use function Flextype\expression;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
|
||||
// Shortcode: eval
|
||||
// Usage: (eval:2+2)
|
||||
// Usage: (eval:2+2)
|
||||
// (eval)2+2(/eval)
|
||||
// (eval)registry.get('flextype.manifest.version')(/eval)
|
||||
// (eval)registry.get('flextype.manifest.version')(/eval)
|
||||
parsers()->shortcodes()->addHandler('eval', static function (ShortcodeInterface $s) {
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.eval.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($s->getContent() != null) {
|
||||
if ($s->getContent() !== null) {
|
||||
return expression()->evaluate(parsers()->shortcodes()->parse($s->getContent()));
|
||||
}
|
||||
|
||||
if ($s->getBbCode() != null) {
|
||||
if ($s->getBbCode() !== null) {
|
||||
return expression()->evaluate(parsers()->shortcodes()->parse($s->getBBCode()));
|
||||
}
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,9 +17,10 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\parsers;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
|
||||
// Shortcode: field
|
||||
// Usage: (field:title)
|
||||
@@ -27,6 +28,6 @@ parsers()->shortcodes()->addHandler('field', static function (ShortcodeInterface
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.field.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
return entries()->registry()->get('methods.fetch.result.' . parsers()->shortcodes()->parse($s->getBBCode()));
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,10 +17,12 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
|
||||
use function array_keys;
|
||||
use function Flextype\collection;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\collection;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
|
||||
// Shortcode: filesystem
|
||||
// Usage: (filesystem get file:'1.txt)
|
||||
@@ -31,14 +33,15 @@ parsers()->shortcodes()->addHandler('filesystem', static function (ShortcodeInte
|
||||
|
||||
$params = $s->getParameters();
|
||||
|
||||
if (collection(array_keys($params))->filter(fn ($v) => $v == 'get')->count() > 0 &&
|
||||
isset($params['file']) &&
|
||||
registry()->get('flextype.settings.parsers.shortcodes.shortcodes.filesystem.get.enabled') === true) {
|
||||
|
||||
if (
|
||||
collection(array_keys($params))->filter(static fn ($v) => $v === 'get')->count() > 0 &&
|
||||
isset($params['file']) &&
|
||||
registry()->get('flextype.settings.parsers.shortcodes.shortcodes.filesystem.get.enabled') === true
|
||||
) {
|
||||
$file = parsers()->shortcodes()->parse($params['file']);
|
||||
|
||||
return filesystem()->file($file)->exists() ? filesystem()->file($file)->get() : '';
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,10 +18,10 @@ namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
use function Flextype\__;
|
||||
use function Flextype\collectionFromQueryString;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\collectionFromQueryString;
|
||||
use function Flextype\__;
|
||||
|
||||
// Shortcode: tr
|
||||
// Usage: (tr:foo values='foo=Foo' locale:'en_US')
|
||||
@@ -30,13 +30,13 @@ parsers()->shortcodes()->addHandler('tr', static function (ShortcodeInterface $s
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($s->getBbCode() != null) {
|
||||
if ($s->getBbCode() !== null) {
|
||||
$translate = parsers()->shortcodes()->parse($s->getBbCode());
|
||||
$values = ($s->getParameter('values') != null) ? collectionFromQueryString(parsers()->shortcodes()->parse($s->getParameter('values')))->toArray() : [];
|
||||
$locale = ($s->getParameter('locale') != null) ? parsers()->shortcodes()->parse($s->getParameter('locale')) : null;
|
||||
|
||||
$values = $s->getParameter('values') !== null ? collectionFromQueryString(parsers()->shortcodes()->parse($s->getParameter('values')))->toArray() : [];
|
||||
$locale = $s->getParameter('locale') !== null ? parsers()->shortcodes()->parse($s->getParameter('locale')) : null;
|
||||
|
||||
return __($translate, $values, $locale);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,11 +17,10 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
|
||||
use function Flextype\expression;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\expression;
|
||||
|
||||
// Shortcode: if
|
||||
// Usage: (if:'(var:score) < (var:level1)') Show something... (/if)
|
||||
@@ -30,5 +29,5 @@ parsers()->shortcodes()->addHandler('if', static function (ShortcodeInterface $s
|
||||
return '';
|
||||
}
|
||||
|
||||
return expression()->evaluate(parsers()->shortcodes()->parse((($s->getBbCode() != null) ? $s->getBbCode() : ''))) === true ? parsers()->shortcodes()->parse($s->getContent()) : '';
|
||||
});
|
||||
return expression()->evaluate(parsers()->shortcodes()->parse(($s->getBbCode() ?? ''))) === true ? parsers()->shortcodes()->parse($s->getContent()) : '';
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,6 +17,7 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
|
||||
@@ -27,10 +28,10 @@ parsers()->shortcodes()->addHandler('markdown', static function (ShortcodeInterf
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.markdown.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($s->getContent() != null) {
|
||||
|
||||
if ($s->getContent() !== null) {
|
||||
return parsers()->markdown()->parse(parsers()->shortcodes()->parse($s->getContent()));
|
||||
}
|
||||
|
||||
return '@markdown';
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,8 +17,11 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use function Flextype\registry;
|
||||
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function ob_get_clean;
|
||||
use function ob_start;
|
||||
|
||||
// Shortcode: php
|
||||
// Usage: (php) php code here (/php)
|
||||
@@ -28,11 +31,12 @@ parsers()->shortcodes()->addHandler('php', static function (ShortcodeInterface $
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($s->getContent() != null) {
|
||||
if ($s->getContent() !== null) {
|
||||
ob_start();
|
||||
eval($s->getContent());
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
return '@php';
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,10 +18,12 @@ namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
use function array_keys;
|
||||
use function Flextype\collection;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\collection;
|
||||
use function is_array;
|
||||
|
||||
// Shortcode: registry
|
||||
// Usage: (registry get id:'flextype.manifest.version')
|
||||
@@ -29,16 +31,17 @@ parsers()->shortcodes()->addHandler('registry', static function (ShortcodeInterf
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.registry.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
$result = '';
|
||||
$params = $s->getParameters();
|
||||
|
||||
if (collection(array_keys($params))->filter(fn ($v) => $v == 'get')->count() > 0 &&
|
||||
isset($params['id']) &&
|
||||
registry()->get('flextype.settings.parsers.shortcodes.shortcodes.registry.get.enabled') === true) {
|
||||
|
||||
if (
|
||||
collection(array_keys($params))->filter(static fn ($v) => $v === 'get')->count() > 0 &&
|
||||
isset($params['id']) &&
|
||||
registry()->get('flextype.settings.parsers.shortcodes.shortcodes.registry.get.enabled') === true
|
||||
) {
|
||||
$id = parsers()->shortcodes()->parse($params['id']);
|
||||
$default = (isset($params['default'])) ? parsers()->shortcodes()->parse($params['default']) : null;
|
||||
$default = isset($params['default']) ? parsers()->shortcodes()->parse($params['default']) : null;
|
||||
$result = registry()->get($id, $default);
|
||||
|
||||
return is_array($result) ? serializers()->json()->encode($result) : $result;
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,10 +17,18 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function count;
|
||||
use function explode;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\serializers;
|
||||
use function Glowy\Strings\strings;
|
||||
use function is_iterable;
|
||||
use function is_string;
|
||||
use function parse_str;
|
||||
|
||||
// Shortcode: strings
|
||||
// Usage: (strings) strings to modify (/strings)
|
||||
@@ -28,18 +36,17 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.strings.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$content = ($s->getContent() != null) ? parsers()->shortcodes()->parse($s->getContent()) : '';
|
||||
$varsDelimeter = ($s->getParameter('varsDelimeter') != null) ? parsers()->shortcodes()->parse($s->getParameter('varsDelimeter')) : ',';
|
||||
|
||||
foreach($s->getParameters() as $key => $value) {
|
||||
$content = $s->getContent() !== null ? parsers()->shortcodes()->parse($s->getContent()) : '';
|
||||
$varsDelimeter = $s->getParameter('varsDelimeter') !== null ? parsers()->shortcodes()->parse($s->getParameter('varsDelimeter')) : ',';
|
||||
|
||||
foreach ($s->getParameters() as $key => $value) {
|
||||
$vars = $value !== null ? strings($value)->contains($varsDelimeter) ? explode($varsDelimeter, $value) : [$value] : [];
|
||||
|
||||
// Parse shortcodes for each var.
|
||||
$vars = array_map(fn($v) => parsers()->shortcodes()->parse(is_string($v) ? $v : ''), $vars);
|
||||
$vars = array_map(static fn ($v) => parsers()->shortcodes()->parse(is_string($v) ? $v : ''), $vars);
|
||||
|
||||
if ($key == 'append') {
|
||||
if ($key === 'append') {
|
||||
if (is_iterable($vars)) {
|
||||
$content = strings($content)->{'append'}(...$vars)->toString();
|
||||
} else {
|
||||
@@ -47,7 +54,7 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
|
||||
}
|
||||
}
|
||||
|
||||
if ($key == 'prepend') {
|
||||
if ($key === 'prepend') {
|
||||
if (is_iterable($vars)) {
|
||||
$content = strings($content)->{'prepend'}(...$vars)->toString();
|
||||
} else {
|
||||
@@ -55,297 +62,300 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
|
||||
}
|
||||
}
|
||||
|
||||
if ($key == 'after') {
|
||||
if ($key === 'after') {
|
||||
$content = strings($content)->{'after'}($vars[0])->toString();
|
||||
}
|
||||
|
||||
if ($key == 'afterLast') {
|
||||
if ($key === 'afterLast') {
|
||||
$content = strings($content)->{'afterLast'}($vars[0])->toString();
|
||||
}
|
||||
|
||||
if ($key == 'before') {
|
||||
if ($key === 'before') {
|
||||
$content = strings($content)->{'before'}($vars[0])->toString();
|
||||
}
|
||||
|
||||
if ($key == 'beforeLast') {
|
||||
|
||||
if ($key === 'beforeLast') {
|
||||
$content = strings($content)->{'beforeLast'}($vars[0])->toString();
|
||||
}
|
||||
|
||||
if ($key == 'lower') {
|
||||
if ($key === 'lower') {
|
||||
$content = strings($content)->{'lower'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'upper') {
|
||||
if ($key === 'upper') {
|
||||
$content = strings($content)->{'upper'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'sort') {
|
||||
if ($key === 'sort') {
|
||||
$content = strings($content)->{'wordsSort' . strings($vars[0])->ucfirst()}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'wordsLimit') {
|
||||
if ($key === 'wordsLimit') {
|
||||
$content = strings($content)->{'wordsLimit'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 100, isset($vars[1]) ? (string) $vars[1] : '...')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'at') {
|
||||
if ($key === 'at') {
|
||||
$content = strings($content)->{'at'}(strings($vars[0])->toInteger())->toString();
|
||||
}
|
||||
|
||||
if ($key == 'base64Decode') {
|
||||
|
||||
if ($key === 'base64Decode') {
|
||||
$content = strings($content)->{'base64Decode'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'base64Encode') {
|
||||
if ($key === 'base64Encode') {
|
||||
$content = strings($content)->{'base64Encode'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'between') {
|
||||
if ($key === 'between') {
|
||||
$content = strings($content)->{'between'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? (string) $vars[1] : '')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'camel') {
|
||||
if ($key === 'camel') {
|
||||
$content = strings($content)->{'camel'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'capitalize') {
|
||||
if ($key === 'capitalize') {
|
||||
$content = strings($content)->{'capitalize'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'chars') {
|
||||
if ($key === 'chars') {
|
||||
$content = serializers()->json()->encode(strings($content)->{'chars'}());
|
||||
}
|
||||
|
||||
if ($key == 'charsFrequency') {
|
||||
if ($key === 'charsFrequency') {
|
||||
$content = serializers()->json()->encode(strings($content)->{'charsFrequency'}());
|
||||
}
|
||||
|
||||
if ($key == 'contains') {
|
||||
if ($key === 'contains') {
|
||||
if (isset($vars[0])) {
|
||||
parse_str($vars[0], $values);
|
||||
} else {
|
||||
$values = [];
|
||||
}
|
||||
$content = strings($content)->{'contains'}(array_keys($values), (isset($vars[1]) ? strings($vars[1])->toBoolean() : true)) ? "true" : "false";
|
||||
|
||||
$content = strings($content)->{'contains'}(array_keys($values), (isset($vars[1]) ? strings($vars[1])->toBoolean() : true)) ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'containsAll') {
|
||||
if ($key === 'containsAll') {
|
||||
if (isset($vars[0])) {
|
||||
parse_str($vars[0], $values);
|
||||
} else {
|
||||
$values = [];
|
||||
}
|
||||
$content = strings($content)->{'containsAll'}(array_keys($values), (isset($vars[1]) ? strings($vars[1])->toBoolean() : true)) ? "true" : "false";
|
||||
|
||||
$content = strings($content)->{'containsAll'}(array_keys($values), (isset($vars[1]) ? strings($vars[1])->toBoolean() : true)) ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'containsAny') {
|
||||
if ($key === 'containsAny') {
|
||||
if (isset($vars[0])) {
|
||||
parse_str($vars[0], $values);
|
||||
} else {
|
||||
$values = [];
|
||||
}
|
||||
$content = strings($content)->{'containsAny'}(array_keys($values), isset($vars[1]) ? strings($vars[1])->toBoolean() : true) ? "true" : "false";
|
||||
|
||||
$content = strings($content)->{'containsAny'}(array_keys($values), isset($vars[1]) ? strings($vars[1])->toBoolean() : true) ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'count') {
|
||||
if ($key === 'count') {
|
||||
$content = (string) strings($content)->{'count'}();
|
||||
}
|
||||
|
||||
if ($key == 'crc32') {
|
||||
if ($key === 'crc32') {
|
||||
$content = (string) strings($content)->{'crc32'}();
|
||||
}
|
||||
|
||||
if ($key == 'countSubString') {
|
||||
if ($key === 'countSubString') {
|
||||
$content = (string) strings($content)->{'countSubString'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? strings($vars[1])->toBoolean() : true);
|
||||
}
|
||||
|
||||
if ($key == 'endsWith') {
|
||||
$content = strings($content)->{'endsWith'}(isset($vars[0]) ? (string) $vars[0] : '') ? "true" : "false";
|
||||
if ($key === 'endsWith') {
|
||||
$content = strings($content)->{'endsWith'}(isset($vars[0]) ? (string) $vars[0] : '') ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'finish') {
|
||||
if ($key === 'finish') {
|
||||
$content = strings($content)->{'finish'}(isset($vars[0]) ? (string) $vars[0] : '')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'firstSegment') {
|
||||
if ($key === 'firstSegment') {
|
||||
$content = strings($content)->{'firstSegment'}(isset($vars[0]) ? (string) $vars[0] : ' ')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'format') {
|
||||
if ($key === 'format') {
|
||||
$formatVars = $vars;
|
||||
if (count($formatVars) > 0) {
|
||||
$content = strings($content)->{'format'}(...$formatVars)->toString();
|
||||
}
|
||||
}
|
||||
|
||||
if ($key == 'getEncoding') {
|
||||
|
||||
if ($key === 'getEncoding') {
|
||||
$content = strings($content)->{'getEncoding'}();
|
||||
}
|
||||
|
||||
if ($key == 'setEncoding') {
|
||||
if ($key === 'setEncoding') {
|
||||
$content = strings($content)->{'setEncoding'}(isset($vars[0]) ? (string) $vars[0] : '');
|
||||
}
|
||||
|
||||
if ($key == 'hash') {
|
||||
if ($key === 'hash') {
|
||||
$content = strings($content)->{'hash'}(isset($vars[0]) ? (string) $vars[0] : 'md5', isset($vars[1]) ? strings($vars[1])->toBoolean() : false)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'increment') {
|
||||
if ($key === 'increment') {
|
||||
$content = strings($content)->{'increment'}(isset($vars[1]) ? (string) $vars[1] : '_', isset($vars[0]) ? (int) $vars[0] : 1)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'indexOf') {
|
||||
if ($key === 'indexOf') {
|
||||
$content = strings($content)->{'indexOf'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? (int) $vars[1] : 0, isset($vars[2]) ? strings($vars[2])->toBoolean() : true);
|
||||
}
|
||||
|
||||
if ($key == 'indexOfLast') {
|
||||
if ($key === 'indexOfLast') {
|
||||
$content = strings($content)->{'indexOfLast'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? (int) $vars[1] : 0, isset($vars[2]) ? strings($vars[2])->toBoolean() : true);
|
||||
}
|
||||
|
||||
if ($key == 'insert') {
|
||||
if ($key === 'insert') {
|
||||
$content = strings($content)->{'insert'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? (int) $vars[1] : 0);
|
||||
}
|
||||
|
||||
if ($key == 'isAlpha') {
|
||||
$content = strings($content)->{'isAlpha'}() ? "true" : "false";
|
||||
if ($key === 'isAlpha') {
|
||||
$content = strings($content)->{'isAlpha'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isAlphanumeric') {
|
||||
$content = strings($content)->{'isAlphanumeric'}() ? "true" : "false";
|
||||
if ($key === 'isAlphanumeric') {
|
||||
$content = strings($content)->{'isAlphanumeric'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isAscii') {
|
||||
$content = strings($content)->{'isAscii'}() ? "true" : "false";
|
||||
if ($key === 'isAscii') {
|
||||
$content = strings($content)->{'isAscii'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isBase64') {
|
||||
$content = strings($content)->{'isBase64'}() ? "true" : "false";
|
||||
if ($key === 'isBase64') {
|
||||
$content = strings($content)->{'isBase64'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isBlank') {
|
||||
$content = strings($content)->{'isBlank'}() ? "true" : "false";
|
||||
if ($key === 'isBlank') {
|
||||
$content = strings($content)->{'isBlank'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isBoolean') {
|
||||
$content = strings($content)->{'isBoolean'}() ? "true" : "false";
|
||||
if ($key === 'isBoolean') {
|
||||
$content = strings($content)->{'isBoolean'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isDigit') {
|
||||
$content = strings($content)->{'isDigit'}() ? "true" : "false";
|
||||
if ($key === 'isDigit') {
|
||||
$content = strings($content)->{'isDigit'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isEmail') {
|
||||
$content = strings($content)->{'isEmail'}() ? "true" : "false";
|
||||
if ($key === 'isEmail') {
|
||||
$content = strings($content)->{'isEmail'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isEmpty') {
|
||||
$content = strings($content)->{'isEmpty'}() ? "true" : "false";
|
||||
}
|
||||
|
||||
if ($key == 'isEqual') {
|
||||
$content = strings($content)->{'isEqual'}(isset($vars[0]) ? (string) $vars[0] : '') ? "true" : "false";
|
||||
if ($key === 'isEmpty') {
|
||||
$content = strings($content)->{'isEmpty'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isFalse') {
|
||||
$content = strings($content)->{'isFalse'}() ? "true" : "false";
|
||||
if ($key === 'isEqual') {
|
||||
$content = strings($content)->{'isEqual'}(isset($vars[0]) ? (string) $vars[0] : '') ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isTrue') {
|
||||
$content = strings($content)->{'isTrue'}() ? "true" : "false";
|
||||
if ($key === 'isFalse') {
|
||||
$content = strings($content)->{'isFalse'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isHexadecimal') {
|
||||
$content = strings($content)->{'isHexadecimal'}() ? "true" : "false";
|
||||
if ($key === 'isTrue') {
|
||||
$content = strings($content)->{'isTrue'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isHTML') {
|
||||
$content = strings($content)->{'isHTML'}() ? "true" : "false";
|
||||
if ($key === 'isHexadecimal') {
|
||||
$content = strings($content)->{'isHexadecimal'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isIP') {
|
||||
$content = strings($content)->{'isIP'}() ? "true" : "false";
|
||||
if ($key === 'isHTML') {
|
||||
$content = strings($content)->{'isHTML'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isJson') {
|
||||
$content = strings($content)->{'isJson'}() ? "true" : "false";
|
||||
if ($key === 'isIP') {
|
||||
$content = strings($content)->{'isIP'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isUpper') {
|
||||
$content = strings($content)->{'isUpper'}() ? "true" : "false";
|
||||
if ($key === 'isJson') {
|
||||
$content = strings($content)->{'isJson'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isLower') {
|
||||
$content = strings($content)->{'isLower'}() ? "true" : "false";
|
||||
if ($key === 'isUpper') {
|
||||
$content = strings($content)->{'isUpper'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isMAC') {
|
||||
$content = strings($content)->{'isMAC'}() ? "true" : "false";
|
||||
if ($key === 'isLower') {
|
||||
$content = strings($content)->{'isLower'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isNumeric') {
|
||||
$content = strings($content)->{'isNumeric'}() ? "true" : "false";
|
||||
if ($key === 'isMAC') {
|
||||
$content = strings($content)->{'isMAC'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isPrintable') {
|
||||
$content = strings($content)->{'isPrintable'}() ? "true" : "false";
|
||||
if ($key === 'isNumeric') {
|
||||
$content = strings($content)->{'isNumeric'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isPunctuation') {
|
||||
$content = strings($content)->{'isPunctuation'}() ? "true" : "false";
|
||||
if ($key === 'isPrintable') {
|
||||
$content = strings($content)->{'isPrintable'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isUrl') {
|
||||
$content = strings($content)->{'isUrl'}() ? "true" : "false";
|
||||
if ($key === 'isPunctuation') {
|
||||
$content = strings($content)->{'isPunctuation'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isSimilar') {
|
||||
$content = strings($content)->{'isSimilar'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? (float) $vars[1] : 80.0) ? "true" : "false";
|
||||
if ($key === 'isUrl') {
|
||||
$content = strings($content)->{'isUrl'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'isSerialized') {
|
||||
$content = strings($content)->{'isSerialized'}() ? "true" : "false";
|
||||
if ($key === 'isSimilar') {
|
||||
$content = strings($content)->{'isSimilar'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? (float) $vars[1] : 80.0) ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'kebab') {
|
||||
if ($key === 'isSerialized') {
|
||||
$content = strings($content)->{'isSerialized'}() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key === 'kebab') {
|
||||
$content = strings($content)->{'kebab'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'lastSegment') {
|
||||
if ($key === 'lastSegment') {
|
||||
$content = strings($content)->{'lastSegment'}(isset($vars[0]) ? (string) $vars[0] : ' ')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'length') {
|
||||
if ($key === 'length') {
|
||||
$content = strings($content)->{'length'}();
|
||||
}
|
||||
|
||||
if ($key == 'limit') {
|
||||
if ($key === 'limit') {
|
||||
$content = strings($content)->{'limit'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 100, isset($vars[1]) ? (string) $vars[1] : '...')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'lines') {
|
||||
if ($key === 'lines') {
|
||||
$content = serializers()->json()->encode(strings($content)->{'lines'}());
|
||||
}
|
||||
|
||||
if ($key == 'md5') {
|
||||
if ($key === 'md5') {
|
||||
$content = strings($content)->{'md5'}(isset($vars[0]) ? strings($vars[0])->toBoolean() : false)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'move') {
|
||||
if ($key === 'move') {
|
||||
$content = strings($content)->{'move'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 0, isset($vars[1]) ? strings($vars[1])->toInteger() : 0, isset($vars[2]) ? strings($vars[2])->toInteger() : 0)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'normalizeNewLines') {
|
||||
if ($key === 'normalizeNewLines') {
|
||||
$content = strings($content)->{'normalizeNewLines'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'normalizeSpaces') {
|
||||
if ($key === 'normalizeSpaces') {
|
||||
$content = strings($content)->{'normalizeSpaces'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'offsetExists') {
|
||||
$content = strings($content)->{'offsetExists'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 0) ? "true" : "false";
|
||||
if ($key === 'offsetExists') {
|
||||
$content = strings($content)->{'offsetExists'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 0) ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'offsetGet') {
|
||||
if ($key === 'offsetGet') {
|
||||
$content = strings($content)->{'offsetGet'}(isset($vars[0]) ? strings($vars[0])->toString() : 0);
|
||||
}
|
||||
|
||||
@@ -361,138 +371,140 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
|
||||
$content = strings($content)->{'padRight'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 0, isset($vars[1]) ? (string) $vars[1] : ' ')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'quotesToEntities') {
|
||||
if ($key === 'quotesToEntities') {
|
||||
$content = strings($content)->{'quotesToEntities'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'random') {
|
||||
if ($key === 'random') {
|
||||
$content = strings($content)->{'random'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 64, isset($vars[1]) ? (string) $vars[1] : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'reduceSlashes') {
|
||||
if ($key === 'reduceSlashes') {
|
||||
$content = strings($content)->{'reduceSlashes'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'repeat') {
|
||||
if ($key === 'repeat') {
|
||||
$content = strings($content)->{'repeat'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 1)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'replace') {
|
||||
if ($key === 'replace') {
|
||||
$content = strings($content)->{'replace'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? (string) $vars[1] : '')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'replaceDashes') {
|
||||
if ($key === 'replaceDashes') {
|
||||
$content = strings($content)->{'replaceDashes'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? strings($vars[1])->toBoolean() : false)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'replaceFirst') {
|
||||
if ($key === 'replaceFirst') {
|
||||
$content = strings($content)->{'replaceFirst'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? (string) $vars[1] : '')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'replaceLast') {
|
||||
if ($key === 'replaceLast') {
|
||||
$content = strings($content)->{'replaceLast'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? (string) $vars[1] : '')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'replaceNonAlpha') {
|
||||
if ($key === 'replaceNonAlpha') {
|
||||
$content = strings($content)->{'replaceNonAlpha'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? strings($vars[1])->toBoolean() : false)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'replaceNonAlphanumeric') {
|
||||
if ($key === 'replaceNonAlphanumeric') {
|
||||
$content = strings($content)->{'replaceNonAlphanumeric'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? strings($vars[1])->toBoolean() : false)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'replacePunctuations') {
|
||||
if ($key === 'replacePunctuations') {
|
||||
$content = strings($content)->{'replacePunctuations'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? strings($vars[1])->toBoolean() : false)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'reverse') {
|
||||
if ($key === 'reverse') {
|
||||
$content = strings($content)->{'reverse'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'segment') {
|
||||
if ($key === 'segment') {
|
||||
$content = strings($content)->{'segment'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 1, isset($vars[1]) ? (string) $vars[1] : ' ')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'segments') {
|
||||
if ($key === 'segments') {
|
||||
$content = serializers()->json()->encode(strings($content)->{'segments'}(isset($vars[0]) ? (string) $vars[0] : ' '));
|
||||
}
|
||||
|
||||
if ($key == 'sha1') {
|
||||
|
||||
if ($key === 'sha1') {
|
||||
$content = strings($content)->{'sha1'}(isset($vars[0]) ? strings($vars[0])->toBoolean() : false)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'sha256') {
|
||||
if ($key === 'sha256') {
|
||||
$content = strings($content)->{'sha256'}(isset($vars[0]) ? strings($vars[0])->toBoolean() : false)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'shuffle') {
|
||||
if ($key === 'shuffle') {
|
||||
$content = strings($content)->{'shuffle'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'similarity') {
|
||||
if ($key === 'similarity') {
|
||||
$content = (string) strings($content)->{'similarity'}(isset($vars[0]) ? (string) $vars[0] : '');
|
||||
}
|
||||
|
||||
if ($key == 'snake') {
|
||||
if ($key === 'snake') {
|
||||
$content = strings($content)->{'snake'}(isset($vars[0]) ? (string) $vars[0] : '_')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'start') {
|
||||
if ($key === 'start') {
|
||||
$content = strings($content)->{'start'}(isset($vars[0]) ? (string) $vars[0] : '')->toString();
|
||||
}
|
||||
|
||||
if ($key == 'startsWith') {
|
||||
$content = strings($content)->{'startsWith'}(isset($vars[0]) ? (string) $vars[0] : '') ? "true" : "false";
|
||||
if ($key === 'startsWith') {
|
||||
$content = strings($content)->{'startsWith'}(isset($vars[0]) ? (string) $vars[0] : '') ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($key == 'stripQuotes') {
|
||||
if ($key === 'stripQuotes') {
|
||||
$content = strings($content)->{'stripQuotes'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'stripSpaces') {
|
||||
if ($key === 'stripSpaces') {
|
||||
$content = strings($content)->{'stripSpaces'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'studly') {
|
||||
if ($key === 'studly') {
|
||||
$content = strings($content)->{'studly'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'substr') {
|
||||
if ($key === 'substr') {
|
||||
$content = strings($content)->{'substr'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 0, isset($vars[1]) ? (string) $vars[1] : null)->toString();
|
||||
}
|
||||
|
||||
if ($key == 'trim') {
|
||||
if ($key === 'trim') {
|
||||
$content = strings($content)->{'trim'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'trimLeft') {
|
||||
if ($key === 'trimLeft') {
|
||||
$content = strings($content)->{'trimLeft'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'trimRight') {
|
||||
if ($key === 'trimRight') {
|
||||
$content = strings($content)->{'trimRight'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'trimSlashes') {
|
||||
if ($key === 'trimSlashes') {
|
||||
$content = strings($content)->{'trimSlashes'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'ucfirst') {
|
||||
if ($key === 'ucfirst') {
|
||||
$content = strings($content)->{'ucfirst'}()->toString();
|
||||
}
|
||||
|
||||
if ($key == 'wordsCount') {
|
||||
if ($key === 'wordsCount') {
|
||||
$content = (string) strings($content)->{'wordsCount'}(isset($vars[0]) ? (string) $vars[0] : '?!;:,.');
|
||||
}
|
||||
|
||||
if ($key == 'words') {
|
||||
if ($key === 'words') {
|
||||
$content = serializers()->json()->encode(strings($content)->{'words'}(isset($vars[0]) ? (string) $vars[0] : '?!;:,.'));
|
||||
}
|
||||
|
||||
if ($key == 'wordsFrequency') {
|
||||
$content = serializers()->json()->encode(strings($content)->{'wordsFrequency'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 2, isset($vars[1]) ? (string) $vars[1] : '.', isset($vars[2]) ? (string) $vars[2] : ','));
|
||||
if ($key !== 'wordsFrequency') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$content = serializers()->json()->encode(strings($content)->{'wordsFrequency'}(isset($vars[0]) ? strings($vars[0])->toInteger() : 2, isset($vars[1]) ? (string) $vars[1] : '.', isset($vars[2]) ? (string) $vars[2] : ','));
|
||||
}
|
||||
|
||||
return (string) $content;
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,6 +17,7 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
|
||||
@@ -27,10 +28,10 @@ parsers()->shortcodes()->addHandler('textile', static function (ShortcodeInterfa
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.textile.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($s->getContent() != null) {
|
||||
|
||||
if ($s->getContent() !== null) {
|
||||
return parsers()->textile()->parse(parsers()->shortcodes()->parse($s->getContent()));
|
||||
}
|
||||
|
||||
return '@textile';
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,8 +17,9 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use function Flextype\registry;
|
||||
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
|
||||
// Shortcode: type
|
||||
// Usage: (type:string)
|
||||
@@ -26,8 +27,8 @@ parsers()->shortcodes()->addHandler('type', static function (ShortcodeInterface
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.type.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($s->getBbCode() != null) {
|
||||
|
||||
if ($s->getBbCode() !== null) {
|
||||
return '@type[' . $s->getBBCode() . ']';
|
||||
}
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,11 +17,10 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
|
||||
use function Flextype\expression;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\expression;
|
||||
|
||||
// Shortcode: unless
|
||||
// Usage: (unless:'(var:score) < (var:level1)') Show something... (/when)
|
||||
@@ -30,5 +29,5 @@ parsers()->shortcodes()->addHandler('unless', static function (ShortcodeInterfac
|
||||
return '';
|
||||
}
|
||||
|
||||
return expression()->evaluate(parsers()->shortcodes()->parse((($s->getBbCode() != null) ? $s->getBbCode() : ''))) === false ? parsers()->shortcodes()->parse($s->getContent()) : '';
|
||||
});
|
||||
return expression()->evaluate(parsers()->shortcodes()->parse(($s->getBbCode() ?? ''))) === false ? parsers()->shortcodes()->parse($s->getContent()) : '';
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,18 +17,17 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use function Flextype\app;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\getBaseUrl;
|
||||
use function Flextype\getBasePath;
|
||||
|
||||
use function Flextype\getAbsoluteUrl;
|
||||
use function Flextype\getBasePath;
|
||||
use function Flextype\getBaseUrl;
|
||||
use function Flextype\getProjectUrl;
|
||||
use function Flextype\getUriString;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\urlFor;
|
||||
|
||||
|
||||
// Shortcode: getBaseUrl
|
||||
// Usage: (getBaseUrl)
|
||||
parsers()->shortcodes()->addHandler('getBaseUrl', static function () {
|
||||
@@ -55,7 +54,7 @@ parsers()->shortcodes()->addHandler('getAbsoluteUrl', static function () {
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.url.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
return getAbsoluteUrl();
|
||||
});
|
||||
|
||||
@@ -65,7 +64,7 @@ parsers()->shortcodes()->addHandler('getProjectUrl', static function () {
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.url.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
return getProjectUrl();
|
||||
});
|
||||
|
||||
@@ -75,7 +74,7 @@ parsers()->shortcodes()->addHandler('getUriString', static function () {
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.url.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
return getUriString();
|
||||
});
|
||||
|
||||
@@ -86,7 +85,9 @@ parsers()->shortcodes()->addHandler('urlFor', static function (ShortcodeInterfac
|
||||
return '';
|
||||
}
|
||||
|
||||
return urlFor($s->getParameter('routeName'),
|
||||
$s->getParameter('data') != null ? serializers()->json()->decode(parsers()->shortcodes()->parse($s->getParameter('data'))) : [],
|
||||
$s->getParameter('queryParams') != null ? serializers()->json()->decode(parsers()->shortcodes()->parse($s->getParameter('queryParams'))) : [],);
|
||||
});
|
||||
return urlFor(
|
||||
$s->getParameter('routeName'),
|
||||
$s->getParameter('data') !== null ? serializers()->json()->decode(parsers()->shortcodes()->parse($s->getParameter('data'))) : [],
|
||||
$s->getParameter('queryParams') !== null ? serializers()->json()->decode(parsers()->shortcodes()->parse($s->getParameter('queryParams'))) : [],
|
||||
);
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,8 +16,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
@@ -30,8 +31,8 @@ parsers()->shortcodes()->addHandler('uuid', static function (ShortcodeInterface
|
||||
}
|
||||
|
||||
$result = '';
|
||||
$uuid = ($s->getBbCode() != null) ? strings(parsers()->shortcodes()->parse($s->getBbCode()))->toInteger() : 4;
|
||||
|
||||
$uuid = $s->getBbCode() !== null ? strings(parsers()->shortcodes()->parse($s->getBbCode()))->toInteger() : 4;
|
||||
|
||||
switch ($uuid) {
|
||||
case 4:
|
||||
default:
|
||||
@@ -40,4 +41,4 @@ parsers()->shortcodes()->addHandler('uuid', static function (ShortcodeInterface
|
||||
}
|
||||
|
||||
return $result;
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,39 +17,42 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\parsers;
|
||||
|
||||
use function Flextype\entries;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
|
||||
// Shortcode: var
|
||||
// Usage: (var:foo)
|
||||
// Usage: (var:foo)
|
||||
// (var get:foo)
|
||||
// (var set:foo value:Foo)
|
||||
// (var set:foo value:Foo)
|
||||
// (var set:foo) Foo (/var)
|
||||
parsers()->shortcodes()->addHandler('var', static function (ShortcodeInterface $s) {
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.var.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$params = ($s->getParameters() != null) ? $s->getParameters() : '';
|
||||
|
||||
$params = $s->getParameters() ?? '';
|
||||
|
||||
if (isset($params['set'])) {
|
||||
if (isset($params['value'])) {
|
||||
$value = $params['value'];
|
||||
} else {
|
||||
$value = ($s->getContent() != null) ? $s->getContent() : '';
|
||||
$value = $s->getContent() ?? '';
|
||||
}
|
||||
|
||||
entries()->registry()->set('methods.fetch.result.vars.' . parsers()->shortcodes()->parse($params['set']), parsers()->shortcodes()->parse($value));
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['get'])) {
|
||||
return entries()->registry()->get('methods.fetch.result.vars.' . parsers()->shortcodes()->parse($params['get']));
|
||||
}
|
||||
}
|
||||
|
||||
if ($s->getBBCode() !== null) {
|
||||
return entries()->registry()->get('methods.fetch.result.vars.' . parsers()->shortcodes()->parse($s->getBBCode()));
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,11 +17,10 @@ declare(strict_types=1);
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
|
||||
use function Flextype\expression;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\expression;
|
||||
|
||||
// Shortcode: when
|
||||
// Usage: (when:'(var:score) < (var:level1)') Show something... (/when)
|
||||
@@ -30,5 +29,5 @@ parsers()->shortcodes()->addHandler('when', static function (ShortcodeInterface
|
||||
return '';
|
||||
}
|
||||
|
||||
return expression()->evaluate(parsers()->shortcodes()->parse((($s->getBbCode() != null) ? $s->getBbCode() : ''))) === true ? parsers()->shortcodes()->parse($s->getContent()) : '';
|
||||
});
|
||||
return expression()->evaluate(parsers()->shortcodes()->parse(($s->getBbCode() ?? ''))) === true ? parsers()->shortcodes()->parse($s->getContent()) : '';
|
||||
});
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -19,9 +19,11 @@ namespace Flextype\Parsers;
|
||||
use Exception;
|
||||
use Netcarver\Textile\Parser;
|
||||
|
||||
use function count;
|
||||
use function Flextype\cache;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
use function is_array;
|
||||
|
||||
final class Textile
|
||||
{
|
||||
@@ -59,15 +61,20 @@ final class Textile
|
||||
$parser = new Parser();
|
||||
|
||||
foreach (registry()->get('flextype.settings.parsers.textile') as $key => $value) {
|
||||
if ($key == 'cache') continue;
|
||||
if ($key == 'symbol') {
|
||||
if ($key === 'cache') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($key === 'symbol') {
|
||||
if (count($value) > 0 && is_array($value)) {
|
||||
foreach ($value as $name => $val) {
|
||||
$parser->setSymbol($name, $val);
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$parser->{'set' . strings($key)->camel()->ucfirst()}($value);
|
||||
}
|
||||
|
||||
@@ -101,7 +108,7 @@ final class Textile
|
||||
*
|
||||
* @return mixed The TEXTILE converted to a PHP value
|
||||
*/
|
||||
public function parse(string $input)
|
||||
public function parse(string $input): mixed
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.parsers.textile.cache.enabled');
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,14 +16,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Glowy\Macroable\Macroable;
|
||||
use Composer\Semver\Semver;
|
||||
use Flextype\I18n;
|
||||
use Glowy\Macroable\Macroable;
|
||||
use RuntimeException;
|
||||
|
||||
use function array_diff_key;
|
||||
use function array_replace_recursive;
|
||||
use function Glowy\Arrays\arrays;
|
||||
use function count;
|
||||
use function filemtime;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
@@ -80,7 +78,7 @@ class Plugins
|
||||
|
||||
// Get plugins list
|
||||
$pluginsList = $this->getPluginsList();
|
||||
|
||||
|
||||
// Get plugins Cache ID
|
||||
$pluginsCacheID = $this->getPluginsCacheID($pluginsList);
|
||||
|
||||
@@ -109,7 +107,6 @@ class Plugins
|
||||
|
||||
// Go through...
|
||||
foreach ($pluginsList as $plugin) {
|
||||
|
||||
// Set plugin settings directory
|
||||
$projectPluginSettingsDir = FLEXTYPE_PATH_PROJECT . '/config/plugins/' . $plugin['dirname'];
|
||||
|
||||
@@ -129,8 +126,8 @@ class Plugins
|
||||
}
|
||||
|
||||
// Get default plugin settings content
|
||||
$defaultPluginSettingsFileContent = filesystem()->file($defaultPluginSettingsFile)->get();
|
||||
$defaultPluginSettings = empty($defaultPluginSettingsFileContent) ? [] : serializers()->yaml()->decode($defaultPluginSettingsFileContent);
|
||||
$defaultPluginSettingsFileContent = filesystem()->file($defaultPluginSettingsFile)->get();
|
||||
$defaultPluginSettings = empty($defaultPluginSettingsFileContent) ? [] : serializers()->yaml()->decode($defaultPluginSettingsFileContent);
|
||||
|
||||
// Create project plugin settings file
|
||||
! filesystem()->file($projectPluginSettingsFile)->exists() and filesystem()->file($projectPluginSettingsFile)->put($defaultPluginSettingsFileContent);
|
||||
@@ -150,8 +147,8 @@ class Plugins
|
||||
}
|
||||
|
||||
// Get default plugin manifest content
|
||||
$defaultPluginManifestFileContent = filesystem()->file($defaultPluginManifestFile)->get();
|
||||
$defaultPluginManifest = empty($defaultPluginManifestFileContent) ? [] : serializers()->yaml()->decode($defaultPluginManifestFileContent);
|
||||
$defaultPluginManifestFileContent = filesystem()->file($defaultPluginManifestFile)->get();
|
||||
$defaultPluginManifest = empty($defaultPluginManifestFileContent) ? [] : serializers()->yaml()->decode($defaultPluginManifestFileContent);
|
||||
|
||||
// Merge plugin settings and manifest data
|
||||
$plugins[$plugin['dirname']]['manifest'] = $defaultPluginManifest;
|
||||
@@ -218,7 +215,7 @@ class Plugins
|
||||
} else {
|
||||
$translates = serializers()->yaml()->decode($content);
|
||||
}
|
||||
|
||||
|
||||
I18n::add($translates, $locale);
|
||||
} else {
|
||||
I18n::add([], registry()->get('flextype.settings.locale'));
|
||||
@@ -268,7 +265,6 @@ class Plugins
|
||||
*/
|
||||
public function getValidPluginsDependencies(array $plugins): array
|
||||
{
|
||||
|
||||
// Set verified plugins array
|
||||
$verifiedPlugins = [];
|
||||
|
||||
@@ -372,12 +368,16 @@ class Plugins
|
||||
if (filesystem()->directory(FLEXTYPE_PATH_PROJECT . '/plugins/')->exists()) {
|
||||
foreach (filesystem()->find()->in(FLEXTYPE_PATH_PROJECT . '/plugins/')->directories()->depth(0) as $plugin) {
|
||||
$pluginName = $plugin->getBasename();
|
||||
if (filesystem()->file(FLEXTYPE_PATH_PROJECT . '/plugins/' . $pluginName . '/plugin.php')->exists() &&
|
||||
filesystem()->file(FLEXTYPE_PATH_PROJECT . '/plugins/' . $pluginName . '/plugin.yaml')->exists() &&
|
||||
filesystem()->file(FLEXTYPE_PATH_PROJECT . '/plugins/' . $pluginName . '/settings.yaml')->exists()) {
|
||||
$pluginsList[$pluginName]['dirname'] = $plugin->getBasename();
|
||||
$pluginsList[$pluginName]['pathname'] = $plugin->getPathname();
|
||||
if (
|
||||
! filesystem()->file(FLEXTYPE_PATH_PROJECT . '/plugins/' . $pluginName . '/plugin.php')->exists() ||
|
||||
! filesystem()->file(FLEXTYPE_PATH_PROJECT . '/plugins/' . $pluginName . '/plugin.yaml')->exists() ||
|
||||
! filesystem()->file(FLEXTYPE_PATH_PROJECT . '/plugins/' . $pluginName . '/settings.yaml')->exists()
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pluginsList[$pluginName]['dirname'] = $plugin->getBasename();
|
||||
$pluginsList[$pluginName]['pathname'] = $plugin->getPathname();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ class Plugins
|
||||
$enabledPlugins = [];
|
||||
|
||||
foreach ($plugins as $name => $plugin) {
|
||||
if (! collection($plugin)->has('settings.enabled') || collection($plugin)->get('settings.enabled') == false) {
|
||||
if (! collection($plugin)->has('settings.enabled') || collection($plugin)->get('settings.enabled') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ class Plugins
|
||||
}
|
||||
|
||||
return $enabledPlugins;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Include enabled plugins
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,19 +16,18 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Serializers;
|
||||
|
||||
use function array_slice;
|
||||
use function Glowy\Arrays\arrays;
|
||||
use function array_filter;
|
||||
use function array_values;
|
||||
use function Flextype\cache;
|
||||
use function count;
|
||||
use function implode;
|
||||
use function Flextype\collection;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\serializers;
|
||||
use function Glowy\Strings\strings;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function ltrim;
|
||||
use function preg_replace;
|
||||
use function preg_split;
|
||||
use function Flextype\registry;
|
||||
use function Flextype\serializers;
|
||||
use function Flextype\collection;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
@@ -41,7 +40,7 @@ class Frontmatter
|
||||
*
|
||||
* @return string A FRONTMATTER string representing the original PHP value.
|
||||
*/
|
||||
public function encode($input): string
|
||||
public function encode(mixed $input): string
|
||||
{
|
||||
$headerSerializer = registry()->get('flextype.settings.serializers.frontmatter.encode.header.serializer');
|
||||
$allowed = registry()->get('flextype.settings.serializers.frontmatter.encode.header.allowed');
|
||||
@@ -73,7 +72,7 @@ class Frontmatter
|
||||
*
|
||||
* @return mixed The FRONTMATTER converted to a PHP value.
|
||||
*/
|
||||
public function decode(string $input)
|
||||
public function decode(string $input): mixed
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.frontmatter.decode.cache.enabled');
|
||||
$headerSerializer = registry()->get('flextype.settings.serializers.frontmatter.decode.header.serializer');
|
||||
@@ -102,18 +101,18 @@ class Frontmatter
|
||||
unset($parts[0]);
|
||||
$parts = array_values(array_filter($parts));
|
||||
}
|
||||
|
||||
|
||||
// Check for custom frontmatter header serializers
|
||||
if (strings(strings($parts[0])->lines()[1])->trim()->contains('---')) {
|
||||
$headerSerializer = strings(strings($parts[0])->lines()[1])->trim()->after('---')->toString();
|
||||
|
||||
|
||||
$parts[0] = strings($parts[0])->replaceFirst('---' . $headerSerializer, '')->toString();
|
||||
|
||||
if (! in_array($headerSerializer, $allowed)) {
|
||||
$headerSerializer = 'yaml';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$frontmatter = serializers()->{$headerSerializer}()->decode(strings($parts[0])->trim()->toString(), false);
|
||||
$content = ['content' => strings($parts[1] ?? '')->trim()->toString()];
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,14 +18,14 @@ namespace Flextype\Serializers;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function defined;
|
||||
use function Flextype\cache;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
use function json_decode;
|
||||
use function json_encode;
|
||||
use function json_last_error;
|
||||
use function json_last_error_msg;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
use const JSON_PRESERVE_ZERO_FRACTION;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
@@ -45,7 +45,7 @@ class Json
|
||||
*
|
||||
* @return mixed A JSON string representing the original PHP value
|
||||
*/
|
||||
public function encode($input)
|
||||
public function encode(mixed $input): mixed
|
||||
{
|
||||
$options = registry()->get('flextype.settings.serializers.json.encode.options');
|
||||
$depth = registry()->get('flextype.settings.serializers.json.encode.depth');
|
||||
@@ -73,7 +73,7 @@ class Json
|
||||
*
|
||||
* @throws RuntimeException If the JSON is not valid
|
||||
*/
|
||||
public function decode(string $input)
|
||||
public function decode(string $input): mixed
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.json.decode.cache.enabled');
|
||||
$assoc = registry()->get('flextype.settings.serializers.json.decode.assoc');
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -18,14 +18,14 @@ namespace Flextype\Serializers;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function defined;
|
||||
use function json_decode;
|
||||
use function Flextype\cache;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
use function json5_decode;
|
||||
use function json_encode;
|
||||
use function json_last_error;
|
||||
use function json_last_error_msg;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
use const JSON_PRESERVE_ZERO_FRACTION;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
@@ -45,7 +45,7 @@ class Json5
|
||||
*
|
||||
* @return mixed A JSON5 string representing the original PHP value.
|
||||
*/
|
||||
public function encode($input)
|
||||
public function encode(mixed $input): mixed
|
||||
{
|
||||
$options = registry()->get('flextype.settings.serializers.json5.encode.options');
|
||||
$depth = registry()->get('flextype.settings.serializers.json5.encode.depth');
|
||||
@@ -73,7 +73,7 @@ class Json5
|
||||
*
|
||||
* @throws RuntimeException If the JSON5 is not valid.
|
||||
*/
|
||||
public function decode(string $input)
|
||||
public function decode(string $input): mixed
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.json5.decode.cache.enabeled');
|
||||
$assoc = registry()->get('flextype.settings.serializers.json5.decode.assoc');
|
||||
@@ -81,7 +81,7 @@ class Json5
|
||||
$flags = registry()->get('flextype.settings.serializers.json5.decode.flags');
|
||||
|
||||
$decode = static function (string $input, bool $assoc, int $depth, int $flags) {
|
||||
return json5_decode($input, $assoc, $depth, $flags);;
|
||||
return json5_decode($input, $assoc, $depth, $flags);
|
||||
};
|
||||
|
||||
if ($cache === true && registry()->get('flextype.settings.cache.enabled') === true) {
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -33,7 +33,7 @@ class Neon
|
||||
*
|
||||
* @return string A NEON string representing the original PHP value.
|
||||
*/
|
||||
public function encode($input): string
|
||||
public function encode(mixed $input): string
|
||||
{
|
||||
$blockMode = registry()->get('flextype.settings.serializers.neon.encode.blockMode');
|
||||
$indentation = registry()->get('flextype.settings.serializers.neon.encode.indentation');
|
||||
@@ -54,7 +54,7 @@ class Neon
|
||||
*
|
||||
* @return mixed The NEON converted to a PHP value.
|
||||
*/
|
||||
public function decode(string $input)
|
||||
public function decode(string $input): mixed
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.neon.decode.cache.enabled');
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,15 +16,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Serializers;
|
||||
|
||||
use Symfony\Component\VarExporter\VarExporter;
|
||||
|
||||
use RuntimeException;
|
||||
use Exception;
|
||||
use Symfony\Component\VarExporter\VarExporter;
|
||||
use Throwable;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
use function var_export;
|
||||
|
||||
class PhpArray
|
||||
{
|
||||
@@ -35,7 +33,7 @@ class PhpArray
|
||||
*
|
||||
* @return string A PhpArray string representing the original PHP value.
|
||||
*/
|
||||
public function encode($input): string
|
||||
public function encode(mixed $input): string
|
||||
{
|
||||
$wrap = registry()->get('flextype.settings.serializers.phparray.encode.wrap');
|
||||
|
||||
@@ -45,7 +43,7 @@ class PhpArray
|
||||
} else {
|
||||
$data = VarExporter::export($input);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
throw new RuntimeException('Encoding PhpArray failed');
|
||||
}
|
||||
|
||||
@@ -59,14 +57,14 @@ class PhpArray
|
||||
*
|
||||
* @return mixed The PhpArray converted to a PHP value.
|
||||
*/
|
||||
public function decode(string $input)
|
||||
public function decode(string $input): mixed
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.phparray.decode.cache.enabled');
|
||||
|
||||
$decode = static function (string $input) {
|
||||
try {
|
||||
$value = include $input;
|
||||
} catch (Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
throw new RuntimeException('Decoding PhpArray failed');
|
||||
}
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -21,13 +21,13 @@ use Symfony\Component\Yaml\Exception\DumpException as SymfonyYamlDumpException;
|
||||
use Symfony\Component\Yaml\Exception\ParseException as SymfonyYamlParseException;
|
||||
use Symfony\Component\Yaml\Yaml as SymfonyYaml;
|
||||
|
||||
use function Flextype\cache;
|
||||
use function error_reporting;
|
||||
use function Flextype\cache;
|
||||
use function Flextype\registry;
|
||||
use function function_exists;
|
||||
use function Glowy\Strings\strings;
|
||||
use function ini_get;
|
||||
use function ini_set;
|
||||
use function Flextype\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
|
||||
class Yaml
|
||||
{
|
||||
@@ -53,7 +53,7 @@ class Yaml
|
||||
*
|
||||
* @return string A YAML string representing the original PHP value.
|
||||
*/
|
||||
public function encode($input): string
|
||||
public function encode(mixed $input): string
|
||||
{
|
||||
$inline = registry()->get('flextype.settings.serializers.yaml.encode.inline');
|
||||
$indent = registry()->get('flextype.settings.serializers.yaml.encode.indent');
|
||||
@@ -80,7 +80,7 @@ class Yaml
|
||||
*
|
||||
* @throws RuntimeException If the YAML is not valid.
|
||||
*/
|
||||
public function decode(string $input)
|
||||
public function decode(string $input): mixed
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.yaml.decode.cache.enabled');
|
||||
$flags = registry()->get('flextype.settings.serializers.yaml.decode.flags');
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -17,16 +17,18 @@ declare(strict_types=1);
|
||||
namespace Flextype;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Whoops\Handler\JsonResponseHandler;
|
||||
use Whoops\Handler\PlainTextHandler;
|
||||
use Whoops\Handler\PrettyPageHandler;
|
||||
use Whoops\Handler\XmlResponseHandler;
|
||||
use Whoops\Run as WhoopsRun;
|
||||
use Whoops\Util\Misc;
|
||||
use Whoops\Handler\PrettyPageHandler;
|
||||
use Whoops\Handler\PlainTextHandler;
|
||||
use Whoops\Handler\JsonResponseHandler;
|
||||
use Whoops\Handler\XmlResponseHandler;
|
||||
|
||||
use function array_merge;
|
||||
use function method_exists;
|
||||
|
||||
class Whoops
|
||||
{
|
||||
|
||||
protected $settings = [];
|
||||
protected $request = null;
|
||||
protected $handlers = [];
|
||||
@@ -36,23 +38,20 @@ class Whoops
|
||||
*
|
||||
* @param array $settings
|
||||
*/
|
||||
public function __construct(array $settings = [])
|
||||
public function __construct(array $settings = [])
|
||||
{
|
||||
$this->settings = array_merge([
|
||||
'enable' => true,
|
||||
'editor' => 'vscode',
|
||||
'title' => 'Error!',
|
||||
'hadler' => 'plain'
|
||||
'hadler' => 'plain',
|
||||
], $settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the server request object
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
* @return void
|
||||
*/
|
||||
public function setRequest(ServerRequestInterface $request): void
|
||||
public function setRequest(ServerRequestInterface $request): void
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
@@ -61,26 +60,23 @@ class Whoops
|
||||
* Set the custom handlers for whoops
|
||||
*
|
||||
* @param array $handlers
|
||||
* @return void
|
||||
*/
|
||||
public function setHandlers(array $handlers): void
|
||||
public function setHandlers(array $handlers): void
|
||||
{
|
||||
$this->handlers = $handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the whoops guard object
|
||||
*
|
||||
* @return WhoopsRun|null
|
||||
*/
|
||||
public function install(): ?WhoopsRun
|
||||
public function install(): ?WhoopsRun
|
||||
{
|
||||
if ($this->settings['enable'] === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set Whoops to default exception handler
|
||||
$whoops = new \Whoops\Run;
|
||||
$whoops = new WhoopsRun();
|
||||
|
||||
switch ($this->settings['handler']) {
|
||||
case 'json':
|
||||
@@ -128,19 +124,19 @@ class Whoops
|
||||
'Port' => $this->request->getUri()->getPort(),
|
||||
'Host' => $this->request->getUri()->getHost(),
|
||||
]);
|
||||
|
||||
|
||||
$whoops->pushHandler($prettyPageHandler);
|
||||
break;
|
||||
}
|
||||
|
||||
// Enable JsonResponseHandler when request is AJAX
|
||||
if (Misc::isAjaxRequest() === true){
|
||||
if (Misc::isAjaxRequest() === true) {
|
||||
$whoops->pushHandler(new JsonResponseHandler());
|
||||
}
|
||||
|
||||
// Add each custom handler to whoops handler stack
|
||||
if (empty($this->handlers) === false) {
|
||||
foreach($this->handlers as $handler) {
|
||||
foreach ($this->handlers as $handler) {
|
||||
$whoops->pushHandler($handler);
|
||||
}
|
||||
}
|
||||
@@ -149,4 +145,4 @@ class Whoops
|
||||
|
||||
return $whoops;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,6 +16,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use function define;
|
||||
use function defined;
|
||||
|
||||
if (! defined('FLEXTYPE_MINIMUM_PHP')) {
|
||||
/**
|
||||
* Define the Flextype Application minimum supported PHP version.
|
||||
@@ -42,4 +45,4 @@ if (! defined('FLEXTYPE_PATH_TMP')) {
|
||||
* Define the project tmp path (without trailing slash).
|
||||
*/
|
||||
define('FLEXTYPE_PATH_TMP', FLEXTYPE_ROOT_DIR . '/var/tmp');
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
@@ -16,21 +16,17 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Cocur\Slugify\Slugify;
|
||||
use DateTimeZone;
|
||||
use Flextype\Console\FlextypeConsole;
|
||||
use Flextype\Entries\Entries;
|
||||
use Flextype\Middlewares\WhoopsMiddleware;
|
||||
use Flextype\Parsers\Parsers;
|
||||
use Flextype\Serializers\Serializers;
|
||||
use Glowy\Csrf\Csrf;
|
||||
use Glowy\Session\Session;
|
||||
use Glowy\View\View;
|
||||
use Cocur\Slugify\Slugify;
|
||||
use DateTimeZone;
|
||||
use Flextype\Entries\Entries;
|
||||
use Flextype\Handlers\HttpErrorHandler;
|
||||
use Flextype\Handlers\ShutdownHandler;
|
||||
use Flextype\Parsers\Parsers;
|
||||
use Flextype\Serializers\Serializers;
|
||||
use Flextype\Tokens\Tokens;
|
||||
use Intervention\Image\ImageManager;
|
||||
use League\Event\Emitter;
|
||||
use League\Flysystem\Filesystem as Flysystem;
|
||||
use League\Flysystem\Local\LocalFilesystemAdapter as Local;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
use Phpfastcache\Drivers\Apcu\Config;
|
||||
@@ -39,50 +35,37 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use RuntimeException;
|
||||
use Slim\Factory\ServerRequestCreatorFactory;
|
||||
use Slim\Middleware\ContentLengthMiddleware;
|
||||
use Slim\Middleware\OutputBufferingMiddleware;
|
||||
use Slim\Middleware\RoutingMiddleware;
|
||||
use Slim\Psr7\Factory\StreamFactory;
|
||||
use Slim\Psr7\Response;
|
||||
use Slim\Psr7\Stream;
|
||||
use Symfony\Component\Yaml\Yaml as SymfonyYaml;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
use Flextype\Middlewares\WhoopsMiddleware;
|
||||
use Flextype\Console\FlextypeConsole;
|
||||
use Symfony\Component\Yaml\Yaml as SymfonyYaml;
|
||||
|
||||
use function Flextype\setBasePath;
|
||||
use function Flextype\app;
|
||||
use function array_replace_recursive;
|
||||
use function Flextype\container;
|
||||
use function count;
|
||||
use function date;
|
||||
use function date_default_timezone_set;
|
||||
use function define;
|
||||
use function Flextype\emitter;
|
||||
use function extension_loaded;
|
||||
use function file_exists;
|
||||
use function filemtime;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
use function Flextype\flextype;
|
||||
use function function_exists;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
use function Glowy\Registry\registry;
|
||||
use function Glowy\Strings\strings;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function mb_internal_encoding;
|
||||
use function mb_language;
|
||||
use function mb_regex_encoding;
|
||||
use function md5;
|
||||
use function Flextype\parsers;
|
||||
use function Flextype\plugins;
|
||||
use function register_shutdown_function;
|
||||
use function Glowy\Registry\registry;
|
||||
use function Flextype\session;
|
||||
use function Glowy\Strings\strings;
|
||||
use function php_sapi_name;
|
||||
use function sprintf;
|
||||
use function sys_get_temp_dir;
|
||||
use function trim;
|
||||
use function var_export;
|
||||
use function version_compare;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
use const PHP_VERSION;
|
||||
|
||||
// Get defines.
|
||||
@@ -168,11 +151,12 @@ if (filesystem()->file($preflightFlextypePath . '/' . $cacheID . '.php')->exists
|
||||
filesystem()->file($preflightFlextypePath . $cacheID . '.php')->put("<?php\n return " . var_export($flextypeData, true) . ";\n");
|
||||
}
|
||||
|
||||
|
||||
// Store flextype merged data in the flextype registry.
|
||||
registry()->set('flextype', $flextypeData);
|
||||
|
||||
// Set Flextype Aplication base path
|
||||
setBasePath('/' . registry()->get('flextype.settings.base_path'));
|
||||
setBasePath(registry()->get('flextype.settings.base_path'));
|
||||
|
||||
// Add Routing Middleware
|
||||
app()->add(new RoutingMiddleware(app()->getRouteResolver(), app()->getRouteCollector()->getRouteParser()));
|
||||
@@ -421,4 +405,4 @@ if (php_sapi_name() === 'cli') {
|
||||
registry()->get('flextype.settings.cli.enabled') and console()->run();
|
||||
} else {
|
||||
registry()->get('flextype.settings.app.enabled') and app()->run();
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
@@ -6,6 +6,9 @@ namespace Flextype;
|
||||
|
||||
use Glowy\Arrays\Arrays as Collection;
|
||||
|
||||
use function function_exists;
|
||||
use function is_array;
|
||||
|
||||
if (! function_exists('collection')) {
|
||||
/**
|
||||
* Create a new arrayable collection object from the given elements.
|
||||
@@ -13,10 +16,8 @@ if (! function_exists('collection')) {
|
||||
* Initializes a Collection object and assigns $items the supplied values.
|
||||
*
|
||||
* @param mixed $items Items
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
function collection($items = null): Collection
|
||||
function collection(mixed $items = null): Collection
|
||||
{
|
||||
return Collection::create($items);
|
||||
}
|
||||
@@ -30,8 +31,6 @@ if (! function_exists('collectionFromJson')) {
|
||||
* @param bool $assoc Decode assoc. When TRUE, returned objects will be converted into associative array collection.
|
||||
* @param int $depth Decode Depth. Set the maximum depth. Must be greater than zero.
|
||||
* @param int $flags Bitmask consisting of decode options
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
function collectionFromJson(string $input, bool $assoc = true, int $depth = 512, int $flags = 0): Collection
|
||||
{
|
||||
@@ -45,8 +44,6 @@ if (! function_exists('collectionFromString')) {
|
||||
*
|
||||
* @param string $string Input string.
|
||||
* @param string $separator Elements separator.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
function collectionFromString(string $string, string $separator): Collection
|
||||
{
|
||||
@@ -62,10 +59,8 @@ if (! function_exists('collectionWithRange')) {
|
||||
* @param float|int|string $high The sequence is ended upon reaching the end value.
|
||||
* @param int $step If a step value is given, it will be used as the increment between elements in the sequence.
|
||||
* step should be given as a positive number. If not specified, step will default to 1.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
function collectionWithRange($low, $high, int $step = 1): Collection
|
||||
function collectionWithRange(float|int|string $low, float|int|string $high, int $step = 1): Collection
|
||||
{
|
||||
return Collection::createWithRange($low, $high, $step);
|
||||
}
|
||||
@@ -75,9 +70,7 @@ if (! function_exists('collectionFromQueryString')) {
|
||||
/**
|
||||
* Create a new arrayable object from the given query string.
|
||||
*
|
||||
* @param string $string Input query string.
|
||||
*
|
||||
* @return Collection
|
||||
* @param string $string Input query string.
|
||||
*/
|
||||
function collectionFromQueryString(string $string): Collection
|
||||
{
|
||||
@@ -94,7 +87,7 @@ if (! function_exists('filterCollection')) {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function filterCollection($items = [], array $options = []): array
|
||||
function filterCollection(mixed $items = [], array $options = []): array
|
||||
{
|
||||
$collection = collection($items);
|
||||
|
||||
@@ -166,4 +159,4 @@ if (! function_exists('filterCollection')) {
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user