Version 5.0.0 beta 2
This commit is contained in:
1 parent
15c7beabc5
commit
f61b0da85d
181 files changed
+3182
-1533
No files matched your search
@@ -494,7 +494,7 @@ abstract class Widget
|
||||
*/
|
||||
public function getSupportedLayouts() : array
|
||||
{
|
||||
if ( !isset( static::$baseWidgetConfig[ $this::class ]['layouts'] ) OR empty( static::$baseWidgetConfig[ $this::class ]['layouts'] ) )
|
||||
if ( !isset( static::$baseWidgetConfig[ $this::class ]['layouts'] ) OR !is_array( static::$baseWidgetConfig[ $this::class ]['layouts'] ) )
|
||||
{
|
||||
$layouts = ['table'];
|
||||
if ( $this->isCustomizableWidget() )
|
||||
@@ -718,6 +718,17 @@ abstract class Widget
|
||||
}
|
||||
|
||||
$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 ) )
|
||||
@@ -732,6 +743,37 @@ abstract class Widget
|
||||
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that the widget actually is supported by the app
|
||||
*
|
||||
* @param Application|string $app
|
||||
* @param string $widgetKey
|
||||
* @return bool
|
||||
*/
|
||||
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->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 ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget Types
|
||||
@@ -1183,11 +1225,12 @@ abstract class Widget
|
||||
/**
|
||||
* Get default widgets for an application
|
||||
*
|
||||
* @param Application $app The application
|
||||
* @param Application|string $app The application
|
||||
* @return array
|
||||
*/
|
||||
public static function appDefaults( Application $app ): array
|
||||
public static function appDefaults( Application|string $app ): array
|
||||
{
|
||||
$app = is_string( $app ) ? Application::load( $app ) : $app;
|
||||
if ( !isset( Store::i()->widgets ) )
|
||||
{
|
||||
$widgets = array();
|
||||
|
||||
Reference in new issue
Block a user