Esempio n. 1
0
 public function __construct()
 {
     $this->logger = \Logger::getLogger('CronMain');
     // factory pattern
     global $env;
     $this->factories = Autoloader::loadFactories($env['basepath'] . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . 'Logic' . DIRECTORY_SEPARATOR . 'Factories' . DIRECTORY_SEPARATOR, 'AttOn\\Controller\\Logic\\Factories\\');
 }
Esempio n. 2
0
        $view = $factory->getOperation();
        $view->run($data);
    } catch (SessionException $ex) {
        $data['errors'] = array('message' => $ex->getMessage());
        HeaderViewHelper::parseCurrentUser($data);
        $app->render('error.twig', $data);
        return;
    }
    HeaderViewHelper::parseCurrentUser($data);
    $app->render('main.twig', $data);
});
$app->map('/:content/', function ($content) use($app, $debug, $logger) {
    $data = array();
    // factory pattern
    $env = $app->environment();
    $factories = Autoloader::loadFactories($env['basepath'] . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR . 'Content' . DIRECTORY_SEPARATOR . 'Factories' . DIRECTORY_SEPARATOR, '\\AttOn\\View\\Content\\Factories\\');
    // get operation
    foreach ($factories as $factory) {
        /* @var $factory ContentFactory */
        if ($factory->getName() === $content) {
            try {
                $view = $factory->getOperation();
                $view->run($data);
            } catch (SessionException $ex) {
                $logger->error($ex);
                $data['errors'] = array('message' => $ex->getMessage());
                HeaderViewHelper::parseCurrentUser($data);
                $app->render('error.twig', $data);
                return;
            }
        }