Skip to content

Instantly share code, notes, and snippets.

@jmolivas
jmolivas / Vagrantfile
Created April 29, 2014 15:24
Adding customizable configuration to Vagrantfile
require "yaml"
parameter_file = "./parameters.yml"
parameters = Array.new(0)
if File.exists?(parameter_file)
parameters = YAML::load_file(parameter_file)
end
# Apply configuration values if available
@jmolivas
jmolivas / DefaultController.php
Last active August 20, 2022 18:57
Drupal 8 example: How to render a Twig template and load a CSS file from a Controller
<?php
namespace Drupal\acme\Controller;
use Drupal\Core\Controller\ControllerBase;
class DefaultController extends ControllerBase
{
/**
@jmolivas
jmolivas / gist:90b406b459b76a5e374e
Created September 1, 2014 04:23
ORM won't kill any kittens
public function indexAction(){
$entityManager = $this->getDoctrine()->getManager();
$articles = $entityManager->getRepository('ORMDemoBundle:Article')->findAll();
return $this->render(
'ORMDemoBundle:Article:index.html.twig',
['articles' => $articles]
);
@jmolivas
jmolivas / console-container-debug.sh
Last active August 29, 2015 14:08
Two Drupal core bugs found using the console project
$ bin/console container:debug
<?php
namespace Drupal\AppConsole\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Drupal\Core\Extension\ExtensionDiscovery;
<?php
/**
* @file
* Contains \Drupal\AppConsole\Command\CacheRebuildCommand.
*/
namespace Drupal\AppConsole\Command;
use Symfony\Component\Console\Input\InputOption;