Hi, i am new in Slim and get trouble to transform a Silex controller to work well :
Blockquote
public static function controller($app) {
$c = $app[‘controllers_factory’];
$c->get(‘/browse/{path}’, function($path) use ($app) {
return self::browse($app, $path);
})->assert(‘path’, ‘.‘);
$c->get(’/ajax/{path}‘, function($path) use ($app) {
$target = DIR.’/…/data/'.$path;
if (!file_exists($target))
return self::msg(False, “$path does not exist”);
if (is_dir($target))
return self::get_content($app, $path);
else
return file_get_contents($target);
})->assert(‘path’, '.’);
$c->post(‘/ajax/{path}’, function($path) use ($app) {
if ($_POST[‘type’] == ‘folder’)
return self::create_folder($path);
else if ($_POST[‘type’] == ‘file’)
return self::create_file($path);
else if ($_POST[‘type’] == ‘move’)
return self::move($_POST[‘src’], $_POST[‘dst’]);
else if ($_POST[‘type’] == ‘upload’)
return self::upload($path);
else if ($_POST[‘type’] == ‘edit’)
return self::save($path, $_POST[‘content’]);
else
return self::msg(False, ‘unknown type’);
})->assert(‘path’, ‘.‘);
$c->delete(’/ajax/{path}', function($path) use ($app) {
return self::remove($path);
})->assert(‘path’, '.’);
$c->get(‘/’, function () use ($app) {
return $app->redirect(‘browse’);
});
return $c;
}
Any help will be more than apreciable