zend-framework2

Zend framework 2 PDF generation [closed]

南楼画角 提交于 2020-01-03 06:30:12
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I want to crate single A5 PDF document with 24 pages , There is no need to account for slugs or bleed , What is the Best Zendframwork 2 PDF generation Module for this ? Do you have tutorials or example pleas send me the links thank you .. 回答1: I use TCPDF. To get it up and running within your Zf2 installation

Zend Framework 2 model foreign keys

旧时模样 提交于 2020-01-03 06:20:06
问题 I am now approaching Zend Framework 2 and I followed the tutorial on creating a simple CRUD application. Everything is fine but now I want to, for instance, add a genre to the album. I added a category table to the database and created a foreign key category_id in the album table which refers to the category.id in the category table. How do I reflect this situation on my model using TableGateway ? 回答1: I hope this will help you and you will get the idea how to accomplish your task: <?php In

ZF2 view rendering

◇◆丶佛笑我妖孽 提交于 2020-01-03 05:54:21
问题 In ZF1 I can do something like this: $view = new Zend_View(); $view->setScriptPath($viewDir); $html = $view->render('template_name.phtml'); How can I do that in ZF2? 回答1: public function abcAction() { $view = new ViewModel(array('variable'=>$value)); $view->setTemplate('module/controler/action.phtml'); // path to phtml file under view folder return $view; } public function differentViewScriptAction() { // Use a different view script $viewModel = new ViewModel(); $viewModel->setTemplate(

ZF2/3 Load Modules from Database

不想你离开。 提交于 2020-01-03 03:57:07
问题 I would like to know if there is a way to load modules from a database table in zend framework 2 preferable 3? I want to be able to dynamically disable or enable modules based on a status column inside a database table 回答1: I'm pretty sure you can accomplish this by attaching listener to some of ModuleManager events. There are docs for v3 https://docs.zendframework.com/zend-modulemanager/module-manager/ and v2 https://framework.zend.com/manual/2.1/en/modules/zend.module-manager.module-manager

Zend Framework 2: How to get ServiceLocator in validation class

雨燕双飞 提交于 2020-01-02 12:20:29
问题 I would like to get ServiceLocator in my validation class. I tried get it from Controller instance but it returns null. MyValidation.php namespace Register\Validator; use Zend\Validator\AbstractValidator; use Register\Controller\RegisterController; class MyValidation extends AbstractValidator { /* code... */ function isValid($value) { $controller = new RegisterController(); $sm = $controller->getServiceLocator(); $tableGateway = $sm->get('Register\Model\RegisterTable'); $tableGateway-

Using PhpRenderer directly with child views in ZF2

怎甘沉沦 提交于 2020-01-02 09:10:43
问题 When sending out e-mails in Zend Framework 2, I want to use view script templates such that I can leverage a layout for my various e-mail templates. The idea is that I have a layout which has the shared markup and echoes out content somewhere. Exactly how layouts work in general. To accomplish this, I am trying to add a child view model to my layout view model and render it with the PhpRenderer . public function someMethod() { $child = new ViewModel(); $child->setTemplate('test-template');

Zend framework 2 : How to set locale globaly?

帅比萌擦擦* 提交于 2020-01-02 01:55:31
问题 I have to change the locale dynamically depending which language the user wants. I can set the locale in the Application/Module.php like this : public function onBootstrap(MvcEvent $e) { $translator = $e->getApplication()->getServiceManager()->get('translator'); $translator->setLocale('hu_HU'); } But, how can I do this in the controller, if I want to change languages ? I tried this, but after this I can change the locale only for this one request and not global. $translator = $this-

ZF2 Translation

寵の児 提交于 2020-01-01 15:36:47
问题 I have two modules - Application and StickyNotes. I need to use translation on all pages. What I do: 1) In view: <?=$this->translate('Home');?> 2) In Application\Module.php: public function onBootstrap(MvcEvent $e) { $translator = $e->getApplication()->getServiceManager()->get('translator'); $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); $app = $e->getParam('application'); $app-

ZF2 Translation

ⅰ亾dé卋堺 提交于 2020-01-01 15:36:12
问题 I have two modules - Application and StickyNotes. I need to use translation on all pages. What I do: 1) In view: <?=$this->translate('Home');?> 2) In Application\Module.php: public function onBootstrap(MvcEvent $e) { $translator = $e->getApplication()->getServiceManager()->get('translator'); $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); $app = $e->getParam('application'); $app-

ZF2 how to wrap content in form fieldset?

荒凉一梦 提交于 2020-01-01 11:39:10
问题 I have form with fieldsets: $formConfig = array( 'fieldsets' => array( ... ); ); $factory = new Zend\Form\Factory(); $form = $factory->createForm($formConfig); echo $this->form($form); It renders something like this: <form> <fieldset> <legend>Fieldset label</legend> <label><span>Elem 1</span><input type="text" name="f1[el1]" /></label> <label><span>Elem 2</span><input type="text" name="f1[el2]" /></label> <label><span>Elem 3</span><input type="text" name="f1[el3]" /></label> </fielset> </form