14
14
use Exception ;
15
15
use hiqdev \assetpackagist \components \Storage ;
16
16
use hiqdev \assetpackagist \registry \RegistryFactory ;
17
+ use hiqdev \assetpackagist \repositories \PackageRepository ;
17
18
use Yii ;
18
19
use yii \base \Object ;
19
20
@@ -82,6 +83,11 @@ public function getFullName()
82
83
return static ::buildFullName ($ this ->_type , $ this ->_name );
83
84
}
84
85
86
+ public static function buildNormalName ($ type , $ name )
87
+ {
88
+ return static ::buildFullName ($ type , static ::normalizeName ($ name ));
89
+ }
90
+
85
91
public static function buildFullName ($ type , $ name )
86
92
{
87
93
return $ type . '-asset/ ' . $ name ;
@@ -95,6 +101,7 @@ public static function splitFullName($full)
95
101
return [$ type , $ name ];
96
102
}
97
103
104
+
98
105
/**
99
106
* @param string $full package name
100
107
* @return static
@@ -112,7 +119,7 @@ public function getType()
112
119
113
120
public function getNormalName ()
114
121
{
115
- return static ::buildFullName ($ this ->_type , static :: normalizeName ( $ this ->_name ) );
122
+ return static ::buildNormalName ($ this ->_type , $ this ->_name );
116
123
}
117
124
118
125
public function getName ()
@@ -292,6 +299,13 @@ public function canAutoUpdate()
292
299
return time () - $ this ->getUpdateTime () > 60 * 60 * 24 ; // 1 day
293
300
}
294
301
302
+ public function isAvailable ()
303
+ {
304
+ $ repository = Yii::createObject (PackageRepository::class, []);
305
+
306
+ return $ repository ->exists ($ this );
307
+ }
308
+
295
309
/**
296
310
* @return array
297
311
*/
0 commit comments