Пример #1
0
    return $app['twig']->render('index.html.twig');
});
//Summary Generation
$app->post('/generate', function (Silex\Application $app, Request $request) {
    $talks = $request->get('talks');
    //Get Primary Talk data
    $talkData = $app['api']->getTalkData($talks[0]);
    if ($talkData === null) {
        throw new UnexpectedValueException("Invalid talk");
    }
    $speakerData = $app['api']->getSpeakerData($talkData->speakers[0]->speaker_uri);
    if ($speakerData === null) {
        throw new UnexpectedValueException("Invalid speaker");
    }
    //New Aggregation
    $agg = new \Agg\Entity\Aggregation();
    $agg->setTitle($talkData->talk_title);
    $agg->setTalks($talks);
    $agg->setSpeakerName($speakerData->full_name);
    $agg->setSpeakerUrl($speakerData->website_uri);
    //Persist
    $app['storage']->storeAggregation($agg);
    //Redirect
    return \Symfony\Component\HttpFoundation\RedirectResponse::create("/talk/" . $agg->getSlug());
});
//Talk page
$app->get('/talk/{slug}', function (Silex\Application $app, $slug) {
    $aggregation = $app['storage']->retrieveAggregationBySlug($slug);
    $summary = $app['parser']->parseSummaryStats($aggregation->getTalks());
    //Render
    return $app['twig']->render('summary.html.twig', array('summary' => $summary, 'aggregation' => $aggregation));
Пример #2
0
 /**
  * Retrieves a list of all aggregations
  *
  * @return array|bool
  */
 public function retrieveAggregationList()
 {
     try {
         $result = $this->tableProxy->queryEntities(self::TABLE_AGGREGATION);
         $entities = $result->getEntities();
         $aggregations = array();
         foreach ($entities as $entity) {
             /** @var $entity Entity */
             $agg = new \Agg\Entity\Aggregation();
             $agg->setSlug($entity->getPropertyValue('slug'));
             $agg->setTitle($entity->getPropertyValue('title'));
             $agg->setTalks(unserialize(htmlspecialchars_decode($entity->getPropertyValue('talks'))));
             $agg->setSpeakerName($entity->getPropertyValue('speakerName'));
             $agg->setSpeakerUrl($entity->getPropertyValue('speakerUrl'));
             $aggregations[] = $agg;
         }
         return $aggregations;
     } catch (ServiceException $e) {
         $code = $e->getCode();
         $error_message = $e->getMessage();
         echo $code . ": " . $error_message . "<br />";
         return false;
     }
 }