mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
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:
parent
e820592d69
commit
566f1b60b9
5 changed files with 25 additions and 4 deletions
|
@ -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))){
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue