-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ArticleRepository and ArticleController getAction
- Loading branch information
1 parent
8857c9f
commit b832467
Showing
16 changed files
with
987 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Sulu\Bundle\ArticleBundle\Domain\Exception; | ||
|
||
use Sulu\Bundle\ArticleBundle\Domain\Model\ArticleInterface; | ||
|
||
class ArticleNotFoundException extends \Exception | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $model; | ||
|
||
/** | ||
* @var mixed[] | ||
*/ | ||
private $filters; | ||
|
||
/** | ||
* @param mixed[] $filters | ||
*/ | ||
public function __construct(array $filters, int $code = 0, \Throwable $previous = null) | ||
{ | ||
$this->model = ArticleInterface::class; | ||
|
||
$criteriaMessages = []; | ||
foreach ($filters as $key => $value) { | ||
$value = new \stdClass(); | ||
|
||
if (\is_object($value)) { | ||
$value = \get_debug_type($value); | ||
} else { | ||
$value = \json_encode($value); | ||
} | ||
|
||
$criteriaMessages[] = \sprintf('"%s" %s', $key, $value); | ||
} | ||
|
||
$message = \sprintf( | ||
'Model "%s" with %s not found', | ||
$this->model, | ||
\implode(' and ', $criteriaMessages) | ||
); | ||
|
||
parent::__construct($message, $code, $previous); | ||
|
||
$this->filters = $filters; | ||
} | ||
|
||
public function getModel(): string | ||
{ | ||
return $this->model; | ||
} | ||
|
||
/** | ||
* @return mixed[] | ||
*/ | ||
public function getCriteria(): array | ||
{ | ||
return $this->filters; | ||
} | ||
|
||
} |
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,89 @@ | ||
<?php | ||
|
||
namespace Sulu\Bundle\ArticleBundle\Domain\Repository; | ||
|
||
use Sulu\Bundle\ArticleBundle\Domain\Exception\ArticleNotFoundException; | ||
use Sulu\Bundle\ArticleBundle\Domain\Model\ArticleInterface; | ||
|
||
/** | ||
* Implementation can be found in the following class: | ||
* | ||
* @see Sulu\Bundle\ArticleBundle\Infrastructure\Doctrine\Repository\ArticleRepository | ||
*/ | ||
interface ArticleRepositoryInterface | ||
{ | ||
public function createNew(?string $uuid = null): ArticleInterface; | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string, | ||
* uuids?: string[], | ||
* locale?: string, | ||
* stage?: string, | ||
* } $filters | ||
* | ||
* @param array{ | ||
* context?: string, | ||
* } $options | ||
* | ||
* @throws ArticleNotFoundException | ||
*/ | ||
public function getOneBy(array $filters, array $options = []): ArticleInterface; | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string, | ||
* uuids?: string[], | ||
* locale?: string, | ||
* stage?: string, | ||
* } $filters | ||
*/ | ||
public function findOneBy(array $filters): ?ArticleInterface; | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string, | ||
* uuids?: string[], | ||
* locale?: string, | ||
* stage?: string, | ||
* categoryIds?: int[], | ||
* categoryKeys?: int[], | ||
* categoryOperator?: 'AND'|'OR', | ||
* tagIds?: int[], | ||
* tagNames?: string[], | ||
* tagOperator?: 'AND'|'OR', | ||
* templateKeys?: string[], | ||
* page?: int, | ||
* limit?: int, | ||
* } $filters | ||
* | ||
* @param array{ | ||
* id?: 'asc'|'desc', | ||
* title?: 'asc'|'desc', | ||
* } $sortBy | ||
* | ||
* @return iterable<ArticleInterface> | ||
*/ | ||
public function findBy(array $filters = [], array $sortBy = []): iterable; | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string, | ||
* uuids?: string[], | ||
* locale?: string, | ||
* stage?: string, | ||
* categoryIds?: int[], | ||
* categoryKeys?: int[], | ||
* categoryOperator?: 'AND'|'OR', | ||
* tagIds?: int[], | ||
* tagNames?: string[], | ||
* tagOperator?: 'AND'|'OR', | ||
* templateKeys?: string[], | ||
* } $filters | ||
*/ | ||
public function countBy(array $filters = []): int; | ||
|
||
public function add(ArticleInterface $article): void; | ||
|
||
public function remove(ArticleInterface $article): void; | ||
} |
Oops, something went wrong.