Skip to content

Commit

Permalink
Added AssetPackageController::actionAvoid
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Apr 27, 2017
1 parent ec7bbcd commit a96ef4b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/console/AssetPackageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,29 @@

use hiqdev\assetpackagist\commands\PackageUpdateCommand;
use hiqdev\assetpackagist\models\AssetPackage;
use hiqdev\assetpackagist\repositories\PackageRepository;
use Yii;
use yii\helpers\Console;

class AssetPackageController extends \yii\console\Controller
{
/**
* @var PackageRepository
*/
protected $packageRepository;

/**
* MaintenanceController constructor.
* @param PackageRepository $packageRepository
* @inheritdoc
*/
public function __construct($id, $module, PackageRepository $packageRepository, $config = [])
{
parent::__construct($id, $module, $config);

$this->packageRepository = $packageRepository;
}

/**
* @param string $type the package type. Can be either `bower` or `npm`
* @param string $name the package name
Expand Down Expand Up @@ -75,6 +93,14 @@ public function actionUpdateAll()
$this->actionUpdateList(Yii::getAlias('@hiqdev/assetpackagist/config/packages.list'));
}

public function actionAvoid($type, $name)
{
$package = new AssetPackage($type, $name);
$this->packageRepository->markAvoided($package);

echo Console::renderColoredString("Package %N$type/$name%n is %Ravoided%n now\n");
}

public function actionList()
{
$packages = Yii::$app->get('packageStorage')->listPackages();
Expand Down
7 changes: 7 additions & 0 deletions src/models/AssetPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public static function normalizeName($name)
return strtolower($name);
}

/**
* AssetPackage constructor.
* @param string $type
* @param string $name
* @param array $config
* @throws Exception
*/
public function __construct($type, $name, $config = [])
{
parent::__construct($config);
Expand Down

0 comments on commit a96ef4b

Please sign in to comment.