97a008ac09d13100993a6cdcbe7da5b00c42b7a6
[civicrm-core.git] / Civi / Api4 / Generic / Traits / IsCurrentTrait.php
1 <?php
2 namespace Civi\Api4\Generic\Traits;
3
4 /**
5 * This trait adds the $current param to a Get action.
6 *
7 * @see \Civi\Api4\Event\Subscriber\IsCurrentSubscriber
8 */
9 trait IsCurrentTrait {
10
11 /**
12 * Convenience filter for selecting items that are enabled and are currently within their start/end dates.
13 *
14 * Adding current = TRUE is a shortcut for
15 * WHERE is_active = 1 AND (end_date IS NULL OR end_date >= now) AND (start_date IS NULL OR start_DATE <= now)
16 *
17 * Adding current = FALSE is a shortcut for
18 * WHERE is_active = 0 OR start_date > now OR end_date < now
19 *
20 * @var bool
21 */
22 protected $current;
23
24 /**
25 * @return bool
26 */
27 public function getCurrent() {
28 return $this->current;
29 }
30
31 /**
32 * @param bool $current
33 * @return $this
34 */
35 public function setCurrent($current) {
36 $this->current = $current;
37 return $this;
38 }
39
40 }