Example #1
0
 public function testAddProjectSaveIt()
 {
     $storage = $this->getStorage();
     $storage->expects($this->once())->method('updateProject');
     $sismo = new Sismo($storage, $this->getBuilder());
     $sismo->addProject($project = new Project('Twig'));
     $sismo->getProject('twig');
 }
Example #2
0
File: app.php Project: havvg/Sismo
    }
    return new Builder($app['build.path'], $app['git.path'], $app['git.cmds']);
});
$app['sismo'] = $app->share(function () use($app) {
    $sismo = new Sismo($app['storage'], $app['builder']);
    if (!is_file($app['config.file'])) {
        throw new \RuntimeException(sprintf("Looks like you forgot to define your projects.\nSismo looked into \"%s\".", $app['config.file']));
    }
    $projects = (require $app['config.file']);
    if (null === $projects) {
        throw new \RuntimeException(sprintf('The "%s" configuration file must return an array of Projects (returns null).', $app['config.file']));
    }
    if (!is_array($projects)) {
        throw new \RuntimeException(sprintf('The "%s" configuration file must return an array of Projects (returns a non-array).', $app['config.file']));
    }
    foreach ($projects as $project) {
        if (!$project instanceof Project) {
            throw new \RuntimeException(sprintf('The "%s" configuration file must return an array of Project instances.', $app['config.file']));
        }
        $sismo->addProject($project);
    }
    return $sismo;
});
$app->error(function (\Exception $e, $code) use($app) {
    if ($app['debug']) {
        return;
    }
    $error = 404 == $code ? $e->getMessage() : null;
    return new Response($app['twig']->render('error.twig', array('error' => $error)), $code);
});
return $app;