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
// Add Headers | |
drupal_add_http_header('Content-Type', 'text/csv'); | |
drupal_add_http_header('Content-Disposition', 'attachment;filename=name_your_file.csv'); | |
$fp = fopen('php://output', 'w'); | |
$first = TRUE; | |
foreach ($results as $line) { | |
//Gets the line so we can flip it and get the column names | |
$column_names = get_object_vars($line); |
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 | |
// Create new vocabulary | |
$vo = new stdClass(); | |
$vo->name = "AAA"; | |
$vo->machine_name = "aaa"; | |
taxonomy_vocabulary_save($vo); | |
// Create field in db | |
if(!db_table_exists('field_data_field_id_on_hub')) { | |
$field = array( |
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
$type = 'billing'; | |
$new_profile = commerce_customer_profile_new($type); | |
$address[] = array( | |
'country' => 'GB', | |
'administrative_area' => 'county', | |
'sub_administrative_area' => '', | |
'locality' => 'London', | |
'dependent_locality' => '', | |
'postal_code' => 'XX 111', |
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
/** | |
* Allow Masquerade role users to impersonate Role1 or Role2 accounts. | |
* Note that these users will never see their own account for editing or otherwise. | |
* As soon as they log in they will act on behalf of the account | |
* that we specify they can masquerade as. | |
* | |
* Only administrators should be able to control the list of users | |
* allowed to masquerade. | |
* | |
* @param $edit |
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
insurec.services.yml | |
services: | |
insurec.event_subscriber: | |
class: Drupal\insurec\EventSubscriber\InsurecSubscriber | |
tags: | |
- { name: 'event_subscriber' } | |
insurec/src/EventSubscriber/InsurecSubscriber.php |
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 | |
/** | |
* https://www.movable-type.co.uk/scripts/latlong.html | |
* @param $lat1 | |
* @param $lat2 | |
* @param $lon1 | |
* @param $lon2 | |
* | |
* @return float|int |
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 | |
/** | |
* @param $postcode | |
* | |
* @return array | |
*/ | |
function getGeoLocationFromPostcode($postcode) { | |
$geo = []; | |
$url = "https://api.postcodes.io/postcodes/" . $postcode; |
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 | |
$dates = [ | |
"12/01/2021", | |
"12/05/2021", | |
"12/09/2021", | |
"12/10/2021", | |
"12/11/2021", | |
"12/15/2021", | |
"12/10/2021", |
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 | |
$PLAYLIST_URL = 'http://www.bbc.co.uk/radio/listen/live/r1.pls'; | |
set_time_limit(5); | |
// Fetch and parse a .pls playlist file | |
// @returns an array of URLs in the playlist | |
function readPlaylist($url) |
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 Contains \Drupal\custom_module\Plugin\Field\FieldType\RoleRate | |
*/ | |
namespace Drupal\custom_module\Plugin\Field\FieldType; | |
use Drupal\Core\Field\FieldStorageDefinitionInterface; | |
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; | |
use Drupal\Core\Form\FormStateInterface; |
OlderNewer