public function saveUserUploadedPhoto(UploadedFile $file) { $extension = CommonFunction::getFileExtension($file->getClientOriginalName()); $fileName = md5(microtime(true)) . '.' . $extension; $file->move($this->getUserPhotoDir(), $fileName); return $fileName; }
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' => 'Готово']); }
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; }
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; }
public static function getFileExtension($fileName) { return CommonFunction::getDomainArea($fileName); }
public function plural($number, $e1, $e2, $e3, $returnNumber = true) { return CommonFunction::nplural((int) $number, $e1, $e2, $e3, $returnNumber); }