private function addApp ()
		{
			$appNew = new Apiapp();
			if (Yii::$app->request->post('method') == 'apiapp')
			{
				$post = Yii::$app->request->post();

				if ($post[ 'id' ])
					$appNew = Apiapp::findOne($post[ 'id' ]);

				$appNew->setAttributes([ 'name' => $post[ 'name' ] ]);
				$appNew->token = StringHelper::random(16);
				if ($appNew->validate())
				{
					$appNew->save();
					if (!$post[ 'id' ])
						Yii::$app->session->set('viewID', $appNew->id);
					$url = Yii::$app->request->referrer . '#' . $appNew->name;
					$appNew->setAttributes([ 'name' => '', 'token' => '' ]);
					LogManager::info(Yii::tr('User {user} has created API application {name}.', [ 'user' => Html::a(Yii::$app->user->identity->name, Url::toRoute([ 'user/view', 'id' => Yii::$app->user->id ])), 'name' => $post[ 'name' ] ]));

					Yii::$app->response->redirect($url);
					Yii::$app->end();
				}
			}

			return $appNew;
		}