Closed 4orever closed 11 years ago
Annotations are namespace aware, if you put a backslash in front of the annotation then it should work.
namespace Backend\Direct\Model;
class Object extends \Backend\Direct\Entity
{
/**
* @\KJSencha\Annotation\Formhandler
*/
public function update($entity, $id)
{
// TODO: Implement update() method.
return array();
}
}
My preferred way to handle annotations is demonstrated in this file
I have tried '@\KJSencha\Annotation\Formhandler' and 'use KJSencha\Annotation as Ext' + '@Ext\Formhandler' - no result
Here is some additional info about the problem:
http://stackoverflow.com/questions/14674693/kjsencha-formhandler-annotation-doesnt-work
I've committed the project to GitHub. Could you try it? https://github.com/4orever/prompc_v2
Thanks, i'll give it a try
I can't seem to reproduce the problem, when i run your IndexController i recieve a valid ExtJS Api with a formhandler on the update method. Which PHP version are you using? I can add a unit test which could reproduce the problem through Travis CI.
PHP Version 5.3.14
This is the output on http://localhost/backend/
<!DOCTYPE html> <html lang="en">
<head>
<meta charset="utf-8">
<title>PROM-PC v.2</title> <link href="http://cdn.sencha.io/ext-4.1.1-gpl/resources/css/ext-all.css" media="screen" rel="stylesheet" type="text/css"><script type="text/javascript" src="http://cdn.sencha.io/ext-4.1.1-gpl/ext-all-debug.js"></script>
<script type="text/javascript">
//<!--
var App={"basePath":""};
//-->
</script>
<script type="text/javascript">
//<!--
Ext.Loader.setConfig({"enabled":true,"paths":{"KJSencha":"\/js\/classes\/KJSencha"}}); //-->
</script>
<script type="text/javascript">
//<!--
Ext.syncRequire(["KJSencha.direct.ModuleRemotingProvider"]); //-->
</script>
<script type="text/javascript">
//<!--
Ext.direct.Manager.addProvider({"type":"kjsenchamoduleremoting","url":"\/kjsencha\/rpc\/","actions":{"Direct.Tree":[{"name":"read","len":2},{"name":"update","len":2},{"name":"create","len":2},{"name":"destroy","len":2}],"Direct.Single":[{"name":"read","len":2},{"name":"create","len":2},{"name":"update","len":2},{"name":"destroy","len":2}],"Direct.Collection":[{"name":"read","len":2},{"name":"create","len":2},{"name":"update","len":2},{"name":"destroy","len":2}],"KJSencha.echo":[{"name":"__construct","len":1},{"name":"greet","len":1}]}}); //-->
</script> </head>
<body>
<script type="text/javascript" src="/backend/js/app.js"></script>
</body>
</html>
The tests are green, you can try and run them locally by running the ant build. Could you check if the tests work locally, if they do then i have to look into your application further.
Thank you for helping me!
Sorry, I'm not familiar in UnitTesting. So I'll describe my steps and you'll check it, please.
Here is the result:
Time: 0 seconds, Memory: 10.25Mb
OK (9 tests, 37 assertions)
Process finished with exit code 0
P.S. I had to comment this lines:
$this->assertInstanceOf('Zend\Http\PhpEnvironment\Response', $result);
$this->assertInstanceOf('Zend\View\Model\JsonModel', $result);
Because of error: Fatal error: Call to undefined method KJSenchaTest\Frontend\DirectControllerTest::assertInstanceOf() in C:\Projects\KJSencha-master\tests\KJSenchaTest\Controller\DirectControllerTest.php on line 98
I think something wrong with my PHPUnit installation or IDE. But this lines have no matter in our case(?)
The steps you have taken look good, you have to upgrade your PHPUnit version, according to the source that method is available since 3.5.0
I'm not familiar with Zend Server and how this affects annotation parsing, you may have a configuration difference between your cli and web environment.
To verify this could you try and run the KJSenchaExample without any modifications and submit the Profile form? If this works then i'm sure its something in your application code.
I've tried KJSenchaExample before posting the issue. It works correctly. Then I was looking for important differences with my code, but found nothing. I can upgrade PHPUnit and PHP, also I can install XAMPP or smth like that, but I think problem is in other place. How did you test my code? Did you open http://localhost/backend/ and check output HTML and Ext.direct.Manager.addProvider()?
I tested both the IndexAction and ApiAction using the /backend/
url. In IndexAction i replaced the code with this:
public function indexAction() {
return array();
}
I will take a further look into your code tomorrow
Ok, thank you! I'll try to test it on Unix server.
On UNIX it works great!
http://dev1.prom-pc.ru/public/backend/
http://dev1.prom-pc.ru/phpinfo.php
I will try to install XAMPP instead of Zend Studio tomorrow.
No result with XAMPP.
I decided to play with KJSecnhaExmaple and... It's incredible, but when I copied Direct\Form\Profile.php, renamed the file and class name and run script - it didn't work!
But if you rename Profile.php and its class, or modify it, or add new @Formhandler method - everything works good.
Problem solved!
Answer found here: http://stackoverflow.com/questions/11836787/zend-reflection-doesnt-get-the-docblock-for-certain-classes
Try to convert the line endings from Windows to Unix style.
F%cking Windows! I spent lots of time!
P.S. May be post it as a bug of Zend/Reflection?
Good to hear that you found the solution! I'm not sure if this is considered as a bug because Zend Framwork 2 conforms to the PSR 2 code standard which forces the UNIX line ending (source)
Most IDE's have the option to automatically convert line endings to UNIX style, which i would recommend using. This is maybe why i couldn't reproduce the problem.
I'm closing this issue as fixed, if you have any other questions feel free to open another issue.
I want to make Object->update() to be a form handler.
I spent some hours to find the reason, but apiBuilder still doesn't append 'formHandler: true' to my method.
Are there any things to do except this?
And this is the module.config.php