Skip to content

Instantly share code, notes, and snippets.

View oksana-c's full-sized avatar

Oksana Cyrwus oksana-c

View GitHub Profile
@oksana-c
oksana-c / d7-add-entity-view-mode.md
Created August 17, 2016 16:19 — forked from swichers/d7-add-entity-view-mode.md
Drupal 7 - Programmatically add view mode to entity

In a module file:

This will enable an additional view mode for use on the specified entity type(s). Many examples will show the custom settings here being set to TRUE. If TRUE is used then that view mode is added to all entities of the specified type regardless of if it should be on the bundle or not.

/**
 * Implements hook_entity_info_alter().
 */
function HOOK_entity_info_alter(&$entity_info) {
@oksana-c
oksana-c / template.php
Created September 17, 2016 00:21 — forked from derhasi/template.php
Drupal: Override views table header labels to accept html output.
<?php
/**
* Preprocess views-view-table.tpl.php.
*
* Recreates column labels to accept html tags and do not check_plain.
* @see template_preprocess_views_view_table().
*/
function mytheme_preprocess_views_view_table(&$vars) {
$view = $vars['view'];
@oksana-c
oksana-c / README.md
Created November 18, 2016 23:17 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
@oksana-c
oksana-c / publickey-git-error.markdown
Created February 26, 2017 18:40 — forked from adamjohnson/publickey-git-error.markdown
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "your_email@example.com". Th
@oksana-c
oksana-c / d8module.install
Created April 5, 2017 00:10 — forked from laradevitt/d8module.install
(Drupal 8) Create a table in a database other than the default during module installation. Database must already be specified in settings.php.
<?php
/**
* @file
* Install, update and uninstall functions for the d8module module.
*/
function d8module_schema_otherdb() {
$schema['mytable'] = array(
'description' => 'My table description',
@oksana-c
oksana-c / dc_emw.php
Created July 11, 2017 23:15 — forked from BBGuy/dc_emw.php
Working with Drupal commerce entities using entity_metadata_wrapper. Just a bunch of exampled copied from the web or added by me. will keep adding over time. now more then just commerce entities
<?php
// Basics
// Get a value.
$value = $wrapper->field_x->value();
// If the field is a reference field you will get the field object
// To get the wrapper back use:
$wrapper_b = $wrapper->field_ref;
// To set a value.
@oksana-c
oksana-c / .eslintrc
Created July 19, 2017 12:14 — forked from jibran/.eslintrc
Sample eslint file for Drupal 7
{
"env": {
"browser": true
},
"globals": {
"Drupal": true,
"jQuery": true,
"tinyMCE": true
},
"rules": {
@oksana-c
oksana-c / inheritance.php
Created July 11, 2018 10:55 — forked from Integralist/inheritance.php
Refreshing my memory on PHP inheritance and general OOP
<?php
// Configure error messages
ini_set('display_errors',1);
error_reporting(E_ALL);
class Adult {
/*
We set the visibility of these properties to 'protected' so they are accessible within the Child class.
We prefix private and protected properties/methods with an underscore, so (at a glance) while scanning a long file we can instantly recognise the visibility.
@oksana-c
oksana-c / gist:087a59fb3853cdab30d3dc6033edcc37
Created August 9, 2018 22:07 — forked from grasmash/gist:9746671
Behat FeatureContext.php for Drupal
<?php
use Drupal\DrupalExtension\Context\DrupalContext,
Drupal\DrupalExtension\Event\EntityEvent,
Drupal\Component\Utility\Random;
use Behat\Behat\Context\BehatContext,
Behat\Behat\Context\Step,
Behat\Behat\Context\Step\Given,
Behat\Gherkin\Node\PyStringNode,
@oksana-c
oksana-c / any.php
Created August 20, 2018 17:24 — forked from robdecker/any.php
Drupal 7: Link l() function with attributes.
l(
t('<span></span>Link Title'),
'link_path',
array(
'attributes' => array(
'class' => array('menu-link'),
'id' =>'faq-page',
),
'html' => TRUE,
),