Skip to content

Instantly share code, notes, and snippets.

View flocondetoile's full-sized avatar

Flocon de toile flocondetoile

View GitHub Profile
$build['quickview'] = [
'#type' => 'link',
'#url' => Url::fromRoute('mymodule.product_quickview', ['commerce_product' => $entity->id()]),
'#title' => $this->t('Quick view'),
'#attributes' => [
'class' => ['use-ajax', 'button', 'button--small', 'button--check-stock'],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'dialogClass' => 'ui-dialog--wide ui-dialog--centered-title ui-dialog--product-stock-levels',
'width' => 1000,
@flocondetoile
flocondetoile / ICS.php
Created October 1, 2017 20:33 — forked from jakebellacera/ICS.php
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* ICS.php
* =======
* Use this class to create an .ics file.
*
* Usage
* -----
* Basic usage - generate ics file contents (see below for available properties):
@flocondetoile
flocondetoile / NodeIndexNid.php
Created September 29, 2017 14:04 — forked from StryKaizer/NodeIndexNid.php
Exposed filters for entity references -> nodes. Port from TaxonomyIndexTid.php
<?php
namespace Drupal\yourmodule\Plugin\views\filter;
use Drupal\Core\Entity\Element\EntityAutocomplete;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\Entity\Node;
use Drupal\node\NodeStorageInterface;
use Drupal\views\ViewExecutable;
/**
* Implements hook_query_TAG_alter().
*/
function micro_page_query_node_access_alter(\Drupal\Core\Database\Query\SelectInterface $query) {
// Read meta-data from query, if provided.
if (!($account = $query->getMetaData('account'))) {
$account = \Drupal::currentUser();
}
if ($account->hasPermission('bypass node access') || $account->hasPermission('link to any page')) {
return;
/**
* Massages the message body into the format expected for rendering.
*
* @param array $message
* The message.
*
* @return array
*/
public function cleanBody(array $message) {
// Get default mail line endings and merge all lines in the e-mail body
/**
* {@inheritdoc}
*/
public function blockForm($form, FormStateInterface $form_state) {
$form['header'] = array(
'#type' => 'fieldset',
'#title' => t('Header'),
);
$form['header']['subtitle'] = array(
'#type' => 'textfield',
<div class="contact-form">
<h3><?php print t('Or by email'); ?></h3>
<?php print '<form id="'.$form['#id'].'" accept-charset="UTF-8" method="'.$form['#method'].'" action="'.$form['#action'].'">'; ?>
<?php print render($form['form_id']); ?>
<?php print drupal_render($form['form_build_id']);?>
<?php print render($form['form_token']); ?>
<div class="clearfix">
<?php print drupal_render($form['gender']); ?>
</div>
-
route_name: node.add
route_params:
entity_type: article
/**
* Implements hook_entity_base_field_info().
*
* - Provides a base field that displays the current workflow state on nodes.
* This field is intended to be used to expose this information.
*/
function state_machine_workflow_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = [];
/** @var \Drupal\state_machine_workflow\WorkflowHelper $workflowHelper */