Skip to content

Instantly share code, notes, and snippets.

View vijaycs85's full-sized avatar

Vijaya Chandran Mani vijaycs85

View GitHub Profile
<?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) {
<?php
$translation_set = i18n_translation_set_create('menu_link');
// translation array
$mlids = array();
$translation_set->reset_translations();
foreach ($mlids as $lang => $item_name) {
list($menu_name, $mlid) = explode(':', $item_name);
$item = menu_link_load($mlid);
$translation_set->add_item($item, $lang);
}
+++ 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
<h2>Wildcard paths</h2>
<h3>Drupal 7</h3>
in modules/book/book.module:
<?php
function book_menu() {
$items['book/export/%/%'] = array(
'page callback' => 'book_export',
'page arguments' => array(2, 3),
<?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',
),
);
D:
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
DROP DATABASE `drupal-8`;
CREATE DATABASE `drupal-8`;
<?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;
/**
* 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);
tour.tip:
type: mapping
label: 'Tour tip'
mapping:
id:
type: string
label: 'ID'
plugin:
type: string
label: 'Plugin'