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

[2.3] Added currency locale data, form type and validator #6566

Closed
wants to merge 1 commit into from
Closed

[2.3] Added currency locale data, form type and validator #6566

wants to merge 1 commit into from

Conversation

mvrhov
Copy link

@mvrhov mvrhov commented Jan 5, 2013

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT
Documentation PR: symfony/symfony-docs#2105

@pjedrzejewski
Copy link

Big 👍 for this. Thanks @mvrhov!

@mvrhov
Copy link
Author

mvrhov commented Jan 5, 2013

BTW: I have no idea why the php 5.3.x seg'faults when running tests on Travis.

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'choices' => Locale::getDisplayCurrencies(\Locale::getDefault()),
Copy link
Contributor

Choose a reason for hiding this comment

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

It should probably be:

'choices' => Locale::getDisplayCurrencies(Locale::getDefault()),

(use Symfony's Locale consistently)

Copy link
Author

Choose a reason for hiding this comment

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

All other types: Country, Language, Locale, Date, Money.. also use the one from main ns.

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case I won't argue ;)

I still think we should use Symfony's Locale class. However, it should be used everywhere consistently (so if we're about to fix it, we should fix it in other types as well).

Copy link
Contributor

Choose a reason for hiding this comment

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

@jakzal It doesn't really matter which of the two you use. If you think it is better, you can create a PR that fixes appearances of \Locale::get|setDefault to Symfony's equivalent.

@mvrhov
Copy link
Author

mvrhov commented Jan 6, 2013

@fabpot: Any chances of having this in 2.2? I really need this in my next project and I would be a shame if I had to maintain a 2.2 fork just because of this feature

@francoispluchino
Copy link
Contributor

👍

/**
* Validates whether a value is a valid locale code
*
* @author Bernhard Schussek <bschussek@gmail.com>
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure?

Copy link
Author

Choose a reason for hiding this comment

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

Well the truth is that the file is almost identical to other locale based validators. So basically I'm the author of the few lines that are different.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's ok that you are the author.
To me the author is the one who had the idea/designed it conceptually or contributed large parts of the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mvrhov it's your decision :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Still you have edited the file, so you should at least add yourself as author (there can be more than one author).

@Baachi
Copy link
Contributor

Baachi commented Feb 1, 2013

Big 👍

use Symfony\Component\Locale\Locale;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class CurrencyType extends AbstractType
Copy link
Contributor

Choose a reason for hiding this comment

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

phpdoc missing

@webmozart
Copy link
Contributor

Looks good apart from a few minor issues!

*
* @throws \RuntimeException When the resource bundles cannot be loaded
*/
public static function getDisplayCurrencies($locale)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds strange. Why not getCurrencyNames?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see it's because \Locale also uses getDisplay....

@mvrhov
Copy link
Author

mvrhov commented Apr 18, 2013

This has been implemented as a part of #7386

@mvrhov mvrhov closed this Apr 18, 2013
@webmozart
Copy link
Contributor

@mvrhov FYI #7386 does not contain a Currency type or validator.

@mvrhov
Copy link
Author

mvrhov commented Apr 18, 2013

Ok, I'll reopen and rebase this later today.

@mvrhov mvrhov reopened this Apr 18, 2013
@mvrhov
Copy link
Author

mvrhov commented Apr 22, 2013

This is now rebased

use Symfony\Component\Intl\Intl;
use Symfony\Component\Locale\Locale;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing doc block

Copy link
Author

Choose a reason for hiding this comment

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

@bschussek All form types are without it. do you still want me to add it?

Copy link
Contributor

Choose a reason for hiding this comment

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

bad examples are still bad examples :)

@webmozart
Copy link
Contributor

Thank you @mvrhov! :) 👍

use Symfony\Component\Validator\Exception\UnexpectedTypeException;

/**
* Validates whether a value is a valid locale code
Copy link
Member

Choose a reason for hiding this comment

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

typo: locale -> currency

@mvrhov
Copy link
Author

mvrhov commented Apr 23, 2013

Please let me know before merging so I can cherry pick this on master and do a clean PR.
I'm afraid that even though I squashed the commits this PR will weigh a hefty 2,8M, due to currency resources data that are not needed anymore.

@webmozart
Copy link
Contributor

Looks good :) Not sure what you mean with your last comment, but do whatever you feel is necessary!

@fabpot
Copy link
Member

fabpot commented Apr 23, 2013

@mvrhov As you squashed your commits, I think there are no problems with the old data.

fabpot added a commit that referenced this pull request Apr 23, 2013
This PR was merged into the master branch.

Discussion
----------

[2.3] Added currency locale data, form type and validator

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT
Documentation PR: symfony/symfony-docs#2105

Commits
-------

5609aae Added currency form type and validator
@fabpot fabpot closed this Apr 23, 2013
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.

8 participants