zend-framework2

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

荒凉一梦 提交于 2019-12-02 08:53:32
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 files of ZfcUserOverride: let's answer all your question one by one. But before let's keep in mind

Zend Framework 2 FrontController Plugin

荒凉一梦 提交于 2019-12-02 08:44:06
I have decided to rewrite an application that I wrote a long time ago in ZF1. A key part of this is the utilisation of a FrontController plugin that looks at a URL and if no matching route is found it will pass it on to another controller to process. The benefit of this is it worked for all modules without having to make further changes as it was registered as a plugin for the frontcontroller. Can someone please help as to how I could achieve the same in ZF2 Thanks in Adavance Adam Now you can do it in Events. ZF2 have default events and you can attach your code(listeners) to particular event.

globally change ZF2 form formatting

半世苍凉 提交于 2019-12-02 07:28:53
问题 I'm building forms from entities $builder = new AnnotationBuilder( $entityManager); $form = $builder->createForm( $entity ); This is a great feature (saves me a lot of work), but what I want is to globally change the layout of these forms. I want to use a table layout instead of <label><span>Name:</span><input type="text" value="" name="name"></label> I want something like <tr><td>Name:</td><td><input type="text"></td></tr> Is that possible? 回答1: I actually was mistaken you do not need to

Set layout variables for use by the (404) error pages in ZF2

喜夏-厌秋 提交于 2019-12-02 07:20:29
问题 At present I set a couple of variables to be used by the app's overall layout.phtml, using the onDispatch method of a BaseController, which all my other controllers extend: public function onDispatch(MvcEvent $e) { $config = $this->getServiceLocator()->get('config'); $this->layout()->setVariable('platformName', $config['platform']['name']); $this->layout()->setVariable('platformYear', $config['platform']['year']); } This works fine, until I test some error pages and find that these pages do

Forward to another controller/action from module.php

时光总嘲笑我的痴心妄想 提交于 2019-12-02 06:39:09
问题 I am writing a module for ACL in ZF2 , And I am almost done with it. The point where I am stucked is when user is not authorised to access the requested page, I want to forward the user to a page showing 403 message. I have tried redirecting user to 403 but it updates URL , so now I am tring to forward user. All I want to do is from Module.php . I have tried below code - Module.php if (!$isAllowed) { $e->getApplication()->getServiceManager()->get('ControllerPluginManager')->get('forward')-

Zend Framework 2 .htaccess mamp pro

自作多情 提交于 2019-12-02 04:40:07
I want start to work with Zend Framework 2.0 . I use os x lion and mamp pro. So to start I used this http://framework.zend.com/manual/2.0/en/user-guide/skeleton-application.html all good, I see zend project index page, but To test that your .htaccess file is working, navigate to http://zf2-tutorial.localhost/1234 and you should see this: If you see a standard Apache 404 error, then you need to fix .htaccess usage before continuing. If you’re are using IIS with the URL Rewrite Module, import the following: RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^.*$ index.php [NC,L] So I do this,

Warning: spl_object_hash() expects parameter 1 to be object, with Message

本小妞迷上赌 提交于 2019-12-02 04:36:51
i am getting the error when i try to flush the data, Warning: spl_object_hash() expects parameter 1 to be object along with this message Found entity of type on association Subject\Entity\Subject#user, but expecting Subject\Entity\User now here is the action i am trying to implement public function addAction() { $form = new SubjectForm(); $form->get('submit')->setAttribute('label', 'Add'); $request = $this->getRequest(); if (!$this->sessionVar) { $this->sessionVar = new SessionContainer('zftutorial'); $userid = $this->sessionVar->offsetGet('userid'); $form->get('user')->setAttribute('value',

ZF2: using url helper and reuse query parameters

笑着哭i 提交于 2019-12-02 03:57:15
I'm trying to reuse query params using Url helper in a view. This is my current url: http://localhost/events/index?__orderby=name&__order=asc I'm using this code in the view: $this->url('events/index', array('__page' => '2'), true); I want to obtain this url: http://localhost/events/index?__orderby=name&__order=asc&__page=2 But instead i get this: http://localhost/events/index?controller=Application\Controller\Events&__page=2 This is my route inside module.config.php file: 'events' => array( 'type' => 'segment', 'options' => array( 'route' => '/eventos[/:action]', 'constraints' => array(

How to get a $_POST request from view module?

别等时光非礼了梦想. 提交于 2019-12-02 03:54:47
问题 I want to get the checkboxes from a table in a view module, but I can't get it to work. This is the table: <form action="" method="post"> <TABLE id="dt_basic" class="table table-striped table-bordered table-hover dataTable"> <THEAD> <TR> <TH></TH> <TH>ID</TH> <TH>Client</TH> <TH>User</TH> <TH>Role</TH> <TH>Projects</TH> </TR> </THEAD> <TBODY> <?php /* @var $item Admin\Model\User */ foreach ($this->users as $item) { ?> <TR> <TD class='admin'><input type="checkbox" name="users[<?php echo $item-

Zend Framework 2 - Custom Form Validation

◇◆丶佛笑我妖孽 提交于 2019-12-02 03:45:58
I needed a custom form validation. So I wrote a function similar to this one. So far so good. But I really have problems where to put the PHP file/class. It was supposed to put it under vendor/ as a lib which seems logical. I used this path: vendor/company/Validator/MyValidator.php. But I couldn't figure out how to include my class. Could anyone give me a short how-to for setting up the vendor module or whatever is necessary to use a custom validator? There are a lot of tutorials on the internet but most of them deal with the logic of validation and not the "basics" for Zend. Thanks! Edit: I