| @@ 587-598 (lines=12) @@ | ||
| 584 | * |
|
| 585 | * @event created($document) |
|
| 586 | */ |
|
| 587 | public static function create($fields = [], ODMInterface $odm = null) |
|
| 588 | { |
|
| 589 | /** |
|
| 590 | * @var DocumentEntity $document |
|
| 591 | */ |
|
| 592 | $document = new static([], null, $odm); |
|
| 593 | ||
| 594 | //Forcing validation (empty set of fields is not valid set of fields) |
|
| 595 | $document->setFields($fields)->dispatch('created', new EntityEvent($document)); |
|
| 596 | ||
| 597 | return $document; |
|
| 598 | } |
|
| 599 | ||
| 600 | /** |
|
| 601 | * Called by ODM with set of loaded fields. Must return name of appropriate class. |
|
| @@ 677-688 (lines=12) @@ | ||
| 674 | * @param ORM $orm ORM component, global container will be called if not instance provided. |
|
| 675 | * @event created() |
|
| 676 | */ |
|
| 677 | public static function create($fields = [], ORMInterface $orm = null) |
|
| 678 | { |
|
| 679 | /** |
|
| 680 | * @var RecordEntity $record |
|
| 681 | */ |
|
| 682 | $record = new static([], false, $orm); |
|
| 683 | ||
| 684 | //Forcing validation (empty set of fields is not valid set of fields) |
|
| 685 | $record->setFields($fields)->dispatch('created', new EntityEvent($record)); |
|
| 686 | ||
| 687 | return $record; |
|
| 688 | } |
|
| 689 | } |
|