Example #1
0
 /**
  * RENDER ******************************************************************
  */
 public function render()
 {
     $this->template->categories = $this->tagRepository->findWithHighPriority();
     $this->template->tags = $this->tagRepository->findWithLowPriority();
     $this->template->setFile(__DIR__ . '/templates/menu.latte');
     $this->template->render();
 }
Example #2
0
 /**
  * @return Form
  */
 protected function createComponentForm()
 {
     $form = new Form();
     $form->addText('addon', 'Addon URL')->addRule($form::REQUIRED, 'URL is required')->addRule($form::URL, 'URL is not valid')->addRule($form::PATTERN, 'Only GitHub urls are allowed', self::GITHUB_REGEX);
     $tags = $this->tagRepository->fetchPairs();
     $form->addMultiSelect('tags', 'Tags', $tags);
     $form->addSubmit('add', 'Add addon');
     $form->onSuccess[] = function (Form $form) {
         $matches = Strings::match($form->values->addon, '#' . self::GITHUB_REGEX . '#');
         if (!$matches) {
             $this->presenter->flashMessage('Invalid addon name.', 'warning');
             $this->presenter->redirect('this');
             return;
         }
         list($all, $owner, $name) = $matches;
         $addon = new Addon();
         $this->addonRepository->attach($addon);
         $addon->state = Addon::STATE_QUEUED;
         $addon->createdAt = new DateTime();
         $addon->owner = $owner;
         $addon->name = $name;
         $addon->github = new Github();
         if ($form->values->tags) {
             $addon->tags->add($form->values->tags);
         }
         try {
             $this->addonRepository->persistAndFlush($addon);
             $this->presenter->flashMessage('Addon successful added to the cron process queue. Thank you.', 'info');
         } catch (UniqueConstraintViolationException $e) {
             $this->presenter->flashMessage('There is already addon "' . ($owner . '/' . $name) . '" in our database.', 'warning');
         } catch (PDOException $e) {
             $this->presenter->flashMessage('Database error has occurred.', 'danger');
         }
         $this->presenter->redirect('this');
     };
     return $form;
 }
Example #3
0
 /**
  * @return int
  */
 public function countTags()
 {
     return $this->tagRepository->findAll()->countStored();
 }