Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F211253
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Subscribers
None
View Options
diff --git a/Engines/Templates/Smarty/Configuration.php b/Engines/Templates/Smarty/Configuration.php
index b660ae1..efc15b7 100644
--- a/Engines/Templates/Smarty/Configuration.php
+++ b/Engines/Templates/Smarty/Configuration.php
@@ -1,128 +1,113 @@
<?php
namespace Zed\Engines\Templates\Smarty;
class Configuration {
///
/// Private members
///
- /**
- * @var string
- */
- private $applicationDirectory;
-
- /**
- * @var string
- */
- private $cacheDirectory;
-
- /**
- * @var string
- */
- private $theme;
-
- /**
- * @var string
- */
- private $staticContentURL;
+ private string $applicationDirectory;
+
+ private string $cacheDirectory;
+
+ private string $theme;
+
+ private string $staticContentURL;
///
/// Singleton
///
- /**
- * @var Engine
- */
- private static $instance = null;
+ private static ?Configuration $instance = null;
public static function load () : Configuration {
if (self::$instance === null) {
self::$instance = self::buildDefaultConfiguration();
}
return self::$instance;
}
///
/// Factory methods
///
public static function buildDefaultConfiguration() : Configuration {
global $Config;
$engineConfig = (new self)
->setApplicationDirectory(dirname(__DIR__, 3))
->setCacheDirectory(CACHE_DIR)
->setStaticContentURL($Config['StaticContentURL']);
if (defined("THEME")) {
// Endpoints like do.php don't have THEME defined.
$engineConfig->setTheme(THEME);
}
return $engineConfig;
}
///
/// Getters and setters
///
public function getApplicationDirectory () : string {
return $this->applicationDirectory;
}
public function setApplicationDirectory (string $dir) : Configuration {
$this->applicationDirectory = $dir;
return $this;
}
public function getCacheDirectory () : string {
return $this->cacheDirectory;
}
public function setCacheDirectory (string $dir) : Configuration {
$this->cacheDirectory = $dir;
return $this;
}
public function getTheme () : string {
return $this->theme;
}
public function setTheme (string $theme) : Configuration {
$this->theme = $theme;
return $this;
}
public function getStaticContentURL () : string {
return $this->staticContentURL;
}
public function setStaticContentURL (string $url) : Configuration {
$this->staticContentURL = $url;
return $this;
}
///
/// Helper methods
///
public function getTemplateDirectory () : string {
return $this->applicationDirectory . '/skins/' . $this->theme;
}
public function getCompileDirectory () : string {
return $this->cacheDirectory . '/compiled';
}
public function getPluginsDirectory () : string {
return __DIR__ . '/Plugins';
}
}
diff --git a/Engines/Templates/Smarty/Engine.php b/Engines/Templates/Smarty/Engine.php
index 444a4e4..42bde7e 100644
--- a/Engines/Templates/Smarty/Engine.php
+++ b/Engines/Templates/Smarty/Engine.php
@@ -1,88 +1,79 @@
<?php
namespace Zed\Engines\Templates\Smarty;
use Smarty;
class Engine {
///
/// Private members
///
- /**
- * @var Smarty
- */
- private $smarty;
+ private Smarty $smarty;
- /**
- * @var Configuration
- */
- private $config;
+ private Configuration $config;
///
/// Singleton
///
- /**
- * @var Engine
- */
- private static $instance = null;
+ private static ?Engine $instance = null;
public static function load () : Engine {
if (self::$instance === null) {
self::$instance = new self;
}
return self::$instance;
}
///
/// Constructor
///
public function __construct (
?Smarty $smarty = null,
?Configuration $config = null
) {
$this->config = $config ?? Configuration::load();
$this->smarty = $smarty ?? $this->buildDefaultSmarty();
}
///
/// Factory methods
///
private function buildDefaultSmarty () : Smarty {
$smarty = new Smarty();
$smarty
->setCacheDir($this->config->getCacheDirectory())
->setCompileDir($this->config->getCompileDirectory())
->setTemplateDir($this->config->getTemplateDirectory())
->setConfigDir($this->config->getApplicationDirectory())
->addPluginsDir($this->config->getPluginsDirectory());
self::initializeDefaultVariables($smarty);
$smarty->config_vars += [
'StaticContentURL' => $this->config->getStaticContentURL(),
];
return $smarty;
}
- private static function initializeDefaultVariables (Smarty $smarty) {
+ private static function initializeDefaultVariables (Smarty $smarty): void {
$smarty->assign("PAGE_CSS", []);
$smarty->assign("PAGE_JS", []);
}
///
/// Getters
///
public function getSmarty () : Smarty {
return $this->smarty;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 23, 09:18 (1 d, 10 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21198
Default Alt Text
(5 KB)
Attached To
rZED Zed
Event Timeline
Log In to Comment