Skip to content

Commit 93d0547

Browse files
committed
A bit of spring cleaning
1 parent ccf1145 commit 93d0547

File tree

11 files changed

+58
-99
lines changed

11 files changed

+58
-99
lines changed

.editorconfig

Lines changed: 0 additions & 16 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
### Composer
2-
composer.phar
31
composer.lock
42
vendor/
5-
6-
### Node
7-
node_modules/
8-
9-
### PHPStorm
10-
.idea/

.php_cs.dist

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
return PhpCsFixer\Config::create()
4+
->setRules([
5+
'@Symfony' => true,
6+
'@Symfony:risky' => true,
7+
'array_syntax' => array('syntax' => 'short'),
8+
'no_unreachable_default_argument_value' => false,
9+
'braces' => array('allow_single_line_closure' => true),
10+
'heredoc_to_nowdoc' => false,
11+
'phpdoc_annotation_without_dot' => false,
12+
'php_unit_test_annotation' => ['style' => 'annotation'],
13+
'php_unit_method_casing' => false,
14+
'psr_autoloading' => false,
15+
])
16+
->setRiskyAllowed(true)
17+
->setFinder(
18+
PhpCsFixer\Finder::create()
19+
->in(__DIR__)
20+
->notPath('conf/')
21+
->notPath('tmp/')
22+
->notPath('node_modules/')
23+
->notPath('var/cache')
24+
->notPath('vendor/')
25+
->notPath('www')
26+
)
27+
;

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# content-mapping-bundle #
1+
# content-mapping-bundle
22

33
Symfony bundle for [webfactory/content-mapping](https://github.com/webfactory/content-mapping). If you configure your
44
Synchronizers as services, you can use the provided console commands to list and start them. This is useful e.g. for
55
cronjobs.
66

77

8-
## Installation ##
8+
## Installation
99

1010
Install the package via composer
1111

@@ -26,7 +26,7 @@ public function registerBundles()
2626
```
2727

2828

29-
## Usage ##
29+
## Usage
3030

3131
First, register your Synchronizers as a service, e.g. in your services.xml:
3232

@@ -79,11 +79,11 @@ the destination systems even if no changes are detected. Be aware that `objectcl
7979
you'd like to synchronize, but the value you defined in the service definition (see above).
8080

8181

82-
## Credits, Copyright and License ##
82+
## Credits, Copyright and License
8383

8484
This project was started at webfactory GmbH, Bonn.
8585

8686
- <https://www.webfactory.de>
8787
- <https://twitter.com/webfactory>
8888

89-
Copyright 2015-2018 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).
89+
Copyright 2015-2022 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313

