1: <?php
2:
3: namespace Charcoal\Cms\Support\Traits;
4:
5:
6: use Charcoal\Cms\Support\Helpers\DateHelper;
7:
8:
9: use Slim\Exception\ContainerException;
10:
11: trait DateHelperAwareTrait
12: {
13: 14: 15:
16: private $dateHelper;
17:
18: 19: 20: 21:
22: protected function dateHelper()
23: {
24: if (!$this->dateHelper instanceof DateHelper) {
25: throw new ContainerException(sprintf(
26: 'Missing dependency for %s: %s',
27: get_called_class(),
28: DateHelper::class
29: ));
30: }
31:
32: return $this->dateHelper;
33: }
34:
35: 36: 37: 38:
39: protected function setDateHelper(DateHelper $dateHelper)
40: {
41: $this->dateHelper = $dateHelper;
42:
43: return $this;
44: }
45: }
46: