1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-12 08:04:05 +02:00

Flextype 0.8.2

This commit is contained in:
Awilum
2019-01-09 01:10:20 +03:00
parent fe74b67a85
commit 3e5d1e56bd

View File

@@ -21,12 +21,65 @@ Event::addListener('onShortcodesInitialized', function () {
// Shortcode: [snippet name=snippet-name]
Entries::shortcode()->addHandler('snippet', function(ShortcodeInterface $s) {
return Snippet::get($s->getParameter('name'));
return Snippets::get($s->getParameter('name'));
});
});
class Snippets
{
/**
* An instance of the Snippets class
*
* @var object
*/
private static $instance = null;
/**
* Images Server
*
* @var
*/
protected static $server;
/**
* Private clone method to enforce singleton behavior.
*
* @access private
*/
private function __clone()
{
}
/**
* Private wakeup method to enforce singleton behavior.
*
* @access private
*/
private function __wakeup()
{
}
/**
* Private construct method to enforce singleton behavior.
*
* @access private
*/
private function __construct()
{
Snippets::init();
}
/**
* Init Snippets
*
* @access private
* @return void
*/
private static function init() : void
{
}
/**
* Get snippet
*
@@ -55,4 +108,19 @@ class Snippets
throw new \RuntimeException("Snippet {$snippet_name} does not exist.");
}
}
/**
* Get the Snippets instance.
*
* @access public
* @return object
*/
public static function getInstance()
{
if (is_null(Snippets::$instance)) {
Snippets::$instance = new self;
}
return Snippets::$instance;
}
}