1: <?php
2:
3: namespace PHPixie\ORM\Relationships\Type;
4:
5: class ManyToMany extends \PHPixie\ORM\Relationships\Relationship\Implementation
6: implements \PHPixie\ORM\Relationships\Relationship\Type\Database
7: {
8: public function entityProperty($side, $entity)
9: {
10: return new ManyToMany\Property\Entity($this->handler(), $side, $entity);
11: }
12:
13: public function queryProperty($side, $query)
14: {
15: return new ManyToMany\Property\Query($this->handler(), $side, $query);
16: }
17:
18: public function preloader($side, $modelConfig, $result, $loader, $pivotResult)
19: {
20: return new ManyToMany\Preloader($this->loaders, $side, $modelConfig, $result, $loader, $pivotResult);
21: }
22:
23: protected function config($configSlice)
24: {
25: return new ManyToMany\Side\Config($this->configs->inflector(), $configSlice);
26: }
27:
28: protected function side($type, $config)
29: {
30: return new ManyToMany\Side($type, $config);
31: }
32:
33: protected function sideTypes($config)
34: {
35: return array('left', 'right');
36: }
37:
38: protected function buildHandler()
39: {
40: return new ManyToMany\Handler(
41: $this->models,
42: $this->planners,
43: $this->plans,
44: $this->steps,
45: $this->loaders,
46: $this->mappers,
47: $this
48: );
49: }
50: }
51: