当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::make方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Response::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::make方法的具体用法?PHP Response::make怎么用?PHP Response::make使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Response的用法示例。


在下文中一共展示了Response::make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: githubLogin

 public function githubLogin()
 {
     $access_token = Input::get('access_token');
     $ch = curl_init('https://api.github.com/user');
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: token {$access_token}"));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
     curl_setopt($ch, CURLOPT_USERAGENT, 'SWAMP');
     $response = curl_exec($ch);
     $user = json_decode($response);
     $account = LinkedAccount::where('user_external_id', '=', $user->id)->first();
     if ($account) {
         Session::set('github_access_token', $access_token);
         $user = User::getIndex($account->user_uid);
         if ($user) {
             if ($user->isEnabled()) {
                 $res = Response::json(array('user_uid' => $user->user_uid));
                 Session::set('timestamp', time());
                 Session::set('user_uid', $user->user_uid);
                 return $res;
             } else {
                 return Response::make('User has not been approved.', 401);
             }
         } else {
             return Response::make('Incorrect username or password.', 401);
         }
     } else {
         return Response::make('Account not found.', 401);
     }
 }
开发者ID:pombredanne,项目名称:open-swamp,代码行数:30,代码来源:SessionController.php

示例2: getIndex

 /**
  * Index action.
  *
  * @return mixed
  */
 public function getIndex($type = null)
 {
     $container = Input::get('c');
     $files = Input::get('files', '');
     if (empty($type) || !in_array($type, array('style', 'script'))) {
         App::abort(404);
     }
     if (empty($container)) {
         App::abort(404);
     }
     $files = json_decode(base64_decode($files), true);
     if (empty($files) || !is_array($files)) {
         App::abort(404);
     }
     foreach ($files as $file) {
         Casset::container($container)->add(array_get($file, 'source'), array(), array_get($file, 'dependencies', array()));
     }
     $response = Response::make(Casset::container($container)->content($type));
     if ('style' == $type) {
         $response->headers->set('Content-Type', 'text/css');
     } else {
         $response->headers->set('Content-Type', 'application/json');
     }
     return $response;
 }
开发者ID:jooorooo,项目名称:laravel-casset,代码行数:30,代码来源:CassetController.php

示例3: bootFilters

 /**
  * Add route filters.
  *
  * @return void
  */
 protected function bootFilters()
 {
     if (config('api.cors_enabled', true)) {
         $this->app['router']->before(function ($request) {
             if (Request::header('Origin') && $_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
                 $response = Response::make(null, 204);
                 Cors::attachHeaders($response);
                 Cors::attachOriginHeader($response, Request::header('Origin'));
                 return $response;
             }
         });
         $this->app['router']->after(function ($request, $response) {
             if (Request::header('Origin')) {
                 Cors::attachHeaders($response);
                 Cors::attachOriginHeader($response, Request::header('Origin'));
             }
         });
     }
     $this->app['router']->filter('protect', function ($route, $request) {
         Api::protect();
     });
     $this->app['router']->filter('checkscope', function ($route, $request, $scope = '') {
         // B/c Laravel uses : as a special character already.
         $scope = str_replace('.', ':', $scope);
         Api::checkScope($scope);
     });
 }
开发者ID:mmanos,项目名称:laravel-api,代码行数:32,代码来源:ApiServiceProvider.php

示例4: index

 public function index(Request $request)
 {
     $parameters = $request->route()->parameters();
     $parser = new Parser($parameters);
     $generator = new Generator($request->path());
     if (!isset($parameters['version']) && !isset($parameters['resource']) && !isset($parameters['action'])) {
         $segments = ['index'];
     } else {
         $segments = $parameters;
     }
     $file = base_path('resources/' . config('apidocu.base') . '/' . implode('/', $segments) . '.md');
     if (file_exists($file)) {
         $content = file_get_contents($file);
         $status = 200;
     } else {
         $status = 404;
         switch (config('apidocu.404.type')) {
             case 'text':
                 $content = config('apidocu.404.value');
                 break;
             case 'view':
                 $content = view(config('apidocu.404.value'));
                 break;
             default:
                 $content = '**404 - page not found**';
                 break;
         }
     }
     $content = $parser->parse($content);
     return Response::make(view('apidocu::index')->with(['navigation' => $generator->navigation(), 'breadcrumb' => $generator->breadcrumb(), 'content' => $content]), $status);
 }
开发者ID:Absolute-Software,项目名称:laravel-apidocu,代码行数:31,代码来源:DocumentationController.php

