Skip to content

Instantly share code, notes, and snippets.

View mglaman's full-sized avatar

Matt Glaman mglaman

View GitHub Profile
<?php
use PHPUnit\Framework\TestCase;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Driver\Selector;
use PHPUnit\TextUI\XmlConfiguration\Loader;
use PHPUnit\TextUI\XmlConfiguration\PhpHandler;
if (!defined('STDOUT')) {
// php://stdout does not obey output buffering. Any output would break
// unserialization of child process results in the parent process.
@mglaman
mglaman / TrimMiddleware.php
Created January 10, 2023 15:23
TrimMiddleware for Drupal
<?php
declare(strict_types=1);
namespace Drupal\mymodule\StackMiddleware;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@mglaman
mglaman / helm.yaml
Created January 4, 2023 21:35
ChaptGPT generated Helm chart
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.deployment.name }}
labels:
app: {{ .Values.deployment.name }}
spec:
replicas: {{ .Values.deployment.replicas }}
selector:
matchLabels:
@mglaman
mglaman / bootstrap.php
Created December 24, 2021 19:52
in memory bootstrapped Drupal
<?php declare(strict_types=1);
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
return;
}
$autoloader = require __DIR__ . '/vendor/autoload.php';
@mglaman
mglaman / foo
Created September 16, 2021 03:05
This post links my 3Box profile to my Github account! Web3 social profiles by 3Box.
✅ did:3:bafyreihndmp3jzb3gm7oqw2vcoqnsv3hmt5redjre24o55btt5a4pwg3ka ✅
Create your profile today to start building social connection and trust online at https://3Box.io/
@mglaman
mglaman / cypress.yml
Created July 11, 2021 21:40
GitHub Actions running Cypress within Lando
name: Cypress
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
@mglaman
mglaman / phpstan.neon
Last active November 24, 2023 10:10
PHPStan configuration for Drupal 7 – https://youtu.be/9HYwq5jq4Sk
parameters:
level: 0
excludePaths:
- '*.api.php'
- '*.database.php'
scanFiles:
- web/authorize.php
- web/cron.php
- web/index.php
- web/update.php
@mglaman
mglaman / phpunit.xml
Last active June 15, 2023 13:38
My Drupal project phpunit.xml configuration
<?xml version="1.0" encoding="UTF-8"?>
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit bootstrap="web/core/tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
@mglaman
mglaman / commerce-modules-d7.json
Created May 22, 2020 23:24
Drupal Commerce Ecosystem
[
{
"nid": "3125281",
"machine_name": "commerce_stripe_ideal",
"url": "https:\/\/www.drupal.org\/project\/commerce_stripe_ideal"
},
{
"nid": "3120253",
"machine_name": "commerce_ship_to_pssc",
"url": "https:\/\/www.drupal.org\/project\/commerce_ship_to_pssc"
@mglaman
mglaman / OrderEventsSubscriber.php
Created August 13, 2019 17:10
Destructable performance wins
<?php
namespace Drupal\commerce_stripe\EventSubscriber;
use Drupal\commerce_order\Event\OrderEvent;
use Drupal\commerce_order\Event\OrderEvents;
use Drupal\commerce_price\Calculator;
use Drupal\commerce_price\Price;
use Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\StripeInterface;
use Drupal\Core\DestructableInterface;