Welcome to the Cookbook

loading...

Components

SecurityComponent

The various requireXX methods like requireGet and requirePost now accept a single array as their argument as well as a collection of string names.

$this->Security->requirePost(array('edit', 'update'));
  1. $this->Security->requirePost(array('edit', 'update'));

Component settings

Component settings for all core components can now be set from the $components array. Much like behaviors, you can declare settings for components when you declare the component.

var $components = array(
    'Cookie' => array(
        'name' => 'MyCookie'
    ),
    'Auth' => array(
        'userModel' => 'MyUser',
        'loginAction' => array('controller' => 'users', 'action' => 'login')
    )
);
  1. var $components = array(
  2. 'Cookie' => array(
  3. 'name' => 'MyCookie'
  4. ),
  5. 'Auth' => array(
  6. 'userModel' => 'MyUser',
  7. 'loginAction' => array('controller' => 'users', 'action' => 'login')
  8. )
  9. );

This should reduce clutter in your Controller's beforeFilter() methods.

EmailComponent

  • You can now retrieve the rendered contents of sent Email messages, by reading $this->Email->htmlMessage and $this->Email->textMessage. These properties will contain the rendered email content matching their name.
  • Many of EmailComponent's private methods have been made protected for easier extension.
  • EmailComponent::$to can now be an array. Allowing easier setting of multiple recipients, and consistency with other properties.
  • EmailComponent::$messageId has been added, it allows control over the Message-ID header for email messages.