zend-framework2

Zend Framework 2 Service in View Helper

无人久伴 提交于 2019-12-07 09:15:00
问题 I need to write a view helper that gets a service and do something with it. I successfully implemented the view helper to have access to the service locator. The problem is that the service I want to get is not being found through the service locator when the __invoke method is called. The view helper code: <?php namespace Application\View\Helper; use Zend\View\Helper\AbstractHelper, Zend\ServiceManager\ServiceLocatorAwareInterface, Application\Model; class LoggedCustomer extends

Zend Framework 2: How to properly replace Figlet with reCaptcha on zfcUser

烈酒焚心 提交于 2019-12-07 09:04:31
问题 I am trying to replace Figlet with reCaptcha on a zfcUser registration form. Partial instruction on how to accomplish this can be found on https://github.com/ZF-Commons/ZfcUser#changing-registration-captcha-element but no complete instruction exists. Checking the README.md file has a two-step instruction on how to accomplish this but still the CAPTCHA uses Figlet when rendered on the form. Has anyone successfully implemented this? I really need a hand on this one. Thanks in advance. EDIT:

Difference between init() and onBootStrap() in Zend Framework 2?

自闭症网瘾萝莉.ら 提交于 2019-12-07 09:01:17
问题 I'm reading a book on ZF2 and it refers to both init() and onBootStrap() as functions in Module.php that are called during every page load and therefore should be as lightweight as possible. Aside from a slightly different signature: init(ModuleManager m) onBootStrap(MvcEvent e) I'm struggling to determine when I should use which, and for what reason. In the book, both methods are being used to attach to (different) events. Can someone provide a clear definition of the difference between the

Doctrine - How to extract results and their relationships as array

夙愿已清 提交于 2019-12-07 08:08:41
问题 I have an entity, call it Stones and Stones has a ManyToMany relationship with Attributes. So I query the entity to get the Stones and then I hydrate this to convert it into an array. $result = $this->stoneRepository->find($stone_id); if ( ! $result ) { return false; } $resultArray = $this->doctrineHydrator->extract($result); This works fine for the Stone entity however I noticed that the join (Attributes) remain as objects. array (size=12) 'id' => int 1 'name' => string 'Agate' (length=5)

zf2 create select/drop down box and populate options in controller?

ぐ巨炮叔叔 提交于 2019-12-07 08:05:42
问题 To Create a text input box I used folling code in zend framework2 use Zend\Form\Form; class Loginform extends Form { public function __construct() { $this->add(array( 'name' => 'usernames', 'attributes' => array( 'id' => 'usernames', 'type' => 'text', ), 'options' => array( 'label' => 'User Name', ), )); } } and I can populate the values in controller action using $form = new Loginform(); $form->get('usernames')->setAttribute('value', 'user 1'); Any idea how can I do the same for Selection

ZF2 View strategy

一个人想着一个人 提交于 2019-12-07 08:04:12
问题 I'm trying to implement the following: Simple controller and action. Action should return response of 2 types depending on the request: HTML in case of ordinary request (text\html), JSON in case of ajax request (application\json) I've managed to do this via a plugin for controller, but this requres to write return $this->myCallBackFunction($data) in each action. And what if I wan't to do this to whole controller? Was trying to figure out how to implement it via event listener, but could not

ZF2 Http uri validation

痴心易碎 提交于 2019-12-07 07:49:21
问题 I try to validate an URI with ZF2. The problem is when I set $value as 'http://google.com' or 'google/com', it gives me both an output 'bool(false)'. My code; use Zend\Uri\Http as ValidateUri; use Zend\Uri\Exception as UriException; class Domain { public function domain($value) { return $this->validate($value); } public function validate($value) { if (empty($value) || !is_string($value)) { return false; } try { $uriHttp = ValidateUri::validateHost($value); var_dump($uriHttp); } catch

zf2 make a join between two different databases

故事扮演 提交于 2019-12-07 07:31:09
问题 I am trying to make a join between two tables placed in different databases with Zend Framework 2. The first table is called users and is stored in the database admin The second table is called hierarchy and is stored in the database customer I load the databases adapters in global.php return array( 'admin' => array( 'driver' => 'Pdo', 'dsn' => 'mysql:dbname=admin;host=localhost', 'driver_options' => array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'' ), ), 'customer' => array(

ZF2: allow empty fieldset, but validate if least one is filled out

 ̄綄美尐妖づ 提交于 2019-12-07 07:11:46
问题 I have defined a fieldset for phone numbers. This contains fields "type" (private, Office mobile ...) and "number". The Input filter for number is "required => true": `` class PhoneFieldset extends BaseFieldset implements InputFilterProviderInterface { public function __construct() { parent::__construct('phones'); $this->setHydrator(new DoctrineHydrator($this->getEntityManager(), 'HtsBase\Entity\Phone')) ->setObject(new Phone()); $this->add(array( 'type' => 'DoctrineORMModule\Form\Element

like in where query in zend framework 2

ぃ、小莉子 提交于 2019-12-07 06:54:12
问题 I am using the Zend framework 2.x and facing the problem as I have search a lot. I want to use the like clause in query but each time gives the errors: Here is my efforts: $sql = new Sql($this->adapter); $select = $sql->select()->columns( array('user_profile_id', 'profile_login_name'))->from($this->table)->where->like( 'profile_login_name', '%'.$strSearch.'%'); echo $select->getSqlString(); die; but this gives the error: Fatal error : Call to undefined method Zend\Db\Sql\Where::getSqlString()