8

In module.config.php file, I have set value for 'password_has_type'. And in controller I want to access that. Here is my module.config.php file:

'auth' => array( 'password_hash_type' => 'sha512', ), 'di' => array( 'instance' => array( 'alias' => array( 'auth' => 'Auth\Controller\AuthController', 'auth_login_form' => 'Auth\Form\LoginForm', ),... 

In controller, I have used

use Auth\Module 

and in Action method I try to get access value by

echo Module::getOption('password_hash_type'); 

But I could not get any value?

So please can anybody help me to get that value ?

2
  • How about $auth = Module::getOption('auth'); echo $auth['password_hash_type']; ? Commented Jan 26, 2012 at 13:10
  • or set the array in registry and get it anywhere Commented Jan 26, 2012 at 14:01

2 Answers 2

5

Please see my answer at Access to module config in Zend Framework 2.

But to make it more concrete to your question, you would do this:

$config = $this->getServiceLocator()->get('Config'); $pwht = $config['auth']['password_hash_type']; 

I hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

0

You can do it with help of aliases and parameters. Put it into di->instance array:

'Auth\Controller\AuthController' => array( 'parameters' => array( 'passwordHashType' => 'sha512' ) ), 

And it is your controller:

namespace Auth\Controller; use Zend\Mvc\Controller\ActionController; class AuthController extends ActionController { protected $passwordHashType; public function indexAction() { echo $this->passwordHashType; } public function setPasswordHashType($passwordHashType) { $this->passwordHashType = $passwordHashType; return $this; } } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.