/** * @dataProvider provideModuleInstances */ public function testGetFieldsMethodFiltered(IModule $module) { $fields = $module->getFields(array('headline', 'clickCount')); $this->assertInstanceOf('Dat0r\\Core\\Field\\FieldCollection', $fields); $this->assertEquals(2, $fields->getSize()); $this->assertInstanceOf('Dat0r\\Core\\Field\\TextField', $fields->get('headline')); $this->assertInstanceOf('Dat0r\\Core\\Field\\IntegerField', $fields->get('clickCount')); }
/** * Hydrates the given set of values into the current IDocument instance. * * @param array $values */ protected function hydrate(array $values = array(), $apply_defaults = false) { $non_hydrated_fields = array(); if (!empty($values)) { foreach ($this->module->getFields() as $fieldname => $field) { if (array_key_exists($fieldname, $values)) { $this->setValue($field->getName(), $values[$fieldname]); } else { $non_hydrated_fields[] = $field; } } } else { foreach ($this->module->getFields() as $fieldname => $field) { $non_hydrated_fields[] = $field; } } if ($apply_defaults) { foreach ($non_hydrated_fields as $field) { $this->setValue($field->getName(), $field->getDefaultValue()); } } }