ErrorException [ Fatal Error ]: Class 'Database_PDO' not found - kohana

I'm trying to extend Kohana_Database_PDO located in
kohana\modules\database\classes\Kohana\Database
To do this I made a file in PDO.php file in
kohana\application\classes\database
The code I am using is
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* PDO database connection.
*
* #package Application
* #category Drivers
*/
class Application_Database_PDO extends Kohana_Database_PDO {} // End Database_PDO
I get the error:
ErrorException [ Fatal Error ]: Class 'Database_PDO' not found
MODPATH\database\classes\Kohana\Database.php [ 78 ]
// Set the driver class name
$driver = 'Database_'.ucfirst($config['type']);
// Create the database connection instance
$driver = new $driver($name, $config); <- highlighted line
// Store the database instance
Database::$instances[$name] = $driver;
}
{PHP internal call} ยป Kohana_Core::shutdown_handler()
Thanks for your help :)

If this code:
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* PDO database connection.
*
* #package Application
* #category Drivers
*/
class Application_Database_PDO extends Kohana_Database_PDO {} // End Database_PDO
is the code in your PDO.php file which resides in APPPATH/classes/Database then it is no wonder that it doesn't work.
your file should look like this:
<?php defined('SYSPATH') or die('No direct script access.');
/**
* PDO database connection.
*
* #package Application
* #category Drivers
*/
class Database_PDO extends Kohana_Database_PDO {...
otherwise if you need it to be Application_... then you have to do your folderstructure like this: APPPATH/classes/Application/Database/PDO.php
Kohana by default explodes the Classname using the _ as the needle and uses every string part as a directory except for the last one which is the filename

Related

Get JSDoc comments Node js

I use PHP's reflectionclass to write my own API documentation generator where it generates Documentation for some functions and classes by getting the Doc Comments attached to them and parsing it.
Now I need to do the same in Node.js. Is there a built-in JavaScript function that can find JSDoc comments of a specific identifier? I mean without having to write code to manually parse the source code as in this JSDoc regex question asked earlier
I need something just like in this PHP example
<?php
/**
* A test class
*
* #param foo bar
* #return baz
*/
class TestClass { }
$rc = new ReflectionClass('TestClass');
var_dump($rc->getDocComment())
?>
Output:
string(55) "/**
* A test class
*
* #param foo bar
* #return baz
*/"

Spring Integration - Spel Mapping of Gateway Parameters

I have the following interface, who's implementation will encrypt a file at a specific path.
package xx.messaging.fileTransfer;
import org.springframework.integration.annotation.Gateway;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Payload;
/**
* <H1>FileEncryptionService</H1>
*/
public interface FileEncryptionService {
/**
* Generates a new encrypted filename based on the input, calls the default method and returns
* the encrypted file name
* #param srcFilename
* #return
* #throws Exception
*/
#Gateway
public String encryptFile(#Payload String srcFilename) throws Exception;
/**
* Encrypt the a file
* #param srcFilename The source file name
* #param destFilename The target file name
*/
#Gateway
public void encryptFile(#Payload String srcFilename, #Header("encryptedFilename") String destFilename);
}
The service will be called via the spring integration and is registered in the context as a gateway via
<int:gateway service-interface="lu.scoteqint.messaging.fileTransfer.FileEncryptionService"/>
The implementing bean and service-activator are registered as
<beans:bean id="fileEncryptionService" class="xx.messaging.fileTransfer.impl.CommandLineEncryptionService"/>
<int:service-activator
input-channel="file1"
output-channel="file2"
expression="#fileEncryptionService.encryptFile(payload)"/>
I'm expecting that the message payload is the string path to the file, since the wire-tag log shows
2013-02-05 15:50:26,911 DEBUG [org.springframework.integration.handler.LoggingHandler] (task-scheduler-1) [Payload=.\src\test\resources\test\xx.xml][Headers={timestamp=1360079426907, id=1c3be020-fc6d-42ba-b3f0-5b963f76fb76}]
But it seems the 'service-activator' expression finds a File.
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 31): Method call: Method encryptFile(java.io.File) cannot be found on lu.scoteqint.messaging.fileTransfer.impl.CommandLineEncryptionService type
at org.springframework.expression.spel.ast.MethodReference.findAccessorForMethod(MethodReference.java:182)
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:106)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126)
at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:86)
... 30 more
EDIT
The log detail
2013-02-05 16:26:42,737 DEBUG [org.springframework.integration.channel.DirectChannel] (task-scheduler-1) preSend on channel 'file1', message: [Payload=.\src\test\resources\test.xml][Headers={timestamp=1360081602736, id=877407f6-c5a2-4bea-9ec7-f970b09f08a8}]
Is there a way to ensure the parameter is mapped as a String rather than a File?

