bytic /
orm
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Nip\Records\Collections; |
||||
| 4 | |||||
| 5 | use Nip\Records\Collections\Collection as RecordCollection; |
||||
| 6 | use Nip\Records\Record as Record; |
||||
| 7 | use Nip\Records\Relations\HasOneOrMany as Relation; |
||||
| 8 | use Nip\Records\Relations\Traits\HasCollectionResults; |
||||
| 9 | |||||
| 10 | class Associated extends RecordCollection |
||||
| 11 | { |
||||
| 12 | |||||
| 13 | /** |
||||
| 14 | * @var Relation |
||||
| 15 | */ |
||||
| 16 | protected $_withRelation; |
||||
| 17 | |||||
| 18 | /** |
||||
| 19 | * @var Record |
||||
| 20 | */ |
||||
| 21 | protected $_item; |
||||
| 22 | |||||
| 23 | /** |
||||
| 24 | * @param HasCollectionResults $relation |
||||
| 25 | */ |
||||
| 26 | 1 | public function initFromRelation($relation) |
|||
| 27 | { |
||||
| 28 | 1 | $this->setWithRelation($relation); |
|||
| 29 | 1 | $this->setManager($relation->getWith()); |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 30 | 1 | $this->setItem($relation->getItem()); |
|||
|
0 ignored issues
–
show
It seems like
getItem() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 31 | 1 | $indexKey = $relation->getParam('indexKey'); |
|||
| 32 | 1 | if ($indexKey) { |
|||
| 33 | $this->setIndexKey($indexKey); |
||||
| 34 | } |
||||
| 35 | 1 | } |
|||
| 36 | |||||
| 37 | public function save() |
||||
| 38 | { |
||||
| 39 | return $this->getWithRelation()->save(); |
||||
| 40 | } |
||||
| 41 | |||||
| 42 | /** |
||||
| 43 | * @return Relation |
||||
| 44 | */ |
||||
| 45 | public function getWithRelation() |
||||
| 46 | { |
||||
| 47 | return $this->_withRelation; |
||||
| 48 | } |
||||
| 49 | |||||
| 50 | /** |
||||
| 51 | * @param Relation $relation |
||||
| 52 | */ |
||||
| 53 | 1 | public function setWithRelation($relation) |
|||
| 54 | { |
||||
| 55 | 1 | $this->_withRelation = $relation; |
|||
| 56 | 1 | } |
|||
| 57 | |||||
| 58 | /** |
||||
| 59 | * @return Record |
||||
| 60 | */ |
||||
| 61 | public function getItem() |
||||
| 62 | { |
||||
| 63 | return $this->_item; |
||||
| 64 | } |
||||
| 65 | |||||
| 66 | /** |
||||
| 67 | * @param Record $item |
||||
| 68 | */ |
||||
| 69 | 1 | public function setItem($item) |
|||
| 70 | { |
||||
| 71 | 1 | $this->_item = $item; |
|||
| 72 | 1 | } |
|||
| 73 | } |
||||
| 74 |