Skip to content

Commit b2f47b3

Browse files
committed
Changed renderView method name to simply view per comments.
1 parent 32e4bcd commit b2f47b3

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

docs/customization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class LoginController extends ShieldLogin
9393

9494
## Integrating Custom View Libraries
9595

96-
If your application uses a different method to convert view files to HTML than CodeIgniter's built-in `view()` helper you can easily integrate your system anywhere that a view is rendered within Shield. All controllers and actions use the `CodeIgniter\Shield\Traits\Viewable` trait which provides a simple `renderView()` method that takes the same arguments as the `view()` helper. This allows you to extend the Action or Controller and only change the single method of rendering the view, leaving all of the logic untouched so your app will not need to maintain Shield logic when it doesn't need to change it.
96+
If your application uses a different method to convert view files to HTML than CodeIgniter's built-in `view()` helper you can easily integrate your system anywhere that a view is rendered within Shield. All controllers and actions use the `CodeIgniter\Shield\Traits\Viewable` trait which provides a simple `view()` method that takes the same arguments as the `view()` helper. This allows you to extend the Action or Controller and only change the single method of rendering the view, leaving all of the logic untouched so your app will not need to maintain Shield logic when it doesn't need to change it.
9797

9898
```php
9999
use Acme\Themes\Traits\Themeable;

src/Authentication/Actions/Email2FA.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function show(): string
4141

4242
$this->createIdentity($user);
4343

44-
return $this->renderView(setting('Auth.views')['action_email_2fa'], ['user' => $user]);
44+
return $this->view(setting('Auth.views')['action_email_2fa'], ['user' => $user]);
4545
}
4646

4747
/**
@@ -84,7 +84,7 @@ public function handle(IncomingRequest $request)
8484
$email = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? '');
8585
$email->setTo($user->email);
8686
$email->setSubject(lang('Auth.email2FASubject'));
87-
$email->setMessage($this->renderView(setting('Auth.views')['action_email_2fa_email'], ['code' => $identity->secret, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date]));
87+
$email->setMessage($this->view(setting('Auth.views')['action_email_2fa_email'], ['code' => $identity->secret, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date]));
8888

8989
if ($email->send(false) === false) {
9090
throw new RuntimeException('Cannot send email for user: ' . $user->email . "\n" . $email->printDebugger(['headers']));
@@ -93,7 +93,7 @@ public function handle(IncomingRequest $request)
9393
// Clear the email
9494
$email->clear();
9595

96-
return $this->renderView(setting('Auth.views')['action_email_2fa_verify']);
96+
return $this->view(setting('Auth.views')['action_email_2fa_verify']);
9797
}
9898

9999
/**
@@ -119,7 +119,7 @@ public function verify(IncomingRequest $request)
119119
if (! $authenticator->checkAction($identity, $postedToken)) {
120120
session()->setFlashdata('error', lang('Auth.invalid2FAToken'));
121121

122-
return $this->renderView(setting('Auth.views')['action_email_2fa_verify']);
122+
return $this->view(setting('Auth.views')['action_email_2fa_verify']);
123123
}
124124

125125
// Get our login redirect url

src/Authentication/Actions/EmailActivator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function show(): string
5858
$email = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? '');
5959
$email->setTo($userEmail);
6060
$email->setSubject(lang('Auth.emailActivateSubject'));
61-
$email->setMessage($this->renderView(setting('Auth.views')['action_email_activate_email'], ['code' => $code, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date]));
61+
$email->setMessage($this->view(setting('Auth.views')['action_email_activate_email'], ['code' => $code, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date]));
6262

6363
if ($email->send(false) === false) {
6464
throw new RuntimeException('Cannot send email for user: ' . $user->email . "\n" . $email->printDebugger(['headers']));
@@ -68,7 +68,7 @@ public function show(): string
6868
$email->clear();
6969

7070
// Display the info page
71-
return $this->renderView(setting('Auth.views')['action_email_activate_show'], ['user' => $user]);
71+
return $this->view(setting('Auth.views')['action_email_activate_show'], ['user' => $user]);
7272
}
7373

7474
/**
@@ -105,7 +105,7 @@ public function verify(IncomingRequest $request)
105105
if (! $authenticator->checkAction($identity, $postedToken)) {
106106
session()->setFlashdata('error', lang('Auth.invalidActivateToken'));
107107

108-
return $this->renderView(setting('Auth.views')['action_email_activate_show']);
108+
return $this->view(setting('Auth.views')['action_email_activate_show']);
109109
}
110110

111111
$user = $authenticator->getUser();

src/Controllers/LoginController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function loginView()
3434
return redirect()->route('auth-action-show');
3535
}
3636

37-
return $this->renderView(setting('Auth.views')['login']);
37+
return $this->view(setting('Auth.views')['login']);
3838
}
3939

4040
/**

src/Controllers/MagicLinkController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function loginView()
5151
return redirect()->to(config('Auth')->loginRedirect());
5252
}
5353

54-
return $this->renderView(setting('Auth.views')['magic-link-login']);
54+
return $this->view(setting('Auth.views')['magic-link-login']);
5555
}
5656

5757
/**
@@ -105,7 +105,7 @@ public function loginAction()
105105
$email = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? '');
106106
$email->setTo($user->email);
107107
$email->setSubject(lang('Auth.magicLinkSubject'));
108-
$email->setMessage($this->renderView(setting('Auth.views')['magic-link-email'], ['token' => $token, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date]));
108+
$email->setMessage($this->view(setting('Auth.views')['magic-link-email'], ['token' => $token, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date]));
109109

110110
if ($email->send(false) === false) {
111111
log_message('error', $email->printDebugger(['headers']));
@@ -124,7 +124,7 @@ public function loginAction()
124124
*/
125125
protected function displayMessage(): string
126126
{
127-
return $this->renderView(setting('Auth.views')['magic-link-message']);
127+
return $this->view(setting('Auth.views')['magic-link-message']);
128128
}
129129

130130
/**

src/Controllers/RegisterController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function registerView()
5050
return redirect()->route('auth-action-show');
5151
}
5252

53-
return $this->renderView(setting('Auth.views')['register']);
53+
return $this->view(setting('Auth.views')['register']);
5454
}
5555

5656
/**

src/Traits/Viewable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait Viewable
1111
* the way the view gets converted to HTML to integrate with their
1212
* own templating systems.
1313
*/
14-
protected function renderView(string $view, array $data = [], array $options = []): string
14+
protected function view(string $view, array $data = [], array $options = []): string
1515
{
1616
return view($view, $data, $options);
1717
}

0 commit comments

Comments
 (0)