Version 5.0.0 beta 8
This commit is contained in:
1 parent
54d5dcd0a0
commit
214f649f1d
483 files changed
+35354
-33568
No files matched your search
@@ -734,18 +734,18 @@ abstract class Widget
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
/* Is this a valid widget? */
|
||||
if( !static::isValidWidget( $parent, $widgetKey ) )
|
||||
{
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
$class = '\IPS\\' . $parent->directory . '\widgets\\' . $widgetKey;
|
||||
$baseWidgetKey = $widgetKey;
|
||||
if ( class_exists( $class ) and in_array( "IPS\\Widget\\Polymorphic", class_implements( $class ) ) )
|
||||
{
|
||||
$baseWidgetKey = $class::getBaseKey();
|
||||
}
|
||||
|
||||
/* Is this a valid widget? */
|
||||
if( !static::isValidWidget( $parent, $baseWidgetKey ) )
|
||||
{
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
/* Return */
|
||||
if ( class_exists( $class ) )
|
||||
@@ -770,26 +770,10 @@ abstract class Widget
|
||||
*/
|
||||
public static function isValidWidget( Application|string $app, string $widgetKey ) : bool
|
||||
{
|
||||
/* Is this a valid widget? */
|
||||
try
|
||||
{
|
||||
$cache = Store::i()->widgets;
|
||||
}
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
static::appDefaults( $app );
|
||||
$cache = Store::i()->widgets;
|
||||
}
|
||||
$app = ( $app instanceof Application ) ? $app : Application::load( $app );
|
||||
$class = '\IPS\\' . $app->directory . '\widgets\\' . $widgetKey;
|
||||
|
||||
$app = ( $app instanceof Application ) ? $app->directory : $app;
|
||||
|
||||
$class = '\IPS\\' . $app . '\widgets\\' . $widgetKey;
|
||||
if ( class_exists( $class ) and in_array( "IPS\\Widget\\Polymorphic", class_implements( $class ) ) )
|
||||
{
|
||||
$widgetKey = $class::getBaseKey();
|
||||
}
|
||||
|
||||
return array_key_exists( $widgetKey, $cache[ $app ] );
|
||||
return ( in_array( $widgetKey, $app->getValidWidgetKeys() ) and class_exists( $class ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user