Skip to content

Commit 0f0ebe7

Browse files
authored
Fixes in PHP client for documentation (#71)
* Usage should be in comments for method: load, delete and store in DocumentSession and openSession in DocumentStore * Usage should be available on class description * Faceted searches fixes * DocumentQueryCustomization class implementation * Methods should have Usage samples * Methods should have usage explanations * Search terms should be able to be passed as an array * interface for ignoreChangesFor object should be enabled and available to be used in code * Update method comments * Need interface be open for method conditionalLoad * OperationExecutor send method should be updated with Usage examples * waitForCompletion should throw TimoutException if duration is defined * In Class Operation method waitForCompletion should return BulkOperationResult object upon succesfull completion * Duration should have option to be converted to DateTime interval * GetDetailedCollectionStatisticsOperation classes should be included * Add support to ToggleDatabasesStateOperation to receive multiple database names * Implement CompactDatabaseOperation and supporting files * PutIndexOperation should accept simple array of IndexDefinitions * We should be able to pass array of strings as parameter * Update classes for TogleDatabaseStateOperation * We should be able to pass array with IndexFieldOptions * DocumentQuery::aggregateBy should be able to receive FacetBaseArray as parameter * Updates required for facet classes * Implement getRevision in DocumentSessionAttachments * Rename includeRevisions builder * Document extensions > Revisions > Client API > Operations > Configure revisions * Document extensions > Revisions > Client API > Operations > Configure conflict revisions * Document extensions > Revisions > Client API > Operations > Get revisions * add method ofYears * Implement conditionalLoad in LazySessionOperations * Implement whatChangedFor in InMemoryDocumentSessionOperations * Time for rollups should be longer * Add support to PutServerWideClientConfigurationOperation
1 parent fefb2b5 commit 0f0ebe7

File tree

86 files changed

+1751
-514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1751
-514
lines changed

src/Documents/DocumentStore.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,17 @@ public function close(): void
145145
/**
146146
* Opens the session for a particular database
147147
*
148-
* @param null|string|SessionOptions $dbNameOrOptions Database to use
148+
* Usage
149+
*
150+
* Open session for a 'default' database configured in 'DocumentStore'
151+
* - openSession(): DocumentSessionInterface;
152+
*
153+
* Open session for a specified database
154+
* - openSession(string $database): DocumentSessionInterface;
155+
*
156+
* - openSession(SessionOptions $sessionOptions): DocumentSessionInterface;
157+
*
158+
* @param null|string|SessionOptions $dbNameOrOptions Database name or options to use
149159
*
150160
* @return DocumentSessionInterface Document session
151161
*/

src/Documents/Indexes/AbstractGenericIndexCreationTask.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ protected function index(?string $field, ?FieldIndexing $indexing): void
6060

6161
/**
6262
* Register a field to be spatially indexed
63+
*
64+
* Usage:
65+
* - spatial("shape", function ($x) {...})
66+
*
6367
* @param string|null $field Field
6468
* @param Closure $indexing factory for spatial options
6569
*/

src/Documents/Indexes/AbstractJavaScriptIndexCreationTask.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ public function getFields(): IndexFieldOptionsArray
3535
return $this->definition->getFields();
3636
}
3737

38-
public function setFields(?IndexFieldOptionsArray $fields): void
38+
public function setFields(null|IndexFieldOptionsArray|array $fields): void
3939
{
40+
if (is_array($fields)) {
41+
$fields = IndexFieldOptionsArray::fromArray($fields);
42+
}
4043
$this->definition->setFields($fields);
4144
}
4245

src/Documents/Indexes/IndexDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class IndexDefinition extends IndexDefinitionBase implements ResultInterface
1414
{
15-
public function __constructor()
15+
public function __construct()
1616
{
1717
parent::__construct();
1818

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace RavenDB\Documents\Operations;
4+
5+
use _PHPStan_b8e553790\Nette\Neon\Exception;
6+
use RavenDB\Type\TypedArray;
7+
8+
class BulkOperationDetailsArray extends TypedArray
9+
{
10+
public function __construct()
11+
{
12+
parent::__construct(BulkOperationDetailsInterface::class);
13+
}
14+
15+
/**
16+
* @throws Exception
17+
*/
18+
public static function createNewItemObjectFromValue(mixed $value): object
19+
{
20+
if (!array_key_exists('$type', $value)) {
21+
throw new Exception('Details array should have \'\$type\' key inside.');
22+
}
23+
24+
$type = $value['$type'];
25+
26+
// print_r($type);
27+
28+
switch ($type) {
29+
case 'Raven.Client.Documents.Operations.BulkOperationResult+DeleteDetails, Raven.Client':
30+
return BulkOperationResultDeleteDetails::fromArray($value);
31+
case 'Raven.Client.Documents.Operations.BulkOperationResult+PatchDetails, Raven.Client':
32+
return BulkOperationResultPatchDetails::fromArray($value);
33+
default:
34+
35+
break;
36+
}
37+
38+
throw new Exception('Unknown type: ' . $type);
39+
40+
}
41+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace RavenDB\Documents\Operations;
4+
5+
interface BulkOperationDetailsInterface
6+
{
7+
8+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
namespace RavenDB\Documents\Operations;
4+
5+
use Symfony\Component\Serializer\Annotation\SerializedName;
6+
7+
class BulkOperationResult
8+
{
9+
#[SerializedName('Total')]
10+
private ?int $total = null;
11+
#[SerializedName('DocumentsProcessed')]
12+
private ?int $documentsProcessed = null;
13+
#[SerializedName('AttachmentsProcessed')]
14+
private ?int $attachmentsProcessed = null;
15+
#[SerializedName('CountersProcessed')]
16+
private ?int $countersProcessed = null;
17+
#[SerializedName('TimeSeriesProcessed')]
18+
private ?int $timeSeriesProcessed = null;
19+
#[SerializedName('Query')]
20+
private ?string $query = null;
21+
// array<BulkOperationDetailsInterface> $details
22+
#[SerializedName('Details')]
23+
private ?BulkOperationDetailsArray $details = null;
24+
25+
// private bool $shouldPersist = false;
26+
// private bool $canMerge = true;
27+
// private string $message = "Processed {Total:#,#0} items.";
28+
29+
public function __construct()
30+
{
31+
$this->details = new BulkOperationDetailsArray();
32+
}
33+
34+
public function getTotal(): ?int
35+
{
36+
return $this->total;
37+
}
38+
39+
public function setTotal(?int $total): void
40+
{
41+
$this->total = $total;
42+
}
43+
44+
public function getDocumentsProcessed(): ?int
45+
{
46+
return $this->documentsProcessed;
47+
}
48+
49+
public function setDocumentsProcessed(?int $documentsProcessed): void
50+
{
51+
$this->documentsProcessed = $documentsProcessed;
52+
}
53+
54+
public function getAttachmentsProcessed(): ?int
55+
{
56+
return $this->attachmentsProcessed;
57+
}
58+
59+
public function setAttachmentsProcessed(?int $attachmentsProcessed): void
60+
{
61+
$this->attachmentsProcessed = $attachmentsProcessed;
62+
}
63+
64+
public function getCountersProcessed(): ?int
65+
{
66+
return $this->countersProcessed;
67+
}
68+
69+
public function setCountersProcessed(?int $countersProcessed): void
70+
{
71+
$this->countersProcessed = $countersProcessed;
72+
}
73+
74+
public function getTimeSeriesProcessed(): ?int
75+
{
76+
return $this->timeSeriesProcessed;
77+
}
78+
79+
public function setTimeSeriesProcessed(?int $timeSeriesProcessed): void
80+
{
81+
$this->timeSeriesProcessed = $timeSeriesProcessed;
82+
}
83+
84+
public function getQuery(): ?string
85+
{
86+
return $this->query;
87+
}
88+
89+
public function setQuery(?string $query): void
90+
{
91+
$this->query = $query;
92+
}
93+
94+
public function getDetails(): ?BulkOperationDetailsArray
95+
{
96+
return $this->details;
97+
}
98+
99+
public function setDetails(?BulkOperationDetailsArray $details): void
100+
{
101+
$this->details = $details;
102+
}
103+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace RavenDB\Documents\Operations;
4+
5+
class BulkOperationResultDeleteDetails implements BulkOperationDetailsInterface
6+
{
7+
private ?string $id = null;
8+
public ?int $etag = null;
9+
10+
public function getId(): ?string
11+
{
12+
return $this->id;
13+
}
14+
15+
public function setId(?string $id): void
16+
{
17+
$this->id = $id;
18+
}
19+
20+
public function getEtag(): ?int
21+
{
22+
return $this->etag;
23+
}
24+
25+
public function setEtag(?int $etag): void
26+
{
27+
$this->etag = $etag;
28+
}
29+
30+
public static function fromArray(array $data): BulkOperationResultDeleteDetails
31+
{
32+
$object = new BulkOperationResultDeleteDetails();
33+
34+
if (array_key_exists('Id', $data)) {
35+
$object->setId($data['Id']);
36+
}
37+
38+
if (array_key_exists('ETag', $data)) {
39+
$object->setEtag($data['ETag']);
40+
}
41+
42+
return $object;
43+
}
44+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace RavenDB\Documents\Operations;
4+
5+
class BulkOperationResultOperationDetails
6+
{
7+
public ?string $query = null;
8+
9+
public function getQuery(): ?string
10+
{
11+
return $this->query;
12+
}
13+
14+
public function setQuery(?string $query): void
15+
{
16+
$this->query = $query;
17+
}
18+
19+
public static function fromArray(array $data): BulkOperationResultOperationDetails
20+
{
21+
$object = new BulkOperationResultOperationDetails();
22+
23+
if (array_key_exists('Query', $data)) {
24+
$object->setQuery($data['Query']);
25+
}
26+
27+
return $object;
28+
}
29+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace RavenDB\Documents\Operations;
4+
5+
class BulkOperationResultPatchDetails implements BulkOperationDetailsInterface
6+
{
7+
public ?string $id = null;
8+
public ?string $changeVector = null;
9+
public ?PatchStatus $status = null;
10+
11+
public function getId(): ?string
12+
{
13+
return $this->id;
14+
}
15+
16+
public function setId(?string $id): void
17+
{
18+
$this->id = $id;
19+
}
20+
21+
public function getChangeVector(): ?string
22+
{
23+
return $this->changeVector;
24+
}
25+
26+
public function setChangeVector(?string $changeVector): void
27+
{
28+
$this->changeVector = $changeVector;
29+
}
30+
31+
public function getStatus(): ?PatchStatus
32+
{
33+
return $this->status;
34+
}
35+
36+
public function setStatus(?PatchStatus $status): void
37+
{
38+
$this->status = $status;
39+
}
40+
41+
public static function fromArray(array $data): BulkOperationResultPatchDetails
42+
{
43+
$object = new BulkOperationResultPatchDetails();
44+
45+
if (array_key_exists('Id', $data)) {
46+
$object->setId($data['Id']);
47+
}
48+
49+
if (array_key_exists('ChangeVector', $data)) {
50+
$object->setChangeVector($data['ChangeVector']);
51+
}
52+
53+
if (array_key_exists('Status', $data)) {
54+
$object->setStatus($data['Status']);
55+
}
56+
57+
return $object;
58+
}
59+
}

0 commit comments

Comments
 (0)