public function buildForm(FormBuilderInterface $builder, array $options) { switch ($this->type) { case self::TYPE_REGISTRATION: $currencyList = Reader::getCurrencyList(); $builder->add('email', 'email', ['label' => 'reader.email.label'])->add('password', 'repeated', ['first_name' => 'password', 'second_name' => 'confirm', 'type' => 'password', 'invalid_message' => 'reader.password.invalid_message', 'first_options' => ['label' => 'reader.password.label'], 'second_options' => ['label' => 'reader.password_repeated.label']])->add('preferredCurrency', 'choice', ['choices' => array_combine($currencyList, ["UAH", "USD", "RUB"]), 'expanded' => TRUE, 'multiple' => FALSE, 'data' => $currencyList[0], 'invalid_message' => "reader.preferred_currency.invalid_message", 'label' => 'reader.preferred_currency.label']); break; case self::TYPE_RESET: $builder->add('email', 'email', ['label' => 'reader.email.label']); break; } }
public function resetPassword(Reader $reader) { // cleanup expired reset requests $this->cleanupExpiredReset(); // set digest $resetDigest = hash('sha256', $reader->getId() . $reader->getEmail() . $reader->getPassword() . openssl_random_pseudo_bytes(64, $crypto_strong)); $reader->setResetDigest($resetDigest); $resetDigestDatetime = (new DateTime('now'))->add(new DateInterval('PT10M')); $reader->setResetDigestDatetime($resetDigestDatetime); $this->_manager->persist($reader); $this->_manager->flush(); return $reader; }
public function getItemsPrice(Reader $user) { $price = $this->getBook()->getPricePaper($user->getPreferredCurrency()); return bcmul($price, $this->getQuantity(), 2); }