Fixing errors when trying to use plugin components.

Added Controller::_initComponents();
Changed helpers and components to allow using plugins helpers or 
components.
Syntax:
var $helpers = array('PluginName/HelperName');
var $components= array('PluginName/ComponentName');


git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3315 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-07-29 17:08:23 +00:00
parent e820592d69
commit 566f1b60b9
5 changed files with 25 additions and 4 deletions

View file

@ -241,7 +241,7 @@ class Dispatcher extends Object {
array_push($controller->helpers, $controller->webservices);
$component =& new Component($controller);
}
$controller->_initComponents();
$controller->constructClasses();
if ($missingAction && !in_array('scaffold', array_keys($classVars))){

View file

@ -84,11 +84,20 @@ class Component extends Object {
*/
function &_loadComponents(&$loaded, $components) {
foreach($components as $component) {
$pos = strpos($component, '/');
if ($pos === false) {
$plugin = $this->controller->plugin;
} else {
$parts = explode('/', $component);
$plugin = Inflector::underscore($parts['0']);
$component = $parts['1'];
}
$componentCn = $component . 'Component';
if (in_array($component, array_keys($loaded)) !== true) {
if (!class_exists($componentCn)) {
if (is_null($this->controller->plugin) || !loadPluginComponent($this->controller->plugin, $component)) {
if (is_null($plugin) || !loadPluginComponent($plugin, $component)) {
if (!loadComponent($component)) {
return $this->cakeError('missingComponentFile', array(array(
'className' => $this->controller->name,

View file

@ -253,13 +253,16 @@ class Controller extends Object{
}
}
}
parent::__construct();
}
function _initComponents(){
if (!empty($this->components)) {
$component = new Component();
$component->init($this);
}
parent::__construct();
}
/**
* Loads and instantiates classes required by this controller,
* including components and models

View file

@ -57,6 +57,7 @@ class ErrorHandler extends Object{
}
$this->controller =& new AppController();
$this->controller->_initComponents();
$this->__dispatch->start($this->controller);
if (method_exists($this->controller, 'apperror')) {

View file

@ -628,11 +628,19 @@ class View extends Object{
}
foreach($helpers as $helper) {
$pos = strpos($helper, '/');
if ($pos === false) {
$plugin = $this->plugin;
} else {
$parts = explode('/', $helper);
$plugin = Inflector::underscore($parts['0']);
$helper = $parts['1'];
}
$helperCn = $helper . 'Helper';
if (in_array($helper, array_keys($loaded)) !== true) {
if (!class_exists($helperCn)) {
if (is_null($this->plugin) || !loadPluginHelper($this->plugin, $helper)) {
if (is_null($plugin) || !loadPluginHelper($plugin, $helper)) {
if (!loadHelper($helper)) {
return $this->cakeError('missingHelperFile', array(array(
'helper' => $helper,