There is a class profile , in it a method for receiving comments of the current user:

private function getComments(){ $comments = $this->comments_model->GetCommentsLov(array('limit' => $this->climit, 'IdToUser' => $this->idUser)); $this->data['comments'] = $this->commentsuser->SetCommentsFields(null, 5, $comments, $this->idUser); $this->data['viewSection'] = 'comments/item'; } 

Each user has his own profile type private $ typeProfile; Depending on which, you need to upload comments related to this profile. T-in the method getComments () to access another methods of the model $ this-> comments_model;

How can this be beautifully done?

  • one
    Private methods can not be overloaded - Snow
  • Let it be public - not the point ... - Jony
  • getComments ($ GetCommentsLov) {.... -> $ GetCommentsLov (... - terantul
  • What is this record? - Jony

1 answer 1

 class Abcd { private $typeProfile; public function getProfileType() { return $this->typeProfile; } } 

...

 class Efgh extends Abcd { public function getComments() { $profileType = $this->getProfileType(); ... } } 
  • And if within the same class? - Jony
  • @Oleg Ponomarchuk, what difference does $ typeProfile privacy have in general? - etki