| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace Atk4\Data\Model\Scope; |
| 6: | |
| 7: | use Atk4\Core\InitializerTrait; |
| 8: | use Atk4\Core\TrackableTrait; |
| 9: | use Atk4\Core\WarnDynamicPropertyTrait; |
| 10: | use Atk4\Data\Exception; |
| 11: | use Atk4\Data\Model; |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | abstract class AbstractScope |
| 17: | { |
| 18: | use InitializerTrait { |
| 19: | init as private _init; |
| 20: | } |
| 21: | use TrackableTrait; |
| 22: | use WarnDynamicPropertyTrait; |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | protected function init(): void |
| 28: | { |
| 29: | $owner = $this->getOwner(); |
| 30: | if (!$owner instanceof self) { |
| 31: | throw new Exception('Scope can only be added as element to scope'); |
| 32: | } |
| 33: | |
| 34: | $this->_init(); |
| 35: | |
| 36: | $this->onChangeModel(); |
| 37: | } |
| 38: | |
| 39: | abstract protected function onChangeModel(): void; |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public function getModel(): ?Model |
| 45: | { |
| 46: | return $this->issetOwner() ? $this->getOwner()->getModel() : null; |
| 47: | } |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | abstract public function clear(): self; |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | |
| 60: | |
| 61: | abstract public function negate(): self; |
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: | abstract public function isEmpty(): bool; |
| 67: | |
| 68: | |
| 69: | |
| 70: | |
| 71: | abstract public function toWords(Model $model = null): string; |
| 72: | |
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: | public function simplify(): self |
| 78: | { |
| 79: | return $this; |
| 80: | } |
| 81: | |
| 82: | |
| 83: | |
| 84: | |
| 85: | public function isCompound(): bool |
| 86: | { |
| 87: | return false; |
| 88: | } |
| 89: | } |
| 90: | |