Skip to content

Instantly share code, notes, and snippets.


Vijaya Chandran Mani vijaycs85

View GitHub Profile
View file.php
// If the URI has a scheme, don't override the umask - schemes can handle this
// issue in their own implementation.
if (file_uri_scheme($uri)) {
return _drupal_mkdir_call($uri, $mode, $recursive, $context);
// If recursive, create each missing component of the parent directory
// individually and set the mode explicitly to override the umask.
if ($recursive) {
View translation_menu.php
$translation_set = i18n_translation_set_create('menu_link');
// translation array
$mlids = array();
foreach ($mlids as $lang => $item_name) {
list($menu_name, $mlid) = explode(':', $item_name);
$item = menu_link_load($mlid);
$translation_set->add_item($item, $lang);
View document.patch
+++ b/core/lib/Drupal/Core/ParamConverter/EntityConverter.phpundefined
@@ -0,0 +1,106 @@
+ /**
+ * Tries to upcast every variable to an entity type.
+ *
+ * If there is a type denoted in the route options it will try to upcast to
+ * it, if there is no definition in the options it will try to upcast to an
+ * entity type of that name. If the chosen enity type does not exists it will
+ * leave the variable untouched.
+ * If the entity type exist, but there is no entity with the given id it will
View converters.html
<h2>Wildcard paths</h2>
<h3>Drupal 7</h3>
in modules/book/book.module:
function book_menu() {
$items['book/export/%/%'] = array(
'page callback' => 'book_export',
'page arguments' => array(2, 3),
View entity.php
// Create a test entity to serialize.
$this->values = array(
'name' => $this->randomName(),
'user_id' => $GLOBALS['user']->uid,
'field_test_text' => array(
'value' => $this->randomName(),
'format' => 'full_html',
View drupal-clean.bat
cd D:\xampp\mysql\bin
mysql -u root < db-drop-create.sql
cd D:\xampp\htdocs\drupal-8\sites\default
rmdir /S /Q files
rm settings.php
View db-drop-create.sql
DROP DATABASE `drupal-8`;
View translation.php
public function translateString($name, $langcode, $source, $context) {
if ($name && $langcode && $source && $context) {
// If translations for a language have not been loaded yet.
if (!isset($this->translations[$name][$langcode])) {
// Preload all translations for this configuration name and language.
$this->translations[$name][$langcode] = array();
foreach ($this->localeStorage->getTranslations(array('language' => $langcode, 'type' => 'configuration', 'name' => $name)) as $string){
$this->translations[$name][$langcode][$string->context][$string->source] = $string;
View config_translation.php
* Submit handler to save config translation.
function config_translation_form_submit(&$form, &$form_state) {
$form_values = $form_state['values'];
$language = $form_values['language'];
$group = $form_values['group'];
foreach ($group->getNames() as $id => $name) {
$config = config('locale.config.' . $language->langcode . '.' . $name);
View tour.tip.yml
type: mapping
label: 'Tour tip'
type: string
label: 'ID'
type: string
label: 'Plugin'