/** * Get a hydrator to bind CustomField objects to the database * * Unlike other tables, the hydrator cannot be provided by the CustomFields * table class due to tricky dependencies. Use this method to get a suitable * hydrator. * * @return \Zend\Hydrator\ArraySerializable */ public function getHydrator() { if (!$this->_hydrator) { $columns = $this->getColumnMap(); $this->_hydrator = new \Zend\Hydrator\ArraySerializable(); $this->_hydrator->setNamingStrategy(new \Database\Hydrator\NamingStrategy\MapNamingStrategy(array_flip($columns))); $dateStrategy = new \Zend\Hydrator\Strategy\DateTimeFormatterStrategy('Y-m-d'); foreach ($this->getFields() as $name => $type) { if ($type == 'date') { $this->_hydrator->addStrategy($name, $dateStrategy); $this->_hydrator->addStrategy($columns[$name], $dateStrategy); } } } return $this->_hydrator; }