コード例 #1
0
ファイル: ProfileType.php プロジェクト: Evrika/Vidal
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $cityToStringTransformer = new CityToStringTransformer($this->em);
     $yearToNumberTransformer = new YearToNumberTransformer($this->em);
     $years = array();
     for ($i = date('Y') + 6; $i > date('Y') - 70; $i--) {
         $years[$i] = $i;
     }
     $builder->add('avatar', 'iphp_file', array('label' => 'Аватар', 'required' => false))->add('lastName', null, array('label' => 'Фамилия', 'constraints' => array(new NotBlank(array('message' => 'Укажите свою фамилию')))))->add('firstName', null, array('label' => 'Имя', 'constraints' => array(new NotBlank(array('message' => 'Укажите свое имя')))))->add('surName', null, array('label' => 'Отчество', 'required' => false))->add('birthdate', 'date', array('label' => 'Дата рождения', 'years' => range(date('Y') - 111, date('Y')), 'format' => 'dd MMMM yyyy', 'constraints' => array(new NotBlank(array('message' => 'Укажите дату своего рождения')), new DateTime(array('message' => 'Дата рождения указана в неверно')))))->add('hideBirthdate', null, array('required' => false))->add($builder->create('city', 'text', array('label' => 'Город', 'required' => true, 'constraints' => array(new NotBlank(array('message' => 'Укажите свой город')))))->addModelTransformer($cityToStringTransformer))->add('phone', null, array('label' => 'Телефон', 'required' => false))->add('hidePhone', null, array('required' => false))->add('digestSubscribed', null, array('label' => 'Получать рассылку новостей портала VIDAL', 'required' => false))->add('submit1', 'submit', array('label' => 'Сохранить'))->add('university', null, array('label' => 'Выберите учебное заведение из списка', 'required' => false, 'empty_value' => 'выберите'))->add('school', null, array('label' => 'Или укажите другое'))->add($builder->create('graduateYear', 'choice', array('label' => 'Год окончания учебного заведения', 'choices' => $years, 'empty_value' => 'выберите', 'required' => false))->addModelTransformer($yearToNumberTransformer))->add('educationType', 'choice', array('label' => 'Форма обучения', 'required' => false, 'choices' => User::getEducationTypes(), 'empty_value' => 'выберите'))->add('primarySpecialty', 'entity', array('label' => 'Основная специальность', 'empty_value' => 'выберите', 'required' => true, 'constraints' => array(new NotBlank(array('message' => 'Укажите свою специальность'))), 'class' => 'VidalMainBundle:Specialty', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('s')->orderBy('s.title', 'ASC');
     }))->add('secondarySpecialty', 'entity', array('label' => 'Дополнительная специальность', 'empty_value' => 'выберите', 'required' => false, 'class' => 'VidalMainBundle:Specialty', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('s')->orderBy('s.title', 'ASC');
     }))->add('specialization', null, array('label' => 'Специализация', 'empty_value' => 'Не имеется', 'attr' => array('data-help' => 'если есть'), 'required' => false))->add('academicDegree', 'choice', array('label' => 'Ученая степень', 'choices' => User::getAcademicDegrees(), 'required' => false, 'empty_data' => 'Нет'))->add('dissertation', null, array('label' => 'Тема диссертации', 'required' => false))->add('professionalInterests', null, array('label' => 'Профессиональные интересы', 'required' => false))->add('submit2', 'submit', array('label' => 'Сохранить'))->add('jobPlace', null, array('label' => 'Место работы', 'required' => false))->add('jobSite', null, array('label' => 'Сайт', 'required' => false))->add('jobPosition', null, array('label' => 'Должность', 'required' => false))->add('jobStage', null, array('label' => 'Стаж работы по специальности', 'required' => false))->add('jobAchievements', null, array('label' => 'Достижения', 'required' => false))->add('about', null, array('label' => 'О себе', 'required' => false))->add('jobPublications', null, array('label' => 'Публикации', 'required' => false))->add('ConfirmationScan', 'iphp_file', array('label' => 'Скан действующего сертификата', 'required' => false))->add('submit3', 'submit', array('label' => 'Сохранить'));
 }
