worldia / textmaster-bundle
A Symfony2 bundle integrating textmaster-api
Installs: 15 896
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 10
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.0
- doctrine/doctrine-bundle: ^1.5
- doctrine/orm: ^2.5
- symfony/form: ^3.2|^4.0
- symfony/framework-bundle: ^3.2|^4.0
- symfony/property-access: ^3.2|^4.0
- symfony/security-csrf: ^3.2|^4.0
- symfony/validator: ^3.2|^4.0
- worldia/textmaster-api: ^1.0
Requires (Dev)
- behat/symfony2-extension: 2.1.*
- matthiasnoback/symfony-config-test: ^3.0
- matthiasnoback/symfony-dependency-injection-test: ^2.0
- phpunit/phpunit: ^6.0
- symfony/asset: ^3.2|^4.0
- symfony/browser-kit: ^3.2|^4.0
- symfony/templating: ^3.2|^4.0
- symfony/twig-bundle: ^3.2|^4.0
- white-october/pagerfanta-bundle: ^1.0
Suggests
- white-october/pagerfanta-bundle: Needed to display pager on list template if you add routing.
README
A Symfony2 bundle integrating textmaster-api.
Installation
Step 1: Download TextmasterBundle using composer
Require the bundle with composer:
$ composer require worldia/textmaster-bundle
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Worldia\Bundle\TextmasterBundle\WorldiaTextmasterBundle(), // ... ); }
Step 3: Configure the bundle
// in app/config/config.yml worldia_textmaster: credentials: api_key: your_api_key api_secret: your_api_secret
Step 4: Add route
The translation manager is using the callback routes.
// in app/config/routing.yml worldia_textmaster_callback: resource: @WorldiaTextmasterBundle/Resources/config/routing/callback.yml
Additional installation
Configuration
By default, the translator provider used is the ArrayBasedMappingProvider. You can easily configure it as followed:
// in app/config/config.yml worldia_textmaster: mapping_properties: AppBundle\Entity\FirstEntity: ['property1', 'property2', 'property3', ...] AppBundle\Entity\SecondEntity: ['propertyA', 'propertyB', 'propertyC', ...] ...
There is a template provided for each route. You can override it easily with configuration:
// in app/config/config.yml worldia_textmaster: templates: project: show: 'MyTemplate:Project:show.html.twig' list: 'MyTemplate:Project:list.html.twig'
Route
You can optionally add object routing files.
If you do you will need white-october/pagerfanta-bundle to display pager on list page.
// in app/config/routing.yml worldia_textmaster_project: resource: @WorldiaTextmasterBundle/Resources/config/routing/project.yml worldia_textmaster_document: resource: @WorldiaTextmasterBundle/Resources/config/routing/document.yml worldia_textmaster_job: resource: @WorldiaTextmasterBundle/Resources/config/routing/job.yml
Usage example
Create a project with documents:
<?php // src/AppBundle/MyService/MyService.php namespace AppBundle\MyService; use Worldia\Bundle\TextmasterBundle\Translation\TranslationManager; class MyService { /** * @var TranslationManager */ protected $translationManager; public function createProject() { // retrieve all entities to translate in array $translatable. $project = $this->translationManager->create( $translatable, 'Project name', 'en', 'fr', 'CO21', 'My poject briefing', array('language_level' => 'premium') ); // the project is sent to TextMaster and launched. } }
API callback
The bundle provide a controller with a route to catch API callback.
This will call textmaster-api Handler to raise en event corresponding to the right object depending on its status.
Then a listener (DocumentListener or ProjectListener) will catch this event and act accordingly.
For example, an event for 'textmaster.document.in_review' will get the job related to the document and finish it.