Advertisement
Guest User

Untitled

a guest
Feb 14th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. // Initial scenario
  4. // (Just a very very simplified version for demonstration)
  5.  
  6. class HelpManager {
  7.  
  8.         protected $entries;
  9.  
  10.         public function __construct() {
  11.                 $this->entries = array();
  12.         }
  13.  
  14.         # DO NOT CALL
  15.        public function _addEntry($entry) {
  16.                 $this->entries[] = $entry;
  17.         }
  18.  
  19.         public function printHelp() {
  20.                 print_r($this->entries);
  21.         }
  22.  
  23. }
  24.  
  25. class XYZ {
  26.  
  27.         protected $helpMan;
  28.  
  29.         public function __construct() {
  30.                 $this->helpMan = new HelpManager();
  31.         }
  32.  
  33.         public function getHelpMan() {
  34.                 return $this->helpMan;
  35.         }
  36.  
  37.         public function add($entry) {
  38.                 $this->helpMan->_addEntry($entry);
  39.         }
  40.  
  41. }
  42.  
  43. $xyz = new XYZ();
  44. $xyz->add('test');
  45. $xyz->getHelpMan()->printHelp();
  46. $xyz->getHelpMan()->_addEntry('illegal');
  47. $xyz->getHelpMan()->printHelp();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement