本文整理汇总了PHP中Slim\Slim::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::redirect方法的具体用法?PHP Slim::redirect怎么用?PHP Slim::redirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\Slim
的用法示例。
在下文中一共展示了Slim::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Delete
public function Delete($files, \Slim\Slim &$app, $page)
{
$obj = new Files();
$obj->parseFile($files);
$user_id = $obj->user_id;
//$cookieDB = $obj->cookie;
$cookie = $app->getCookie('username');
$db = $app->db;
$logged = new Logged();
$id = $logged->getLogged($db, $cookie);
//checking of the user is registered in Users table as the user or anonymous which added this file and getting his id
if ($id == $user_id) {
$foo = new Foo();
$foo->token = $page;
$mapper = new FooMapper($db);
$files = $mapper->delete($foo);
$path = $obj->path;
$filename = "uploads/" . $path;
//deleting file from the folder
unlink($filename);
$app->redirect('/TwigBlog/');
} else {
$app->error();
}
}
示例2: get
public function get()
{
$cookieName = session_name();
$sessionParams = session_get_cookie_params();
// Unset cookie in browser
setcookie($cookieName, false, 1, $sessionParams['path'], $sessionParams['domain'], $sessionParams['secure']);
$this->slim->redirect($this->slim->request->getRootUri() . '/login');
}
示例3: post
public function post()
{
// Read JSON from Body-input
$requestData = json_decode($this->slim->request->getBody());
// Create feed
$feedId = $this->feedsDao->create($_SESSION['user']['id'], ['name' => $requestData->name, 'website_uri' => $requestData->website_uri, 'feed_uri' => $requestData->feed_uri, 'update_interval' => $requestData->update_interval]);
// Redirect to the new API-Resource to tell the client where it is
$this->slim->redirect($this->slim->request->getRootUri() . '/api/feeds/' . $feedId);
}
示例4: redirect
public function redirect($url, $status = 302)
{
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
parent::redirect((Config::get('url_rewrite', true) ? '' : '/index.php') . $url, $status);
} else {
parent::redirect($url, $status);
}
}
示例5: redirect
/**
* @param $location
* @param $status
*/
public function redirect($location, $status = 302)
{
try {
$this->app->redirect($location, $status);
} catch (\Slim\Exception\Stop $e) {
// do nothing
}
}
示例6: routes
function routes(\Slim\Slim $app)
{
$base = $this->getBasePath();
$app->get($base . '/', function () use($app) {
$app->redirect($app->Doc->getBasePath() . '/api-doc/');
});
$app->get($base . '/api-doc/json', function () use($app) {
$app->Doc->json();
});
$app->get($base . '/api-doc/', function () use($app) {
$app->Doc->ui();
});
$app->get($base . '/api-doc/json/:name', function ($name) use($app) {
$app->Doc->api($name);
});
}
示例7: checkRequirements
public function checkRequirements()
{
$paths = Utils::getPaths(SW_PATH . "/engine/Shopware/Components/Check/Data/Path.xml");
clearstatcache();
$systemCheckPathResults = Utils::checkPaths($paths, SW_PATH);
foreach ($systemCheckPathResults as $value) {
if (!$value['result']) {
$fileName = SW_PATH . '/' . $value['name'];
@mkdir($fileName, 0777, true);
@chmod($fileName, 0777);
}
}
clearstatcache();
$systemCheckPathResults = Utils::checkPaths($paths, SW_PATH);
$hasErrors = false;
foreach ($systemCheckPathResults as $value) {
if (!$value['result']) {
$hasErrors = true;
}
}
$directoriesToDelete = ['engine/Library/Mpdf/tmp' => false, 'engine/Library/Mpdf/ttfontdata' => false];
CommonUtils::clearOpcodeCache();
$results = [];
foreach ($directoriesToDelete as $directory => $deleteDirecory) {
$result = true;
$filePath = SW_PATH . '/' . $directory;
Utils::deleteDir($filePath, $deleteDirecory);
if ($deleteDirecory && is_dir($filePath)) {
$result = false;
$hasErrors = true;
}
if ($deleteDirecory) {
$results[$directory] = $result;
}
}
if (!$hasErrors && $this->app->request()->get("force") !== "1") {
// No errors, skip page except if force parameter is set
$this->app->redirect($this->app->urlFor("dbmigration"));
}
$isSkippableCheck = $this->app->config('skippable.check');
if ($isSkippableCheck && $this->app->request()->get("force") !== "1") {
// No errors, skip page except if force parameter is set
$this->app->redirect($this->app->urlFor("dbmigration"));
}
$this->app->render('checks.php', ['systemCheckResultsWritePermissions' => $systemCheckPathResults, 'filesToDelete' => $results, 'error' => $hasErrors]);
}
示例8: redirect
/**
* Redirect controller
*
* @param string $path
* @return void
*/
protected function redirect($path)
{
$path = str_replace('//', '/', $this->app->baseURL . $path);
$this->app->redirect($path);
}
示例9: action_logout
public function action_logout(\Slim\Slim $app)
{
$app->user->logout();
$app->redirect("/");
}
示例10: Picture
if (isset($matches[1])) {
$format = $matches[1];
}
$picture = new Picture($conf, DEFAULT_PICTURE, $app_base_url);
$display = $picture->getDisplay($format);
$response = $app->response();
foreach ($display['headers'] as $key => $header) {
$response[$key] = $header;
}
$response->body($display['content']);
} else {
$app->render('50x.html.twig', array('exception' => $e));
}
});
//main route
$app->get('/', function () use($app, $app_base_url) {
$app->redirect($app_base_url . '/viewer/' . DEFAULT_PICTURE);
});
//include routes files
require_once 'routes/images.routes.php';
require_once 'routes/series.routes.php';
require_once 'routes/ajax.routes.php';
if (APP_DEBUG === true) {
include_once 'routes/debug.routes.php';
}
if (!defined('APP_TESTS')) {
$app->run();
if (isset($profiler)) {
$profiler->stop();
}
}
示例11: redirect
public function redirect($name, $params = array(), $routeName = true)
{
$url = $routeName ? $this->urlFor($name, $params) : $name;
parent::redirect($url);
}
示例12: function
$app->group('/', function () use($app) {
$app->get('/', function () use($app) {
});
});
$app->group('/login', function () use($app) {
$app->get('/', function () use($app) {
$app->render('login.php');
});
$app->post('/', function () use($app) {
$data = $app->request()->post();
$login = new LoginController();
$result = $login->login($data);
if ($result) {
$app->flash('msgInfo', 'Bienvenido ' . $_SESSION['user']);
if ($_SESSION['tipo'] == 1) {
$app->redirect(URL . 'pacientes');
}
if ($_SESSION['tipo'] == 2) {
$app->redirect(URL . 'turnos');
}
if ($_SESSION['tipo'] == 3) {
$app->redirect(URL . 'guardias');
}
if ($_SESSION['tipo'] == 4) {
$app->redirect(URL . 'turnos');
}
} else {
$app->flash('msgError', 'Datos incorrectos.');
$app->redirect(URL . 'login');
}
});
示例13: redirect
/**
* {@inheritDoc}
*/
public function redirect($url, $status = 302)
{
parent::redirect($this->getWebPath() . $url, $status);
}
示例14: function
$app->get('/download_report', function () use($app, $config) {
$fileName = $app->request()->params('filename');
echo "<pre>";
echo file_get_contents($config['log_files_path'] . $fileName);
});
$app->get('/process/', function () use($app, $config) {
$fileName = $app->request()->params('filename');
$locker = new ProcessLocker($config['lock_file']);
if (!$locker->isLocked()) {
$splitter = new CsvSplitter(new CsvFile($fileName), $config['output_csv_path']);
$splitter->split($config['split_size']);
$command = $config['nohup_path'] . ' ' . $config['php_path'] . ' ' . __DIR__ . '/src/shell/csv_importer.php ' . $config['output_csv_path'] . ' > /dev/null 2>&1 &';
$process = new Process($command, $config['proc_working_path']);
$process->run();
}
$app->redirect('/csv_batch_process/index.php');
});
use Helpers\Magento\MageWrapper;
use Repositories\Magento\CatalogRepository;
use Repositories\Magento\EavCatalogProductRepository;
use Processors\Magento\ProductImporter;
$app->get('/test/', function () use($app, $config) {
ini_set('max_execution_time', -1);
Mage::app('admin', 'store', array('global_ban_use_cache' => true))->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$mageWrapper = new MageWrapper(Mage);
$eavRepository = new EavCatalogProductRepository($mageWrapper);
$catalogRepository = new CatalogRepository($mageWrapper, $eavRepository);
$magentoProcessor = new ProductImporter($catalogRepository);
$magentoProcessor->process(new CsvFile('sample.csv'), 'sample.csv');
});
$app->get('/test_splitter/', function () use($app, $config) {
示例15: configureRoutes
/**
* Configure routes to be handled by application.
*
* @param \Slim\Slim $slim Application
*/
protected function configureRoutes(\Slim\Slim $slim)
{
$middleware = array('must-revalidate' => function () use($slim) {
$slim->response->headers->set('Cache-Control', 'private, must-revalidate, max-age=0');
$slim->response->headers->set('Expires', 'Thu, 01 Jan 1970 00:00:00 GMT');
}, 'inject-user' => function () use($slim) {
$user = $slim->authManager->getUserData();
$slim->view->set('user', $user);
}, 'require-user' => function () use($slim) {
if ($slim->authManager->isAnonymous()) {
if ($slim->request->isGet()) {
$uri = $slim->request->getUrl() . $slim->request->getPath();
$qs = Form::qsMerge();
if ($qs) {
$uri = "{$uri}?{$qs}";
}
$_SESSION[AuthManager::NEXTPAGE_SESSION_KEY] = $uri;
}
// FIXME: use i18n
$slim->flash('error', 'Login required');
$slim->flashKeep();
$slim->redirect($slim->urlFor('login'));
}
});
$slim->group('/', $middleware['inject-user'], function () use($slim, $middleware) {
App::redirect($slim, '', 'random', 'home');
App::redirect($slim, 'index', 'random');
$slim->get('random', function () use($slim) {
$page = new Pages\Random($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page();
})->name('random');
$slim->get('random.json', function () use($slim) {
$slim->response->headers->set('Content-Type', 'application/json');
$page = new Pages\Random($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page->setTemplate('random.json');
$page();
})->name('random.json');
$slim->get('search', function () use($slim) {
$page = new Pages\Search($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page();
})->name('search');
$slim->get('top', function () use($slim) {
$page = new Pages\Top($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page();
})->name('top');
App::template($slim, 'login');
$slim->get('logout', $middleware['must-revalidate'], function () use($slim) {
$slim->authManager->logout();
$slim->redirect($slim->urlFor('home'));
})->name('logout');
App::template($slim, 'about');
App::template($slim, 'help');
});
// end group '/'
$slim->group('/quip/', $middleware['inject-user'], function () use($slim, $middleware) {
$slim->get(':id', function ($id) use($slim) {
$page = new Pages\Quip($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page($id);
})->name('quip');
$slim->get(':id/edit', $middleware['require-user'], function ($id) use($slim) {
$page = new Pages\Edit($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page($id);
})->name('edit');
$slim->post(':id/post', $middleware['require-user'], function ($id) use($slim) {
$page = new Pages\Edit($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page($id);
})->name('edit_post');
$slim->post(':id/delete', $middleware['require-user'], function ($id) use($slim) {
$page = new Pages\Delete($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page($id);
})->name('delete_post');
$slim->post(':id/vote', $middleware['require-user'], function ($id) use($slim) {
$page = new Pages\Vote($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page($id);
})->name('vote_post');
});
$slim->group('/oauth/', function () use($slim) {
//.........这里部分代码省略.........