fix update, remove delete

This commit is contained in:
cornernote 2015-08-09 17:03:17 +09:30
parent 41e441b369
commit 59d03b80fe

View File

@ -2,6 +2,7 @@
namespace app\controllers; namespace app\controllers;
use app\components\Git;
use Yii; use Yii;
use app\models\Package; use app\models\Package;
use app\models\search\PackageSearch; use app\models\search\PackageSearch;
@ -14,17 +15,6 @@ use yii\filters\VerbFilter;
*/ */
class ModController extends Controller class ModController extends Controller
{ {
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/** /**
* Lists all Package models. * Lists all Package models.
@ -80,27 +70,10 @@ class ModController extends Controller
public function actionUpdate($name) public function actionUpdate($name)
{ {
$model = $this->findModel($name); $model = $this->findModel($name);
$model->bower = Git::getFile($model->url, 'bower.json');
if ($model->load(Yii::$app->request->post()) && $model->save()) { $model->setBowerData();
return $this->redirect(['view', 'name' => $model->name]); $model->save();
} else { $this->redirect(['view', 'name' => $model->name]);
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Package model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param string $name
* @return mixed
*/
public function actionDelete($name)
{
$this->findModel($name)->delete();
return $this->redirect(['index']);
} }
/** /**