Commit a3444914 authored by Shakarim Sapa's avatar Shakarim Sapa

- Fix

parent ca2da46c
<?php <?php
namespace console\controllers; namespace console\controllers;
use common\modules\content\models\CoContentLang;
use Yii; use Yii;
use common\modules\blog\models\PostLang; use common\modules\blog\models\PostLang;
use yii\console\Controller; use yii\console\Controller;
...@@ -17,6 +18,35 @@ class ReplaceController extends Controller ...@@ -17,6 +18,35 @@ class ReplaceController extends Controller
{ {
foreach($data as $i=>$item) foreach($data as $i=>$item)
{ {
// $item->text = str_replace('http://task-on.com/', 'https://task-on.com/', $item->text);
$item->text = str_replace('https://task-on.com/', '/', $item->text);
if (!$item->save())
{
throw new ServerErrorHttpException(current(current($item->getErrors())));
}
echo ($i+1)." of ".count($data)." successfully updated\n";
}
$transaction->commit();
}
catch(\Exception $e)
{
echo "[".$e->getCode()."]".$e->getMessage();
echo "\n";
$transaction->rollback();
}
}
/**
* @throws \yii\web\ServerErrorHttpException
*/
public function actionPortfolio()
{
$data = CoContentLang::find()->all();
$transaction = Yii::$app->db->beginTransaction();
try
{
foreach($data as $i=>$item)
{
// $item->text = str_replace('http://task-on.com/', 'https://task-on.com/', $item->text); // $item->text = str_replace('http://task-on.com/', 'https://task-on.com/', $item->text);
$item->text = str_replace('https://task-on.com/', '/', $item->text); $item->text = str_replace('https://task-on.com/', '/', $item->text);
if (!$item->save()) if (!$item->save())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment