-
Notifications
You must be signed in to change notification settings - Fork 78
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
d7b691b
commit 6b08021
Showing
36 changed files
with
2,262 additions
and
74 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,49 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ArticleBundle\Application\Mapper; | ||
|
||
use Sulu\Bundle\ArticleBundle\Domain\Model\ArticleInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Application\ContentPersister\ContentPersisterInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
/** | ||
* @experimental | ||
* | ||
* @internal This class should be instantiated inside a project. | ||
* Use the message to create or modify an article. | ||
* Or the inject all the mappers into a custom service. | ||
* Create an own Mapper to extend the mapper with | ||
* custom logic. | ||
*/ | ||
final class ArticleContentMapper implements ArticleMapperInterface | ||
{ | ||
/** | ||
* @var ContentPersisterInterface | ||
*/ | ||
private $contentPersister; | ||
|
||
public function __construct(ContentPersisterInterface $contentPersister) | ||
{ | ||
$this->contentPersister = $contentPersister; | ||
} | ||
|
||
public function mapArticleData(ArticleInterface $article, array $data): void | ||
{ | ||
$locale = $data['locale'] ?? null; | ||
Assert::string($locale); | ||
|
||
$dimensionAttributes = ['locale' => $locale]; | ||
|
||
// TODO this will be changed to `$article`, `$dimensionAttributes`, `$data` | ||
$this->contentPersister->persist($article, $data, $dimensionAttributes); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ArticleBundle\Application\Mapper; | ||
|
||
use Sulu\Bundle\ArticleBundle\Domain\Model\ArticleInterface; | ||
|
||
/** | ||
* @experimental | ||
*/ | ||
interface ArticleMapperInterface | ||
{ | ||
/** | ||
* @param mixed[] $data | ||
*/ | ||
public function mapArticleData(ArticleInterface $article, array $data): void; | ||
} |
64 changes: 64 additions & 0 deletions
64
Application/Message/ApplyWorkflowTransitionArticleMessage.php
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,64 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ArticleBundle\Application\Message; | ||
|
||
class ApplyWorkflowTransitionArticleMessage | ||
{ | ||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
private $identifier; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $locale; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $transitionName; | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
public function __construct(array $identifier, string $locale, string $transitionName) | ||
{ | ||
$this->identifier = $identifier; | ||
$this->locale = $locale; | ||
$this->transitionName = $transitionName; | ||
} | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
public function getIdentifier(): array | ||
{ | ||
return $this->identifier; | ||
} | ||
|
||
public function getLocale(): string | ||
{ | ||
return $this->locale; | ||
} | ||
|
||
public function getTransitionName(): string | ||
{ | ||
return $this->transitionName; | ||
} | ||
} |
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,55 @@ | ||
<?php | ||
|
||
namespace Sulu\Bundle\ArticleBundle\Application\Message; | ||
|
||
class CopyLocaleArticleMessage | ||
{ | ||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
private $identifier; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $sourceLocale; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $targetLocale; | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
public function __construct($identifier, string $sourceLocale, string $targetLocale) | ||
{ | ||
$this->identifier = $identifier; | ||
$this->sourceLocale = $sourceLocale; | ||
$this->targetLocale = $targetLocale; | ||
} | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
public function getIdentifier() | ||
{ | ||
return $this->identifier; | ||
} | ||
|
||
public function getSourceLocale(): string | ||
{ | ||
return $this->sourceLocale; | ||
} | ||
|
||
public function getTargetLocale(): string | ||
{ | ||
return $this->targetLocale; | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ArticleBundle\Application\Message; | ||
|
||
use Webmozart\Assert\Assert; | ||
|
||
/** | ||
* @experimental | ||
*/ | ||
class CreateArticleMessage | ||
{ | ||
/** | ||
* @var mixed[] | ||
*/ | ||
private $data; | ||
|
||
/** | ||
* @param mixed[] $data | ||
*/ | ||
public function __construct(array $data) | ||
{ | ||
Assert::string($data['locale'] ?? null, 'Expected a "locale" string given.'); | ||
Assert::nullOrString($data['uuid'] ?? null, 'Expected "uuid" to be a string.'); | ||
|
||
$this->data = $data; | ||
} | ||
|
||
/** | ||
* @return mixed[] | ||
*/ | ||
public function getData(): array | ||
{ | ||
return $this->data; | ||
} | ||
} |
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,64 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ArticleBundle\Application\Message; | ||
|
||
use Webmozart\Assert\Assert; | ||
|
||
/** | ||
* @experimental | ||
*/ | ||
class ModifyArticleMessage | ||
{ | ||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
private $identifier; | ||
|
||
/** | ||
* @var mixed[] | ||
*/ | ||
private $data; | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
* @param mixed[] $data | ||
*/ | ||
public function __construct(array $identifier, array $data) | ||
{ | ||
Assert::string($data['locale'] ?? null, 'Expected a "locale" string given.'); | ||
|
||
$this->identifier = $identifier; | ||
$this->data = $data; | ||
} | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
public function getIdentifier(): array | ||
{ | ||
return $this->identifier; | ||
} | ||
|
||
/** | ||
* @var mixed[] | ||
*/ | ||
public function getData(): array | ||
{ | ||
return $this->data; | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ArticleBundle\Application\Message; | ||
|
||
/** | ||
* @experimental | ||
*/ | ||
class RemoveArticleMessage | ||
{ | ||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
private $identifier; | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
public function __construct(array $identifier) | ||
{ | ||
$this->identifier = $identifier; | ||
} | ||
|
||
/** | ||
* @param array{ | ||
* uuid?: string | ||
* } $identifier | ||
*/ | ||
public function getIdentifier(): array | ||
{ | ||
return $this->identifier; | ||
} | ||
} |
Oops, something went wrong.