zend-framework2

Complex Righty System: ACL, RBAC and more what?

假如想象 提交于 2019-12-03 13:27:37
问题 We are currently developing a project management software. And we are having trouble deciding on the correct approach to implement security. We have looked at both ACL and RBAC and are already pretty certain that we need at least a combination of both for specific reasons. But there are a couple of problems that do not have a nice solution in either world. Let me explain: Let's say you have the following entities: Users , with different roles, i.e. Project Lead Worker Admin Projects Assigned

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

你。 提交于 2019-12-03 13:22:06
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 with which to see a RouteMatch object for purposes of this specific request. So, I tried: $result =

How to use InputFilterManager to construct custom InputFilters in Zf2

假如想象 提交于 2019-12-03 12:44:46
问题 ZF2 documentation says following on defult services documentation; InputFilterManager, mapping to Zend\Mvc\Service\InputFilterManagerFactory. This creates and returns an instance of Zend\InputFilter\InputFilterPluginManager, which can be used to manage and persist input filter instances. I have a custom zf2 inputfilter class and i'm adding filters and validators inside init() method like following; namespace Application\Filter; use Zend\InputFilter\InputFilter; class GlassFilter extends

Zend Framework 2 Db\\Adapter\\Adapter query resultset like ZF1

北城以北 提交于 2019-12-03 12:27:38
Just need a hand understanding some simple database queries in ZF2. In ZF1 I have simple methods like this: public function recordset() { // listing of all records $db = Zend_Registry::get('db'); $sql = "SELECT " . $this->_selectlist() . " from customer c"; $r = $db->fetchAll($sql); return $r; } In ZF2, how would I do the same? I have tried the following, but this just returns what looks like a "Result" object, but all I want is an array like ZF1 did with fetchAll. If I have to iterate the result object only to provide the array later, which then must be iterated over again, it just seems like

How to get Zend\Db\Adapter instance from within a Model? (ZF2)

天大地大妈咪最大 提交于 2019-12-03 11:19:50
问题 I'm creating abstract models for managing database entities - I already have EntityAbstract , EntitySetAbstract and a ManagerAbstract models. In my ManagerAbstract model I need a Zend/Db/Adapter instance in order to create a Zend\Db\TableGateway . How could I pull the main instance of the adapter to my ManagerAbstract ? In ZF1 I could have achieved this with Zend_Registry. If this isn't the right way of doing things in ZF2, I would love to hear the correct way to this kind of things. Thanks!

What is the sense of naming invokables like classes?

扶醉桌前 提交于 2019-12-03 10:16:38
问题 I'm going trough ZfcUser to learn more about modules in Zend Framework 2. In the Module.php you can see 'invokables' => array( 'ZfcUser\Authentication\Adapter\Db' => 'ZfcUser\Authentication\Adapter\Db', 'ZfcUser\Authentication\Storage\Db' => 'ZfcUser\Authentication\Storage\Db', 'ZfcUser\Form\Login' => 'ZfcUser\Form\Login', 'zfcuser_user_service' => 'ZfcUser\Service\User', 'zfcuser_register_form_hydrator' => 'Zend\Stdlib\Hydrator\ClassMethods', ), Now, what is the difference between giving

Where to put custom settings in Zend Framework 2?

北城以北 提交于 2019-12-03 10:12:26
问题 I have some custom application specific settings, I want to put in a configuration file. Where would I put these? I considered /config/autoload/global.php and/or local.php. But I'm not sure which key(s) I should use in the config array to be sure not to override any system settings. I was thinking of something like this (e.g. in global.php): return array( 'settings' => array( 'settingA' => 'foo', 'settingB' => 'bar', ), ); Is that an agreeable way? If so, how can I access the settings e.g.

Conditionally required in Zend Framework's 2 InputFilter

喜欢而已 提交于 2019-12-03 10:03:17
问题 I am making an application using Zend Framework 2. I am validating input using it's InputFilter . Is it possible, to make some Input s required conditionally? I mean I have code like that: $filter = new \Zend\InputFilter\InputFilter(); $factory = new \Zend\InputFilter\Factory(); $filter->add($factory->createInput(array( 'name' => 'type', 'required' => true ))); $filter->add($factory->createInput(array( 'name' => 'smth', 'required' => true ))); I want the field something , to be required, ONLY

ZF2 custom attributes in navigation

倖福魔咒の 提交于 2019-12-03 09:41:26
问题 How would I add custom attributes into Zend Framework 2 navigation? I know I can add id or class -> but that's about it.... 1) How would I add data-test='blahblah' attribute for example? 2) Can I add attribute to li elements that contain actual links? $container = new Zend\Navigation\Navigation(array( array( 'label' => 'Page 1', 'id' => 'home-link', 'uri' => '/', ), array( 'label' => 'Zend', 'uri' => 'http://www.zend-project.com/', 'order' => 100, ), ); Edit: @Bram Gerritsen: Thanks for your

Injecting the Service Manager to Build a Doctrine Repository in ZF2

寵の児 提交于 2019-12-03 09:15:27
How do I inject the service manager into a Doctrine repository to allow me to retrieve the Doctrine Entity Manager? I using the ZF2-Commons DoctrineORMModule and are trying to implement the repository example listed in the Doctrine Tutorial (bottom of tutorial in link below): http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html However, I keep getting a message " Fatal error: Call to a member function get() on a non-object in C:\zendProject\zf2 ... ", which suggests that I do not have a working instance of the service locator. My Doctrine repository