Kohana ErrorException [ Fatal Error ]: Call to undefined method Request::redirect()

I'm using Kohana 3.3.0 and i have a controller which is supposed to save blog articles to a database then redirect to the homepage, my code is as follows:-
class Controller_Article extends Controller {
const INDEX_PAGE = 'index.php/article';
public function action_post() {
$article_id = $this->request->param('id');
$article = new Model_Article($article_id);
$article->values($_POST); // populate $article object from $_POST array
$article->save(); // saves article to database
$this->request->redirect(self::INDEX_PAGE);
}
The article saves to database but the redirect line gives the error:-
ErrorException [ Fatal Error ]: Call to undefined method Request::redirect()
Please let me know how i can do the redirect.
Thanks
You're getting the Exception because as of Kohana 3.3, Request no longer has the method redirect.
You can fix your example by replacing
$this->request->redirect(self::INDEX_PAGE);
with
HTTP::redirect(self::INDEX_PAGE);
Yeah, Request::redirect is not longer exists. So in order to easily to move from 3.2 to 3.3 I extented Kohana_Request class and added redirect method. Just create Request.php in classes folder and write
class Request extends Kohana_Request {
/**
* Kohana Redirect Method
* #param string $url
*/
public function redirect($url) {
HTTP::redirect($url);
}
}
So you will be able to use both Request::redirect and $this->request->redirect
in your controller $this->redirect('page');
$this->redirect('article/index');

JSDoc3 & NodeJS link to types from modules

I try to find how to let JSDoc3 automatically generate links to classes from other modules.
I find it hard to explain in words, so let me give some examples. The following script generates the expected output:
/**
* #constructor
*/
var SomeClass = function(){}
/**
* #param {SomeClass} someParam description
*/
var someFunc = function(someParam){}
That is, JSDoc3 correctly generates a link from the parameter list of someFunc to the class description of SomeClass. However, when I put SomeClass in an external module I can't seem to let JSDoc3 generate the links:
/**
* #file SomeClass.js
* #module SomeClass
*/
/**
* #constructor
*/
exports.SomeClass(){}
/**
* #file main.js
*/
var SomeClass = require('./SomeClass');
/**
* #param {SomeClass} someParam description
*/
function someFunc(someParam){}
Now JSDoc3 correctly generates the documentation for both files, but it doesn't link the parameter type of someFunc to the page of SomeClass. I tried replacing #param {SomeClass} with:
#param {SomeClass.SomeClass}
#param {SomeClass/SomeClass}
#param {#link SomeClass}
#param {#link SomeClass.SomeClass}
#param {#link SomeClass/SomeClass}
But none of these worked: in all cases the documentation simply shows the text inside the curly brackets (even when I used #link).
How can I let JSDoc3 correctly generate links to the external modules?
Use the module: prefix when referencing modules. If the module's return value is the class itself, then use module:SomeClass. If it is a property of the module, use module:SomeClass.SomeClass. The #link tag shouldn't be necessary if jsdoc can find a reference to the existing class documentation.
Use typeof import
/**
* #param {typeof import("puppeteer").Browser} browser
*/
Docs here

Why can't Kohana find my controller?

I have the following controller:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Static extends Controller_DefaultTemplate {
public function action_index()
{
View::set_global('message', '<span class="highlight">This is a global message.</span>');
$data = array (
'siteTitle' => 'Kohana Test Site',
'siteSubtitle' => 'A site to learn Kohana',
'menu' => View::factory('blocks/menu'),
);
$view = View::factory('templates/layout', $data);
$this->request->response = $view->render();
}
}
but kohana gives me the error:
ErrorException [ Fatal Error ]: Class
'Controller_DefaultTemplate' not found
although Eclipse can find the file (via F3) and I thought Kohana was able to find all classes via autoloading?
How can I get Kohana to find the Controller_DefaultTemplate class so I can extend Controller_Static?
You must include file with definition of Controller_DefaultTemplate
The problem was that my file name defaultTemplate.php was camel case, changing it to all-lowercase defaultemplate.php enabled Kohana to find the class inside it.

Resources