-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
874 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Vdhicts\Dicms\Filter; | ||
|
||
use Vdhicts\Dicms\Filter\Contracts; | ||
|
||
class OrderAdapter implements Contracts\OrderAdapter | ||
{ | ||
/** | ||
* Returns the query builder with the order applied. | ||
* @param mixed $builder | ||
* @param Order $order | ||
* @return mixed | ||
*/ | ||
public function getOrderQuery($builder, Order $order) | ||
{ | ||
foreach ($order->get() as $orderField) { | ||
/** @var OrderField $orderField */ | ||
$builder = $builder->orderBy($orderField->getField(), $orderField->getDirection()); | ||
} | ||
|
||
return $builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Vdhicts\Dicms\Filter; | ||
|
||
use Vdhicts\Dicms\Filter\Contracts; | ||
|
||
class PaginationAdapter implements Contracts\PaginationAdapter | ||
{ | ||
/** | ||
* Returns the query builder with the pagination applied. | ||
* @param mixed $builder | ||
* @param Pagination $pagination | ||
* @return mixed | ||
*/ | ||
public function getPaginationQuery($builder, Pagination $pagination) | ||
{ | ||
return $builder->limit($pagination->getLimit()) | ||
->offset($pagination->getOffset()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Vdhicts\Dicms\Filter\Contracts; | ||
|
||
use Vdhicts\Dicms\Filter\Order; | ||
|
||
interface OrderAdapter | ||
{ | ||
/** | ||
* Returns the query builder with the order applied. | ||
* @param mixed $builder | ||
* @param Order $order | ||
* @return mixed | ||
*/ | ||
public function getOrderQuery($builder, Order $order); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Vdhicts\Dicms\Filter\Contracts; | ||
|
||
use Vdhicts\Dicms\Filter\Pagination; | ||
|
||
interface PaginationAdapter | ||
{ | ||
/** | ||
* Returns the query builder with the pagination applied. | ||
* @param mixed $builder | ||
* @param Pagination $pagination | ||
* @return mixed | ||
*/ | ||
public function getPaginationQuery($builder, Pagination $pagination); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Vdhicts\Dicms\Filter\Exceptions; | ||
|
||
use Vdhicts\Dicms\Filter\FilterException; | ||
|
||
class DuplicatedGroup extends FilterException | ||
{ | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Vdhicts\Dicms\Filter\Exceptions; | ||
|
||
use Vdhicts\Dicms\Filter\FilterException; | ||
|
||
class InvalidApproval extends FilterException | ||
{ | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Vdhicts\Dicms\Filter\Exceptions; | ||
|
||
use Exception; | ||
use Vdhicts\Dicms\Filter\FilterException; | ||
|
||
class InvalidOrderDirection extends FilterException | ||
{ | ||
/** | ||
* InvalidOrderDirection constructor. | ||
* @param string $direction | ||
* @param array $supportedDirections | ||
* @param Exception|null $previous | ||
*/ | ||
public function __construct($direction, array $supportedDirections, Exception $previous = null) | ||
{ | ||
parent::__construct( | ||
sprintf( | ||
'Direction `%s` not supported, please use on of the `%s` directions', | ||
$direction, | ||
implode(', ', $supportedDirections) | ||
), | ||
0, | ||
$previous | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Vdhicts\Dicms\Filter\Exceptions; | ||
|
||
use Exception; | ||
use Vdhicts\Dicms\Filter\FilterException; | ||
|
||
class InvalidOrderField extends FilterException | ||
{ | ||
/** | ||
* InvalidOrderField constructor. | ||
* @param string $field | ||
* @param Exception|null $previous | ||
*/ | ||
public function __construct($field, Exception $previous = null) | ||
{ | ||
parent::__construct( | ||
sprintf('Invalid field provided, it must be a string and filled'), | ||
0, | ||
$previous | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.