Move ITemplateEngine to src

- Fix method name format
This commit is contained in:
Hypolite Petovan 2017-11-19 10:22:18 -05:00
parent 97f063e4be
commit 104a1d7fd3
5 changed files with 23 additions and 22 deletions

View File

@ -1,6 +1,7 @@
<?php
require_once "object/TemplateEngine.php";
use Friendica\Render\ITemplateEngine;
require_once("library/Smarty/libs/Smarty.class.php");
require_once "include/plugin.php";
@ -54,13 +55,13 @@ class FriendicaSmartyEngine implements ITemplateEngine {
}
// ITemplateEngine interface
public function replace_macros($s, $r) {
public function replaceMacros($s, $r) {
$template = '';
if (gettype($s) === 'string') {
$template = $s;
$s = new FriendicaSmarty();
}
$r['$APP'] = get_app();
// "middleware": inject variables into templates
@ -80,7 +81,7 @@ class FriendicaSmartyEngine implements ITemplateEngine {
return $s->parsed($template);
}
public function get_template_file($file, $root=''){
public function getTemplateFile($file, $root=''){
$a = get_app();
$template_file = get_template_file($a, SMARTY3_TEMPLATE_FOLDER.'/'.$file, $root);
$template = new FriendicaSmarty();

View File

@ -30,7 +30,7 @@ function replace_macros($s, $r) {
$t = $a->template_engine();
try {
$output = $t->replace_macros($s, $r);
$output = $t->replaceMacros($s, $r);
} catch (Exception $e) {
echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
killme();
@ -591,7 +591,7 @@ function get_markup_template($s, $root = '') {
$a = get_app();
$t = $a->template_engine();
try {
$template = $t->get_template_file($s, $root);
$template = $t->getTemplateFile($s, $root);
} catch (Exception $e) {
echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
killme();

View File

@ -1,15 +0,0 @@
<?php
/**
* @file object/TemplateEngine.php
*/
require_once 'boot.php';
/**
* Interface for template engines
*/
interface ITemplateEngine
{
public function replace_macros($s, $v);
public function get_template_file($file, $root = '');
}

View File

@ -295,7 +295,7 @@ class App {
// Register template engines
$dc = get_declared_classes();
foreach ($dc as $k) {
if (in_array('ITemplateEngine', class_implements($k))) {
if (in_array('Friendica\Render\ITemplateEngine', class_implements($k))) {
$this->register_template_engine($k);
}
}

View File

@ -0,0 +1,15 @@
<?php
/**
* @file src/Render/ITemplateEngine.php
*/
namespace Friendica\Render;
/**
* Interface for template engines
*/
interface ITemplateEngine
{
public function replaceMacros($s, $v);
public function getTemplateFile($file, $root = '');
}