Permalink
Browse files

cleanup

  • Loading branch information...
TomasVotruba committed Jun 9, 2017
1 parent 4dbb7de commit 1c257b323e6cc307a7db6740c9de2a7c88c763e6
View
@@ -5,7 +5,7 @@
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
apigen.neon export-ignore
apigen.yml export-ignore
CHANGELOG.md export-ignore
easy-coding-standard.neon export-ignore
generate-api.sh export-ignore
View
@@ -1,7 +1,3 @@
/api
/vendor
composer.lock
# Symfony
src/DependencyInjection/cache/
src/DependencyInjection/logs/
View
@@ -1,7 +1,6 @@
#!/usr/bin/env php
<?php declare(strict_types=1);
use ApiGen\DependencyInjection\Container\ContainerFactory as SymfonyContainerFactory;
use ApiGen\DependencyInjection\Container\ContainerFactory;
use Symfony\Component\Console\Application;
@@ -11,13 +10,7 @@ gc_disable();
// Require Composer autoload
require_once getcwd() . '/vendor/autoload.php';
$container = (new ContainerFactory)->create();
///** @var Application $application */
//$application = $container->get(Application::class);
//$application->run();
$symfonyContainer = (new SymfonyContainerFactory())->create();
$container = (new ContainerFactory())->create();
/** @var Application $application */
$application = $symfonyContainer->get(Application::class);
$application = $container->get(Application::class);
$application->run();
@@ -3,9 +3,9 @@
namespace ApiGen\ModularConfiguration\Parameter;
use ApiGen\ModularConfiguration\Contract\Parameter\ParameterProviderInterface;
use Nette\DI\Container;
use Nette\Utils\Strings;
use Symfony\Component\DependencyInjection\Container as SymfonyContainer;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
final class ParameterProvider implements ParameterProviderInterface
{
@@ -14,38 +14,21 @@
*/
private $parameters = [];
public function __construct(SymfonyContainer $symfonyContainer, ?Container $netteContainer = null)
{
if ($symfonyContainer !== null) {
$containerParameters = $symfonyContainer->getParameterBag()->all();
$this->parameters = $this->unsetSymfonyDefaultParameters($containerParameters);
} elseif ($netteContainer !== null) {
$containerParameters = $netteContainer->getParameters();
$this->parameters = $this->unsetNetteDefaultParameters($containerParameters);
}
}
/**
* @return mixed[]
* @param Container|ContainerInterface $container
*/
public function provide(): array
public function __construct(ContainerInterface $container)
{
return $this->parameters;
$containerParameters = $container->getParameterBag()->all();
$this->parameters = $this->unsetSymfonyDefaultParameters($containerParameters);
}
/**
* @param mixed[] $containerParameters
* @return mixed[]
*/
private function unsetNetteDefaultParameters(array $containerParameters): array
public function provide(): array
{
unset(
$containerParameters['appDir'], $containerParameters['wwwDir'],
$containerParameters['debugMode'], $containerParameters['productionMode'],
$containerParameters['consoleMode'], $containerParameters['tempDir']
);
return $containerParameters;
return $this->parameters;
}
/**
@@ -3,7 +3,6 @@
namespace ApiGen\DependencyInjection;
use ApiGen\DependencyInjection\CompilerPass\CollectorCompilerPass;
use ApiGen\DependencyInjection\CompilerPass\LatteFiltersCollectorCompilerPass;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
@@ -51,6 +50,5 @@ public function getLogDir(): string
protected function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new CollectorCompilerPass);
$container->addCompilerPass(new LatteFiltersCollectorCompilerPass);
}
}
@@ -5,9 +5,11 @@
use ApiGen\Annotation\AnnotationDecorator;
use ApiGen\Annotation\Contract\AnnotationSubscriber\AnnotationSubscriberInterface;
use ApiGen\Contract\Generator\GeneratorInterface;
use ApiGen\Contract\Templating\FilterProviderInterface;
use ApiGen\Element\Contract\ReflectionCollector\BasicReflectionCollectorInterface;
use ApiGen\Element\ReflectionCollectorCollector;
use ApiGen\Generator\GeneratorQueue;
use ApiGen\Latte\FiltersAwareLatteEngineFactory;
use ApiGen\ModularConfiguration\CommandDecorator;
use ApiGen\ModularConfiguration\ConfigurationResolver;
use ApiGen\ModularConfiguration\Contract\Option\CommandBoundInterface;
@@ -37,6 +39,7 @@ public function process(ContainerBuilder $containerBuilder): void
$this->collectRoutesToStringRouter($containerBuilder);
$this->collectEventSubscribersToDispatcher($containerBuilder);
$this->collectGeneratorsToGeneratorQueue($containerBuilder);
$this->collectFilterProvidersToLatteEngine($containerBuilder);
}
private function collectCommandsToApplication(ContainerBuilder $containerBuilder): void
@@ -128,4 +131,14 @@ private function collectGeneratorsToGeneratorQueue(ContainerBuilder $containerBu
'addGenerator'
);
}
private function collectFilterProvidersToLatteEngine(ContainerBuilder $containerBuilder): void
{
DefinitionCollector::loadCollectorWithType(
$containerBuilder,
FiltersAwareLatteEngineFactory::class,
FilterProviderInterface::class,
'addFilterProvider'
);
}
}

This file was deleted.

Oops, something went wrong.
@@ -10,20 +10,20 @@
/**
* @var FilterProviderInterface[]
*/
private $filtersProviders = [];
private $filterProviders = [];
public function addFiltersProvider(FilterProviderInterface $filtersProvider): void
public function addFilterProvider(FilterProviderInterface $filtersProvider): void
{
$this->filtersProviders[] = $filtersProvider;
$this->filterProviders[] = $filtersProvider;
}
public function create(): Engine
{
$latteEngine = new Engine;
$latteEngine->setTempDirectory(sys_get_temp_dir() . '/_latte_cache');
foreach ($this->filtersProviders as $filtersProvider) {
foreach ($filtersProvider->getFilters() as $name => $callback) {
foreach ($this->filterProviders as $filterProvider) {
foreach ($filterProvider->getFilters() as $name => $callback) {
$latteEngine->addFilter($name, $callback);
}
}
View
@@ -3,60 +3,41 @@ services:
autowire: true
autoconfigure: true
# main application entrance (cannot be autowired)
Symfony\Component\Console\Application: ~
ApiGen\Application\ApiGenApplication: ~
ApiGen\ModularConfiguration\Parameter\ParameterProvider:
arguments: ['@service_container']
# 3rd party services (cannot be autowired)
Symfony\Component\Console\Output\ConsoleOutput: ~
# DocBlock
phpDocumentor\Reflection\DocBlockFactory:
factory: phpDocumentor\Reflection\DocBlockFactory::createInstance
# Source Code Highlighter
FSHL\Output\Html: ~
FSHL\Lexer\Php: ~
FSHL\Highlighter:
calls:
- [setLexer, ['@FSHL\Lexer\Php']]
Symfony\Component\EventDispatcher\EventDispatcher: ~
phpDocumentor\Reflection\Types\ContextFactory: ~
phpDocumentor\Reflection\FqsenResolver: ~
# PSR-4 autodiscovery
ApiGen\:
resource: '../../src'
exclude: '../../src/{Application/Command,Event,Exception}'
ApiGen\ModularConfiguration\Option\:
resource: '../../packages/ModularConfiguration/src/Option'
ApiGen\Element\:
resource: '../../packages/Element/src'
ApiGen\StringRouting\:
resource: '../../packages/StringRouting/src'
ApiGen\Annotation\:
resource: '../../packages/Annotation/src'
ApiGen\Element\:
resource: '../../packages/Element/src'
ApiGen\ModularConfiguration\:
resource: '../../packages/ModularConfiguration/src'
exclude: '../../packages/ModularConfiguration/src/{Exception}'
ApiGen\Reflection\:
resource: '../../packages/Reflection/src'
exclude: '../../packages/Reflection/src/{Exception,Reflection}'
# root collectors (move to package builder?)
ApiGen\ModularConfiguration\CommandDecorator: ~
ApiGen\ModularConfiguration\ConfigurationResolver: ~
ApiGen\Reflection\TransformerCollector: ~
ApiGen\Element\ReflectionCollectorCollector: ~
# services (might be removed, when reflection container aware)
ApiGen\Configuration\Configuration: ~
ApiGen\Reflection\Parser\Parser: ~
ApiGen\Reflection\ReflectionStorage: ~
ApiGen\Utils\RelativePathResolver: ~
ApiGen\StringRouting\:
resource: '../../packages/StringRouting/src'
# Filter Aware Latte Engine
ApiGen\Latte\FiltersAwareLatteEngineFactory: ~
Latte\Engine:
factory: 'ApiGen\Latte\FiltersAwareLatteEngineFactory:create'
# PHP Documentor
phpDocumentor\Reflection\DocBlockFactory:
factory: phpDocumentor\Reflection\DocBlockFactory::createInstance
phpDocumentor\Reflection\Types\ContextFactory: ~
phpDocumentor\Reflection\FqsenResolver: ~
# Source Code Highlighter
FSHL\Output\Html: ~
FSHL\Lexer\Php: ~
FSHL\Highlighter:
calls:
- [setLexer, ['@FSHL\Lexer\Php']]
# 3rd party services
Symfony\Component\Console\Application: ~
Symfony\Component\Console\Output\ConsoleOutput: ~
Symfony\Component\EventDispatcher\EventDispatcher: ~

0 comments on commit 1c257b3

Please sign in to comment.