1: <?php
2:
3: namespace PHPixie\ORM\Relationships\Type\ManyToMany\Property;
4:
5: class Query extends \PHPixie\ORM\Relationships\Relationship\Implementation\Property\Query
6: {
7: public function query()
8: {
9: return $this->handler->query($this->side, $this->query);
10: }
11:
12: public function add($items)
13: {
14: $config = $this->side->config();
15: list($left, $right) = $this->getSides($items);
16: $plan = $this->handler->linkPlan($config, $left, $right);
17: $plan->execute();
18: $this->handler->resetProperties($this->side, $items);
19: return $this;
20: }
21:
22: public function remove($items)
23: {
24: $config = $this->side->config();
25: list($left, $right) = $this->getSides($items);
26: $plan = $this->handler->unlinkPlan($config, $left, $right);
27: $plan->execute();
28: $this->handler->resetProperties($this->side, $items);
29: return $this;
30: }
31:
32: public function removeAll()
33: {
34: $plan = $this->handler->unlinkAllPlan($this->side, $this->query);
35: $plan->execute();
36: return $this;
37: }
38:
39: protected function getSides($opposing)
40: {
41: if ($this->side->type() === 'right')
42: return array($this->query, $opposing);
43:
44: return array($opposing, $this->query);
45: }
46: }
47: