Cerys
4 weeks ago
6 changed files with 102 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||||
|
<?php |
||||
|
|
||||
|
require_once __DIR__ . '/../vendor/autoload.php'; |
||||
|
require_once __DIR__ . '/../examples/DeegraphConnection.php'; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder; |
||||
|
|
||||
|
|
||||
|
$result = QueryBuilder::References() |
||||
|
->RelativePath("{0b368d41-7c15-42c8-899c-2b178ae9d983}") |
||||
|
->Build() |
||||
|
->RunQuery(DeegraphConnection::DB()) |
||||
|
; |
||||
|
|
||||
|
echo "References\n"; |
||||
|
echo "=========\n"; |
||||
|
|
||||
|
foreach($result->Map as $key=>$value) |
||||
|
{ |
||||
|
echo str_pad($key, 20) . ": " . $value . "\n"; |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\ReferencesQuery; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Core\DeegraphServer; |
||||
|
|
||||
|
final class ReferencesQuery |
||||
|
{ |
||||
|
protected string $QueryString; |
||||
|
|
||||
|
public function __construct(string $queryString) |
||||
|
{ |
||||
|
$this->QueryString = $queryString; |
||||
|
} |
||||
|
|
||||
|
public function RunQuery(DeegraphServer $server): ReferencesQueryResponse |
||||
|
{ |
||||
|
$response = $server->RunRawRequest( |
||||
|
endpoint: "/api/v1/@query", |
||||
|
method: "POST", |
||||
|
body: $this->QueryString |
||||
|
); |
||||
|
$temp = json_decode($response, true); |
||||
|
return new ReferencesQueryResponse($temp); |
||||
|
} |
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\ReferencesQuery; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\PermissionsQuery\PermissionQuery; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderQuery] |
||||
|
final class ReferencesQueryBuilder |
||||
|
{ |
||||
|
|
||||
|
use QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderRequiredField] |
||||
|
protected string $RelativePath = ""; |
||||
|
|
||||
|
|
||||
|
public function RelativePath(string $relativePath): ReferencesQueryBuilder |
||||
|
{ |
||||
|
self::ValidateDeegraphPath(target: $relativePath); |
||||
|
$this->RelativePath = $relativePath; |
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function Build(): ReferencesQuery |
||||
|
{ |
||||
|
self::ValidateValues(target: $this); |
||||
|
|
||||
|
$builder = "REFERENCES " . $this->RelativePath; |
||||
|
|
||||
|
return new ReferencesQuery(queryString: $builder); |
||||
|
} |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\ReferencesQuery; |
||||
|
|
||||
|
class ReferencesQueryResponse |
||||
|
{ |
||||
|
public array $Map; |
||||
|
|
||||
|
public function __construct(array $deegraphResponse) |
||||
|
{ |
||||
|
$this->Map = $deegraphResponse["@map"]; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue