This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Delete a field instance. | |
*/ | |
function mymodule_update_7001() { | |
$instance = field_info_instance('entity_type', 'field_name', 'bundle'); | |
if (!empty($instance)) { | |
field_delete_instance($instance, FALSE); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Disable the media browser view. | |
*/ | |
function mymodule_update_7001() { | |
$view = views_get_view('media_default'); // media_default is the machine name of the view. | |
if (!empty($view)) { | |
ctools_include('export'); | |
ctools_export_crud_set_status('views_view', $view, TRUE); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Move all data in one field to another. | |
* In the example below we replace a multi cardinality field (field_old_field) | |
* with a single cardinality field (field_new_field). | |
* The data in the first element of the old field becomes the only data in the new field. | |
* | |
* @requires entity module | |
*/ | |
function mymodule_update_7001(&$sandbox) { | |
if (!isset($sandbox['progress'])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_form_FORM_ID_alter(). | |
*/ | |
function mymodule_form_file_entity_add_upload_alter(&$form) { | |
_mymodule_media_form_alter($form); | |
} | |
/** | |
* Implements hook_form_FORM_ID_alter(). | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Rebuild node access permissions. | |
* node_access_rebuild(TRUE) claims to be able to do this in batch mode but all it does is set a | |
* batch. There is no way to process the batch from within an update hook. You could do it using | |
* a separate drush command but if you only have access to run updb on your production env | |
* then you need to do all the processing from within the update hook. This gem allows complete | |
* safe permission rebuild, batched, from within a single update hook. | |
*/ | |
function mymodule_update_7001(&$sandbox) { | |
_node_access_rebuild_batch_operation($sandbox); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Enable modules. | |
* Normally we'd use master module for this but sometimes you can't run anything other than updb in production. | |
*/ | |
function mymodule_update_7001(&$sandbox) { | |
$modules = array( | |
'mymodule_one', | |
'mymodule_two', | |
'mymodule_three', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @When I click :link_text in table row containing :text | |
*/ | |
public function iClickOperationLinkInTableRowWithText($link_text, $text) { | |
$session = $this->getSession(); | |
$el = $session->getPage()->find('xpath', "//td[contains(., '{$text}')]"); | |
if (empty($el)) { | |
throw new ExpectationException(t('No such text in table - @text', array( | |
'@text' => $text, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* | |
* Add this code in a file features/bootstrap/PersonaContext.php | |
* | |
* Include the PersonaContext in behat.yml like this ... | |
* | |
* default: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_views_query_alter(). | |
* | |
* This is a view of users and the view has a relationship to node and a contextual filter. | |
* There is an entity reference field on the user pointing to the node called field_node_entity_reference. | |
* | |
* By placing the restiction on the join and not requiring the relationship means we can additional exposed filters | |
* such as where node.nid is empty (users who do not link to the node). | |
*/ | |
function mymodule_views_query_alter(&$view, &$query) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_menu_alter(). | |
*/ | |
function mymodule_menu_alter(&$items) { | |
if (isset($items['user/%user'])) { | |
// Turn user/%user into an edit form callback rather than view. | |
$items['user/%user']['page callback'] = 'drupal_get_form'; | |
$items['user/%user']['page arguments'] = array('user_profile_form', 1); | |
$items['user/%user']['access callback'] = 'user_edit_access'; | |
$items['user/%user']['access arguments'] = array(1); |
OlderNewer