From 3e5d1e56bd124ed11390b4edd000e94b20baf8e7 Mon Sep 17 00:00:00 2001 From: Awilum Date: Wed, 9 Jan 2019 01:10:20 +0300 Subject: [PATCH] Flextype 0.8.2 --- flextype/Snippets.php | 70 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/flextype/Snippets.php b/flextype/Snippets.php index cd6d9c7f..bed79239 100644 --- a/flextype/Snippets.php +++ b/flextype/Snippets.php @@ -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; + } }