Skip to content
Permalink
Browse files

Updating intialiize() callbacks. Moving $this->_set() int Component::…

…__construct as all the core components did it. Updating constructors and including parent calls.
  • Loading branch information...
markstory committed Jul 4, 2010
1 parent 052c817 commit a4e2f7c55fbe7cd3ddc17c7380fd3cb575732ee3
@@ -67,7 +67,7 @@ class Component extends Object {
public function __construct(ComponentCollection $collection, $settings = array()) {
$this->_Collection = $collection;
$this->settings = $settings;
$this->_set($settings);
if (!empty($this->components)) {
$this->_componentMap = ComponentCollection::normalizeObjectArray($this->components);
}
@@ -46,7 +46,8 @@ class AclComponent extends Component {
*
* @throws Exception when Acl.classname could not be loaded.
*/
public function __construct() {
public function __construct(ComponentCollection $collection, $settings = array()) {

This comment has been minimized.

Copy link
@CauanCabral

CauanCabral Jan 3, 2013

Contributor

I'm talking about that line @markstory , but that isn't in 1.3 branche.
So, again, sorry my mistake.

This comment has been minimized.

Copy link
@markstory

markstory Jan 3, 2013

Author Member

No worries 👍

parent::__construct($collection, $settings);
$name = Inflector::camelize(strtolower(Configure::read('Acl.classname')));
if (!class_exists($name)) {
if (App::import('Component', $name)) {
@@ -86,16 +87,6 @@ public function adapter($adapter = null) {
return $this->_Instance;
}
/**
* Startup is not used
*
* @param object $controller Controller using this component
* @return boolean Proceed with component usage (true), or fail (false)
*/
public function startup(&$controller) {
return true;
}
/**
* Pass-thru function for ACL check instance. Check methods
* are used to check whether or not an ARO can access an ACO
@@ -268,7 +268,7 @@ class AuthComponent extends Component {
* @param object $controller A reference to the instantiating controller object
* @return void
*/
public function initialize(&$controller, $settings = array()) {
public function initialize(&$controller) {

This comment has been minimized.

Copy link
@CauanCabral

CauanCabral Jan 3, 2013

Contributor

Why reference? Objects are always passed by reference: http://php.net/manual/en/language.oop5.references.php

This comment has been minimized.

Copy link
@dereuromark

dereuromark Jan 3, 2013

Member

Cake1.3 still had/has PHP4 BC.

This comment has been minimized.

Copy link
@CauanCabral

CauanCabral Jan 3, 2013

Contributor

Oh, its true.
But type hinting is supported in PHP 4? www.php.net/manual/en/language.oop5.typehinting.php

This comment has been minimized.

Copy link
@lorenzo

lorenzo Jan 3, 2013

Member

Why are you even commenting on something that happened 3 years ago?

This comment has been minimized.

Copy link
@ceeram

ceeram Jan 3, 2013

Member

That page clearly says it was introduced in php5, but typehinting does not make it a reference

This comment has been minimized.

Copy link
@ADmad

ADmad Jan 3, 2013

Member

Where did you see type hinting in 1.3?

This comment has been minimized.

Copy link
@CauanCabral

CauanCabral Jan 3, 2013

Contributor

Good question @lorenzo , I saw notification for that commit at some point but don't saw the date. Sorry.

Only for clarification, type hinting are introduced at acl.php file, line 49.

This comment has been minimized.

Copy link
@markstory

markstory Jan 3, 2013

Author Member

I don't see any typehinting in the current AclShell, AclComponent or AclBehavior on line 49.

$this->params = $controller->params;
$crud = array('create', 'read', 'update', 'delete');
$this->actionMap = array_merge($this->actionMap, array_combine($crud, $crud));
@@ -290,8 +290,7 @@ public function initialize(&$controller, $settings = array()) {
));
}
}
$this->_set($settings);
if (Configure::read('debug') > 0) {
if (Configure::read() > 0) {
App::import('Debugger');
Debugger::checkSecurityKeys();
}
@@ -162,9 +162,8 @@ class CookieComponent extends Component {
*
* @param object $controller A reference to the instantiating controller object
*/
public function initialize(&$controller, $settings) {
public function initialize(&$controller) {
$this->key = Configure::read('Security.salt');
$this->_set($settings);
}
/**
@@ -303,12 +303,11 @@ class EmailComponent extends Component {
*
* @param object $controller Instantiating controller
*/
public function initialize(&$controller, $settings = array()) {
public function initialize(&$controller) {
$this->Controller = $controller;
if (Configure::read('App.encoding') !== null) {
$this->charset = Configure::read('App.encoding');
}
$this->_set($settings);
}
/**
@@ -173,8 +173,10 @@ class RequestHandlerComponent extends Component {
/**
* Constructor. Parses the accepted content types accepted by the client using HTTP_ACCEPT
*
* @param ComponentCollection $collection ComponentCollection object.
* @param array $settings Array of settings.
*/
function __construct() {
function __construct(ComponentCollection $collection, $settings = array()) {
$this->__acceptTypes = explode(',', env('HTTP_ACCEPT'));
foreach ($this->__acceptTypes as $i => $type) {
@@ -183,7 +185,7 @@ function __construct() {
$this->__acceptTypes[$i] = $type[0];
}
}
parent::__construct();
parent::__construct($collection, $settings);
}
/**
@@ -197,11 +199,10 @@ function __construct() {
* @return void
* @see Router::parseExtensions()
*/
public function initialize(&$controller, $settings = array()) {
public function initialize(&$controller) {
if (isset($controller->params['url']['ext'])) {
$this->ext = $controller->params['url']['ext'];
}
$this->_set($settings);
}
/**
@@ -169,17 +169,6 @@ class SecurityComponent extends Component {
*/
protected $_action = null;
/**
* Initialize the SecurityComponent
*
* @param object $controller Controller instance for the request
* @param array $settings Settings to set to the component
* @return void
*/
public function initialize(&$controller, $settings = array()) {
$this->_set($settings);
}
/**
* Component startup. All security checking happens here.
*
@@ -625,7 +625,7 @@ public function redirect($url, $status = null, $exit = true) {
$response = $this->Components->trigger(
'beforeRedirect',
array(&$this, $url, $status, $exit),
array('break' => true, 'breakOn' => false)
array('break' => true, 'breakOn' => false, 'collectReturn' => true)
);
if ($response === false) {

0 comments on commit a4e2f7c

Please sign in to comment.
You can’t perform that action at this time.