Skip to content

Instantly share code, notes, and snippets.

@nikathone
nikathone / README.md
Last active April 16, 2020 18:23
Orlando Cambridge docker compose

Orlando Cambridge Docker compose

All the commands below assume you are on mac or linux distribution OS.

0. Prerequisites

1. First time user

@nikathone
nikathone / settings.php
Created February 26, 2020 20:12
Settings.php
<?php
$databases['default']['default'] = [
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USER'),
'password' => getenv('DB_PASSWORD'),
'host' => getenv('DB_HOST'),
'port' => getenv('DB_PORT'),
'driver' => 'mysql',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
@nikathone
nikathone / DynamicDataTableForm.php
Last active January 22, 2020 00:59
Drupal table with ajax submit button in the header
<?php
namespace Drupal\hello_world\Form;
use Drupal\Component\Utility\Environment;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
@nikathone
nikathone / ReportOrderToAdministrate.php
Last active January 8, 2019 15:14
Report drupal commerce order to administrate
<?php
namespace Drupal\administrate_esr;
use Drupal\address\AddressInterface;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Driver\Exception\Exception;
@nikathone
nikathone / RecurringOrderManager.php
Last active November 21, 2019 22:15
Customization for revoking a subscription/Commerce recurring
<?php
namespace Drupal\custom_commerce_recurring;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\commerce_recurring\RecurringOrderManager as BaseRecurringOrderManager;
use Drupal\commerce_recurring\RecurringOrderManagerInterface;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
@nikathone
nikathone / CurrentStoreContext.php
Last active October 26, 2017 20:41
Current store context.
<?php
namespace Drupal\customize_commerce\ContextProvider;
use Drupal\commerce_store\CurrentStoreInterface;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
@nikathone
nikathone / UserResetLoginSubscriber.php
Created February 14, 2017 20:32
User reset login subscriber and redirect alter example.
<?php
namespace Drupal\wh_signup\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
@nikathone
nikathone / moving2composerworkflow.md
Last active March 6, 2019 19:21
Moving an existing Drupal site to composer workflow

Old site:
drush sql-dump to backup database
New site:
composer create-project drupal-composer/drupal-project:8.x-dev newsitefolder --prefer-dist --no-progress --no-interaction
cd newsitefolder
composer require <all of your modules here, as drupal/whatever>

If running SELinux on CentOS, on others it may be a different context
chcon -R -t httpd_sys_content_rw_t web
$ pwd