本文整理汇总了PHP中Route::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::get方法的具体用法?PHP Route::get怎么用?PHP Route::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Route
的用法示例。
在下文中一共展示了Route::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_index
public function action_index()
{
$username = $this->request->param('username');
$this->view = new View_Message_Create();
$this->view->username = $username;
if ($this->request->method() == HTTP_Request::POST) {
try {
$post = $this->request->post();
$receiver = ORM::factory('User')->where('username', '=', $post['receiver'])->find();
if (!$receiver->loaded()) {
return Hint::error('Cannot find a user with the username: ' . $username);
} elseif ($this->user->id === $receiver->id) {
return Hint::error('You cannot send a message to yourself!');
}
$message_data = Arr::merge($this->request->post(), array('sender_id' => $this->user->id, 'receiver_id' => $receiver->id));
$message = ORM::factory('Message')->create_message($message_data, array('receiver_id', 'subject', 'content', 'sender_id'));
$message_data_sent = Arr::merge($this->request->post(), array('receiver_id' => $this->user->id, 'sender_id' => $receiver->id, 'sent' => 1, 'read' => 1));
ORM::factory('Message')->create_message($message_data_sent, array('receiver_id', 'subject', 'content', 'sender_id', 'sent', 'read'));
Hint::success('You have sent a message');
$this->redirect(Route::get('message.inbox')->uri());
} catch (ORM_Validation_Exception $e) {
Hint::error($e->errors('models'));
}
}
}
示例2: boot
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
// Publish config
$configPath = __DIR__ . '/../../config/config.php';
$this->publishes([$configPath => config_path('liebigCron.php')], 'config');
// Build in Cron run route
\Route::get('cron.php', function () {
// Get security key from config
$cronkeyConfig = \Config::get('liebigCron.cronKey');
// If no security key is set in the config, this route is disabled
if (empty($cronkeyConfig)) {
\Log::error('Cron route call with no configured security key');
\App::abort(404);
}
// Get security key from request
$cronkeyRequest = \Input::get('key');
// Create validator for security key
$validator = \Validator::make(array('cronkey' => $cronkeyRequest), array('cronkey' => 'required|alpha_num'));
if ($validator->passes()) {
if ($cronkeyConfig === $cronkeyRequest) {
\Artisan::call('cron:run', array());
} else {
// Configured security key is not equals the sent security key
\Log::error('Cron route call with wrong security key');
\App::abort(404);
}
} else {
// Validation not passed
\Log::error('Cron route call with missing or no alphanumeric security key');
\App::abort(404);
}
});
}
示例3: action_update
/**
* CRUD controller: UPDATE
*/
public function action_update()
{
$this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id');
$form = new FormOrm($this->_orm_model, $this->request->param('id'));
if ($this->request->post()) {
if ($success = $form->submit()) {
if (Valid::email($form->object->email, TRUE)) {
//check we have this email in the DB
$user = new Model_User();
$user = $user->where('email', '=', Kohana::$_POST_ORIG['formorm']['email'])->where('id_user', '!=', $this->request->param('id'))->limit(1)->find();
if ($user->loaded()) {
Alert::set(Alert::ERROR, __('A user with the email you specified already exists'));
} else {
$form->save_object();
Alert::set(Alert::SUCCESS, __('Item updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini ajax-load" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1" title="' . __('Delete cache') . '">' . __('Delete cache') . '</a>');
$this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller())));
}
} else {
Alert::set(Alert::ERROR, __('Invalid Email'));
}
} else {
Alert::set(Alert::ERROR, __('Check form for errors'));
}
}
return $this->render('oc-panel/pages/user/update', array('form' => $form));
}
示例4: action_index
public function action_index()
{
$loader_uri = Jx_Loader::uri(array('file' => array('loader'), 'clearSession' => 'true', 'rebuild' => 'true', 'compress' => 'false'));
Jx_Assets::add_js_file('options', 'main', 'options');
Jx_Assets::add_js_file($loader_uri, 'main', 'loader', 'options');
//add the menu
$menu = Jx_Menu::get_admin_menu();
$menu = json_encode($menu);
$menu_script = <<<MENU
var menu = {$menu};
MENU;
Jx_Assets::add_js_script($menu_script, 'main', 'menu', 'loader');
$loader_uri = Jx_Loader::uri(array('file' => array('admin')));
$script = <<<'SCRIPT'
$uses(['admin'],'admin',null,function(){});
SCRIPT;
Jx_Assets::add_js_script($script, 'main', 'admin', 'menu');
//styles... hide the page
$styles = <<<styles
#page-container {
visibility: hidden;
opacity: 0;
}
styles;
Jx_Assets::add_css_styles($styles, 'main', 'hide_page');
//other things needed
$this->template->username = $this->auth->get_user()->username;
$this->template->logout_link = Route::get('users')->uri(array('action' => 'logout'));
}
示例5: action_index
public function action_index()
{
$view = View::factory('kadldap/index');
$this->template->content = $view;
$this->template->title = 'Kadldap';
$this->template->menu = NULL;
$this->template->breadcrumb = array(Route::get('docs/guide')->uri() => __('User Guide'), Route::get('docs/guide')->uri() . '/kadldap.about' => $this->template->title, 'Configuration Test');
$view->message = FALSE;
if (isset($_POST['login'])) {
$post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('username', 'not_empty')->rule('username', 'min_length', array(1))->rule('password', 'not_empty');
if ($post->check()) {
$username = $post['username'];
$password = arr::get($post, 'password', '');
try {
if (Auth::instance()->login($username, $password)) {
$view->message = 'Successful login.';
} else {
$view->message = 'Login failed.';
}
} catch (adLDAPException $e) {
$view->message = $e->getMessage();
}
} else {
$view->message = 'You must enter both your username and password.';
}
}
if (Auth::instance()->logged_in()) {
$username = Auth::instance()->get_user();
$password = Auth::instance()->password($username);
$view->kadldap = Kadldap::instance();
$view->kadldap->authenticate($username, $password);
}
}
示例6: registerRoutes
private function registerRoutes()
{
Route::get('/account', MainController::class . '@index');
Route::get('/account/forms/fields', MainController::class . '@forms');
Route::post('/account/forms/user', MainController::class . '@formUser');
Route::post('/account/forms/password', MainController::class . '@formPassword');
Route::post('/account/forms/card/save', MainController::class . '@formCardSave');
Route::post('/account/forms/autopay/save', MainController::class . '@formAutopaySave');
Route::post('/account/forms/card/remove', MainController::class . '@formCardRemove');
Route::get('/account/orders', MainController::class . '@orders');
Route::get('/account/history', MainController::class . '@history');
Route::get('/account/order/{id}', MainController::class . '@order');
Route::get('/account/order/services/{id}', MainController::class . '@orderServices');
Route::get('/account/order/services/pdf/{id}', MainController::class . '@orderServicesPdf');
Route::get('/account/pay/init/{id}/{target}/{reset}', MainController::class . '@pay');
Route::get('/account/new_card', MainController::class . '@newCard');
Route::post('/account/delete_card', MainController::class . '@deleteCard');
Route::post('/account/autopay', MainController::class . '@autopay');
Route::post('/account/pay_finish', MainController::class . '@payFinish');
Route::get('/account/pay/card', MainController::class . '@card');
Route::get('/account/prepayment', MainController::class . '@prepayment');
Route::post('/account/pay_by_token', MainController::class . '@payByToken');
Route::get('/account/pay/check/{id}', MainController::class . '@checkPay');
Route::post('/account/pay/token', MainController::class . '@token');
Route::post('/account/pay/refund', MainController::class . '@refund');
Route::get('/account/flash/message/{type}', ServiceController::class . '@flash');
Route::get('/account/bonus', MainController::class . '@bonus');
Route::get('/account/order/review/{id}', MainController::class . '@review');
Route::post('/account/order/review', MainController::class . '@reviewOrder');
Route::get('/account/subscriptions', MainController::class . '@subscriptions');
Route::get('/account/customers_cards', MainController::class . '@customersCards');
Route::get('/account/lang/{lang}', ['as' => 'lang.set', 'before' => 'lang.set', function () {
return App::getLocale();
}]);
}
示例7: action_index
public function action_index()
{
$breadcrumb = 'menu_navigation_production_applis';
$elements = ORM::factory('syntaxchecker_project')->order_by('namespace')->order_by('title')->find_all()->as_array('id');
$view = View::factory($this->request->controller() . '/' . $this->request->action(), array('elements' => $elements));
Design::instance()->set_title(__($breadcrumb))->set_breadcrumb('index', __($breadcrumb), Route::get('default')->uri(array('controller' => 'applis', 'action' => 'index')))->set_content('index', $view);
}
示例8: action_complete
public function action_complete()
{
// Get the transaction details.
$fetch = $this->_gateway->fetchTransaction($this->_payment_vars())->send();
$data = $fetch->getData();
// Add the buyer email to parameters.
$parameters = $this->_payment_vars() + array('email' => $data['EMAIL']);
/** @var Payment_PayPal_CreateRecurringPaymentsRequest $request */
$request = $this->_gateway->createRecurringPaymentsProfile($parameters);
// Overwrite Item Category.
$data = $request->getData();
$data['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = $this->_config['itemCategory'];
/** @var Omnipay\PayPal\Message\ExpressAuthorizeResponse $response */
$response = $request->sendData($data);
if ($response->isSuccessful()) {
$response_data = $response->getData();
// Get the transaction details.
// $fetch = $this->_gateway->fetchTransaction($this->_payment_vars())->send();
// $data = $fetch->getData();
ORM::factory('Payment_Subscription')->values(array('user_id' => $this->user->id, 'package_id' => $this->_package->id, 'status' => Model_Payment_Subscription::PENDING, 'recurring_payment_id' => $response_data['PROFILEID']))->create();
Hint::success(Kohana::message('payment', 'payment.success'));
$this->redirect(Route::get('payment')->uri());
} else {
// Log the error.
Kohana::$log->add(Log::ERROR, IPN::array_to_string($response->getData()));
throw HTTP_Exception::factory('403', 'Something went wrong, no cash should have been drawn, if the error proceeds contact support!');
}
}
示例9: before
/**
* Loads test suite
*/
public function before()
{
parent::before();
if( ! Kohana_Tests::enabled())
{
// Pretend this is a normal 404 error...
$this->status = 404;
throw new Kohana_Request_Exception('Unable to find a route to match the URI: :uri',
array(':uri' => $this->request->uri));
}
// Prevent the whitelist from being autoloaded, but allow the blacklist
// to be laoded
Kohana_Tests::configure_enviroment(FALSE);
$this->config = Kohana::$config->load('phpunit');
// This just stops some very very long lines
$route = Route::get('unittest');
$this->report_uri = $route->uri(array('controller' => 'phpunit', 'action' => 'report'));
$this->run_uri = $route->uri(array('controller' => 'phpunit', 'action' => 'run'));
// Switch used to disable cc settings
$this->xdebug_loaded = extension_loaded('xdebug');
$this->template->set_global('xdebug_enabled', $this->xdebug_loaded);
}
示例10: action_logout
/**
* Basic logout action
*/
public function action_logout()
{
Auth::instance()->logout();
Session::instance()->destroy();
// $this->content = View::factory('admin/login');
$this->redirect(Route::get('login')->uri());
}
示例11: user
/**
*
* @return string
*/
public function user()
{
if (empty($this->user_id)) {
return NULL;
}
return HTML::anchor(Route::get('backend')->uri(array('controller' => 'users', 'action' => 'profile', 'id' => $this->user->id)), $this->user->username);
}
示例12: backend
/**
* Returns a string with a backend url string based on arguments
*
* @param string $controller
* @param string $action
* @param mixed $id
* @return string
*/
public static function backend($controller = null, $action = null, $id = null)
{
if (!is_array($controller)) {
$controller = array('controller' => $controller, 'action' => $action, 'id' => $id);
}
return URL::site(Route::get('backend')->uri($controller));
}
示例13: handler
public static function handler(Exception $e)
{
if (Kohana::$environment !== Kohana::PRODUCTION) {
parent::handler($e);
} else {
try {
//not saving 404 as error
if ($e->getCode() != 404) {
Kohana::$log->add(Log::ERROR, parent::text($e));
}
$params = array('action' => 500, 'origuri' => rawurlencode(Arr::get($_SERVER, 'REQUEST_URI')), 'message' => rawurlencode($e->getMessage()));
if ($e instanceof HTTP_Exception) {
$params['action'] = $e->getCode();
}
//d($params);
// Error sub-request.
echo Request::factory(Route::get('error')->uri($params))->execute()->send_headers()->body();
} catch (Exception $e) {
// Clean the output buffer if one exists
ob_get_level() and ob_clean();
// Display the exception text
echo parent::text($e);
// Exit with an error status
exit(1);
}
}
}
示例14: content
/**
* Render view.
*
* @return string
*/
public function content()
{
ob_start();
?>
<ul class="thumbnails">
<?php
foreach ($this->flyers as $flyer) {
$name = $flyer->event ? $flyer->event->name : $flyer->name;
?>
<li class="span2">
<?php
echo HTML::anchor(Route::get('flyer')->uri(array('id' => $flyer->id)), HTML::image($flyer->image->get_url('thumbnail')), array('class' => 'thumbnail'));
?>
<h4><?php
echo HTML::anchor(Route::get('flyer')->uri(array('id' => $flyer->id)), HTML::chars($name), array('title' => HTML::chars($name)));
?>
</h4>
</li>
<?php
}
?>
</ul>
<?php
return ob_get_clean();
}
示例15: url_to_route
public static function url_to_route($route_str)
{
$route_name = self::route_name($route_str);
$route_name = mb_strtolower($route_name);
$route_params = self::route_params($route_str);
return Route::get($route_name)->uri($route_params);
}