Skip to content

Instantly share code, notes, and snippets.

View omahm's full-sized avatar

Steve Cousins omahm

View GitHub Profile
@jacerider
jacerider / D8 | Programmatically Create Field.md
Last active February 15, 2024 01:37
Programmatically create a field in Drupal 8.
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;

$bundles = ['user'];

$fields['user_picture'] = [
  'type' => 'image',
  'entity_type' => 'user',
  'bundle' => 'user',
@thepsion5
thepsion5 / EloquentFooRepository.php
Created May 2, 2014 15:09
Example implementation of a Eloquent-based repository that provides a fluent interface for sorting and pagination without exposing the underlying model API.
<?php
class EloquenFooRepository
{
/**
* The base eloquent model
* @var Eloquent
*/
protected $model;