Skip to content

Instantly share code, notes, and snippets.

@mohit-rocks
mohit-rocks / ApiConsumer.php
Last active October 9, 2020 11:29
Creating Integrations Plugin in Mautic - Managing third-party Authentications in Mautic Plugin for Integrations
class ApiConsumer
{
// Other variables, methods declaration.
// Full code: https://github.com/mohit-rocks/HelloWorldBundle/blob/master/Connection/ApiConsumer.php
/**
* Fetch the data from API endpoint.
*/
public function getSubscribers()
{
$users = $this->client->get('v2/api/fetch-dummy-users');
@mohit-rocks
mohit-rocks / lando.yml-Step-1
Last active June 14, 2020 05:48
Local Mautic Development using Lando
name: mautic
recipe: lamp
config:
webroot: .
@mohit-rocks
mohit-rocks / import.php
Created December 4, 2018 11:56 — forked from crittermike/import.php
Importing Drupal 8 config programmatically
<?php
// Import arbitrary config from a variable.
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html');
$config->setData($data)->save();
// Or, re-import the default config for a module or profile, etc.
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module');
// Or, import YAML config an arbitrary directory.
@mohit-rocks
mohit-rocks / unoconv_example.module
Last active May 16, 2018 14:30
Example hook for how to use Unoconv service. https://drupal.org/project/unoconv_service
<?php
/**
* Implements hook_ENTITY_TYPE_presave().
*/
function unoconv_example_media_presave(EntityInterface $entity) {
$original_file_id = $entity->get('field_document_file')->getValue();
/** @var \Drupal\file\Entity\File $file */
$file = File::load($original_file_id[0]['target_id']);
@mohit-rocks
mohit-rocks / UnoconvTranscode.php
Created May 16, 2018 14:26
Sample implementation for Transcode method.
/**
* {@inheritdoc}
*/
public function transcode($source_path, $destination_path, $destination_uri) {
$unoconv_config = $this->configFactory->get('unoconv_service.unoconvconfig');
try {
$unoconv = Unoconv::create(array(
'timeout' => $unoconv_config->get('timeout'),
'unoconv.binaries' => $unoconv_config->get('binaries_path'),
));
@mohit-rocks
mohit-rocks / node_page.yml
Last active February 14, 2018 03:58
Migration template : Specify custom ID Map Plugin (Drupal 8)
id: node_page
label: "Page Content"
migration_tags:
- content_import
# Notice ID Map plugin here.
idMap:
plugin: content_update
# ID Map plguin declaration ends.
source:
plugin: csv
@mohit-rocks
mohit-rocks / ContentUpdate.php
Created February 14, 2018 03:40
ID Map plugin for migration (Drupal 8)
<?php
namespace Drupal\my_module\Plugin\migrate\id_map;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\migrate\id_map\Sql;
/**
* Defines the sql based ID map implementation.
*
@mohit-rocks
mohit-rocks / FallbackAliasStorage.php
Created January 26, 2018 04:49
Multilingual URL Alias Fallback
<?php
namespace Drupal\my_module;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Path\AliasStorageInterface;
class FallbackAliasStorage implements AliasStorageInterface {
@mohit-rocks
mohit-rocks / gist:bed1fc9f2d2c6213cebd7c9a0b18ef9c
Created August 3, 2016 10:06 — forked from mitchellh/gist:1277049
Configure Vagrant VM to use Host DNS for VPN
Vagrant::Config.run do |config|
# ...
config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
@mohit-rocks
mohit-rocks / gist:7d43ec7585b89a00bf4c
Created November 9, 2015 12:58 — forked from robertmarsal/gist:9feaa9150926efa4175a
Install f.lux on Ubuntu 14.10
sudo apt-get install python-glade2 python-appindicator
git clone https://github.com/Kilian/f.lux-indicator-applet.git
cd f.lux-indicator-applet
chmod +x setup.py
sudo ./setup.py install
fluxgui