Skip to content

Commit

Permalink
Orm load order changed, added Caller for twig
Browse files Browse the repository at this point in the history
  • Loading branch information
andrevanzuydam committed Jan 19, 2020
1 parent 2a5f04b commit d54e3ee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions Tina4/Caller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
namespace Tina4;
class Caller {
/**
* Method to call classes using twig
* Example in twig {{ Tina4.call ("Class", "Method", "Params") }}
* @param $class
* @param string $method
* @param array $params
* @return string
*/
function call ($class, $method="", $params=[]) {
eval ('$class = new '.$class.'();');
$object = [$class, $method];
$result = call_user_func_array($object, $params);

return $result."";
}
}
2 changes: 1 addition & 1 deletion Tina4/ORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ function save($tableName = "", $fieldMapping = [])
* @throws \Exception Error on failure
* @example examples\exampleORMLoadData.php for loading table row data
*/
function load($tableName = "", $fieldMapping = [], $filter = "")
function load($filter = "", $tableName = "", $fieldMapping = [])
{
$this->checkDBConnection();

Expand Down
1 change: 1 addition & 0 deletions Tina4Php.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ function __construct($config = null)

$twig = new \Twig\Environment($twigLoader, ["debug" => true]);
$twig->addExtension(new \Twig\Extension\DebugExtension());
$twig->addGlobal('Tina4', new \Tina4\Caller());

}

Expand Down

0 comments on commit d54e3ee

Please sign in to comment.