| @@ 58-71 (lines=14) @@ | ||
| 55 | * |
|
| 56 | * @throws SourceException |
|
| 57 | */ |
|
| 58 | public function __construct($class = null, ODMInterface $odm = null) |
|
| 59 | { |
|
| 60 | if (empty($class)) { |
|
| 61 | if (empty(static::DOCUMENT)) { |
|
| 62 | throw new SourceException('Unable to create source without associated class'); |
|
| 63 | } |
|
| 64 | ||
| 65 | $class = static::DOCUMENT; |
|
| 66 | } |
|
| 67 | ||
| 68 | $this->class = $class; |
|
| 69 | $this->odm = $this->saturate($odm, ODMInterface::class); |
|
| 70 | $this->setSelector($this->odm->selector($this->class)); |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * Create new DocumentEntity based on set of provided fields. |
|
| @@ 59-72 (lines=14) @@ | ||
| 56 | * |
|
| 57 | * @throws SugarException |
|
| 58 | */ |
|
| 59 | public function __construct($class = null, ORMInterface $orm = null) |
|
| 60 | { |
|
| 61 | if (empty($class)) { |
|
| 62 | if (empty(static::RECORD)) { |
|
| 63 | throw new SourceException('Unable to create source without associated class'); |
|
| 64 | } |
|
| 65 | ||
| 66 | $class = static::RECORD; |
|
| 67 | } |
|
| 68 | ||
| 69 | $this->class = $class; |
|
| 70 | $this->orm = $this->saturate($orm, ORMInterface::class); |
|
| 71 | $this->setSelector($this->orm->selector($this->class)); |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| 75 | * Create new Record based on set of provided fields. |
|