1: <?php
2:
3: namespace Charcoal\Cms;
4:
5: // From 'charcoal-translator'
6: use Charcoal\Translator\Translation;
7:
8: /**
9: * Default implementation, as Trait, of the SearchableInterface
10: */
11: trait SearchableTrait
12: {
13: /**
14: * @var array
15: */
16: private $searchProperties = [];
17:
18: /**
19: * @var Translation|string|null
20: */
21: private $searchKeywords;
22:
23: /**
24: * @param array $properties The properties to search into.
25: * @return self
26: */
27: public function setSearchProperties(array $properties)
28: {
29: $this->searchProperties = $properties;
30: return $this;
31: }
32:
33: /**
34: * @return array
35: */
36: public function searchProperties()
37: {
38: return $this->searchProperties;
39: }
40:
41: /**
42: * @param mixed $keywords The search keywords (localized).
43: * @return self
44: */
45: public function setSearchKeywords($keywords)
46: {
47: $this->searchKeywords = $this->translator()->translation($keywords);
48: return $this;
49: }
50:
51: /**
52: * @return Translation|string|null
53: */
54: public function searchKeywords()
55: {
56: return $this->searchKeywords;
57: }
58: }
59: