Skip to content

Commit

Permalink
Rename variable/class references to collection classes.
Browse files Browse the repository at this point in the history
Replace many collection based references with the real class changes.
  • Loading branch information
markstory committed Jul 27, 2013
1 parent 84c627f commit 11658f4
Show file tree
Hide file tree
Showing 49 changed files with 152 additions and 143 deletions.
6 changes: 3 additions & 3 deletions lib/Cake/Console/Command/AclShell.php
Expand Up @@ -19,7 +19,7 @@
namespace Cake\Console\Command;

use Cake\Console\Shell;
use Cake\Controller\ComponentCollection;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Component\AclComponent;
use Cake\Controller\Controller;
use Cake\Core\App;
Expand Down Expand Up @@ -97,8 +97,8 @@ public function startup() {
}

if (!in_array($this->command, array('initdb'))) {
$collection = new ComponentCollection();
$this->Acl = new AclComponent($collection);
$registry = new ComponentRegistry();
$this->Acl = new AclComponent($registry);
$controller = new Controller();
$this->Acl->startup($controller);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Console/Command/Task/TestTask.php
Expand Up @@ -522,8 +522,8 @@ public function generateConstructor($type, $fullClassName, $plugin) {
$construct = "new {$className}(\$View);\n";
}
if ($type === 'component') {
$pre = "\$Collection = new ComponentCollection();\n";
$construct = "new {$className}(\$Collection);\n";
$pre = "\$registry = new ComponentRegistry();\n";
$construct = "new {$className}(\$registry);\n";
}
return array($pre, $construct, $post);
}
Expand All @@ -540,7 +540,7 @@ public function generateUses($type, $realType, $fullClassName) {
$uses = array();
$type = strtolower($type);
if ($type == 'component') {
$uses[] = 'Cake\Controller\ComponentCollection';
$uses[] = 'Cake\Controller\ComponentRegistry';
}
if ($type == 'helper') {
$uses[] = 'Cake\View\View';
Expand Down
10 changes: 10 additions & 0 deletions lib/Cake/Console/Command/UpgradeShell.php
Expand Up @@ -422,6 +422,16 @@ public function rename_collections() {
$this->_findFiles('php');
foreach ($this->_files as $filePath) {
$patterns = [
[
' Replace $this->_Collection with $this->_registry',
'#\$this->_Collection#',
'$this->_registry',
],
[
' Replace ComponentCollection arguments',
'#ComponentCollection\s+\$collection#',
'ComponentRegistry $registry',
],
[
' Rename ComponentCollection',
'#ComponentCollection#',
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Shell.php
Expand Up @@ -138,7 +138,7 @@ class Shell extends Object {
/**
* Task Collection for the command, used to create Tasks.
*
* @var TaskCollection
* @var TaskRegistry
*/
public $Tasks;

Expand Down Expand Up @@ -183,7 +183,7 @@ public function __construct($stdout = null, $stderr = null, $stdin = null) {
list(, $class) = namespaceSplit(get_class($this));
$this->name = str_replace(array('Shell', 'Task'), '', $class);
}
$this->Tasks = new TaskCollection($this);
$this->Tasks = new TaskRegistry($this);

$this->stdout = $stdout ? $stdout : new ConsoleOutput('php://stdout');
$this->stderr = $stderr ? $stderr : new ConsoleOutput('php://stderr');
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/TaskCollection.php
Expand Up @@ -19,10 +19,10 @@
use Cake\Utility\ObjectRegistry;

/**
* Collection object for Tasks. Provides features
* Registry for Tasks. Provides features
* for lazily loading tasks.
*/
class TaskCollection extends ObjectRegistry {
class TaskRegistry extends ObjectRegistry {

/**
* Shell to use to set params to tasks.
Expand Down
14 changes: 7 additions & 7 deletions lib/Cake/Controller/Component.php
Expand Up @@ -65,11 +65,11 @@
class Component extends Object implements EventListener {

/**
* Component collection class used to lazy load components.
* Component registry class used to lazy load components.
*
* @var ComponentCollection
* @var ComponentRegistry
*/
protected $_Collection;
protected $_registry;

/**
* Settings for this Component
Expand All @@ -95,11 +95,11 @@ class Component extends Object implements EventListener {
/**
* Constructor
*
* @param ComponentCollection $collection A ComponentCollection this component can use to lazy load its components
* @param ComponentRegistry $registry A ComponentRegistry this component can use to lazy load its components
* @param array $settings Array of configuration settings.
*/
public function __construct(ComponentCollection $collection, $settings = array()) {
$this->_Collection = $collection;
public function __construct(ComponentRegistry $registry, $settings = []) {
$this->_registry = $registry;
$this->settings = $settings;
$this->_set($settings);
if (!empty($this->components)) {
Expand All @@ -116,7 +116,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
public function __get($name) {
if (isset($this->_componentMap[$name]) && !isset($this->{$name})) {
$settings = array_merge((array)$this->_componentMap[$name]['settings'], array('enabled' => false));
$this->{$name} = $this->_Collection->load($this->_componentMap[$name]['class'], $settings);
$this->{$name} = $this->_registry->load($this->_componentMap[$name]['class'], $settings);
}
if (isset($this->{$name})) {
return $this->{$name};
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Controller/Component/AclComponent.php
Expand Up @@ -16,7 +16,7 @@

use Cake\Configure\IniReader;
use Cake\Controller\Component;
use Cake\Controller\ComponentCollection;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Component\Acl\AclInterface;
use Cake\Core\App;
use Cake\Core\Configure;
Expand Down Expand Up @@ -61,11 +61,11 @@ class AclComponent extends Component {
/**
* Constructor. Will return an instance of the correct ACL class as defined in `Configure::read('Acl.classname')`
*
* @param ComponentCollection $collection
* @param ComponentRegistry $collection
* @param array $settings
* @throws Cake\Error\Exception when Acl.classname could not be loaded.
*/
public function __construct(ComponentCollection $collection, $settings = array()) {
public function __construct(ComponentRegistry $collection, $settings = array()) {
parent::__construct($collection, $settings);
$classname = $name = Configure::read('Acl.classname');
if (!class_exists($classname)) {
Expand Down
5 changes: 2 additions & 3 deletions lib/Cake/Controller/Component/Auth/ActionsAuthorize.php
Expand Up @@ -19,9 +19,8 @@

/**
* An authorization adapter for AuthComponent. Provides the ability to authorize using the AclComponent,
* If AclComponent is not already loaded it will be loaded using the Controller's ComponentCollection.
* If AclComponent is not already loaded it will be loaded using the Controller's ComponentRegistry.
*
* @package Cake.Controller.Component.Auth
* @since 2.0
* @see AuthComponent::$authenticate
* @see AclComponent::check()
Expand All @@ -36,7 +35,7 @@ class ActionsAuthorize extends BaseAuthorize {
* @return boolean
*/
public function authorize($user, Request $request) {
$Acl = $this->_Collection->load('Acl');
$Acl = $this->_registry->load('Acl');
$user = array($this->settings['userModel'] => $user);
return $Acl->check($user, $this->action($request));
}
Expand Down
14 changes: 7 additions & 7 deletions lib/Cake/Controller/Component/Auth/BaseAuthenticate.php
Expand Up @@ -15,7 +15,7 @@
*/
namespace Cake\Controller\Component\Auth;

use Cake\Controller\ComponentCollection;
use Cake\Controller\ComponentRegistry;
use Cake\Error;
use Cake\Network\Request;
use Cake\Network\Response;
Expand Down Expand Up @@ -58,11 +58,11 @@ abstract class BaseAuthenticate {
);

/**
* A Component collection, used to get more components.
* A Component registry, used to get more components.
*
* @var ComponentCollection
* @var ComponentRegistry
*/
protected $_Collection;
protected $_registry;

/**
* Password hasher instance.
Expand All @@ -74,11 +74,11 @@ abstract class BaseAuthenticate {
/**
* Constructor
*
* @param ComponentCollection $collection The Component collection used on this request.
* @param ComponentRegistry $registry The Component registry used on this request.
* @param array $settings Array of settings to use.
*/
public function __construct(ComponentCollection $collection, $settings) {
$this->_Collection = $collection;
public function __construct(ComponentRegistry $registry, $settings) {
$this->_registry = $registry;
$this->settings = Hash::merge($this->settings, $settings);
}

Expand Down
16 changes: 8 additions & 8 deletions lib/Cake/Controller/Component/Auth/BaseAuthorize.php
Expand Up @@ -15,7 +15,7 @@
*/
namespace Cake\Controller\Component\Auth;

use Cake\Controller\ComponentCollection;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Controller;
use Cake\Error;
use Cake\Network\Request;
Expand All @@ -40,11 +40,11 @@ abstract class BaseAuthorize {
protected $_Controller = null;

/**
* Component collection instance for getting more components.
* ComponentRegistry instance for getting more components.
*
* @var ComponentCollection
* @var ComponentRegistry
*/
protected $_Collection;
protected $_registry;

/**
* Settings for authorize objects.
Expand Down Expand Up @@ -72,12 +72,12 @@ abstract class BaseAuthorize {
/**
* Constructor
*
* @param ComponentCollection $collection The controller for this request.
* @param ComponentRegistry $registry The controller for this request.
* @param string $settings An array of settings. This class does not use any settings.
*/
public function __construct(ComponentCollection $collection, $settings = array()) {
$this->_Collection = $collection;
$controller = $collection->getController();
public function __construct(ComponentRegistry $registry, $settings = array()) {
$this->_registry = $registry;
$controller = $registry->getController();
$this->controller($controller);
$this->settings = Hash::merge($this->settings, $settings);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Controller/Component/Auth/BasicAuthenticate.php
Expand Up @@ -15,7 +15,7 @@
*/
namespace Cake\Controller\Component\Auth;

use Cake\Controller\ComponentCollection;
use Cake\Controller\ComponentRegistry;
use Cake\Error;
use Cake\Network\Request;
use Cake\Network\Response;
Expand Down Expand Up @@ -50,11 +50,11 @@ class BasicAuthenticate extends BaseAuthenticate {
/**
* Constructor, completes configuration for basic authentication.
*
* @param ComponentCollection $collection The Component collection used on this request.
* @param ComponentRegistry $registry The Component registry used on this request.
* @param array $settings An array of settings.
*/
public function __construct(ComponentCollection $collection, $settings) {
parent::__construct($collection, $settings);
public function __construct(ComponentRegistry $registry, $settings) {
parent::__construct($registry, $settings);
if (empty($this->settings['realm'])) {
$this->settings['realm'] = env('SERVER_NAME');
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Controller/Component/Auth/BlowfishAuthenticate.php
Expand Up @@ -15,7 +15,7 @@
*/
namespace Cake\Controller\Component\Auth;

use Cake\Controller\ComponentCollection;
use Cake\Controller\ComponentRegistry;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\Utility\Security;
Expand Down Expand Up @@ -48,12 +48,12 @@ class BlowfishAuthenticate extends FormAuthenticate {
/**
* Constructor. Sets default passwordHasher to Blowfish
*
* @param ComponentCollection $collection The Component collection used on this request.
* @param ComponentRegistry $registry The Component registry used on this request.
* @param array $settings Array of settings to use.
*/
public function __construct(ComponentCollection $collection, $settings) {
public function __construct(ComponentRegistry $registry, $settings) {
$this->settings['passwordHasher'] = 'Blowfish';
parent::__construct($collection, $settings);
parent::__construct($registry, $settings);
}

}
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/Auth/ControllerAuthorize.php
Expand Up @@ -15,7 +15,7 @@
*/
namespace Cake\Controller\Component\Auth;

use Cake\Controller\ComponentCollection;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Controller;
use Cake\Error;
use Cake\Network\Request;
Expand Down
10 changes: 5 additions & 5 deletions lib/Cake/Controller/Component/Auth/CrudAuthorize.php
Expand Up @@ -15,7 +15,7 @@
*/
namespace Cake\Controller\Component\Auth;

use Cake\Controller\ComponentCollection;
use Cake\Controller\ComponentRegistry;
use Cake\Network\Request;
use Cake\Routing\Router;

Expand All @@ -39,11 +39,11 @@ class CrudAuthorize extends BaseAuthorize {
/**
* Sets up additional actionMap values that match the configured `Routing.prefixes`.
*
* @param ComponentCollection $collection The component collection from the controller.
* @param ComponentRegistry $registry The component registry from the controller.
* @param string $settings An array of settings. This class does not use any settings.
*/
public function __construct(ComponentCollection $collection, $settings = array()) {
parent::__construct($collection, $settings);
public function __construct(ComponentRegistry $registry, $settings = array()) {
parent::__construct($registry, $settings);
$this->_setPrefixMappings();
}

Expand Down Expand Up @@ -94,7 +94,7 @@ public function authorize($user, Request $request) {
return false;
}
$user = array($this->settings['userModel'] => $user);
$Acl = $this->_Collection->load('Acl');
$Acl = $this->_registry->load('Acl');
return $Acl->check(
$user,
$this->action($request, ':controller'),
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Controller/Component/Auth/DigestAuthenticate.php
Expand Up @@ -15,7 +15,7 @@
*/
namespace Cake\Controller\Component\Auth;

use Cake\Controller\ComponentCollection;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Component\Auth\BasicAuthenticate;
use Cake\Network\Request;
use Cake\Network\Response;
Expand Down Expand Up @@ -98,11 +98,11 @@ class DigestAuthenticate extends BasicAuthenticate {
/**
* Constructor, completes configuration for digest authentication.
*
* @param ComponentCollection $collection The Component collection used on this request.
* @param ComponentRegistry $registry The Component registry used on this request.
* @param array $settings An array of settings.
*/
public function __construct(ComponentCollection $collection, $settings) {
parent::__construct($collection, $settings);
public function __construct(ComponentRegistry $registry, $settings) {
parent::__construct($registry, $settings);
if (empty($this->settings['nonce'])) {
$this->settings['nonce'] = uniqid('');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/Auth/FormAuthenticate.php
Expand Up @@ -15,7 +15,7 @@
*/
namespace Cake\Controller\Component\Auth;

use Cake\Controller\ComponentCollection;
use Cake\Controller\ComponentRegistry;
use Cake\Network\Request;
use Cake\Network\Response;

Expand Down

0 comments on commit 11658f4

Please sign in to comment.