Search
 
SCRIPT & CODE EXAMPLE
 

PHP

facade pattern php

1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// The Facade class
class shareFacade {
  // Holds a reference to all of the classes.
  protected $twitter;    
  protected $google;   
  protected $reddit;    
    
  // The objects are injected to the constructor.   
  function __construct($twitterObj,$gooleObj,$redditObj)
  {
    $this->twitter = $twitterObj;
    $this->google  = $gooleObj;
    $this->reddit  = $redditObj;
  }  
        
  // One function makes all the job of calling all the share methods
  //  that belong to all the social networks.
  function share($url,$title,$status)
  {
    $this->twitter->tweet($status, $url);
    $this->google->share($url);
    $this->reddit->reddit($url, $title);
  }
}

// Create the objects from the classes.
$twitterObj = new CodeTwit();
$gooleObj   = new Googlize();
$redditObj  = new Reddiator();

// Pass the objects to the class facade object.
$shareObj = new shareFacade($twitterObj,$gooleObj,$redditObj);

// Call only 1 method to share your post with all the social networks.
$shareObj->share('https://myBlog.com/post-awsome','My greatest post','Read my greatest post ever.');
Comment

PREVIOUS NEXT
Code Example
Php :: generate parentheses 
Php :: Embed the site when you click on the link laravel 
Php :: change php version 
Php :: http://www.finalclap.com/faq/81-php-afficher-date-heure-francais 
Java :: android manifest cleartext traffic permitted 
Java :: javafx center node in gridpane 
Java :: how to print hello world in java 
Java :: bukkit scoreboard 
Java :: android get screen width and height 
Java :: how to clear terminal in java 
Java :: priority queue reverse order java 
Java :: Junit 5 console input test 
Java :: handler delay android 
Java :: how to clear the screen by pressing a key in java 
Java :: recyclerview dependency java android 
Java :: how to print to console in java 
Java :: dialog getWindow().setBackgroundDrawable transparent 
Java :: android round double to 2 decimal 
Java :: keyset sort java 
Java :: how to reverse order of arraylist 
Java :: java ip regex 
Java :: prendere valore da tastiera java 
Java :: como utilizar random en java 
Java :: bubble sort java 
Java :: android plain text remove underline 
Java :: get value google sheet with app script 
Java :: bundletool aab to apk 
Java :: java for each array 
Java :: textarea user select disable java swing 
Java :: fizzbuzz java 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =