1: <?php
2:
3: namespace PHPixie\ORM\Relationships\Type\OneTo\Type\Many\Property\Entity;
4:
5: class Items extends \PHPixie\ORM\Relationships\Type\OneTo\Property\Entity
6: {
7: protected function load()
8: {
9: $this->handler->loadItemsProperty($this->side, $this->entity);
10: }
11:
12: public function add($items)
13: {
14: $config = $this->side->config();
15: $plan = $this->handler->linkPlan($config, $this->entity, $items);
16: $plan->execute();
17: $this->handler->addOwnerItems($config, $this->entity, $items);
18: return $this;
19: }
20:
21: public function remove($items)
22: {
23: $config = $this->side->config();
24: $plan = $this->handler->unlinkPlan($config, $this->entity, $items);
25: $plan->execute();
26: $this->handler->removeOwnerItems($config, $this->entity, $items);
27: return $this;
28: }
29:
30: public function removeAll()
31: {
32: $config = $this->side->config();
33: $plan = $this->handler->unlinkOwnersPlan($config, $this->entity);
34: $plan->execute();
35: $this->handler->removeAllOwnerItems($config, $this->entity);
36: return $this;
37: }
38:
39: public function asData($recursive = false)
40: {
41: $data = array();
42: foreach($this->value() as $entity) {
43: if(!$entity->isDeleted()) {
44: $data[] = $entity->asObject($recursive);
45: }
46: }
47: return $data;
48: }
49: }
50: