Hoa central
AFunction.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Cache\Frontend;
38 
39 use Hoa\Cache;
40 
49 class AFunction extends Frontend
50 {
56  protected $_arguments = [];
57 
58 
59 
68  public function __call($function, Array $arguments)
69  {
70  if (!function_exists($function)) {
71  throw new Cache\Exception(
72  'Function %s does not exists.',
73  0,
74  $function
75  );
76  }
77 
78  $this->_arguments = $this->ksort($arguments);
79  $idExtra = serialize($this->_arguments);
80  $this->makeId($function . '/' . $idExtra);
81  $content = $this->_backend->load();
82 
83  if (false !== $content) {
84  echo $content[0]; // output
85 
86  return $content[1]; // return
87  }
88 
89  ob_start();
90  ob_implicit_flush(false);
91  $return = call_user_func_array($function, $arguments);
92  $output = ob_get_contents();
93  ob_end_clean();
94 
95  $this->_backend->store([$output, $return]);
96  $this->removeId();
97 
98  echo $output;
99 
100  return $return;
101  }
102 }
ksort(Array &$array)
Definition: Cache.php:258
$content
Definition: Hoa.php:119
__call($function, Array $arguments)
Definition: AFunction.php:68
makeId($id=null)
Definition: Cache.php:162