/** * @param $type * * @return \PServerCore\Entity\PageInfo|null */ public function getPage4Type($type) { $cachingKey = Caching::PAGE_INFO . '_' . $type; $pageInfo = $this->cachingHelperService->getItem($cachingKey, function () use($type) { /** @var \PServerCore\Entity\Repository\PageInfo $repository */ $repository = $this->entityManager->getRepository($this->collectionOptions->getEntityOptions()->getPageInfo()); return $repository->getPageData4Type($type); }); return $pageInfo; }
/** * @param UserInterface $user */ public function addSecretQuestion(UserInterface $user) { if (!$this->collectionOptions->getPasswordOptions()->isSecretQuestion()) { return; } $this->setUser($user); /** @var \PServerCore\Entity\Repository\SecretAnswer $repositorySecretAnswer */ $repositorySecretAnswer = $this->entityManager->getRepository($this->collectionOptions->getEntityOptions()->getSecretAnswer()); $answer = $repositorySecretAnswer->getAnswer4UserId($this->getUser()->getId()); if (!$answer) { return; } $this->add(['name' => 'question', 'options' => ['label' => 'SecretQuestion'], 'attributes' => ['placeholder' => 'Question', 'class' => 'form-control', 'type' => 'text', 'disabled' => 'true', 'value' => $answer->getQuestion()->getQuestion(), 'required' => true]]); $this->add(['name' => 'answer', 'options' => ['label' => 'SecretAnswer'], 'attributes' => ['placeholder' => 'Answer', 'class' => 'form-control', 'type' => 'text', 'required' => true]]); }
/** * @return ObjectRepository|\PServerCore\Entity\Repository\UserCodes */ protected function getRepositoryManager() { if (!$this->repositoryManager) { $this->repositoryManager = $this->entityManager->getRepository($this->collectionOptions->getEntityOptions()->getUserCodes()); } return $this->repositoryManager; }
/** * output the player online image */ public function outputCurrentPlayerImage() { $playerNumber = $this->getCurrentPlayer(); $image = imagecreate(250, 50); //set the background color of the image $color = $this->collectionOptions->getGeneralOptions()->getImagePlayer()['background_color']; imagecolorallocate($image, $color[0], $color[1], $color[2]); //set the color for the text $color = $this->collectionOptions->getGeneralOptions()->getImagePlayer()['font_color']; $fontColor = imagecolorallocate($image, $color[0], $color[1], $color[2]); //adf the string to the image $maxPlayer = $this->collectionOptions->getGeneralOptions()->getMaxPlayer(); if ($maxPlayer > 0) { $text = sprintf('%s/%s Player Online', $playerNumber, $maxPlayer); } else { $text = sprintf('%s Player Online', $playerNumber); } $this->imageCenterString($image, 5, $text, $fontColor); imagepng($image); imagedestroy($image); }
/** * Register constructor. * @param EntityManager $entityManager * @param AdapterInterface $sanCaptcha * @param Collection $collection */ public function __construct(EntityManager $entityManager, AdapterInterface $sanCaptcha, Collection $collection) { parent::__construct(); $this->entityManager = $entityManager; $this->sanCaptcha = $sanCaptcha; $this->collection = $collection; $this->add(['type' => Form\Element\Csrf::class, 'name' => 'eugzhoe45gh3o49ug2wrtu7gz50']); $this->add(['name' => 'username', 'options' => ['label' => 'Username'], 'attributes' => ['placeholder' => 'Username', 'class' => 'form-control', 'type' => 'text', 'required' => true]]); $this->add(['name' => 'email', 'options' => ['label' => 'Email'], 'attributes' => ['placeholder' => 'Email', 'class' => 'form-control', 'type' => 'email', 'required' => true]]); $this->add(['name' => 'emailVerify', 'options' => ['label' => 'Email Verify'], 'attributes' => ['placeholder' => 'Email Verify', 'class' => 'form-control', 'type' => 'email', 'required' => true]]); $this->add(['name' => 'password', 'options' => ['label' => 'Password'], 'attributes' => ['placeholder' => 'Password', 'class' => 'form-control', 'type' => 'password', 'required' => true]]); $this->add(['name' => 'passwordVerify', 'options' => ['label' => 'Password Verify'], 'attributes' => ['placeholder' => 'Password Verify', 'class' => 'form-control', 'type' => 'password', 'required' => true]]); if ($this->collection->getConfig()['password']['secret_question']) { $entityOptions = $this->collection->getEntityOptions(); $this->add(['name' => 'question', 'type' => 'DoctrineModule\\Form\\Element\\ObjectSelect', 'options' => ['object_manager' => $this->entityManager, 'target_class' => $entityOptions->getSecretQuestion(), 'property' => 'question', 'label' => 'SecretQuestion', 'empty_option' => '-- select --', 'is_method' => true, 'find_method' => ['name' => 'getQuestions']], 'attributes' => ['class' => 'form-control', 'required' => true]]); $this->add(['name' => 'answer', 'options' => ['label' => 'SecretAnswer'], 'attributes' => ['placeholder' => 'Answer', 'class' => 'form-control', 'type' => 'text', 'required' => true]]); } $captcha = new Form\Element\Captcha('captcha'); $captcha->setCaptcha($this->sanCaptcha)->setOptions(['label' => 'Please verify you are human.'])->setAttributes(['class' => 'form-control', 'type' => 'text', 'required' => true]); $this->add($captcha, ['priority' => -90]); $submitElement = new Form\Element\Button('submit'); $submitElement->setLabel('Register')->setAttributes(['class' => 'btn btn-default', 'type' => 'submit']); $this->add($submitElement, ['priority' => -100]); }
/** * @return null|\PServerCore\Entity\Repository\SecretAnswer */ protected function getEntityManagerAnswer() { return $this->entityManager->getRepository($this->collectionOptions->getEntityOptions()->getSecretAnswer()); }
/** * @return Validator\UserNameBackendNotExists */ public function getUserNameBackendNotExistsValidator() { return new Validator\UserNameBackendNotExists($this->gameBackendService, $this->collection->getEntityOptions()); }
/** * @param $key * * @return string */ public function getSubject4Key($key) { $subjectList = $this->collectionOptions->getMailOptions()->getSubject(); // added fallback if the key not exists, in the config return isset($subjectList[$key]) ? $subjectList[$key] : $key; }
/** * @return \Doctrine\ORM\QueryBuilder */ public function getNewsQueryBuilder() { /** @var \PServerCore\Entity\Repository\News $repository */ $repository = $this->entityManager->getRepository($this->collectionOptions->getEntityOptions()->getNews()); return $repository->getQueryBuilder(); }
/** * @param $userId * * @return null|\PServerCore\Entity\UserInterface */ protected function getUser4Id($userId) { /** @var \PServerCore\Entity\Repository\User $userRepository */ $userRepository = $this->entityManager->getRepository($this->collectionOptions->getEntityOptions()->getUser()); return $userRepository->getUser4Id($userId); }
/** * @param ContainerInterface $container * @param string $requestedName * @param array|null $options * @return Collection */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $collection = new Collection(); $collection->setEntityOptions($container->get(EntityOptions::class)); $collection->setGeneralOptions($container->get(GeneralOptions::class)); $collection->setLoginOptions($container->get(LoginOptions::class)); $collection->setMailOptions($container->get(MailOptions::class)); $collection->setPasswordOptions($container->get(PasswordOptions::class)); $collection->setRegisterOptions($container->get(RegisterOptions::class)); $collection->setUserCodesOptions($container->get(UserCodeOptions::class)); $collection->setValidationOptions($container->get(ValidationOptions::class)); $collection->setConfig($container->get('config')['pserver']); return $collection; }
/** * @return AbstractRecord */ public function getEmailValidator() { /** @var $repositoryUser \Doctrine\Common\Persistence\ObjectRepository */ $repositoryUser = $this->entityManager->getRepository($this->collectionOptions->getEntityOptions()->getUser()); return new Validator\NoRecordExists($repositoryUser, 'email'); }