| @@ 594-615 (lines=22) @@ | ||
| 591 | * |
|
| 592 | * @throws DocumentException |
|
| 593 | */ |
|
| 594 | protected function validate($reset = false) |
|
| 595 | { |
|
| 596 | $this->innerErrors = []; |
|
| 597 | ||
| 598 | //Validating all compositions |
|
| 599 | foreach ($this->odmSchema[ODM::D_COMPOSITIONS] as $field) { |
|
| 600 | ||
| 601 | $composition = $this->getField($field); |
|
| 602 | if (!$composition instanceof ValidatesInterface) { |
|
| 603 | //Something weird. |
|
| 604 | continue; |
|
| 605 | } |
|
| 606 | ||
| 607 | if (!$composition->isValid()) { |
|
| 608 | $this->innerErrors[$field] = $composition->getErrors($reset); |
|
| 609 | } |
|
| 610 | } |
|
| 611 | ||
| 612 | parent::validate($reset); |
|
| 613 | ||
| 614 | return $this->hasErrors() && empty($this->innerErrors); |
|
| 615 | } |
|
| 616 | ||
| 617 | /** |
|
| 618 | * {@inheritdoc} |
|
| @@ 629-647 (lines=19) @@ | ||
| 626 | * |
|
| 627 | * @throws RecordException |
|
| 628 | */ |
|
| 629 | protected function validate($reset = false) |
|
| 630 | { |
|
| 631 | $this->innerErrors = []; |
|
| 632 | ||
| 633 | foreach ($this->relations as $name => $relation) { |
|
| 634 | if (!$relation instanceof ValidatesInterface) { |
|
| 635 | //Never constructed |
|
| 636 | continue; |
|
| 637 | } |
|
| 638 | ||
| 639 | if ($this->embeddedRelation($name) && !$relation->isValid()) { |
|
| 640 | $this->innerErrors[$name] = $relation->getErrors($reset); |
|
| 641 | } |
|
| 642 | } |
|
| 643 | ||
| 644 | parent::validate($reset); |
|
| 645 | ||
| 646 | return $this->hasErrors() && empty($this->innerErrors); |
|
| 647 | } |
|
| 648 | ||
| 649 | /** |
|
| 650 | * Get WHERE array to be used to perform record data update or deletion. Usually will include |
|