| @@ 675-686 (lines=12) @@ | ||
| 672 | * |
|
| 673 | * @event created($document) |
|
| 674 | */ |
|
| 675 | public static function create($fields = [], ODMInterface $odm = null) |
|
| 676 | { |
|
| 677 | /** |
|
| 678 | * @var DocumentEntity $document |
|
| 679 | */ |
|
| 680 | $document = new static([], null, $odm); |
|
| 681 | ||
| 682 | //Forcing validation (empty set of fields is not valid set of fields) |
|
| 683 | $document->setFields($fields)->dispatch('created', new EntityEvent($document)); |
|
| 684 | ||
| 685 | return $document; |
|
| 686 | } |
|
| 687 | ||
| 688 | /** |
|
| 689 | * Called by ODM with set of loaded fields. Must return name of appropriate class. |
|
| @@ 754-765 (lines=12) @@ | ||
| 751 | * @param ORM $orm ORM component, global container will be called if not instance provided. |
|
| 752 | * @event created() |
|
| 753 | */ |
|
| 754 | public static function create($fields = [], ORMInterface $orm = null) |
|
| 755 | { |
|
| 756 | /** |
|
| 757 | * @var RecordEntity $record |
|
| 758 | */ |
|
| 759 | $record = new static([], false, $orm); |
|
| 760 | ||
| 761 | //Forcing validation (empty set of fields is not valid set of fields) |
|
| 762 | $record->setFields($fields)->dispatch('created', new EntityEvent($record)); |
|
| 763 | ||
| 764 | return $record; |
|
| 765 | } |
|
| 766 | } |
|