コード例 #2
0
ファイル: RegisterType.php プロジェクト: Evrika/Vidal
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $cityToStringTransformer = new CityToStringTransformer($this->em);
     $yearToNumberTransformer = new YearToNumberTransformer($this->em);
     $years = array();
     for ($i = date('Y') + 6; $i > date('Y') - 70; $i--) {
         $years[$i] = $i;
     }
     $builder->add('username', null, array('label' => 'E-mail'))->add('password', 'password', array('label' => 'Придумайте пароль', 'constraints' => array(new Regex(array('pattern' => '/[а-яА-Я]/', 'match' => false, 'message' => 'Русские буквы в пароле недопустимы')))))->add('lastName', null, array('label' => 'Фамилия', 'constraints' => array(new NotBlank(array('message' => 'Укажите свою фамилию')))))->add('firstName', null, array('label' => 'Имя', 'constraints' => array(new NotBlank(array('message' => 'Укажите свое имя')))))->add('surName', null, array('label' => 'Отчество', 'required' => false))->add('birthdate', 'date', array('label' => 'Дата рождения', 'years' => range(date('Y') - 111, date('Y')), 'data' => new \DateTime('1970-01-01'), 'format' => 'dd MMMM yyyy', 'constraints' => array(new NotBlank(array('message' => 'Укажите дату своего рождения')), new DateTime(array('message' => 'Дата рождения указана в неверно')))))->add($builder->create('city', 'text', array('label' => 'Город', 'required' => true, 'constraints' => array(new NotBlank(array('message' => 'Укажите свой город')))))->addModelTransformer($cityToStringTransformer))->add('university', null, array('label' => 'Выберите учебное заведение из списка', 'required' => false, 'empty_value' => 'выберите'))->add('school', null, array('label' => 'Или укажите другое'))->add($builder->create('graduateYear', 'choice', array('label' => 'Год окончания учебного заведения', 'choices' => $years, 'empty_value' => 'выберите', 'required' => false))->addModelTransformer($yearToNumberTransformer))->add('primarySpecialty', 'entity', array('label' => 'Основная специальность', 'empty_value' => 'выберите', 'required' => true, 'constraints' => array(new NotBlank(array('message' => 'Укажите свою специальность'))), 'class' => 'VidalMainBundle:Specialty', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('s')->orderBy('s.title', 'ASC');
     }))->add('secondarySpecialty', 'entity', array('label' => 'Дополнительная специальность', 'empty_value' => 'выберите', 'required' => false, 'class' => 'VidalMainBundle:Specialty', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('s')->orderBy('s.title', 'ASC');
     }))->add('academicDegree', 'choice', array('label' => 'Ученая степень', 'choices' => User::getAcademicDegrees(), 'required' => false, 'data' => 'Нет'))->add('captcha', 'captcha', array('label' => 'Проверочный код', 'mapped' => false, 'required' => true))->add('eula', 'checkbox', array('label' => 'Пользовательское соглашение', 'mapped' => false, 'required' => false, 'constraints' => new True(array('message' => 'Пожалуйста, подтвердите, что Вы согласны с пользовательским соглашением'))))->add('submit', 'submit', array('label' => 'Зарегистрироваться'));
 }
コード例 #3
0
ファイル: ParseUserCommand.php プロジェクト: Evrika/Vidal
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('--- vidal:parse_user started');
     $em = $this->getContainer()->get('doctrine')->getManager();
     $users = $this->findUsers();
     for ($i = 0; $i < count($users); $i++) {
         $user = $users[$i];
         $u = new User();
         $confirmed = $user['Confirmed'] == '0' ? false : true;
         $u->setPassword($user['Password']);
         $u->setEnabled($user['Checked']);
         $u->setCreated(new \DateTime($user['Created']));
         $u->setUpdated(new \DateTime($user['LastUpdated']));
         $u->setUsername($user['Email']);
         $u->setEmailConfirmed($confirmed);
         $u->setOldLogin($user['Login']);
         $u->setOldUser(true);
         $u->setFirstName($user['NameI']);
         $u->setLastName($user['NameF']);
         $u->setSurName($user['NameO']);
         $u->setOldCompany($user['Company']);
         if ($confirmed) {
             $u->setRoles('ROLE_DOCTOR');
         }
         $em->persist($u);
         $em->flush($u);
         if ($i && $i % 500 == 0) {
             $output->writeln("... +{$i}");
         }
     }
     $output->writeln('--- vidal:parse_user finished');
 }