zend-framework2

Disable notInArray Validator Zend Framework 2

这一生的挚爱 提交于 2019-12-05 18:09:53
问题 Is there a way to disable notInArray Validator in Zend Framework 2. All the info on the internet shows how to disable the notInArray Validator in Zend Framework 1, for example in this fashion If you do not want the InArray validator at all, you can disable this behavior by either calling setRegisterInArrayValidator(false) on the element, or by passing false to the registerInArrayValidator configuration key on element creation. One the posts in stackoverflow can be found here Unfortunately

Give permission for bjyauthorize to run mvc application of ZF2 from CLI

白昼怎懂夜的黑 提交于 2019-12-05 17:36:40
I have a completely running mvc application on ZF2. I want to run some actions from command line. I have properly set up my console routes and other environments. When I run my app from CLI, I got Permission denied exception like this: 'You are not authorized to access GeneratePdf\Controller\GeneratePdf\GeneratePdf:generate-all' in /var/www/zf2-reporting/module/BjyAuthorize/src/BjyAuthorize/Guard/Controller.php‌​:172 I already have some user in my database. How can I use those credentials to authorize a CLI user to run Actions? Edit : Following is the guards array in bjyauthorize.global.php

Doctrine 2 self-referenced entity without unnecessary queries

◇◆丶佛笑我妖孽 提交于 2019-12-05 17:16:47
I'm trying that a self-referenced entity stop from querying the database everytime I fetch the children of one object, and get the whole tree in one query. This is my entity: /** * @ORM\Entity(repositoryClass="ExampleRep") * @ORM\Table(name="example_table") */ class Example { /** * @ORM\Id * @ORM\Column(type="integer", nullable=false); * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\ManyToOne(targetEntity="Example", inversedBy="children") * @ORM\JoinColumn(name="parent", referencedColumnName="id", onDelete="SET NULL") */ private $parent = null; /** * @ORM\OneToMany

Zend Framework 2: How to properly replace Figlet with reCaptcha on zfcUser

笑着哭i 提交于 2019-12-05 16:06:37
I am trying to replace Figlet with reCaptcha on a zfcUser registration form. Partial instruction on how to accomplish this can be found on https://github.com/ZF-Commons/ZfcUser#changing-registration-captcha-element but no complete instruction exists. Checking the README.md file has a two-step instruction on how to accomplish this but still the CAPTCHA uses Figlet when rendered on the form. Has anyone successfully implemented this? I really need a hand on this one. Thanks in advance. EDIT: Here is a proven working solution I developed: 1. Add to composer.json // Add the lines below under the

How do I get the Service Manager in Zend Framework 2 beta4 to create an instance for album-table?

坚强是说给别人听的谎言 提交于 2019-12-05 15:12:36
This is the Rob Allen's Quick start Tutorial for Zend Framework beta4. Error Message:Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for album-table It seems like it fails trying to make a connection to the db, but I have not found way to tell. It's uses a closure to return an instance from the ServiceManager, but gets the above error message. module/Album/Module.php namespace Album; class Module { public function getAutoloaderConfig() { return array( 'Zend\Loader\ClassMapAutoloader' => array( __DIR__ . '/autoload_classmap.php', ), 'Zend\Loader

Generate PDF file with Zend Framework 2 [closed]

≯℡__Kan透↙ 提交于 2019-12-05 14:31:19
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm started to learn ZF2 right now and notice that there's no "Zend_Pdf" or similar on zend framework 2... How can I create pdf on this version of the framework? Anyone knows a good tutorial? Zend Framework 2 has moved many of the old Zend Framework libraries out of the main core and created modules instead. Zend_Pdf is one of the libraries that was moved to a module. You can find them all in the Zend Framework

ZF2 View strategy

旧时模样 提交于 2019-12-05 14:28:45
I'm trying to implement the following: Simple controller and action. Action should return response of 2 types depending on the request: HTML in case of ordinary request (text\html), JSON in case of ajax request (application\json) I've managed to do this via a plugin for controller, but this requres to write return $this->myCallBackFunction($data) in each action. And what if I wan't to do this to whole controller? Was trying to figure out how to implement it via event listener, but could not succed. Any tips or link to some article would be appreciated! ZF2 has the acceptable view model

Difference between init() and onBootStrap() in Zend Framework 2?

怎甘沉沦 提交于 2019-12-05 14:10:09
I'm reading a book on ZF2 and it refers to both init() and onBootStrap() as functions in Module.php that are called during every page load and therefore should be as lightweight as possible. Aside from a slightly different signature: init(ModuleManager m) onBootStrap(MvcEvent e) I'm struggling to determine when I should use which, and for what reason. In the book, both methods are being used to attach to (different) events. Can someone provide a clear definition of the difference between the two, and some concrete examples where I would use one but not the other (and why)? Thanks! The answer

PHP retrieving array values using dash arrow “->”

人走茶凉 提交于 2019-12-05 12:39:24
问题 I've been using PHP quite a while now, but never been an advanced programmer. I feel like this is dumb question but never understood why some array values can be retrieved using different methods: This: $array->value rather than normal: $array['value'] The standard $array['value'] always works, but the one using the -> method doesn't at times. Why is that? Here's an example. I am using Zend Framework 2 and I can grab a session value using the -> method: $this->session->some_value However, I

Adding input filter to fieldset in ZF2

走远了吗. 提交于 2019-12-05 12:37:57
I have a form Register , which has a fieldset Profile , which in turn has a fieldset Account . The fieldsets implement InputFilterProviderInterface and thus the getInputFilterSpecification method. This is where I have added general validators and filters that should be used whenever the fieldsets are used. Now, in my registration form, I want to validate that an account with a given username does not already exist. Therefore I need to add a validator to complement the validators that are defined on the Account fieldset. This is where I got in trouble. After digging around a bit, I found a way