Skip to content

Commit

Permalink
[TASK] Update coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
gertvdb committed Oct 23, 2020
1 parent b3a5546 commit 2eaa3fc
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 191 deletions.
2 changes: 2 additions & 0 deletions Autoload/LegacyClassLoaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
interface LegacyClassLoaderInterface
{

/**
* Autoload the legacy code.
*
Expand All @@ -31,4 +32,5 @@ public function isAutoloaded();
* @param LegacyKernelInterface $kernel
*/
public function setKernel(LegacyKernelInterface $kernel);

}
14 changes: 6 additions & 8 deletions DependencyInjection/Compiler/KernelConfigurationPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class KernelConfigurationPass implements CompilerPassInterface
{


/**
* You can modify the container here before it is dumped to PHP code.
*
Expand All @@ -26,32 +25,31 @@ class KernelConfigurationPass implements CompilerPassInterface
*/
public function process(ContainerBuilder $container)
{

$kernelId = $container->getParameter('legacy_bridge_bundle.legacy_kernel.id');
$kernelOptions = $container->getParameter('legacy_bridge_bundle.legacy_kernel.options');
$classLoaderId = $this->getClassLoaderId($container);
$container->setAlias('legacy_bridge_bundle.legacy_kernel', $kernelId);

if (empty($kernelOptions) === false) {
if (empty($kernelOptions) === FALSE) {
$definition = $container->findDefinition($kernelId);
$definition->addMethodCall('setOptions', [$kernelOptions]);
}

if ($classLoaderId !== null) {
if ($classLoaderId !== NULL) {
$definition = $container->findDefinition($kernelId);
$definition->addMethodCall('setClassLoader', [new Reference($classLoaderId)]);
}
}

private function getClassLoaderId(ContainerBuilder $container) {
}

private function getClassLoaderId(ContainerBuilder $container)
{
try {
return $container->getParameter('legacy_bridge_bundle.legacy_kernel.class_loader.id');
} catch (\Exception $exception) {
return null;
return NULL;
}

}//end getClassLoaderId()


}
2 changes: 2 additions & 0 deletions DependencyInjection/Compiler/LoaderInjectorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class LoaderInjectorPass implements CompilerPassInterface
public function __construct(ClassLoader $loader)
{
$this->loader = $loader;

}

/**
Expand All @@ -40,6 +41,7 @@ public function process(ContainerBuilder $container)
foreach ($taggedServices as $id => $attributes) {
$container->getDefinition($id)->addMethodCall('setLoader', [new Reference('composer.loader')]);
}

}

}
7 changes: 2 additions & 5 deletions DependencyInjection/Compiler/ReplaceRouterPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
class ReplaceRouterPass implements CompilerPassInterface
{


/**
* Process container.
*
Expand All @@ -25,12 +24,11 @@ class ReplaceRouterPass implements CompilerPassInterface
*/
public function process(ContainerBuilder $container)
{

// When our router service is defined we replace the default router listener.
if ($container->hasDefinition('legacy_bridge_bundle.router_listener') === true) {
if ($container->hasDefinition('legacy_bridge_bundle.router_listener') === TRUE) {
// First get te default router_listener.
$routerListener = $container->getDefinition('router_listener');

// Then get our custom route listener and inject the default route listener.
$definition = $container->getDefinition('legacy_bridge_bundle.router_listener');
$definition->replaceArgument(0, $routerListener);
Expand All @@ -41,5 +39,4 @@ public function process(ContainerBuilder $container)

}//end process()


}//end class
27 changes: 1 addition & 26 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
class Configuration implements ConfigurationInterface
{


/**
* {@inheritDoc}
*/
Expand All @@ -21,31 +20,7 @@ public function getConfigTreeBuilder()
$treeBuilder = new TreeBuilder('legacy_bridge_bundle');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
->scalarNode('root_dir')
->info('The path where the legacy app lives')
->isRequired()
->end()
->arrayNode('legacy_kernel')
->children()
->scalarNode('id')
->info('The legacy kernel id')
->isRequired()
->end()
->arrayNode('options')
->children()
->scalarNode('application')
->info('The legacy application')
->end()
->scalarNode('environment')
->info('The environment')
->end()
->booleanNode('debug')
->info('Whether to enable debug')
->end()
->end()
->end();
$rootNode->children()->scalarNode('root_dir')->info('The path where the legacy app lives')->isRequired()->end()->arrayNode('legacy_kernel')->children()->scalarNode('id')->info('The legacy kernel id')->isRequired()->end()->arrayNode('options')->children()->scalarNode('application')->info('The legacy application')->end()->scalarNode('environment')->info('The environment')->end()->booleanNode('debug')->info('Whether to enable debug')->end()->end()->end();

return $treeBuilder;

Expand Down
5 changes: 0 additions & 5 deletions DependencyInjection/LegacyBridgeBundleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;


/**
* This is the class that loads and manages your bundle configuration
*/
class LegacyBridgeBundleExtension extends Extension
{


/**
* Loads a specific configuration.
*
Expand All @@ -31,18 +29,15 @@ class LegacyBridgeBundleExtension extends Extension
*/
public function load(array $configs, ContainerBuilder $container)
{

$loader = new XmlFileLoader(
$container,
new FileLocator(__DIR__.'/../Resources/config')
);
$loader->load('services.xml');


// Register composer class loader.
$container->register('composer.loader', 'Composer\Autoload\ClassLoader');

}//end load()


}
6 changes: 6 additions & 0 deletions Event/LegacyKernelBootEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
class LegacyKernelBootEvent extends Event
{

/**
* @var Request
*/
Expand All @@ -33,6 +34,7 @@ public function __construct(Request $request, array $options = array())
{
$this->request = $request;
$this->options = $options;

}

/**
Expand All @@ -41,6 +43,7 @@ public function __construct(Request $request, array $options = array())
public function getRequest()
{
return $this->request;

}

/**
Expand All @@ -49,6 +52,7 @@ public function getRequest()
public function getOptions()
{
return $this->options;

}

/**
Expand All @@ -57,6 +61,7 @@ public function getOptions()
public function setOptions($options)
{
$this->options = $options;

}

/**
Expand All @@ -66,6 +71,7 @@ public function setOptions($options)
public function setOption($name, $value)
{
$this->options[$name] = $value;

}

}
9 changes: 8 additions & 1 deletion Kernel/LegacyKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
*/
abstract class LegacyKernel implements LegacyKernelInterface
{

/**
* @var bool
*/
protected $isBooted = false;
protected $isBooted = FALSE;

/**
* @var string
Expand All @@ -37,6 +38,7 @@ abstract class LegacyKernel implements LegacyKernelInterface
public function isBooted()
{
return $this->isBooted;

}

/**
Expand All @@ -45,6 +47,7 @@ public function isBooted()
public function getRootDir()
{
return $this->rootDir;

}

/**
Expand All @@ -53,6 +56,7 @@ public function getRootDir()
public function setRootDir($rootDir)
{
$this->rootDir = $rootDir;

}

/**
Expand All @@ -62,6 +66,7 @@ public function setClassLoader(LegacyClassLoaderInterface $classLoader)
{
$classLoader->setKernel($this);
$this->classLoader = $classLoader;

}

/**
Expand All @@ -70,5 +75,7 @@ public function setClassLoader(LegacyClassLoaderInterface $classLoader)
public function setOptions(array $options = array())
{
$this->options = $options;

}

}
8 changes: 0 additions & 8 deletions Kernel/LegacyKernelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
interface LegacyKernelInterface extends HttpKernelInterface
{


/**
* Boot the legacy kernel.
*
Expand All @@ -29,53 +28,46 @@ interface LegacyKernelInterface extends HttpKernelInterface
*/
public function boot(ContainerInterface $container);


/**
* Check whether the legacy kernel is already booted or not.
*
* @return boolean
*/
public function isBooted();


/**
* Return the directory where the legacy app lives.
*
* @return string
*/
public function getRootDir();


/**
* Set the directory where the legacy app lives.
*
* @param string $rootDir
*/
public function setRootDir($rootDir);


/**
* Set the class loader to use to load the legacy project.
*
* @param LegacyClassLoaderInterface $classLoader
*/
public function setClassLoader(LegacyClassLoaderInterface $classLoader);


/**
* Return the name of the kernel.
*
* @return string
*/
public function getName();


/**
* Set kernel options
*
* @param array $options
*/
public function setOptions(array $options=[]);


}//end interface
8 changes: 6 additions & 2 deletions LegacyBridgeBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ class LegacyBridgeBundle extends Bundle
/**
* @param ClassLoader $loader
*/
public function __construct(ClassLoader $loader = null)
public function __construct(ClassLoader $loader = NULL)
{
$this->loader = $loader;

}

/**
Expand All @@ -39,16 +40,19 @@ public function __construct(ClassLoader $loader = null)
public function build(ContainerBuilder $container)
{
// The loader can be null when clearing the cache.
if (null !== $this->loader) {
if (NULL !== $this->loader) {
$container->addCompilerPass(new LoaderInjectorPass($this->loader));
}

$container->addCompilerPass(new KernelConfigurationPass());
$container->addCompilerPass(new ReplaceRouterPass());

}

public function getContainerExtension()
{
return new LegacyBridgeBundleExtension();

}

}
Loading

0 comments on commit 2eaa3fc

Please sign in to comment.