Skip to content

Instantly share code, notes, and snippets.

@whisher
Created June 14, 2013 07:25
Show Gist options
  • Save whisher/5780088 to your computer and use it in GitHub Desktop.
Save whisher/5780088 to your computer and use it in GitHub Desktop.
namespace FbswitBlog\Controller\Plugin;
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
use FbswitBlog\Service\Category as CategoryService;
class FbswitBlogService extends AbstractPlugin
{
protected $categoryService;
public function getCategoryService()
{
return $this->categoryService;
}
public function setCategoryService(CategoryService $service)
{
$this->categoryService = $service;
return $this;
}
}
//MY Module
public function getControllerPluginConfig()
{
return array(
'factories' => array(
'fbswitBlogService' => function ($sm) {
$serviceLocator = $sm->getServiceLocator();
$controllerPlugin = new Controller\Plugin\FbswitBlogService();
$controllerPlugin->setCategoryService($serviceLocator->get('fbswitblog_category_service'));
return $controllerPlugin;
},
),
);
}
// From within my controller
$this->fbswitBlogService();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment