public function __invoke($services) { $hydrator = new ClassMethods(); $hydrator->addStrategy('createdDatetime', new DatetimeStrategy()); $hydrator->addStrategy('lastModified', new DatetimeStrategy()); return $hydrator; }
/** * Return an instance of ClassMethods * * @return ClassMethods */ protected function getHydrator() { if (!isset($this->hydrator)) { $hydrator = new ClassMethods(); $hydrator->addStrategy('coord', new CoordStrategy()); $hydrator->addStrategy('sun', new SunStrategy()); $this->hydrator = $hydrator; } return $this->hydrator; }
/** * @return ClassMethodsHydrator */ public function createService(ServiceLocatorInterface $serviceLocator) { $serviceLocator = FactoryUtils::resolveServiceLocator($serviceLocator); $objectManager = $serviceLocator->get('doctrine.entitymanager.orm_default'); $hydrator = new ClassMethodsHydrator(false); $hydrator->addStrategy('client', new EntityStrategy($objectManager->getRepository('Ajasta\\Client\\Entity\\Client'))); $hydrator->addStrategy('project', new EntityStrategy($objectManager->getRepository('Ajasta\\Client\\Entity\\Project'))); $hydrator->addStrategy('issueDate', new DateStrategy()); $hydrator->addStrategy('dueDate', new DateStrategy()); return $hydrator; }
/** * Return an instance of ClassMethods hydrator * * @return ClassMethods */ protected function getHydrator() { if (!isset($this->hydrator)) { $hydrator = new ClassMethods(); $hydrator->addStrategy('location', new LocationStrategy()); $hydrator->addStrategy('credit', new CreditStrategy()); $hydrator->addStrategy('meta', new MetaStrategy()); $hydrator->addStrategy('sun', new SunStrategy()); $hydrator->addStrategy('forecast', new ForecastStrategy()); $this->hydrator = $hydrator; } return $this->hydrator; }
public function find($id) { $order = $this->ordersRepository->find($id); $client = $this->clientsRepository->findBy(['id' => $order->getClientId()])->current(); $ptype = $this->ptypesRepository->findBy(['id' => $order->getPtypeId()])->current(); $user = $this->usersRepository->findBy(['id' => $order->getUserId()])->current(); $sql = $this->ordersRepository->getItemTable()->getSql(); $select = $sql->select(); $select->join('products', 'order_items.product_id = products.id', ['product_name' => 'name'])->where(['order_id' => $order->getId()]); $items = $this->ordersRepository->getItemTable()->selectWith($select); foreach ($items as $item) { $order->addItem($item); } $hydrator = new ClassMethods(); $hydrator->addStrategy('items', new OrdersItemsHydratorStrategy(new ClassMethods())); $order->setClient($hydrator->extract($client)); $order->setPtype($hydrator->extract($ptype)); $order->setUser($hydrator->extract($user)); $result = $hydrator->extract($order); unset($result['client_id']); unset($result['ptype_id']); unset($result['user_id']); unset($result['user']['username']); unset($result['user']['password']); return $result; }
protected function buildHydrator($product, $direction) { $this->assertOptionsValid(); $config = $this->options->getConfig(); $class = $this->options->getClass(); $hydrator = new ClassMethods(); if (!isset($config[$this->options->getClass()][$product])) { return $hydrator; } $tmp = new Config(array()); if (isset($config[$class]['*'])) { $tmp = new Config($config[$class]['*']); } if (isset($config[$class][$product])) { $productConfig = new Config($config[$class][$product]); $tmp = $productConfig->merge($tmp); } $config = $tmp['shared']; if (isset($tmp[$direction])) { $config->merge($tmp[$direction]); } $config = $config->toArray(); if (!empty($config['map'])) { $hydrator->setNamingStrategy(new ArrayMapNamingStrategy($config['map'])); } if (!empty($config['strategy'])) { foreach ($config['strategy'] as $name => $strategyCallback) { $hydrator->addStrategy($name, $strategyCallback()); } } if (!empty($config['options'])) { $this->options->setFromArray($config['options']); } return $hydrator; }
public function init() { $hydrator = new ClassMethods(); $hydrator->addStrategy('birthdate', new DateTimeStrategy()); $this->setAttribute('method', 'post'); $this->setHydrator($hydrator)->setObject(new \Customer\Entity\Customer()); $this->add(array('name' => 'company', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Company')))); $this->add(array('name' => 'firstname', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('First name')))); $this->add(array('name' => 'lastname', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Last name')))); $this->add(array('name' => 'note', 'attributes' => array('type' => 'textarea', 'class' => 'wysiwyg'), 'options' => array('label' => _('Private Notes')))); $this->add(array('name' => 'birthdate', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth date')))); $this->add(array('name' => 'birthplace', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth place')))); $this->add(array('name' => 'birthdistrict', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth district')))); $this->add(array('name' => 'birthcountry', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth country')))); $this->add(array('name' => 'birthnationality', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth nationality')))); $this->add(array('name' => 'taxpayernumber', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Tax payer number')))); $this->add(array('name' => 'vat', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('VAT')))); $this->add(array('type' => 'Customer\\Form\\Element\\CustomerGroup', 'name' => 'group_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Customer Group')))); $this->add(array('type' => 'Base\\Form\\Element\\Languages', 'name' => 'language_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Language')))); $this->add(array('type' => 'Customer\\Form\\Element\\Legalform', 'name' => 'legalform_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Legal form')))); $this->add(array('type' => 'Customer\\Form\\Element\\Companytype', 'name' => 'type_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Company Type')))); $this->add(array('type' => 'Customer\\Form\\Element\\Status', 'name' => 'status_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Status'), 'section' => 'customers'))); $this->add(array('type' => 'Zend\\Form\\Element\\File', 'name' => 'file', 'attributes' => array('class' => ''), 'options' => array('label' => _('Upload Document')), 'filters' => array(array('required' => false)))); $this->add(array('name' => 'contact', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Contact')))); $this->add(array('type' => 'Customer\\Form\\Element\\ContactType', 'name' => 'contacttype', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Contact Type')))); $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'gender', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Gender'), 'value_options' => array('M' => _('Male'), 'F' => _('Female'))))); // This is a fieldset $this->add(array('name' => 'address', 'type' => '\\Customer\\Form\\Fieldset\\AddressFieldset', 'object' => '\\Customer\\Entity\\Address', 'options' => array('use_as_base_fieldset' => false))); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'class' => 'btn btn-success', 'value' => _('Save')))); $this->add(array('name' => 'user_id', 'attributes' => array('type' => 'hidden'))); $this->add(array('name' => 'uid', 'attributes' => array('type' => 'hidden'))); $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); }
public function createService(ServiceLocatorInterface $serviceLocator) { $dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter'); $hydrator = new ClassMethods(); $hydrator->addStrategy(DbViewVotes::DATETIME, new DateTimeFormatterStrategy('Y-m-d H:i:s')); $prototype = $serviceLocator->get('VotePrototype'); return new VoteDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewVotes::TABLE, DbViewVotes::__ID); }
/** * Get Hydrator * @return ClassMethods */ public function getHydrator() { if (!$this->hydrator) { // use underscore separated keys by default $this->hydrator = new ClassMethods(); $this->hydrator->addStrategy('_id', new MongoIdStrategy()); } return $this->hydrator; }
public function init() { $hydrator = new ClassMethods(); $hydrator->addStrategy('birthdate', new DateTimeStrategy()); $this->setAttribute('method', 'post'); $this->setHydrator($hydrator)->setObject(new \Dummy\Entity\Dummy()); $this->add(array('name' => 'name', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Company')))); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'class' => 'btn btn-success', 'value' => _('Save')))); $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); }
public function createService(ServiceLocatorInterface $services) { $service = new PostService(); $service->setSqlService($services->get(SqlService::class)); $hydrator = new ClassMethods(); // Stupid MySQL... $hydrator->addStrategy('is_visible', new BooleanStrategy("1", "0")); $service->setPostHydrator($hydrator); return $service; }
public function createService(ServiceLocatorInterface $serviceLocator) { $dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter'); $hydrator = new ClassMethods(); $namingStrat = new \Zend\Stdlib\Hydrator\NamingStrategy\MapNamingStrategy(array(DbViewPages::PAGEID => 'id', DbViewPages::PAGENAME => 'name', DbViewPages::REVISIONS => 'revisionCount', DbViewPages::STATUSID => 'status', DbViewPages::STATUS => '', DbViewPages::KINDID => 'kind', DbViewPages::KIND => '')); $hydrator->setNamingStrategy($namingStrat); $hydrator->addStrategy(DbViewPages::CREATIONDATE, new \Zend\Stdlib\Hydrator\Strategy\DateTimeFormatterStrategy('Y-m-d H:i:s')); $prototype = $serviceLocator->get('PagePrototype'); return new PageDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewPages::TABLE, DbViewPages::PAGEID); }
public function createService(ServiceLocatorInterface $serviceLocator) { $dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter'); $hydrator = new ClassMethods(); $names = array(DbViewRevisions::REVISIONID => 'id', DbViewRevisions::REVISIONINDEX => 'index'); $hydrator->setNamingStrategy(new MapNamingStrategy($names)); $hydrator->addStrategy(DbViewRevisions::DATETIME, new \Zend\Stdlib\Hydrator\Strategy\DateTimeFormatterStrategy('Y-m-d H:i:s')); $prototype = $serviceLocator->get('RevisionPrototype'); return new RevisionDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewRevisions::TABLE, DbViewRevisions::REVISIONID); }
/** * Return an instance of ClassMethods * * @return ClassMethods */ protected function getHydrator() { if (!isset($this->hydrator)) { $hydrator = new ClassMethods(false); $hydrator->addStrategy("city", new CityStrategy()); $hydrator->addStrategy('temperature', new TemperatureStrategy()); $hydrator->addStrategy('humidity', new HumidityStrategy()); $hydrator->addStrategy('pressure', new PressureStrategy()); $hydrator->addStrategy('windSpeed', new WindSpeedStrategy()); $hydrator->addStrategy('windDirection', new WindDirectionStrategy()); $hydrator->addStrategy('clouds', new CloudsStrategy()); $hydrator->addStrategy('precipitation', new PrecipitationStrategy()); $hydrator->addStrategy('weather', new WeatherStrategy()); $this->hydrator = $hydrator; } return $this->hydrator; }
public function find($id) { $hydrator = new ClassMethods(); $hydrator->addStrategy('items', new OrderItemHydratorStrategy(new ClassMethods())); $orderBusca = $this->tableGateway->select(['id' => $id]); $order = $orderBusca->current(); $items = $this->orderItemTableGateway->select(['order_id' => $order->getId()]); foreach ($items as $item) { $order->addItems($item); } $res = $hydrator->extract($order); return $res; }
public function findByUser($userId) { $hydrator = new ClassMethods(); $hydrator->addStrategy('items', new OrderItemHydratorStrategy(new ClassMethods())); $orders = $this->tableGateway->select(['user_id' => (int) $userId]); foreach ($orders as $order) { $items = $this->orderItemTableGateway->select(['order_id' => $order->getId()]); foreach ($items as $item) { $order->addItem($item); } $data[] = $hydrator->extract($order); } $ordersCollection = new OrdersCollection(new ArrayAdapter($data)); return $ordersCollection; }
/** * List only one order pass through $id * @param int $id * @param int $userId */ public function fetch($id, $userId) { $hydrator = new ClassMethods(); $hydrator->addStrategy('items', new OrderItemHydratorStrategy(new ClassMethods())); $orders = $this->repository->findByUserAndOrder($id, $userId); $result = []; foreach ($orders as $order) { $items = $this->orderItemTableGateway->select(['order_id' => $order->getId()]); foreach ($items as $item) { $order->addItem($item); } $result[] = $hydrator->extract($order); } $arrayAdapter = new ArrayAdapter($result); $ordersCollection = new OrdersCollection($arrayAdapter); return $ordersCollection; }
/** * @return array */ public function findAll() { $hydrator = new ClassMethods(); $hydrator->addStrategy('items', new OrderItemHydratorStrategy(new ClassMethods())); $orders = $this->tableGateway->select(); $res = []; foreach ($orders as $order) { $items = $this->orderItemTableGateway->select(['order_id' => $order->getId()]); foreach ($items as $item) { $order->addItem($item); } $data = $hydrator->extract($orders); $res[] = $data; } $arratAdapter = new ArrayAdapter($res); $ordersCollection = new OrdersCollection($arratAdapter); return $res; }
public function findAll($userId = null) { $hydrator = new ClassMethods(); $hydrator->addStrategy('items', new OrderItemHydratorStrategy(new ClassMethods())); // permite apenas que usuários vendedores consultar apenas seus próprios pedidos. $orders = $this->tableGateway->select(['user_id' => $userId]); $res = []; foreach ($orders as $order) { $items = $this->orderItemTableGateway->select(['order_id' => $order->getId()]); foreach ($items as $item) { $order->addItem($item); } $data = $hydrator->extract($order); $res[] = $data; } //$paginatorAdapter = new DbTableGateway($tableGateway); $arrayAdapter = new ArrayAdapter($res); $ordersCollection = new OrdersCollection($arrayAdapter); return $ordersCollection; //return $res; }
public function find($id) { $resultSet = $this->tableGateway->select(['id' => (int) $id]); if ($resultSet->count() == 1) { $hydrator = new ClassMethods(); $hydrator->addStrategy('items', new OrderItemHydratorStrategy(new ClassMethods())); $order = $resultSet->current(); $client = $this->clientTableGateway->select(['id' => $order->getClientId()])->current(); $sql = $this->orderItemTableGateway->getSql(); $select = $sql->select(); $select->join('products', 'order_items.product_id = products.id', ['product_name' => 'name'])->where(['order_id' => $order->getId()]); $items = $this->orderItemTableGateway->selectWith($select); $order->setClient($client); foreach ($items as $item) { $order->addItem($item); } $data = $hydrator->extract($order); return $data; } return false; }
public function find($id, UsersEntity $user = null) { $hydrator = new ClassMethods(); $hydrator->addStrategy('items', new OrderItemHydratorStrategy($hydrator)); $where = new Where(); $where->equalTo('id', $id); if ($user) { $where->equalTo('user_id', $user->getId()); } $order = $this->tableGateway->select($where)->current(); if (!$order) { return null; } $client = $this->clientTableGateway->select(['id' => $order->getClientId()])->current(); $order->setClient($client); $sql = $this->tableGatewayItems->getSql(); $select = $sql->select(); $select->join('products', 'order_items.product_id = products.id', ['product_name' => 'name'])->where(['order_id' => $order->getId()]); $items = $this->tableGatewayItems->selectWith($select); foreach ($items as $item) { $order->addItem($item); } return $hydrator->extract($order); }
public function findByIdUsuario($id, $idUsuario) { $hydrator = new ClassMethods(); $hydrator->addStrategy('items', new OrderItemHydratorStrategy(new ClassMethods())); $order = $this->TableGateway->select(['id' => (int) $id, 'user_id' => $idUsuario])->current(); $res = []; $items = $this->OrderItemTableGateway->select(['order_id' => $order->getId()]); foreach ($items as $item) { $order->addItem($item); } $data = $hydrator->extract($order); $res[] = $data; $arrayAdapter = new ArrayAdapter($res); $ordersColletion = new OrdersCollection($arrayAdapter); return $ordersColletion; }
/** * @dataProvider underscoreHandlingDataProvider */ public function testWhenUsingUnderscoreSeparatedKeysHydratorStrategyIsAlwaysConsideredUnderscoreSeparatedToo($underscoreSeparatedKeys, $formFieldKey) { $hydrator = new ClassMethods($underscoreSeparatedKeys); $strategy = $this->getMock('Zend\\Stdlib\\Hydrator\\Strategy\\StrategyInterface'); $entity = new TestAsset\ClassMethodsUnderscore(); $value = $entity->getFooBar(); $hydrator->addStrategy($formFieldKey, $strategy); $strategy->expects($this->once())->method('extract')->with($this->identicalTo($value))->will($this->returnValue($value)); $attributes = $hydrator->extract($entity); $strategy->expects($this->once())->method('hydrate')->with($this->identicalTo($value))->will($this->returnValue($value)); $hydrator->hydrate($attributes, $entity); }
/** * Create service with name * * @param ServiceLocatorInterface $serviceLocator * @param $name * @param $requestedName * @return mixed */ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) { $config = $serviceLocator->get('Config'); $zohoConfig = $config['zoho']; $resourceConfig = $config['zoho']['resources'][$requestedName]; $resource = new Resource($zohoConfig['auth_token'], $zohoConfig['organization_id']); $resource->setPath($resourceConfig['path']); $resource->setCollectionName($resourceConfig['collectionName']); $entityClass = array_key_exists('entityClass', $resourceConfig) ? $resourceConfig['entityClass'] : str_replace('Resource', 'Entity', $requestedName); $resource->setEntityClass($entityClass); $resource->setEntityName($resourceConfig['entityName']); if (isset($resourceConfig['input-filter']) && is_array($resourceConfig['input-filter'])) { $inputFilterFactory = new InputFilterFactory(); $inputFilter = $inputFilterFactory->createInputFilter($resourceConfig['input-filter']); $resource->setInputFilter($inputFilter); } $hydratorManager = $serviceLocator->get('HydratorManager'); $hydratorName = str_replace('Entity', 'Hydrator', $entityClass); if ($hydratorManager->has($hydratorName)) { $hydrator = $hydratorManager->get($hydratorName); } else { $hydrator = new ClassMethods(); } if (isset($resourceConfig['strategies'])) { foreach ($resourceConfig['strategies'] as $field => $strategyKey) { if (!$serviceLocator->has($strategyKey)) { throw new ServiceNotCreatedException(sprintf('Invalid strategy %s for field %s', $strategyKey, $field)); } $strategy = $serviceLocator->get($strategyKey); if (!$strategy instanceof StrategyInterface) { throw new ServiceNotCreatedException(sprintf('Invalid strategy class %s for field %s', get_class($strategy), $field)); } $hydrator->addStrategy($field, $strategy); } } $resource->setHydrator($hydrator); return $resource; }
public function testUseWildStrategyAndOther() { $hydrator = new ClassMethods(); $datas = $hydrator->extract($this->classMethodsUnderscore); $this->assertEquals($datas['foo_bar'], '1'); $hydrator->addStrategy('foo_bar', new DefaultStrategy()); $hydrator->addStrategy('*', new SerializableStrategy('phpserialize')); $datas = $hydrator->extract($this->classMethodsUnderscore); $this->assertEquals($datas['foo_bar'], '1'); $this->assertEquals($datas['foo_bar_baz'], 's:1:"2";'); }
/** * (non-PHPdoc) * @see \Zend\ServiceManager\FactoryInterface::createService() */ public function createService(ServiceLocatorInterface $serviceLocator) { $hydrator = new ClassMethods(); $hydrator->addStrategy('node_route_config', new SerializableStrategy(new PhpSerialize())); return $hydrator; }
public function getLead($id) { $select = $this->sql->select(); $select->where(array('id' => $id)); $statement = $this->sql->prepareStatementForSqlObject($select); $result = $statement->execute()->current(); if (!$result) { return null; } $hydrator = new ClassMethods(); $hydrator->addStrategy('timecreated', new DateTimeLocalStrategy()); $hydrator->addStrategy('timesubmitted', new DateTimeLocalStrategy()); $hydrator->addStrategy('submitted', new BooleanStrategy()); $lead = new LeadEntity(); $hydrator->hydrate($result, $lead); return $lead; }
/** * Prepare the attribute form * * @param $attributes array * @return \ProductAdmin\Form\ProductForm */ public function createAttributesElements(array $attributes) { $customHydrator = new ClassMethods(true); $parentFilter = new \Zend\InputFilter\InputFilter(); $fieldset = new \Zend\Form\Fieldset('attributes'); // $fieldset->setUseAsBaseFieldset(true); $fieldset->setObject(new \Zend\Stdlib\ArrayObject()); $fieldset->setFormFactory($this->getFormFactory()); // thanks to jurians #zftalk irc $fieldInput = null; $inputFilter = new \Zend\InputFilter\InputFilter(); foreach ($attributes as $attribute) { $formitem = array(); $filterChain = new \Zend\Filter\FilterChain(); $name = $attribute->getName(); $label = $attribute->getLabel() ? $attribute->getLabel() : "-"; $type = $attribute->getType() ? $attribute->getType() : "string"; $isRequired = $attribute->getIsRequired(); $sourceModel = $attribute->getSourceModel(); $filters = $attribute->getFilters(); $validators = $attribute->getValidators(); $cssStyles = $attribute->getCss(); $validators = !empty($validators) ? json_decode($validators, true) : array(); // create the new form element array structure $formitem['attributes'] = $attribute->getCustomAttributes() ? json_decode($attribute->getCustomAttributes(), true) : json_decode($attribute->attributes, true); $formitem['attributes']['id'] = $name; $formitem['attributes']['class'] = !empty($attribute->basecss) ? $attribute->basecss : null; $formitem['attributes']['name'] = $name; $formitem['type'] = !empty($sourceModel) ? $sourceModel : $attribute->input_type; $formitem['options']['label'] = $label; if ($attribute->getData()) { $formitem['options']['value_options'] = json_decode($attribute->getData(), true); } $filterChain->attachByName('null'); // set as default // set the css style of the element if (!empty($cssStyles)) { $formitem['attributes']['class'] .= " " . $cssStyles; } // Handle the dates if (!empty($type) && $type == "date") { $customHydrator->addStrategy($name, new DateTimeStrategy()); $typeSource = 'Zend\\Form\\Element\\Date'; $formitem['type'] = "\\Zend\\Form\\Element\\Date"; $formitem['options']['format'] = 'd/m/Y'; } // handle the validators preferences of the attribute foreach ($validators as $validator) { $formitem['validators'] = $validator; } // var_dump($type); // var_dump($customHydrator); // var_dump($formitem); // Attach the form item into the form $fieldset->add($formitem); $fieldInput = new \Zend\InputFilter\Input($name); $fieldInput->setRequired($isRequired); // handle the filters preferences of the attribute if (!empty($filters)) { // get the filters attached to the attribute $filters = json_decode($filters, true); foreach ($filters as $filter) { // if the filter is an array check it by name if (is_array($filter)) { // If the filter is a ... if ($filter['name'] == "File\\RenameUpload") { // create the filter Zend\InputFilter\FileInput $thefilter = new \Zend\InputFilter\FileInput($filter['options']); // ... but how to attach the new filter to the // chain? $chain = new \Zend\Filter\FilterChain(); // ... in this way it doesn't work!! $chain->attachByName("filerenameupload", $filter['options']); $filterChain->merge($chain); // just for debugging it ... $filtersApplied = $filterChain->getFilters(); // var_dump($filtersApplied->toArray()); } } elseif ($filter == "cleanurl") { // custom filter $filterChain->attach(new \ProductAdmin\Form\Filter\Cleanurl()); } elseif (is_string($filter)) { $filterChain->attachByName($filter); } } } $fieldInput->setFilterChain($filterChain); $inputFilter->add($fieldInput); } $fieldset->setHydrator($customHydrator); $this->add($fieldset); $parentFilter->add($inputFilter, 'attributes'); // thanks to GeeH #zftalk irc $this->setInputFilter($parentFilter); return $this; }