function add_rest($uri, $resource)
{
    $create = !is_object($resource);
    add_route($uri, 'route_rest_uri_get', 'GET', array('create' => $create, 'controller' => $resource, 'router' => true));
    add_route($uri, array($resource, 'createAction'), 'POST', array('create' => $create));
    add_route($uri, array($resource, 'updateAction'), 'PUT', array('create' => $create));
    add_route($uri, array($resource, 'deleteAction'), 'DELETE', array('create' => $create));
}
Ejemplo n.º 2
0
<?php

$app_dir = __DIR__ . '/../../../symfony/app';
function add_bundle($bundle_class, $app_dir)
{
    $contents = file_get_contents($app_dir . '/AppKernel.php');
    $length = strlen($contents);
    $return_pos = strpos($contents, 'return $bundles');
    $h = fopen($app_dir . '/AppKernel.php', 'c+');
    fseek($h, $return_pos);
    fwrite($h, '$bundles[] = new ' . $bundle_class . ";\n\t");
    fwrite($h, substr($contents, $return_pos - $length));
    fclose($h);
}
function add_route($app_dir)
{
    $contents = file_get_contents(__DIR__ . '/routing.yml');
    $h = fopen($app_dir . '/config/routing.yml', 'w');
    fwrite($h, $contents . "\n");
    fclose($h);
}
add_bundle('ActiveLAMP\\TaxonomyBundle\\ALTaxonomyBundle()', $app_dir);
add_route($app_dir);
print file_get_contents($app_dir . '/AppKernel.php');
print file_get_contents($app_dir . '/config/routing.yml');
function add_public_route($url, $arg2, $options = array())
{
    $options['public'] = TRUE;
    add_route($url, $arg2, $options);
}
Ejemplo n.º 4
0
<?php

add_route('get', '/', array('controller' => new \Towel\Controller\BaseController(), 'action' => 'index', 'route_name' => 'home'));
add_route('get', '/assets', array('controller' => new \Towel\Controller\AssetsController(), 'action' => 'index', 'route_name' => 'assets'));
Ejemplo n.º 5
0
function add_rest($controller)
{
    // TODO
    $c = ucfirst($controller) . 'Controller';
    add_route($controller, array($c, 'indexAction'), 'GET');
    add_route($controller . '/{id}', array($c, 'showAction'), 'GET');
    add_route($controller, array($c, 'createAction'), 'POST');
    // etc.
}
Ejemplo n.º 6
0
function put($pattern, $handler)
{
    return add_route($pattern, $handler, 'PUT');
}
Ejemplo n.º 7
0
<?php

/**
 * Default routes for User Controller, copy this file
 * to yourapp/config/routes to enabled this feature.
 */
$controller = get_app()->getInstance('user_controller');
add_route('get', 'login', array('controller' => $controller, 'action' => 'loginShow', 'route_name' => 'login'));
add_route('post', 'login', array('controller' => $controller, 'action' => 'loginAction', 'route_name' => 'login_post'));
add_route('get', 'logout', array('controller' => $controller, 'action' => 'logoutAction', 'route_name' => 'logout'));
add_route('get', 'user', array('controller' => $controller, 'action' => 'profileShow', 'route_name' => 'user'));
add_route('get', 'user/register', array('controller' => $controller, 'action' => 'registerShow'));
add_route('post', 'user/register', array('controller' => $controller, 'action' => 'registerAction', 'route_name' => 'user_register'));
add_route('get', 'user/recover', array('controller' => $controller, 'action' => 'recoverShow', 'route_name' => 'user_recover'));
add_route('post', '/user/recover', array('controller' => $controller, 'action' => 'recoverAction', 'route_name' => 'user_recover_post'));
Ejemplo n.º 8
0
<?php

$out_file = path(APP_PATH, 'app', 'controllers', "{$name}.php");
if (is_file($out_file)) {
    error("\n  Controller '{$name}' already exists\n");
} else {
    add_controller($name, arg('A no-action'));
    add_route($name, "{$name}#index", $name);
    if (!arg('V no-view')) {
        $text = "section\n  header\n    {$name}#index.view\n  pre = path(APP_PATH, 'app', 'views', '{$name}', 'index.php.neddle')";
        add_view($name, 'index.php.neddle', "{$text}\n");
    }
}
Ejemplo n.º 9
0
<?php

$out_file = path(APP_PATH, 'app', 'controllers', "{$name}.php");
if (!is_file($out_file)) {
    error("\n  Missing '{$name}' controller\n");
} elseif (!$action) {
    error("\n  Missing action for '{$name}' controller\n");
} else {
    $continue = TRUE;
    $method = arg('m method') ?: 'get';
    $route = arg('r route') ?: "{$name}/{$action}";
    $path = arg('p path') ?: "{$name}_{$action}";
    if (!arg('A no-action')) {
        if (!add_action($name, $action, $method, $route, $path)) {
            error("\n  Action '{$action}' already exists\n");
            $continue = FALSE;
        }
    }
    if ($continue) {
        add_route($route, "{$name}#{$action}", $path, $method);
        if (!arg('V no-view')) {
            $text = "section\n  header\n    {$name}#{$action}.view\n  pre = path(APP_PATH, 'app', 'views', '{$name}', '{$action}.php.neddle')";
            add_view($name, "{$action}.php.neddle", "{$text}\n");
        }
    }
}