Esempio n. 1
0
    if (null === $videoProxy) {
        $uri = $this->router->pathFor('homepage', array());
        return $response->withRedirect((string) $uri, 301);
    }
    $this->view->render($response, 'show_video.html.twig', array('videoProxy' => $videoProxy));
    return $response;
})->setName('show_video');
$app->get('/admin/', function ($request, $response, $args) {
    $channels = $this->get('tvlistings.channel.repository')->findAll();
    $this->view->render($response, 'admin/list.html.twig', array('channels' => $channels, 'flash' => $this->flash));
    return $response;
})->setName('admin_homepage');
$app->map(['GET', 'POST'], '/admin/channels/new', function ($request, $response, $args) {
    if ($request->isPost()) {
        $parsedBody = $request->getParsedBody();
        $channel = new Channel($parsedBody['name'], $parsedBody['logoPath']);
        $channelRepository = $this->get('tvlistings.channel.repository');
        $uri = $this->router->pathFor('admin_homepage', array());
        if (null !== $channelRepository->findOneBySlug($channel->getSlug())) {
            $this->flash->addMessage('error', sprintf('Энэ суваг (%s) аль хэдийн бүртгэгдсэн байна.', $channel->getName()));
            return $response->withRedirect((string) $uri, 301);
        }
        $channelRepository->persist($channel);
        return $response->withRedirect((string) $uri, 301);
    }
    $this->view->render($response, 'admin/new.html.twig', array());
    return $response;
})->setName('admin_channel_new');
$app->post('/admin/channels/{slug}', function ($request, $response, $args) {
    $channel = $this->get('tvlistings.channel.repository')->findOneBySlug($args['slug']);
    if (null === $channel) {
 /**
  * @test
  */
 public function it_should_be_able_to_change_description()
 {
     $channel = new Channel("MNB", "mnb.png");
     $channel->setDescription("Mongolian National Broadcasting");
     $this->assertEquals("Mongolian National Broadcasting", $channel->getDescription());
 }