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

use setFactory service definition method for symfony >= 2.6 (when possible) #566

Merged
merged 19 commits into from
Jun 4, 2015

Conversation

adam187
Copy link
Contributor

@adam187 adam187 commented Feb 28, 2015

setFactoryClass, setFactoryMethod is deprecated since 2.6

@adam187 adam187 changed the title use setFactory service definition method for symfony >= 2.6 use setFactory service definition method for symfony >= 2.6 (when possible) Feb 28, 2015
@lsmith77 lsmith77 added the State: Reviewing This item is being reviewed to determine if it should be accepted. label May 29, 2015
@lsmith77
Copy link
Contributor

can you expand the .travis.yml file to include more versions of Symfony, if possible even including Symfony 3 https://github.com/doctrine/DoctrinePHPCRBundle/pull/187/files

@adam187
Copy link
Contributor Author

adam187 commented May 30, 2015

@lsmith77 I expanded symfony version up to 3.0.* in .travis.yml but not for 2.7 and up tests are failing on some other tests related to CacheResolver. I could probably fix them but i think it shouldn't be subject of this PR. Any suggestion?

@gremo
Copy link

gremo commented May 31, 2015

Any updates on this? Deprecation messages are quite annoying :(

@adam187
Copy link
Contributor Author

adam187 commented May 31, 2015

@gremo You can use my fork until this one is resolved or generally disable deprecation messages with custom console file https://gist.github.com/adam187/9bdc986bcc69f4090f30

@gremo
Copy link

gremo commented May 31, 2015

@adam187 thanks, I will use your fork until gets merged.

You should (I could be wrong) tag your current master version as 1.2.4 so that when this get merged we can simply remove the repository in composer.json and get the fixed version from the original repo (my minimum stability is stable):

"require": {
    "liip/imagine-bundle": "~1.0"
},
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/adam187/LiipImagineBundle"
    }
]

Right now to use your fork I'm forced to use:

"require": {
    "liip/imagine-bundle": "dev-master"
}

@adam187
Copy link
Contributor Author

adam187 commented May 31, 2015

@gremo You have to use

"require": {
    "liip/imagine-bundle": "dev-set-factories"
}

because this changes hasn't been merged to master on my fork.
Also i think tagging not stable version on fork it's not a good idea.
It can create issues for syncing fork with upstream repo.

@lsmith77
Copy link
Contributor

lsmith77 commented Jun 1, 2015

to fix the memory issue with PHP 5.3 add the following to the travis build section:
if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi

for the deprecation notices you can add the symfony phpunit bridge:
http://symfony.com/blog/new-in-symfony-2-7-phpunit-bridge

@adam187 adam187 force-pushed the set-factories branch 2 times, most recently from 48d00e4 to 0e3e544 Compare June 1, 2015 13:08
@adam187
Copy link
Contributor Author

adam187 commented Jun 2, 2015

@lsmith77 I added memory limit rule and phpunit-bridge but there are still some errors duo OptionsResolver/OptionsResolverInterface for symfony 2.7 and above.

Should i fix them here or is it a case for another PR ?

@lsmith77
Copy link
Contributor

lsmith77 commented Jun 2, 2015

no I think its good if we do it all in here. thank you for your work!

@makasim
Copy link
Collaborator

makasim commented Jun 2, 2015

@adam187 Agree with @lsmith77 . The PR must be green before we can merge it.

$awsS3ClientDefinition = new Definition('Aws\S3\S3Client');
$awsS3ClientDefinition->setFactoryClass('Aws\S3\S3Client');
$awsS3ClientDefinition->setFactoryMethod('factory');
if (method_exists($awsS3ClientDefinition, 'setFactory')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO, it is better to check symfony version here to be more explicit why we have this if.

Copy link
Collaborator

Choose a reason for hiding this comment

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

And it will also reflect the preferred may and the one which will be removed in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

okay, could you add a comment to else statement that it can be remove when we drop support of symfony <2.7

@adam187
Copy link
Contributor Author

adam187 commented Jun 3, 2015

@lsmith77 Ready to check

/**
* @param ContainerBuilder $container
*/
private function setFactories($container)
Copy link
Collaborator

Choose a reason for hiding this comment

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

ContainerInterface typehint

@adam187
Copy link
Contributor Author

adam187 commented Jun 3, 2015

@makasim Updated

'index_key' => 'string',
);

if (version_compare(Kernel::VERSION_ID, '20600') >= 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the logic behind this change. Looks strange to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@makasim Since symfony 2.6 setAllowedTypes api changed.

Now you call it with option and array of types instead off array where key is option and value is allowed types.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah okay

Copy link
Collaborator

Choose a reason for hiding this comment

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

but it is a BC break, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adam187
Copy link
Contributor Author

adam187 commented Jun 4, 2015

@makasim Updated

makasim added a commit that referenced this pull request Jun 4, 2015
use setFactory service definition method for symfony >= 2.6 (when possible)
@makasim makasim merged commit 24c977c into liip:master Jun 4, 2015
@lsmith77 lsmith77 removed the State: Reviewing This item is being reviewed to determine if it should be accepted. label Jun 4, 2015
@makasim
Copy link
Collaborator

makasim commented Jun 4, 2015

@vishalmelmatti
Copy link

Thanks for adding 2.7 support but still there is warning while updating composer.

Deprecated: Symfony\Component\DependencyInjection\Definition::setFactoryClass(Aws\S3\S3Client) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead. in vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php on line 101

@makasim
Copy link
Collaborator

makasim commented Jun 5, 2015

@adam187 this deprecation was "fixed", wasn't it? @vishalmelmatti Did you upgrade to 1.3.0 version.

@vishalmelmatti
Copy link

@makasim yeah I upgraded to 1.3.0. This is my composer.lock

"name": "liip/imagine-bundle",
"version": "1.3.0",
"target-dir": "Liip/ImagineBundle",
"source": {
"type": "git",
"url": "https://github.com/liip/LiipImagineBundle.git",
"reference": "24c977ccf1a15854dc5fb3efc5de86011f8f0ef3"
},

@vishalmelmatti
Copy link

@adam187 @makasim Yeah I saw the code changes. But if you still try to run composer update or install it gives same warnings.

@adam187
Copy link
Contributor Author

adam187 commented Jun 5, 2015

@vishalmelmatti Are you sure this warning is from this bundle and not from some service definition in yml/xml?

@vishalmelmatti
Copy link

@adam187 Ah, it could be due to this http://symfony.com/doc/master/bundles/LiipImagineBundle/cache-resolver/aws_s3.html#create-resolver-as-a-service . I am defining my custom Aws client service.

@adam187
Copy link
Contributor Author

adam187 commented Jun 5, 2015

@vishalmelmatti

services:
    acme.amazon_s3:
        class: Aws\S3\S3Client
        factory: [Aws\S3\S3Client, factory]

@vishalmelmatti
Copy link

@adam187 Great. It clears warnings. Thanks a lot.

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