Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge] symfony 5 compatibility #5

Open
wants to merge 5 commits into
base: symfony_4.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions Controller/PanelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,43 @@
*/
namespace Propel\Bundle\PropelBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Response;
use Psr\Container\ContainerInterface;
use Twig\Environment;

/**
* PanelController is designed to display information in the Propel Panel.
*
* @author William DURAND <william.durand1@gmail.com>
*/
class PanelController extends ContainerAware
class PanelController
{
use ContainerAwareTrait;

private $twig;

public function __construct(ContainerInterface $container, Environment $twig)
{
$this->container = $container;
$this->twig = $twig;
}

/**
* This method renders the global Propel configuration.
*/
public function configurationAction()
{
$templating = $this->container->get('templating');
$configuration = $this->container->get('propel.configuration')->getParameters();

return $templating->renderResponse(
'PropelBundle:Panel:configuration.html.twig',
array(
'propel_version' => \Propel::VERSION,
'configuration' => $this->container->get('propel.configuration')->getParameters(),
'default_connection' => $this->container->getParameter('propel.dbal.default_connection'),
'logging' => $this->container->getParameter('propel.logging'),
'path' => $this->container->getParameter('propel.path'),
'phing_path' => $this->container->getParameter('propel.phing_path'),
)
);
return new Response($this->twig->render('@Propel/Panel/configuration.html.twig', array(
'propel_version' => \Propel::VERSION,
'configuration' => $configuration,
'default_connection' => $this->container->getParameter('propel.dbal.default_connection'),
'logging' => $this->container->getParameter('propel.logging'),
'path' => $this->container->getParameter('propel.path'),
'phing_path' => $this->container->getParameter('propel.phing_path'),
)));
}

/**
Expand Down Expand Up @@ -73,8 +82,8 @@ public function explainAction($token, $connection, $query)
return new Response('<div class="error">This query cannot be explained.</div>');
}

return $this->container->get('templating')->renderResponse(
'PropelBundle:Panel:explain.html.twig',
return $this->twig->render(
'@Propel/Panel/explain.html.twig',
array(
'data' => $results,
'query' => $query,
Expand Down
2 changes: 1 addition & 1 deletion DataCollector/PropelDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(PropelLogger $logger, \PropelConfiguration $propelCo
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, ?\Throwable $exception = null)
{
$this->data = array(
'queries' => $this->buildQueries(),
Expand Down
2 changes: 1 addition & 1 deletion DataFixtures/Loader/AbstractDataLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract protected function transformDataToArray($file);
/**
* {@inheritdoc}
*/
public function load($files = array(), $connectionName)
public function load($files = array(), $connectionName = null)
{
$nbFiles = 0;
$this->deletedClasses = array();
Expand Down
2 changes: 1 addition & 1 deletion DataFixtures/Loader/DataLoaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ interface DataLoaderInterface
* @param array $files A set of files containing datas to load.
* @param string $connectionName The Propel connection name
*/
public function load($files = array(), $connectionName);
public function load($files = array(), $connectionName = null);
}
2 changes: 1 addition & 1 deletion DataFixtures/Loader/DataWiper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DataWiper extends AbstractDataLoader
* @param array $files A set of files containing datas to load.
* @param string $connectionName The Propel connection name
*/
public function load($files = array(), $connectionName)
public function load($files = array(), $connectionName = null)
{
$this->deletedClasses = array();
$this->loadMapBuilders($connectionName);
Expand Down
50 changes: 25 additions & 25 deletions Resources/views/Collector/propel.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %}
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% block toolbar %}
{% if collector.querycount %}
Expand All @@ -14,7 +14,7 @@

{% set text %}{% endset %}

{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { link: profiler_url } %}
{% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { link: profiler_url } %}
{% endif %}
{% endblock %}

Expand Down Expand Up @@ -73,33 +73,33 @@
<tr><td>No queries.</td></tr>
{% else %}
{% for i, query in collector.queries %}
<tr>
<td>
<a name="propel-query-{{ i }}" ></a>
<code>{{ query.sql|format_sql }}</code>
{% if app.request.query.has('query') and app.request.query.get('query') == i %}
<div class="SQLExplain">
{% render controller('PropelBundle:Panel:explain', {
'token': token,
'panel': 'propel',
'query': app.request.query.get('query'),
'connection': app.request.query.get('connection')
}) %}
</div>
{% endif %}
<div class="SQLInfo">
Time: {{ query.time }} - Memory: {{ query.memory }} - Connection: {{ query.connection }}

