Cerys
4 weeks ago
9 changed files with 166 additions and 131 deletions
@ -0,0 +1,20 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderQuery] |
||||
|
class LinkQuery_Step1 |
||||
|
{ |
||||
|
use QueryBuilderTrait; |
||||
|
|
||||
|
public function RelativePath(string $relativePath): LinkQuery_Step2 |
||||
|
{ |
||||
|
self::ValidateDeegraphPath(target: $relativePath); |
||||
|
return new LinkQuery_Step2(querySoFar: "LINK " . $relativePath); |
||||
|
} |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderQuery] |
||||
|
class LinkQuery_Step2 |
||||
|
{ |
||||
|
use QueryBuilderTrait; |
||||
|
private string $QuerySoFar = ""; |
||||
|
public function __construct(string $querySoFar) |
||||
|
{ |
||||
|
$this->QuerySoFar = $querySoFar; |
||||
|
} |
||||
|
|
||||
|
public function To(string $relativePath): LinkQuery_Step3 |
||||
|
{ |
||||
|
self::ValidateDeegraphPath(target: $relativePath); |
||||
|
return new LinkQuery_Step3($this->QuerySoFar . " TO " . $relativePath); |
||||
|
} |
||||
|
|
||||
|
public function Of(string $relativePath): LinkQuery_Step3 |
||||
|
{ |
||||
|
self::ValidateDeegraphPath(target: $relativePath); |
||||
|
return new LinkQuery_Step3($this->QuerySoFar . " OF " . $relativePath); |
||||
|
} |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQuery; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderQuery] |
||||
|
class LinkQuery_Step3 |
||||
|
{ |
||||
|
use QueryBuilderTrait; |
||||
|
private string $QuerySoFar = ""; |
||||
|
public function __construct(string $querySoFar) |
||||
|
{ |
||||
|
$this->QuerySoFar = $querySoFar; |
||||
|
} |
||||
|
|
||||
|
public function As(string $asPropertyName): LinkQuery_Step4 |
||||
|
{ |
||||
|
self::ValidateDeegraphPath(target: $asPropertyName); |
||||
|
return new LinkQuery_Step4($this->QuerySoFar . " AS " . $asPropertyName); |
||||
|
} |
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQuery; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderQuery] |
||||
|
class LinkQuery_Step4 |
||||
|
{ |
||||
|
use QueryBuilderTrait; |
||||
|
private string $QuerySoFar = ""; |
||||
|
public function __construct(string $querySoFar) |
||||
|
{ |
||||
|
$this->QuerySoFar = $querySoFar; |
||||
|
} |
||||
|
|
||||
|
public function Overwrite(): LinkQuery_Step9 |
||||
|
{ |
||||
|
return new LinkQuery_Step9($this->QuerySoFar . " OVERWRITE"); |
||||
|
} |
||||
|
|
||||
|
public function Replace(): LinkQuery_Step9 |
||||
|
{ |
||||
|
return new LinkQuery_Step9($this->QuerySoFar . " REPLACE"); |
||||
|
} |
||||
|
|
||||
|
public function Force(): LinkQuery_Step9 |
||||
|
{ |
||||
|
return new LinkQuery_Step9($this->QuerySoFar . " FORCE"); |
||||
|
} |
||||
|
|
||||
|
public function Build(): LinkQuery |
||||
|
{ |
||||
|
return new LinkQuery($this->QuerySoFar); |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQuery; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderQuery] |
||||
|
class LinkQuery_Step9 |
||||
|
{ |
||||
|
use QueryBuilderTrait; |
||||
|
private string $QuerySoFar = ""; |
||||
|
public function __construct(string $querySoFar) |
||||
|
{ |
||||
|
$this->QuerySoFar = $querySoFar; |
||||
|
} |
||||
|
|
||||
|
public function Build() |
||||
|
{ |
||||
|
return new LinkQuery($this->QuerySoFar); |
||||
|
} |
||||
|
} |
@ -1,106 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery; |
|
||||
|
|
||||
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
|
||||
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
|
||||
use Darksparrow\DeegraphInteractions\QueryBuilder\DirectoryQuery\DirectoryQuery; |
|
||||
use Darksparrow\DeegraphInteractions\QueryBuilder\DirectoryQuery\DirectoryQueryBuilder; |
|
||||
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
|
||||
|
|
||||
#[QueryBuilderQuery] |
|
||||
class LinkQueryBuilder |
|
||||
{ |
|
||||
use QueryBuilderTrait; |
|
||||
|
|
||||
#[QueryBuilderRequiredField] |
|
||||
protected string $RelativePath1 = ""; |
|
||||
|
|
||||
#[QueryBuilderRequiredField] |
|
||||
protected string $ToOrOf = ""; |
|
||||
|
|
||||
#[QueryBuilderRequiredField] |
|
||||
protected string $RelativePath2 = ""; |
|
||||
|
|
||||
#[QueryBuilderRequiredField] |
|
||||
protected string $PropertyName = ""; |
|
||||
|
|
||||
|
|
||||
protected string $Mode = ""; |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
public function LinkWhat(string $relativePath): LinkQueryBuilder |
|
||||
{ |
|
||||
self::ValidateDeegraphPath(target: $relativePath); |
|
||||
$this->RelativePath1 = $relativePath; |
|
||||
return $this; |
|
||||
} |
|
||||
public function LinkTo(string $relativePath): LinkQueryBuilder |
|
||||
{ |
|
||||
self::EnsureNotSet($this->RelativePath2); |
|
||||
self::ValidateDeegraphPath(target: $relativePath); |
|
||||
$this->RelativePath2 = $relativePath; |
|
||||
$this->ToOrOf = "TO"; |
|
||||
return $this; |
|
||||
} |
|
||||
public function LinkOf(string $relativePath): LinkQueryBuilder |
|
||||
{ |
|
||||
self::EnsureNotSet($this->RelativePath2); |
|
||||
self::ValidateDeegraphPath(target: $relativePath); |
|
||||
$this->RelativePath2 = $relativePath; |
|
||||
$this->ToOrOf = "OF"; |
|
||||
return $this; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
public function PropertyName(string $propertyName): LinkQueryBuilder |
|
||||
{ |
|
||||
$this->PropertyName = $propertyName; |
|
||||
return $this; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
public function Overwrite(): LinkQueryBuilder |
|
||||
{ |
|
||||
self::EnsureNotSet($this->Mode); |
|
||||
$this->Mode = "OVERWRITE"; |
|
||||
return $this; |
|
||||
} |
|
||||
public function Replace(): LinkQueryBuilder |
|
||||
{ |
|
||||
self::EnsureNotSet($this->Mode); |
|
||||
$this->Mode = "REPLACE"; |
|
||||
return $this; |
|
||||
} |
|
||||
public function Force(): LinkQueryBuilder |
|
||||
{ |
|
||||
self::EnsureNotSet($this->Mode); |
|
||||
$this->Mode = "FORCE"; |
|
||||
return $this; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
public function Build(): LinkQuery |
|
||||
{ |
|
||||
self::ValidateValues(target: $this); |
|
||||
|
|
||||
$builder = "LINK " |
|
||||
. $this->RelativePath1 |
|
||||
. " " |
|
||||
. $this->ToOrOf |
|
||||
. " " |
|
||||
. $this->RelativePath2 |
|
||||
. " AS " |
|
||||
. $this->PropertyName; |
|
||||
|
|
||||
if($this->Mode != "") $builder .= " " . $this->Mode; |
|
||||
|
|
||||
return new LinkQuery(queryString: $builder); |
|
||||
} |
|
||||
} |
|
||||
|
|
Loading…
Reference in new issue