| @@ 666-677 (lines=12) @@ | ||
| 663 | * |
|
| 664 | * @event created($document) |
|
| 665 | */ |
|
| 666 | public static function create($fields = [], ODMInterface $odm = null) |
|
| 667 | { |
|
| 668 | /** |
|
| 669 | * @var DocumentEntity $document |
|
| 670 | */ |
|
| 671 | $document = new static([], null, $odm); |
|
| 672 | ||
| 673 | //Forcing validation (empty set of fields is not valid set of fields) |
|
| 674 | $document->setFields($fields)->dispatch('created', new EntityEvent($document)); |
|
| 675 | ||
| 676 | return $document; |
|
| 677 | } |
|
| 678 | ||
| 679 | /** |
|
| 680 | * Called by ODM with set of loaded fields. Must return name of appropriate class. |
|
| @@ 738-749 (lines=12) @@ | ||
| 735 | * @param ORM $orm ORM component, global container will be called if not instance provided. |
|
| 736 | * @event created() |
|
| 737 | */ |
|
| 738 | public static function create($fields = [], ORMInterface $orm = null) |
|
| 739 | { |
|
| 740 | /** |
|
| 741 | * @var RecordEntity $record |
|
| 742 | */ |
|
| 743 | $record = new static([], false, $orm); |
|
| 744 | ||
| 745 | //Forcing validation (empty set of fields is not valid set of fields) |
|
| 746 | $record->setFields($fields)->dispatch('created', new EntityEvent($record)); |
|
| 747 | ||
| 748 | return $record; |
|
| 749 | } |
|
| 750 | } |
|