Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,28 +11,39 @@
|
||||
namespace IPS\Api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Member;
|
||||
use IPS\Theme;
|
||||
use ReflectionMethod;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Documentation Helper
|
||||
*/
|
||||
abstract class _DocumentationHelper
|
||||
abstract class DocumentationHelper
|
||||
{
|
||||
|
||||
public static function getDescriptionForClass( $class )
|
||||
/**
|
||||
* @param string $class
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescriptionForClass( string $class ) : string
|
||||
{
|
||||
if ( method_exists( $class, 'apiOutput') )
|
||||
{
|
||||
$reflection = new \ReflectionMethod( $class, 'apiOutput' );
|
||||
$decoded = \IPS\Api\Controller::decodeDocblock( $reflection->getDocComment() );
|
||||
return \IPS\Theme::i()->getTemplate('api','core')->referenceTable( $decoded['details']['apiresponse'] );
|
||||
$reflection = new ReflectionMethod( $class, 'apiOutput' );
|
||||
$decoded = Controller::decodeDocblock( $reflection->getDocComment() );
|
||||
return Theme::i()->getTemplate('api','core')->referenceTable( $decoded['details']['apiresponse'] );
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->block( '', \IPS\Member::loggedIn()->language()->addToStack( 'class_no_apioutput_method' ) );
|
||||
return Theme::i()->getTemplate( 'global' )->block( '', Member::loggedIn()->language()->addToStack( 'class_no_apioutput_method' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +53,7 @@ abstract class _DocumentationHelper
|
||||
* @param bool $exclude If FALSE, will include this class itself in the return array
|
||||
* @return array
|
||||
*/
|
||||
public static function getAdditionalClasses( $class, $exclude=FALSE )
|
||||
public static function getAdditionalClasses( string $class, bool $exclude=FALSE ) : array
|
||||
{
|
||||
if( !class_exists( $class ) or !method_exists( $class, 'apiOutput'))
|
||||
{
|
||||
@@ -50,15 +61,15 @@ abstract class _DocumentationHelper
|
||||
}
|
||||
|
||||
$return = $exclude ? array() : array( $class => $class );
|
||||
$reflection = new \ReflectionMethod( $class, 'apiOutput' );
|
||||
$decoded = \IPS\Api\Controller::decodeDocblock( $reflection->getDocComment() );
|
||||
$reflection = new ReflectionMethod( $class, 'apiOutput' );
|
||||
$decoded = Controller::decodeDocblock( $reflection->getDocComment() );
|
||||
foreach ( $decoded['details']['apiresponse'] as $response )
|
||||
{
|
||||
if ( mb_strpos( $response[0], '|' ) === FALSE AND !\in_array( $response[0], array( 'int', 'string', 'float', 'datetime', 'bool', 'object', 'array' ) ) )
|
||||
if ( mb_strpos( $response[0], '|' ) === FALSE AND !in_array( $response[0], array( 'int', 'string', 'float', 'datetime', 'bool', 'object', 'array' ) ) )
|
||||
{
|
||||
if ( mb_substr( $response[0], 0, 1 ) == '[' )
|
||||
{
|
||||
if ( !\in_array( mb_substr( $response[0], 1, -1 ), $return ) and !\in_array( mb_substr( $response[0], 1, -1 ), array( 'int', 'string', 'float', 'datetime', 'bool', 'object', 'array' ) ) )
|
||||
if ( !in_array( mb_substr( $response[0], 1, -1 ), $return ) and !in_array( mb_substr( $response[0], 1, -1 ), array( 'int', 'string', 'float', 'datetime', 'bool', 'object', 'array' ) ) )
|
||||
{
|
||||
if( $returned = static::getAdditionalClasses( mb_substr( $response[0], 1, -1 ) ) )
|
||||
{
|
||||
@@ -66,7 +77,7 @@ abstract class _DocumentationHelper
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ( !\in_array( $response[0], $return ) )
|
||||
elseif ( !in_array( $response[0], $return ) )
|
||||
{
|
||||
if( $returned = static::getAdditionalClasses( $response[0] ) )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user