@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $this->container = new \yii\di\Container; |
| 89 | 89 | $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser'); |
| 90 | 90 | $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior'); |
| 91 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
| 91 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
| 92 | 92 | return new \common\components\Time('America/Los_Angeles'); |
| 93 | 93 | }); |
| 94 | 94 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | public function testIsTokenCurrent() { |
| 137 | - $this->specify('isTokenCurrent should function correctly', function () { |
|
| 137 | + $this->specify('isTokenCurrent should function correctly', function() { |
|
| 138 | 138 | $good_token = \Yii::$app |
| 139 | 139 | ->getSecurity() |
| 140 | 140 | ->generateRandomString() . '_' . time(); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | public function testConfirmVerifyEmailToken() { |
| 169 | 169 | $this->user->verify_email_token = 'hello_world'; |
| 170 | 170 | $this->user->confirmVerifyEmailToken(); |
| 171 | - expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world'.$this->user::CONFIRMED_STRING)); |
|
| 171 | + expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world' . $this->user::CONFIRMED_STRING)); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | public function testIsVerified() { |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | ->disableOriginalConstructor() |
| 263 | 263 | ->setMethods(['save', 'attributes', 'getCheckinBreakdown']) |
| 264 | 264 | ->getMock(); |
| 265 | - $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php'); |
|
| 265 | + $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php'); |
|
| 266 | 266 | $user_behavior->method('getCheckinBreakdown')->willReturn($expected); |
| 267 | 267 | |
| 268 | 268 | $user = $this->getMockBuilder(User::class) |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | 'allow' => true, |
| 28 | 28 | 'roles' => ['@'], |
| 29 | 29 | ], [ |
| 30 | - 'actions' => [ 'change-email', ], |
|
| 30 | + 'actions' => ['change-email', ], |
|
| 31 | 31 | 'allow' => true, |
| 32 | 32 | ], |
| 33 | 33 | ], |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | if ($editProfileForm->load(Yii::$app->request->post())) { |
| 60 | 60 | $saved_user = $editProfileForm->saveProfile(); |
| 61 | - if($saved_user) { |
|
| 61 | + if ($saved_user) { |
|
| 62 | 62 | Yii::$app->session->setFlash('success', 'New profile data saved!'); |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $model = Yii::$container->get(\site\models\DeleteAccountForm::class, [Yii::$app->user->identity]); |
| 79 | 79 | |
| 80 | 80 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
| 81 | - if($model->deleteAccount()) { |
|
| 81 | + if ($model->deleteAccount()) { |
|
| 82 | 82 | $this->redirect(['site/index']); |
| 83 | 83 | } else { |
| 84 | 84 | Yii::$app->session->setFlash('error', 'Wrong password!'); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $model = Yii::$container->get(\site\models\ChangePasswordForm::class, [Yii::$app->user->identity]); |
| 93 | 93 | |
| 94 | 94 | if ($model->load(Yii::$app->request->post())) { |
| 95 | - if($model->validate() && $model->changePassword()) { |
|
| 95 | + if ($model->validate() && $model->changePassword()) { |
|
| 96 | 96 | Yii::$app->session->setFlash('success', 'Password successfully changed'); |
| 97 | 97 | } else { |
| 98 | 98 | Yii::$app->session->setFlash('error', 'Wrong password!'); |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | public function actionChangeEmail(string $token) { |
| 117 | 117 | $user = Yii::$container->get(\common\interfaces\UserInterface::class)->findByChangeEmailToken($token); |
| 118 | 118 | |
| 119 | - if($user) { |
|
| 119 | + if ($user) { |
|
| 120 | 120 | $validator = new \yii\validators\EmailValidator(); |
| 121 | - if($validator->validate($user->desired_email, $error)) { |
|
| 121 | + if ($validator->validate($user->desired_email, $error)) { |
|
| 122 | 122 | $user->removeChangeEmailToken(); |
| 123 | 123 | $user->email = $user->desired_email; |
| 124 | 124 | $user->desired_email = null; |
| 125 | 125 | $user->save(); |
| 126 | - if(!Yii::$app->user->isGuest) { |
|
| 126 | + if (!Yii::$app->user->isGuest) { |
|
| 127 | 127 | Yii::$app->user->logout(); |
| 128 | 128 | Yii::$app->session->setFlash('success', 'Your email address was successfully changed. For security, we\'ve logged you out.'); |
| 129 | 129 | } else { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | public function actionExport() { |
| 145 | 145 | header("Content-Type: text/csv"); |
| 146 | - header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv"); |
|
| 146 | + header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv"); |
|
| 147 | 147 | |
| 148 | 148 | $reader = Yii::$app->user->identity->getExportData(); |
| 149 | 149 | $fp = fopen('php://output', 'w'); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | fputcsv($fp, $header); |
| 161 | 161 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); |
| 162 | - while($row = $reader->read()) { |
|
| 162 | + while ($row = $reader->read()) { |
|
| 163 | 163 | $row = $user_behavior::decorate([$row]); |
| 164 | 164 | $row = Yii::$app->user->identity->cleanExportRow($row[0]); |
| 165 | 165 | fputcsv($fp, $row); |
@@ -157,15 +157,15 @@ |
||
| 157 | 157 | |
| 158 | 158 | public function setUp() { |
| 159 | 159 | $this->question = $this->getMockBuilder('\common\models\Question') |
| 160 | - ->setMethods(['save', 'attributes']) |
|
| 161 | - ->getMock(); |
|
| 160 | + ->setMethods(['save', 'attributes']) |
|
| 161 | + ->getMock(); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | public function testParseQuestionData() { |
| 165 | 165 | $questions = array_map(function ($d) { |
| 166 | 166 | $q = $this->getMockBuilder('\common\models\Question') |
| 167 | - ->setMethods(['save', 'attributes']) |
|
| 168 | - ->getMock(); |
|
| 167 | + ->setMethods(['save', 'attributes']) |
|
| 168 | + ->getMock(); |
|
| 169 | 169 | $q->method('save')->willReturn(true); |
| 170 | 170 | $q->method('attributes') |
| 171 | 171 | ->willReturn([ |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | public function testParseQuestionData() { |
| 165 | - $questions = array_map(function ($d) { |
|
| 165 | + $questions = array_map(function($d) { |
|
| 166 | 166 | $q = $this->getMockBuilder('\common\models\Question') |
| 167 | 167 | ->setMethods(['save', 'attributes']) |
| 168 | 168 | ->getMock(); |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | 'date', |
| 180 | 180 | 'userBehavior', |
| 181 | 181 | ]); |
| 182 | - foreach($d as $k => $v) { |
|
| 183 | - if($k === 'behavior_id' && $v === null) { |
|
| 182 | + foreach ($d as $k => $v) { |
|
| 183 | + if ($k === 'behavior_id' && $v === null) { |
|
| 184 | 184 | $ub = new \StdClass(); |
| 185 | 185 | $ub->custom_behavior = 'some_custom_behavior'; |
| 186 | 186 | $q->userBehavior = $ub; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | ->groupBy('date, user_id') |
| 93 | 93 | ->having('user_id = :user_id'); |
| 94 | 94 | $temp_dates = $query->all(); |
| 95 | - foreach($temp_dates as $temp_date) { |
|
| 95 | + foreach ($temp_dates as $temp_date) { |
|
| 96 | 96 | $past_checkin_dates[] = $this->time->convertUTCToLocal($temp_date['date']); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | public function getCheckinBreakdown(int $period = 30) { |
| 123 | 123 | $datetimes = $this->time->getDateTimesInPeriod($period); |
| 124 | - $key = "checkins_".Yii::$app->user->id."_{$period}_".$this->time->getLocalDate(); |
|
| 124 | + $key = "checkins_" . Yii::$app->user->id . "_{$period}_" . $this->time->getLocalDate(); |
|
| 125 | 125 | $checkins = Yii::$app->cache->get($key); |
| 126 | 126 | |
| 127 | - if($checkins === false) { |
|
| 127 | + if ($checkins === false) { |
|
| 128 | 128 | $checkins = []; |
| 129 | - foreach($datetimes as $datetime) { |
|
| 129 | + foreach ($datetimes as $datetime) { |
|
| 130 | 130 | $behaviors = self::decorate($this->getBehaviorsWithCounts($datetime)); |
| 131 | 131 | $checkins[$datetime->format('Y-m-d')] = $this->getBehaviorsByCategory($behaviors); |
| 132 | 132 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | public function getBehaviorsByCategory(array $decorated_behaviors) { |
| 153 | 153 | $arr = array_reduce($decorated_behaviors, function($acc, $row) { |
| 154 | 154 | $cat_id = $row['category_id']; |
| 155 | - if(array_key_exists($cat_id, $acc)) { |
|
| 155 | + if (array_key_exists($cat_id, $acc)) { |
|
| 156 | 156 | $acc[$cat_id]['count'] += $row['count']; |
| 157 | 157 | } else { |
| 158 | 158 | $acc[$cat_id] = [ |
@@ -184,11 +184,11 @@ discard block |
||
| 184 | 184 | ->having('user_id = :user_id') |
| 185 | 185 | ->orderBy('count DESC'); |
| 186 | 186 | |
| 187 | - if($limit instanceof \DateTime) { |
|
| 187 | + if ($limit instanceof \DateTime) { |
|
| 188 | 188 | list($start, $end) = $this->time->getUTCBookends($limit->format('Y-m-d')); |
| 189 | 189 | $query->params += [':start_date' => $start, ':end_date' => $end]; |
| 190 | 190 | $query->where('user_id=:user_id AND date > :start_date AND date <= :end_date'); |
| 191 | - } else if(is_int($limit)) { |
|
| 191 | + } else if (is_int($limit)) { |
|
| 192 | 192 | $query->limit($limit); |
| 193 | 193 | } |
| 194 | 194 | return $query->all(); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | 204 | public function getByDate(int $user_id, $local_date = null) { |
| 205 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 205 | + if (is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 206 | 206 | |
| 207 | 207 | $behaviors = $this->getBehaviorData($user_id, $local_date); |
| 208 | 208 | $behaviors = self::decorate($behaviors); |
@@ -215,13 +215,13 @@ discard block |
||
| 215 | 215 | * @return an array of decorated UserBehaviors, each with an added Category and Behavior |
| 216 | 216 | */ |
| 217 | 217 | public static function decorate(array $uo) { |
| 218 | - foreach($uo as &$o) { |
|
| 218 | + foreach ($uo as &$o) { |
|
| 219 | 219 | $behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id']); |
| 220 | 220 | $category = \common\models\Category::getCategory('id', $o['category_id']); |
| 221 | - if($behavior) { |
|
| 221 | + if ($behavior) { |
|
| 222 | 222 | $o['behavior'] = $behavior; |
| 223 | 223 | } |
| 224 | - if($category) { |
|
| 224 | + if ($category) { |
|
| 225 | 225 | $o['category'] = $category; |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | // TODO: this should probably be a private method...but unit testing is hard |
| 249 | 249 | public function parseBehaviorData($behaviors) { |
| 250 | - if(!$behaviors) return []; |
|
| 250 | + if (!$behaviors) return []; |
|
| 251 | 251 | |
| 252 | 252 | $bhvrs_by_cat = []; |
| 253 | - foreach($behaviors as $behavior) { |
|
| 253 | + foreach ($behaviors as $behavior) { |
|
| 254 | 254 | $indx = $behavior['category_id']; |
| 255 | 255 | |
| 256 | 256 | $bname = AH::getValue($behavior, 'behavior.name', AH::getValue($behavior, 'custom_behavior')); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public function __construct(QuestionInterface $question, |
| 54 | 54 | $config = []) { |
| 55 | - $this->question = $question; |
|
| 55 | + $this->question = $question; |
|
| 56 | 56 | parent::__construct($config); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | 'whenClient' => "function(attribute, value) { return false; }", // lame, but acceptable |
| 71 | 71 | "message" => "You must select a behavior your responses apply to."], |
| 72 | 72 | |
| 73 | - [['answer_1a','answer_1b','answer_1c','answer_2a','answer_2b','answer_2c','answer_3a','answer_3b','answer_3c','answer_4a','answer_4b','answer_4c','answer_5a', 'answer_5b','answer_5c','answer_6a', 'answer_6b','answer_6c','answer_7a','answer_7b','answer_7c'], 'safe'] |
|
| 73 | + [['answer_1a', 'answer_1b', 'answer_1c', 'answer_2a', 'answer_2b', 'answer_2c', 'answer_3a', 'answer_3b', 'answer_3c', 'answer_4a', 'answer_4b', 'answer_4c', 'answer_5a', 'answer_5b', 'answer_5c', 'answer_6a', 'answer_6b', 'answer_6c', 'answer_7a', 'answer_7b', 'answer_7c'], 'safe'] |
|
| 74 | 74 | ]; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | public function getBhvrValidator() { |
| 90 | 90 | return function($model, $attr) { |
| 91 | - $attrNum = $attr[strlen($attr)-1]; |
|
| 92 | - foreach(['a', 'b', 'c'] as $l) { |
|
| 91 | + $attrNum = $attr[strlen($attr) - 1]; |
|
| 92 | + foreach (['a', 'b', 'c'] as $l) { |
|
| 93 | 93 | $attr = "answer_{$attrNum}{$l}"; |
| 94 | - if($model->$attr) return true; |
|
| 94 | + if ($model->$attr) return true; |
|
| 95 | 95 | } |
| 96 | 96 | return false; |
| 97 | 97 | }; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | public function getPrefixProps($prefix) { |
| 124 | 124 | return array_filter(get_object_vars($this), function($v, $k) use($prefix) { |
| 125 | - if(strpos($k, $prefix) === 0 && strlen($v)) { |
|
| 125 | + if (strpos($k, $prefix) === 0 && strlen($v)) { |
|
| 126 | 126 | return true; |
| 127 | 127 | } |
| 128 | 128 | }, ARRAY_FILTER_USE_BOTH); |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | public function getAnswers($bhvrs) { |
| 141 | 141 | $answers = []; |
| 142 | 142 | $user_bhvrs = array_combine($this->getUserBehaviorProps(), $bhvrs); |
| 143 | - foreach($user_bhvrs as $property => $user_bhvr) { |
|
| 143 | + foreach ($user_bhvrs as $property => $user_bhvr) { |
|
| 144 | 144 | $behavior_id = intval(substr($property, -1, 1)); |
| 145 | - foreach($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) { |
|
| 145 | + foreach ($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) { |
|
| 146 | 146 | $question_id = \common\models\Question::$TYPES[$answer_letter]; |
| 147 | 147 | array_push($answers, [ |
| 148 | 148 | 'behavior_id' => $user_bhvr->behavior_id, |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | public function saveAnswers(int $user_id, array $bhvrs) { |
| 160 | 160 | $result = true; |
| 161 | 161 | |
| 162 | - foreach($this->getAnswers($bhvrs) as $answer) { |
|
| 162 | + foreach ($this->getAnswers($bhvrs) as $answer) { |
|
| 163 | 163 | $model = Yii::$container->get(\common\interfaces\QuestionInterface::class); |
| 164 | 164 | $model->user_id = $user_id; |
| 165 | 165 | $model->behavior_id = $answer['behavior_id']; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $model->date = new Expression("now()::timestamp"); |
| 169 | 169 | $model->question = $answer['question_id']; |
| 170 | 170 | $model->answer = $answer['answer']; |
| 171 | - if(!$model->save()) { |
|
| 171 | + if (!$model->save()) { |
|
| 172 | 172 | $result = false; |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | public function actionIndex() { |
| 38 | 38 | $form = Yii::$container->get(\site\models\CheckinForm::class); |
| 39 | 39 | if ($form->load(Yii::$app->request->post()) && $form->validate()) { |
| 40 | - if(!$form->compileBehaviors()) { |
|
| 40 | + if (!$form->compileBehaviors()) { |
|
| 41 | 41 | return $this->redirect(['view']); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | return $this->redirect(['questions']); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $behaviors = Yii::$container->get(BehaviorInterface::class)::$behaviors; |
|
| 51 | + $behaviors = Yii::$container->get(BehaviorInterface::class)::$behaviors; |
|
| 52 | 52 | $custom = \common\models\CustomBehavior::find(['user_id' => Yii::$app->user->id])->asArray()->all(); |
| 53 | 53 | return $this->render('index', [ |
| 54 | 54 | 'categories' => Yii::$container->get(CategoryInterface::class)::$categories, |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $date = Yii::$container->get(TimeInterface::class)->getLocalDate(); |
| 64 | 64 | |
| 65 | 65 | $user_behaviors = $user_behavior->getUserBehaviorsWithCategory($date); |
| 66 | - if(count($user_behaviors) === 0) { |
|
| 66 | + if (count($user_behaviors) === 0) { |
|
| 67 | 67 | return $this->redirect(['view']); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | $form->deleteToday($Yii::$app->user->id); |
| 74 | 74 | |
| 75 | 75 | $behaviors = $user_behavior->findAll($form->getUserBehaviorIds()); |
| 76 | - if($result = $form->saveAnswers(Yii::$app->user->id, $behaviors)) { |
|
| 76 | + if ($result = $form->saveAnswers(Yii::$app->user->id, $behaviors)) { |
|
| 77 | 77 | |
| 78 | - if(Yii::$app->user->identity->send_email) { |
|
| 79 | - if(Yii::$app->user->identity->sendEmailReport($date)) { |
|
| 78 | + if (Yii::$app->user->identity->send_email) { |
|
| 79 | + if (Yii::$app->user->identity->sendEmailReport($date)) { |
|
| 80 | 80 | Yii::$app->session->setFlash('success', 'Your check-in is complete. A notification has been sent to your report partners.'); |
| 81 | 81 | } else { |
| 82 | 82 | Yii::$app->session->setFlash('success', 'Your check-in is complete.'); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $raw_pie_data = $user_behavior::decorate($user_behavior->getBehaviorsWithCounts()); |
| 133 | 133 | $answer_pie = $user_behavior->getBehaviorsByCategory($raw_pie_data); |
| 134 | 134 | |
| 135 | - $pie_data = [ |
|
| 135 | + $pie_data = [ |
|
| 136 | 136 | "labels" => array_column($answer_pie, "name"), |
| 137 | 137 | "datasets" => [[ |
| 138 | 138 | "data" => array_map('intval', array_column($answer_pie, "count")), |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | $checkins = $user_behavior->getCheckInBreakdown($period); |
| 168 | 168 | |
| 169 | 169 | $accum = []; |
| 170 | - foreach($checkins as $date => $cats) { |
|
| 171 | - for($i = 1; $i <= 7; $i ++) { |
|
| 170 | + foreach ($checkins as $date => $cats) { |
|
| 171 | + for ($i = 1; $i <= 7; $i++) { |
|
| 172 | 172 | $accum[$i][] = array_key_exists($i, $cats) ? $cats[$i]['count'] : []; |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $bar_datasets = []; |
| 177 | - foreach($accum as $idx => $data) { |
|
| 177 | + foreach ($accum as $idx => $data) { |
|
| 178 | 178 | $bar_datasets[] = [ |
| 179 | 179 | 'label' => ($category::getCategories())[$idx], |
| 180 | 180 | 'backgroundColor' => $category::$colors[$idx]['color'], |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function actions() { |
| 44 | 44 | return array_replace_recursive(parent::actions(), [ |
| 45 | - 'update' => [ // identifier for your editable column action |
|
| 45 | + 'update' => [// identifier for your editable column action |
|
| 46 | 46 | 'class' => EditableColumnAction::className(), // action class name |
| 47 | 47 | 'modelClass' => CustoMBehavior::className(), // the model for the record being edited |
| 48 | 48 | 'scenario' => CustomBehavior::SCENARIO_DEFAULT, // model scenario assigned before validation & update |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | 'ajaxOnly' => true, |
| 53 | 53 | 'findModel' => function($id, $action) { |
| 54 | 54 | $model = $this->findModel($id); |
| 55 | - if($model !== null) { |
|
| 55 | + if ($model !== null) { |
|
| 56 | 56 | return $model; |
| 57 | 57 | } |
| 58 | 58 | throw new NotFoundHttpException('The specified behavior does not exist.'); |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | public function actionCreate() { |
| 65 | 65 | $form = Yii::$container->get(\site\models\CustomBehaviorForm::class, [Yii::$app->user->identity]); |
| 66 | 66 | |
| 67 | - if($form->load(Yii::$app->request->post()) && $form->validate()) { |
|
| 67 | + if ($form->load(Yii::$app->request->post()) && $form->validate()) { |
|
| 68 | 68 | $form->save(); |
| 69 | 69 | return $this->redirect(['profile/index']); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; |
| 73 | - if($errors = $form->getErrorSummary(true)) { |
|
| 73 | + if ($errors = $form->getErrorSummary(true)) { |
|
| 74 | 74 | return $errors; |
| 75 | 75 | } else { |
| 76 | 76 | return ["success" => false, "message" => "Unknown Error"]; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | protected function findModel($id) { |
| 87 | 87 | $model = CustomBehavior::findOne(['id' => $id, 'user_id' => Yii::$app->user->id]); |
| 88 | - if($model !== null) { |
|
| 88 | + if ($model !== null) { |
|
| 89 | 89 | return $model; |
| 90 | 90 | } |
| 91 | 91 | |