function let(ManagerRegistry $managerRegistry, TranslatableListener $translatableListener, ObjectManager $manager, ClassMetadata $translatableMetadata) { $managerRegistry->getManagerForClass(Argument::type('string'))->willReturn($manager); $translatableListener->getExtendedMetadata($manager, Argument::type('string'))->willReturn($translatableMetadata); $translatableListener->getLocale()->willReturn('en'); $this->beConstructedWith($managerRegistry, $translatableListener, new PropertyAccessor()); }
/** * @param \FSi\Component\DataGrid\Column\CellViewInterface $view * @param string $propertyPath * @return bool */ private function isPropertyPathTranslated(CellViewInterface $view, $propertyPath) { if (!($propertyPath = $this->validatePropertyPath($propertyPath))) { return false; } return $this->getObjectLocale($view, $propertyPath) !== $this->translatableListener->getLocale(); }
function it_should_return_map_in_current_locale(TranslatableListener $translatableListener) { $translatableListener->getLocale()->willReturn('en'); $map = $this->getMap(); $map['resource_group']['resource_block']['resource_a']->shouldHaveType('FSi\\Bundle\\ResourceRepositoryBundle\\Repository\\Resource\\Type\\TextType'); $map['resource_group']['resource_block']['resource_a']->getName()->shouldReturn('resource_group.resource_block.resource_a.en'); $map['resource_group']['resource_block']['resource_b']->shouldHaveType('FSi\\Bundle\\ResourceRepositoryBundle\\Repository\\Resource\\Type\\TextType'); $map['resource_group']['resource_block']['resource_b']->getName()->shouldReturn('resource_group.resource_block.resource_b'); }
/** * @return string */ private function getCurrentLocale() { return $this->translatableListener->getLocale() ?: $this->translatableListener->getDefaultLocale(); }
/** * @param FormInterface $form * @return bool */ public function isFormDataInCurrentLocale(FormInterface $form) { return $this->getFormNormDataLocale($form) === $this->translatableListener->getLocale(); }
function it_does_nothing_when_form_data_has_no_translatable_properties(ManagerRegistry $managerRegistry, ObjectManager $objectManager, TranslatableListener $translatableListener, FormEvent $event, FormInterface $form, FormConfigInterface $formConfig, ClassMetadata $translatableClassMetadata) { $translatableListener->getLocale()->willReturn('en'); $event->getForm()->willReturn($form); $form->getConfig()->willReturn($formConfig); $formConfig->getOption('data_class')->willReturn('TranslatableEntity'); $managerRegistry->getManagerForClass('TranslatableEntity')->willReturn($objectManager); $translatableListener->getExtendedMetadata($objectManager, 'TranslatableEntity')->willReturn($translatableClassMetadata); $translatableClassMetadata->hasTranslatableProperties()->willReturn(false); $event->getData()->shouldNotBeCalled(); $this->setTranslatableLocale($event); }