Пример #1
0
 protected function buildDomainObject($row)
 {
     $slide = new Slide();
     $slide->setId($row['slide_id']);
     $slide->setTitle($row['slide_title']);
     $slide->setType($row['slide_type']);
     $slide->setContent($row['slide_content']);
     $slide->setCreationDate($row['slide_creation_date']);
     $slide->setDeletionDate($row['slide_deletion_date']);
     if (array_key_exists('slide_screens', $row)) {
         $slide->setScreens($row['slide_screens']);
     }
     if (array_key_exists('slide_creator', $row)) {
         // Find and set the associated author
         $userId = $row['slide_creator'];
         $user = $this->userDAO->find($userId);
         $slide->setCreator($user);
     }
     return $slide;
 }
Пример #2
0
use RaspBee\Form\Type\ScreenGroupType;
use RaspBee\Custom\EDT;
$app->get('/', function () use($app) {
    $slides = $app['dao.slide']->findAll();
    return $app['twig']->render('index.html.twig', array('level' => 0, 'slides' => $slides));
})->bind('home');
// Login form
$app->get('/login', function (Request $request) use($app) {
    return $app['twig']->render('login.html.twig', array('error' => $app['security.last_error']($request), 'last_username' => $app['session']->get('_security.last_username')));
})->bind('login');
//Création de slide
$app->match('/publi/{type}', function ($type, Request $request) use($app) {
    $slideFormView = null;
    if ($app['security.authorization_checker']->isGranted('IS_AUTHENTICATED_FULLY')) {
        $slide = new Slide();
        $slide->setCreator($app['user']);
        $slide->setCreationDate(date("Y-m-d H:i:s", time()));
        $slide->setType($type);
        $slideForm = $app['form.factory']->create(new SlideType(), $slide, array('screens' => $app['dao.screen']->findByGroup(null), 'groups' => $app['dao.screen_group']->findAll()));
        $slideForm->handleRequest($request);
        if ($slideForm->isSubmitted() && $slideForm->isValid()) {
            $slide = $app['dao.slide']->save($slide);
            $screenList = array();
            foreach ($slideForm->get('groups')->getData() as $group) {
                $screenList = array_merge($screenList, $app['dao.screen']->findByGroup($group->getId()));
            }
            $screenList = array_merge($screenList, $slideForm->get('screens')->getData());
            foreach ($screenList as $screen) {
                $app['dao.slide']->assignToScreen($slide->getId(), $screen->getId());
            }
            $app['session']->getFlashBag()->add('success', 'Slide créée ! Votre slide a bien été ajoutée ');