Suppose I have the following functions:
public function vardump($var, $controller = false)
{
ob_start();
$this->_vardump($var, (bool)$controller);
$output = ob_get_clean();
if ($controller) {
$controller->BResponse->set($output)->output('text/html');
} else {
// output to file
}
}
/**
* Reference BDebug::dump()
*/
protected function _vardump($var, $isController)
{
// some code similar to BDebug::dump()
}
The above would be inside a helper in Magento, which can be called anywhere. In Sellvana, there is no such thing, or is there? So, I think I can add that to the BDebug class. And I want to be able to call vardump
like this:
// in a controller
return $this->BDebug->vardump($var, $this);
// in other classes
return $this->BDebug->vardump($var);
However, I don't know what's bootstrapping, so how do I create the bootstrap method:
BModuleRegistry::i()->addMethod('BDebug', 'vardump', $whatIscallback);
What should be $callback
, is there a code snippets I can reference? [edit] I got it working now.
And I'm trying the override
method: [edit] I still need to get this to work.
modules:
Celera_Clog:
version: 0.1.0
require: { module: [ FCom_Core ] }
description: "Celera Clog Module"
areas:
FCom_Frontend:
routing:
- [ /clog, Celera_Clog_Frontend_Controller.index ]
- [ /clog/info, Celera_Clog_Frontend_Controller.info ]
- [ /clog/ip, Celera_Clog_Frontend_Controller.ip ]
override:
module:
- [ BDebug, Celera_Clog_Debug ]
I created a file class Celere_Clog_Debug extends BDebug
and inserted the vardump functions in it. This returns ERROR: Invalid method: BDebug::vardump (core/FCom/Core/buckyball/com/core.php:1320)
. How do I fix it?
[EDIT]
I manged to figure out how to addMethod
:
manifest.yml
modules:
Celera_Clog:
version: 0.1.0
require: { module: [ FCom_Core ] }
description: "Celera Clog Module"
bootstrap: { file: Debug.php, callback: [Celera_Clog_Debug, bootstrap] }
areas:
FCom_Frontend:
routing:
- [ /clog, Celera_Clog_Frontend_Controller.index ]
- [ /clog/info, Celera_Clog_Frontend_Controller.info ]
- [ /clog/ip, Celera_Clog_Frontend_Controller.ip ]
#override:
# module:
# - [ BDebug, Celera_Clog_Debug ]
The bootsrap file:
class Celera_Clog_Debug extends BDebug
{
public static function bootstrap()
{
//BModuleRegistry::i()->addMethod('BDebug', 'vardump', ['Celera_Clog_Debug', 'vardump']); // this returns an error: Invalid method
BClassRegistry::i()->addMethod('BDebug', 'vardump', ['Celera_Clog_Debug', 'vardump']);
}
public static function vardump()
{
$var = func_get_args();
#ob_start();
#self::_vardump($var);
#$output = ob_get_clean();
$controller->BResponse->set('testing')->output('text/html');
}