Skip to content

Commit

Permalink
Merge pull request #464 from tommygnr/DiExtraBundle-removal-tommygnr
Browse files Browse the repository at this point in the history
Remove dependency on JMSDiExtraBundle
  • Loading branch information
schmittjoh authored Jan 31, 2018
2 parents 990a177 + ee9a841 commit ede571a
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 17 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

### 1.3.2 to UNRELEASED
* Remove dependencies on JMSDiExtraBundle and JMSAopBundle. If you do not use these bundles elsewhere in your application you will need to remove the reference to them in `registerBundles` of your `AppKernel`

### 1.3.1 to 1.3.2
* Added configuration options to disable date/sources in xliff dump
Expand Down
17 changes: 13 additions & 4 deletions Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,39 @@
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;

/**
* @Route("/api")
* @Route("/api", service="jms_translation.controller.api_controller")
*
* @author Johannes M. Schmitt <[email protected]>
*/
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
26 changes: 21 additions & 5 deletions Controller/TranslateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,53 @@
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.
*
* @Route(service="jms_translation.controller.translate_controller")
* @author Johannes M. Schmitt <[email protected]>
*/
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 type="service" id="jms_translation.config_factory"/>
<argument type="service" id="jms_translation.loader_manager"/>
<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
3 changes: 0 additions & 3 deletions Resources/doc/webinterface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ that you need to have the SensioFrameworkExtraBundle_ installed)::
type: annotation
prefix: /_trans

This bundle also requires the JMSDiExtraBundle_ for annotation-based
dependency injection for controllers.

Usage
-----
If you have followed the instructions above, you can now access the interface
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 @@ -26,7 +26,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

0 comments on commit ede571a

Please sign in to comment.