예제 #1
0
 protected function migrate($entityName)
 {
     $locator = base::getDbLocator();
     $mapper = $locator->mapper($entityName);
     $mapper->migrate();
     echo 'OK!';
 }
예제 #2
0
 private static function register($assetType, $assetName, $assetFile)
 {
     $assets_path = base::getBasePath() . DIRECTORY_SEPARATOR . self::$assetsFolder;
     if (!file_exists($assets_path)) {
         mkdir($assets_path, 0755, true);
     }
     if (copy($assetFile, $assets_path . DIRECTORY_SEPARATOR . $assetName . '.' . $assetType)) {
         self::$assets[$assetType][] = self::$assetsFolder . DIRECTORY_SEPARATOR . $assetName . '.' . $assetType;
     }
 }
 public function shoutBox(Request $request, Response $response)
 {
     $locator = base::getDbLocator();
     $mapper = $locator->mapper('app\\models\\Message');
     if (!empty($_POST)) {
         $message = $mapper->insert(['author' => $_POST['author'], 'message' => $_POST['message']]);
     }
     $messages = $mapper->all();
     AssetBundle::registerCss('bootstrap', __DIR__ . '/../views/css/bootstrap.css');
     return $this->render('shoutbox', ['messages' => $messages]);
 }
예제 #4
0
 public function render($view, $data = [], $responseCode = 200)
 {
     $views_path = realpath(base::getBasePath() . DIRECTORY_SEPARATOR . self::$viewsFolder . DIRECTORY_SEPARATOR);
     $loader = new \Twig_Loader_Filesystem($views_path);
     $twig = new \Twig_Environment($loader, ['debug' => true]);
     $data['assets'] = new AssetBundle();
     $data['hipersia_csrf'] = Sec::getCsrf();
     $content = $twig->render($view . '.html', $data);
     $response = new Response();
     $response->setContent($content);
     $response->setStatusCode($responseCode);
     return $response;
 }