Yii Framework Forum: How To Extend Capplication Class - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Extend Capplication Class How to extend CApplication class without rewriting CWebapplication, Rate Topic: -----

#1 User is offline   Meghraj Choudhary 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 30-November 12

Posted 15 March 2013 - 12:34 AM

hello all,
can you please help me a little, how can i extend capplication class, i need some core thing there, that will be common in WebApplication and ConsoleApplication, and i also don't want to rewrite CWebApplication code. for example see this code

"WebApplication extends CWebApplication" and "ConsoleApplication extends CConsoleApplication", and i want something common in both so i have to "Application extends CApplication", but how CWebApplication and CConsoleApplication extends from this "Application"

i want my code to be suppoted in php 5.3,
do you have any idea, best pratices, any solution,

Thanks, all for this great framework
0

#2 User is offline   Meghraj Choudhary 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 30-November 12

Posted 15 March 2013 - 09:47 AM

is there someone who can help me?
0

#3 User is offline   acorncom 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 100
  • Joined: 25-February 11
  • Location:CO, USA

Posted 19 March 2013 - 12:41 AM

If you want your code to work for both a web and console app, the best solution is to write a behavior for you app model. Then you can have your logic in there
0

#4 User is offline   Meghraj Choudhary 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 30-November 12

Posted 19 March 2013 - 01:10 AM

just a day ago i remembered this, how can i forget this ! damm!
Thanks brother !
0

#5 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 19 March 2013 - 01:20 AM

There's a lot of options here, Meghraj.

You can use the Controller class (in protected/components), or you can write an application component. Or a behavior.
It depends.
Yii is flexible enough. ;)
"Less noise - more signal"
0

#6 User is offline   Meghraj Choudhary 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 30-November 12

Posted 19 March 2013 - 01:27 AM

Thanks jacmoe, hi jacmoe do know something better approach for modules, i am trying to load all my modules once, when application starts, so all enabled modules will load and according to their dependency, so they can communicate with each other, do you know any good example of code where application is divided into modules, like a base module will load front page, and other module will get a chance to inject their items in menus, etc trough event, hook or anything,

please suggest me some good examples of code if you know any, or something about idea,
0

#7 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 19 March 2013 - 01:36 AM

Put the module names in the preload array in your main config.

Besides that, I am not really using modules much myself, as I always end up making them application specific anyway (and thus defeating the purpose).

You can use CAction to attach common functionality to controllers. I think that's better.
Browse through our wiki; there's a lot of good information there.
Or search for it. Google search is better than the forum search (which kind of sucks).
Github/Bitbucket is also a good place to look for Yii code..
"Less noise - more signal"
0

#8 User is offline   Meghraj Choudhary 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 30-November 12

Posted 19 March 2013 - 01:38 AM

Thanks jacmoe.
0

#9 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 19 March 2013 - 01:39 AM

Model behaviors are also great, btw. :)

The Yii Guide is recommended - find it under Documentation / tutorials.
"Less noise - more signal"
0

#10 User is offline   Meghraj Choudhary 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 30-November 12

Posted 19 March 2013 - 01:43 AM

i know, its really great and similar to php traits , and i am also watching code of yupe-cms, zurmo which are most powerfull apps buid on top of yii (as i see yet)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users