/** * Test base field saving. * * @dataProvider fieldDataProvider */ public function testFieldSaving($field_name, $vocabulary_name) { $service = multisite_config_service('field'); $service->createBaseField($field_name, 'taxonomy_term_reference')->setVocabulary($vocabulary_name)->save(); $field = field_info_field($field_name); $this->assertEquals('taxonomy_term_reference', $field['type']); $this->assertEquals($field_name, $field['field_name']); $this->assertEquals('taxonomy', $field['module']); $this->assertEquals(1, $field['cardinality']); $this->assertEquals($vocabulary_name, $field['settings']['allowed_values'][0]['vocabulary']); field_delete_field($field_name); }
/** * Test base field saving. * * @dataProvider fieldDataProvider */ public function testFieldSaving($field_name, $type, $module) { $handler = new DefaultFieldHandler($field_name, $type); $field = $handler->save(); $this->assertEquals($type, $field['type']); $this->assertEquals($field_name, $field['field_name']); $this->assertEquals($module, $field['module']); $this->assertEquals(FALSE, $field['locked']); $this->assertEquals(1, $field['active']); $this->assertEquals(0, $field['deleted']); $this->assertEquals(1, $field['cardinality']); $this->assertEquals(FALSE, $field['translatable']); field_delete_field($field_name); }
/** * Test instance field creation. * * @dataProvider fieldDataProvider */ public function testFieldInstanceCreation($field_name, $type, $label, $widget, $default_formatter, $teaser_formatter) { $base_handler = new DefaultBaseFieldHandler($field_name, $type); $base_handler->save(); $handler = new DefaultInstanceFieldHandler($field_name, 'node', self::CONTENT_TYPE_WITHOUT_FIELDS); $handler->label($label)->widget($widget)->display('default', $default_formatter, 'inline')->display('teaser', $teaser_formatter); $instance = $handler->getField(); $handler->save(); $saved_instance = field_info_instance('node', $field_name, self::CONTENT_TYPE_WITHOUT_FIELDS); $this->assertEquals($label, $saved_instance['label']); $this->assertEquals($widget, $saved_instance['widget']['type']); $this->assertEquals($default_formatter, $saved_instance['display']['default']['type']); $this->assertEquals($teaser_formatter, $saved_instance['display']['teaser']['type']); field_delete_field($field_name); }
function delete_extra_fields() { drush_log('Dropping field: field_flickr_tags', 'ok'); field_delete_field('field_flickr_tags'); safe_delete_field_instance('field_related_oshwiki_articles', 'highlight'); safe_delete_field_instance('field_related_oshwiki_articles', 'news'); safe_delete_field_instance('field_file', 'seminar'); safe_delete_field_instance('field_author', 'guideline'); safe_delete_field_instance('field_author', 'directive'); // CW-415 extra fields from seminars safe_delete_field_instance('field_summary', 'seminar'); drush_log('Dropping extra fields from seminars', 'ok'); field_delete_field('field_sem_date_to_be_confirmed'); field_delete_field('field_seminar_attendees'); field_delete_field('field_seminar_event_url'); field_delete_field('field_seminar_contact_name'); field_delete_field('field_seminar_contact_phone'); field_delete_field('field_seminar_contact_email'); field_delete_field('field_seminar_attachment'); field_delete_field('field_seminar_conclusions'); field_delete_field('field_seminar_further_actions'); field_delete_field('field_seminar_show_roster_hour'); safe_delete_field_instance('field_image', 'seminar'); }
<?php // Delete fields. $fields_to_delete = array('field_one', 'field_two', 'field_three'); foreach ($fields_to_delete as $field_name) { field_delete_field($field_name); } // Increase batch size for safe measure. field_purge_batch(10); // Confirm the fields have been removed from field_config and field_config_instance tables in database.
public function deleteExistingObject(NodeInterface $node, Context $context, $dirtyAllowed = false) { /* @var $node FieldNode */ $name = $node->getName(); $field = $this->getExistingObject($node, $context); if (!$field) { $context->logWarning(sprintf("%s: does not exists", $node->getPath())); return false; } $nameList = array(); foreach ($this->getInstances($name) as $instance) { $nameList[] = $this->instanceLoader->getInstanceIdFromNode($instance['entity_type'], $instance['bundle'], $name); } if (!empty($nameList)) { foreach ($nameList as $name) { $this->instanceLoader->deleteExistingObject($node, $context); } } field_delete_field($name); }
<?php /** * @file * Author: Cristian Romanescu <cristi _at_ eaudeweb dot ro> * Created: 201411011810 */ // Will be recreated by feature-revert with new data type. drush_log('Dropping field: field_pr_notes_to_editor (will be recreated during feature-revert)', 'ok'); field_delete_field('field_pr_notes_to_editor'); drush_log('Creating search server: solr_server will be used by search_api_solr module', 'ok'); osha_configure_solr(); /********************************************************************** SLICK */ /** * Configure the apachesolr and search_api_solr modules with proper settings. */ function osha_configure_solr() { $config_file = sprintf('%s/../../conf/config.json', dirname(__FILE__)); if (!is_readable($config_file)) { drupal_set_message("Cannot read configuration file!", 'warning'); return; } $cfg = json_decode(file_get_contents($config_file), TRUE); if (empty($cfg)) { drupal_set_message('Configuration file was empty, nothing to do here', 'warning'); return; } $cfg = array_merge(array('name' => 'Solr server', 'enabled' => 1, 'description' => 'Search server', 'scheme' => 'http', 'host' => 'localhost', 'port' => '8983', 'path' => '/solr', 'http_user' => '', 'http_password' => '', 'excerpt' => NULL, 'retrieve_data' => NULL, 'highlight_data' => NULL, 'skip_schema_check' => NULL, 'solr_version' => '', 'http_method' => 'AUTO'), $cfg['solr_server']); if (module_exists('search_api_solr') && module_load_include('inc', 'search_api', 'search_api.admin')) { drupal_set_message('Configuring search_api_solr ...');
/** * @AfterScenario @remove_ODFE */ public function removeODFE(AfterScenarioScope $event) { // Disable 'open_data_federal_extras' module. module_disable(array('open_data_federal_extras')); // Remove ODFE fields. field_delete_field('field_odfe_bureau_code'); field_delete_field('field_odfe_data_quality'); field_delete_field('field_odfe_investment_uii'); field_delete_field('field_odfe_program_code'); field_delete_field('field_odfe_system_of_records'); }
<?php // Remove 'video' field, comment out to run field_delete_field('field_featured_'); field_purge_batch(1);
<?php /* Add new stuff for deployment of sprint-4 branch here. To avoid conflicts, add them after your name * Also include the ticket number, see example below */ // andrei // CW-526 drush_log('Dropping field: field_related_man_pubs', 'ok'); field_delete_field('field_related_man_pubs'); drush_log('Dropping field: field_workflow_status', 'ok'); field_delete_field('field_workflow_status'); drush_log('Dropping field: field_needs_retranslation', 'ok'); field_delete_field('field_needs_retranslation'); // cristi // dragos drush_log('Dropping field: field_pr_related_links', 'ok'); field_delete_field('field_pr_related_links'); drush_log('Dropping field: field_pr_release_date', 'ok'); field_delete_field('field_pr_release_date'); // claudia // radu
public function afterScenario($event) { foreach ($this->users as $user) { $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'commerce_order')->propertyCondition('uid', $user->uid); $result = $query->execute(); if (isset($result['commerce_order'])) { $order_ids = array_keys($result['commerce_order']); commerce_order_delete_multiple($order_ids); } $query2 = new EntityFieldQuery(); $query2->entityCondition('entity_type', 'rooms_booking')->propertyCondition('uid', $user->uid); $result = $query2->execute(); if (isset($result['rooms_booking'])) { $booking_ids = array_keys($result['rooms_booking']); rooms_booking_delete_multiple($booking_ids); } } parent::afterScenario($event); if (!empty($this->units)) { foreach ($this->units as $unit) { $unit->delete(); } } if (!empty($this->unitTypes)) { foreach ($this->unitTypes as $unit_type) { $unit_type->delete(); } } if (!empty($this->bookingTypes)) { foreach ($this->bookingTypes as $booking_type) { $booking_type->delete(); } } if (!empty($this->bookings)) { rooms_booking_delete_multiple($this->bookings); } if (!empty($this->customerProfiles)) { commerce_customer_profile_delete_multiple($this->customerProfiles); db_delete('rooms_customers')->condition('commerce_customer_id', $this->customerProfiles)->execute(); } if (!empty($this->products)) { $product_ids = array(); foreach ($this->products as $product) { $product_ids[] = $product->product_id; } commerce_product_delete_multiple($product_ids); } foreach ($this->content_types as $content_type) { node_type_delete($content_type); } foreach ($this->fields as $field) { field_delete_field($field); } }
/** * Revert to previous settings after scenario execution. * * @AfterScenario */ public function removeFields() { // Remove the fields. foreach ($this->fields as $field) { field_delete_field($field['field_name']); } field_purge_batch(100); }