Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6898385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:17:21+00:00 2026-05-27T07:17:21+00:00

How to apply a decorator in a structure views, knowing that only a single

  • 0

How to apply a decorator in a structure views, knowing that only a single view is responsible for executing the block of code to render the template? as:

<?php
          class View {

                 public function render ( $template ) {
                        printf ( 'Rendering template %s' , $template ) ;
                 }

          }

          class MemberView { }

          class AdministratorView { }


          $Admin = new MemberView ( new AdministratorView ( ) ) ;
          $Admin->render ( ) ;

In this case, I am rendering an administrator, but when going through the drivers, will acquire and the basic functions that every member has reached the view and perform to show panels, or things that only administrators can see, but in logic, a administrator is also a member .. so the structure has to be made​​, applies to moderators, global moderators ..

My question is that of how to apply the decorator in this case ..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:17:21+00:00Added an answer on May 27, 2026 at 7:17 am

    Well, we managed to solve the problem .. the solution:

    <?php
    
              class View {
    
                     public function render ( $template ) {
                            printf ( 'Rendering template %s' , $template ) ;
                     }
    
              }
    
              abstract class ViewDecorator extends View {
    
                     protected $view ;
    
                     public function __construct ( View $view ) {
                            $this->view = $view ;
                     }
    
              }
    
              class MemberView extends ViewDecorator {
    
                     public function render ( ) {
                            $this->view->render ( 'Member' ) ;
                     }
    
              }
    
              class AdministratorView extends ViewDecorator {
    
                     public function render ( ) {
                            $this->view->render ( 'Administrator' ) ;
                     }
    
              }
    
              $ADM = new MemberView ( new AdministratorView ( new View ( ) ) ) ;
              $ADM->render ( ) ;
    

    The output: Rendering template Administrator

    If I remove the rendering of the administrator.

    <?php
              $Member = new MemberView ( new View ( ) ) ;
              $Member->render ( ) ;
    

    The output: Rendering template Member

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a function decorator that will apply a conversion to the first
I'm trying to apply the Decorator Design Pattern to the following situation: I've 3
Is there a way I can apply the login_required decorator to an entire app?
How do I apply the MarshalAsAttribute to the return type of the code below?
I'm trying to apply autofac decorator support feature to my scenario with no success.
Is there a way to apply an underline text decoration to one character only
I need to write the code that would format the value according to the
I have an HTML ordered list, that I need to apply a strikethrough to.
I apply a filter to Dataview and after that I need to get the
I am trying to apply the timing decorator described here to a method within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.