CakePHP: Custom Function in bootstrap that uses $ajax->link not working

Hello I have two questions:

(1) Is it best practice to create global custom functions in the bootstrap file? Is there a better place to store them?

(2) I am unable use the following line of code in my custom function located in my bootstrap.php file:

    $url = $ajax->link ( 'Delete', array ('controller' => 'events', 'action' => 'delete', 22 ), array ('update' => 'event' ), 'Do you want to delete this event?' );
    echo $url;

I receive the following error:

Notice (8): Undefined variable: ajax [APP\config\bootstrap.php, line 271]

Code

}

function testAjax () {

            $url = $ajax->link ( 'Delete', array ('controller' => 'events', 'action' => 'delete', 22 ), array ('update' => 'event' ), 'Do you want to delete this event?' );

testAjax - APP\config\bootstrap.php, line 271
include - APP\views\event\queue.ctp, line 19
View::_render() - CORE\cake\libs\view\view.php, line 649
View::render() - CORE\cake\libs\view\view.php, line 372
Controller::render() - CORE\cake\libs\controller\controller.php, line 766
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 211
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 181
[main] - APP\webroot\index.php, line 91

However it works as intended if I place that same code in my view:

Delete

Please help :)

Thanks in advance!!