Version 5.0.0 beta 9
This commit is contained in:
1 parent
214f649f1d
commit
56979f8ee8
202 files changed
+4403
-1123
No files matched your search
+14
-12
@@ -1852,28 +1852,30 @@ class Output
|
||||
|
||||
foreach( $this->breadcrumb as $breadcrumb )
|
||||
{
|
||||
$crumb = [
|
||||
'@type' => "ListItem",
|
||||
'position' => $position,
|
||||
'item' => [
|
||||
'name' => $breadcrumb[1],
|
||||
]
|
||||
];
|
||||
|
||||
if( $breadcrumb[0] )
|
||||
{
|
||||
$elements[] = array(
|
||||
'@type' => "ListItem",
|
||||
'position' => $position,
|
||||
'item' => array(
|
||||
'@id' => (string) $breadcrumb[0],
|
||||
'name' => $breadcrumb[1],
|
||||
)
|
||||
);
|
||||
|
||||
$position++;
|
||||
$crumb['item']['@id'] = (string) $breadcrumb[0];
|
||||
}
|
||||
|
||||
$elements[] = $crumb;
|
||||
$position++;
|
||||
}
|
||||
|
||||
if( count( $elements ) )
|
||||
{
|
||||
$jsonLd['breadcrumbs'] = array(
|
||||
$jsonLd['breadcrumbs'] = [
|
||||
'@context' => "https://schema.org",
|
||||
'@type' => "BreadcrumbList",
|
||||
'itemListElement' => $elements,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,66 +92,20 @@ class UiExtension extends Singleton
|
||||
*/
|
||||
public function run( Content|Model|string $object, string $method, ?array $payload=array() ) : array
|
||||
{
|
||||
$className = is_string( $object ) ? $object : get_class( $object );
|
||||
$baseClass = null;
|
||||
switch( $className )
|
||||
{
|
||||
case '':
|
||||
default:
|
||||
return [];
|
||||
|
||||
case is_subclass_of( $className, Model::class ):
|
||||
|
||||
/* If this node class cannot be extended, just return and do nothing */
|
||||
if( !$className::$canBeExtended )
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$type = 'Node';
|
||||
$baseClass = Model::class;
|
||||
break;
|
||||
case is_subclass_of( $className, Content\Item::class ):
|
||||
$type = 'Item';
|
||||
$baseClass = Content\Item::class;
|
||||
break;
|
||||
case is_subclass_of( $className, Content\Review::class ):
|
||||
$type = 'Review';
|
||||
$baseClass = Content\Review::class;
|
||||
break;
|
||||
case is_subclass_of( $className, Content\Comment::class ):
|
||||
$type = 'Comment';
|
||||
$baseClass = Content\Comment::class;
|
||||
break;
|
||||
}
|
||||
|
||||
$return = [];
|
||||
|
||||
/* If we are working with an object (Item/Comment/Node), put it first in the parameter list */
|
||||
/* If we are working with an object (Item/Comment/Node), put it first in the parameter list */
|
||||
$params = is_array( $payload ) ? array_values( $payload ) : array();
|
||||
array_unshift( $params, is_string( $object ) ? null : $object );
|
||||
|
||||
foreach( $this->extensions( $type ) as $extension )
|
||||
foreach( $this->getObjectExtensions( $object ) as $extension )
|
||||
{
|
||||
/* Use subclass to account for classes in Pages */
|
||||
if( isset( $extension::$class ) AND $className != $extension::$class AND !is_subclass_of( $className, $extension::$class ) )
|
||||
if ( $response = $extension->$method( ...$params ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Block extension of base classes */
|
||||
if( $baseClass !== null AND $extension::$class == $baseClass )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( $response = $extension->$method( ...$params ) )
|
||||
{
|
||||
if( is_array( $response ) )
|
||||
if ( is_array( $response ) )
|
||||
{
|
||||
$return = array_merge( $return, $response );
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
$return[] = $response;
|
||||
}
|
||||
@@ -160,4 +114,65 @@ class UiExtension extends Singleton
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all available extensions for this object
|
||||
*
|
||||
* @param Content|Model|string $object
|
||||
* @return array
|
||||
*/
|
||||
public function getObjectExtensions( Content|Model|string $object ) : array
|
||||
{
|
||||
$className = is_string( $object ) ? $object : get_class( $object );
|
||||
$baseClass = null;
|
||||
switch ( $className )
|
||||
{
|
||||
case '':
|
||||
default:
|
||||
return [];
|
||||
|
||||
case is_subclass_of( $className, Model::class ):
|
||||
|
||||
/* If this node class cannot be extended, just return and do nothing */
|
||||
if ( !$className::$canBeExtended )
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$type = 'Node';
|
||||
$baseClass = Model::class;
|
||||
break;
|
||||
case is_subclass_of( $className, Content\Item::class ):
|
||||
$type = 'Item';
|
||||
$baseClass = Content\Item::class;
|
||||
break;
|
||||
case is_subclass_of( $className, Content\Review::class ):
|
||||
$type = 'Review';
|
||||
$baseClass = Content\Review::class;
|
||||
break;
|
||||
case is_subclass_of( $className, Content\Comment::class ):
|
||||
$type = 'Comment';
|
||||
$baseClass = Content\Comment::class;
|
||||
break;
|
||||
}
|
||||
|
||||
$return = [];
|
||||
foreach ( $this->extensions( $type ) as $extension )
|
||||
{
|
||||
/* Use subclass to account for classes in Pages */
|
||||
if ( isset( $extension::$class ) and $className != $extension::$class and !is_subclass_of( $className, $extension::$class ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Block extension of base classes */
|
||||
if ( $baseClass !== null and $extension::$class == $baseClass )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$return[] = $extension;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user