Skip to content

Commit

Permalink
Merge branch 'broadway-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
NikoGrano committed Mar 18, 2020
2 parents bf1c3db + c5eeb7c commit 08abed4
Show file tree
Hide file tree
Showing 42 changed files with 296 additions and 197 deletions.
8 changes: 8 additions & 0 deletions .docheader
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* This file is part of the broadway/broadway-bundle package.
*
* (c) 2020 Broadway project
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
composer.lock
.phpunit.result.cache
.php_cs.cache
13 changes: 13 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

$config = require 'vendor/broadway/coding-standard/.php_cs.dist';

$config->setFinder(
\PhpCsFixer\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/test',
])
);

return $config;
11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ install:
- composer info

script:
- vendor/bin/phpunit --exclude-group=none
- git log $(git describe --abbrev=0 --tags)...HEAD --no-merges --pretty=format:"* [%h](http://github.com/${TRAVIS_REPO_SLUG}/commit/%H) %s (%cN)"

branches:
only:
- master
- develop
- make test
- make qa
- make license
- make changelog
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014 Qandidate.com - http://qandidate.com/
Copyright (c) 2020 Broadway project - https://github.com/broadway

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.DEFAULT_GOAL:=help

.PHONY: dependencies
dependencies:
composer install --no-interaction --no-suggest --no-scripts --ansi

.PHONY: test
test:
vendor/bin/phpunit --testdox --exclude-group=none --colors=always

.PHONY: qa
qa: php-cs-fixer-ci

.PHONY: php-cs-fixer
php-cs-fixer:
vendor/bin/php-cs-fixer fix --no-interaction --allow-risky=yes --diff --verbose

.PHONY: php-cs-fixer-ci
php-cs-fixer-ci:
vendor/bin/php-cs-fixer fix --dry-run --no-interaction --allow-risky=yes --diff --verbose

.PHONY: changelog
changelog:
git log $$(git describe --abbrev=0 --tags)...HEAD --no-merges --pretty=format:"* [%h](http://github.com/${TRAVIS_REPO_SLUG}/commit/%H) %s (%cN)"

.PHONY: license
license:
vendor/bin/docheader check --no-interaction --ansi -vvv {src,test,examples}

# Based on https://suva.sh/posts/well-documented-makefiles/
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Broadway Bundle

Symfony bundle to integrate Broadway into your Symfony application.

