PluginProbe
ShiftController Employee Shift Scheduling / 4.9.66
ShiftController Employee Shift Scheduling v4.9.66
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / hc3 / hookswrapper.php

hookswrapper.php in ShiftController Employee Shift Scheduling 4.9.66, at hc3/hookswrapper.php

63 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 class HC3_HooksWrapper
3 {
4 private $obj = NULL;
5 private $h = NULL;
6
7 public function __construct( $obj, HC3_IHooks $hooks )
8 {
9 $this->obj = $obj;
10 $this->h = $hooks;
11 }
12
13 public function _getClass()
14 {
15 return get_class( $this->obj );
16 }
17
18 public function __call( $method, $args )
19 {
20 $hook = get_class($this->obj) . '::' . $method;
21 $hook = strtolower( $hook );
22 $hook = str_replace( '_', '/', $hook );
23
24 $hookBefore = $hook . '::before';
25 $hookAfter = $hook . '::after';
26
27 if( method_exists($this->obj, $method) OR $this->h->exists($hook) OR $this->h->exists($hookAfter) OR $this->h->exists($hookBefore) ){
28 // before hook, may alter args or stop execution
29 $args = $this->h->apply( $hookBefore, $args );
30 if( $args === FALSE ){
31 // echo "ESCAPE EXECUTION!";
32 // exit;
33 return;
34 // return $return;
35 }
36
37 // own object method
38 $return = NULL;
39 if( method_exists($this->obj, $method) ){
40 $return = call_user_func_array(
41 array($this->obj, $method), $args
42 );
43 }
44
45 // just listen
46 $this->h->apply( $hook, $args );
47
48 // after hook, may alter return value
49 $return = $this->h->apply( $hookAfter, $return, $args );
50
51 if( $return === $this->obj ){
52 return $this;
53 }
54 else {
55 return $return;
56 }
57 }
58 else {
59 echo 'Undefined method - ' . get_class($this->obj) . '::' . $method;
60 exit;
61 }
62 }
63 }