PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Problem with overriding Functions (oop)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Problem with overriding Functions (oop)

Réponse
 
LinkBack Outils de la discussion
Vieux 19/01/2008, 23h32   #1
Johannes Permoser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Problem with overriding Functions (oop)

Hi,

i'va got a class 'Page'. One of it members is an instance of a template engine.
The Page-class has a method render() which calls the functions read(),
transform(), transport() and starts the template engine.

Now I want to reuse the Page class for a more specialized page 'ImagePage'. So:
ImagePage extends Page. This Page contains an extra picture and therefore needs
to call image() before starting the template engine. How do i smartly integrate
that call into the Page::render() function.

I could override the whole funtion, but then i'd have to copy and paste the
whole code for the calls of read(), transform(), transport()?
What's the professional way here?

Johannes
  Réponse avec citation
Vieux 19/01/2008, 23h39   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with overriding Functions (oop)

On Sun, 20 Jan 2008 00:32:16 +0100, Johannes Permoser <ee_pp@yahoo.de>
wrote:

> Hi,
>
> i'va got a class 'Page'. One of it members is an instance of a template
> engine. The Page-class has a method render() which calls the functions
> read(), transform(), transport() and starts the template engine.
>
> Now I want to reuse the Page class for a more specialized page
> 'ImagePage'. So: ImagePage extends Page. This Page contains an extra
> picture and therefore needs to call image() before starting the template
> engine. How do i smartly integrate that call into the Page::render()
> function.
>
> I could override the whole funtion, but then i'd have to copy and paste
> the whole code for the calls of read(), transform(), transport()?
> What's the professional way here?



class ImagePage extends Page{
function render($arg){
$this->image();
parent::render($arg);
}
}

--
Rik Wasmus
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h52.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,06792 seconds with 10 queries