Last active
May 17, 2018 16:06
-
-
Save anyt/04c5ebd9576b58edf17f9ef0ab5591e1 to your computer and use it in GitHub Desktop.
Translate Task Priority field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle; | |
use Symfony\Component\HttpKernel\Bundle\Bundle; | |
class AppBundle extends Bundle | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\DependencyInjection; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
use Symfony\Component\Config\FileLocator; | |
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | |
use Symfony\Component\DependencyInjection\Loader; | |
class AppExtension extends Extension | |
{ | |
const ALIAS = 'app'; | |
/** | |
* {@inheritDoc} | |
*/ | |
public function load(array $configs, ContainerBuilder $container) | |
{ | |
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | |
$loader->load('services.yml'); | |
} | |
/** | |
* {@inheritDoc} | |
*/ | |
public function getAlias() | |
{ | |
return self::ALIAS; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundles: | |
- { name: AppBundle\AppBundle, priority: 1000 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Normal: New Normal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
task_type.form_type_extension: | |
class: AppBundle\Form\Extension\TaskTypeTypeExtension | |
tags: | |
- { name: form.type_extension, extended_type: Oro\Bundle\TaskBundle\Form\Type\TaskType } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Form\Extension | |
namespace AppBundle\Form\Extension; | |
use Oro\Bundle\FormBundle\Utils\FormUtils; | |
use Oro\Bundle\TaskBundle\Form\Type\TaskType; | |
use Symfony\Component\Form\AbstractTypeExtension; | |
use Symfony\Component\Form\FormBuilderInterface; | |
use Symfony\Component\Form\FormEvent; | |
use Symfony\Component\Form\FormEvents; | |
class TaskTypeTypeExtension extends AbstractTypeExtension | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
$builder->addEventListener( | |
FormEvents::PRE_SET_DATA, | |
function (FormEvent $event) { | |
$form = $event->getForm(); | |
FormUtils::replaceField($form, 'taskPriority', ['translatable_options'=> true]); | |
} | |
); | |
} | |
public function getExtendedType() | |
{ | |
return TaskType::class; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment