replace() public static method

Replace the input for the current request.
public static replace ( array $input ) : void
$input array
return void
Example #1
0
 public function analyse()
 {
     $query = Input::get('q');
     $analysisData = new stdClass();
     $analysisData->keyword = $query;
     $analysisData->posts = array();
     $analysisData->tools = array('all');
     $postsRetrievers = array(new FacebookPostsRetriever(), new TwitterPostsRetriever());
     foreach ($postsRetrievers as $postsRetriever) {
         $posts = $postsRetriever->retrieve($query, null);
         $analysisData->posts = array_merge($analysisData->posts, $posts);
     }
     $analysisDataJSON = json_encode($analysisData);
     //        $response = Unirest::post("http://service/analyzer",
     //			array( "Accept" => "application/json" ),
     //			array('query' => $analysisDataJSON)
     //        );
     $request = Request::create('/service/analyzer', 'POST', array('query' => $analysisDataJSON));
     Request::replace($request->input());
     $response = Route::dispatch($request)->getContent();
     //		$analysisResult = json_decode($response->raw_body);
     $analysisResult = json_decode($response);
     foreach ($analysisResult->posts as $post) {
         foreach ($analysisData->posts as $postData) {
             if ($postData['id'] == $post->id) {
                 $post->data = $postData;
                 break;
             }
         }
     }
     return View::make('AnalysisResult')->with('analysisResult', $analysisResult);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $request = Request::create('/api/blocknotify', 'GET', array('secret' => !$this->option('secret') ? Config::get('bitcoin.callback_secret') : $this->option('secret'), 'blockhash' => $this->option('blockhash')));
     Request::replace($request->input());
     $response = Route::dispatch($request)->getContent();
     if ($this->option('debug')) {
         $this->info($response);
     }
 }
 public function testLogin_ok()
 {
     $this->createAndSeedTestingDb();
     $sr = \Mockery::mock(SR::class)->makePartial();
     $ac = new AC($sr);
     $sr->shouldReceive('create')->andReturn(149);
     \Request::replace(['username' => 'user', 'password' => 'pass']);
     $r = $ac->login();
     $this->assertInstanceOf(JsonResponse::class, $r);
     $this->assertSame(149, $r->getData());
 }
 public function testUpdateNoHash()
 {
     $faker = Faker\Factory::create();
     $email = $faker->email;
     $user = \Distilleries\Expendable\Models\User::create(['email' => $email, 'password' => \Hash::make('test'), 'status' => true, 'role_id' => 1]);
     \Distilleries\Expendable\Models\User::observe(new \Distilleries\Expendable\Observers\PasswordObserver());
     $user = \Distilleries\Expendable\Models\User::find($user->id);
     \Request::replace(['password' => 'newpassword']);
     $user->update(['name' => $faker->name, 'password' => 'newpassword']);
     $this->assertTrue(\Hash::check('newpassword', $user->password));
 }
Example #5
0
 /** @test */
 function it_registers_request_params()
 {
     $supporter = $this->getSupporter();
     $this->assertNull($supporter->getCurrentKey());
     $this->assertNull($supporter->getCurrentDirection());
     // Populate request
     \Request::replace(array_merge(\Request::input(), ['s' => 'created_at', 'd' => 'desc']));
     $this->assertEquals('created_at', Request::input('s'));
     $this->assertEquals('desc', Request::input('d'));
     SortableItem::sortable();
     $this->assertEquals('created_at', $supporter->getCurrentKey());
     $this->assertEquals('desc', $supporter->getCurrentDirection());
 }
 public function release($url, $method = 'GET', $input, $no_json)
 {
     // Store the original input of the request
     $originalInput = \Request::input();
     // Create request to the API, adding the no-json parameter, since it's an internal request
     $request = \Request::create($url, $method);
     // Replace the input with the request instance input
     \Request::replace($input);
     // Fetch the response
     if ($no_json) {
         $content = \Route::dispatch($request)->getContent();
         $result = json_decode($content, 1);
     } else {
         $result = \Route::dispatch($request)->getContent();
     }
     // Replace the input again with the original request input.
     \Request::replace($originalInput);
     return $result;
 }
 protected function seedWithRequest($http_type, $uri, array $params)
 {
     $request = Request::create($uri, $http_type, $params);
     // Replace the input with your request instance input
     Request::replace($request->input());
     Route::dispatch($request)->getContent();
 }
Example #8
0
    $api->get('topic', ['as' => 'topic.index', 'uses' => 'TopicController@index']);
    $api->post('topic', ['as' => 'topic.store', 'uses' => 'TopicController@store']);
    $api->match(['put', 'patch'], 'topic/{topic}', ['as' => 'topic.update', 'uses' => 'TopicController@update']);
    $api->delete('topic/{topic}', ['as' => 'topic.destroy', 'uses' => 'TopicController@destroy']);
    $api->get('user/me', ['middleware' => ['oauth'], 'uses' => 'UserController@me']);
    $api->post('reply', ['as' => 'reply.store', 'uses' => 'ReplyController@store']);
    $api->delete('reply/{reply}', ['as' => 'reply.destroy', 'uses' => 'ReplyController@destroy']);
});
$api->group(['version' => 'v1', 'namespace' => 'Imojie\\Http\\ApiControllers'], function ($api) {
    $api->post('login', ['as' => 'login', 'uses' => 'UserController@login']);
    $api->post('oauth/access_token', ['as' => 'access_token', function () {
        return \Authorizer::issueAccessToken();
    }]);
    $api->post('oauth/refresh_token', ['as' => 'refresh_token', function () {
        $input = ['grant_type' => 'refresh_token', 'refresh_token' => \Request::input('refresh_token', ''), 'client_id' => env('OAUTH_CLIENT_ID'), 'client_secret' => env('OAUTH_CLIENT_SECRET')];
        \Request::replace($input);
        return \Authorizer::issueAccessToken();
    }]);
});
// 首页
Route::get('/', function () {
    return view('page.index');
});
Route::post('oauth/access_token', function () {
    return Response::json(Authorizer::issueAccessToken());
});
Route::get('testOAuth', ['middleware' => ['oauth', 'oauth-client'], 'uses' => 'TestController@testOAuth']);
// 注册
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', 'Auth\\AuthController@postRegister');
Route::get('auth/registered', 'Auth\\AuthController@getRegistered');