Skip to content

Add Symfony 4 support #145

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

Merged
merged 29 commits into from
Dec 28, 2017
Merged

Add Symfony 4 support #145

merged 29 commits into from
Dec 28, 2017

Conversation

bocharsky-bw
Copy link
Member

No description provided.

@Nyholm Nyholm self-requested a review December 12, 2017 22:00
@Nyholm
Copy link
Member

Nyholm commented Dec 13, 2017

Thank you. I will make sure the tests are green later today.

@bocharsky-bw
Copy link
Member Author

I was able to fix some of them, but I still have some weird fails.

Also, StyleCI shows some fails not related to this PR. Should I fix them here?

@bocharsky-bw
Copy link
Member Author

This PR is blocked by php-translation/symfony-storage#19

@bocharsky-bw
Copy link
Member Author

Finally, I was able to fix all the tests, but they pass only with php-translation/symfony-storage#19 patch

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

We need a legacy layer for the TranslationReader

*/
public function __construct(TranslationLoader $loader)
public function __construct(TranslationReader $reader)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class does not exists in sf3.4

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but I'm not sure what's the best way to inject wether translation.reader or translation.loader depends on Symfony version. Injecting the whole container probably is not an option because those services are private. Maybe Compiler Pass can help with it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler pass would be preferable as that moves the calculation from runtime to compile time. 👍

Unfortunately TranslationLoader does not have the TranslationReaderInterface yet, so typehinting won't be possible right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bocharsky-bw I've made a PR to your fork. Please have a look.

@@ -1,10 +1,12 @@
services:
php_translation.extractor.php:
public: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these really have to be public?

@bocharsky-bw
Copy link
Member Author

One more blocker for this PR: php-translation/symfony-storage#22

symfony-storage tests had not revealed it, but symfony-bundle tests did

@bocharsky-bw
Copy link
Member Author

@Nyholm finally this PR is done and ready for your review

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

use Translation\Bundle\Model\Configuration;
use Translation\SymfonyStorage\LegacyTranslationLoader;
use Translation\SymfonyStorage\TranslationLoader;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface does not exist anymore

*/
public function __construct(TranslationLoader $loader)
public function __construct($loader)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be renamed to "$reader"

{
// Create a legacy loader which is a wrapper for TranslationReader
if ($loader instanceof TranslationReader) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!$loader instanceof TranslationReaderInterface)

if ($loader instanceof TranslationReader) {
$loader = new LegacyTranslationLoader($loader);
}
if (!$loader instanceof SymfonyTranslationLoader && !$loader instanceof TranslationLoader) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed if you change the logic of the if above

@@ -53,7 +53,7 @@ public function __construct(
public function writeCatalogues(Configuration $config, array $catalogues)
{
foreach ($catalogues as $catalogue) {
$this->writer->writeTranslations(
$this->writeTranslations(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use $this->writer->write()


use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you write a class comment that explains the purpose of this CompilerPass?

@@ -14,6 +14,10 @@ services:
class: Translation\Bundle\EditInPlace\Activator
arguments: ['@session']

test.php_translation.edit_in_place.activator:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we put these in a separate file?

class: Translation\Bundle\Catalogue\CatalogueFetcher
arguments: ["@translation.loader"]
arguments: ["@translation.loader_or_reader"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thanks to @dkozickis for this idea and his help

@@ -13,26 +15,37 @@ services:
arguments: ["@php_translation.catalogue_fetcher", "@php_translation.catalogue_writer", ~]

php_translation.catalogue_manager:
public: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the services need to be public?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we call it from the container in WebUIController::showAction()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can inject it into controller instead, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should But that is out of scope for this PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, it won't work in 2.7, will it?

composer.json Outdated

"php-translation/common": "^0.2.1",
"php-translation/symfony-storage": "^0.3.2",
"php-translation/symfony-storage": "^0.3.4",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 0.4.0

@bocharsky-bw
Copy link
Member Author

@Nyholm All the requested changes are done!

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Just some minors

use Translation\Bundle\Model\Configuration;
use Translation\SymfonyStorage\LegacyTranslationReader;
use Translation\SymfonyStorage\TranslationLoader;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface does not exits anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? Because I see it in master: https://github.com/php-translation/symfony-storage/blob/master/src/TranslationLoader.php and it is not even deprecated.

@@ -39,7 +39,7 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
$importer = $container->get('php_translation.importer');
$importer = $container->get('test.php_translation.importer');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... This is not perfect. Lets make php_translation.importer public for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fix this and I'm happy to merge

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Sorry about this

@Nyholm
Copy link
Member

Nyholm commented Dec 28, 2017 via email

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks!

@Nyholm Nyholm merged commit e6b000b into php-translation:master Dec 28, 2017
@bocharsky-bw bocharsky-bw deleted the patch-1 branch December 28, 2017 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants