zend-framework2

How do I access the getServiceLocator in Model ZF2

烂漫一生 提交于 2019-12-10 19:35:12
问题 I am trying to access the getServiceLocator function in a model. It works in the controller but when I move it into a model I get NULL when trying to access. Call to a member function get() on null It seemed like below link offered a comparable solution but I had trouble implementing Use another module in our custom helper in zend framework 2 Below is the code I am trying to run in a model. use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorInterface;

Zend Framework 2 Get controller name from layout

血红的双手。 提交于 2019-12-10 19:08:27
问题 I have the follow routes to different controllers and actions, that all shows the same layout and different views, example: http://<my domain>/controllername1/action1 http://<my domain>/controllername1/ http://<my domain>/controllername2/action1 http://<my domain>/controllername3/action1 How can I get the controller name that loads the Layout in the Layout code?, something that returns: " controllername1 ", " controllername2 " or " controllername3 " The goal is to identify in which section I

ZF2 get service from service manager with additional parameter

我怕爱的太早我们不能终老 提交于 2019-12-10 19:07:19
问题 I have two examples where I would like to use the service manager to get a service and have it resolve the dependencies through configs, apart from one dependency/parameter which is variable (pseudo code because I realise 'get' only allows one argument): in controller, to get an entity from a database: $sm = $this->getServiceLocator(); $myObject = $sm->get('Model', $id); in mapper (the service manager should get the corresponding adapter): $sm = $this->getServiceLocator(); $tableGateway = $sm

How to integrate LESS into ZendFramework 2

江枫思渺然 提交于 2019-12-10 18:22:03
问题 I have found this tutorial which is for ZendFramework 1 . I download less and put it under project/vendor/ . Leafo └── Less ├── Lessc.php └── Lessify.php In project/module/Application/Module.php ... public function onBootstrap(MvcEvent $e) { ... $this->compileLess(); } ... public function compileLess() { if (APPLICATION_ENV == 'production') { return; } require_once PROJECT_PATH . '/vendor/Leafo/Less/Lessc.php'; $less_file = PROJECT_PATH . '/public/less/style.less'; $css_file = PROJECT_PATH .

zf2 navigation - 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for navigation'

独自空忆成欢 提交于 2019-12-10 18:18:53
问题 Hy everybody! I am learning zf2, and trying to set up a navigation panel(based on: Zend Framework 2: Zend_Navigation), but the answer from the computer is still: An error occurred An error occurred during execution; please try again later. Additional information: Zend\ServiceManager\Exception\ServiceNotFoundException File: /var/www/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:453 Message: Zend\ServiceManager\ServiceManager::get was unable to

How to build an ACL Assertion for a variable value in Zend Framework 2?

北慕城南 提交于 2019-12-10 18:03:37
问题 I have a simple ACL configures in an acl.global.php like this: return [ 'acl' => [ 'roles' => [ 'guest' => null, 'member' => 'guest', 'admin' => 'member' ], 'resources' => [ 'allow' => [ 'Application\Controller\Index' => ['all' => 'member'], 'Application\Controller\Error' => ['all' => 'member'], 'Item\Controller\Process' => [ 'index' => 'member', 'create' => 'member', 'showItem' => 'member', // website.tld/item/:id 'showList' => 'member' // website.tld/list-items ] ] ], ] ]; A parser iterates

represent a variable in twig using for loop

痴心易碎 提交于 2019-12-10 17:52:48
问题 In my Service I return an array which looks like this: $array = [ 'bible_anagram_word' => $result->getBibleAnagramWord(), 'word_1' => $result->getWord1(), 'word_2' => $result->getWord2(), 'word_3' => $result->getWord3(), ... 'word_22' => $result->getWord22(), 'word_23' => $result->getWord23(), 'word_24' => $result->getWord24(), 'word_25' => $result->getWord25(), 'Bible_verse_reference' => $result->getBibleVerseReference(), 'Bible_verse_text' => $result->getBibleVerseText(), 'Bible_translation

ZF3 session timeout issue

淺唱寂寞╮ 提交于 2019-12-10 17:48:32
问题 I have been facing issue related to Session timeout using Zend Framework 3. Session expired within 5-10 min. I had used the default code for the session, which Zf3 skeleton provides in global.php as below. // Session configuration. 'session_config' => [ 'cookie_lifetime' => 60*60*1, // Session cookie will expire in 1 hour. 'gc_maxlifetime' => 60*60*1, // Store session data on server maximum for 1 hour. ], // Session manager configuration. 'session_manager' => [ 'validators' => [ RemoteAddr:

Select Element Validation

≡放荡痞女 提交于 2019-12-10 17:12:57
问题 I have a Select element in my form like this: $this->add(array( 'name' => 'cat_id', 'type' => 'Zend\Form\Element\Select', 'options' => array( 'label' => 'Categoria', 'empty_option' => '', 'value_options' => array( '' => '', ), ), )); The value_options is filled with database info in my controller... (there's is a better way?) And I have a InputFilter for him, like this: $this->add(array( 'name' => 'cat_id', 'required' => true, 'validators' => array( array( 'name' => 'NotEmpty', 'break_chain

zend smtp mail crashes after 100+ mails

ε祈祈猫儿з 提交于 2019-12-10 16:58:47
问题 While sending a newsletter-kind-of mail I came across this weird problem. In a for loop, I loop through all the users in a database and try to send them all an HTML mail with some basic information. Now the thing is that the first 200 or so mails run fine, but then the script crashes and gives the following error: Warning: fwrite(): SSL operation failed with code 1. OpenSSL Error messages: error:140D00CF:SSL routines:SSL_write:protocol is shutdown in /opt/zendframework2/library/Zend/Mail