[![Build Status](https://travis-ci.org/broadway/broadway-bundle.svg?branch=master)](https://travis-ci.org/broadway/broadway-bundle)

## Installation

The easiest way to install and configure the BroadwayBundle with Symfony is by using
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@
}
],
"require-dev": {
"symfony/framework-bundle": "^4.0||^5.0",
"monolog/monolog": "~1.8",
"symfony/proxy-manager-bridge": "^4.0||^5.0",
"symfony/framework-bundle": "^3.4||^4.4|^5.0",
"monolog/monolog": "~2.0",
"symfony/proxy-manager-bridge": "^3.4||^4.4|^5.0",
"phpunit/phpunit": "^8.0",
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"broadway/broadway-saga": "^0.7"
"broadway/broadway-saga": "^0.7",
"broadway/coding-standard": "^1.0"
},
"suggest": {
"psr/log-implementation": "Implementation for PSR3, LoggerInterface",
Expand Down
11 changes: 5 additions & 6 deletions src/BroadwayBundle.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

declare(strict_types=1);

/*
* This file is part of the broadway/broadway package.
* This file is part of the broadway/broadway-bundle package.
*
* (c) Qandidate.com <[email protected]>
* (c) 2020 Broadway project
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Broadway\Bundle\BroadwayBundle;

use Broadway\Bundle\BroadwayBundle\Command\SchemaEventStoreCreateCommand;
use Broadway\Bundle\BroadwayBundle\Command\SchemaEventStoreDropCommand;
use Broadway\Bundle\BroadwayBundle\DependencyInjection\RegisterBusSubscribersCompilerPass;
use Broadway\Bundle\BroadwayBundle\DependencyInjection\RegisterEventListenerCompilerPass;
use Broadway\Bundle\BroadwayBundle\DependencyInjection\RegisterEventStoreCompilerPass;
Expand All @@ -21,14 +21,13 @@
use Broadway\Bundle\BroadwayBundle\DependencyInjection\RegisterSagaCompilerPass;
use Broadway\Bundle\BroadwayBundle\DependencyInjection\RegisterSagaStateRepositoryCompilerPass;
use Broadway\Bundle\BroadwayBundle\DependencyInjection\RegisterSerializersCompilerPass;
use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class BroadwayBundle extends Bundle
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
Expand Down
14 changes: 8 additions & 6 deletions src/Command/CommandMetadataEnricher.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);

/*
* This file is part of the broadway/broadway package.
* This file is part of the broadway/broadway-bundle package.
*
* (c) Qandidate.com <[email protected]>
* (c) 2020 Broadway project
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -23,7 +25,7 @@ class CommandMetadataEnricher implements MetadataEnricher
private $event;

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function enrich(Metadata $metadata): Metadata
{
Expand All @@ -33,9 +35,9 @@ public function enrich(Metadata $metadata): Metadata

$data = [
'console' => [
'command' => get_class($this->event->getCommand()),
'arguments' => $this->event->getInput()->__toString()
]
'command' => get_class($this->event->getCommand()),
'arguments' => $this->event->getInput()->__toString(),
],
];
$newMetadata = new Metadata($data);

Expand Down
10 changes: 6 additions & 4 deletions src/DependencyInjection/BroadwayExtension.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);

/*
* This file is part of the broadway/broadway package.
* This file is part of the broadway/broadway-bundle package.
*
* (c) Qandidate.com <[email protected]>
* (c) 2020 Broadway project
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -21,11 +23,11 @@
class BroadwayExtension extends ConfigurableExtension
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected function loadInternal(array $mergedConfig, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');

if (isset($mergedConfig['event_store'])) {
Expand Down
26 changes: 11 additions & 15 deletions src/DependencyInjection/CompilerPass.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);

/*
* This file is part of the broadway/broadway package.
* This file is part of the broadway/broadway-bundle package.
*
* (c) Qandidate.com <[email protected]>
* (c) 2020 Broadway project
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -19,36 +21,30 @@
abstract class CompilerPass implements CompilerPassInterface
{
/**
* @param ContainerBuilder $container
* @param string $definitionId
* @param string $definitionId
*/
protected function assertContainerHasDefinition(ContainerBuilder $container, $definitionId)
{
if (!$container->hasDefinition($definitionId)) {
throw new InvalidArgumentException(
sprintf('Service id "%s" could not be found in container', $definitionId)
);
throw new InvalidArgumentException(sprintf('Service id "%s" could not be found in container', $definitionId));
}
}

/**
* @param ContainerBuilder $container
* @param string $definitionId
* @param string $interface
* @param string $definitionId
* @param string $interface
*/
protected function assertDefinitionImplementsInterface(ContainerBuilder $container, $definitionId, $interface)
{
$this->assertContainerHasDefinition($container, $definitionId);

$definition = $container->getDefinition($definitionId);
$definition = $container->getDefinition($definitionId);
$definitionClass = $container->getParameterBag()->resolveValue($definition->getClass());

$reflectionClass = new ReflectionClass($definitionClass);

if (! $reflectionClass->implementsInterface($interface)) {
throw new InvalidArgumentException(
sprintf('Service "%s" must implement interface "%s".', $definitionClass, $interface)
);
if (!$reflectionClass->implementsInterface($interface)) {
throw new InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $definitionClass, $interface));
}
}
}
13 changes: 7 additions & 6 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);

/*
* This file is part of the broadway/broadway package.
* This file is part of the broadway/broadway-bundle package.
*
* (c) Qandidate.com <[email protected]>
* (c) 2020 Broadway project
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -20,16 +22,15 @@
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('broadway');

if (\method_exists($treeBuilder, 'getRootNode')){
if (\method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
}
else {
} else {
// BC layer for symfony/config 4.1 and older
$rootNode = $treeBuilder->root('broadway');
}
Expand Down
17 changes: 8 additions & 9 deletions src/DependencyInjection/RegisterBusSubscribersCompilerPass.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);

/*
* This file is part of the broadway/broadway package.
* This file is part of the broadway/broadway-bundle package.
*
* (c) Qandidate.com <[email protected]>
* (c) 2020 Broadway project
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -13,7 +15,6 @@

use InvalidArgumentException;
use ReflectionClass;
use RuntimeException;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
Expand All @@ -34,13 +35,13 @@ class RegisterBusSubscribersCompilerPass implements CompilerPassInterface
*/
public function __construct($busService, $serviceTag, $subscriberInterface)
{
$this->busService = $busService;
$this->serviceTag = $serviceTag;
$this->busService = $busService;
$this->serviceTag = $serviceTag;
$this->subscriberInterface = $subscriberInterface;
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
Expand All @@ -58,9 +59,7 @@ public function process(ContainerBuilder $container)
$refClass = new ReflectionClass($class);

if (!$refClass->implementsInterface($this->subscriberInterface)) {
throw new InvalidArgumentException(
sprintf('Service "%s" must implement interface "%s".', $id, $this->subscriberInterface)
);
throw new InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $this->subscriberInterface));
}

$definition->addMethodCall('subscribe', [new Reference($id)]);
Expand Down
Loading

0 comments on commit 08abed4

Please sign in to comment.