aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/Application.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-07-20 18:39:34 +0200
committerThomas Lange <code@nerdmind.de>2021-07-20 18:39:34 +0200
commite6103791f528357197f8afb9ed222a9469cbd177 (patch)
tree2eeb9ac567532c6dbe646dc44c9f9bca4eb8936f /core/namespace/Application.php
parent01d4727f939c0b9530fe5fc976b7accb9e078db1 (diff)
downloadblog-e6103791f528357197f8afb9ed222a9469cbd177.tar.gz
blog-e6103791f528357197f8afb9ed222a9469cbd177.tar.xz
blog-e6103791f528357197f8afb9ed222a9469cbd177.zip
Implement new *content functions* feature (readme)
This commit implements a new feature called *content functions* that is similar but much more powerful than the already existing *content tags* which you may have already used (`{POST[1]}`, for example). You now can also add your own *content functions* to do some interesting things like embedding a YouTube video or other things to prevent typing repetitive lines of text or code in your entities content. Read the corresponding wiki page to learn more about this: https://github.com/Nerdmind/Blog/wiki/Content-functions
Diffstat (limited to 'core/namespace/Application.php')
-rw-r--r--core/namespace/Application.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/namespace/Application.php b/core/namespace/Application.php
index 5690841..140baac 100644
--- a/core/namespace/Application.php
+++ b/core/namespace/Application.php
@@ -1,5 +1,6 @@
<?php
use ORM\EntityInterface;
+use Parsers\FunctionParser;
class Application {
@@ -214,6 +215,18 @@ class Application {
}
#===============================================================================
+ # Add a custom content function
+ #===============================================================================
+ public static function addContentFunction(string $name, callable $callback): void {
+ if(!preg_match('#^([0-9A-Z_]+)$#', $name)) {
+ throw new Exception('The name for adding a content function must
+ contain only numbers, uppercase letters and underscores!');
+ }
+
+ FunctionParser::register($name, $callback);
+ }
+
+ #===============================================================================
# Exit application with a custom message and status code
#===============================================================================
public static function exit($message = '', $code = 503): void {