Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
MemberComparator.php
Go to the documentation of this file.
1<?php
2
4
5
8
20 protected $member;
21 protected $class;
22 protected Member $newMember;
23
24 public function __construct(string $class,string $member){
25 $this->class=$class;
26 $this->member=$member;
27 }
28
29 public function compareTo(Member $member){
30 $this->newMember=$member;
31 }
32
33
34 protected function getAnnotations(string $class,string $member): array {
35 return CacheManager::getAnnotationsEngineInstance()->getAnnotsOfProperty($class,$member);
36 }
37
38 public function compareAttributes(){
39 $myAnnots=$this->getAnnotations($this->class,$this->member);
40 $otherAnnots=$this->newMember->getAnnotations();
41 $result=[];
42 foreach ($myAnnots as $myAnnot){
43 $index=$this->indexOfAnnotation($myAnnot,$otherAnnots);
44 if($index===-1){
45 $result[]=$myAnnot;
46 }
47 }
48 return $result;
49 }
50
51 protected function indexOfAnnotation($annotation,array $annots){
52 $contains=-1;
53 foreach ($annots as $index=>$annot){
54 if($annot->isSameAs($annotation)){
55 return $index;
56 }
57 }
58 return $contains;
59 }
60
61 public function maintain(){
62 return \count(CacheManager::getAnnotationsEngineInstance()->getAnnotsOfProperty($this->class,$this->member,'transient'))>0;
63 }
64}
Manager for caches (Router, Rest, models).
getAnnotations(string $class, string $member)
indexOfAnnotation($annotation, array $annots)
__construct(string $class, string $member)