mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-17 11:13:27 +02:00
Refactoring classes into src/ folder, so they will be auto-loaded by composer
This commit is contained in:
42
system/src/Hook.php
Normal file
42
system/src/Hook.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC;
|
||||
|
||||
class Hook
|
||||
{
|
||||
private $_name, $_type, $_file;
|
||||
|
||||
public function __construct($name, $type, $file) {
|
||||
$this->_name = $name;
|
||||
$this->_type = $type;
|
||||
$this->_file = $file;
|
||||
}
|
||||
|
||||
public function execute($params)
|
||||
{
|
||||
global $db, $config, $template_path, $ots, $content, $twig;
|
||||
|
||||
if(is_callable($this->_file))
|
||||
{
|
||||
$params['db'] = $db;
|
||||
$params['config'] = $config;
|
||||
$params['template_path'] = $template_path;
|
||||
$params['ots'] = $ots;
|
||||
$params['content'] = $content;
|
||||
$params['twig'] = $twig;
|
||||
|
||||
$tmp = $this->_file;
|
||||
$ret = $tmp($params);
|
||||
}
|
||||
else {
|
||||
extract($params);
|
||||
|
||||
$ret = include BASE . $this->_file;
|
||||
}
|
||||
|
||||
return !isset($ret) || $ret == 1 || $ret;
|
||||
}
|
||||
|
||||
public function name() {return $this->_name;}
|
||||
public function type() {return $this->_type;}
|
||||
}
|
Reference in New Issue
Block a user