1414
"require": {
15-
"php": "7.2.*|7.4.*",
15+
"php": "7.2.*|7.4.*|8.0.*|8.1.*",
1616
"symfony/config": "^2.4|^3.0|^4.0|^5.0",
1717
"symfony/console": "^2.4|^3.0|^4.0|^5.0",
1818
"symfony/dependency-injection": "^2.4|^3.0|^4.0|^5.0",

src/Command/ListSynchronizersCommand.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,18 @@ class ListSynchronizersCommand extends Command
1717
*/
1818
private $synchronizerRegistry;
1919

20-
/**
21-
* @param Registry $synchronizerRegistry
22-
*/
2320
public function __construct(Registry $synchronizerRegistry)
2421
{
2522
parent::__construct();
2623
$this->synchronizerRegistry = $synchronizerRegistry;
2724
}
2825

29-
/**
30-
* {@inheritDoc}
31-
*/
32-
protected function configure()
26+
protected function configure(): void
3327
{
3428
$this->setName('content-mapping:list-synchronizers')
3529
->setDescription('Lists the available synchronizers');
3630
}
3731

38-
/**
39-
* {@inheritDoc}
40-
*/
4132
protected function execute(InputInterface $input, OutputInterface $output): int
4233
{
4334
foreach ($this->synchronizerRegistry->getObjectclasses() as $objectclass) {

src/Command/SynchronizeCommand.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace Webfactory\ContentMappingBundle\Command;
44

55
use Psr\Log\LoggerInterface;
6+
use Psr\Log\NullLogger;
67
use Symfony\Component\Console\Command\Command;
78
use Symfony\Component\Console\Input\InputInterface;
8-
use Symfony\Component\Console\Output\OutputInterface;
99
use Symfony\Component\Console\Input\InputOption;
10+
use Symfony\Component\Console\Output\OutputInterface;
1011
use Webfactory\ContentMappingBundle\Synchronizer\Registry;
1112

1213
/**
@@ -24,21 +25,14 @@ final class SynchronizeCommand extends Command
2425
*/
2526
private $logger;
2627

27-
/**
28-
* @param Registry $synchronizerRegistry
29-
* @param LoggerInterface $logger
30-
*/
31-
public function __construct(Registry $synchronizerRegistry, LoggerInterface $logger)
28+
public function __construct(Registry $synchronizerRegistry, LoggerInterface $logger = null)
3229
{
3330
parent::__construct();
3431
$this->synchronizerRegistry = $synchronizerRegistry;
35-
$this->logger = $logger;
32+
$this->logger = $logger ?? new NullLogger();
3633
}
3734

38-
/**
39-
* {@inheritDoc}
40-
*/
41-
protected function configure()
35+
protected function configure(): void
4236
{
4337
$this->setName('content-mapping:synchronize')
4438
->setDescription('Starts the synchronizer(s).');
@@ -56,21 +50,18 @@ protected function configure()
5650
);
5751
}
5852

59-
/**
60-
* {@inheritDoc}
61-
*/
6253
protected function execute(InputInterface $input, OutputInterface $output): int
6354
{
6455
$force = $input->getOption('force');
6556
$only = $input->getOption('only');
6657

6758
foreach ($this->synchronizerRegistry->getObjectclasses() as $objectclass) {
68-
if ($only && !in_array($objectclass, $only)) {
59+
if ($only && !\in_array($objectclass, $only)) {
6960
$this->logger->debug("Skipping Synchronizer for object class $objectclass");
7061
continue;
7162
}
7263

73-
$this->logger->debug('Use Synchronizer for object class ' . $objectclass);
64+
$this->logger->debug('Use Synchronizer for object class '.$objectclass);
7465

7566
$this->synchronizerRegistry->getSynchronizer($objectclass)
7667
->synchronize($objectclass, $force);

src/DependencyInjection/Compiler/RegisterSynchronizerPass.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@
88

99
namespace Webfactory\ContentMappingBundle\DependencyInjection\Compiler;
1010

11-
use Symfony\Component\DependencyInjection\ContainerBuilder;
1211
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
12+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1313

1414
/**
1515
* Fills the Synchronizer\Registry with services tagged as "contentmapping.synchronizer".
1616
*/
1717
final class RegisterSynchronizerPass implements CompilerPassInterface
1818
{
19-
/**
20-
* {@inheritDoc}
21-
*/
22-
public function process(ContainerBuilder $container)
19+
public function process(ContainerBuilder $container): void
2320
{
2421
$definition = $container->getDefinition('contentmapping.synchronizer_registry');
2522

@@ -29,7 +26,7 @@ public function process(ContainerBuilder $container)
2926
throw new \Exception('The contentmapping.synchronizer tag requires the objectclass attribute.');
3027
}
3128

32-
$definition->addMethodCall('addSynchronizer', array($tag['objectclass'], $id));
29+
$definition->addMethodCall('addSynchronizer', [$tag['objectclass'], $id]);
3330

3431
// Prevents Symfony from optimizing these services away if they're anonymous
3532
$container->getDefinition($id)->setPublic(true);

src/DependencyInjection/WebfactoryContentMappingExtension.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,16 @@
88

99
namespace Webfactory\ContentMappingBundle\DependencyInjection;
1010

11-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
12-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
13-
use Symfony\Component\DependencyInjection\ContainerBuilder;
1411
use Symfony\Component\Config\FileLocator;
12+
use Symfony\Component\DependencyInjection\ContainerBuilder;
13+
use Symfony\Component\DependencyInjection\Extension\Extension;
14+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1515

16-
/**
17-
* Symfony dependency injection extension.
18-
*/
1916
class WebfactoryContentMappingExtension extends Extension
2017
{
21-
/**
22-
* {@inheritDoc}
23-
*/
24-
public function load(array $configs, ContainerBuilder $container)
18+
public function load(array $configs, ContainerBuilder $container): void
2519
{
26-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
20+
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
2721
$loader->load('services.xml');
2822
}
2923
}

src/Synchronizer/Registry.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,34 @@ final class Registry
2727
/**
2828
* @var array(string objectClass => string serviceId)
2929
*/
30-
private $services = array();
30+
private $services = [];
3131

32-
/**
33-
* @param ContainerInterface $container
34-
*/
3532
public function __construct(ContainerInterface $container)
3633
{
3734
$this->container = $container;
3835
}
3936

40-
/**
41-
* @param string $objectclass
42-
* @param string $serviceId
43-
*/
44-
public function addSynchronizer($objectclass, $serviceId)
37+
public function addSynchronizer(string $objectclass, string $serviceId)
4538
{
4639
$this->services[$objectclass] = $serviceId;
4740
}
4841

4942
/**
5043
* @return string[]
5144
*/
52-
public function getObjectclasses()
45+
public function getObjectclasses(): array
5346
{
5447
return array_keys($this->services);
5548
}
5649

57-
/**
58-
* @param string $objectclass The objectclass to retrieve the Synchronizer for.
59-
* @return Synchronizer
60-
*/
61-
public function getSynchronizer($objectclass)
50+
public function getSynchronizer(string $objectclass): Synchronizer
6251
{
63-
if (array_key_exists($objectclass, $this->services) === false) {
64-
throw new \RuntimeException('No Synchronizer for objectclass "' . $objectclass . '" configured.');
52+
if (false === \array_key_exists($objectclass, $this->services)) {
53+
throw new \RuntimeException('No Synchronizer for objectclass "'.$objectclass.'" configured.');
6554
}
6655

6756
$serviceId = $this->services[$objectclass];
57+
6858
return $this->container->get($serviceId);
6959
}
7060
}

0 commit comments

Comments
 (0)