示例#1
0
 public function saveUserUploadedPhoto(UploadedFile $file)
 {
     $extension = CommonFunction::getFileExtension($file->getClientOriginalName());
     $fileName = md5(microtime(true)) . '.' . $extension;
     $file->move($this->getUserPhotoDir(), $fileName);
     return $fileName;
 }
示例#2
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     /**
      * @var $attributes ProductAttribute[]
      */
     $data = $options['data'];
     $attributes = $data[C::FORM_ATTRIBUTE_LIST];
     foreach ($attributes as $attribute) {
         $formId = AbstractAttribute::FORM_PREFIX . $attribute->getId();
         switch ($attribute->getType()) {
             case ProductAttribute::ATTRIBUTE_TYPE_NUMBER:
                 $builder->add($formId, TextType::class, ['label' => $attribute->getName(), 'required' => false, 'attr' => ['class' => 'generated_number_type']]);
                 break;
             case ProductAttribute::ATTRIBUTE_TYPE_STRING:
                 $builder->add($formId, TextType::class, ['label' => $attribute->getName(), 'required' => false, 'attr' => ['class' => 'generated_string_type']]);
                 break;
                 break;
             case ProductAttribute::ATTRIBUTE_TYPE_BOOL:
                 $builder->add($formId, CheckboxType::class, ['label' => $attribute->getName(), 'required' => false]);
                 break;
             case ProductAttribute::ATTRIBUTE_TYPE_REFERENCE:
                 $reference = $attribute->getReference();
                 $builder->add($formId, ChoiceType::class, ['label' => $attribute->getName(), 'choices' => CommonFunction::entitiesToFormView($reference->getItems() ?: []), 'required' => false]);
                 break;
         }
     }
     $builder->add(C::FORM_SUBMIT, SubmitType::class, ['label' => 'Готово']);
 }
示例#3
0
 public function saveUploadedFile(UploadedFile $file = null)
 {
     $fileName = $file->getClientOriginalName();
     $fileExtension = CommonFunction::getFileExtension($fileName);
     $tmpFileName = md5($fileName . microtime(true)) . '.' . $fileExtension;
     $file->move($this->defaultModel->getUploadRootDir(), $tmpFileName);
     $this->createTemporaryUploadedImageThumb($tmpFileName);
     return $tmpFileName;
 }
示例#4
0
 public function authenticateByVk()
 {
     try {
         $vkToken = $this->session->get(C::PARAM_VK_TOKEN);
         $vkUserId = $this->session->get(C::PARAM_VK_USER_ID);
     } catch (\Exception $e) {
         throw new \Exception('vk session params not found');
     }
     if ($user = $this->userModel->getUserByVkAccountId($vkUserId)) {
         $this->forceAuthenticate($user);
         return true;
     }
     $userInfo = $this->vkApi->getUserInfo();
     $user = $this->createUser($userInfo['screen_name'], CommonFunction::generatePassword(12), $userInfo['screen_name']);
     $user->setVkAccountId($vkUserId);
     $this->em->flush();
     $this->forceAuthenticate($user);
     return true;
 }
示例#5
0
 public static function getFileExtension($fileName)
 {
     return CommonFunction::getDomainArea($fileName);
 }
示例#6
0
 public function plural($number, $e1, $e2, $e3, $returnNumber = true)
 {
     return CommonFunction::nplural((int) $number, $e1, $e2, $e3, $returnNumber);
 }