public function createComponentOrderForm() { $form = new Form(); foreach ($this->songsManager->getSongAlphaNumericIds() as $song) { $form->addCheckbox($song); } $form->addSubmit('order', 'Objednat'); $form->onValidate[] = $this->atLeastOneSongSelected; $form->onSuccess[] = $this->orderSongs; 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 addSong(Form $form, array $values) { /** @var FileUpload $songFile */ $songFiles = $values['song']; $genreId = $values['genre']; $onlyOneSong = count($songFiles) == 1; $uploadOk = true; $alreadyExists = false; foreach ($songFiles as $songFile) { if ($songFile->isOk()) { $alreadyExists = $alreadyExists || $this->songsManager->addSongFromHTTP($songFile, $genreId); } else { $uploadOk = false; } } if ($uploadOk && !$alreadyExists) { if ($onlyOneSong) { $this->flashMessage('Skladba byla úspěšně přidána.', 'success'); } else { $this->flashMessage('Skladby byly úspěšně přidány.', 'success'); } } else { if ($alreadyExists) { if ($onlyOneSong) { $this->flashMessage('Skladba již byla nahrána dříve.', 'info'); } else { $this->flashMessage('Některé skladby již byly nahrány dříve.', 'info'); } } else { if ($onlyOneSong) { $this->flashMessage('Skladbu se nepodařilo přidat.', 'error'); } else { $this->flashMessage('Skladby se nepodařilo přidat.', 'error'); } } } $this->redirect('this'); }
public function renderDefault() { $this->template->songs = $this->songsManager->getAllSongs(); Debugger::barDump($this->template->songs[0]); }
public function renderDefault() { $this->template->genres = $this->genresManager->countAllGenres(); $this->template->songs = $this->songsManager->countAllSongs(); // $this->songsManager->hashSongs(); }
public function actionDownload($songId) { list($path, $song) = $this->songsManager->getSongPathAndName($songId); $this->presenter->sendResponse(new FileResponse($path, $song)); }