{% if app.request.query.get('query', -1) != i %}
- <a href="{{ path('_profiler', {'panel': 'propel', 'token': token, 'connection': query.connection, 'query': i}) }}#propel-query-{{ i }}">Explain the query</a>
<tr>
<td>
<a name="propel-query-{{ i }}" ></a>
<code>{{ query.sql|format_sql }}</code>
{% if app.request.query.has('query') and app.request.query.get('query') == i %}
<div class="SQLExplain">
{{ render(controller('PropelBundle:Panel:explain', {
'token': token,
'panel': 'propel',
'query': app.request.query.get('query'),
'connection': app.request.query.get('connection')
})) }}
</div>
{% endif %}
</div>
</td>
</tr>
<div class="SQLInfo">
Time: {{ query.time }} - Memory: {{ query.memory }} - Connection: {{ query.connection }}

{% if app.request.query.get('query', -1) != i %}
- <a href="{{ path('_profiler', {'panel': 'propel', 'token': token, 'connection': query.connection, 'query': i}) }}#propel-query-{{ i }}">Explain the query</a>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>

{% render controller('PropelBundle:Panel:configuration') %}
{{ render(controller('PropelBundle:Panel:configuration')) }}
{% endblock %}
6 changes: 4 additions & 2 deletions Resources/views/Panel/configuration.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<tr>
<th>Default connection</th>
<td>{{ default_connection }}</td>

</tr>
<tr>
<th>Logging</th>
<td>{{ logging ? 'enabled' : 'disabled' }}</td>
Expand Down Expand Up @@ -57,7 +59,7 @@
<td>
<ul>
{% for key, value in config.connection.options %}
<li>{{ key }} : {{ value }}</li>
<li>{{ key }} : {% if value is iterable %}{{ value|json_encode }}{% else %}{{ value }}{% endif %}</li>
{% endfor %}
</ul>
</td>
Expand All @@ -67,7 +69,7 @@
<td>
<ul>
{% for key, value in config.connection.attributes %}
<li>{{ key }} : {{ value }}</li>
<li>{{ key }} : {% if value is iterable %}{{ value|json_encode }}{% else %}{{ value }}{% endif %}</li>
{% endfor %}
</ul>
</td>
Expand Down
3 changes: 3 additions & 0 deletions Tests/Command/FixturesLoadCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
class FixturesLoadCommandTest extends TestCase
{
protected $command;
protected $fixturesDir;
protected $fixturesFiles;
protected $filesystem;

public function setUp(): void
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/DataFixtures/Dumper/YamlDataDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public function testYamlDump()
$expected = <<<YAML
Propel\Bundle\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthor:
BookAuthor_1:
id: '1'
id: 1
name: 'A famous one'
Propel\Bundle\PropelBundle\Tests\Fixtures\DataFixtures\Loader\Book:
Book_1:
id: '1'
id: 1
name: 'An important one'
author_id: BookAuthor_1
complementary_infos: !php/object 'O:8:"stdClass":1:{s:15:"first_word_date";s:10:"2012-01-01";}'
Expand Down
10 changes: 10 additions & 0 deletions Translation/ModelTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ private function getColumnPhpname($identifier)
return $this->query->getTableMap()->getColumn($this->getColumnname($identifier))->getPhpName();
}

public function __serialize()
{
return $this->serialize();
}

/**
* {@inheritdoc}
*/
Expand All @@ -249,6 +254,11 @@ public function serialize()
));
}

public function __unserialize($serialized)
{
return $this->unserialize($serialized);
}

/**
* {@inheritdoc}
*/
Expand Down
2 changes: 1 addition & 1 deletion Util/PropelInflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ class PropelInflector
*/
public static function camelize($word)
{
return lcfirst(str_replace(" ", "", ucwords(strtr($word, "_-", " "))));
return lcfirst(str_replace(" ", "", ucwords(strtr($word ?? '', "_-", " "))));
}
}
2 changes: 1 addition & 1 deletion autoload_aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class_alias(str_replace('Propel\PropelBundle', 'Propel\Bundle\PropelBundle', $cl
}
}

spl_autoload_register('autoload_propel_aliases', false, true);
spl_autoload_register('autoload_propel_aliases', true, true);
21 changes: 14 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
},

"require": {
"php": "^7.2",
"propel/propel1": "^1.6",
"symfony/framework-bundle": "^3.0|^4.0",
"symfony/symfony": "^4.0"
"php": "^7.2|^8.3",
"propel/propel1": "1.6.19|dev-symfony-5",
"symfony/framework-bundle": "^3.0|^4.0|^5.0",
"symfony/symfony": "^4.0|^5.0"
},
"require-dev": {
"ext-sqlite3": "*",
"sensio/framework-extra-bundle": "^4.0",
"fzaninotto/faker": "^1.5",
"sensio/framework-extra-bundle": "^4.0|^5.0",
"fakerphp/faker": "^1.5",
"phpunit/phpunit": "^8.5.27",
"symfony/phpunit-bridge": "^6"
},
Expand All @@ -38,5 +38,12 @@
},
"suggest": {
"propel/propel-acl-bundle": "For using the Propel ACL implementation"
}
},
"repositories": [
{
"type": "git",
"url": "https://github.com/CrossKnowledge/Propel.git",
"packagist.org": false
}
]
}