-
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
Joris Langlois
committed
Jul 13, 2020
1 parent
3447baf
commit 35e12d2
Showing
12 changed files
with
194 additions
and
40 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
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,55 @@ | ||
<?php | ||
|
||
namespace App\Domain\Command; | ||
|
||
use App\Domain\Model\Article; | ||
|
||
class EditArticle | ||
{ | ||
/** | ||
* @var Article | ||
*/ | ||
private $article; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $title; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $content; | ||
|
||
public function __construct(Article $article) | ||
{ | ||
$this->article = $article; | ||
$this->title = $article->getTitle(); | ||
$this->content = $article->getContent(); | ||
} | ||
|
||
public function getArticle(): Article | ||
{ | ||
return $this->article; | ||
} | ||
|
||
public function getTitle(): string | ||
{ | ||
return $this->title; | ||
} | ||
|
||
public function setTitle(string $title) | ||
{ | ||
$this->title = $title; | ||
} | ||
|
||
public function getContent(): string | ||
{ | ||
return $this->content; | ||
} | ||
|
||
public function setContent(string $content) | ||
{ | ||
$this->content = $content; | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
namespace App\Domain\Command\Handler; | ||
|
||
use App\Domain\Model\Article; | ||
use App\Domain\Command\EditArticle as EditArticleCommand; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
|
||
class EditArticle | ||
{ | ||
/** | ||
* @var ObjectManager | ||
*/ | ||
private $manager; | ||
|
||
public function __construct( | ||
ObjectManager $manager | ||
) { | ||
$this->manager = $manager; | ||
} | ||
|
||
public function __invoke(EditArticleCommand $command): Article | ||
{ | ||
$article = $command->getArticle(); | ||
$article->edit( | ||
$command->getTitle(), | ||
$command->getContent() | ||
); | ||
|
||
$this->manager->persist($article); | ||
$this->manager->flush(); | ||
|
||
return $article; | ||
} | ||
} |
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
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