Ported to CakePHP 2.x