ZEND2.0

Hi,

I have started using ZF2 In our recent application development.

Enjoying Big update from ZEND as ZF2.

Skeleton can be download from here.. https://github.com/zendframework/ZendSkeletonApplication

How to write Wrapper in ZF2 here..

<?php

interface SocialInterface {
public function setUserSession();
public function getProfile();
public function getFriends();
public function sendMesageToFriend($friend);
}

class SocialFactory
{
protected $service_type;
protected $service;
public function __construct($service_type) {
$this->service_type = $service_type;
//$this->service = new {}
$class_name = ucfirst($service_type).’Social’;
if(!class_exists($class_name))
{
die(‘This service is not available.s’);
}
$this->service = new $class_name;
}

public function getService() {
return $this->service;
}
}

class FaceBookSocial implements  SocialInterface {
public function setUserSession() {
// Set Facebook User Session
}
public function getProfile() {
return array(‘name’ => ‘Facebook Name’);
}
public function getFriends() {
return array( array(‘name’ => ‘Facebook Friend 1’));
}
public function sendMesageToFriend($friend) {
return array(‘message’ => ‘send message to facebook friend’);
}
}

class TwitterSocial implements  SocialInterface {
public function setUserSession() {
// Set Twitter User Session
}
public function getProfile() {
return array(‘name’ => ‘Twitter Name’);
}
public function getFriends() {
return array( array(‘name’ => ‘Twitter Friend 1’));
}
public function sendMesageToFriend($friend) {
return array(‘message’ => ‘send message to Twitter friend’);
}
}

class LinkedInSocial implements  SocialInterface {
public function setUserSession() {
// Set LinkedIn User Session
}

public function getProfile() {
return array(‘name’ => ‘LinkedIn Name’);
}
public function getFriends() {
return array( array(‘name’ => ‘LinkedIn Friend 1’));
}
public function sendMesageToFriend($friend) {
return array(‘message’ => ‘send message to LinkedIn friend’);
}
}

class GooglePlusSocial implements  SocialInterface {
public function setUserSession() {
// Set GooglePlus User Session
}

public function getProfile() {
return array(‘name’ => ‘GooglePlus Name’);
}
public function getFriends() {
return array( array(‘name’ => ‘GooglePlus Friend 1’));
}
public function sendMesageToFriend($friend) {
return array(‘message’ => ‘send message to GooglePlus friend’);
}
}

$obj = new SocialFactory(‘linkedin’);
$a = $obj->getService()->getProfile();
print_r($a);

?>

Add a Comment

Your email address will not be published. Required fields are marked *