本文整理汇总了PHP中Symfony\Component\Form\FormInterface::getPropertyPath方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::getPropertyPath方法的具体用法?PHP FormInterface::getPropertyPath怎么用?PHP FormInterface::getPropertyPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::getPropertyPath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function it_does_nothing_if_form_has_no_translatable_parent(FormView $view, FormInterface $form, FormConfigInterface $formConfig, FormInterface $parentForm, FormConfigInterface $parentFormConfig)
{
$form->getPropertyPath()->willReturn('translatable_property');
$form->getConfig()->willReturn($formConfig);
$form->getParent()->willReturn($parentForm);
$parentForm->getConfig()->willReturn($parentFormConfig);
$parentFormConfig->getInheritData()->willReturn(true);
$parentForm->getParent()->willReturn(null);
$this->finishView($view, $form, array());
}
开发者ID:szymach,项目名称:admin-translatable-bundle,代码行数:10,代码来源:TranslatableFSiRemovableFileExtensionSpec.php
示例2: isFormPropertyPathTranslatable
/**
* @param FormInterface $form
* @return bool
*/
public function isFormPropertyPathTranslatable(FormInterface $form)
{
$propertyPath = $form->getPropertyPath();
if (!$propertyPath) {
return false;
}
$parent = $this->getFirstTranslatableParent($form);
if (!$parent) {
return false;
}
if (!$this->hasFormTranslatableProperty($parent, $propertyPath)) {
return false;
}
return true;
}
示例3: array
function it_does_nothing_if_forms_property_is_not_translatable_in_first_translatable_parent(ManagerRegistry $managerRegistry, ObjectManager $manager, TranslatableListener $translatableListener, ClassMetadata $translatableMetadata, PropertyPath $propertyPath, FormView $view, FormInterface $form, FormConfigInterface $formConfig, FormInterface $parentForm, FormConfigInterface $parentFormConfig, FormInterface $grandParentForm, FormConfigInterface $grandParentFormConfig)
{
$propertyPath->__toString()->willReturn('translatable_property');
$form->getPropertyPath()->willReturn($propertyPath);
$form->getConfig()->willReturn($formConfig);
$form->getParent()->willReturn($parentForm);
$parentForm->getConfig()->willReturn($parentFormConfig);
$parentFormConfig->getInheritData()->willReturn(true);
$parentForm->getParent()->willReturn($grandParentForm);
$grandParentForm->getConfig()->willReturn($grandParentFormConfig);
$grandParentFormConfig->getInheritData()->willReturn(false);
$grandParentFormConfig->getDataClass()->willReturn('translatable_class');
$managerRegistry->getManagerForClass('translatable_class')->willReturn($manager);
$translatableListener->getExtendedMetadata($manager, 'translatable_class')->willReturn($translatableMetadata);
$translatableMetadata->hasTranslatableProperties()->willReturn(true);
$translatableMetadata->getTranslatableProperties()->willReturn(array());
$this->finishView($view, $form, array());
expect($view->vars['translatable'])->toBe(false);
expect($view->vars['not_translated'])->toBe(false);
}
示例4: buildView
/**
* Pass the image URL to the view
*
* @param FormView $view
* @param FormInterface $form
* @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['translation'] = isset($options['translation']) && $options['translation'] === true;
$view->vars['currentLocale'] = $this->defaultLocale;
if ($view->vars['translation']) {
$parent = $form->getParent();
if ($parent instanceof Form) {
$property = new Property($form->getPropertyPath());
$entity = $parent->getConfig()->getDataClass();
if (is_object($parent->getData())) {
$entity = $parent->getData();
}
$translations = $this->translator->getTranslations($entity, $property);
if ($translations === null) {
$view->vars['translation'] = false;
return;
}
$view->vars['translations'] = $translations;
}
}
}
示例5: let
function let(ManagerRegistry $managerRegistry, TranslatableListener $translatableListener, PropertyAccessor $propertyAccessor, ObjectManager $manager, ClassMetadata $translatableMetadata, PropertyPath $propertyPath, FormView $view, FormInterface $form, FormConfigInterface $formConfig, FormInterface $parentForm, FormConfigInterface $parentFormConfig, FormInterface $grandParentForm, FormConfigInterface $grandParentFormConfig)
{
$this->beConstructedWith($managerRegistry, $translatableListener, $propertyAccessor);
$propertyPath->__toString()->willReturn('translatable_property');
$form->getPropertyPath()->willReturn($propertyPath);
$form->getConfig()->willReturn($formConfig);
$form->getParent()->willReturn($parentForm);
$parentForm->getConfig()->willReturn($parentFormConfig);
$parentFormConfig->getInheritData()->willReturn(true);
$parentForm->getParent()->willReturn($grandParentForm);
$data = new \stdClass();
$grandParentForm->getNormData()->willReturn($data);
$propertyAccessor->getValue($data, 'locale')->willReturn('en');
$grandParentForm->getConfig()->willReturn($grandParentFormConfig);
$grandParentFormConfig->getInheritData()->willReturn(false);
$grandParentFormConfig->getDataClass()->willReturn('translatable_class');
$managerRegistry->getManagerForClass('translatable_class')->willReturn($manager);
$translatableListener->getExtendedMetadata($manager, 'translatable_class')->willReturn($translatableMetadata);
$translatableListener->getLocale()->willReturn('de');
$translatableMetadata->localeProperty = 'locale';
$translatableMetadata->hasTranslatableProperties()->willReturn(true);
}
示例6: isDataEmptyValue
/**
* @param mixed $targetEntity
* @param FormInterface $form
* @return bool
*/
protected function isDataEmptyValue($targetEntity, FormInterface $form)
{
$formConfig = $form->getConfig();
// Check to see if there's a value provided by the form.
$accessor = PropertyAccess::createPropertyAccessor();
try {
$value = $accessor->getValue($targetEntity, $form->getPropertyPath());
if ($formConfig->getOption('multiple')) {
$result = $value instanceof Collection && $value->isEmpty();
} else {
$result = null === $value;
}
} catch (NoSuchPropertyException $exception) {
// If value cannot be get then treat it as value as empty and we need to suppress this exception.
$result = false;
}
return $result;
}
示例7: resolveDataClass
/**
* Gets the form root data class used by the given form.
*
* @param FormInterface $form
* @return string|null
*/
private function resolveDataClass(FormInterface $form)
{
// Nothing to do if root
if ($form->isRoot()) {
return $form->getConfig()->getDataClass();
}
$propertyPath = $form->getPropertyPath();
/** @var FormInterface $dataForm */
$dataForm = $form;
// If we have a index then we need to use it's parent
if ($propertyPath->getLength() === 1 && $propertyPath->isIndex(0) && $form->getConfig()->getCompound()) {
return $this->resolveDataClass($form->getParent());
}
// Now locate the closest data class
// TODO what is the length really for?
for ($i = $propertyPath->getLength(); $i != 0; $i--) {
$dataForm = $dataForm->getParent();
# When a data class is found then use that form
# This happend when property_path contains multiple parts aka `entity.prop`
if ($dataForm->getConfig()->getDataClass() !== null) {
break;
}
}
// If the root inherits data, then grab the parent
if ($dataForm->getConfig()->getInheritData()) {
$dataForm = $dataForm->getParent();
}
return $dataForm->getConfig()->getDataClass();
}