395

Zend Controller Action , get Helper in other class?

is there any way to get an Action Helper from an Service Class?

I have the following Helper:

class Helper_Host extends Zend_Controller_Action_Helper_Abstract { /** * Return Hosturl with path * * @return string Hostname */ public function direct() { $front = Zend_Controller_Front::getInstance(); $host = 'http://' . $_SERVER['HTTP_HOST']; $host .= $front->getBaseUrl() . '/'; return (string) $host; } }

Now i want to get the Hostname from "My_Service_XYZ" , getStaticHelper is not working like excepted (;

class My_Service_XYZ { public function test() { $h = Zend_Controller_Action_HelperBroker::getStaticHelper('Host'); return $h->host(); // not working.. } }

Answer1:

class My_Service_XYZ { public function test() { $h = Zend_Controller_Action_HelperBroker::getStaticHelper('Host'); return $h->direct(); // not working.. } }

should works

Answer2:

Maybe you should try:

$h = Zend_Controller_Action_HelperBroker::getStaticHelper('Host');

instead of:

$h = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');

Recommend

  • Ansible: setting user on dynamic ec2
  • How to obtain service credentials for a service instance created on IBM Bluemix without binding the
  • How to autoplay video in angularjs?
  • Laravel Eloquent integration in Codeigniter
  • Vigenere cipher not working
  • Examples of how to a STS in .Net 4.5 using WCF
  • How can we prepend rows to a react native list-view?
  • Can I use AllJoyn Framework for Wifi Direct in iOS?
  • Ruby on Rails App deployed to heroku showing “We're sorry, but something went wrong”
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • Salesforce Different WSDL files and when to use
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • Specifying Castle WCF Integration Facility Endpoint Behavior per Endpoint
  • Is there a amazon webstore API for customers?
  • script to move all files from one location to another location
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • AT Commands to Send SMS not working in Windows 8.1
  • Circular dependency while pushing http interceptor
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • JTable with a ScrollPane misbehaving
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Change div Background jquery
  • apache spark aggregate function using min value
  • Bitwise OR returns boolean when one of operands is nil
  • unknown Exception android
  • Is there any way to bind data to data.frame by some index?
  • Django query for large number of relationships
  • Sorting a 2D array using the second column C++
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • failed to connect to specific WiFi in android programmatically
  • Net Present Value in Excel for Grouped Recurring CF
  • How to push additional view controllers onto NavigationController but keep the TabBar?
  • How can I use threading to 'tick' a timer to be accessed by other threads?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?