8000 [Translation] added LoggingTranslator. by aitboudad · Pull Request #10887 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Translation] added LoggingTranslator. #10887

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

Closed
wants to merge 10 commits into from
Closed
Prev Previous commit
Next Next commit
added TranslatorBagInterface.
  • Loading branch information
aitboudad committed Sep 24, 2014
commit 071880b2a31270508d1d63dff256600d24b04f32
1 change: 1 addition & 0 deletions src/Symfony/Component/Translation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
-----

* added possibility to cache catalogues
* added TranslatorBagInterface
* added LoggableTranslator
Copy link
Member

Choose a reason for hiding this comment

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

It's going to be for 2.6.


2.5.0
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/Translation/LoggableTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class LoggableTranslator implements TranslatorInterface
*/
private $logger;

/**
* @param Translator $translator The translator
* @param LoggerInterface $logger A logger instance
*/
public function __construct(Translator $translator, LoggerInterface $logger)
public function __construct($translator, LoggerInterface $logger)
Copy link
Contributor

Choose a reason for hiding this comment

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

missing phpdoc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Tobion $translator must implements TranslatorInterface and TranslatorBagInterface and I don't find the standard way to document it ?

/**
 * @param TranslatorInterface|TranslatorBagInterface $translator
 */

Copy link
Member

Choose a reason for hiding this comment

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

looks good to me

{
if (!($translator instanceof TranslatorInterface && $translator instanceof TranslatorBagInterface)) {
throw new \InvalidArgumentException(sprintf('The Translator "%s" must implements TranslatorInterface and TranslatorBagInterface.', get_class($translator)));
}

$this->translator = $translator;
$this->logger = $logger;
}
Expand Down
8 changes: 2 additions & 6 deletions src/Symfony/Component/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @api
*/
class Translator implements TranslatorInterface
class Translator implements TranslatorInterface, TranslatorBagInterface
{
/**
* @var MessageCatalogueInterface[]
Expand Down Expand Up @@ -257,11 +257,7 @@ public function transChoice($id, $number, array $parameters = array(), $domain =
}

/**
* Gets the catalogue by locale.
*
* @param string|null $locale The locale or null to use the default
*
* @return MessageCatalogueInterface
* {@inheritdoc}
*/
public function getCatalogue($locale = null)
{
Expand Down
29 changes: 29 additions & 0 deletions src/Symfony/Component/Translation/TranslatorBagInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Translation;

/**
* TranslatorBagInterface
*
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
*/
interface TranslatorBagInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this interface. There was also none added for #9859

Copy link
Member

Choose a reason for hiding this comment

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

agreed

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
Contributor

Choose a reason for hiding this comment

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

then just typehint in the constructor the concrete implmentation instead of the interface. until we can add these methods in the interface in 3.0

{
/**
* Gets the catalogue by locale.
*
* @param string|null $locale The locale or null to use the default
*
* @return MessageCatalogueInterface
*/
public function getCatalogue($locale = null);
}
0