Skip to content

Instantly share code, notes, and snippets.

View steveoliver's full-sized avatar

Steve Oliver steveoliver

View GitHub Profile
@steveoliver
steveoliver / CartManagerTest.php
Last active March 7, 2018 16:29
Testing an event subscriber
<?php
namespace Drupal\Tests\commerce_cart\Kernel;
use Drupal\commerce_order\Entity\OrderItem;
use Drupal\commerce_price\Price;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\commerce_product\Entity\ProductVariation;
use Drupal\Tests\commerce\Kernel\CommerceKernelTestBase;
@steveoliver
steveoliver / tablesizes.sql
Created July 25, 2017 00:16
get db table sizes
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
WHERE table_schema = "DB_NAME"
ORDER BY (data_length + index_length) DESC;
@steveoliver
steveoliver / composer--bad-patch.json
Last active May 25, 2017 02:21
drupal commerce composer patched project cannot composer install
{
"name": "drupalcommerce/project-base",
"description": "Commerce 2.x project template",
"type": "project",
"license": "GPL-2.0+",
"authors": [
{
"name": "",
"role": ""
}
@steveoliver
steveoliver / Onsite.php
Created September 29, 2016 15:20
Drupal Commerce 2.x Onsite payment gateway token register method
<?php
// Drupal Commerce 2.x Onsite payment method
// ...
/**
* {@inheritdoc}
*/
public function createPaymentMethod(PaymentMethodInterface $payment_method, array $payment_details) {
$required_keys = [
@steveoliver
steveoliver / observations.md
Last active July 18, 2016 19:33
Field Collection database/uuid issue(s) (nested field collections), Drupal 8

database observations

  • field_collection_item__field_CHILDCOLLECTION_X tables exist for all child field collections EXCEPT the one without the UUID
  • field_collection_item__668c612c1b table exists for the child field collection under consideration (will call it field_CHILDCOLLECTION_Y). ... It has the same structure as the other tables with valid data for field instances.

configuration

  • field_collection config item 'field_CHILDCOLLECTION_Y' has null uuid value.

drupal behaviour

  • DELETE field_CHILDCOLLECTION_X1: OK.
  • DELETE field_CHILDCOLLECTION_X2: OK.
@steveoliver
steveoliver / composer.json
Created January 30, 2016 00:01
Getting Drupal 8 project to build from composer.json instead of project.make.yml file
{
"name": "my/project",
"description": "My platform.sh Drupal 8 / Composer project",
"type": "project",
"license": "GPL-2.0+",
"authors": [
{
"name": "",
"role": ""
}
@steveoliver
steveoliver / README.md
Last active March 10, 2016 19:00
Adding an SSL domain to platform.sh with GoDaddy certificate and intermediate chain bundle
@steveoliver
steveoliver / gist:7469874
Created November 14, 2013 16:33
Next buttons first
diff --git a/includes/wizard.inc b/includes/wizard.inc
index 6f5d794..a3227b5 100644
--- a/includes/wizard.inc
+++ b/includes/wizard.inc
@@ -291,13 +291,25 @@ function ctools_wizard_wrapper($form, &$form_state) {
$button_attributes = array('class' => array('ctools-use-ajax'));
}
+ // If there is a next form, place the next button.
+ if (isset($form_state['next']) || !empty($form_info['free trail'])) {
@steveoliver
steveoliver / common.inc
Created October 16, 2013 03:51
has_render_content() function
/**
* Checks that a render array has content that can be rendered.
*
* @param $element
* The element to check.
*
* @param $offset
* The key of the child to check.
*
* @return bool
@steveoliver
steveoliver / theme.inc
Created October 16, 2013 03:50
theme.inc::template_preprocess_html checking visibilitiy of regions using has_render_content().
// Add information about the number of sidebars.
if (has_render_content($variables['page'], 'sidebar_first') && has_render_content($variables['page'], 'sidebar_second')) {
$variables['attributes']['class'][] = 'two-sidebars';
}
elseif (has_render_content($variables['page'], 'sidebar_first')) {
$variables['attributes']['class'][] = 'one-sidebar';
$variables['attributes']['class'][] = 'sidebar-first';
}
elseif (has_render_content($variables['page'], 'sidebar_second')) {
$variables['attributes']['class'][] = 'one-sidebar';