Skip to content

Instantly share code, notes, and snippets.

@fazni
fazni / d8_reset.sh
Created July 21, 2017 16:52 — forked from cam8001/d8_reset.sh
A reset & reinstall script for Drupal 8 core development.
#!/bin/sh
# Removes an existing Drupal 8 install, then install again.
# Requires Drush 7 - https://github.com/drush-ops/drush
#
# Run this script from the docroot of a Drupal 8 checkout.
# Installs to mysql://localhost/drupal, user 1 user/pass is admin/admin.
if [ ! -e ./core/core.services.yml ]
then
@fazni
fazni / __INDEX.txt
Created August 22, 2017 15:01 — forked from facine/__INDEX.txt
Drupal 8 - Examples
# Taxonomy terms:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php
# Menu links:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_menu_link-php
# File items:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_file-php
# Nodes:
@fazni
fazni / drupal-image.php
Created September 3, 2017 10:16 — forked from colorfield/drupal-image.php
Drupal 7 and 8 theme image
<?php
/**
* Drupal 7
*/
$fid = 1;
$uri = file_load($fid)->uri; // or fetched via the uri property of a field
$image_url = image_style_url('thumbnail', $uri);
$image = theme_image(array(
'path' => $image_url,
@fazni
fazni / README.md
Created November 29, 2017 14:25 — forked from WengerK/README.md
Drupal 8  —  Differences between Configuration API & State API

Article Ressources - Drupal 8  —  Differences between Configuration API & State API

This is the Gist repository for my article Drupal 8  —  Differences between Configuration API & State API.

Be aware that this article has been wrote for the Blog of Antistatique — Web Agency in Lausanne, Switzerland. A place where I work as Full Stack Web Developer.

Feel free to read it the full article on Medium or check it out on Antistatique.

@fazni
fazni / php7_2_upgrade.sh
Last active September 12, 2019 09:11
Installing PHP 7.2 Ubuntu 14.04, 16.04, 17.04, & 17.10
#!/bin/sh
# Installing PHP 7.2
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2-cli
sudo apt-get install php7.2-mysql php7.2-curl php7.2-json php7.2-cgi php7.2-xsl
# For developer drupal 8 apply patch https://www.drupal.org/files/issues/php_7_2_fatal_error-2894884-3.patch
@fazni
fazni / drupal8-links.php
Created February 8, 2018 14:56 — forked from colorfield/drupal8-links.php
Drupal 8 links, or where is my l() function
@fazni
fazni / url.php
Created March 19, 2018 13:06 — forked from webflo/url.php
Create link with attributes in Drupal 8
<?php
$url = Url::fromRoute('node.add', array('node_type' => $content_type));
$url->setOption('query', \Drupal::destination()->getAsArray(),);
$link = [
'#type' => 'link',
'#title' => t('Add !content_type content', array('!content_type' => $content_type)),
'#url' => $url,
'#attributes' => [
@fazni
fazni / SettingUpMailcatcher.md
Last active May 23, 2018 10:27
Setting Up Mailcatcher

1 - Ruby Installation
sudo apt-get install ruby ruby-dev rubygems libsqlite3-dev
2 - Installing MailCatcher sudo gem install mailcatcher
3 - Getting started
[fazni]-[~] "Terminal" $ mailcatcher Starting MailCatcher
==> smtp://127.0.0.1:1025
==> http://127.0.0.1:1080

@fazni
fazni / drupal-PSA-003-check.sh
Created April 25, 2018 16:47 — forked from jerbob92/drupal-PSA-003-check.sh
Check whether Drupal 7.59 and 8.5.3 are released
#!/bin/sh
url="https://ftp.drupal.org/files/projects/drupal-7.59.zip";
if curl --output /dev/null --silent --head --fail "$url"; then
echo "URL exists: $url";
else
echo "URL does not exist: $url";
fi;
url="https://ftp.drupal.org/files/projects/drupal-8.5.3.zip";
@fazni
fazni / AddAnotherItem.php
Created December 2, 2018 15:06 — forked from leymannx/AddAnotherItem.php
Drupal 8 Ajax Form Add Item Example
<?php
/**
* @file
* Contains \Drupal\hello_world\Form\AddAnotherItem.
*/
namespace Drupal\hello_world\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;