Class to implement utility methods. More...
Static Public Member Functions | |
| static bool | isLtiMessage () |
| Check whether the request received could be an LTI message. | |
| static array | getRequestParameters () |
| Return GET and POST request parameters (POST parameters take precedence). | |
| static void | logError (string $message, bool $showSource=true) |
| Log an error message. | |
| static void | logInfo (string $message, bool $showSource=false) |
| Log an information message. | |
| static void | logDebug (string $message, bool $showSource=false) |
| Log a debug message. | |
| static void | logRequest (bool $debugLevel=false) |
| Log a request received. | |
| static void | logForm (string $url, array $params, string $method="POST", bool $debugLevel=false) |
| Log a form submission. | |
| static void | log (string $message, bool $showSource=false) |
| Log an error message irrespective of the logging level. | |
| static void | logMessage (string $message, LogLevel $type=LogLevel::None, bool $showSource=false) |
| Log an error message irrespective of the logging level. | |
| static void | setLoggerClient (?LoggerInterface $loggerClient) |
| Set the Logger client to use for logging messages. | |
| static LoggerInterface null | getLoggerClient () |
| Get the Logger client to use for logging messages. | |
| static void | setMessage (bool $isError, string $message) |
| Set an error or warning message. | |
| static array | getMessages (bool $isError) |
| Get the system error or warning messages. | |
| static string | sendForm (string $url, array $params, string $target="", string $javascript="") |
| Generate a web page containing an auto-submitted form of parameters. | |
| static void | sendResponse (string $body="", string $contentType="", int $statusCode=200, string $statusMessage="OK") |
| Send a service response. | |
| static string | addQueryParameters (string $url, array $params) |
| Add query parameters to a URL. | |
| static void | redirect (string $url, array $params=[], bool $disableExit=false) |
| Redirect to a URL with query parameters. | |
| static void | setTestCookie (bool $delete=false) |
| Set or delete a test cookie. | |
| static string | getRandomString (int $length=8) |
| Generate a random string. | |
| static string | stripHtml (string $html) |
| Strip HTML tags from a string. | |
| static string | urlEncode (?string $val) |
| URL encode a value. | |
| static string | valToString (mixed $val, ?string $default="") |
| Convert a value to a string. | |
| static int float null | valToNumber (mixed $val) |
| Convert a value to a numeric. | |
| static bool | valToBoolean (mixed $val) |
| Convert a value to a boolean. | |
| static object null | checkObject (object $obj, string $fullname, bool $required=false, bool $stringValues=false) |
| Get the named object element from object. | |
| static array null | checkArray (object $obj, string $fullname, bool $required=false, bool $notEmpty=false, ?array $default=[]) |
| Get the named array element from object. | |
| static string | checkString (object $obj, string $fullname, bool $required=false, ?bool $notEmpty=false, string|array $fixedValue="", bool $overrideStrictMode=false, ?string $default="") |
| Get the named string element from object. | |
| static string | checkUrl (object $obj, string $fullname, bool $required=false, bool $allowEmpty=false) |
| Get the named filly-qualified URL element from object. | |
| static int float null | checkNumber (object $obj, string $fullname, bool $required=false, int|false $minimum=false, bool $minimumExclusive=false, bool $overrideStrictMode=false) |
| Get the named number element from object. | |
| static int null | checkInteger (object $obj, string $fullname, bool $required=false, int|false $minimum=false, bool $minimumExclusive=false, bool $overrideStrictMode=false) |
| Get the named integer element from object. | |
| static bool null | checkBoolean (object $obj, string $fullname, bool $required=false, ?bool $default=null) |
| Get the named boolean element from object. | |
| static int | checkDateTime (object $obj, string $fullname, bool $required=false) |
| Get the named number element from object. | |
| static mixed | jsonDecode (?string $str, bool $associative=false) |
| Decode a JSON string. | |
| static object | cloneObject (object $obj) |
| Clone an object and any objects it contains. | |
| static bool | canEncrypt () |
| Check whether the application instance supports the encryption/decryption methods. | |
| static string null | encrypt (?string $value, int $maximumLength=0) |
| Encrypt a string value. | |
| static string null | decrypt (?string $value) |
| Decrypt an encrypted string value. | |
Public Attributes | |
| const | JWT_CLAIM_PREFIX = 'https://purl.imsglobal.org/spec/lti' |
| Prefix for standard JWT message claims. | |
| const | MESSAGE_TYPE_MAPPING |
| Mapping for standard message types. | |
| const | JWT_CLAIM_MAPPING |
| Mapping for standard message parameters to JWT claim. | |
| const | TEST_COOKIE_NAME = 'celtic_lti_test_cookie' |
| Name of test cookie. | |
Static Public Attributes | |
| static array | $METHOD_NAMES |
| List of supported message types and associated class methods. | |
| static array | $requestParameters = null |
| GET and POST request parameters. | |
| static string | $version = '5.3.0' |
| Value of library version. | |
| static string | $userAgentHeaderValue = 'LTI-PHP/{VERSION} (from ceLTIc Project)' |
| Value of User-Agent header of HTTP requests. | |
| static LogLevel | $logLevel = LogLevel::None |
| Current logging level. | |
| static bool | $strictMode = false |
| Whether full compliance with the LTI specification is required. | |
| static bool | $disableFetchedPublicKeysSave = false |
| Whether the automatic saving of fetched valid public keys should be disabled. | |
| static int | $formSubmissionTimeout = 2 |
| Delay (in seconds) before a manual button is displayed in case a browser is blocking a form submission. | |
| static string | $encryptionKey = null |
| Key to use when encrypting and decrypting values. | |
Class to implement utility methods.
|
static |
Add query parameters to a URL.
| string | $url | URL to which the form should be submitted |
| array | $params | Array of form parameters |
References OAuthRequest\from_request().
|
static |
Check whether the application instance supports the encryption/decryption methods.
|
static |
Get the named array element from object.
| object | $obj | Object containing the element |
| string | $fullname | Name of element |
| bool | $required | True if the element must be present |
| bool | $notEmpty | True if the element must not have an empty value |
| array | null | $default | Value to return when a conversion is not possible (optional, default is an empty array) |
Referenced by checkObject(), and Membership\getWithGroups().
|
static |
Get the named boolean element from object.
| object | $obj | Object containing the element |
| string | $fullname | Name of element (may include a path) |
| bool | $required | True if the element must be present |
| string | null | $default | Value to return when a conversion is not possible (optional, default is an empty string) |
Referenced by Groups\get(), LineItem\get(), and FileItem\setExpiresAt().
|
static |
Get the named number element from object.
| object | $obj | Object containing the element |
| string | $fullname | Name of element (may include a path) |
| bool | $required | True if the element must be present |
References cloneObject().
Referenced by LineItem\get().
|
static |
Get the named integer element from object.
| object | $obj | Object containing the element |
| string | $fullname | Name of element (may include a path) |
| bool | $required | True if the element must be present |
| int | false | $minimum | Minimum value (or false is none) |
| bool | $minimumExclusive | True if value must exceed the minimum |
| bool | $overrideStrictMode | Ignore strict mode setting |
Referenced by checkNumber(), and Image\toJsonldObject().
|
static |
Get the named number element from object.
| object | $obj | Object containing the element |
| string | $fullname | Name of element (may include a path) |
| bool | $required | True if the element must be present |
| int | false | $minimum | Minimum value (or false is none) |
| bool | $minimumExclusive | True if value must exceed the minimum |
| bool | $overrideStrictMode | Ignore strict mode setting |
References checkInteger().
Referenced by LineItem\get().
|
static |
Get the named object element from object.
| object | $obj | Object containing the element |
| string | $fullname | Name of element |
| bool | $required | True if the element must be present |
| bool | $stringValues | True if the values must be strings |
References checkArray().
|
static |
Get the named string element from object.
| object | $obj | Object containing the element |
| string | $fullname | Name of element (may include a path) |
| bool | $required | True if the element must be present |
| bool | null | $notEmpty | True if the element must not have an empty value (use null to issue a warning message when it does) |
| string | $fixedValue | Required value of element (empty string if none) |
| bool | $overrideStrictMode | Ignore strict mode setting |
| string | null | $default | Value to return when a conversion is not possible (optional, default is an empty string) |
Referenced by Placement\fromJsonObject(), Groups\get(), LineItem\get(), Membership\getWithGroups(), and ContentItem\toJsonObject().
|
static |
Get the named filly-qualified URL element from object.
| object | $obj | Object containing the element |
| string | $fullname | Name of element (may include a path) |
| bool | $required | True if the element must be present |
| bool | $allowEmpty | True if the element can be empty |
Referenced by Image\toJsonldObject().
|
static |
Clone an object and any objects it contains.
| object | $obj | Object to be cloned |
Referenced by checkDateTime().
|
static |
Decrypt an encrypted string value.
| string | null | $value | String to be decrypted |
Referenced by Platform\fromConsumerKey(), Tool\fromConsumerKey(), and Platform\getToolSettings().
|
static |
Encrypt a string value.
| string | null | $value | String to be encrypted |
| int | $maximumLength | Maximum length allowed for encrypted string (optional, default is 0 for no restriction) |
Referenced by Tool\__construct(), and Platform\initialize().
|
static |
Get the Logger client to use for logging messages.
|
static |
Get the system error or warning messages.
| bool | $isError | True if error messages are to be returned |
|
static |
Generate a random string.
The generated string will only comprise letters (upper- and lower-case) and digits.
| int | $length | Length of string to be generated (optional, default is 8 characters) |
|
static |
Return GET and POST request parameters (POST parameters take precedence).
References logDebug(), and logMessage().
Referenced by Platform\getTools().
|
static |
Check whether the request received could be an LTI message.
References logInfo(), and logMessage().
|
static |
Decode a JSON string.
| string | null | $str | The JSON string to be decoded |
| bool | $associative | True to return JSON objects as associative arrays |
Referenced by DataConnector_mysqli\deletePlatformNonce(), DataConnector_oci8\deletePlatformNonce(), DataConnector_pdo\deletePlatformNonce(), DataConnector_pgsql\deletePlatformNonce(), DataConnector_sql\deletePlatformNonce(), DataConnector_oci8\deleteTool(), AccessToken\get(), FirebaseClient\getJWKS(), FirebaseClient\getPayload(), CanvasApi\isConfigured(), DataConnector_oci8\loadTool(), and System\sendMessage().
|
static |
Log an error message irrespective of the logging level.
| string | $message | Message to be logged |
| bool | $showSource | True if the name and line number of the current file are to be included |
|
static |
Log a debug message.
| string | $message | Message to be logged |
| bool | $showSource | True if the name and line number of the current file are to be included |
Referenced by HttpMessage\__construct(), getRequestParameters(), FirebaseClient\hasClaim(), WebTokenClient\hasClaim(), logMessage(), and logRequest().
|
static |
Log an error message.
| string | $message | Message to be logged |
| bool | $showSource | True if the name and line number of the current file are to be included |
References OAuthRequest\$POST_INPUT, OAuthUtil\get_headers(), and OAuthUtil\parse_parameters().
Referenced by FirebaseClient\getJWKS(), and AccessToken\load().
|
static |
Log a form submission.
| string | $url | URL to which the form should be submitted |
| array | $params | Array of form parameters |
| string | $method | HTTP Method used to submit form (optional, default is POST) |
| bool | $debugLevel | True if the form details should always be logged (optional, default is false to use current log level) |
|
static |
Log an information message.
| string | $message | Message to be logged |
| bool | $showSource | True if the name and line number of the current file are to be included |
Referenced by isLtiMessage(), and logRequest().
|
static |
Log an error message irrespective of the logging level.
| string | $message | Message to be logged |
| LogLevel | $type | Type of message to be logged (optional, default is none) |
| bool | $showSource | True if the name and line number of the current file are to be included |
References logDebug().
Referenced by getRequestParameters(), and isLtiMessage().
|
static |
Log a request received.
| bool | $debugLevel | True if the request details should be logged at the debug level (optional, default is false for information level) |
References logDebug(), and logInfo().
Referenced by Platform\getTools().
|
static |
Redirect to a URL with query parameters.
| string | $url | URL to which the form should be submitted |
| array | $params | Array of form parameters (optional, default is none) |
| bool | $disableExit | True if the exit statement should not be called |
|
static |
Generate a web page containing an auto-submitted form of parameters.
| string | $url | URL to which the form should be submitted |
| array | $params | Array of form parameters |
| string | $target | Name of target (optional) |
| string | $javascript | Javascript to be inserted (optional, default is to just auto-submit form) |
Referenced by Tool\onLtiEndAssessment().
|
static |
Send a service response.
| string | $body | Body of response (default is empty) |
| string | $contentType | Content type of response (default is empty) |
| int | $statusCode | Status code of response (default is 200) |
| string | $statusMessage | Status message of response (default is 'OK') |
Referenced by Platform\handleRequest().
|
static |
Set the Logger client to use for logging messages.
| LoggerInterface | null | $loggerClient | Logger client (use null to reset to default) |
|
static |
Set an error or warning message.
| bool | $isError | True if the message represents an error |
| string | $message | Message |
Referenced by Groups\get(), Membership\getWithGroups(), ContentItem\toJsonObject(), and valToNumber().
|
static |
Set or delete a test cookie.
| bool | $delete | True if the cookie is to be deleted (optional, default is false) |
|
static |
Strip HTML tags from a string.
| string | $html | HTML string to be stripped |
|
static |
URL encode a value.
| string | null | $val | The value to be encoded |
|
static |
Convert a value to a boolean.
| mixed | $val | The value to be converted |
|
static |
Convert a value to a numeric.
| mixed | $val | The value to be converted |
References setMessage(), and valToString().
|
static |
Convert a value to a string.
| mixed | $val | The value to be converted |
| string | null | $default | Value to return when a conversion is not possible (optional, default is an empty string) |
Referenced by TimePeriod\__construct(), and valToNumber().
|
static |
List of supported message types and associated class methods.
| const MESSAGE_TYPE_MAPPING |
Mapping for standard message types.
Referenced by System\saveSettings().