-
Notifications
You must be signed in to change notification settings - Fork 17
/
AbsBaseAp.php
59 lines (53 loc) · 1.47 KB
/
AbsBaseAp.php
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace WebSharks\CometCache;
/**
* Abstract Base for Advanced Cache and Plugin.
*
* @since 150422 Rewrite.
*/
abstract class AbsBaseAp extends AbsBase
{
/**
* Class constructor.
*
* @since 150422 Rewrite.
*/
public function __construct()
{
parent::__construct();
$closures_dir = dirname(dirname(__FILE__)).'/closures/Shared';
$self = $this; // Reference for closures.
foreach (scandir($closures_dir) as $_closure) {
if (substr($_closure, -4) === '.php') {
require $closures_dir.'/'.$_closure;
}
}
unset($_closure); // Housekeeping.
}
/**
* Magic/overload property setter.
*
* @param string $property Property to set.
* @param mixed $value The value for this property.
*
* @see http://php.net/manual/en/language.oop5.overloading.php
*/
public function __set($property, $value)
{
$property = (string) $property;
$this->{$property} = $value;
}
/**
* Closure overloading.
*
* @since 150422 Rewrite.
*/
public function __call($closure, $args)
{
$closure = (string) $closure;
if (isset($this->{$closure}) && is_callable($this->{$closure})) {
return call_user_func_array($this->{$closure}, $args);
}
throw new \Exception(sprintf(__('Undefined method/closure: `%1$s`.', 'comet-cache'), $closure));
}
}