summaryrefslogtreecommitdiff
path: root/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db4.php
blob: 571df0d82eec71020182db79ca1a05bfdc7718e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     resource.db3.php
 * Type:     resource
 * Name:     db
 * Purpose:  Fetches templates from a database
 * -------------------------------------------------------------
 */

use Smarty\Template;
use Smarty\Template\Config;
use Smarty\Template\Source;

class Smarty_Resource_Db4 extends Smarty\Resource\BasePlugin
{
    public function populate(Source $source, Template $_template = null)
    {
        $source->uid = sha1($source->resource);
        $source->timestamp = 0;
        $source->exists = true;
    }

    public function getContent(Source $source)
    {
        if ($source instanceof Config) {
            return "foo = 'bar'\n";
        }

        return '{$x="hello world"}{$x}';
    }
}