PluginProbe
ShiftController Employee Shift Scheduling / 4.9.85
ShiftController Employee Shift Scheduling v4.9.85
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 / sh4 / shifts / conflicts.php

conflicts.php in ShiftController Employee Shift Scheduling 4.9.85, at sh4/shifts/conflicts.php

48 lines 1015 B
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 interface SH4_Shifts_IConflicts
3 {
4 public function register( $check );
5 public function get( SH4_Shifts_Model $shift );
6 }
7
8 class SH4_Shifts_Conflicts implements SH4_Shifts_IConflicts
9 {
10 protected $checks = array();
11 protected $cache = array();
12 public $dic;
13
14 public function __construct( HC3_Dic $dic )
15 {
16 $this->dic = $dic;
17 }
18
19 public function register( $check )
20 {
21 $this->checks[] = $check;
22 return $this;
23 }
24
25 public function get( SH4_Shifts_Model $shift, array $skipIdList = array() )
26 {
27 $id = $shift->getId();
28 if( ($id > 0) && isset($this->cache[$id]) ){
29 return $this->cache[$id];
30 }
31
32 $return = array();
33
34 reset( $this->checks );
35 foreach( $this->checks as $check ){
36 $check = $this->dic->make( $check );
37
38 $checkResult = $check->check( $shift, $skipIdList );
39 if( ! $checkResult ){
40 $return[] = $check;
41 }
42 }
43
44 $this->cache[$id] = $return;
45
46 return $return;
47 }
48 }