\Alddesign\Crudkit\ClassesDataProcessor

Holds a set of usefull methods.

In most cases the static methods are all you need. An instance of this Object is only needed by CRUDKit itself. Thats a little bit messy but its ok for now.

Summary

Methods
Properties
Constants
formatRecords()
e()
ex()
xout()
getAjaxErrorResult()
getAjaxResult()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

formatRecords()

formatRecords(  $records, \Alddesign\Crudkit\Classes\bool  $singleRecord = false, \Alddesign\Crudkit\Classes\bool  $formaDateAndTime = true,   $formatBool = true,   $formatDec = true,   $formatBinary = true) 

Parameters

$records
\Alddesign\Crudkit\Classes\bool $singleRecord
\Alddesign\Crudkit\Classes\bool $formaDateAndTime
$formatBool
$formatDec
$formatBinary

e()

e(mixed  $var) : boolean

A better implementation of PHP function empty(); - See code itself for details.

Parameters

mixed $var

The variable to check

Returns

boolean

ex()

ex(string  $message, mixed  $p1 = '', mixed  $p2 = '', mixed  $p3 = '', mixed  $p4 = '', mixed  $p5 = '', mixed  $p6 = '', mixed  $p7 = '', mixed  $p8 = '') 

Shorthand call of throw new Exception(); with up to 8 placeholders

//Example usage:
DataProcessor::ex("%d errors while trying to delete user '%s'.", 4, "admin");

Parameters

string $message

The Exception message to show

mixed $p1

(optional) placeholder

mixed $p2

(optional) placeholder

mixed $p3

(optional) placeholder

mixed $p4

(optional) placeholder

mixed $p5

(optional) placeholder

mixed $p6

(optional) placeholder

mixed $p7

(optional) placeholder

mixed $p8

(optional) placeholder

xout()

xout(mixed  $value, boolean  $dontDie = false, \Alddesign\Crudkit\Classes\bool  $initCall = true) 

A better implementation of PHP function var_dump();

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

//Example usage:
DataProcessor::xout(['cars' => ['audi','bmw'], 'nothing' => (object)['name' => 'Mario', 'age' => 34]]);

Parameters

mixed $value

The variable to print out

boolean $dontDie

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

\Alddesign\Crudkit\Classes\bool $initCall

getAjaxErrorResult()

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

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

Parameters

mixed $data

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

string $message

A simple message for the user

string $p1

p1 to p8 are placeholders for the message

$p2
$p3
$p4
$p5
$p6
$p7
$p8

Returns

string —

JSON string you can return to the client

getAjaxResult()

getAjaxResult(array  $data) : string

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

Parameters

array $data

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...']
];

Returns

string —

JSON string