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

Removed reliance on DiExtraBundle annotations. #411

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 12 additions & 3 deletions Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use JMS\TranslationBundle\Translation\Updater;
use Symfony\Component\HttpFoundation\Response;
use JMS\TranslationBundle\Util\FileUtils;
use JMS\DiExtraBundle\Annotation as DI;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -36,17 +35,27 @@
class ApiController
{
/**
* @DI\Inject("jms_translation.config_factory")
* @var ConfigFactory
*/
private $configFactory;

/**
* @DI\Inject("jms_translation.updater")
* @var Updater
*/
private $updater;

/**
* ApiController constructor.
*
* @param ConfigFactory $configFactory
* @param Updater $updater
*/
public function __construct(ConfigFactory $configFactory, Updater $updater)
{
$this->configFactory = $configFactory;
$this->updater = $updater;
}

/**
* @Route("/configs/{config}/domains/{domain}/locales/{locale}/messages",
* name="jms_translation_update_message",
Expand Down
25 changes: 20 additions & 5 deletions Controller/TranslateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
use JMS\TranslationBundle\Translation\ConfigFactory;
use JMS\TranslationBundle\Translation\LoaderManager;
use JMS\TranslationBundle\Util\FileUtils;
use JMS\DiExtraBundle\Annotation as DI;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Translation\MessageCatalogue;

/**
* Translate Controller.
Expand All @@ -36,23 +34,40 @@
class TranslateController
{
/**
* @DI\Inject("jms_translation.config_factory")
* @var ConfigFactory
*/
private $configFactory;

/**
* @DI\Inject("jms_translation.loader_manager")
* @var LoaderManager
*/
private $loader;

/**
* @DI\Inject("%jms_translation.source_language%")
* @var string
*/
private $sourceLanguage;

/**
* TranslateController constructor.
*
* @param ConfigFactory $configFactory
* @param LoaderManager $loader
*/
public function __construct(ConfigFactory $configFactory, LoaderManager $loader)
{
$this->configFactory = $configFactory;
$this->loader = $loader;
}

/**
* @param string $lang
*/
public function setSourceLanguage($lang)
{
$this->sourceLanguage = $lang;
}

/**
* @Route("/", name="jms_translation_index", options = {"i18n" = false})
* @Template
Expand Down
17 changes: 17 additions & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<parameters>
<parameter key="jms_translation.twig_extension.class">JMS\TranslationBundle\Twig\TranslationExtension</parameter>

<parameter key="jms_translation.controller.translate_controller.class">JMS\TranslationBundle\Controller\TranslateController</parameter>
<parameter key="jms_translation.controller.api_controller.class">JMS\TranslationBundle\Controller\ApiController</parameter>

<parameter key="jms_translation.extractor_manager.class">JMS\TranslationBundle\Translation\ExtractorManager</parameter>
<parameter key="jms_translation.extractor.file_extractor.class">JMS\TranslationBundle\Translation\Extractor\FileExtractor</parameter>
<parameter key="jms_translation.extractor.file.default_php_extractor">JMS\TranslationBundle\Translation\Extractor\File\DefaultPhpFileExtractor</parameter>
Expand Down Expand Up @@ -34,6 +37,20 @@
</parameters>

<services>
<!-- Controllers -->
<service id="jms_translation.controller.translate_controller" class="%jms_translation.controller.translate_controller.class%">
<argument id="jms_translation.config_factory" type="service"/>
<argument id="jms_translation.loader_manager" type="service"/>
<call method="setSourceLanguage">
<argument>%jms_translation.source_language%</argument>
</call>
</service>
<service id="jms_translation.controller.api_controller" class="%jms_translation.controller.api_controller.class%">
<argument id="jms_translation.config_factory" type="service"/>
<argument id="jms_translation.updater" type="service"/>
</service>


<service id="jms_translation.updater" class="%jms_translation.updater.class%">
<argument type="service" id="jms_translation.loader_manager" />
<argument type="service" id="jms_translation.extractor_manager" />
Expand Down
2 changes: 0 additions & 2 deletions Tests/Functional/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public function registerBundles()
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \JMS\TranslationBundle\JMSTranslationBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new \JMS\DiExtraBundle\JMSDiExtraBundle($this),
new \JMS\AopBundle\JMSAopBundle(),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace JMS\TranslationBundle\Tests\Functional\Fixture\TestBundle\Controller;

use JMS\DiExtraBundle\Annotation as DI;
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"symfony/symfony": "^2.3 || ^3.0",
"symfony/expression-language": "^2.6 || ^3.0",
"sensio/framework-extra-bundle": "^2.3 || ^3.0",
"jms/di-extra-bundle": "^1.1",
"nyholm/nsa": "^1.0.1",
"matthiasnoback/symfony-dependency-injection-test": "^0.7.6"
},
Expand Down