Skip to content

Latest commit

 

History

History
290 lines (227 loc) · 11.6 KB

number.rst

File metadata and controls

290 lines (227 loc) · 11.6 KB

CakeNumber

If you need :phpNumberHelper functionalities outside of a View, use the CakeNumber class:

<?php
class UsersController extends AppController {

    public $components = array('Auth');

    public function afterLogin() {
        App::uses('CakeNumber', 'Utility');
        $storageUsed = $this->Auth->user('storage_used');
        if ($storageUsed > 5000000) {
            // notify users of quota
            $this->Session->setFlash(__('You are using %s storage', CakeNumber::toReadableSize($storageUsed)));
        }
    }
}

2.1 CakeNumber has been factored out from :phpNumberHelper.

All of these functions return the formatted number; They do not automatically echo the output into the view.