zend-framework2

ZF2 Controller Plugin

两盒软妹~` 提交于 2019-12-19 10:26:12
问题 I'm new to ZF2 and am having some trouble with what should be a basic idea. I'm using the ZfCommons User module for authentication, it's been installed and is operating properly. Now I want validate the user is in fact logged in from my controller based on this (How to check if the user is logged in but I can't figure out out how to register the controller plugin, I'm currently receiving this error: Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for

Dependency management in Zend Framework 2 MVC applications

陌路散爱 提交于 2019-12-19 09:15:36
问题 As the ServiceLocatorAwareInterface will likely be removed from the AbstractController in ZF3, dependencies should instead be passed via the constructor or via setter methods. With this in mind, consider the use case of a user or site controller with actions such as register, activate account, login, logout, etc. At a minimum, this would require a UserService and 2 forms. Add a few more related actions (remote authentication, linking of accounts, etc.) and you end up with 4 or 5 forms.

ServiceLocator, let's thoughts about it in ZF2 context

a 夏天 提交于 2019-12-19 07:48:28
问题 According to Marco's Pivetta thoughts with this, this old question and my answer to an other question I was interrogating myself about the better way to use our Services in Zend Framework 2 application. Actually we can use the ServiceLocatorAwareInterface combined with ServiceLocatorAwareTrait . With the fact In ZF3 service locator will be removed in controller It may be possible that they will also remove this interface, or advice people not using it, it make sense. The only way I see how

Zend Framework 2 multiple databases

喜夏-厌秋 提交于 2019-12-19 04:51:16
问题 How to configure Zend Framework 2 project to work with multiple databases? I have followed the answer in configure multiple databases in zf2 I created my own factory as MyProject/module/MyModuleName/src/MyModuleName/Classes/MyAdapterFactory.php. Is this a correct path to create the file? I couldn't figure out where should I call: $adapter1=$serviceManager->get('myadapter1'); $adapter2=$serviceManager->get('myadapter2'); And also I cant ask for more clarifications since the question is

Zend Framework 2 MVC - Modules Route mapping not working

让人想犯罪 __ 提交于 2019-12-19 04:15:17
问题 I try to follow Akrabats Tutorial the Application/Index is working, the Album part not. I tried it also with the ZendSkeletonModule with no luck. The error in both cases is: album/album (resolves to invalid controller class or alias: album/album) I tried it with ZF2 master and beta4 tag (but beta4 tag gives php error about missing method getEventManager) I took the code from Akrabats Tutorial, and after that failed used the code form the GitHub Repo. Unfortunatly there isnt some Forum or

Zend Framework 2 and Doctrine 2 - Configuration for multiple databases

牧云@^-^@ 提交于 2019-12-18 17:54:09
问题 I pasted the code from the configuration.md file to module.config.php 'doctrine' => array( 'connection' => array( 'orm_crawler' => array( 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', 'params' => array( 'host' => 'localhost', 'port' => '3306', 'user' => 'root', 'password' => 'root', 'dbname' => 'crawler', 'driverOptions' => array( 1002 => 'SET NAMES utf8' ), ) ) ), 'configuration' => array( 'orm_crawler' => array( 'metadata_cache' => 'array', 'query_cache' => 'array', 'result_cache

Zend Framework 2 - Translate Standard Form Validation and Error messages

让人想犯罪 __ 提交于 2019-12-18 17:28:31
问题 I'm writing a complete German application and therefore need to set basically everything to German. My question: What is the best and easiest way to set for example the form validation to German? I found this page but couldn't figure out how to get this code working: Zend_Validate_Abstract::setDefaultTranslator($translate); Could anyone give me some advice how to use this? Edit: Thanks to @Gordon I put the following into my Application/Module.php: use Zend\I18n\Translator\Translator; use Zend

Deprecated: Retrieve service locator in functional system - ZF2

大憨熊 提交于 2019-12-18 15:55:11
问题 I'm developing a ZF2 system and it was working very well, but after I clone the repository in other computer this deprecated error has appeared: You are retrieving the service locator from within the class Module\Controller\Controller. Please be aware that ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along with the ServiceLocatorAwareInitializer. You will need to update your class to accept all dependencies at creation, either via constructor arguments or

ZF2 apigility - How can we validate collections in json data

北慕城南 提交于 2019-12-18 13:38:17
问题 How can I get validated json value using Apigility. For example, I need to get validated user_id under users collection in the following json data. { "log_type": "split food", "meal_type": "Break Fast", "meal_date": "12-2-2015", "users": [ { "user_id": 1, "food_details": [ { "food_id":101 } ] } ] } I know fields can be validated through apigility but here is from json. Thank you 回答1: You should look into the documentation of ZF2 validation for validating (form) collections. Some documentation

Zend Framework 2: subqueries

霸气de小男生 提交于 2019-12-18 13:26:32
问题 ZF2 recently updated to version 2.1.4 with a database API has changed http://framework.zend.com/security/advisory/ZF2013-03 Now the code that I used for a subquery was an exception: $sub = new Select('md_type'); $sub->columns(array(new Expression('COUNT(mt2.parent_id) as total'))) ->where(array( new \Zend\Db\Sql\Predicate\Expression('mt2.parent_id = mt1.id') )) ; $subquery = new \Zend\Db\Sql\Expression("({$sub->getSqlString()})"); $select = new \Zend\Db\Sql\Select('mt1'); $select->columns