示例5: getActivity

 public function getActivity(Request $request)
 {
     $me = GitHub::me()->show();
     $lastEventId = $request->session()->get('last_notification_id', false);
     $activity = [];
     $interval = 60;
     if ($lastEventId) {
         list($interval, $activity) = $this->findNewActivity($me['login'], $lastEventId);
         if ($activity) {
             $request->session()->set('last_notification_id', $activity[0]['id']);
             // Mark as read
             try {
                 GitHub::notification()->markRead();
             } catch (\Exception $e) {
                 // Github returns empty string for this endpoint but the API library tries to parse it as json
             }
             foreach ($activity as &$notice) {
                 $notice['html_url'] = $this->getRelatedHtmlUrl($notice['subject']);
             }
         }
     }
     $html = view('notifications.live', ['me' => $me, 'activity' => $activity]);
     $data = ['activity' => $html->render(), 'interval' => (int) $interval * 1000, 'count' => count($activity)];
     $response = \Illuminate\Support\Facades\Response::make(json_encode($data), 200);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
开发者ID:cdsalmons,项目名称:my-github,代码行数:27,代码来源:LiveController.php

示例6: postCreate

 public function postCreate()
 {
     // create a single model
     //
     $projectInvitation = new ProjectInvitation(array('project_uid' => Input::get('project_uid'), 'invitation_key' => GUID::create(), 'inviter_uid' => Input::get('inviter_uid'), 'invitee_name' => Input::get('invitee_name'), 'email' => Input::get('email')));
     $user = User::getByEmail(Input::get('email'));
     if ($user) {
         if (ProjectMembership::where('user_uid', '=', $user->user_uid)->where('project_uid', '=', Input::get('project_uid'))->where('delete_date', '=', null)->first()) {
             return Response::json(array('error' => array('message' => Input::get('invitee_name') . ' is already a member')), 409);
         }
     }
     $invite = ProjectInvitation::where('project_uid', '=', Input::get('project_uid'))->where('email', '=', Input::get('email'))->where('accept_date', '=', null)->where('decline_date', '=', null)->first();
     if ($invite) {
         return Response::json(array('error' => array('message' => Input::get('invitee_name') . ' already has a pending invitation')), 409);
     }
     // Model valid?
     //
     if ($projectInvitation->isValid()) {
         $projectInvitation->save();
         $projectInvitation->send(Input::get('confirm_route'), Input::get('register_route'));
         return $projectInvitation;
     } else {
         $errors = $projectInvitation->errors();
         return Response::make($errors->toJson(), 409);
     }
 }
开发者ID:pombredanne,项目名称:open-swamp,代码行数:26,代码来源:ProjectInvitationsController.php

示例7: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->filter('auth', function () {
         if (Auth::guest()) {
             if (Request::ajax()) {
                 return Response::make('Unauthorized', 401);
             } else {
                 return Redirect::guest('/');
             }
         }
     });
     $router->filter('auth.basic', function () {
         return Auth::basic();
     });
     $router->filter('guest', function () {
         if (Auth::check()) {
             return Redirect::to('/');
         }
     });
     $router->filter('admin', function () {
         if (Auth::check()) {
             if (Auth::user()->email != "ceesco53@gmail.com") {
                 return Redirect::to('/');
             }
         } else {
             return Redirect::to('/');
         }
     });
     parent::boot($router);
 }
开发者ID:siparker,项目名称:ribbbon,代码行数:36,代码来源:RouteServiceProvider.php

示例8: sendLockoutResponse

 protected function sendLockoutResponse(Request $request)
 {
     if ($request->ajax()) {
         return Response::make("Too Many Requests", 429);
     }
     return $this->traitSendLockoutResponse($request);
 }
开发者ID:MetropoliaUAS,项目名称:ISDProject-Online,代码行数:7,代码来源:AuthController.php

示例9: respondWithArray

 protected function respondWithArray(array $array, array $headers = [])
 {
     $mimeTypeRaw = Input::server('HTTP_ACCEPT', '*/*');
     // If its empty or has */* then default to JSON
     if ($mimeTypeRaw === '*/*') {
         $mimeType = 'application/json';
     } else {
         // You'll probably want to do something intelligent with charset if provided
         // This chapter just assumes UTF8 everything everywhere
         $mimeParts = (array) explode(',', $mimeTypeRaw);
         $mimeType = strtolower($mimeParts[0]);
     }
     switch ($mimeType) {
         case 'application/json':
             $contentType = 'application/json';
             $content = json_encode($array);
             break;
         case 'application/x-yaml':
             $contentType = 'application/x-yaml';
             $dumper = new YamlDumper();
             $content = $dumper->dump($array, 2);
             break;
         default:
             $contentType = 'application/json';
             $content = json_encode(['error' => ['code' => static::CODE_INVALID_MIME_TYPE, 'http_code' => 415, 'message' => sprintf('Content of type %s is not supported.', $mimeType)]]);
     }
     $response = Response::make($content, $this->statusCode, $headers);
     $response->header('Content-Type', $contentType);
     return $response;
 }
开发者ID:kife-design,项目名称:knoters,代码行数:30,代码来源:ApiController.php

