Methods summary
public static
|
|
public static
|
#
define( string $funcName, callable $func )
Define a cloud function
The function shall take two arguments: the first is an array of
parameters, the second is user in the session. Example:
Cloud::define("sayHello", function($params, $user) { return "Hello {$params['name']}!";
});
Parameters
See
self::run
|
public static
|
#
beforeSave( string $className, callable $func )
Define before save hook for a class
Define before save hook for a class
The function shall take two arguments: the first one is class
object, the second is user if available in session. If your $func
throws FunctionError , the save will be rejected. Example:
Cloud::beforeSave("TestObject", function($object, $user) { $title = $object->get("title"); if (strlen($title) > 140) {
});
Parameters
See
|
public static
|
#
afterSave( string $className, callable $func )
Define after save hook for a class
Define after save hook for a class
The function shall take two arguments: the first one is class
object, the second is user if available in session. Any error
in after hook will be ignored.
Parameters
See
|
public static
|
#
beforeUpdate( string $className, callable $func )
Define before update hook for a class
Define before update hook for a class
The function shall take two arguments: the first one is class
object, the second is user if available in session. If your $func
throws FunctionError , the update will be rejected.
Parameters
See
|
public static
|
#
afterUpdate( string $className, callable $func )
Define after update hook for a class
Define after update hook for a class
The function shall take two arguments: the first one is class
object, the second is user if available in session. Any error
in $func will be ignored.
Parameters
See
|
public static
|
#
beforeDelete( string $className, callable $func )
Define before delete hook for a class
Define before delete hook for a class
The function shall take two arguments: the first one is class
object, the second is user if available in session. If your $func
throws FunctionError , the delete will be rejected.
Parameters
See
|
public static
|
#
afterDelete( string $className, callable $func )
Define after delete hook for a class
Define after delete hook for a class
The function shall take two arguments: the first one is class
object, the second is user if available in session. Any error
in $func will be ignored.
Parameters
See
|
public static
|
#
onLogin( callable $func )
Define hook for when user tries to login
Define hook for when user tries to login
The function takes one argument, the login user. A FunctionError
could be thrown in the $func, which will reject the user for login.
Parameters
See
self::runOnLogin
|
public static
|
#
onVerified( string $type, callable $func )
Define hook for when user verified sms or email
Define hook for when user verified sms or email
The function takes one argument, the verified user.
Parameters
- $type
- Either "sms" or "email"
- $func
See
self::runOnVerified
|
public static
|
#
onInsight( callable $func )
Define on complete hook for big query
Define on complete hook for big query
The function takes one argument, the big query job info as array:
array( "id" => "job id", "status" => "OK/ERROR", "message" => "..."
);
Parameters
See
self::runOnInsight
|
public static
mixed
|
#
run( string $funcName, array $params, User $user = null, array $meta = array() )
Run cloud function
Example:
LeanEngine::run("sayHello", array("name" => "alice"), $user);
Parameters
- $funcName
- Name of defined function
- $params
- $data Array of parameters passed to function
- $user
- Request user
- $meta
Optional parameters that will be passed to
user function
Returns
mixed
Throws
See
self::define
|
public static
|
#
start( )
Start cloud function Stand-alone mode, start to process request.
Start cloud function Stand-alone mode, start to process request.
|
public static
|
|
public static
mixed
|
#
runHook( string $className, string $hookName, LeanObject $object, User $user = null, array $meta = array() )
Run cloud hook
Example:
LeanEngine::runHook("TestObject", "beforeUpdate", $object, $user);
Parameters
- $className
- Classname
- $hookName
- Hook name, e.g. beforeUpdate
- $object
- The object of attached hook
- $user
- Request user
- $meta
Optional parameters that will be passed to
user function
Returns
mixed
Throws
|
public static
|
#
runOnLogin( User $user, array $meta = array() )
Run hook when a user logs in
Run hook when a user logs in
Parameters
- $user
- The user object that tries to login
- $meta
Optional parameters that will be passed to
user function
Throws
See
self::onLogin
|
public static
|
#
runOnVerified( string $type, User $user, array $meta = array() )
Run hook when user verified by Email or SMS
Run hook when user verified by Email or SMS
Parameters
- $type
- Either "sms" or "email", case-sensitive
- $user
- The verifying user
- $meta
Optional parameters that will be passed to
user function
Throws
See
self::onVerified
|
public static
mixed
|
#
runOnInsight( array $params, array $meta = array() )
Run hook on big query complete
Run hook on big query complete
Parameters
- $params
- Big query job info
- $meta
Optional parameters that will be passed to
user function
Returns
mixed
Throws
See
self::onInsight
|