本文整理汇总了PHP中Zend_Controller_Action_HelperBroker::hasHelper方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Action_HelperBroker::hasHelper方法的具体用法?PHP Zend_Controller_Action_HelperBroker::hasHelper怎么用?PHP Zend_Controller_Action_HelperBroker::hasHelper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Action_HelperBroker
的用法示例。
在下文中一共展示了Zend_Controller_Action_HelperBroker::hasHelper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getViewRenderer
/**
* Retrieves the view renderer object
*
* @return Zend_Controller_Action_Helper_ViewRenderer|null
* @throws Glitch_Application_Resource_Exception
*/
public function getViewRenderer()
{
if (null === $this->_viewRenderer) {
// Pull in the front controller; bootstrap first if necessary
$this->_bootstrap->bootstrap('FrontController');
$front = $this->_bootstrap->getResource('FrontController');
// Ignore if no view renderer is to be used
if ($front->getParam('noViewRenderer')) {
return null;
}
// Get existing renderer, if any, or create a new one
$this->_viewRenderer = Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer') ? Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer') : new $this->_className(null, $this->getOptions());
// Dynamic class loading; perform sanity check
if (!$this->_viewRenderer instanceof Zend_Controller_Action_Helper_ViewRenderer) {
throw new Glitch_Application_Resource_Exception('Class is not a valid view renderer instance');
}
// Register the view as the default view for handling view scripts
$this->_bootstrap->bootstrap('View');
$view = $this->_bootstrap->getResource('View');
$this->_viewRenderer->setView($view);
// It is paramount to set this base path spec: ZF otherwise uses its own
// spec, causing it to create a path to a conventional ZF-style directory
$this->_viewRenderer->setViewBasePathSpec(':module/' . Glitch_View::PATH_VIEW);
// Set empty inflector settings: all path translations are handled by the custom dispatcher
$inflector = new Zend_Filter_Inflector();
$inflector->addRules(array(':module' => array(), ':controller' => array(), ':action' => array()));
$this->_viewRenderer->setInflector($inflector, true);
if (!Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
Zend_Controller_Action_HelperBroker::addHelper($this->_viewRenderer);
}
}
return $this->_viewRenderer;
}
示例2: getViewScript
/**
* Construct view script path
*
* Used by render() to determine the path to the view script.
*
* @param string $action Defaults to action registered in request object
* @param bool $noController Defaults to false; i.e. use controller name as subdir in which to search for view script
* @return string
* @throws Zend_Controller_Exception with bad $action
*/
public function getViewScript($action = null, $noController = null)
{
if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) {
$viewRenderer = $this->_helper->getHelper('viewRenderer');
if (null !== $noController) {
$viewRenderer->setNoController($noController);
}
return $viewRenderer->getViewScript($action);
}
$request = $this->getRequest();
if (null === $action) {
$action = $request->getActionName();
} elseif (!is_string($action)) {
throw new Zend_Controller_Exception('Invalid action specifier for view render');
}
if (null === $this->_delimiters) {
$dispatcher = Zend_Controller_Front::getInstance()->getDispatcher();
$wordDelimiters = $dispatcher->getWordDelimiter();
$pathDelimiters = $dispatcher->getPathDelimiter();
$this->_delimiters = array_unique(array_merge($wordDelimiters, (array) $pathDelimiters));
}
$action = str_replace($this->_delimiters, '-', $action);
$script = $action . '.' . $this->viewSuffix;
if (!$noController) {
$controller = $request->getControllerName();
$controller = str_replace($this->_delimiters, '-', $controller);
$script = $controller . DIRECTORY_SEPARATOR . $script;
}
return $script;
}
示例3: _handleError
/**
* @param \Zend_Controller_Request_Abstract $request
* @throws mixed
*/
protected function _handleError(\Zend_Controller_Request_Abstract $request)
{
// remove zend error handler
$front = \Zend_Controller_Front::getInstance();
$front->unregisterPlugin("Zend_Controller_Plugin_ErrorHandler");
$response = $this->getResponse();
if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
// get errorpage
try {
// enable error handler
$front->setParam('noErrorHandler', false);
$errorPath = Config::getSystemConfig()->documents->error_pages->default;
if (Site::isSiteRequest()) {
$site = Site::getCurrentSite();
$errorPath = $site->getErrorDocument();
}
if (empty($errorPath)) {
$errorPath = "/";
}
$document = Document::getByPath($errorPath);
if (!$document instanceof Document\Page) {
// default is home
$document = Document::getById(1);
}
if ($document instanceof Document\Page) {
$params = Tool::getRoutingDefaults();
if ($module = $document->getModule()) {
$params["module"] = $module;
}
if ($controller = $document->getController()) {
$params["controller"] = $controller;
$params["action"] = "index";
}
if ($action = $document->getAction()) {
$params["action"] = $action;
}
$this->setErrorHandler($params);
$request->setParam("document", $document);
\Zend_Registry::set("pimcore_error_document", $document);
// ensure that a viewRenderer exists, and is enabled
if (!\Zend_Controller_Action_HelperBroker::hasHelper("viewRenderer")) {
$viewRenderer = new \Pimcore\Controller\Action\Helper\ViewRenderer();
\Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
}
$viewRenderer = \Zend_Controller_Action_HelperBroker::getExistingHelper("viewRenderer");
$viewRenderer->setNoRender(false);
if ($viewRenderer->view === null) {
$viewRenderer->initView(PIMCORE_WEBSITE_PATH . "/views");
}
}
} catch (\Exception $e) {
\Logger::emergency("error page not found");
}
}
// call default ZF error handler
parent::_handleError($request);
}
示例4: setUp
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @return void
*/
public function setUp()
{
Zend_Controller_Front::getInstance()->resetInstance();
Zend_Layout_PluginTest_Layout::$_mvcInstance = null;
if (Zend_Controller_Action_HelperBroker::hasHelper('Layout')) {
Zend_Controller_Action_HelperBroker::removeHelper('Layout');
}
if (Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer');
}
}
示例5: setUp
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @return void
*/
public function setUp()
{
Zend_Controller_Front::getInstance()->resetInstance();
if (Zend_Controller_Action_HelperBroker::hasHelper('Layout')) {
Zend_Controller_Action_HelperBroker::removeHelper('Layout');
}
if (Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer');
}
Zend_View_Helper_LayoutTest_Layout::resetMvcInstance();
}
示例6: viewAction
public function viewAction()
{
if (Zend_Controller_Action_HelperBroker::hasHelper('redirector')) {
$redirector = Zend_Controller_Action_HelperBroker::getExistingHelper('redirector');
}
$hometargeturl = $this->_urlHelper->url(array('controller' => 'index', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
// Get user identity
$auth = Zend_Auth::getInstance();
// Disable edit profile by default
$userEdit = false;
// Get params
$params = $this->getRequest()->getParams();
if (isset($params['user'])) {
// Get username from params
$username = $params['user'];
} else {
$redirector->gotoUrl($hometargeturl);
}
// Get content types
$contentTypes = new Default_Model_ContentTypes();
$this->view->content_types = $contentTypes->getAllNamesAndIds();
// Get user data from User Model
$user = new Default_Model_User();
$data = $user->getUserByName($username);
if ($data == null) {
$redirector->gotoUrl($hometargeturl);
}
$this->view->user = $data;
$id = $data['id_usr'];
// Get public user data from UserProfiles Model
$userProfile = new Default_Model_UserProfiles();
$dataa = $userProfile->getPublicData($id);
// $dataa is an array with key=>val like firstname => "Joel Peeloten"
// This was replaced with get public data and the foreach above
// Kept here just in case for the future
/*
$dataa['gender'] = $userprofile->getUserProfileValue($id, 'gender');
$dataa['surname'] = $userprofile->getUserProfileValue($id, 'surname');
$dataa['firstname'] = $userprofile->getUserProfileValue($id, 'firstname');
$dataa['category'] = $userprofile->getUserProfileValue($id, 'user category');
$dataa['profession'] = $userprofile->getUserProfileValue($id, 'profession');
$dataa['company'] = $userprofile->getUserProfileValue($id, 'company');
$dataa['biography'] = $userprofile->getUserProfileValue($id, 'biography');
$dataa['city'] = $userprofile->getUserProfileValue($id, 'city');
$dataa['phone'] = $userprofile->getUserProfileValue($id, 'phone');
$dataa['birthday'] = $userprofile->getUserProfileValue($id, 'birthday');
*/
// No countries in countries_ctr and not very good table at all?
// This would be better: http://snipplr.com/view/6636/mysql-table--iso-country-list-with-abbreviations/
/*
$dataa['country'] = $userProfile->getUserProfileValue($id, 'country');
$userCountry = new Default_Model_UserCountry();
$dataa['country'] = $userCountry->getCountryNameById(
$dataa['country']['profile_value_usp']
);
*/
// Get content user has released
$type = isset($params['type']) ? $params['type'] : 0;
$contentList = $user->getUserContent($data['id_usr']);
$temp = array();
// Initialize content counts
$dataa['contentCounts']['all'] = 0;
$dataa['contentCounts']['user_edit'] = 0;
$dataa['contentCounts']['problem'] = 0;
$dataa['contentCounts']['finfo'] = 0;
$dataa['contentCounts']['idea'] = 0;
// Count amount of content user has published
// and check unpublished so only owner can see it.
foreach ($contentList as $k => $c) {
// If user not logged in and content not published,
// remove content from list
if (!$auth->hasIdentity() && $c['published_cnt'] == 0) {
unset($contentList[$k]);
// Else if user logged in and not owner of unpublished content,
// remove content from list
} else {
if ($auth->hasIdentity() && $c['id_usr'] != $auth->getIdentity()->user_id && $c['published_cnt'] == 0) {
unset($contentList[$k]);
// Else increase content counts and sort content by content type
} else {
if (isset($c['key_cty'])) {
// Set content to array by its content type
//$temp[$c['key_cty']][] = $c;
//$temp[] = $c;
// Increase total count
$dataa['contentCounts']['all']++;
// Set content type count to 0 if count is not set
if (!isset($dataa['contentCounts'][$c['key_cty']])) {
$dataa['contentCounts'][$c['key_cty']] = 0;
}
// Increase content type count
$dataa['contentCounts'][$c['key_cty']]++;
}
}
}
if ($c['published_cnt'] == 0) {
$dataa['contentCounts']['user_edit']++;
}
}
//.........这里部分代码省略.........
示例7: testResettingMvcInstanceUnregistersHelperAndPlugin
public function testResettingMvcInstanceUnregistersHelperAndPlugin()
{
$this->testGetMvcInstanceReturnsLayoutInstanceWhenStartMvcHasBeenCalled();
Zend_Layout::resetMvcInstance();
$front = Zend_Controller_Front::getInstance();
$this->assertFalse($front->hasPlugin('Zend_Layout_Controller_Plugin_Layout'), 'Plugin not unregistered');
$this->assertFalse(Zend_Controller_Action_HelperBroker::hasHelper('Layout'), 'Helper not unregistered');
}
示例8: _initHelper
/**
* Initialize action helper
*
* @return void
*/
protected function _initHelper()
{
$helperClass = $this->getHelperClass();
if (!Zend_Controller_Action_HelperBroker::hasHelper('layout')) {
if (!class_exists($helperClass)) {
Zend_Loader::loadClass($helperClass);
}
Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-90, new $helperClass($this));
}
}
示例9: testViewRendererHelperRegisteredByDefault
public function testViewRendererHelperRegisteredByDefault()
{
$this->_controller->resetInstance();
$this->assertTrue(Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer'));
}
示例10: dispatch
/**
* Dispatch an HTTP request to a controller/action.
*
* @param Zend_Controller_Request_Abstract|null $request
* @param Zend_Controller_Response_Abstract|null $response
* @return void|Zend_Controller_Response_Abstract Returns response object if returnResponse() is true
*/
public function dispatch(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
{
if (!$this->getParam('noErrorHandler') && !$this->_plugins->hasPlugin('Zend_Controller_Plugin_ErrorHandler')) {
// Register with stack index of 100
#require_once 'Zend/Controller/Plugin/ErrorHandler.php';
$this->_plugins->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(), 100);
}
if (!$this->getParam('noViewRenderer') && !Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
#require_once 'Zend/Controller/Action/Helper/ViewRenderer.php';
Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-80, new Zend_Controller_Action_Helper_ViewRenderer());
}
/**
* Instantiate default request object (HTTP version) if none provided
*/
if (null !== $request) {
$this->setRequest($request);
} elseif (null === $request && null === ($request = $this->getRequest())) {
#require_once 'Zend/Controller/Request/Http.php';
$request = new Zend_Controller_Request_Http();
$this->setRequest($request);
}
/**
* Set base URL of request object, if available
*/
if (is_callable(array($this->_request, 'setBaseUrl'))) {
if (null !== $this->_baseUrl) {
$this->_request->setBaseUrl($this->_baseUrl);
}
}
/**
* Instantiate default response object (HTTP version) if none provided
*/
if (null !== $response) {
$this->setResponse($response);
} elseif (null === $this->_response && null === ($this->_response = $this->getResponse())) {
#require_once 'Zend/Controller/Response/Http.php';
$response = new Zend_Controller_Response_Http();
$this->setResponse($response);
}
/**
* Register request and response objects with plugin broker
*/
$this->_plugins->setRequest($this->_request)->setResponse($this->_response);
/**
* Initialize router
*/
$router = $this->getRouter();
$router->setParams($this->getParams());
/**
* Initialize dispatcher
*/
$dispatcher = $this->getDispatcher();
$dispatcher->setParams($this->getParams())->setResponse($this->_response);
// Begin dispatch
try {
/**
* Route request to controller/action, if a router is provided
*/
/**
* Notify plugins of router startup
*/
$this->_plugins->routeStartup($this->_request);
$router->route($this->_request);
/**
* Notify plugins of router completion
*/
$this->_plugins->routeShutdown($this->_request);
/**
* Notify plugins of dispatch loop startup
*/
$this->_plugins->dispatchLoopStartup($this->_request);
/**
* Attempt to dispatch the controller/action. If the $this->_request
* indicates that it needs to be dispatched, move to the next
* action in the request.
*/
do {
$this->_request->setDispatched(true);
/**
* Notify plugins of dispatch startup
*/
$this->_plugins->preDispatch($this->_request);
/**
* Skip requested action if preDispatch() has reset it
*/
if (!$this->_request->isDispatched()) {
continue;
}
/**
* Dispatch request
*/
try {
$dispatcher->dispatch($this->_request, $this->_response);
//.........这里部分代码省略.........
示例11: testHelperClassPassedToStartMvcIsUsed
/**
* @return void
*/
public function testHelperClassPassedToStartMvcIsUsed()
{
$layout = Zend_Layout::startMvc(array('helperClass' => 'Zend_Layout_LayoutTest_Controller_Action_Helper_Layout'));
$this->assertTrue(Zend_Controller_Action_HelperBroker::hasHelper('layout'));
$helper = Zend_Controller_Action_HelperBroker::getStaticHelper('layout');
$this->assertTrue($helper instanceof Zend_Layout_LayoutTest_Controller_Action_Helper_Layout);
}
示例12: setActionController
/**
* setActionController()
*
* @param Zend_Controller_Action $oActionController
* @return Zend_Controller_ActionHelper_Abstract
*/
public function setActionController(Zend_Controller_Action $oActionController = null)
{
static $bSmartyInitialized;
foreach ($this->_aTranslationsPaths as $sName => $sPath) {
$this->_aTranslationsPaths[$sName] = Volcano_Tools::fixPath($sPath);
}
$aProposedLocales = array();
if ($this->_sRequestParamName && ($sParam = $oActionController->getRequest()->getParam($this->_sRequestParamName))) {
$aProposedLocales[] = $sParam;
}
$sCookieLocale = false;
if ($this->_sCookieName && ($sCookieLocale = $oActionController->getRequest()->getCookie($this->_sCookieName))) {
$aProposedLocales[] = $sCookieLocale;
}
$oLocalizer = new Volcano_Localizer($aProposedLocales, $this->_sTranslationAdapterName, $this->_aTranslationsPaths, $this->_bParseRequestHeaders);
if ($sCookieLocale != $oLocalizer->getLocale()->getLanguage()) {
setcookie($this->_sCookieName, $oLocalizer->getLocale()->getLanguage(), time() + 60 * 60 * 24 * 30, "/");
}
parent::setActionController($oActionController);
$oActionController->localizer = $oLocalizer;
//add localizer to smarty
if (Zend_Controller_Action_HelperBroker::hasHelper('Smarty') && !$bSmartyInitialized) {
$oSmartyHelper = Zend_Controller_Action_HelperBroker::getExistingHelper('Smarty');
$oSmartyHelper->addCustomFunction('modifier', array($oLocalizer, 'translate'), 'translate');
$oSmartyHelper->locale = array('language' => $oLocalizer->getLocale()->getLanguage(), 'region' => $oLocalizer->getLocale()->getRegion());
$bSmartyInitialized = TRUE;
}
return $this;
}
示例13: addActionHelper
/**
* Adds the given action helper to the broker.
*
* @param Zend_Controller_Action_Helper_Abstract $helper
*/
protected function addActionHelper(Zend_Controller_Action_Helper_Abstract $helper)
{
$this->helpersToRemove[] = $helper->getName();
Zend_Controller_Action_HelperBroker::addHelper($helper);
$message = 'Helper "' . $helper->getName() . '" was not added.';
$this->assertTrue(Zend_Controller_Action_HelperBroker::hasHelper($helper->getName()), $message);
}
示例14: postDispatch
/**
* Hook 12: Called after an action is dispatched by \Zend_Controller_Dispatcher.
*
* This callback allows for proxy or filter behavior. By altering the
* request and resetting its dispatched flag (via {@link
* \Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
* a new action may be specified for dispatching.
*
* \Zend_Layout_Controller_Plugin_Layout uses this event to change the output
* of the $response with the rendering of the layout. As the Layout plugin
* has a priority of 99, this Escort event will take place before the layout
* is rendered, unless $this->run() was called with a stackIndex lower than zero.
*
* Previous hook: controllerAfterAction()
* Actions since: ob_get_clean(); $response->appendBody()
* Actions after: while (! Request->isDispatched()) or back to Hook 8 preDispatch()
* Next hook: dispatchLoopShutdown()
*
* @param \Zend_Controller_Request_Abstract $request
* @return void
*/
public function postDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request->isDispatched()) {
$response = \Zend_Controller_Front::getInstance()->getResponse();
$response->setHeader('X-UA-Compatible', 'IE=edge,chrome=1', true);
if ($this->project->offsetExists('x-frame')) {
$response->setHeader('X-Frame-Options', $this->project->offsetGet('x-frame'), true);
}
// Only when we need to render the layout, we run the layout prepare
if (\Zend_Controller_Action_HelperBroker::hasHelper('layout') && \Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->isEnabled()) {
// Per project layout preparation
if (isset($this->project->layoutPrepare)) {
foreach ($this->project->layoutPrepare as $prepare => $type) {
if ($type) {
$function = '_layout' . ucfirst($prepare);
if (isset($this->project->layoutPrepareArgs, $this->project->layoutPrepareArgs[$prepare])) {
$args = $this->project->layoutPrepareArgs[$prepare];
} else {
$args = array();
}
$result = $this->{$function}($args);
// When a result is returned, add it to the view,
// according to the type method
if (null !== $result) {
if (is_numeric($type)) {
$this->view->{$prepare} = $result;
} else {
if (!isset($this->view->{$type})) {
$this->view->{$type} = new \MUtil_Html_Sequence();
}
$sequence = $this->view->{$type};
$sequence[$prepare] = $result;
}
}
}
}
}
}
// For AJAX calls we sometimes need to add JQuery onload scripts since otherwise they won't get rendered:
// We expect JQuery to be loaded in the master page, since the call is probably made using JQuery
if ($request instanceof \Zend_Controller_Request_Http && $request->isXmlHttpRequest()) {
\MUtil_JQuery::enableView($this->view);
$scripts = $this->view->jQuery()->getOnLoadActions();
$content = '';
foreach ($scripts as $script) {
$content .= "<script type='text/javascript'>{$script}</script>\n";
}
$content .= $this->view->inlineScript();
// Now cleanup the rendered content (just to make sure)
$this->view->jQuery()->clearOnLoadActions();
$this->view->inlineScript()->exchangeArray(array());
if (!empty($content)) {
$response->appendBody($content);
}
}
}
}
示例15: testViewRendererHelperNotRegisteredIfNoViewRendererSet
public function testViewRendererHelperNotRegisteredIfNoViewRendererSet()
{
$this->assertFalse(Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer'));
$this->_controller->setParam('noViewRenderer', true);
$request = new Zend_Controller_Request_Http('http://example.com/index/index');
$this->_controller->setResponse(new Zend_Controller_Response_Cli());
$response = $this->_controller->dispatch($request);
$this->assertFalse(Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer'));
}