Skip to content

Commit a96ef4b

Browse files
committed
Added AssetPackageController::actionAvoid
1 parent ec7bbcd commit a96ef4b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Diff for: src/console/AssetPackageController.php

+26
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,29 @@
1313

1414
use hiqdev\assetpackagist\commands\PackageUpdateCommand;
1515
use hiqdev\assetpackagist\models\AssetPackage;
16+
use hiqdev\assetpackagist\repositories\PackageRepository;
1617
use Yii;
1718
use yii\helpers\Console;
1819

1920
class AssetPackageController extends \yii\console\Controller
2021
{
22+
/**
23+
* @var PackageRepository
24+
*/
25+
protected $packageRepository;
26+
27+
/**
28+
* MaintenanceController constructor.
29+
* @param PackageRepository $packageRepository
30+
* @inheritdoc
31+
*/
32+
public function __construct($id, $module, PackageRepository $packageRepository, $config = [])
33+
{
34+
parent::__construct($id, $module, $config);
35+
36+
$this->packageRepository = $packageRepository;
37+
}
38+
2139
/**
2240
* @param string $type the package type. Can be either `bower` or `npm`
2341
* @param string $name the package name
@@ -75,6 +93,14 @@ public function actionUpdateAll()
7593
$this->actionUpdateList(Yii::getAlias('@hiqdev/assetpackagist/config/packages.list'));
7694
}
7795

96+
public function actionAvoid($type, $name)
97+
{
98+
$package = new AssetPackage($type, $name);
99+
$this->packageRepository->markAvoided($package);
100+
101+
echo Console::renderColoredString("Package %N$type/$name%n is %Ravoided%n now\n");
102+
}
103+
78104
public function actionList()
79105
{
80106
$packages = Yii::$app->get('packageStorage')->listPackages();

Diff for: src/models/AssetPackage.php

+7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ public static function normalizeName($name)
6262
return strtolower($name);
6363
}
6464

65+
/**
66+
* AssetPackage constructor.
67+
* @param string $type
68+
* @param string $name
69+
* @param array $config
70+
* @throws Exception
71+
*/
6572
public function __construct($type, $name, $config = [])
6673
{
6774
parent::__construct($config);

0 commit comments

Comments
 (0)