8000 add new kernel getProjectDir() and project_dir parameter · lazerball/HitTracker@2d6f3aa · GitHub
[go: up one dir, main page]

Skip to content

Commit 2d6f3aa

Browse files
author
Johnny Robeson
committed
add new kernel getProjectDir() and project_dir parameter
This new parameter and method will appear in Symfony 3.3 as per symfony/symfony#22315 We will remove it then.
1 parent adf6e2e commit 2d6f3aa

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

app/AppKernel.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@
2020
use Symfony\Component\HttpKernel\Kernel;
2121
use function Cekurte\Environment\env;
2222

23+
24+
/**
25+
* {@inheritdoc}
26+
27+
* @todo remove projectDir for symfony 3.3
28+
*/
2329
abstract class AppKernel extends Kernel
2430
{
31+
private $projectDir;
32+
2533
/**
2634
* {@inheritdoc}
2735
*
2836
* @throw InvalidArgumentException if not in a subclass of AppKernel
2937
*/
3038
public function __construct($environment, $debug)
3139
{
40+
$this->projectDir = dirname(__DIR__);
41+
3242
/*
3343
* Can't add new args to the constructor, due to instantiation
3444
* in the cache warmer
@@ -122,6 +132,22 @@ public function registerContainerConfiguration(LoaderInterface $loader)
122132
}
123133
}
124134

135+
/**
136+
* @todo remove project_dir and this whole method for symfony 3.3
137+
*/
138+
protected function getKernelParameters(): array
139+
{
140+
$kernelParameters = parent::getKernelParameters();
141+
$kernelParameters['kernel.project_dir'] = realpath($this->projectDir) ?: $this->projectDir;
142+
143+
return $kernelParameters;
144+
}
145+
146+
public function getProjectDir(): string
147+
{
148+
return $this->projectDir;
149+
}
150+
125151
public function getCacheDir(): string
126152
{
127153
$varDir = env('SYMFONY__VAR_DIR');
@@ -130,7 +156,7 @@ public function getCacheDir(): string
130156
}
131157

132158
return implode('/', [
133-
dirname($this->rootDir),
159+
$this->projectDir,
134160
'/var/cache',
135161
$this->getBuildType(),
136162
$this->environment,
@@ -145,7 +171,7 @@ public function getLogDir(): string
145171
}
146172

147173
return implode('/', [
148-
dirname($this->rootDir),
174+
$this->projectDir,
149175
'/var/logs',
150176
$this->getBuildType(),
151177
]);

app/config/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ doctrine:
5050
mappings:
5151
LazerBall\HitTracker\Model:
5252
type: annotation
53-
dir: '%kernel.root_dir%/../src/Model'
53+
dir: '%kernel.project_dir%/src/Model'
5454
is_bundle: false
5555
prefix: LazerBall\HitTracker\Model
5656
alias: HitTracker
5757

5858
doctrine_migrations:
59+
# can't use project_dir here yet due to migration bundle's Doctrine command
5960
dir_name: "%kernel.root_dir%/../migrations"
6061
namespace: "LazerBall\\HitTracker\\Migrations"
6162

app/config/electron/parameters.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
parameters:
2-
env(HITTRACKER_ 8A76 DATABASE_PATH): "%kernel.root_dir%/../var/data/hittracker.db"
2+
env(HITTRACKER_DATABASE_PATH): "%kernel.project_dir%/var/data/hittracker.db"
33
database_server_version: 3.14.2
44
database_path: "%env(HITTRACKER_DATABASE_PATH)%"

app/config/parameters_default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
parameters:
22
env(HITTRACKER_BUILD_TYPE): standalone
3-
env(HITTRACKER_UPLOAD_DIR): "%kernel.root_dir%/../var/uploads"
3+
env(HITTRACKER_UPLOAD_DIR): "%kernel.project_dir%/var/uploads"
44
secret: "%env(HITTRACKER_SESSION_SECRET)"
55
locale: en_US
66
icu_time_date_format: 'MM/dd/y hh:mm a'

0 commit comments

Comments
 (0)
0