1: <?php
2:
3: namespace PHPixie\ORM\Relationships\Type\ManyToMany\Side;
4:
5: class Config extends \PHPixie\ORM\Relationships\Relationship\Implementation\Side\Config
6: {
7: public $leftModel;
8: public $leftProperty;
9: public $leftPivotKey;
10:
11: public $rightModel;
12: public $rightProperty;
13: public $rightPivotKey;
14:
15: public $pivot;
16: public $pivotConnection;
17:
18: protected function processConfig($configSlice, $inflector)
19: {
20: $sides = array('left' => 'right', 'right' => 'left');
21:
22: foreach ($sides as $side) {
23: $property = $side.'Model';
24: $this->$property = $configSlice->getRequired($side);
25: }
26:
27: foreach ($sides as $side => $opposing) {
28: $property = $side.'Property';
29: if(($this->$property = $configSlice->get($side.'Options.property', null)) === null)
30: $this->$property = $inflector->plural($this->get($opposing.'Model'));
31: }
32:
33: $this->pivot = $configSlice->get('pivot', null);
34:
35: if($this->pivot === null) {
36: $this->pivot = $this->rightProperty.ucfirst($this->leftProperty);
37: }
38:
39: $this->pivotConnection = $configSlice->get('pivotOptions.connection', null);
40:
41: foreach ($sides as $side => $opposing) {
42: $property = $side.'PivotKey';
43: if(($this->$property = $configSlice->get('pivotOptions.'.$side.'Key', null)) === null)
44: $this->$property = $inflector->singular($this->get($opposing.'Property')).'Id';
45: }
46: }
47: }
48: