本文整理汇总了PHP中Zend_Controller_Action_HelperBroker::getStaticHelper方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Action_HelperBroker::getStaticHelper方法的具体用法?PHP Zend_Controller_Action_HelperBroker::getStaticHelper怎么用?PHP Zend_Controller_Action_HelperBroker::getStaticHelper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Action_HelperBroker
的用法示例。
在下文中一共展示了Zend_Controller_Action_HelperBroker::getStaticHelper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forceExit
public function forceExit()
{
if (APPLICATION_ENV != "testing") {
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
}
$plugins = Zend_Controller_Front::getInstance()->getPlugins();
$broker = new Zend_Controller_Plugin_Broker();
$broker->setRequest(Zend_Controller_Front::getInstance()->getRequest());
$broker->setResponse(Zend_Controller_Front::getInstance()->getResponse());
foreach ($plugins as $index => $plugin) {
$broker->registerPlugin($plugin, $index);
}
try {
$broker->postDispatch($broker->getRequest());
} catch (Exception $e) {
\App::log()->crit('Error executing "postDispatch" after stream');
\App::log()->crit($e);
}
try {
$broker->dispatchLoopShutdown();
} catch (Exception $e) {
\App::log()->crit('Error executing "dispatchLoopShutdown" after stream');
\App::log()->crit($e);
}
if (APPLICATION_ENV !== 'testing') {
exit;
}
}
示例2: __construct
public function __construct()
{
if ($this->_layoutService == null) {
$serviceFinder = Zend_Controller_Action_HelperBroker::getStaticHelper('service');
$this->_layoutService = $serviceFinder->getService('layout', 'layouts');
}
}
示例3: _initView
protected function _initView()
{
// Start initail view
$this->bootstrap('layout');
$config = $this->getOption('views');
$resources = $this->getOption('resources');
$view = new Zend_View();
if (isset($resources['layout']['layoutPath'])) {
$view->assign('layoutRootPath', $resources['layout']['layoutPath']);
}
$this->bootstrap('db');
Zend_Loader::loadClass('Ht_Utils_SystemSetting');
$sysSetting = Ht_Utils_SystemSetting::getSettings();
$view->assign('sysSetting', $sysSetting);
$view->assign('profile', Zend_Auth::getInstance()->getIdentity());
Zend_Loader::loadClass("Ht_Model_SystemSetting");
$this->setSystemLogConfiguration($sysSetting);
// use the viewrenderer to keep the code DRY
// instantiate and add the helper in one go
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);
$viewRenderer->setViewSuffix('phtml');
// add it to the action helper broker
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
/**
* Set inflector for Zend_Layout
*/
$inflector = new Zend_Filter_Inflector(':script.:suffix');
$inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml'));
// Initialise Zend_Layout's MVC helpers
$this->getResource('layout')->setLayoutPath(realpath($resources['layout']['layoutPath']))->setView($view)->setContentKey('content')->setInflector($inflector);
return $this->getResource('layout')->getView();
}
示例4: authenticate
public function authenticate($type, $role, $module, $controller, $action)
{
// escape error handler
$front = Zend_Controller_Front::getInstance();
$params = array($type, $role, $module, $controller, $action);
$count = count($params);
$plugins = new Base_Php_Overloader($front->getParam("bootstrap")->getOption('plugins'));
$errorModule = $plugins->errorHandler->params->module;
$errorController = $plugins->errorHandler->params->controller;
$errorAction = $plugins->errorHandler->params->action;
$redirecting = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
/*
* the conditions are for to be passed or redirected, default is passed
* array(typeCondition, roleCondition, moduleCondition, controllerCondition, actionCondition, redirectOrNot, url)
* order by typeCondition ASC, roleCondition ASC, moduleCondition ASC, controllerCondition ASC, actionCondition ASC
*/
$permission = array(array(null, null, $errorModule, $errorController, $errorAction, FALSE, null), array(Auth_Constant_Server::GUEST_TYPE, null, 'admin', 'index', 'login', false, null), array(Auth_Constant_Server::GUEST_TYPE, null, 'admin', 'index', 'logout', true, '/admin/index/login'), array(Auth_Constant_Server::GUEST_TYPE, null, 'admin', null, null, true, '/admin/index/login'), array(Auth_Constant_Server::ADMIN_TYPE, null, 'admin', 'index', 'login', true, '/admin'), array(null, null, 'home', null, null, false, null));
foreach ($permission as $permission) {
for ($i = 0; $i <= 4; $i++) {
if (isset($permission[$i]) && $params[$i] != $permission[$i]) {
continue 2;
}
}
if ($permission[5] == true) {
$redirecting->gotoUrl($permission[6])->redirectAndExit();
}
// if a rule is matched, not check remain rules
return;
}
}
示例5: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$loginController = 'authentication';
$loginAction = 'login';
$auth = Zend_Auth::getInstance();
// If user is not logged in and is not requesting login page
// - redirect to login page.
if (!$auth->hasIdentity() && $request->getControllerName() != $loginController && $request->getActionName() != $loginAction) {
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoSimpleAndExit($loginAction, $loginController);
}
// User is logged in or on login page.
if ($auth->hasIdentity()) {
// Is logged in
// Let's check the credential
$acl = new Tynex_Models_TynexAcl();
$identity = $auth->getIdentity();
// role is a column in the user table (database)
$isAllowed = $acl->isAllowed($identity->role, $request->getControllerName(), $request->getActionName());
if (!$isAllowed) {
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoUrlAndExit('/');
}
}
}
示例6: _getFlashMessenger
/**
* Lazily fetches FlashMessenger Instance.
*
* @return Zend_Controller_Action_Helper_FlashMessenger
*/
public function _getFlashMessenger()
{
if (NULL === $this->_flashMessenger) {
$this->_flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
}
return $this->_flashMessenger;
}
示例7: doRequest
public function doRequest($request)
{
// redirector should not exit
$redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->setExit(false);
// json helper should not exit
$json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$json->suppressExit = true;
$zendRequest = new \Zend_Controller_Request_HttpTestCase();
$zendRequest->setMethod($request->getMethod());
$zendRequest->setCookies($request->getCookies());
$zendRequest->setParams($request->getParameters());
// Sf2's BrowserKit does not distinguish between GET, POST, PUT etc.,
// so we set all parameters in ZF's request here to not break apps
// relying on $request->getPost()
$zendRequest->setPost($request->getParameters());
$zendRequest->setRawBody($request->getContent());
$zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
$zendRequest->setHeaders($this->extractHeaders($request));
$_FILES = $this->remapFiles($request->getFiles());
$_SERVER = array_merge($_SERVER, $request->getServer());
$zendResponse = new \Zend_Controller_Response_HttpTestCase();
$this->front->setRequest($zendRequest)->setResponse($zendResponse);
ob_start();
try {
$this->bootstrap->run();
} catch (\Exception $e) {
ob_end_clean();
throw $e;
}
ob_end_clean();
$this->zendRequest = $zendRequest;
$response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $this->formatResponseHeaders($zendResponse));
return $response;
}
示例8: testReturnsFlashMessengerCustomNamespace
public function testReturnsFlashMessengerCustomNamespace()
{
$object = $this->_helper->flashMessenger('Test');
$assert = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
$assert->setNamespace('Test');
$this->assertEquals($assert, $object);
}
示例9: listAction
public function listAction()
{
$rows = array();
$json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$json->suppressExit = true;
$json->direct(array('rows' => $rows));
}
示例10: indexAction
public function indexAction()
{
$src = strtolower(preg_replace('/[^a-z-0-9]/i', '', $this->_getParam('src')));
$q = preg_replace('/[^a-zA-Z0-9\\%\\.]/', '', $this->_getParam('q'));
$rows = array();
if (strlen($q) > 0) {
switch ($src) {
case 'cpt':
$procedureCodeIterator = new ProcedureCodesCPTIterator();
$procedureCodeIterator->setFilters($q);
$rows = $procedureCodeIterator->toJsonArray('code', array('textLong', 'code'));
break;
case 'icd9':
$diagnosisCodeIterator = new DiagnosisCodesICDIterator();
$diagnosisCodeIterator->setFilter($q);
$icd = $diagnosisCodeIterator->toJsonArray('code', array('textShort', 'code'));
$diagnosisCodeSNOMEDIterator = new DiagnosisCodesSNOMEDIterator();
$diagnosisCodeSNOMEDIterator->setFilter($q);
$snomed = $diagnosisCodeSNOMEDIterator->toJsonArray('snomedId', array('description', 'snomedId'));
$rows = array_merge($icd, $snomed);
break;
default:
break;
}
}
$data = array();
$data['rows'] = $rows;
$json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$json->suppressExit = true;
$json->direct($data);
}
示例11: flashMessages
/**
* Return a message
* @return string
*/
public function flashMessages()
{
$messages = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->getMessages();
$output = '';
if (count($messages) > 0) {
foreach ($messages as $message) {
$alertType = 'alert-block';
switch (strtolower($message['type'])) {
default:
case 'warning':
$alertType = 'alert-block';
break;
case 'error':
$alertType = 'alert-error';
break;
case 'success':
$alertType = 'alert-success';
break;
case 'info':
$alertType = 'alert-info';
break;
}
$output .= '<div class="alert ' . $alertType . '">';
$output .= '<button type="button" class="close" data-dismiss="alert">×</button>';
$output .= isset($message['header']) && strlen($message['header']) > 0 ? '<h4>' . $message['header'] . '</h4>' : '';
$output .= $message['message'];
$output .= '</div>';
}
}
return $output;
}
示例12: getAccessControl
/**
* Returns the Zend_Acl object or null.
* @return Zend_Acl
*/
protected function getAccessControl()
{
if (is_null($this->_accessControl)) {
$this->_accessControl = Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl');
}
return $this->_accessControl;
}
示例13: getProductCompanies
/**
* Get a list of Product Companies based on
* Agent Contracts if this is root user pull all
* companies
* the Select List for the Product Form
*/
public function getProductCompanies()
{
$companyList = array();
//Get Identity
$identity = Zend_Auth::getInstance()->getIdentity()->toArray();
//Establish Services for Agent and AgentContracts
$agentService = Zend_Controller_Action_HelperBroker::getStaticHelper('Service')->direct('agent', 'agents');
$agentContractService = Zend_Controller_Action_HelperBroker::getStaticHelper('Service')->direct('agentContract', 'agents');
if ($identity['role'] === 'Root') {
$productService = Zend_Controller_Action_HelperBroker::getStaticHelper('Service')->direct('productCompany', 'products');
$companies = $productService->fetchProductCompanies();
if (!$companies) {
return null;
}
$companies = $companies->toArray();
} else {
//Fetch the Agents Details
$agentData = $agentService->fetchAgentContact($identity['agent_id']);
$companies = $agentContractService->fetchContractsByAgent($agentData['agent_id']);
if (is_object($companies)) {
$companies = $companies->toArray();
}
}
//Build Product Category Select List
$companyList[''] = '***Select Product Company***';
foreach ($companies as $company) {
$companyList[$company['product_company_id']] = $company['product_company_name'];
}
return $companyList;
}
示例14: configureTheme
function configureTheme($theme = APPLICATION_THEME, $layoutName = 'index', $layoutPath = '/themes/core/layouts')
{
global $baseUrl;
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
if ($layoutName == 'integration') {
$viewRenderer->view->themeUrl = str_replace("index.php", "", BASE_URL) . '/public/' . $theme;
$viewRenderer->view->themeImages = $viewRenderer->view->themeUrl . "/images";
} else {
$viewRenderer->view->themeUrl = str_replace("index.php", "", BASE_URL) . "/themes/" . $theme;
$viewRenderer->view->themesUrl = str_replace("index.php", "", BASE_URL) . "/themes/";
$viewRenderer->view->themeImages = $viewRenderer->view->themeUrl . "/images";
}
$viewRenderer->view->theme = $theme;
$viewRenderer->view->asset = new Joobsbox_Helpers_AssetHelper();
$viewRenderer->view->css = new Joobsbox_Helpers_CssHelper();
$viewRenderer->view->js = new Joobsbox_Helpers_JsHelper();
$viewRenderer->view->addScriptPath(APPLICATION_DIRECTORY . '/themes/core/views/scripts');
$viewRenderer->view->addScriptPath(APPLICATION_DIRECTORY . '/themes/' . $theme . '/views/scripts');
$viewRenderer->view->setEncoding("UTF-8");
$viewRenderer->view->addHelperPath(APPLICATION_DIRECTORY . '/Joobsbox/Helpers', "Joobsbox_Helpers");
$conf = Zend_Registry::get("conf");
Zend_Registry::set("theme", $theme);
$viewRenderer->view->conf = $conf;
if ($conf->general->standalone) {
if ($layout = Zend_Layout::getMvcInstance()) {
$layout->setLayoutPath(APPLICATION_DIRECTORY . $layoutPath);
$layout->setLayout($layoutName);
} else {
Zend_Layout::startMvc(array('layoutPath' => APPLICATION_DIRECTORY . $layoutPath, 'layout' => $layoutName));
}
}
}
示例15: preDispatch
/**
*
* @param Zend_Controller_Request_Abstract $request
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$options = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getApplication()->getOptions();
$config = new Zend_Config($options);
$acl = new My_Acl($config);
$role = 'guest';
if (Zend_Auth::getInstance()->hasIdentity()) {
$role = 'user';
if (Zend_Auth::getInstance()->hasIdentity()) {
return;
} else {
$login = Zend_Auth::getInstance()->getIdentity();
$user = My_Model::get('Users')->getUserByEmail($login);
if ($user->admin == 1) {
$role = 'admin';
}
}
}
$controller = $request->getControllerName();
$action = $request->getActionName();
$resource = $controller;
$privilege = $action;
if (!$acl->has($resource)) {
$resource = null;
}
if (is_null($privilege)) {
$privilege = 'index';
}
if (!$acl->isAllowed($role, $resource, $privilege)) {
// $flash = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
// $flash->addMessage('Access Denied');
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoSimpleAndExit('login', 'admin');
}
}