zend-framework2

ZF2 Form: Customizing order of elements

╄→гoц情女王★ 提交于 2019-12-10 16:53:43
问题 I'm creating a form for a logged-in user to change their password, so I created a subclass of an existing password-reset form I have available. The forms will be identical except with an additional field for existing password. It's worked so far, except I can't figure out a way to manually set the order the new field; the only place I've gotten it to appear is at the end of the form. It seems that ZF2 requires you to add() form elements in the order that you want them rendered. I would do so,

Zend 2: How to override module's configuration file?

微笑、不失礼 提交于 2019-12-10 16:39:26
问题 How can I override configuration files found under ./vendor/.../module_name/config/module.config.php? And no, this link isn't working for me. I'm not sure why. 回答1: Try naming the configuration file filename.global.php or filename.local.php. Inside application.config.php it has this line: config/autoload/{,*.}{global,local}.php With regards to ZfcUser module and changing the main route. In zfcuser.global.php modify the following at the bottom of the file: return array( 'zfcuser' => $settings,

404 HTTP errors not being rendered in JSON using Zend framework 2

房东的猫 提交于 2019-12-10 16:04:36
问题 I'm creating a simple restful api using zend framework2 and I've references Rob Allen's notes on the subject as well as this excellent tutorial by http://hounddog.github.com/blog/getting-started-with-rest-and-zend-framework-2/ below is my module_config.php. You'll see that I have routes and the JSON view strategy configured. My understanding is that when you set up the JSON strategy in this fashion it accommodates all modules. The issue is that when an invalid route is entered the 404

zend framework 2 Dynamic Breadcrumbs - Passing Parameters

耗尽温柔 提交于 2019-12-10 15:58:29
问题 I'm a newcomer to Zend Framework 2 and I´m trying to generate dynamic Breadcrumbs using ZF2 but without success. I used http://adam.lundrigan.ca/2012/07/quick-and-dirty-zf2-zend-navigation/ as a base for my work and as described I constructed the sitemap for the routes exposed by my modules. Example: // config/autoload/nav_zfcuser.global.php <?php return array( // All navigation-related configuration is collected in the 'navigation' key 'navigation' => array( // The DefaultNavigationFactory

Set variables to 404 in zend framework 2

陌路散爱 提交于 2019-12-10 15:37:31
问题 In my controller I throw a 404 response after an If statement, something like that : if ($foo) { $this->getResponse()->setStatusCode(404); return; } Then, I would like to send some variables to my 404 page. In my mind, I want to do something like that : $this->getResponse()->setVariables(array('foo' => 'bar', 'baz' => 'bop')); $this->getResponse()->setStatusCode(404); return; It's not the good solution, so how I have to do that ? And after, how to get these variables in my 404 view ? Thank

How to specify route with parameter in paginationControl?

独自空忆成欢 提交于 2019-12-10 14:53:40
问题 I am trying to create pagination on my news feed. I have two modes in my news feed: all news feed and feed by category. Pagination for all news feed works fine, but I have problems with "feed by category" pagination. I use paginationControl like this: <?=$this->paginationControl( $this->news, 'Sliding', 'pagination_control', array('route' => 'news/category') )?> Route news/category config: 'category' => array( 'type' => 'Segment', 'options' => array( 'route' => '/:category[/page-:page]',

Zend Framework 2 - Database connection

笑着哭i 提交于 2019-12-10 14:48:54
问题 Trying to wrap my head around the new concepts of Zend Framework 2.0. I'm trying to connect to a database, and to get that connection in a controller or model. Nothing fancy, just the pure connection to run queries against. So this is my current code: //module.config.php return array( 'db' => array( 'driver' => 'Pdo', 'dsn' => 'mysql:dbname=DBNAME;host=HOSTNAME, 'driver_options' => array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'' ), 'username' => 'USERNAME', 'password' => 'PASSWORD

Convert Zend\Db\ResultSet\HydratingResultSet to Array of Objects

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 14:20:47
问题 In my Mapper class I'm extending AbstractDbMapper from ZfcBase to fetch rows from the database. A simple example would be code like this: class MyMapper extends AbstractDbMapper { //... public function fetchAll() { $select = $this->getSelect(); return $this->select($select); // returns HydratingResultSet } } The problem is that $this->select() returns a Zend\Db\ResultSet\HydratingResultSet (containing the needed and hydrated objects). But I would like to return an array of these objects

ZF 2 :Catchable fatal error: Argument 1 passed to Zend\View\HelperPluginManager

一笑奈何 提交于 2019-12-10 13:52:01
问题 I run the app created with Zend Framework 2 i get this Error: Catchable fatal error: Argument 1 passed to Zend\View\HelperPluginManager::__construct() must implement interface Interop\Container\ContainerInterface, none given, called in C:\wamp\www\blog\vendor\zendframework\zend-mvc\src\Service\AbstractPluginManagerFactory.php on line 32 and defined in C:\wamp\www\blog\vendor\zendframework\zend-view\src\HelperPluginManager.php on line 241 how can i resolved that Thanks in advance 回答1: See the

Amazon CloudWatchLogs putLogEvents in PHP gives error tooOldLogEventEndIndex

这一生的挚爱 提交于 2019-12-10 12:44:48
问题 hi guys i'm trying to put Log on amazon CloudWatchLogs like this: $response2 = $amzonLoger->putLogEvents([ 'logGroupName' => 'myGroup', 'logStreamName' => 'myStream', 'logEvents' => [ [ 'timestamp' => time(), 'message' => 'message' ], ], 'sequenceToken' => lastToken, ]); var_dump($response2); but always i've this response : bject(Guzzle\Service\Resource\Model)#289 (2) { ["structure":protected]=> NULL ["data":protected]=> array(2) { ["nextSequenceToken"]=> string(56)