public function unhandleEntity(array $metadata = array()) { if (!empty($metadata['webform_validation']['processed'])) { $unresolver = new Unresolver($this->original_entity, false); $unresolver->unresolveDependencies($metadata['webform_validation']['rules'], 'webform_validation'); $new_webform_validation = (array) $unresolver->unresolvedDefinition(); // Delete the existing validation fields. webform_validation_node_delete($this->original_entity->definition); // Add the new validation fields. foreach ($new_webform_validation as $rule) { unset($rule['ruleid']); $rule['action'] = 'add'; $rule['nid'] = $this->original_entity->id(); $rule['rule_components'] = $rule['components']; webform_validation_rule_save($rule); } } }
public function unhandleEntity(array $metadata = array()) { if (!empty($metadata['sitemap_definition'])) { // Unresolve the sitemap information. $unresolver = new Unresolver($this->original_entity, false); $unresolver->unresolveDependencies($metadata['sitemap_definition'], 'xmlsitemap'); $new_sitemap = (array) $unresolver->unresolvedDefinition(); unset($new_sitemap['id']); unset($new_sitemap['changefreq']); unset($new_sitemap['changecount']); unset($new_sitemap['lastmod']); // Get the existing sitemap link. $existing = xmlsitemap_link_load($this->original_entity->type(), $this->original_entity->id()); // Overwrite the values in the existing if one already exists. if ($existing) { xmlsitemap_link_save(array_replace($existing, $new_sitemap)); } else { xmlsitemap_link_save($new_sitemap); } } }