Created
April 24, 2018 12:09
-
-
Save mega6382/e64ed30710048e7902dbc977b50cde80 to your computer and use it in GitHub Desktop.
My Old Trait Implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace TheProject\Extensions; | |
use Zend\Json\Json; | |
use Zend\View\Model\ViewModel; | |
trait HBModelController | |
{ | |
protected $postsTable; | |
protected $UsersTable; | |
protected $PagesTable; | |
protected $categoriesTable; | |
protected $AccountsTable; | |
protected $jsonModel; | |
public function JsonModel($data) | |
{ | |
$vm = new ViewModel(); | |
$vm->setTerminal(true); | |
$json = new Json(); | |
echo $json->encode($data); | |
return $vm; | |
} | |
public function getUsersTable() | |
{ | |
if (!$this->UsersTable) | |
{ | |
$sm = $this->getServiceLocator(); | |
$this->UsersTable = $sm->get('AutoSocialize\Model\usersTable'); | |
} | |
return $this->UsersTable; | |
} | |
public function getPagesTable() | |
{ | |
if (!$this->PagesTable) | |
{ | |
$sm = $this->getServiceLocator(); | |
$this->PagesTable = $sm->get('AutoSocialize\Model\pagesTable'); | |
} | |
return $this->PagesTable; | |
} | |
public function getPostsTable() | |
{ | |
if (!$this->postsTable) | |
{ | |
$sm = $this->getServiceLocator(); | |
$this->postsTable = $sm->get('AutoSocialize\Model\PostsTable'); | |
} | |
return $this->postsTable; | |
} | |
public function getAccountsTable() | |
{ | |
if (!$this->accountsTable) | |
{ | |
$sm = $this->getServiceLocator(); | |
$this->accountsTable = $sm->get('AutoSocialize\Model\AccountsTable'); | |
} | |
return $this->accountsTable; | |
} | |
public function getCategoriesTable() | |
{ | |
if (!$this->categoriesTable) | |
{ | |
$sm = $this->getServiceLocator(); | |
$this->categoriesTable = $sm->get('AutoSocialize\Model\CategoriesTable'); | |
} | |
return $this->categoriesTable; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment