1 | <?php |
||
17 | class TermRepository implements TermRepositoryInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var CacheRepository The cache to store the terms in |
||
21 | */ |
||
22 | protected $cache; |
||
23 | |||
24 | /** |
||
25 | * @var string The term cache key prefix |
||
26 | */ |
||
27 | protected static $cacheKey = 'Rocket::Taxonomy::Term::'; |
||
28 | |||
29 | /** |
||
30 | * TermRepository constructor. |
||
31 | * |
||
32 | * @param CacheRepository $cache The cache in which to keep terms |
||
33 | */ |
||
34 | 192 | public function __construct(CacheRepository $cache) |
|
38 | |||
39 | /** |
||
40 | * Get a term with all translations |
||
41 | * |
||
42 | * @param int $term_id |
||
43 | * @param bool $from_cache |
||
44 | * @return \Rocket\Taxonomy\Term |
||
45 | */ |
||
46 | 39 | public function getTerm($term_id, $from_cache = true) |
|
58 | |||
59 | /** |
||
60 | * Remove a term from the cache |
||
61 | * |
||
62 | * @param int $term_id |
||
63 | * @return bool |
||
64 | */ |
||
65 | 174 | public function uncacheTerm($term_id) |
|
69 | |||
70 | /** |
||
71 | * Puts the term in the cache and returns it for usage |
||
72 | * |
||
73 | * @param int $term_id |
||
74 | * @return array |
||
75 | */ |
||
76 | 39 | protected function cacheTerm($term_id) |
|
121 | } |
||
122 |