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',
|
'prefilter',
|
||||||
'postfilter',
|
'postfilter',
|
||||||
'outputfilter',
|
'outputfilter',
|
||||||
'resource',
|
|
||||||
'insert',
|
'insert',
|
||||||
] as $type) {
|
] as $type) {
|
||||||
foreach (glob($path . $type . '.?*.php') as $filename) {
|
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';
|
$type = 'cacheresource';
|
||||||
foreach (glob($path . $type . '.?*.php') as $filename) {
|
foreach (glob($path . $type . '.?*.php') as $filename) {
|
||||||
$pluginName = $this->getPluginNameFromFilename($filename);
|
$pluginName = $this->getPluginNameFromFilename($filename);
|
||||||
|
@@ -14,7 +14,7 @@ use Smarty\Resource\RecompiledPlugin;
|
|||||||
use Smarty\Template;
|
use Smarty\Template;
|
||||||
use Smarty\Template\Source;
|
use Smarty\Template\Source;
|
||||||
|
|
||||||
class _DbPlugin extends RecompiledPlugin {
|
class Smarty_Resource_Db extends RecompiledPlugin {
|
||||||
|
|
||||||
public function populate(Source $source, Template $_template = null) {
|
public function populate(Source $source, Template $_template = null) {
|
||||||
$source->filepath = 'db:';
|
$source->filepath = 'db:';
|
||||||
|
@@ -14,7 +14,7 @@ use Smarty\Resource\RecompiledPlugin;
|
|||||||
use Smarty\Template;
|
use Smarty\Template;
|
||||||
use Smarty\Template\Source;
|
use Smarty\Template\Source;
|
||||||
|
|
||||||
class _Db2Plugin extends RecompiledPlugin
|
class Smarty_Resource_Db2 extends RecompiledPlugin
|
||||||
{
|
{
|
||||||
public function populate(Source $source, Template $_template = null)
|
public function populate(Source $source, Template $_template = null)
|
||||||
{
|
{
|
||||||
|
@@ -49,7 +49,7 @@ class ResourcePluginTest extends PHPUnit_Smarty
|
|||||||
public function testResourcePluginRegisteredInstance()
|
public function testResourcePluginRegisteredInstance()
|
||||||
{
|
{
|
||||||
$this->smarty->addPluginsDir("./PHPunitplugins/");
|
$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'));
|
$this->assertEquals('hello world', $this->smarty->fetch('db2a:test'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user