CRUDKit api-doc [Developer]

CHelper
in package

Helper Class for Crudkit. Yes, i know, classes like "Helper" are bad design.

..

Tags
internal

Table of Contents

appendToArray()  : void
binaryStringToBase64Png()  : string
e()  : bool
A better implementation of PHP function empty();
fastArrayMerge()  : void
This is upt to 2000 times faster than array_merge().
formatSeconds()  : string
Formats 3620 seconds into 1h 0m 20s
getAjaxErrorResult()  : string
Gets a JSON string which can be used for CRUDKit custom ajax error results.
getAjaxResult()  : string
Gets a JSON string which can be used for CRUDKit custom ajax results.
getCrudkitDbConfig()  : mixed
getFiltersFromRequest()  : array<string|int, Filter>
Gets an array of filters from the CRUDKit request
getFiltersFromUrl()  : array<string|int, Filter>
Gets an array of filters from a given CRUDKit URL
getParamsFromUrl()  : array<string|int, mixed>
Gets an array of the URL params $key => $value
getPrimaryKeyValuesFromRequest()  : array<string|int, mixed>
Gets an array of CRUDKit primary keys from the CRUDKit request
getPrimaryKeyValuesFromUrl()  : array<string|int, mixed>
Gets an array with primary key values from a given CRUDKit URL
getTexts()  : string
Gets all text constants for the specified language form the config (crudkit-texts.php)
noop()  : mixed
swap()  : mixed
Swaps the values of two variables.
text()  : string
Gets a single text constant for the specified language form the config (crudkit-texts.php)
xout()  : mixed
A better implementation of PHP function var_dump();
__construct()  : mixed

Methods

appendToArray()

public static appendToArray(mixed $value, array<string|int, mixed> &$array[, bool $appendIfEmpty = true ]) : void
Parameters
$value : mixed

The value to append

$array : array<string|int, mixed>

The array (as reference)

$appendIfEmpty : bool = true
Tags
internal
Return values
void

binaryStringToBase64Png()

public static binaryStringToBase64Png(string $data[, int $scaleWidthTo = -1 ]) : string
Parameters
$data : string

The binary image data as string (mostly it comes like this from the DB)

$scaleWidthTo : int = -1

If you want to scale the image width

Tags
internal
Return values
string

The base64 encoded image as a string (PNG format)

e()

A better implementation of PHP function empty();

public static e(mixed $var[, bool $zeroIsEmpty = false ]) : bool
Parameters
$var : mixed

The variable to check

$zeroIsEmpty : bool = false

Indicates whether a int/doube zero is considered empty

Return values
bool

fastArrayMerge()

This is upt to 2000 times faster than array_merge().

public static fastArrayMerge(array<string|int, mixed> &$array, array<string|int, mixed> &$intoArray) : void
Parameters
$array : array<string|int, mixed>

the array which will be merged into $intoArray

$intoArray : array<string|int, mixed>

the new "result" array (this one will be modified)

Tags
internal
Return values
void

formatSeconds()

Formats 3620 seconds into 1h 0m 20s

public static formatSeconds(int $seconds) : string
Parameters
$seconds : int
Tags
internal
Return values
string

getAjaxErrorResult()

Gets a JSON string which can be used for CRUDKit custom ajax error results.

public static getAjaxErrorResult(mixed $data[, string $message = '' ][, string $p1 = '' ][, mixed $p2 = '' ][, mixed $p3 = '' ][, mixed $p4 = '' ][, mixed $p5 = '' ][, mixed $p6 = '' ][, mixed $p7 = '' ][, mixed $p8 = '' ]) : string
Parameters
$data : mixed

which will be logged by the JS console on the client: console.log(data);

$message : string = ''

A simple message for the user

$p1 : string = ''

p1 to p8 are placeholders for the message

$p2 : mixed = ''
$p3 : mixed = ''
$p4 : mixed = ''
$p5 : mixed = ''
$p6 : mixed = ''
$p7 : mixed = ''
$p8 : mixed = ''
Return values
string

JSON string you can return to the client

getAjaxResult()

Gets a JSON string which can be used for CRUDKit custom ajax results.

public static getAjaxResult(array<string|int, mixed> $data) : string
Parameters
$data : array<string|int, mixed>

is an array of objects:

//Example
$data =
[
		(object)['id' => 1, 'text' => 'john doe', 'img' => 'data:image/png;base64,R0lG...'],
		(object)['id' => 2, 'text' => 'jane doe', 'img' => 'data:image/png;base64,R0ax...']
];
Return values
string

JSON string

getCrudkitDbConfig()

public static getCrudkitDbConfig() : mixed
Tags
internal
Return values
mixed

getFiltersFromRequest()

Gets an array of filters from the CRUDKit request

public static getFiltersFromRequest(Request $request) : array<string|int, Filter>
Parameters
$request : Request
Tags
internal
Return values
array<string|int, Filter>

getFiltersFromUrl()

Gets an array of filters from a given CRUDKit URL

public static getFiltersFromUrl(string $url) : array<string|int, Filter>
Parameters
$url : string
Tags
internal
Return values
array<string|int, Filter>

getParamsFromUrl()

Gets an array of the URL params $key => $value

public static getParamsFromUrl(string $url) : array<string|int, mixed>
Parameters
$url : string
Tags
internal
Return values
array<string|int, mixed>

getPrimaryKeyValuesFromRequest()

Gets an array of CRUDKit primary keys from the CRUDKit request

public static getPrimaryKeyValuesFromRequest(Request $request) : array<string|int, mixed>
Parameters
$request : Request
Tags
internal
Return values
array<string|int, mixed>

getPrimaryKeyValuesFromUrl()

Gets an array with primary key values from a given CRUDKit URL

public static getPrimaryKeyValuesFromUrl(string $url) : array<string|int, mixed>
Parameters
$url : string
Tags
internal
Return values
array<string|int, mixed>

getTexts()

Gets all text constants for the specified language form the config (crudkit-texts.php)

public static getTexts([string $language = '' ]) : string
Parameters
$language : string = ''

The language code. If not set, the default language is used.

Tags
internal
Return values
string

noop()

public static noop() : mixed
Tags
internal
Return values
mixed

swap()

Swaps the values of two variables.

public static swap(mixed &$var1, mixed &$var2) : mixed
Parameters
$var1 : mixed
$var2 : mixed
Tags
internal
Return values
mixed

text()

Gets a single text constant for the specified language form the config (crudkit-texts.php)

public static text(string $name[, string $language = '' ]) : string
Parameters
$name : string

The name of the test constant.

$language : string = ''

The language code. If not set, the default language is used.

Tags
internal
Return values
string

xout()

A better implementation of PHP function var_dump();

public static xout(mixed $value[, bool $dontDie = false ][, bool $initCall = true ]) : mixed

Provides syntax-highlighted insight even into nested objects,arrays, etc.

//Example usage:
CHelper::xout(['cars' => ['audi','bmw'], 'nothing' => (object)['name' => 'Mario', 'age' => 34]]);
Parameters
$value : mixed

The variable to print out

$dontDie : bool = false

Default = false. If set to true the script will not be aborted after execution of this function.

$initCall : bool = true
Return values
mixed

__construct()

private __construct() : mixed
Return values
mixed

Search results