Advertisement
petrabarus

Untitled

Oct 7th, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. I'm having problem with logging in. So can I put my comment here?
  2. I just want to add example for the autocompletion especially about
  3. CWebApplication component injection. Although I'm still not sure
  4. enough if this is important enough to be in the new Yii NB Plugin.
  5.  
  6. The nice thing I like about Yii is that I can easily add component
  7. in the CWebApplication from the config (/protected/config/main.php.
  8. this is the default config file for production)
  9.  
  10. e.g.
  11.  
  12. <?php
  13. //CONFIG #1
  14. return array(
  15. //cut
  16. 'components' => array(
  17. 'user' => array(
  18. 'allowAutoLogin' => true,
  19. )
  20. )
  21. //cut
  22. );
  23.  
  24.  
  25. the current Netbeans can detect the App singleton in Yii class,
  26. although it only detects the singleton as CApplication instead of
  27. CWebApplication (if I code it for the web endpoint not console).
  28.  
  29. It will be nice if the NB can do autocomplete for the 'component' config.
  30.  
  31. Let's say if I had the config #1 above, and I type `Yii::app()->us`
  32. it can complete to `Yii::app()->user` and knows that `Yii::app()->user`
  33. is the default CWebUser (see [1] and [2])
  34.  
  35. And what's really nice about the `component` part in the config, I can
  36. change the class for `user` component.
  37.  
  38. <?php
  39. //CONFIG #2
  40. return array(
  41. //cut
  42. 'components' => array(
  43. 'user' => array(
  44. 'class' => 'MyWebUser',
  45. 'allowAutoLogin' => true,
  46. )
  47. )
  48. //cut
  49. );
  50.  
  51. So, if I type `Yii::app()->user`, it would be nice if NetBeans could
  52. know if the `user` field is an instance of `MyWebUser`.
  53.  
  54. Another thing is, as I mentioned above, that I can add custom component
  55. to `Yii::app()` singleton.
  56.  
  57. <?php
  58. //CONFIG #3
  59. return array(
  60. //cut
  61. 'components' => array(
  62. 'myComponent' => array(
  63. 'class' => 'MyComponentClass',
  64. )
  65. )
  66. //cut
  67. );
  68.  
  69. This is not the default `CWebApplication` components as stated in [1],
  70. but this is what I really like from Yii. I can just call my component
  71. by `Yii::app()->myComponent`. And it would be nice if NetBeans could
  72. know if the `myComponent` is an instance of `MyComponentClass`.
  73.  
  74. Again, I'm not sure if it's important enough for everyone else and
  75. I'm already getting used to it. But I'm just suggesting. :)
  76.  
  77.  
  78. [1] http://www.yiiframework.com/doc/api/1.1/CWebApplication
  79. [2] https://github.com/yiisoft/yii/blob/1.1.12/framework/web/CWebApplication.php#L208
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement