Skip to content

Commit

Permalink
Update to new domain foundation version.
Browse files Browse the repository at this point in the history
  • Loading branch information
wysow committed Jul 12, 2015
1 parent 32e0a05 commit fb44ed1
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 86 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/composer.phar
/vendor/
/web/bundles/
.idea/
17 changes: 3 additions & 14 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ parameters:
# parameter_name: value

services:
app.unit_of_work.factory:
class: RayRutjes\DomainFoundation\UnitOfWork\Factory\DefaultUnitOfWorkFactory
app.unit_of_work:
class: RayRutjes\DomainFoundation\UnitOfWork
factory: [@app.unit_of_work.factory, createUnitOfWork]
class: RayRutjes\DomainFoundation\UnitOfWork\DefaultUnitOfWork

app.command.handler_registry:
class: RayRutjes\DomainFoundation\Command\Handler\Registry\InMemoryCommandHandlerRegistry
calls:
- [subscribe, ['AppBundle\Identity\RegisterUserCommand', @app.command.register_user_handler]]
- [subscribe, ['AppBundle\Identity\ChangeUsernameCommand', @app.command.change_username_handler]]
- [subscribe, ['AppBundle\Identity\ChangeUserPasswordCommand', @app.command.change_user_password_handler]]

app.command.register_user_handler:
class: AppBundle\Identity\RegisterUserCommandHandler
arguments: [@app.user.register, @app.user.repository]
Expand All @@ -28,12 +26,9 @@ services:
app.command.bus:
class: RayRutjes\DomainFoundation\Command\Bus\SimpleCommandBus
arguments: [@app.command.handler_registry, @app.unit_of_work]
app.command.factory:
class: RayRutjes\DomainFoundation\Command\Factory\GenericCommandFactory
arguments: [@app.contract.factory, @app.identifier.factory]
app.command.gateway:
class: RayRutjes\DomainFoundation\Command\Gateway\DefaultCommandGateway
arguments: [@app.command.bus, @app.command.factory]
arguments: [@app.command.bus]

app.user.register:
class: AppBundle\Domain\Identity\RegisterUserService
Expand All @@ -56,9 +51,3 @@ services:

app.password.hashing:
class: AppBundle\Infrastructure\Identity\BcryptPasswordHashingService

app.contract.factory:
class: RayRutjes\DomainFoundation\Contract\ConventionalContractFactory

app.identifier.factory:
class: RayRutjes\DomainFoundation\Message\Identifier\Factory\UuidMessageIdentifierFactory
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"require": {
"php": ">=5.3.9",
"php": ">=5.6",
"symfony/symfony": "2.7.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
Expand Down
133 changes: 122 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions src/AppBundle/Domain/Identity/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace AppBundle\Domain\Identity;

use RayRutjes\DomainFoundation\ValueObject\ValueObject;

final class Password implements ValueObject
final class Password
{
/**
* @var string
Expand All @@ -26,7 +24,7 @@ public function __construct($password)
*
* @return bool
*/
public function sameValueAs(ValueObject $other)
public function sameValueAs(Password $other)
{
if (!$other instanceof self) {
return false;
Expand Down
43 changes: 42 additions & 1 deletion src/AppBundle/Domain/Identity/UserIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,47 @@
use RayRutjes\DomainFoundation\Domain\AggregateRoot\AggregateRootIdentifier;
use RayRutjes\DomainFoundation\ValueObject\Identity\Uuid;

final class UserIdentifier extends Uuid implements AggregateRootIdentifier
final class UserIdentifier implements AggregateRootIdentifier
{
/**
* @var Uuid
*/
private $uuid;

/**
* @param string|Uuid $uuid
*/
public function __construct($uuid)
{
$this->uuid = $uuid instanceof Uuid ? $uuid : new Uuid($uuid);
}

/**
* @return UserIdentifier
*/
public static function generate()
{
return new self(Uuid::generate());
}

/**
* @return string
*/
public function toString()
{
return $this->uuid->toString();
}

/**
* @param UserIdentifier $identifier
*
* @return bool
*/
public function equals(AggregateRootIdentifier $identifier)
{
if(!$identifier instanceof $this) {
return false;
}
return $this->toString() === $identifier->toString();
}
}
6 changes: 2 additions & 4 deletions src/AppBundle/Domain/Identity/Username.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace AppBundle\Domain\Identity;

use RayRutjes\DomainFoundation\ValueObject\ValueObject;

final class Username implements ValueObject
final class Username
{
/**
* @var string
Expand All @@ -27,7 +25,7 @@ public function __construct($username)
*
* @return bool
*/
public function sameValueAs(ValueObject $other)
public function sameValueAs(Username $other)
{
if (!$other instanceof self) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
use AppBundle\Domain\Identity\UserRepository;
use AppBundle\Persistence\Doctrine\EventStore\DoctrineEventStore;
use Doctrine\DBAL\Connection;
use RayRutjes\DomainFoundation\Contract\ConventionalContractFactory;
use RayRutjes\DomainFoundation\Contract\Contract;
use RayRutjes\DomainFoundation\EventBus\EventBus;
use RayRutjes\DomainFoundation\Repository\AggregateRootRepository;
use RayRutjes\DomainFoundation\Repository\AggregateRootRepositoryFactory;
use RayRutjes\DomainFoundation\UnitOfWork\UnitOfWork;

final class DoctrineUserRepository implements UserRepository
Expand All @@ -28,11 +27,9 @@ public function __construct(UnitOfWork $unitOfWork, Connection $connection, Even
{
$eventStore = new DoctrineEventStore($connection);

$contractFactory = new ConventionalContractFactory();
$aggregateRootType = $contractFactory->createFromClassName(User::class);
$aggregateRootType = Contract::createFromClassName(User::class);

$repositoryFactory = new AggregateRootRepositoryFactory($eventStore, $eventBus);
$this->repository = $repositoryFactory->create($unitOfWork, $aggregateRootType);
$this->repository = new AggregateRootRepository($unitOfWork, $aggregateRootType, $eventStore, $eventBus);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/AppBundle/Listener/UserListProjectorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Doctrine\DBAL\Connection;
use RayRutjes\DomainFoundation\Contract\ConventionalContractFactory;
use RayRutjes\DomainFoundation\Domain\Event\Event;
use RayRutjes\DomainFoundation\EventBus\Listener\EventListener;
use RayRutjes\DomainFoundation\EventBus\EventListener;

class UserListProjectorListener implements EventListener
{
Expand Down
Loading

0 comments on commit fb44ed1

Please sign in to comment.