zend-framework2

How to attach css and javascript files in zf2 controller?

≯℡__Kan透↙ 提交于 2019-12-11 10:26:54
问题 i attach some stylesheets in zend controller but blank page shown,how i include stylesheets and javascript files in zend controller?here is my code: public function showAction() { //css $this->viewHelperManager->get('headLink')->appendStylesheet('/css/style.css'); $this->viewHelperManager->get('headLink')->appendStylesheet('/css/bootstrap-theme.min.css'); $this->viewHelperManager->get('headLink')->appendStylesheet('/css/tweaks.css'); $this->viewHelperManager->get('headLink')->appendStylesheet

ZF2: How can I set basePath to be the same for a whole application?

会有一股神秘感。 提交于 2019-12-11 10:23:00
问题 The manual's example shows how to set the basePath only for some specific viewModel : $this->getHelper('basePath')->setBasePath() But I want to set it somewhere in one place and then it is the same for any viewModel I create in any Controller. How can I do it? 回答1: You could set a global base path in config: 'view_manager' => array( 'base_path' => '/path/' ) 来源: https://stackoverflow.com/questions/13955426/zf2-how-can-i-set-basepath-to-be-the-same-for-a-whole-application

How to override the native zf2 view helpers with a custom helper

心已入冬 提交于 2019-12-11 10:03:09
问题 I wanted to create a custom basepath helper to replace the original zf2 basepath view helper. So if i call $this->basepath , it will use my custom basepath instead of the original one. I am not sure if this is can be done. I want my custom basepath extends the original basepath class too. I have found some answers on how to create custom helpers and how to register them in module.php or module.config.php But i can't find any similar questions on how to override the original helpers! 回答1:

Time between request in Zend 2

橙三吉。 提交于 2019-12-11 09:58:47
问题 I have a question about Zend Framework 2.I want to find out how much time take to complete a request and I know that it should be possible using Zend MVCEvent but I don't know how. 回答1: a better solution in my mind is to replace a special variable inside your template files like this {{ renderTime }} so you are free to controll the text position and don't mess up json response models in your zf application. let me explain why i don't hook up into the \Zend\View\ViewEvent::EVENT_RENDERER event

Create Doctrine entity of single table from database in Zend Framework 2

僤鯓⒐⒋嵵緔 提交于 2019-12-11 09:58:26
问题 I have configured doctrine ORM in my ZF2 project and create doctrine entity of whole database. Now, I have added one more table named dashboard_group in database. How can I create Doctrine entity for only this table. I don't want to replace other created entities. 回答1: Use –filter option in your command : ./vendor//bin/doctrine-module orm:convert-mapping --namespace="YourModule\\Entity\\" --force --from-database --filter="dashboard_group" annotation ./module/MonModule/src/ And then to add

ZF2 - ApiGility installed in my own app - route not working

∥☆過路亽.° 提交于 2019-12-11 09:57:08
问题 I am attempting to install APIGILITY in my app. I have followed this tutorial: https://apigility.org/documentation/recipes/apigility-in-an-existing-zf2-application When I attempt to access the apigility admin: www.myapp.dev/apigility I get a "The requested URL could not be matched by routing" error. My config is as follows: 'modules' => array( 'DoctrineModule', 'DoctrineORMModule', 'ZfcRbac', //Keep this at the top 'Application', //The applications main functions run from this module /

with Zend\Db\Sql\Select can I manipulate the order that the SQL parts are put together?

一曲冷凌霜 提交于 2019-12-11 09:53:52
问题 I am using PDO Firebird with Zend\Db. This is fine until i want to limit the number of records returned. I am using this code; $select = $this->getSelect() ->limit($limit); Which produces this SQL; SELECT "MODELS".* FROM "MODELS" limit '10' However firebird needs SQL like this; SELECT first 10 "MODELS".* FROM "MODELS" I can change the word 'limit' to 'first' by using this statement; $select->setSpecification('limit', 'first %1$s'); But I can't figure out how i get it to put the limit (first)

How to add a rule to the Zend URL mapping and compose multiple MVC paths?

梦想的初衷 提交于 2019-12-11 09:45:25
问题 This is because I want to develop a web platform with more than one application in the same project. In any MVC web application we should have this default URL schema: domain / controller / action / parameters 1: In Zend, what can I do (in which files) to change this schema to add the application name before the controller name? Expected Result: domain / application / controller / action / parameters 2: How can I implement the consequences of this new URL block in terms that I will separate

ZF2 Form and Doctrine 2 modify the value_options

只愿长相守 提交于 2019-12-11 09:37:25
问题 I am using Doctrine 2 in my Zend Framework 2 Project. I have now created a Form and create one of my Dropdowns with Values from the Database. My Problem now is that I want to change which values are used and not the one which I get back from my repository. Okay, here some Code for a better understanding: $this->add( array( 'type' => 'DoctrineModule\Form\Element\ObjectSelect', 'name' => 'county', 'options' => array( 'object_manager' => $this->getObjectManager(), 'label' => 'County', 'target

Zend framework 2 callback filter

核能气质少年 提交于 2019-12-11 08:47:34
问题 In ZF2, is it possible to pass form values array to the callback filter similar to the callback validator? //Validator callback works 'callback' => function($value, $context){ //$context contains form values } //Need similar functionality for filter 'callback' => function($value, $context){ //$context will issue a warning because its not set } //I know the following filter works, but I dont know how to pass the form 'callback' => function($value, $context){ print_r($context); //Prints 'hello