/** * Renew the CSRF token on a given Phery instance * Resets any selectors that were being chained before * * @param Phery $instance Instance of Phery * @return PheryResponse */ public function renew_csrf(Phery $instance) { if ($instance->config('csrf') === true) { $this->cmd(13, array($instance->csrf())); } return $this; }
} break; } return $r; }, 'nested' => function () { /* This is the same as doing: $(this).before( $('<p/>', { 'text' => 'Text content at UNIX ' + new Date().getTime() }) ); */ return PheryResponse::factory()->this->before(PheryResponse::factory('<p/>', array('text' => 'Text content at UNIX ' . time()))); }))->process(false); $csrf_token = $phery->csrf(); /** * To separate the callback from the rest of the other functions, * just call a second process() */ $phery->callback(array('before' => 'pre_callback', 'after' => 'post_callback'))->set(array('test3' => function ($args, $param) { // Lambda/anonymous function, without named parameters, using ordinal indexes return PheryResponse::factory()->alert($args[0])->alert($args[1])->alert($param['param1'])->alert((string) $param[0])->alert((string) $param[1]); }, 'the_one_with_expr' => 'the_one_with_expr'))->data(array('param1' => 'named as param1'), 1, 'argument')->process(false); $phery->config(array('error_reporting' => E_ALL))->callback(array('before' => array(), 'after' => array()))->set(array('on_purpose_exception' => function () { strlen($code); }, 'deep-nesting' => function () { $r = new PheryResponse('<h3/>'); $d = new PheryResponse('<p/>'); $v = new PheryResponse('<div id="blah_' . mt_rand() . '"/>'); return $r->append($d->append($v->text('this element can be clicked')->bind('click', PheryFunction::factory('function(){ alert(this.id); }'))))->insertAfter(PheryResponse::factory()->this);