public function onSubmit(Form $form)
{
$data = $form->getValues();
// Předáme data do šablony
$this->template->values = $data;
$queueId = uniqid();
\dibi::begin();
$gallery_id = $this->gallery->insert(array("name" => $data["name"]));
// Přesumene uploadované soubory
foreach ($data["upload"] as $file) {
// $file je instance HttpUploadedFile
$newFilePath = FILESTORAGE_DIR . "/q{" . $queueId . "}__f{" . rand(10, 99) . "}__" . $file->getName();
// V produkčním módu nepřesunujeme soubory...
if (!Environment::isProduction()) {
if ($file->move($newFilePath)) {
$this->flashMessage("Soubor " . $file->getName() . " byl úspěšně přesunut!");
} else {
$this->flashMessage("Při přesouvání souboru " . $file->getName() . " nastala chyba! Pro více informací se podívejte do logů.");
}
}
$this->files->insert($file);
$this->gallery->addFile($gallery_id, $file_id);
dump($file);
}
\dibi::commit();
}