예제 #1
0
 public function getAppJs()
 {
     $routes = \PublicRouteDriver::all();
     $entities = \EntityDriver::all();
     $content = \View::make('site.assets.appjs', compact('routes', 'entities'));
     return \Response::make($content, 200, array('Content-Type' => 'text/javascript'));
 }
예제 #2
0
 public function sitemap()
 {
     $query = \PublicRouteDriver::query();
     $urls = [];
     $routes = $query->where('directory_hidden', false)->get();
     foreach ($routes as $route) {
         if (!$route->dependencies) {
             $urls[] = route($route->name);
         } else {
             $directory = json_decode($route->directory, 1);
             foreach ($route->dependencies as $dependency) {
                 if (array_key_exists($dependency, $directory)) {
                     $parts = explode('<', $directory[$dependency]);
                     if (count($parts) == 3) {
                         $items = \Evaluator::getQuery($directory[$dependency])->get();
                         $identifier = $parts[2];
                         foreach ($items as $item) {
                             $urls[] = route($route->name, $item->{$identifier});
                         }
                     }
                 }
             }
         }
     }
     $sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . \View::make('directory.sitemapxml', compact('urls'));
     return \Response::make($sitemap, 200)->header('Content-Type', 'application/xml');
 }
예제 #3
0
 private function getPublicRoute()
 {
     if ($this->public_route) {
         return $this->public_route;
     }
     $route = \Route::current();
     $route_path = $route->uri();
     foreach ($route->parameters() as $key => $value) {
         $route_path = str_replace('{' . $key . '}', ':' . $key, $route_path);
     }
     if ($route_path == '/') {
         $route_path = '';
     }
     $this->public_route = \PublicRouteDriver::getByPath($route_path);
     return $this->public_route;
 }
예제 #4
0
파일: RoutesCoder.php 프로젝트: joadr/cms
 public function codeRoutes()
 {
     $routes = \PublicRouteDriver::all();
     $entities = \EntityDriver::all();
     $this->codeRoutesForRoutesAndEntities($routes, $entities);
 }
예제 #5
0
 public function destroy($id)
 {
     $public_route = \PublicRouteDriver::delete($id);
     return;
 }
예제 #6
0
파일: routes.php 프로젝트: joadr/cms
<?php

Route::group(['namespace' => 'Cms\\Site\\Controllers'], function () {
    Route::get('js/app.js', ['as' => 'site.assets.appjs', 'uses' => 'AssetsController@getAppJs']);
    Route::get('api/definitions/', ['as' => 'api.definitions.index', 'uses' => 'DefinitionsController@index']);
    Route::get('api/{entity}/', ['as' => 'api.entity.index', 'uses' => 'EntitiesController@index']);
    Route::get('api/{entity}/{id}', ['as' => 'api.entity.show', 'uses' => 'EntitiesController@show']);
    $routes = \PublicRouteDriver::all();
    foreach ($routes as $route) {
        Route::get($route->laravel_format, ['as' => $route->name, 'uses' => 'SiteController@route']);
    }
    Route::get('sitemap.xml', ['as' => 'site.directory.sitemap', 'uses' => 'DirectoryController@sitemap']);
    Route::get('directory', ['as' => 'site.directory.index', 'uses' => 'DirectoryController@index']);
    Route::get('directory/{id}', ['as' => 'site.directory.depended', 'uses' => 'DirectoryController@depended']);
});
if (!Config::get('app.debug')) {
    App::error(function (\Exception $exception) {
        Log::error($exception);
        return Response::view('errors.unknown', array(), 500);
    });
    App::fatal(function ($exception) {
        Log::error($exception);
        return Response::view('errors.fatal', array(), 500);
    });
    App::missing(function ($exception) {
        return Response::view('errors.missing', array(), 404);
    });
}