/**
  * @return Form
  */
 public function create()
 {
     $form = $this->factory->create();
     $form->addText('genre', 'Název žánru: ')->setRequired('Musíte vyplnit název žánru')->addRule(Form::IS_NOT_IN, 'Tento žánr již existuje', $this->genresManager->getAllGenreNames())->getControlPrototype()->addAttributes(['tabindex' => 1, 'accesskey' => 'i']);
     $form->addSubmit('send', 'Vytvořit nový žánr')->getControlPrototype()->addAttributes(['tabindex' => 2, 'accesskey' => 's']);
     return $form;
 }
 /**
  * @param string $defaultGenre
  * @return Form
  */
 public function create(string $defaultGenre = null)
 {
     $form = $this->factory->create();
     $maxSize = SizeParser::parse_size(ini_get("upload_max_filesize"));
     $form->addUpload('song', 'Nová skladba: ', true)->addRule(Form::MAX_FILE_SIZE, 'Nemůžete nahrát vetší soubor než ' . Filters::bytes($maxSize) . '(nastaveno v php.ini)', $maxSize)->getControlPrototype()->addAttributes(['class' => 'file', 'tabindex' => 1, 'accesskey' => 'i']);
     $genres = $this->genresManager->getAllGenreIdsAndNames();
     $form->addSelect('genre', 'Žánr: ', $genres)->setPrompt('-')->setDefaultValue($defaultGenre)->getControlPrototype()->addAttributes(['tabindex' => 2, 'accesskey' => 'g']);
     $form->addSubmit('send', 'Nahrát skladbu')->getControlPrototype()->addAttributes(['tabindex' => 3, 'accesskey' => 's']);
     $form->onValidate[] = $this->validateSongsMetadata;
     return $form;
 }
 public function createComponentOrderForm()
 {
     $form = new Form();
     $radioList = [];
     foreach ($this->genresManager->getAllNonEmptyGenres() as $genre) {
         $radioList[$genre->getId()] = $genre->getName();
     }
     $form->addRadioList('genre', '', $radioList);
     $form->addSubmit('order', 'Objednat');
     $form->onSuccess[] = $this->orderGenre;
     return $form;
 }
 public function orderGenre(string $genreId, float $price, Address $address)
 {
     $songEntities = [];
     //genre order is order of random song from given genre and setting of given genre as genre to be played when queue is empty
     //current genre is saved as genreId in file, because it is simple and fast
     $genre = $this->genresManager->getGenre($genreId);
     $order = new Order($price, $address, $genre);
     $this->entityManager->persist($order);
     $songEntities[] = $order;
     $song = $this->songsManager->getRandomSong($genre);
     $songEntities[] = $this->orderSong($song, $order);
     $this->entityManager->flush($songEntities);
 }
 public function addGenre(Form $form, array $values)
 {
     $this->genresManager->addGenre($values['genre']);
     $this->flashMessage('Žánr byl úspěšně přidán.', 'success');
     $this->redirect('this');
 }
 public function renderDefault()
 {
     $this->template->genres = $this->genresManager->countAllGenres();
     $this->template->songs = $this->songsManager->countAllSongs();
     //		$this->songsManager->hashSongs();
 }
 public function actionDefault()
 {
     $this->genres = $this->genresManager->getAllNonEmptyGenres();
 }
 public function renderDefault(string $genre = null)
 {
     $this->template->songs = $this->songsManager->getSongsByGenreId($genre);
     $this->template->currentGenre = $genre;
     $this->template->genres = $this->genresManager->getAllGenres();
 }