Skip to content

Commit 21dafe0

Browse files
committed
Merge remote-tracking branch 'origin/master' into step-0.1
2 parents 4414d5f + af84790 commit 21dafe0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scripts/steps/step-000.3.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ class AccessOnce extends Behavior
321321
{
322322
$owner = $this->owner;
323323
324-
if ($owner instanceof Controller) {
324+
if ($owner instanceof \yii\web\Controller) {
325325
return [
326326
$owner::EVENT_BEFORE_ACTION => 'имя_обработчика',
327327
$owner::EVENT_AFTER_ACTION => 'имя_обработчика',
@@ -337,7 +337,7 @@ class AccessOnce extends Behavior
337337
EVENT_BEFORE_ACTION и EVENT_AFTER_ACTION у этих объектов может и не быть. Поэтому вводим дополнительную проверку
338338

339339
```php
340-
if ($owner instanceof Controller) {
340+
if ($owner instanceof \yii\web\Controller) {
341341
```
342342

343343
которая ограничит неверное использование поведения AccessOnce.
@@ -414,7 +414,7 @@ class AccessOnce extends Behavior
414414
{
415415
if (in_array($event->action->id, $this->actions, true)) {
416416
if (\Yii::$app->session->get($event->action->id . '-access-lock') !== null) {
417-
throw new HttpException(403, $this->message);
417+
throw new \yii\web\HttpException(403, $this->message);
418418
}
419419
}
420420
}
@@ -424,15 +424,15 @@ class AccessOnce extends Behavior
424424
При срабатывании
425425

426426
```php
427-
throw new HttpException(403, $this->message);
427+
throw new \yii\web\HttpException(403, $this->message);
428428
```
429429

430430
пользователя перекинет на `/index.php?r=site/error`. Самостоятельно попробуйте разобраться как сработает `site/error`.
431431

432432
После всего сделанного, в итоге имеем:
433433

434434
```php
435-
class SiteController extends Controller
435+
class SiteController extends \yii\web\Controller
436436
{
437437
public function behaviors()
438438
{
@@ -454,7 +454,7 @@ class AccessOnce extends Behavior
454454
{
455455
$owner = $this->owner;
456456

457-
if ($owner instanceof Controller) {
457+
if ($owner instanceof \yii\web\Controller) {
458458
return [
459459
$owner::EVENT_BEFORE_ACTION => 'checkAccess',
460460
$owner::EVENT_AFTER_ACTION => 'closeDoor',

0 commit comments

Comments
 (0)