Skip to content

Instantly share code, notes, and snippets.

Aaron Crosman acrosman

Block or report user

Report or block acrosman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@acrosman
acrosman / JsonController.php
Created May 6, 2017
A simple example Drupal Controller with an uncached JsonResponse
View JsonController.php
<?php
namespace Drupal\example\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
class ExampleController extends ControllerBase {
public function getJson(Request $request) {
View custom_blocks_copyright.html.twig
View custom_blocks.module
<?php
/**
* Implements hook_theme().
*/
function custom_blocks_theme($existing, $type, $theme, $path) {
return [
'custom_blocks_copyright' => [
'variables' => [
View CopyrightBlock.php
<?php
namespace Drupal\custom_blocks\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a 'CopyrightBlock' block.
*
* @Block(
View ExampleController.php
<?php
public function runTask($task_id, $site_name) {
$plugin = $this->pluginManagerService->createInstance($task_id);
$site = Site::load($site_name);
$status = $plugin->run($site);
if ($status == 'Success') {
$output = $plugin->getTaskOutput();
View RunCron.php
<?php
namespace Drupal\sitemanager\Plugin\TaskPlugin;
use Drupal\sitemanager\Plugin\TaskPluginBase;
/**
* Class RunCron.
*
* @package Drupal\sitemanager\Plugin\TaskPlugin
*
View TaskPluginBase.php
<?php
namespace Drupal\sitemanager\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Config\ConfigFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
View TaskPluginInterface.php
<?php
namespace Drupal\sitemanager\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
/**
* Defines an interface for Task plugin plugins.
*/
interface TaskPluginInterface extends PluginInspectionInterface {
View phpscan.py
#!/usr/bin/python
import sys
from os import listdir
from os.path import isfile, join
from os import walk
test_path = sys.argv[1]
files = []
View TaskPlugin.php
<?php
/**
* @file
* Provides TaskPlugin base class.
*/
namespace Drupal\sitemanager\Annotation;
use Drupal\Component\Annotation\Plugin;
You can’t perform that action at this time.