Skip to content

Commit b87f74a

Browse files
committed
use PSR-1 and PSR-2 code style.
1 parent 33d644c commit b87f74a

3 files changed

+96
-97
lines changed

src/DrupalEmbeddedKernel.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88
abstract class DrupalEmbeddedKernel extends BaseKernel
99
{
10-
1110
const EXTRA_VERSION = 'drupal';
1211

1312
/**
@@ -17,7 +16,7 @@ abstract class DrupalEmbeddedKernel extends BaseKernel
1716
*/
1817
public function getCacheDir()
1918
{
20-
$cache_dir = 'public://var' . '/'. $this->getName() .'/'. $this->environment .'/cache';
19+
$cache_dir = 'public://var'.'/'.$this->getName().'/'.$this->environment.'/cache';
2120
file_prepare_directory($cache_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
2221

2322
return drupal_realpath($cache_dir);
@@ -30,7 +29,7 @@ public function getCacheDir()
3029
*/
3130
public function getLogDir()
3231
{
33-
$log_dir = 'public://var' . '/' . $this->getName() .'/'. $this->environment .'/logs';
32+
$log_dir = 'public://var'.'/'.$this->getName().'/'.$this->environment.'/logs';
3433
file_prepare_directory($log_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
3534

3635
return drupal_realpath($log_dir);

src/DrupalKernelServiceProvider.php

+76-76
Original file line numberDiff line numberDiff line change
@@ -4,90 +4,90 @@
44

55
class DrupalKernelServiceProvider implements ServiceProviderInterface
66
{
7-
/**
8-
* Registers services on the given container.
9-
*
10-
* This method should only be used to configure services and parameters.
11-
* It should not get services.
12-
*
13-
* @param \Pimple\Container $pimple An Container instance
14-
*/
15-
public function register(\Pimple\Container $pimple)
16-
{
17-
$pimple['kernel.name'] = 'app';
18-
$pimple['kernel.info'] = function ($c) {
19-
return kernel_info($c['kernel.name']);
20-
};
21-
22-
$pimple['kernel'] = function ($c) {
23-
$info = $c['kernel.info'];
24-
if (is_array($info['require_once'])) {
25-
$files = array_filter($info['require_once'], 'file_exists');
26-
if (!empty($files)) {
27-
foreach ($files as $file) {
28-
require_once $file;
29-
}
30-
}
31-
}
7+
/**
8+
* Registers services on the given container.
9+
*
10+
* This method should only be used to configure services and parameters.
11+
* It should not get services.
12+
*
13+
* @param \Pimple\Container $pimple An Container instance
14+
*/
15+
public function register(\Pimple\Container $pimple)
16+
{
17+
$pimple['kernel.name'] = 'app';
18+
$pimple['kernel.info'] = function ($c) {
19+
return kernel_info($c['kernel.name']);
20+
};
3221

33-
if ($info['arguments'][1]) {
34-
\Symfony\Component\Debug\Debug::enable();
35-
}
22+
$pimple['kernel'] = function ($c) {
23+
$info = $c['kernel.info'];
24+
if (is_array($info['require_once'])) {
25+
$files = array_filter($info['require_once'], 'file_exists');
26+
if (!empty($files)) {
27+
foreach ($files as $file) {
28+
require_once $file;
29+
}
30+
}
31+
}
3632

37-
if (class_exists($info['kernel class'])) {
33+
if ($info['arguments'][1]) {
34+
\Symfony\Component\Debug\Debug::enable();
35+
}
3836

39-
/* @var \Symfony\Component\HttpKernel\KernelInterface $kernel */
40-
if (!empty($info['arguments']) && is_array($info['arguments'])) {
41-
$reflect = new ReflectionClass($info['kernel class']);
42-
$kernel = $reflect->newInstanceArgs($info['arguments']);
43-
} else {
44-
$kernel = new $info['kernel class']();
45-
}
37+
if (class_exists($info['kernel class'])) {
38+
/* @var \Symfony\Component\HttpKernel\KernelInterface $kernel */
39+
if (!empty($info['arguments']) && is_array($info['arguments'])) {
40+
$reflect = new ReflectionClass($info['kernel class']);
41+
$kernel = $reflect->newInstanceArgs($info['arguments']);
42+
} else {
43+
$kernel = new $info['kernel class']();
44+
}
4645

47-
foreach ($info['calls'] as $method => $args) {
48-
call_user_func_array(array($kernel, $method), $args);
49-
}
46+
foreach ($info['calls'] as $method => $args) {
47+
call_user_func_array(array($kernel, $method), $args);
48+
}
5049

51-
return $kernel;
52-
} else {
53-
throw new \ErrorException($info['kernel class'] .' is not found');
54-
}
50+
return $kernel;
51+
} else {
52+
throw new \ErrorException($info['kernel class'].' is not found');
53+
}
5554

56-
};
55+
};
5756

58-
$pimple['container'] = function ($c) {
59-
$c['kernel']->boot();
57+
$pimple['container'] = function ($c) {
58+
$c['kernel']->boot();
6059

61-
return $c['kernel']->getContainer();
62-
};
60+
return $c['kernel']->getContainer();
61+
};
6362

64-
$pimple['router'] = function ($c) {
65-
return $c['container']->get('router');
66-
};
67-
$pimple['router.transformer'] = $pimple->protect(
68-
/**
69-
* @param $path
70-
*
71-
* @return array
72-
*/
73-
function ($path) {
74-
return array(
75-
'path' => $path,
76-
'page_callback' => 'kernel_callback',
77-
'page_arguments' => array(\Symfony\Component\HttpFoundation\Request::createFromGlobals()),
78-
'delivery_callback' => '',
79-
'tab_parent' => '',
80-
'tab_root' => $path,
81-
'title' => '',
82-
'type' => MENU_CALLBACK,
83-
'include_file' => drupal_get_path('module', 'kernel') . '/kernel.pages.inc',
84-
'href' => $path,
85-
'tab_root_href' => $path,
86-
'tab_parent_href' => '',
87-
'access' => TRUE,
88-
'original_map' => arg(NULL, $path),
89-
'map' => arg(NULL, $path),
63+
$pimple['router'] = function ($c) {
64+
return $c['container']->get('router');
65+
};
66+
$pimple['router.transformer'] = $pimple->protect(
67+
/**
68+
* @param $path
69+
*
70+
* @return array
71+
*/
72+
function ($path) {
73+
return array(
74+
'path' => $path,
75+
'page_callback' => 'kernel_callback',
76+
'page_arguments' => array(\Symfony\Component\HttpFoundation\Request::createFromGlobals()),
77+
'delivery_callback' => '',
78+
'tab_parent' => '',
79+
'tab_root' => $path,
80+
'title' => '',
81+
'type' => MENU_CALLBACK,
82+
'include_file' => drupal_get_path('module', 'kernel').'/kernel.pages.inc',
83+
'href' => $path,
84+
'tab_root_href' => $path,
85+
'tab_parent_href' => '',
86+
'access' => true,
87+
'original_map' => arg(null, $path),
88+
'map' => arg(null, $path),
89+
);
90+
}
9091
);
91-
});
92-
}
92+
}
9393
}

src/DrushKernelServiceProvider.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<?php
22

3+
use Pimple\ServiceProviderInterface;
34
use Symfony\Bundle\FrameworkBundle\Console\Application;
45

5-
class DrushKernelServiceProvider implements \Pimple\ServiceProviderInterface
6+
class DrushKernelServiceProvider implements ServiceProviderInterface
67
{
8+
/**
9+
* Registers services on the given container.
10+
*
11+
* This method should only be used to configure services and parameters.
12+
* It should not get services.
13+
*
14+
* @param \Pimple\Container $pimple An Container instance
15+
*/
16+
public function register(\Pimple\Container $pimple)
17+
{
18+
$pimple['console.application'] = function ($c) {
19+
$application = new Application($c['kernel']);
20+
$application->setAutoExit(false);
721

8-
/**
9-
* Registers services on the given container.
10-
*
11-
* This method should only be used to configure services and parameters.
12-
* It should not get services.
13-
*
14-
* @param \Pimple\Container $pimple An Container instance
15-
*/
16-
public function register(\Pimple\Container $pimple)
17-
{
18-
$pimple['console.application'] = function ($c) {
19-
$application = new Application($c['kernel']);
20-
$application->setAutoExit(false);
21-
22-
return $application;
23-
};
24-
}
22+
return $application;
23+
};
24+
}
2525
}

0 commit comments

Comments
 (0)