zend-framework2

ZF2: How to pass parameters to forward plugin which I can then get in the method I forward them to?

▼魔方 西西 提交于 2019-12-09 12:14:38
问题 I have an Action method in Foo Controller which requires parameters: public function fooAction($one, $two) { $a = one; $b = $two; } And I need to forward to that method from the other method of some Boo Controller. And one of those parameters has to be by reference parameter. The only example that the manual has is this: $result = $this->forward()->dispatch('Boo\Controller\Boo', array('action' => 'boo')); No any additional parameters. But they write: $params is an optional array of parameters

ZF2 getServiceLocator in ControllerPlugin class

懵懂的女人 提交于 2019-12-09 11:59:25
问题 I am trying to get service locator/entity manager in plugin class, How can I get that. In my controller I am getting it like this. public function getEntityManager() { if(null === $this->em){ $this->em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); } return $this->em; } public function setEntityManager(EntityManager $em) { $this->em = $em; } but in plugin class I am getting error on $this->getServiceLocator() line. because this is not available in plugin class. How

Getting $_GET parameters from route in Zend Framework 2

帅比萌擦擦* 提交于 2019-12-09 06:12:33
问题 Zend Framework 1 had a very simple way of parsing URL routes and setting found params in the $_GET superglobal for easy access. Sure, you could use ->getParam($something) inside the controller, but if the param was found in the URL, it was also accessible via $_GET. Example for url mypage.com/mymodule/mycontroller/myaction/someparam/5: ZF1 $this->getParam('someparam'); // 5 $_GET['someparam']; // 5 ZF2 $this->getEvent()->getRouteMatch()->getParam('someparam'); // 5 $_GET['someparam'] //

How can I redirect to previous page in zend framework 2?

别等时光非礼了梦想. 提交于 2019-12-09 05:32:55
问题 For these situations, I want to auto redirect back to the pages from where I made the request: After finishing any action (CRUD etc) - Here I think we need to redirect to 'HTTP_REFERER' While surfing or shopping, if login required, so after finishing authentication process, it should redirect back to the same page A different situation (which is not 'redirect to previous page'): Pass a redirect URL (landing page address) in query, for eg: If I send a (external)/URL (ofc encoded) in as GET

How to override/clone modules, which are downloaded to the vendor by composer in zf2?

非 Y 不嫁゛ 提交于 2019-12-09 03:58:46
问题 SO!!! I added zfcUser module (but I want to do this with any other module too) to my project, based on Zend Framework 2.*. How I can override controllers/views/configs of this module, so changes of them wouldn't be deleted with updating dependencies with composer (I tried to do this and didn't found files are chaned, but what if.... Oo). I know that there are the way existing to do this, but I don't know it. View Helper? Or what? Help me, please! Thank you. ADDITIONAL INFO Current folders and

Validation in Zend Framework 2 with Doctrine 2

纵然是瞬间 提交于 2019-12-09 01:02:27
问题 I am right now getting myself more and more familiar with Zend Framework 2 and in the meantime I was getting myself updated with the validation part in Zend Framework 2. I have seen few examples how to validate the data from the database using Zend Db adapter, for example the code from the Zend Framework 2 official website: //Check that the username is not present in the database $validator = new Zend\Validator\Db\NoRecordExists( array( 'table' => 'users', 'field' => 'username' ) ); if (

How to consolidate ZF2 unit/application module tests into a single call?

℡╲_俬逩灬. 提交于 2019-12-08 21:48:11
问题 I'm following the ZF2 convention of storing tests in the modules and everything is working fine when tests are run from within each module. What I would like to do is have a root level phpunit.xml that calls the individual module tests and consolidates them to produce code coverage data and other metrics. The problem is that each individual test suite is bootstrapped within the modular phpunit.xml files. The only way I'm aware of doing things is to configure the bootstrap in each phpunit.xml

ZendFatal error: Class 'Zend\\Ldap\\Ldap' not found

爷,独闯天下 提交于 2019-12-08 19:26:28
So, i'm trying to make a Ldap authentication, following the docs in https://zf2.readthedocs.org/en/latest/user-guide/skeleton-application.html I just replace the 'Album' module with a 'Auth' module and use the sample code for Ldap autentication https://zf2.readthedocs.org/en/latest/modules/zend.authentication.adapter.ldap.html but i'm getting this error where Zend can't find the Ldap class when i submit the form with the login data. Fatal error: Class 'Zend\Ldap\Ldap' not found in C:\wamp\www\sade\vendor\zendframework\zend-authentication\src\Adapter\Ldap.php on line 139 I'm using composer, for

Zend Form Rendering and Decorators (Use correctly with bootstrap)

荒凉一梦 提交于 2019-12-08 16:27:33
The Bootstrap Example Code http://getbootstrap.com/css/#forms Copying a simple email input element from getbootstrap.com suggests we format the HTML in the following way: <div class="form-group"> <label for="exampleInputEmail1">Email address</label> <input id="exampleInputEmail1" class="form-control" type="email" placeholder="Email"> </div> Above we have a <label> tag that closes straight after it's text content, "Email address". I would now like to create the same form group using Zend Framework. module/MyApp/src/MyModule/Form/MyForm.php namespace MyModule\Form; use Zend\Form\Form; class

Zend framework 2 module name routing issue

a 夏天 提交于 2019-12-08 15:46:13
问题 I have a problem with module routing. I have 2 modules, Application and Admin. Each modules have indexAction as default action: localhost/ --> Application/index localhost/admin/ -> Admin/index Admin/index works only with localhost/admin/index/ This problem happens when a module name starts with the letter "A". If I rename Admin to "Cars", localhost/cars/ works correctly! the error is: A 404 error occurred The requested controller was unable to dispatch the request. Controller: Application