Ошибка компиляции: не может объявить класс, потому что имя уже используетсяPhp

Кемеровские программисты php общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Ошибка компиляции: не может объявить класс, потому что имя уже используется

Сообщение Anonymous »

Я мигрирую на веб -сайте с Symfony 2.6 на 3.4, и у меня есть некоторые проблемы с регистрационными формами и Fosuserbundle. У меня появляется эта ошибка. Я проверил его код и увидел, что под его SRC \ Pix \ UserBundle \ Form \ RegistrationFormType.php, но есть еще одна папка «тип» с файлом с тем же именем: «RegistrationFormType.php» < /p>
Я пробовал изменить форму с новейшим стилем, взятым оттуда: оттуда: < /p>
Я пробовал изменить форму новейшим стилем: < /p>
https://github.com/symfony/symfony/blob ... .8.md#form
app/config/config.yml:
fos_user:
db_driver: orm
firewall_name: main
user_class: Pix\UserBundle\Entity\User
registration:
form:
type: Pix\UserBundle\Form\RegistrationFormType
validation_groups: [ pix_registration, Default ]

Файл службы в Pix/Userbundle/Resources/config/services.yml
services:
pix_userbundle_registrationformtype:
class: Pix\UserBundle\Form\Type\RegistrationFormType
arguments: ["%fos_user.model.user.class%"]
tags:
- { name: form.type }

pix/userbundle/form/registrationformtype.php:
namespace Pix\UserBundle\Form;

use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class RegistrationFormType extends AbstractType
{

public function __construct($class = "User")
{
parent::__construct($class);
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);

$builder
->add('username', 'text', array(
'label' => 'Pseudonyme',
))
->add('email', 'text', array(
'label' => 'Adresse mail',
))
->add('plainPassword', 'repeated', array(
'type' => 'password',
'first_options' => array('label' => 'Mot de passe'),
'second_options' => array('label' => 'Confirmation'),
'invalid_message' => 'Mot de passe incorrect',
))
->add('enabled', 'checkbox', array(
'label' => "Activé",
'required' => false
))

->add('firstname', 'text', array(
'label' => 'Prénom',
))
->add('lastname', 'text', array(
'label' => 'Nom',
))
->add('phone', 'text', array(
'label' => 'Téléphone',
))
->add('street', 'text', array(
'label' => "Adresse postale",
'required' => true
))
->add('number', 'text', array(
'label' => "Numéro d'adresse",
'required' => true
))
->add('npa', 'text', array(
'label' => "Code postal",
'required' => true
))
->add('city', 'text', array(
'label' => "Ville",
'required' => true
))
->add('state', 'text', array(
'label' => "Canton",
'required' => true
))
->add('country', 'text', array(
'label' => "Pays",
'required' => true
))
->add('latitude', 'text', array(
'label' => "Latitude",
'required' => true
))
->add('longitude', 'text', array(
'label' => "Longitude",
'required' => true
))
->add('code', 'text', array(
'label' => 'Code de parrainage',
'required' => false
))
->add('pro', 'choice', array(
'label' => "Professionel",
'choices' => array(
true => 'Oui',
false => 'Non',
),
'expanded' => false,
'multiple' => false,
'required' => true
))

->add('iban', 'text', array(
'label' => 'IBAN',
'required' => false
))
->add('distance', 'text', array(
'label' => "Rayon d'intervention",
'required' => false
))
->add('picture', new DocumentType(), array('required' => false))
->add('curriculum', new DocumentType(), array('required' => false))
->add('motivation', new DocumentType(), array('required' => false))
->add('document', new DocumentType(), array('required' => false))
;
}

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Pix\UserBundle\Entity\User'
));
}
public function getParent()
{
return BaseRegistrationFormType::class;
}
public function getBlockPrefix()
{
return 'pix_userbundle_registrationformtype';
}
}


и, наконец, pix/userbundle/form/type/registrationformtype.php:
namespace Pix\UserBundle\Form\Type;

use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use FOS\UserBundle\Form\Type\RegistrationFormType;
use Symfony\Component\Form\AbstractType;
use Pix\UserBundle\Form\DocumentType;
use Pix\UserBundle\Entity\AbilityRepository;
use Symfony\Component\Form\Extension\Core\Type\TextType;

class RegistrationFormType extends AbstractType
{

public function __construct($class = "User")
{
parent::__construct($class);
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder->remove('username');
$builder
->add('firstname', TexType::class, array(
'label' => 'Prénom',
))
->add('lastname', TexType::class, array(
'label' => 'Nom',
))
->add('phone', TexType::class, array(
'label' => 'Téléphone',
))
->add('street', 'hidden')
->add('number', 'hidden')
->add('npa', 'hidden')
->add('city', 'hidden')
->add('state', 'hidden')
->add('country', 'hidden')
->add('latitude', 'hidden')
->add('longitude', 'hidden')
->add('code', TexType::class, array(
'label' => 'Code de parrainage',
'required' => false
))
/*
->add('contact', 'choice', array(
'label' => 'Moyen de contact favorisé',
'choices' => array(
true => 'Par téléphone',
false => 'Par e-mail',
),
'expanded' => true,
'multiple' => false,
'required' => true
))
*/
->add('pro', 'choice', array(
'label' => false,
'choices' => array(
true => 'Oui',
false => 'Non',
),
'expanded' => false,
'multiple' => false,
'required' => true
))

->add('iban', TexType::class, array(
'label' => 'IBAN',
'required' => false
))
->add('distance', TexType::class, array(
'label' => "Rayon d'intervention",
'required' => false
))
->add('picture', new DocumentType(), array('required' => false))
->add('curriculum', new DocumentType(), array('required' => false))
->add('motivation', new DocumentType(), array('required' => false))
->add('document', new DocumentType(), array('required' => false))

->add('abilities', 'entity', array(
'label' => 'Domaines de compétence',
'attr' => array(
'class'=>'form-control multiselect'
),
'class' => 'PixUserBundle:Ability',
'property' => 'title',
'multiple' => true,
'expanded' => true,
'required' => false,
'query_builder' => function(AbilityRepository $er) {
return $er->getAbilities();
},
))
->add('condition', 'checkbox', array('label' => "J'ai lu et j'accepte les conditions générales."))
;
}

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Pix\UserBundle\Entity\User',
'intention' => 'registration'
));
}
public function getBlockPrefix()
{
return 'pix_userbundle_registrationformtype';
}
public function getParent()
{
return RegistrationFormType::class;
}
}



Подробнее здесь: https://stackoverflow.com/questions/554 ... ady-in-use
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Php»