These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace enigmatix\confirmation; |
||
4 | |||
5 | use yii\web\Controller; |
||
6 | use Yii; |
||
7 | use enigmatix\confirmation\ConfirmationRequest; |
||
8 | use yii\base\ErrorException; |
||
9 | use yii\web\NotFoundHttpException; |
||
10 | use yii\filters\VerbFilter; |
||
11 | |||
12 | /** |
||
13 | * ConfirmationRequestsController implements the CRUD actions for ConfirmationRequest model. |
||
14 | */ |
||
15 | class ConfirmationRequestsController extends Controller |
||
16 | { |
||
17 | |||
18 | var $defaultAction = 'release'; |
||
0 ignored issues
–
show
|
|||
19 | /** |
||
20 | * @inheritdoc |
||
21 | */ |
||
22 | public function behaviors() |
||
23 | { |
||
24 | return [ |
||
25 | 'verbs' => [ |
||
26 | 'class' => VerbFilter::className(), |
||
27 | 'actions' => [ |
||
28 | 'delete' => ['POST'], |
||
29 | ], |
||
30 | ], |
||
31 | ]; |
||
32 | } |
||
33 | |||
34 | |||
35 | /** |
||
36 | * Releases a single change as stored in the ConfirmationRequest model. |
||
37 | * @param integer $id |
||
0 ignored issues
–
show
There is no parameter named
$id . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
38 | * @return mixed |
||
39 | */ |
||
40 | public function actionRelease($release_token) |
||
41 | { |
||
42 | |||
43 | try{ |
||
44 | $model = $this->findModel($release_token); |
||
45 | } catch (NotFoundHttpException $e){ |
||
46 | Yii::$app->session->setFlash('danger' , "We were not able to find your change. Perhaps it has already been processed?"); |
||
47 | return $this->goHome(); |
||
48 | } |
||
49 | |||
50 | try{ |
||
51 | $model->release(); |
||
52 | } catch (ErrorException $e){ |
||
53 | return $this->redirect(['confirmation-requests/expired']); |
||
54 | } |
||
55 | |||
56 | $viewLink = $model->constructObject()->getViewLink(); |
||
57 | $model->delete(); |
||
58 | |||
59 | if(!Yii::$app->user->isGuest){ |
||
60 | return $this->redirect($viewLink); |
||
61 | } |
||
62 | |||
63 | return $this->render('@vendor/enigmatix/yii2-confirmation/views/confirm', []); |
||
64 | } |
||
65 | |||
66 | public function actionExpired(){ |
||
67 | return $this->render('@vendor/enigmatix/yii2-confirmation/views/expired', []); |
||
68 | |||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Finds the ConfirmationRequest model based on its primary key value. |
||
73 | * If the model is not found, a 404 HTTP exception will be thrown. |
||
74 | * @param integer $id |
||
0 ignored issues
–
show
There is no parameter named
$id . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
75 | * @return ConfirmationRequest the loaded model |
||
76 | * @throws NotFoundHttpException if the model cannot be found |
||
77 | */ |
||
78 | protected function findModel($release_token) |
||
79 | { |
||
80 | if (($model = ConfirmationRequest::findOne(['release_token' => $release_token])) !== null) { |
||
81 | return $model; |
||
82 | } else { |
||
83 | throw new NotFoundHttpException('The requested page does not exist.'); |
||
84 | } |
||
85 | } |
||
86 | } |
||
87 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.