Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move src/php code into the explicit architecture structure
I could find two components, one for user management, and another one relative to he blog. At this point I am trying to change the minimum code possible. I will create the ports and any other needed abstractions at a later stage.
- Loading branch information
Showing
72 changed files
with
753 additions
and
439 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
no-vcs | ||
var | ||
!var/data/blog.sqlite | ||
.env |
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,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Explicit Architecture POC, | ||
* which is created on top of the Symfony Demo application. | ||
* | ||
* (c) Herberto Graça <herberto.graca@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Acme\App\Build\Fixture\Doctrine; | ||
|
||
use Acme\App\Core\Component\User\Domain\Entity\User; | ||
use Doctrine\Bundle\FixturesBundle\Fixture; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; | ||
|
||
/** | ||
* Defines the sample users to load in the database before a production deployment is ready. | ||
* Execute this command to load the data. | ||
* | ||
* $ php bin/console doctrine:fixtures:load | ||
* | ||
* See https://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html | ||
* | ||
* @author Herberto Graça <herberto.graca@gmail.com> | ||
*/ | ||
class UserFixtures extends Fixture | ||
{ | ||
/** | ||
* @var UserPasswordEncoderInterface | ||
*/ | ||
private $passwordEncoder; | ||
|
||
public function __construct(UserPasswordEncoderInterface $passwordEncoder) | ||
{ | ||
$this->passwordEncoder = $passwordEncoder; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function load(ObjectManager $manager): void | ||
{ | ||
$tomAdmin = new User(); | ||
$tomAdmin->setFullName('Tom Doe'); | ||
$tomAdmin->setUsername('tom_admin'); | ||
$tomAdmin->setEmail('tom_admin@symfony.com'); | ||
$tomAdmin->setRoles(['ROLE_ADMIN']); | ||
$encodedPassword = $this->passwordEncoder->encodePassword($tomAdmin, 'kitten'); | ||
$tomAdmin->setPassword($encodedPassword); | ||
$manager->persist($tomAdmin); | ||
// In case if fixture objects have relations to other fixtures, adds a reference | ||
// to that object by name and later reference it to form a relation. | ||
// See https://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html#sharing-objects-between-fixtures | ||
$this->addReference('tom-admin', $tomAdmin); | ||
|
||
$manager->flush(); | ||
} | ||
} |
File renamed without changes.
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
Oops, something went wrong.