Skip to content

Commit ab2ae31

Browse files
TheCelavilisachenko
authored andcommitted
Add Doctrine entities support, tests, commands, documentation, XSD schema #16
1 parent ab024da commit ab2ae31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+5039
-16
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
/vendor/
2+
/build/
3+
/Tests/Fixtures/project/var/cache/*
4+
/Tests/Fixtures/project/var/logs/*

.scrutinizer.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
filter:
2+
excluded_paths: [vendor/*, Tests/*, bin/*, Resources/]
3+
checks:
4+
php: true
5+
tools:
6+
external_code_coverage:
7+
timeout: 600
8+
php_sim: true
9+
php_mess_detector: true
10+
php_cs_fixer: true
11+
php_analyzer: true
12+
php_code_sniffer: true
13+
sensiolabs_security_checker: true
14+
php_loc:
15+
enabled: true
16+
excluded_dirs: [vendor]
17+
php_pdepend:
18+
enabled: true
19+
excluded_dirs: [vendor, Tests, bin]

.travis.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
language: php
2+
3+
php:
4+
- 5.6
5+
- 7.0
6+
- 7.1
7+
8+
sudo: false
9+
10+
cache:
11+
directories:
12+
- $HOME/.composer/cache/files
13+
14+
before_install:
15+
- composer self-update
16+
17+
install: composer update --prefer-source
18+
19+
script: vendor/bin/phpunit --coverage-clover=coverage.clover

CacheWarmer/AspectCacheWarmer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public function warmUp($cacheDir)
8383
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
8484
});
8585

86-
$errors = array();
8786
foreach ($iterator as $file) {
8887
$realPath = $file->getRealPath();
8988
try {
@@ -94,7 +93,7 @@ public function warmUp($cacheDir)
9493
"/resource=" . $realPath
9594
);
9695
} catch (\Exception $e) {
97-
$errors[$realPath] = $e;
96+
/* noop */
9897
}
9998
}
10099

