Skip to content

Commit cd135e9

Browse files
committed
Initial changes for Symfony 4 compatibility.
1 parent 903c8a7 commit cd135e9

4 files changed

Lines changed: 65 additions & 10 deletions

File tree

Command/AbstractCommand.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010
namespace Propel\Bundle\PropelBundle\Command;
1111

12-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
1312
use Symfony\Component\Console\Input\InputInterface;
1413
use Symfony\Component\Console\Question\ConfirmationQuestion;
1514
use Symfony\Component\Console\Output\OutputInterface;
@@ -230,7 +229,7 @@ protected function copySchemas(KernelInterface $kernel, $cacheDir)
230229
$filesystem->mkdir($cacheDir);
231230
}
232231

233-
$base = ltrim(realpath($kernel->getRootDir().'/..'), DIRECTORY_SEPARATOR);
232+
$base = ltrim(realpath($kernel->getProjectDir()), DIRECTORY_SEPARATOR);
234233

235234
$finalSchemas = $this->getFinalSchemas($kernel, $this->bundle);
236235
foreach ($finalSchemas as $schema) {
@@ -351,7 +350,7 @@ protected function getRelativeFileName(\SplFileInfo $file)
351350
protected function createBuildPropertiesFile(KernelInterface $kernel, $file)
352351
{
353352
$filesystem = new Filesystem();
354-
$buildPropertiesFile = $kernel->getRootDir().'/config/propel.ini';
353+
$buildPropertiesFile = $kernel->getProjectDir().'/config/propel.ini';
355354

356355
if (file_exists($buildPropertiesFile)) {
357356
$filesystem->copy($buildPropertiesFile, $file);
@@ -652,8 +651,8 @@ private function getPhingArguments(KernelInterface $kernel, $workingDirectory, $
652651
$properties = array_merge(array(
653652
'propel.database' => 'mysql',
654653
'project.dir' => $workingDirectory,
655-
'propel.output.dir' => $kernel->getRootDir().'/propel',
656-
'propel.php.dir' => $kernel->getRootDir().'/..',
654+
'propel.output.dir' => $kernel->getProjectDir().'/propel',
655+
'propel.php.dir' => $kernel->getProjectDir(),
657656
'propel.packageObjectModel' => true,
658657
'propel.useDateTimeClass' => true,
659658
'propel.dateTimeClass' => 'DateTime',

Command/ContainerAwareCommand.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Propel\Bundle\PropelBundle\Command;
13+
14+
use Symfony\Component\Console\Command\Command;
15+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
16+
use Symfony\Component\DependencyInjection\ContainerInterface;
17+
18+
/**
19+
* Command.
20+
*
21+
* @author Fabien Potencier <fabien@symfony.com>
22+
*/
23+
abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface
24+
{
25+
/**
26+
* @var ContainerInterface|null
27+
*/
28+
private $container;
29+
30+
/**
31+
* @return ContainerInterface
32+
*
33+
* @throws \LogicException
34+
*/
35+
protected function getContainer()
36+
{
37+
if (null === $this->container) {
38+
$application = $this->getApplication();
39+
if (null === $application) {
40+
throw new \LogicException('The container cannot be retrieved as the application instance is not yet set.');
41+
}
42+
43+
$this->container = $application->getKernel()->getContainer();
44+
}
45+
46+
return $this->container;
47+
}
48+
49+
/**
50+
* {@inheritdoc}
51+
*/
52+
public function setContainer(ContainerInterface $container = null)
53+
{
54+
$this->container = $container;
55+
}
56+
}

Twig/Extension/SyntaxExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
namespace Propel\Bundle\PropelBundle\Twig\Extension;
1111

12+
use Twig\Extension\AbstractExtension;
1213
use Twig\TwigFilter;
1314

1415
/**
@@ -18,7 +19,7 @@
1819
* @subpackage Extension
1920
* @author William DURAND <william.durand1@gmail.com>
2021
*/
21-
class SyntaxExtension extends \Twig_Extension
22+
class SyntaxExtension extends AbstractExtension
2223
{
2324
public function getFilters()
2425
{

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
"require": {
2626
"ext-simplexml": "*",
2727
"ext-pdo": "*",
28-
"symfony/framework-bundle": "^3.0.2",
29-
"palepurple/propel1": "^1.7"
28+
"symfony/framework-bundle": "4.4.*",
29+
"palepurple/propel1": "^1.7",
30+
"symfony/console": "^4.4"
3031
},
3132
"require-dev": {
3233
"phpunit/phpunit": "^4.8.21|^5.0.10",
3334
"phing/phing": "^2.12",
34-
"symfony/symfony": "^3.0.2",
35-
"sensio/framework-extra-bundle": "^3.0.2",
3635
"fzaninotto/faker": "^1.5"
3736
},
3837
"conflict": {

0 commit comments

Comments
 (0)