Skip to content

Instantly share code, notes, and snippets.

@annikaC
annikaC / MYMODULE.module
Last active February 8, 2018 15:12 — forked from ndeet/MYTHEME.info
Drupal 7, Panels 3.3+ Pane Style Plugin
/**
* Implements hook_ctools_plugin_directory().
*/
function MYMODULE_ctools_plugin_directory($module, $plugin) {
if ($module === 'panels' || $module === 'ctools' && !empty($plugin)) {
return "plugins/{$plugin}";
}
}
@annikaC
annikaC / AccountEditRedirectController.php
Created September 29, 2016 14:03
Drupal 8 redirect user to own user edit page (for use in menu links)
<?php
namespace Drupal\yourmodule\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* A controller that redirects to the current user's edit account page.
@annikaC
annikaC / gist:546198c3be67279dfae8f82428e3cff1
Created July 29, 2016 12:06
Drupal 8 add placeholders to password_confirm element
/**
* Implements hook_element_info_alter().
*/
function module_element_info_alter(array &$types) {
// Add placeholders to password_confirm element.
$types['password_confirm']['#process'][] = "_module_add_pass_confirm_placeholders";
}
function _module_add_pass_confirm_placeholders(&$element, FormStateInterface $form_state, &$complete_form) {
$element['pass1']['#placeholder'] = t('Password');
// Change font (ctrl a)
var font_name = [doc askForUserInput:"Font name:" initialValue:"Arial"];
function check_layer(layer){
log("Checking layer " + layer + " of klass: " + [layer class])
switch ([layer class]) {
case MSTextLayer:
log("Found text layer!")
layer.setFontPostscriptName(font_name);
break;

PHP Developer Interview: What you should know

###1. What’s the difference between " self " and " this " ?

Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members.

Source: When to use self vs this -stackoverflow