Skip to content

Commit

Permalink
Merge branch 'release/1.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Olegs Capligins committed Mar 15, 2018
2 parents 1c93c59 + d25d702 commit 74ea983
Show file tree
Hide file tree
Showing 104 changed files with 442 additions and 1,381 deletions.
75 changes: 75 additions & 0 deletions commands/AssetController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
* This file is part of cBackup, network equipment configuration backup tool
* Copyright (C) 2017, Oļegs Čapligins, Imants Černovs, Dmitrijs Galočkins
*
* cBackup is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace app\commands;

use yii\base\ErrorException;
use yii\console\ExitCode;
use yii\helpers\FileHelper;


/**
* Allows you to flush assets, to combine and compress your JavaScript and CSS files
* @package app\commands
*/
class AssetController extends \yii\console\controllers\AssetController
{

/**
* Flushes all assets in ./web/assets folder
* @return int
*/
public function actionFlushAll()
{

$assdir = \Yii::getAlias('@app').DIRECTORY_SEPARATOR.'web'.DIRECTORY_SEPARATOR.'assets';

if(!file_exists($assdir) || !is_dir($assdir)) {
$this->stderr("Directory $assdir doesn't exist, check your asset path\n");
return ExitCode::UNSPECIFIED_ERROR;
}

$assets = FileHelper::findDirectories($assdir, ['recursive' => false]);
$status = true;

if (!empty($assets)) {

foreach ($assets as $asset) {
try {
FileHelper::removeDirectory($asset);
}
catch (ErrorException $e) {
$status = false;
}
}

}

if($status === true) {
$this->stdout("Old assets where successfully removed\n");
return ExitCode::OK;
}
else {
$this->stderr("Unexpected error while removing assets, check $assdir\n");
return ExitCode::UNSPECIFIED_ERROR;
}

}

}
3 changes: 2 additions & 1 deletion commands/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@


/**
* Extension of base message extractor to generate messages in format suitable for Transifex
* Extracts messages to be translated from source files and provides some validation as well
* To generate message files, use command line `./yii message/extract messages/config.php`
* To extract sources for en, use command line `./yii message/source`
*
* @package app\commands
*/
Expand Down
Loading

0 comments on commit 74ea983

Please sign in to comment.