Yii Framework Forum: Generate BaseController and BaseModel in gii - Yii Framework Forum

Jump to content

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

Generate BaseController and BaseModel in gii Rate Topic: -----

#1 User is offline   liang 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 26-June 10

Posted 29 June 2010 - 01:03 PM

I just started learning Yii. The gii is very cool. It is very useful for quick prototyping. But I am wondering why it does not generate a BaseController and a BaseModel, and then derive actual controllers/models from the base class? By doing this, we can put code that is common to all controllers/models in the BaseController/BaseModel without having to modify Yii core classes.

Will gii give us an option to do this in the future? Or there is already a simple way to do this without hacking into source code of gii?
0

#2 User is offline   PoL 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 506
  • Joined: 05-November 08
  • Location:Buenos Aires, Argentina

Posted 29 June 2010 - 01:13 PM

Actully, the BaseController you speak is called Controller.php and is located under protected/components....
About BaseModel (or BaseActiveRecord) this is not done by Gii, but you easily can make it yourserlf... just create the clase in protected/components, ej.: ActiveRecord.php (whose class must be ActiveRecord and inherit prom CActiveRecord)
And then make all your model inherit form ActiveRecord (instead of CActiveRecord)
Don't say what you think, think what you say
The problem is communication! Excess of communication!
0

#3 User is offline   mech7 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 220
  • Joined: 26-March 09

Posted 29 June 2010 - 09:59 PM

I have found a use for a base controller but never for a base model? What functionality do you find in a model that you want to share in every model ?
0

#4 User is offline   Slivicon 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 14-February 13

Posted 14 April 2013 - 11:23 AM

View Postmech7, on 29 June 2010 - 09:59 PM, said:

I have found a use for a base controller but never for a base model? What functionality do you find in a model that you want to share in every model ?

Maybe a behaviour that applies to all your models, such as Blameable?
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