setBaseUrl() public method

public setBaseUrl ( $baseUrl )
Exemplo n.º 1
0
 /**
  * @param Request $request
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function handle(Request $request)
 {
     $input = $request->getParsedBody();
     $data = new DefaultsDataProvider();
     $data->setDatabaseConfiguration(['driver' => 'mysql', 'host' => array_get($input, 'mysqlHost'), 'database' => array_get($input, 'mysqlDatabase'), 'username' => array_get($input, 'mysqlUsername'), 'password' => array_get($input, 'mysqlPassword'), 'prefix' => array_get($input, 'tablePrefix')]);
     $data->setAdminUser(['username' => array_get($input, 'adminUsername'), 'password' => array_get($input, 'adminPassword'), 'password_confirmation' => array_get($input, 'adminPasswordConfirmation'), 'email' => array_get($input, 'adminEmail')]);
     $baseUrl = rtrim((string) $request->getAttribute('originalUri'), '/');
     $data->setBaseUrl($baseUrl);
     $data->setSetting('forum_title', array_get($input, 'forumTitle'));
     $data->setSetting('mail_from', 'noreply@' . preg_replace('/^www\\./i', '', parse_url($baseUrl, PHP_URL_HOST)));
     $data->setSetting('welcome_title', 'Welcome to ' . array_get($input, 'forumTitle'));
     $body = fopen('php://temp', 'wb+');
     $input = new StringInput('');
     $output = new StreamOutput($body);
     $this->command->setDataSource($data);
     try {
         $this->command->run($input, $output);
     } catch (Exception $e) {
         return new HtmlResponse($e->getMessage(), 500);
     }
     $session = $request->getAttribute('session');
     $this->authenticator->logIn($session, 1);
     return new Response($body);
 }
Exemplo n.º 2
0
 /**
  * @param Request $request
  * @param array $routeParams
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function handle(Request $request, array $routeParams = [])
 {
     $input = $request->getParsedBody();
     $data = new DefaultsDataProvider();
     $data->setDatabaseConfiguration(['driver' => 'mysql', 'host' => array_get($input, 'mysqlHost'), 'database' => array_get($input, 'mysqlDatabase'), 'username' => array_get($input, 'mysqlUsername'), 'password' => array_get($input, 'mysqlPassword'), 'prefix' => array_get($input, 'tablePrefix')]);
     $data->setAdminUser(['username' => array_get($input, 'adminUsername'), 'password' => array_get($input, 'adminPassword'), 'password_confirmation' => array_get($input, 'adminPasswordConfirmation'), 'email' => array_get($input, 'adminEmail')]);
     $baseUrl = rtrim((string) $request->getAttribute('originalUri'), '/');
     $data->setBaseUrl($baseUrl);
     $data->setSetting('forum_title', array_get($input, 'forumTitle'));
     $data->setSetting('mail_from', 'noreply@' . preg_replace('/^www\\./i', '', parse_url($baseUrl, PHP_URL_HOST)));
     $data->setSetting('welcome_title', 'Welcome to ' . array_get($input, 'forumTitle'));
     $body = fopen('php://temp', 'wb+');
     $input = new StringInput('');
     $output = new StreamOutput($body);
     $this->command->setDataSource($data);
     try {
         $this->command->run($input, $output);
     } catch (Exception $e) {
         return new JsonResponse(['error' => $e->getMessage()], 500);
     }
     $token = $this->bus->dispatch(new GenerateAccessToken(1));
     $token->update(['expires_at' => new DateTime('+2 weeks')]);
     return $this->withRememberCookie(new Response($body, 200), $token->id);
 }