-
Notifications
You must be signed in to change notification settings - Fork 35
/
Document.php
37 lines (29 loc) 路 928 Bytes
/
Document.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/*
* This file is part of the jolicode/elastically library.
*
* (c) JoliCode <coucou@jolicode.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace JoliCode\Elastically\Model;
use Elastica\Document as ElasticaDocument;
use Elastica\Index;
class Document extends ElasticaDocument
{
private ?object $model;
public function __construct(?string $id, ?object $model = null, array|string $data = [], Index|string $index = '')
{
parent::__construct($id, $data, $index);
$this->model = $model;
}
public static function createFromDocument(ElasticaDocument $document, ?object $model = null): self
{
return new self($document->getId(), $model, $document->getData(), $document->getIndex());
}
public function getModel(): ?object
{
return $this->model;
}
}