Skip to content

Instantly share code, notes, and snippets.

View bojanz's full-sized avatar

Bojan Zivanovic bojanz

View GitHub Profile
@bojanz
bojanz / extension-patterns.md
Last active January 14, 2023 16:59
Extension patterns: events, tagged services, plugins

This documentation is destined for drupal.org. Created first as a gist to make initial comments easier. Rewrites and clarifications welcome. Code samples are simplified for clarity. Perhaps a bit too much?

When talking about extensibility, there are several distinct use cases:

  1. Reacting to an action that has already happened.

The reaction can be anything; outputting a message, sending an email, modifying a related object, etc. Examples:

  • "A node has been saved"
  • "A product has been added to the cart".

Keybase proof

I hereby claim:

  • I am bojanz on github.
  • I am bojanz (https://keybase.io/bojanz) on keybase.
  • I have a public key whose fingerprint is 44A5 A3CC 1569 CD18 1863 8732 6FC5 55AF 7DB3 3E13

To claim this, I am signing this object:

color pt_black
syntax enable
set nowrap
set wildmenu
set lazyredraw
set showmatch
set incsearch
set hlsearch
@bojanz
bojanz / generate_currencies.php
Last active June 27, 2017 11:48
Script for regenerating Commerce 1.x currencies based on CLDR
<?php
/**
* Regenerates the Commerce 1.x currency list from CLDR.
*
* Assumes the existence of commerce/ and intl/ folders.
* The intl/ folder should contain the commerceguys/intl
* library with the CLDR dataset downloaded via
* scripts/fetch_data.sh
*/
@bojanz
bojanz / CustomerProfile.php
Created December 21, 2018 01:05
Addressbook 2.x UX
<?php
namespace Drupal\commerce_order\Plugin\Commerce\InlineForm;
use Drupal\commerce\EntityHelper;
use Drupal\commerce\Plugin\Commerce\InlineForm\EntityInlineFormBase;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\EntityTypeManagerInterface;
@bojanz
bojanz / responsetest.go
Last active April 29, 2024 12:55
OpenAPI assert helper
package responsetest
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"github.com/getkin/kin-openapi/openapi3"
"github.com/getkin/kin-openapi/openapi3filter"
@bojanz
bojanz / bench_test.go
Created January 21, 2022 17:58
bojanz/currency benchmark
package currency_test
import (
"testing"
"github.com/bojanz/currency"
)
var result currency.Amount
var cmpResult int