Command/CacheWarmupCommand.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Go! AOP framework
4+
*
5+
* @copyright Copyright 2015, Lisachenko Alexander <lisachenko.it@gmail.com>
6+
*
7+
* This source file is subject to the license that is bundled
8+
* with this source code in the file LICENSE.
9+
*/
10+
11+
namespace Go\Symfony\GoAopBundle\Command;
12+
13+
use Go\Core\AspectKernel;
14+
use Symfony\Component\Console\Input\InputInterface;
15+
use Symfony\Component\Console\Output\OutputInterface;
16+
use Go\Console\Command\CacheWarmupCommand as BaseCommand;
17+
18+
/**
19+
* Console command for warming the cache
20+
*
21+
* @codeCoverageIgnore
22+
*/
23+
class CacheWarmupCommand extends BaseCommand
24+
{
25+
public function __construct(AspectKernel $aspectKernel)
26+
{
27+
parent::__construct(null);
28+
$this->aspectKernel = $aspectKernel;
29+
}
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
protected function configure()
35+
{
36+
parent::configure();
37+
$arguments = $this->getDefinition()->getArguments();
38+
unset($arguments['loader']);
39+
$this->getDefinition()->setArguments($arguments);
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*/
45+
protected function loadAspectKernel(InputInterface $input, OutputInterface $output)
46+
{
47+
/* noop */
48+
}
49+
}

Command/DebugAdvisorCommand.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Go! AOP framework
4+
*
5+
* @copyright Copyright 2015, Lisachenko Alexander <lisachenko.it@gmail.com>
6+
*
7+
* This source file is subject to the license that is bundled
8+
* with this source code in the file LICENSE.
9+
*/
10+
11+
namespace Go\Symfony\GoAopBundle\Command;
12+
13+
use Go\Core\AspectKernel;
14+
use Symfony\Component\Console\Input\InputInterface;
15+
use Symfony\Component\Console\Output\OutputInterface;
16+
use Go\Console\Command\DebugAdvisorCommand as BaseCommand;
17+
18+
/**
19+
* Console command to debug an advisors
20+
*
21+
* @codeCoverageIgnore
22+
*/
23+
class DebugAdvisorCommand extends BaseCommand
24+
{
25+
public function __construct(AspectKernel $aspectKernel)
26+
{
27+
parent::__construct(null);
28+
$this->aspectKernel = $aspectKernel;
29+
}
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
protected function configure()
35+
{
36+
parent::configure();
37+
$arguments = $this->getDefinition()->getArguments();
38+
unset($arguments['loader']);
39+
$this->getDefinition()->setArguments($arguments);
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*/
45+
protected function loadAspectKernel(InputInterface $input, OutputInterface $output)
46+
{
47+
/* noop */
48+
}
49+
}

Command/DebugAspectCommand.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Go! AOP framework
4+
*
5+
* @copyright Copyright 2015, Lisachenko Alexander <lisachenko.it@gmail.com>
6+
*
7+
* This source file is subject to the license that is bundled
8+
* with this source code in the file LICENSE.
9+
*/
10+
11+
namespace Go\Symfony\GoAopBundle\Command;
12+
13+
use Go\Core\AspectKernel;
14+
use Symfony\Component\Console\Input\InputInterface;
15+
use Symfony\Component\Console\Output\OutputInterface;
16+
use Go\Console\Command\DebugAspectCommand as BaseCommand;
17+
18+
/**
19+
* Class DebugAspectCommand
20+
*
21+
* Console command for querying an information about aspects
22+
*
23+
* @codeCoverageIgnore
24+
*/
25+
class DebugAspectCommand extends BaseCommand
26+
{
27+
public function __construct(AspectKernel $aspectKernel)
28+
{
29+
parent::__construct(null);
30+
$this->aspectKernel = $aspectKernel;
31+
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
protected function configure()
37+
{
38+
parent::configure();
39+
$arguments = $this->getDefinition()->getArguments();
40+
unset($arguments['loader']);
41+
$this->getDefinition()->setArguments($arguments);
42+
}
43+
44+
/**
45+
* {@inheritdoc}
46+
*/
47+
protected function loadAspectKernel(InputInterface $input, OutputInterface $output)
48+
{
49+
/* noop */
50+
}
51+
}

DependencyInjection/Compiler/AspectCollectorPass.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919
*/
2020
class AspectCollectorPass implements CompilerPassInterface
2121
{
22-
2322
/**
24-
* You can modify the container here before it is dumped to PHP code.
25-
*
26-
* @param ContainerBuilder $container
27-
*
28-
* @api
23+
* {@inheritdoc}
2924
*/
3025
public function process(ContainerBuilder $container)
3126
{
27+
if (!$container->hasDefinition('goaop.aspect.container')) {
28+
return;
29+
}
30+
3231
$aspectIds = $container->findTaggedServiceIds('goaop.aspect');
3332
$aspectContainer = $container->getDefinition('goaop.aspect.container');
3433
foreach ($aspectIds as $aspectId => $aspectTags) {

DependencyInjection/Configuration.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ public function getConfigTreeBuilder()
3434
$rootNode
3535
->children()
3636
->booleanNode('cache_warmer')->defaultTrue()->end()
37+
->booleanNode('doctrine_support')->defaultFalse()->end()
3738
->arrayNode('options')
3839
->addDefaultsIfNotSet()
40+
->fixXmlConfig('feature', 'features')
41+
->fixXmlConfig('include_path', 'include_paths')
42+
->fixXmlConfig('exclude_path', 'exclude_paths')
3943
->children()
4044
->scalarNode('features')
4145
->beforeNormalization()
@@ -47,7 +51,7 @@ public function getConfigTreeBuilder()
4751
if (!isset($features[$featureName])) {
4852
throw new InvalidConfigurationException("Uknown feature: {$featureName}");
4953
}
50-
$featureMask += isset($features[$featureName]) ? $features[$featureName] : 0;
54+
$featureMask |= $features[$featureName];
5155
}
5256

5357
return $featureMask;

DependencyInjection/GoAopExtension.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818

1919
class GoAopExtension extends Extension
2020
{
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function getNamespace()
25+
{
26+
return 'http://go.aopphp.com/xsd-schema/go-aop-bundle';
27+
}
28+
29+
/**
30+
* {@inheritdoc}
31+
*/
32+
public function getXsdValidationBasePath()
33+
{
34+
return __DIR__ . '/../Resources/config/schema';
35+
}
2136

2237
/**
2338
* Loads a specific configuration.
@@ -42,12 +57,19 @@ public function load(array $config, ContainerBuilder $container)
4257
}
4358
$container->setParameter('goaop.options', $normalizedOptions);
4459

45-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
60+
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
4661
$loader->load('services.xml');
62+
$loader->load('commands.xml');
4763

4864
if ($config['cache_warmer']) {
4965
$definition = $container->getDefinition('goaop.cache.warmer');
5066
$definition->addTag('kernel.cache_warmer');
5167
}
68+
69+
if ($config['doctrine_support']) {
70+
$container
71+
->getDefinition('goaop.bridge.doctrine.metadata_load_interceptor')
72+
->addTag('doctrine.event_subscriber');
73+
}
5274
}
5375
}

0 commit comments

Comments
 (0)