Drupal Dump

Drupal Snippets, Hacks and more....

495 posts since 2011

Behat - log in to a site using only blackbox driver

This just another simple test for behat and mink combo with plain blackbox driver. To log in to a site and do check some behavior you can write this simple test, again no PHP needed for it. You will be logged in and checking what is on people admin page. Add it to your some.feature file and run behat.
 

Dependency injection and constructors - what really happens

use Drupal\Core\Controller\ControllerBase;
use Drupal\my_module\SomeClass;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;

class SomeController extends ControllerBase
{
    private $someProperty;

    public function __construct(SomeClass $someProperty)
    {

Drupal 8 - getting what is what

Getting into drupal 8 from drupal 7 is hard. Especially if you are new to OOP, some articles about what is what will help you on that way. I suggest the following in that order

Drilling data from entities in drupal 8

Still new to this drupal 8 beast and trying to learn how to drill down data from entites. There are this magic getters and setters methods that get you data without need to write them. So

Mixed vagrant enviroments, check where does url load from

I had many vagrant machines and haven't really paid much attention to setting unique hostname, machine name and IP address, which resulted in mixed environments. Meaning I loaded one URL and I got files and database from the other vagrant machine. To debug what was really happening I went into devel/php and found out where is my mind I mean Index file :) to do that I echoed it like this.

Install composer and drush globally

You may get this message trying to update drush globally via composer,
"To initialize a project, please create a composer.json file as described in the...."

so lets make it sure both are globally installed and required.

Download phar file with

curl -sS https://getcomposer.org/installer | php

then move it to /usr/local