-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from SURFnet/feature/publication-of-production…
…-entity Publish production entity
- Loading branch information
Showing
26 changed files
with
881 additions
and
59 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,22 @@ | ||
pick 27b45ca Update entity state when editing prod-published | ||
fixup 3b96458 fixup! Update entity state when editing prod-published | ||
pick 3bdf2f1 Upgrade the service mail message | ||
|
||
# Rebase 1406950..3b96458 onto 1406950 (3 commands) | ||
# | ||
# Commands: | ||
# p, pick = use commit | ||
# r, reword = use commit, but edit the commit message | ||
# e, edit = use commit, but stop for amending | ||
# s, squash = use commit, but meld into previous commit | ||
# f, fixup = like "squash", but discard this commit's log message | ||
# x, exec = run command (the rest of the line) using shell | ||
# d, drop = remove commit | ||
# | ||
# These lines can be re-ordered; they are executed from top to bottom. | ||
# | ||
# If you remove a line here THAT COMMIT WILL BE LOST. | ||
# | ||
# However, if you remove everything, the rebase will be aborted. | ||
# | ||
# Note that empty commits are commented out |
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,34 @@ | ||
<?php | ||
|
||
namespace Application\Migrations; | ||
|
||
use Doctrine\DBAL\Migrations\AbstractMigration; | ||
use Doctrine\DBAL\Schema\Schema; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
class Version20171103103244 extends AbstractMigration | ||
{ | ||
/** | ||
* @param Schema $schema | ||
*/ | ||
public function up(Schema $schema) | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('ALTER TABLE entity ADD status VARCHAR(255) NOT NULL'); | ||
} | ||
|
||
/** | ||
* @param Schema $schema | ||
*/ | ||
public function down(Schema $schema) | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('ALTER TABLE entity DROP status'); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...et/ServiceProviderDashboard/Application/Command/Entity/PublishEntityProductionCommand.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 | ||
|
||
/** | ||
* Copyright 2017 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Surfnet\ServiceProviderDashboard\Application\Command\Entity; | ||
|
||
use Surfnet\ServiceProviderDashboard\Application\Command\Command; | ||
use Surfnet\ServiceProviderDashboard\Domain\Mailer\Message; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class PublishEntityProductionCommand implements Command | ||
{ | ||
/** | ||
* @var string | ||
* @Assert\NotBlank | ||
* @Assert\Uuid | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var Message | ||
*/ | ||
private $message; | ||
|
||
/** | ||
* @param string $id | ||
* @param Message $message | ||
*/ | ||
public function __construct($id, Message $message) | ||
{ | ||
$this->id = $id; | ||
$this->message = $message; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return Message | ||
*/ | ||
public function getMessage() | ||
{ | ||
return $this->message; | ||
} | ||
} |
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
57 changes: 57 additions & 0 deletions
57
...Surfnet/ServiceProviderDashboard/Application/Command/Entity/UpdateEntityStatusCommand.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,57 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2017 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Surfnet\ServiceProviderDashboard\Application\Command\Entity; | ||
|
||
use Surfnet\ServiceProviderDashboard\Application\Command\Command; | ||
|
||
class UpdateEntityStatusCommand implements Command | ||
{ | ||
/** | ||
* @var string | ||
* @Assert\NotBlank | ||
* @Assert\Uuid | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @param string $id | ||
* @param string $status | ||
*/ | ||
public function __construct($id, $status) | ||
{ | ||
$this->id = $id; | ||
$this->status = $status; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getStatus() | ||
{ | ||
return $this->status; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...iderDashboard/Application/CommandHandler/Entity/PublishEntityProductionCommandHandler.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,76 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2017 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Surfnet\ServiceProviderDashboard\Application\CommandHandler\Entity; | ||
|
||
use League\Tactician\CommandBus; | ||
use Psr\Log\LoggerInterface; | ||
use Surfnet\ServiceProviderDashboard\Application\Command\Entity\PublishEntityProductionCommand; | ||
use Surfnet\ServiceProviderDashboard\Application\Command\Mail\PublishToProductionMailCommand; | ||
use Surfnet\ServiceProviderDashboard\Application\CommandHandler\CommandHandler; | ||
use Surfnet\ServiceProviderDashboard\Application\Exception\InvalidArgumentException; | ||
use Surfnet\ServiceProviderDashboard\Domain\Entity\Entity; | ||
use Surfnet\ServiceProviderDashboard\Domain\Repository\EntityRepository; | ||
|
||
class PublishEntityProductionCommandHandler implements CommandHandler | ||
{ | ||
/** | ||
* @var EntityRepository | ||
*/ | ||
private $repository; | ||
|
||
/** | ||
* @var CommandBus | ||
*/ | ||
private $commandBus; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
public function __construct( | ||
EntityRepository $entityRepository, | ||
CommandBus $commandBus, | ||
LoggerInterface $logger | ||
) { | ||
$this->repository = $entityRepository; | ||
$this->commandBus = $commandBus; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* @param PublishEntityProductionCommand $command | ||
* | ||
* @throws InvalidArgumentException | ||
*/ | ||
public function handle(PublishEntityProductionCommand $command) | ||
{ | ||
$entity = $this->repository->findById($command->getId()); | ||
$this->logger->info(sprintf('Sending publish request mail to servicedesk for "%s".', $entity->getNameEn())); | ||
|
||
// Send the confirmation mail | ||
$mailCommand = new PublishToProductionMailCommand($command->getMessage()); | ||
$this->commandBus->handle($mailCommand); | ||
|
||
// Set entity status to published even though it is not realy published to manage | ||
$entity->setStatus(Entity::STATE_PUBLISHED); | ||
$this->logger->info(sprintf('Updating status of "%s" to published.', $entity->getNameEn())); | ||
$this->repository->save($entity); | ||
} | ||
} |
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
51 changes: 51 additions & 0 deletions
51
...eProviderDashboard/Application/CommandHandler/Entity/UpdateEntityStatusCommandHandler.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,51 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2017 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Surfnet\ServiceProviderDashboard\Application\CommandHandler\Entity; | ||
|
||
use League\Tactician\CommandBus; | ||
use Psr\Log\LoggerInterface; | ||
use Surfnet\ServiceProviderDashboard\Application\Command\Entity\PublishEntityProductionCommand; | ||
use Surfnet\ServiceProviderDashboard\Application\Command\Entity\UpdateEntityStatusCommand; | ||
use Surfnet\ServiceProviderDashboard\Application\Command\Mail\PublishToProductionMailCommand; | ||
use Surfnet\ServiceProviderDashboard\Application\CommandHandler\CommandHandler; | ||
use Surfnet\ServiceProviderDashboard\Application\Exception\InvalidArgumentException; | ||
use Surfnet\ServiceProviderDashboard\Domain\Entity\Entity; | ||
use Surfnet\ServiceProviderDashboard\Domain\Repository\EntityRepository; | ||
|
||
class UpdateEntityStatusCommandHandler implements CommandHandler | ||
{ | ||
/** | ||
* @var EntityRepository | ||
*/ | ||
private $repository; | ||
|
||
public function __construct(EntityRepository $entityRepository) | ||
{ | ||
$this->repository = $entityRepository; | ||
} | ||
|
||
public function handle(UpdateEntityStatusCommand $command) | ||
{ | ||
$entity = $this->repository->findById($command->getId()); | ||
|
||
$entity->setStatus(Entity::STATE_DRAFT); | ||
|
||
$this->repository->save($entity); | ||
} | ||
} |
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.