示例10: putVerify

 public function putVerify($verificationKey)
 {
     $emailVerification = EmailVerification::where('verification_key', '=', $verificationKey)->first();
     $emailVerification->verify_date = new DateTime();
     $userAccount = UserAccount::where('user_uid', '=', $emailVerification->user_uid)->first();
     $user = User::getIndex($emailVerification->user_uid);
     $username = $user->username;
     $user->email = $emailVerification->email;
     unset($user->owner);
     unset($user->username);
     $errors = array();
     if ($userAccount->email_verified_flag != 1 || $user->isValid($errors)) {
         $user->username = $username;
         $user->modify();
     } else {
         $message = "This request could not be processed due to the following:<br/><br/>";
         $message .= implode('<br/>', $errors);
         $message .= "<br/><br/>If you believe this to be in error or a security issue, please contact the SWAMP immediately.";
         return Response::make($message, 500);
     }
     // automatically send welcome email iff email has never been verified
     //
     if ($userAccount->email_verified_flag != 1) {
         Mail::send('emails.welcome', array('user' => $user, 'logo' => Config::get('app.cors_url') . '/images/logos/swamp-logo-small.png', 'manual' => Config::get('app.cors_url') . '/documentation/SWAMP-UserManual.pdf'), function ($message) use($user) {
             $message->to($user->email, $user->getFullName());
             $message->subject('Welcome to the Software Assurance Marketplace');
         });
     }
     $userAccount->email_verified_flag = 1;
     $userAccount->save();
     $emailVerification->save();
     return Response::make('This email address has been verified.', 200);
 }
开发者ID:pombredanne,项目名称:open-swamp,代码行数:33,代码来源:EmailVerificationsController.php

示例11: checkBuildSystem

 function checkBuildSystem()
 {
     switch ($this->build_system) {
         case 'none':
             return Response::make("Python package ok for no build.", 200);
             break;
         case 'distutils':
             // create archive from package
             //
             $archive = new Archive($this->getPackagePath());
             $buildPath = Archive::concatPaths($this->source_path, $this->build_dir);
             $buildFile = $this->build_file;
             // search archive for build file in build path
             //
             if ($buildFile != NULL) {
                 if ($archive->contains($buildPath, $buildFile)) {
                     return Response::make("Python package build system ok for build with distutils.", 200);
                 } else {
                     return Response::make("Could not find a build file called '" . $buildFile . "' within the '" . $buildPath . "' directory. You may need to set your build path or the path to your build file.", 404);
                 }
             }
             break;
         case 'other':
             return Response::make("Python package ok for no build.", 200);
             break;
     }
 }
开发者ID:pombredanne,项目名称:open-swamp,代码行数:27,代码来源:PythonPackageVersion.php

示例12: markAcceptance

 public function markAcceptance($policyCode, $userUid)
 {
     // get inputs
     //
     $policy = Policy::where('policy_code', '=', $policyCode)->first();
     $user = User::getIndex($userUid);
     $acceptFlag = Input::has('accept_flag');
     // check inputs
     //
     if (!$user || !$policy || !$acceptFlag) {
         return Response::make('Invalid input.', 404);
     }
     // check privileges
     //
     if (!$user->isAdmin() && $user->user_uid != Session::get('user_uid')) {
         return Response::make('Insufficient privileges to mark policy acceptance.', 401);
     }
     // get or create new user policy
     //
     $userPolicy = UserPolicy::where('user_uid', '=', $userUid)->where('policy_code', '=', $policyCode)->first();
     if (!$userPolicy) {
         $userPolicy = new UserPolicy(array('user_policy_uid' => GUID::create(), 'user_uid' => $userUid, 'policy_code' => $policyCode));
     }
     $userPolicy->accept_flag = $acceptFlag;
     $userPolicy->save();
     return $userPolicy;
 }
开发者ID:pombredanne,项目名称:open-swamp,代码行数:27,代码来源:UserPoliciesController.php

示例13: response

 /**
  * Return the current response instance.
  *
  * @return Response
  */
 protected function response()
 {
     if (!isset($this->response)) {
         $this->response = Response::make();
     }
     return $this->response;
 }
开发者ID:mmanos,项目名称:laravel-api,代码行数:12,代码来源:ControllerTrait.php

示例14: deleted

 /**
  * Return a new "deleted" response object
  *
  * @param  array|object $object
  * @return Response
  */
 public function deleted($object = null)
 {
     if ($object != null) {
         return Response::json($object, 200);
     } else {
         return Response::make(null, 204);
     }
 }
开发者ID:estebanprimost,项目名称:laravel-api-handler,代码行数:14,代码来源:ApiHandler.php

示例15: suggestAction

 /**
  * Returns the view for the XHR response with the product information for the search suggestion.
  *
  * @return Response Response object containing the generated output
  */
 public function suggestAction()
 {
     $params = app('Aimeos\\Shop\\Base\\Page')->getSections('catalog-suggest');
     $contents = View::make('shop::catalog.suggest', $params);
     $response = Response::make($contents, 200);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
开发者ID:leoclaro,项目名称:aimeos-laravel,代码行数:13,代码来源:CatalogController.php


注:本文中的Illuminate\Support\Facades\Response::make方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。