Skip to content

Commit

Permalink
Fix after upgraded library
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Feb 26, 2024
1 parent 22e4c1b commit b924ec3
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
use Doctrine\Common;
use Doctrine\ORM;
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineOrmQuery;
use Ramsey\Uuid;
use function in_array;

/**
* Find channel controls entities query
Expand Down Expand Up @@ -72,17 +70,13 @@ public function byChannelId(Uuid\UuidInterface $channelId): void
};
}

/**
* @throws Exceptions\InvalidArgument
*/
public function sortBy(string $sortBy, string $sortDir = Common\Collections\Criteria::ASC): void
public function sortBy(
string $sortBy,
Common\Collections\Order $sortDir = Common\Collections\Order::Ascending,
): void
{
if (!in_array($sortDir, [Common\Collections\Criteria::ASC, Common\Collections\Criteria::DESC], true)) {
throw new Exceptions\InvalidArgument('Provided sortDir value is not valid.');
}

$this->filter[] = static function (ORM\QueryBuilder $qb) use ($sortBy, $sortDir): void {
$qb->addOrderBy($sortBy, $sortDir);
$qb->addOrderBy($sortBy, $sortDir->value);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
use Doctrine\Common;
use Doctrine\ORM;
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineOrmQuery;
use Ramsey\Uuid;
use function in_array;

/**
* Find channel properties entities query
Expand Down Expand Up @@ -116,17 +114,13 @@ public function queryable(bool $state): void
};
}

/**
* @throws Exceptions\InvalidArgument
*/
public function sortBy(string $sortBy, string $sortDir = Common\Collections\Criteria::ASC): void
public function sortBy(
string $sortBy,
Common\Collections\Order $sortDir = Common\Collections\Order::Ascending,
): void
{
if (!in_array($sortDir, [Common\Collections\Criteria::ASC, Common\Collections\Criteria::DESC], true)) {
throw new Exceptions\InvalidArgument('Provided sortDir value is not valid.');
}

$this->filter[] = static function (ORM\QueryBuilder $qb) use ($sortBy, $sortDir): void {
$qb->addOrderBy($sortBy, $sortDir);
$qb->addOrderBy($sortBy, $sortDir->value);
};
}

Expand Down
16 changes: 5 additions & 11 deletions src/FastyBird/Module/Devices/src/Queries/Entities/FindChannels.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
use Doctrine\Common;
use Doctrine\ORM;
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineOrmQuery;
use Ramsey\Uuid;
use function in_array;

/**
* Find device channels entities query
Expand Down Expand Up @@ -113,17 +111,13 @@ public function withSettableProperties(): void
};
}

/**
* @throws Exceptions\InvalidArgument
*/
public function sortBy(string $sortBy, string $sortDir = Common\Collections\Criteria::ASC): void
public function sortBy(
string $sortBy,
Common\Collections\Order $sortDir = Common\Collections\Order::Ascending,
): void
{
if (!in_array($sortDir, [Common\Collections\Criteria::ASC, Common\Collections\Criteria::DESC], true)) {
throw new Exceptions\InvalidArgument('Provided sortDir value is not valid.');
}

$this->filter[] = static function (ORM\QueryBuilder $qb) use ($sortBy, $sortDir): void {
$qb->addOrderBy($sortBy, $sortDir);
$qb->addOrderBy($sortBy, $sortDir->value);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
use Doctrine\Common;
use Doctrine\ORM;
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineOrmQuery;
use Ramsey\Uuid;
use function in_array;

/**
* Find connector properties entities query
Expand Down Expand Up @@ -72,17 +70,13 @@ public function byConnectorId(Uuid\UuidInterface $connectorId): void
};
}

/**
* @throws Exceptions\InvalidArgument
*/
public function sortBy(string $sortBy, string $sortDir = Common\Collections\Criteria::ASC): void
public function sortBy(
string $sortBy,
Common\Collections\Order $sortDir = Common\Collections\Order::Ascending,
): void
{
if (!in_array($sortDir, [Common\Collections\Criteria::ASC, Common\Collections\Criteria::DESC], true)) {
throw new Exceptions\InvalidArgument('Provided sortDir value is not valid.');
}

$this->filter[] = static function (ORM\QueryBuilder $qb) use ($sortBy, $sortDir): void {
$qb->addOrderBy($sortBy, $sortDir);
$qb->addOrderBy($sortBy, $sortDir->value);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
use Doctrine\Common;
use Doctrine\ORM;
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineOrmQuery;
use Ramsey\Uuid;
use function in_array;

/**
* Find connector properties entities query
Expand Down Expand Up @@ -101,17 +99,13 @@ public function queryable(bool $state): void
};
}

/**
* @throws Exceptions\InvalidArgument
*/
public function sortBy(string $sortBy, string $sortDir = Common\Collections\Criteria::ASC): void
public function sortBy(
string $sortBy,
Common\Collections\Order $sortDir = Common\Collections\Order::Ascending,
): void
{
if (!in_array($sortDir, [Common\Collections\Criteria::ASC, Common\Collections\Criteria::DESC], true)) {
throw new Exceptions\InvalidArgument('Provided sortDir value is not valid.');
}

$this->filter[] = static function (ORM\QueryBuilder $qb) use ($sortBy, $sortDir): void {
$qb->addOrderBy($sortBy, $sortDir);
$qb->addOrderBy($sortBy, $sortDir->value);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
use Doctrine\Common;
use Doctrine\ORM;
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineOrmQuery;
use Ramsey\Uuid;
use function in_array;

/**
* Find connectors entities query
Expand Down Expand Up @@ -57,17 +55,13 @@ public function byIdentifier(string $identifier): void
};
}

/**
* @throws Exceptions\InvalidArgument
*/
public function sortBy(string $sortBy, string $sortDir = Common\Collections\Criteria::ASC): void
public function sortBy(
string $sortBy,
Common\Collections\Order $sortDir = Common\Collections\Order::Ascending,
): void
{
if (!in_array($sortDir, [Common\Collections\Criteria::ASC, Common\Collections\Criteria::DESC], true)) {
throw new Exceptions\InvalidArgument('Provided sortDir value is not valid.');
}

$this->filter[] = static function (ORM\QueryBuilder $qb) use ($sortBy, $sortDir): void {
$qb->addOrderBy($sortBy, $sortDir);
$qb->addOrderBy($sortBy, $sortDir->value);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
use Doctrine\Common;
use Doctrine\ORM;
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineOrmQuery;
use Ramsey\Uuid;
use function in_array;

/**
* Find device controls entities query
Expand Down Expand Up @@ -72,17 +70,13 @@ public function byDeviceId(Uuid\UuidInterface $deviceId): void
};
}

/**
* @throws Exceptions\InvalidArgument
*/
public function sortBy(string $sortBy, string $sortDir = Common\Collections\Criteria::ASC): void
public function sortBy(
string $sortBy,
Common\Collections\Order $sortDir = Common\Collections\Order::Ascending,
): void
{
if (!in_array($sortDir, [Common\Collections\Criteria::ASC, Common\Collections\Criteria::DESC], true)) {
throw new Exceptions\InvalidArgument('Provided sortDir value is not valid.');
}

$this->filter[] = static function (ORM\QueryBuilder $qb) use ($sortBy, $sortDir): void {
$qb->addOrderBy($sortBy, $sortDir);
$qb->addOrderBy($sortBy, $sortDir->value);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
use Doctrine\Common;
use Doctrine\ORM;
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineOrmQuery;
use Ramsey\Uuid;
use function in_array;

/**
* Find device properties entities query
Expand Down Expand Up @@ -116,17 +114,13 @@ public function queryable(bool $state): void
};
}

/**
* @throws Exceptions\InvalidArgument
*/
public function sortBy(string $sortBy, string $sortDir = Common\Collections\Criteria::ASC): void
public function sortBy(
string $sortBy,
Common\Collections\Order $sortDir = Common\Collections\Order::Ascending,
): void
{
if (!in_array($sortDir, [Common\Collections\Criteria::ASC, Common\Collections\Criteria::DESC], true)) {
throw new Exceptions\InvalidArgument('Provided sortDir value is not valid.');
}

$this->filter[] = static function (ORM\QueryBuilder $qb) use ($sortBy, $sortDir): void {
$qb->addOrderBy($sortBy, $sortDir);
$qb->addOrderBy($sortBy, $sortDir->value);
};
}

Expand Down
16 changes: 5 additions & 11 deletions src/FastyBird/Module/Devices/src/Queries/Entities/FindDevices.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
use Doctrine\Common;
use Doctrine\ORM;
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineOrmQuery;
use Ramsey\Uuid;
use function in_array;

/**
* Find devices entities query
Expand Down Expand Up @@ -144,17 +142,13 @@ public function withChannels(): void
};
}

/**
* @throws Exceptions\InvalidArgument
*/
public function sortBy(string $sortBy, string $sortDir = Common\Collections\Criteria::ASC): void
public function sortBy(
string $sortBy,
Common\Collections\Order $sortDir = Common\Collections\Order::Ascending,
): void
{
if (!in_array($sortDir, [Common\Collections\Criteria::ASC, Common\Collections\Criteria::DESC], true)) {
throw new Exceptions\InvalidArgument('Provided sortDir value is not valid.');
}

$this->filter[] = static function (ORM\QueryBuilder $qb) use ($sortBy, $sortDir): void {
$qb->addOrderBy($sortBy, $sortDir);
$qb->addOrderBy($sortBy, $sortDir->value);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
use Doctrine\Common;
use Doctrine\ORM;
use FastyBird\Module\Triggers\Entities;
use FastyBird\Module\Triggers\Exceptions;
use IPub\DoctrineOrmQuery;
use Ramsey\Uuid;
use function in_array;

/**
* Find trigger properties entities query
Expand Down Expand Up @@ -71,17 +69,13 @@ public function forTrigger(Entities\Triggers\Trigger $trigger): void
};
}

/**
* @throws Exceptions\InvalidArgument
*/
public function sortBy(string $sortBy, string $sortDir = Common\Collections\Criteria::ASC): void
public function sortBy(
string $sortBy,
Common\Collections\Order $sortDir = Common\Collections\Order::Ascending,
): void
{
if (!in_array($sortDir, [Common\Collections\Criteria::ASC, Common\Collections\Criteria::DESC], true)) {
throw new Exceptions\InvalidArgument('Provided sortDir value is not valid.');
}

$this->filter[] = static function (ORM\QueryBuilder $qb) use ($sortBy, $sortDir): void {
$qb->addOrderBy($sortBy, $sortDir);
$qb->addOrderBy($sortBy, $sortDir->value);
};
}

Expand Down

0 comments on commit b924ec3

Please sign in to comment.