mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04:26 +02:00
Fixed BC loading of resource pluging from dir and all ResourcePluginTest tests
This commit is contained in:
@@ -167,7 +167,6 @@ class BCPluginsAdapter extends Base {
|
||||
'prefilter',
|
||||
'postfilter',
|
||||
'outputfilter',
|
||||
'resource',
|
||||
'insert',
|
||||
] as $type) {
|
||||
foreach (glob($path . $type . '.?*.php') as $filename) {
|
||||
@@ -181,6 +180,17 @@ class BCPluginsAdapter extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
$type = 'resource';
|
||||
foreach (glob($path . $type . '.?*.php') as $filename) {
|
||||
$pluginName = $this->getPluginNameFromFilename($filename);
|
||||
if ($pluginName !== null) {
|
||||
require_once $filename;
|
||||
if (class_exists($className = 'smarty_' . $type . '_' . $pluginName)) {
|
||||
$this->smarty->registerResource($pluginName, new $className());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$type = 'cacheresource';
|
||||
foreach (glob($path . $type . '.?*.php') as $filename) {
|
||||
$pluginName = $this->getPluginNameFromFilename($filename);
|
||||
|
@@ -14,7 +14,7 @@ use Smarty\Resource\RecompiledPlugin;
|
||||
use Smarty\Template;
|
||||
use Smarty\Template\Source;
|
||||
|
||||
class _DbPlugin extends RecompiledPlugin {
|
||||
class Smarty_Resource_Db extends RecompiledPlugin {
|
||||
|
||||
public function populate(Source $source, Template $_template = null) {
|
||||
$source->filepath = 'db:';
|
||||
|
@@ -14,7 +14,7 @@ use Smarty\Resource\RecompiledPlugin;
|
||||
use Smarty\Template;
|
||||
use Smarty\Template\Source;
|
||||
|
||||
class _Db2Plugin extends RecompiledPlugin
|
||||
class Smarty_Resource_Db2 extends RecompiledPlugin
|
||||
{
|
||||
public function populate(Source $source, Template $_template = null)
|
||||
{
|
||||
|
@@ -49,7 +49,7 @@ class ResourcePluginTest extends PHPUnit_Smarty
|
||||
public function testResourcePluginRegisteredInstance()
|
||||
{
|
||||
$this->smarty->addPluginsDir("./PHPunitplugins/");
|
||||
$this->smarty->registerResource('db2a', new _Db2Plugin('db2a'));
|
||||
$this->smarty->registerResource('db2a', new Smarty_Resource_Db2('db2a'));
|
||||
$this->assertEquals('hello world', $this->smarty->fetch('db2a:test'));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user