1: <?php
2:
3: namespace PHPixie\ORM\Relationships\Type\OneTo\Side;
4:
5: abstract class Config extends \PHPixie\ORM\Relationships\Relationship\Implementation\Side\Config
6: {
7: public $ownerModel;
8: public $itemModel;
9: public $ownerKey;
10: public $itemOwnerProperty;
11: public $onDelete;
12:
13: protected function processConfig($configSlice, $inflector)
14: {
15: $itemOptionName = $this->itemOptionName();
16: $itemPropertyName = $this->ownerPropertyName();
17:
18: $this->ownerModel = $configSlice->getRequired('owner');
19: $this->itemModel = $configSlice->getRequired($itemOptionName);
20:
21: $itemOptionsPrefix = $itemOptionName.'Options';
22: $this->itemOwnerProperty = $configSlice->get($itemOptionsPrefix.'.ownerProperty', $this->ownerModel);
23: $this->ownerKey = $configSlice->get($itemOptionsPrefix.'.ownerKey', $this->itemOwnerProperty.'Id');
24: $this->onDelete = $configSlice->get($itemOptionsPrefix.'.onOwnerDelete', 'update');
25:
26: $itemProperty = $configSlice->get('ownerOptions.'.$itemOptionName.'Property', null);
27: if ($itemProperty === null)
28: $itemProperty = $this->defaultOwnerProperty($inflector);
29:
30: $this->$itemPropertyName = $itemProperty;
31: }
32:
33: public function ownerProperty()
34: {
35: $property = $this->ownerPropertyName();
36: return $this->$property;
37: }
38:
39: abstract protected function itemOptionName();
40: abstract protected function ownerPropertyName();
41: abstract protected function defaultOwnerProperty($inflector);
42: }
43: