diff --git a/composer.json b/composer.json index 4c4f823..9fa6935 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "symfony/yaml": "2.3.*", "twig/twig": "1.12.*", "doctrine/common": "2.4.*@beta", - "guzzle/http": "3.7.*", + "guzzle/http": "3.1.*", "kriswallsmith/assetic": "1.1.*@alpha", "symfony-cmf/routing": "1.1.*@alpha", "easyrdf/easyrdf": "0.8.*@beta", diff --git a/composer.lock b/composer.lock index ce988ad..35f3e82 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "eb2c59507a34a3831afe33b16c4d5775", + "hash": "99355ea2b3166a2c7d7029c8ddc76f4e", "packages": [ { "name": "doctrine/annotations", @@ -449,17 +449,17 @@ }, { "name": "guzzle/common", - "version": "v3.7.1", + "version": "v3.1.2", "target-dir": "Guzzle/Common", "source": { "type": "git", - "url": "https://github.com/guzzle/common.git", - "reference": "v3.7.1" + "url": "git://github.com/guzzle/common.git", + "reference": "v3.1.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/common/zipball/v3.7.1", - "reference": "v3.7.1", + "url": "https://github.com/guzzle/common/archive/v3.1.2.zip", + "reference": "v3.1.2", "shasum": "" }, "require": { @@ -469,7 +469,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.7-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -489,21 +489,21 @@ "event", "exception" ], - "time": "2013-07-05 20:17:54" + "time": "2013-01-28 00:07:40" }, { "name": "guzzle/http", - "version": "v3.7.1", + "version": "v3.1.2", "target-dir": "Guzzle/Http", "source": { "type": "git", - "url": "https://github.com/guzzle/http.git", - "reference": "v3.7.1" + "url": "git://github.com/guzzle/http.git", + "reference": "v3.1.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/http/zipball/v3.7.1", - "reference": "v3.7.1", + "url": "https://github.com/guzzle/http/archive/v3.1.2.zip", + "reference": "v3.1.2", "shasum": "" }, "require": { @@ -518,7 +518,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.7-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -546,21 +546,21 @@ "http", "http client" ], - "time": "2013-07-02 19:53:26" + "time": "2013-01-26 08:20:43" }, { "name": "guzzle/parser", - "version": "v3.7.1", + "version": "v3.1.2", "target-dir": "Guzzle/Parser", "source": { "type": "git", - "url": "https://github.com/guzzle/parser.git", - "reference": "v3.7.1" + "url": "git://github.com/guzzle/parser.git", + "reference": "v3.1.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/parser/zipball/v3.7.1", - "reference": "v3.7.1", + "url": "https://github.com/guzzle/parser/archive/v3.1.2.zip", + "reference": "v3.1.2", "shasum": "" }, "require": { @@ -569,7 +569,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.7-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -590,34 +590,31 @@ "message", "url" ], - "time": "2013-06-11 00:24:07" + "time": "2013-01-12 21:43:21" }, { "name": "guzzle/stream", - "version": "v3.7.1", + "version": "v3.1.2", "target-dir": "Guzzle/Stream", "source": { "type": "git", - "url": "https://github.com/guzzle/stream.git", - "reference": "v3.7.1" + "url": "https://github.com/guzzle/stream", + "reference": "v3.0.7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/stream/zipball/v3.7.1", - "reference": "v3.7.1", + "url": "https://github.com/guzzle/stream/archive/v3.0.7.zip", + "reference": "v3.0.7", "shasum": "" }, "require": { "guzzle/common": "self.version", "php": ">=5.3.2" }, - "suggest": { - "guzzle/http": "To convert Guzzle request objects to PHP streams" - }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.7-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -643,7 +640,7 @@ "component", "stream" ], - "time": "2013-06-27 00:50:43" + "time": "2012-12-07 16:45:11" }, { "name": "kriswallsmith/assetic", diff --git a/core/CHANGELOG.txt b/core/CHANGELOG.txt index 80e38a4..3debd6f 100644 --- a/core/CHANGELOG.txt +++ b/core/CHANGELOG.txt @@ -47,7 +47,7 @@ Drupal 8.0, xxxx-xx-xx (development version) - Universally Unique IDentifier (UUID): * Support for generating and validating UUIDs. - JavaScript changes: - * Updated to jQuery 2.0.3 + * Updated to jQuery 2.0 * Updated to jQuery UI 1.10.2 - Tremendously improved language support all around. * Great language improvements for users: diff --git a/core/assets/vendor/jquery-form/jquery.form.js b/core/assets/vendor/jquery-form/jquery.form.js index 8ca137a..73ed98b 100644 --- a/core/assets/vendor/jquery-form/jquery.form.js +++ b/core/assets/vendor/jquery-form/jquery.form.js @@ -1,113 +1,95 @@ /*! * jQuery Form Plugin - * version: 3.39.0-2013.07.31 + * version: 3.27.0-2013.02.06 * @requires jQuery v1.5 or later - * Copyright (c) 2013 M. Alsup + * * Examples and documentation at: http://malsup.com/jquery/form/ * Project repository: https://github.com/malsup/form - * Dual licensed under the MIT and GPL licenses. - * https://github.com/malsup/form#copyright-and-license + * Dual licensed under the MIT and GPL licenses: + * http://malsup.github.com/mit-license.txt + * http://malsup.github.com/gpl-license-v2.txt */ -/*global ActiveXObject */ +/*global ActiveXObject alert */ ;(function($) { -"use strict"; - -/* - Usage Note: - ----------- - Do not use both ajaxSubmit and ajaxForm on the same form. These - functions are mutually exclusive. Use ajaxSubmit if you want - to bind your own submit handler to the form. For example, - - $(document).ready(function() { - $('#myForm').on('submit', function(e) { - e.preventDefault(); // <-- important - $(this).ajaxSubmit({ - target: '#output' - }); - }); - }); - - Use ajaxForm when you want the plugin to manage all the event binding - for you. For example, - - $(document).ready(function() { - $('#myForm').ajaxForm({ - target: '#output' - }); - }); - - You can also use ajaxForm with delegation (requires jQuery v1.7+), so the - form does not have to exist when you invoke ajaxForm: - - $('#myForm').ajaxForm({ - delegation: true, - target: '#output' - }); - - When using ajaxForm, the ajaxSubmit function will be invoked for you - at the appropriate time. -*/ - -/** - * Feature detection - */ -var feature = {}; -feature.fileapi = $("").get(0).files !== undefined; -feature.formdata = window.FormData !== undefined; - -var hasProp = !!$.fn.prop; - -// attr2 uses prop when it can but checks the return type for -// an expected string. this accounts for the case where a form -// contains inputs with names like "action" or "method"; in those -// cases "prop" returns the element -$.fn.attr2 = function() { - if ( ! hasProp ) - return this.attr.apply(this, arguments); - var val = this.prop.apply(this, arguments); - if ( ( val && val.jquery ) || typeof val === 'string' ) - return val; - return this.attr.apply(this, arguments); -}; - -/** - * ajaxSubmit() provides a mechanism for immediately submitting - * an HTML form using AJAX. - */ -$.fn.ajaxSubmit = function(options) { + "use strict"; + + /* + Usage Note: + ----------- + Do not use both ajaxSubmit and ajaxForm on the same form. These + functions are mutually exclusive. Use ajaxSubmit if you want + to bind your own submit handler to the form. For example, + + $(document).ready(function() { + $('#myForm').on('submit', function(e) { + e.preventDefault(); // <-- important + $(this).ajaxSubmit({ + target: '#output' + }); + }); + }); + + Use ajaxForm when you want the plugin to manage all the event binding + for you. For example, + + $(document).ready(function() { + $('#myForm').ajaxForm({ + target: '#output' + }); + }); + + You can also use ajaxForm with delegation (requires jQuery v1.7+), so the + form does not have to exist when you invoke ajaxForm: + + $('#myForm').ajaxForm({ + delegation: true, + target: '#output' + }); + + When using ajaxForm, the ajaxSubmit function will be invoked for you + at the appropriate time. + */ + + /** + * Feature detection + */ + var feature = {}; + feature.fileapi = $("").get(0).files !== undefined; + feature.formdata = window.FormData !== undefined; + + /** + * ajaxSubmit() provides a mechanism for immediately submitting + * an HTML form using AJAX. + */ + $.fn.ajaxSubmit = function(options) { /*jshint scripturl:true */ // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) if (!this.length) { - log('ajaxSubmit: skipping submit process - no element selected'); - return this; + log('ajaxSubmit: skipping submit process - no element selected'); + return this; } var method, action, url, $form = this; if (typeof options == 'function') { - options = { success: options }; - } - else if ( options === undefined ) { - options = {}; + options = { success: options }; } - method = options.type || this.attr2('method'); - action = options.url || this.attr2('action'); - + method = this.attr('method'); + action = this.attr('action'); url = (typeof action === 'string') ? $.trim(action) : ''; url = url || window.location.href || ''; if (url) { - // clean url (don't include hash vaue) - url = (url.match(/^([^#]+)/)||[])[1]; + // clean url (don't include hash vaue) + url = (url.match(/^([^#]+)/)||[])[1]; } options = $.extend(true, { - url: url, - success: $.ajaxSettings.success, - type: method || $.ajaxSettings.type, - iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' + url: url, + success: $.ajaxSettings.success, + type: method || 'GET', + iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' }, options); // hook for manipulating the form data before it is extracted; @@ -115,101 +97,85 @@ $.fn.ajaxSubmit = function(options) { var veto = {}; this.trigger('form-pre-serialize', [this, options, veto]); if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); - return this; + log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); + return this; } // provide opportunity to alter form data before it is serialized if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSerialize callback'); - return this; + log('ajaxSubmit: submit aborted via beforeSerialize callback'); + return this; } var traditional = options.traditional; if ( traditional === undefined ) { - traditional = $.ajaxSettings.traditional; + traditional = $.ajaxSettings.traditional; } var elements = []; var qx, a = this.formToArray(options.semantic, elements); if (options.data) { - options.extraData = options.data; - qx = $.param(options.data, traditional); + options.extraData = options.data; + qx = $.param(options.data, traditional); } // give pre-submit callback an opportunity to abort the submit if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSubmit callback'); - return this; + log('ajaxSubmit: submit aborted via beforeSubmit callback'); + return this; } // fire vetoable 'validate' event this.trigger('form-submit-validate', [a, this, options, veto]); if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); - return this; + log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); + return this; } var q = $.param(a, traditional); if (qx) { - q = ( q ? (q + '&' + qx) : qx ); + q = ( q ? (q + '&' + qx) : qx ); } if (options.type.toUpperCase() == 'GET') { - options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; - options.data = null; // data is null for 'get' + options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; + options.data = null; // data is null for 'get' } else { - options.data = q; // data is the query string for 'post' + options.data = q; // data is the query string for 'post' } var callbacks = []; if (options.resetForm) { - callbacks.push(function() { $form.resetForm(); }); + callbacks.push(function() { $form.resetForm(); }); } if (options.clearForm) { - callbacks.push(function() { $form.clearForm(options.includeHidden); }); + callbacks.push(function() { $form.clearForm(options.includeHidden); }); } // perform a load on the target only if dataType is not provided if (!options.dataType && options.target) { - var oldSuccess = options.success || function(){}; - callbacks.push(function(data) { - var fn = options.replaceTarget ? 'replaceWith' : 'html'; - $(options.target)[fn](data).each(oldSuccess, arguments); - }); + var oldSuccess = options.success || function(){}; + callbacks.push(function(data) { + var fn = options.replaceTarget ? 'replaceWith' : 'html'; + $(options.target)[fn](data).each(oldSuccess, arguments); + }); } else if (options.success) { - callbacks.push(options.success); + callbacks.push(options.success); } options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg - var context = options.context || this ; // jQuery 1.4+ supports scope context - for (var i=0, max=callbacks.length; i < max; i++) { - callbacks[i].apply(context, [data, status, xhr || $form, $form]); - } + var context = options.context || this ; // jQuery 1.4+ supports scope context + for (var i=0, max=callbacks.length; i < max; i++) { + callbacks[i].apply(context, [data, status, xhr || $form, $form]); + } }; - if (options.error) { - var oldError = options.error; - options.error = function(xhr, status, error) { - var context = options.context || this; - oldError.apply(context, [xhr, status, error, $form]); - }; - } - - if (options.complete) { - var oldComplete = options.complete; - options.complete = function(xhr, status) { - var context = options.context || this; - oldComplete.apply(context, [xhr, status, $form]); - }; - } - // are there files to upload? // [value] (issue #113), also see comment: // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219 - var fileInputs = $('input[type=file]:enabled:not([value=""])', this); + var fileInputs = $('input[type=file]:enabled[value!=""]', this); var hasFileInputs = fileInputs.length > 0; var mp = 'multipart/form-data'; @@ -224,29 +190,29 @@ $.fn.ajaxSubmit = function(options) { // options.iframe allows user to force iframe mode // 06-NOV-09: now defaulting to iframe mode if file input is detected if (options.iframe !== false && (options.iframe || shouldUseFrame)) { - // hack to fix Safari hang (thanks to Tim Molendijk for this) - // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d - if (options.closeKeepAlive) { - $.get(options.closeKeepAlive, function() { - jqxhr = fileUploadIframe(a); - }); - } - else { - jqxhr = fileUploadIframe(a); - } + // hack to fix Safari hang (thanks to Tim Molendijk for this) + // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d + if (options.closeKeepAlive) { + $.get(options.closeKeepAlive, function() { + jqxhr = fileUploadIframe(a); + }); + } + else { + jqxhr = fileUploadIframe(a); + } } else if ((hasFileInputs || multipart) && fileAPI) { - jqxhr = fileUploadXhr(a); + jqxhr = fileUploadXhr(a); } else { - jqxhr = $.ajax(options); + jqxhr = $.ajax(options); } $form.removeData('jqxhr').data('jqxhr', jqxhr); // clear element array for (var k=0; k < elements.length; k++) - elements[k] = null; + elements[k] = null; // fire 'notify' event this.trigger('form-submit-notify', [this, options]); @@ -254,945 +220,908 @@ $.fn.ajaxSubmit = function(options) { // utility fn for deep serialization function deepSerialize(extraData){ - var serialized = $.param(extraData, options.traditional).split('&'); - var len = serialized.length; - var result = []; - var i, part; - for (i=0; i < len; i++) { - // #252; undo param space replacement - serialized[i] = serialized[i].replace(/\+/g,' '); - part = serialized[i].split('='); - // #278; use array instead of object storage, favoring array serializations - result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]); - } - return result; + var serialized = $.param(extraData).split('&'); + var len = serialized.length; + var result = []; + var i, part; + for (i=0; i < len; i++) { + // #252; undo param space replacement + serialized[i] = serialized[i].replace(/\+/g,' '); + part = serialized[i].split('='); + // #278; use array instead of object storage, favoring array serializations + result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]); + } + return result; } - // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) + // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) function fileUploadXhr(a) { - var formdata = new FormData(); - - for (var i=0; i < a.length; i++) { - formdata.append(a[i].name, a[i].value); - } - - if (options.extraData) { - var serializedData = deepSerialize(options.extraData); - for (i=0; i < serializedData.length; i++) - if (serializedData[i]) - formdata.append(serializedData[i][0], serializedData[i][1]); - } - - options.data = null; - - var s = $.extend(true, {}, $.ajaxSettings, options, { - contentType: false, - processData: false, - cache: false, - type: method || 'POST' - }); - - if (options.uploadProgress) { - // workaround because jqXHR does not expose upload property - s.xhr = function() { - var xhr = $.ajaxSettings.xhr(); - if (xhr.upload) { - xhr.upload.addEventListener('progress', function(event) { - var percent = 0; - var position = event.loaded || event.position; /*event.position is deprecated*/ - var total = event.total; - if (event.lengthComputable) { - percent = Math.ceil(position / total * 100); - } - options.uploadProgress(event, position, total, percent); - }, false); - } - return xhr; - }; - } - - s.data = null; - var beforeSend = s.beforeSend; - s.beforeSend = function(xhr, o) { - o.data = formdata; - if(beforeSend) - beforeSend.call(this, xhr, o); + var formdata = new FormData(); + + for (var i=0; i < a.length; i++) { + formdata.append(a[i].name, a[i].value); + } + + if (options.extraData) { + var serializedData = deepSerialize(options.extraData); + for (i=0; i < serializedData.length; i++) + if (serializedData[i]) + formdata.append(serializedData[i][0], serializedData[i][1]); + } + + options.data = null; + + var s = $.extend(true, {}, $.ajaxSettings, options, { + contentType: false, + processData: false, + cache: false, + type: method || 'POST' + }); + + if (options.uploadProgress) { + // workaround because jqXHR does not expose upload property + s.xhr = function() { + var xhr = jQuery.ajaxSettings.xhr(); + if (xhr.upload) { + xhr.upload.addEventListener('progress', function(event) { + var percent = 0; + var position = event.loaded || event.position; /*event.position is deprecated*/ + var total = event.total; + if (event.lengthComputable) { + percent = Math.ceil(position / total * 100); + } + options.uploadProgress(event, position, total, percent); + }, false); + } + return xhr; }; - return $.ajax(s); + } + + s.data = null; + var beforeSend = s.beforeSend; + s.beforeSend = function(xhr, o) { + o.data = formdata; + if(beforeSend) + beforeSend.call(this, xhr, o); + }; + return $.ajax(s); } // private function for handling file uploads (hat tip to YAHOO!) function fileUploadIframe(a) { - var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; - var deferred = $.Deferred(); - - // #341 - deferred.abort = function(status) { - xhr.abort(status); - }; - - if (a) { - // ensure that every serialized input is still enabled - for (i=0; i < elements.length; i++) { - el = $(elements[i]); - if ( hasProp ) - el.prop('disabled', false); - else - el.removeAttr('disabled'); + var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; + var useProp = !!$.fn.prop; + var deferred = $.Deferred(); + + if (a) { + // ensure that every serialized input is still enabled + for (i=0; i < elements.length; i++) { + el = $(elements[i]); + if ( useProp ) + el.prop('disabled', false); + else + el.removeAttr('disabled'); + } + } + + s = $.extend(true, {}, $.ajaxSettings, options); + s.context = s.context || s; + id = 'jqFormIO' + (new Date().getTime()); + if (s.iframeTarget) { + $io = $(s.iframeTarget); + n = $io.attr('name'); + if (!n) + $io.attr('name', id); + else + id = n; + } + else { + $io = $(''); + $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' }); + } + io = $io[0]; + + + xhr = { // mock object + aborted: 0, + responseText: null, + responseXML: null, + status: 0, + statusText: 'n/a', + getAllResponseHeaders: function() {}, + getResponseHeader: function() {}, + setRequestHeader: function() {}, + abort: function(status) { + var e = (status === 'timeout' ? 'timeout' : 'aborted'); + log('aborting upload... ' + e); + this.aborted = 1; + + try { // #214, #257 + if (io.contentWindow.document.execCommand) { + io.contentWindow.document.execCommand('Stop'); } + } + catch(ignore) {} + + $io.attr('src', s.iframeSrc); // abort op in progress + xhr.error = e; + if (s.error) + s.error.call(s.context, xhr, e, status); + if (g) + $.event.trigger("ajaxError", [xhr, s, e]); + if (s.complete) + s.complete.call(s.context, xhr, e); } - - s = $.extend(true, {}, $.ajaxSettings, options); - s.context = s.context || s; - id = 'jqFormIO' + (new Date().getTime()); - if (s.iframeTarget) { - $io = $(s.iframeTarget); - n = $io.attr2('name'); - if (!n) - $io.attr2('name', id); - else - id = n; + }; + + g = s.global; + // trigger ajax global events so that activity/block indicators work like normal + if (g && 0 === $.active++) { + $.event.trigger("ajaxStart"); + } + if (g) { + $.event.trigger("ajaxSend", [xhr, s]); + } + + if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) { + if (s.global) { + $.active--; } - else { - $io = $(''); - $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' }); + deferred.reject(); + return deferred; + } + if (xhr.aborted) { + deferred.reject(); + return deferred; + } + + // add submitting element to data if we know it + sub = form.clk; + if (sub) { + n = sub.name; + if (n && !sub.disabled) { + s.extraData = s.extraData || {}; + s.extraData[n] = sub.value; + if (sub.type == "image") { + s.extraData[n+'.x'] = form.clk_x; + s.extraData[n+'.y'] = form.clk_y; + } } - io = $io[0]; - - - xhr = { // mock object - aborted: 0, - responseText: null, - responseXML: null, - status: 0, - statusText: 'n/a', - getAllResponseHeaders: function() {}, - getResponseHeader: function() {}, - setRequestHeader: function() {}, - abort: function(status) { - var e = (status === 'timeout' ? 'timeout' : 'aborted'); - log('aborting upload... ' + e); - this.aborted = 1; - - try { // #214, #257 - if (io.contentWindow.document.execCommand) { - io.contentWindow.document.execCommand('Stop'); - } - } - catch(ignore) {} - - $io.attr('src', s.iframeSrc); // abort op in progress - xhr.error = e; - if (s.error) - s.error.call(s.context, xhr, e, status); - if (g) - $.event.trigger("ajaxError", [xhr, s, e]); - if (s.complete) - s.complete.call(s.context, xhr, e); - } - }; - - g = s.global; - // trigger ajax global events so that activity/block indicators work like normal - if (g && 0 === $.active++) { - $.event.trigger("ajaxStart"); + } + + var CLIENT_TIMEOUT_ABORT = 1; + var SERVER_ABORT = 2; + + function getDoc(frame) { + var doc = frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document; + return doc; + } + + // Rails CSRF hack (thanks to Yvan Barthelemy) + var csrf_token = $('meta[name=csrf-token]').attr('content'); + var csrf_param = $('meta[name=csrf-param]').attr('content'); + if (csrf_param && csrf_token) { + s.extraData = s.extraData || {}; + s.extraData[csrf_param] = csrf_token; + } + + // take a breath so that pending repaints get some cpu time before the upload starts + function doSubmit() { + // make sure form attrs are set + var t = $form.attr('target'), a = $form.attr('action'); + + // update form attrs in IE friendly way + form.setAttribute('target',id); + if (!method) { + form.setAttribute('method', 'POST'); } - if (g) { - $.event.trigger("ajaxSend", [xhr, s]); + if (a != s.url) { + form.setAttribute('action', s.url); } - if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) { - if (s.global) { - $.active--; - } - deferred.reject(); - return deferred; + // ie borks in some cases when setting encoding + if (! s.skipEncodingOverride && (!method || /post/i.test(method))) { + $form.attr({ + encoding: 'multipart/form-data', + enctype: 'multipart/form-data' + }); } - if (xhr.aborted) { - deferred.reject(); - return deferred; + + // support timout + if (s.timeout) { + timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout); } - // add submitting element to data if we know it - sub = form.clk; - if (sub) { - n = sub.name; - if (n && !sub.disabled) { - s.extraData = s.extraData || {}; - s.extraData[n] = sub.value; - if (sub.type == "image") { - s.extraData[n+'.x'] = form.clk_x; - s.extraData[n+'.y'] = form.clk_y; - } - } + // look for server aborts + function checkState() { + try { + var state = getDoc(io).readyState; + log('state = ' + state); + if (state && state.toLowerCase() == 'uninitialized') + setTimeout(checkState,50); + } + catch(e) { + log('Server abort: ' , e, ' (', e.name, ')'); + cb(SERVER_ABORT); + if (timeoutHandle) + clearTimeout(timeoutHandle); + timeoutHandle = undefined; + } } - var CLIENT_TIMEOUT_ABORT = 1; - var SERVER_ABORT = 2; - - function getDoc(frame) { - /* it looks like contentWindow or contentDocument do not - * carry the protocol property in ie8, when running under ssl - * frame.document is the only valid response document, since - * the protocol is know but not on the other two objects. strange? - * "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy - */ - - var doc = null; - - // IE8 cascading access check - try { - if (frame.contentWindow) { - doc = frame.contentWindow.document; + // add "extra" data to form if provided in options + var extraInputs = []; + try { + if (s.extraData) { + for (var n in s.extraData) { + if (s.extraData.hasOwnProperty(n)) { + // if using the $.param format that allows for multiple values with the same name + if($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) { + extraInputs.push( + $('').val(s.extraData[n].value) + .appendTo(form)[0]); + } else { + extraInputs.push( + $('').val(s.extraData[n]) + .appendTo(form)[0]); } - } catch(err) { - // IE8 access denied under ssl & missing protocol - log('cannot get iframe.contentWindow document: ' + err); - } - - if (doc) { // successful getting content - return doc; + } } + } - try { // simply checking may throw in ie8 under ssl or mismatched protocol - doc = frame.contentDocument ? frame.contentDocument : frame.document; - } catch(err) { - // last attempt - log('cannot get iframe.contentDocument: ' + err); - doc = frame.document; - } - return doc; + if (!s.iframeTarget) { + // add iframe to doc and submit the form + $io.appendTo('body'); + if (io.attachEvent) + io.attachEvent('onload', cb); + else + io.addEventListener('load', cb, false); + } + setTimeout(checkState,15); + // just in case form has element with name/id of 'submit' + var submitFn = document.createElement('form').submit; + submitFn.apply(form); } - - // Rails CSRF hack (thanks to Yvan Barthelemy) - var csrf_token = $('meta[name=csrf-token]').attr('content'); - var csrf_param = $('meta[name=csrf-param]').attr('content'); - if (csrf_param && csrf_token) { - s.extraData = s.extraData || {}; - s.extraData[csrf_param] = csrf_token; + finally { + // reset attrs and remove "extra" input elements + form.setAttribute('action',a); + if(t) { + form.setAttribute('target', t); + } else { + $form.removeAttr('target'); + } + $(extraInputs).remove(); } + } - // take a breath so that pending repaints get some cpu time before the upload starts - function doSubmit() { - // make sure form attrs are set - var t = $form.attr2('target'), a = $form.attr2('action'); - - // update form attrs in IE friendly way - form.setAttribute('target',id); - if (!method) { - form.setAttribute('method', 'POST'); - } - if (a != s.url) { - form.setAttribute('action', s.url); - } - - // ie borks in some cases when setting encoding - if (! s.skipEncodingOverride && (!method || /post/i.test(method))) { - $form.attr({ - encoding: 'multipart/form-data', - enctype: 'multipart/form-data' - }); - } - - // support timout - if (s.timeout) { - timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout); - } - - // look for server aborts - function checkState() { - try { - var state = getDoc(io).readyState; - log('state = ' + state); - if (state && state.toLowerCase() == 'uninitialized') - setTimeout(checkState,50); - } - catch(e) { - log('Server abort: ' , e, ' (', e.name, ')'); - cb(SERVER_ABORT); - if (timeoutHandle) - clearTimeout(timeoutHandle); - timeoutHandle = undefined; - } - } + if (s.forceSync) { + doSubmit(); + } + else { + setTimeout(doSubmit, 10); // this lets dom updates render + } - // add "extra" data to form if provided in options - var extraInputs = []; - try { - if (s.extraData) { - for (var n in s.extraData) { - if (s.extraData.hasOwnProperty(n)) { - // if using the $.param format that allows for multiple values with the same name - if($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) { - extraInputs.push( - $('').val(s.extraData[n].value) - .appendTo(form)[0]); - } else { - extraInputs.push( - $('').val(s.extraData[n]) - .appendTo(form)[0]); - } - } - } - } + var data, doc, domCheckCount = 50, callbackProcessed; - if (!s.iframeTarget) { - // add iframe to doc and submit the form - $io.appendTo('body'); - if (io.attachEvent) - io.attachEvent('onload', cb); - else - io.addEventListener('load', cb, false); - } - setTimeout(checkState,15); - - try { - form.submit(); - } catch(err) { - // just in case form has element with name/id of 'submit' - var submitFn = document.createElement('form').submit; - submitFn.apply(form); - } - } - finally { - // reset attrs and remove "extra" input elements - form.setAttribute('action',a); - if(t) { - form.setAttribute('target', t); - } else { - $form.removeAttr('target'); - } - $(extraInputs).remove(); - } + function cb(e) { + if (xhr.aborted || callbackProcessed) { + return; } - - if (s.forceSync) { - doSubmit(); + try { + doc = getDoc(io); } - else { - setTimeout(doSubmit, 10); // this lets dom updates render + catch(ex) { + log('cannot access response document: ', ex); + e = SERVER_ABORT; + } + if (e === CLIENT_TIMEOUT_ABORT && xhr) { + xhr.abort('timeout'); + deferred.reject(xhr, 'timeout'); + return; + } + else if (e == SERVER_ABORT && xhr) { + xhr.abort('server abort'); + deferred.reject(xhr, 'error', 'server abort'); + return; } - var data, doc, domCheckCount = 50, callbackProcessed; - - function cb(e) { - if (xhr.aborted || callbackProcessed) { - return; - } - - doc = getDoc(io); - if(!doc) { - log('cannot access response document'); - e = SERVER_ABORT; - } - if (e === CLIENT_TIMEOUT_ABORT && xhr) { - xhr.abort('timeout'); - deferred.reject(xhr, 'timeout'); - return; - } - else if (e == SERVER_ABORT && xhr) { - xhr.abort('server abort'); - deferred.reject(xhr, 'error', 'server abort'); - return; - } - - if (!doc || doc.location.href == s.iframeSrc) { - // response not received yet - if (!timedOut) - return; - } - if (io.detachEvent) - io.detachEvent('onload', cb); - else - io.removeEventListener('load', cb, false); - - var status = 'success', errMsg; - try { - if (timedOut) { - throw 'timeout'; - } - - var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc); - log('isXml='+isXml); - if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) { - if (--domCheckCount) { - // in some browsers (Opera) the iframe DOM is not always traversable when - // the onload callback fires, so we loop a bit to accommodate - log('requeing onLoad callback, DOM not available'); - setTimeout(cb, 250); - return; - } - // let this fall through because server response could be an empty document - //log('Could not access iframe DOM after mutiple tries.'); - //throw 'DOMException: not available'; - } - - //log('response detected'); - var docRoot = doc.body ? doc.body : doc.documentElement; - xhr.responseText = docRoot ? docRoot.innerHTML : null; - xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; - if (isXml) - s.dataType = 'xml'; - xhr.getResponseHeader = function(header){ - var headers = {'content-type': s.dataType}; - return headers[header]; - }; - // support for XHR 'status' & 'statusText' emulation : - if (docRoot) { - xhr.status = Number( docRoot.getAttribute('status') ) || xhr.status; - xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText; - } - - var dt = (s.dataType || '').toLowerCase(); - var scr = /(json|script|text)/.test(dt); - if (scr || s.textarea) { - // see if user embedded response in textarea - var ta = doc.getElementsByTagName('textarea')[0]; - if (ta) { - xhr.responseText = ta.value; - // support for XHR 'status' & 'statusText' emulation : - xhr.status = Number( ta.getAttribute('status') ) || xhr.status; - xhr.statusText = ta.getAttribute('statusText') || xhr.statusText; - } - else if (scr) { - // account for browsers injecting pre around json response - var pre = doc.getElementsByTagName('pre')[0]; - var b = doc.getElementsByTagName('body')[0]; - if (pre) { - xhr.responseText = pre.textContent ? pre.textContent : pre.innerText; - } - else if (b) { - xhr.responseText = b.textContent ? b.textContent : b.innerText; - } - } - } - else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) { - xhr.responseXML = toXml(xhr.responseText); - } - - try { - data = httpData(xhr, dt, s); - } - catch (err) { - status = 'parsererror'; - xhr.error = errMsg = (err || status); - } - } - catch (err) { - log('error caught: ',err); - status = 'error'; - xhr.error = errMsg = (err || status); - } - - if (xhr.aborted) { - log('upload aborted'); - status = null; - } - - if (xhr.status) { // we've set xhr.status - status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error'; - } - - // ordering of these callbacks/triggers is odd, but that's how $.ajax does it - if (status === 'success') { - if (s.success) - s.success.call(s.context, data, 'success', xhr); - deferred.resolve(xhr.responseText, 'success', xhr); - if (g) - $.event.trigger("ajaxSuccess", [xhr, s]); + if (!doc || doc.location.href == s.iframeSrc) { + // response not received yet + if (!timedOut) + return; + } + if (io.detachEvent) + io.detachEvent('onload', cb); + else + io.removeEventListener('load', cb, false); + + var status = 'success', errMsg; + try { + if (timedOut) { + throw 'timeout'; + } + + var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc); + log('isXml='+isXml); + if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) { + if (--domCheckCount) { + // in some browsers (Opera) the iframe DOM is not always traversable when + // the onload callback fires, so we loop a bit to accommodate + log('requeing onLoad callback, DOM not available'); + setTimeout(cb, 250); + return; } - else if (status) { - if (errMsg === undefined) - errMsg = xhr.statusText; - if (s.error) - s.error.call(s.context, xhr, status, errMsg); - deferred.reject(xhr, 'error', errMsg); - if (g) - $.event.trigger("ajaxError", [xhr, s, errMsg]); + // let this fall through because server response could be an empty document + //log('Could not access iframe DOM after mutiple tries.'); + //throw 'DOMException: not available'; + } + + //log('response detected'); + var docRoot = doc.body ? doc.body : doc.documentElement; + xhr.responseText = docRoot ? docRoot.innerHTML : null; + xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; + if (isXml) + s.dataType = 'xml'; + xhr.getResponseHeader = function(header){ + var headers = {'content-type': s.dataType}; + return headers[header]; + }; + // support for XHR 'status' & 'statusText' emulation : + if (docRoot) { + xhr.status = Number( docRoot.getAttribute('status') ) || xhr.status; + xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText; + } + + var dt = (s.dataType || '').toLowerCase(); + var scr = /(json|script|text)/.test(dt); + if (scr || s.textarea) { + // see if user embedded response in textarea + var ta = doc.getElementsByTagName('textarea')[0]; + if (ta) { + xhr.responseText = ta.value; + // support for XHR 'status' & 'statusText' emulation : + xhr.status = Number( ta.getAttribute('status') ) || xhr.status; + xhr.statusText = ta.getAttribute('statusText') || xhr.statusText; } - - if (g) - $.event.trigger("ajaxComplete", [xhr, s]); - - if (g && ! --$.active) { - $.event.trigger("ajaxStop"); + else if (scr) { + // account for browsers injecting pre around json response + var pre = doc.getElementsByTagName('pre')[0]; + var b = doc.getElementsByTagName('body')[0]; + if (pre) { + xhr.responseText = pre.textContent ? pre.textContent : pre.innerText; + } + else if (b) { + xhr.responseText = b.textContent ? b.textContent : b.innerText; + } } + } + else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) { + xhr.responseXML = toXml(xhr.responseText); + } + + try { + data = httpData(xhr, dt, s); + } + catch (e) { + status = 'parsererror'; + xhr.error = errMsg = (e || status); + } + } + catch (e) { + log('error caught: ',e); + status = 'error'; + xhr.error = errMsg = (e || status); + } - if (s.complete) - s.complete.call(s.context, xhr, status); - - callbackProcessed = true; - if (s.timeout) - clearTimeout(timeoutHandle); + if (xhr.aborted) { + log('upload aborted'); + status = null; + } - // clean up - setTimeout(function() { - if (!s.iframeTarget) - $io.remove(); - xhr.responseXML = null; - }, 100); + if (xhr.status) { // we've set xhr.status + status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error'; } - var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+) - if (window.ActiveXObject) { - doc = new ActiveXObject('Microsoft.XMLDOM'); - doc.async = 'false'; - doc.loadXML(s); - } - else { - doc = (new DOMParser()).parseFromString(s, 'text/xml'); - } - return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null; - }; - var parseJSON = $.parseJSON || function(s) { - /*jslint evil:true */ - return window['eval']('(' + s + ')'); - }; + // ordering of these callbacks/triggers is odd, but that's how $.ajax does it + if (status === 'success') { + if (s.success) + s.success.call(s.context, data, 'success', xhr); + deferred.resolve(xhr.responseText, 'success', xhr); + if (g) + $.event.trigger("ajaxSuccess", [xhr, s]); + } + else if (status) { + if (errMsg === undefined) + errMsg = xhr.statusText; + if (s.error) + s.error.call(s.context, xhr, status, errMsg); + deferred.reject(xhr, 'error', errMsg); + if (g) + $.event.trigger("ajaxError", [xhr, s, errMsg]); + } - var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4 + if (g) + $.event.trigger("ajaxComplete", [xhr, s]); - var ct = xhr.getResponseHeader('content-type') || '', - xml = type === 'xml' || !type && ct.indexOf('xml') >= 0, - data = xml ? xhr.responseXML : xhr.responseText; + if (g && ! --$.active) { + $.event.trigger("ajaxStop"); + } - if (xml && data.documentElement.nodeName === 'parsererror') { - if ($.error) - $.error('parsererror'); - } - if (s && s.dataFilter) { - data = s.dataFilter(data, type); - } - if (typeof data === 'string') { - if (type === 'json' || !type && ct.indexOf('json') >= 0) { - data = parseJSON(data); - } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) { - $.globalEval(data); - } - } - return data; - }; + if (s.complete) + s.complete.call(s.context, xhr, status); + + callbackProcessed = true; + if (s.timeout) + clearTimeout(timeoutHandle); + + // clean up + setTimeout(function() { + if (!s.iframeTarget) + $io.remove(); + xhr.responseXML = null; + }, 100); + } + + var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+) + if (window.ActiveXObject) { + doc = new ActiveXObject('Microsoft.XMLDOM'); + doc.async = 'false'; + doc.loadXML(s); + } + else { + doc = (new DOMParser()).parseFromString(s, 'text/xml'); + } + return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null; + }; + var parseJSON = $.parseJSON || function(s) { + /*jslint evil:true */ + return window['eval']('(' + s + ')'); + }; + + var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4 + + var ct = xhr.getResponseHeader('content-type') || '', + xml = type === 'xml' || !type && ct.indexOf('xml') >= 0, + data = xml ? xhr.responseXML : xhr.responseText; + + if (xml && data.documentElement.nodeName === 'parsererror') { + if ($.error) + $.error('parsererror'); + } + if (s && s.dataFilter) { + data = s.dataFilter(data, type); + } + if (typeof data === 'string') { + if (type === 'json' || !type && ct.indexOf('json') >= 0) { + data = parseJSON(data); + } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) { + $.globalEval(data); + } + } + return data; + }; - return deferred; + return deferred; } -}; - -/** - * ajaxForm() provides a mechanism for fully automating form submission. - * - * The advantages of using this method instead of ajaxSubmit() are: - * - * 1: This method will include coordinates for elements (if the element - * is used to submit the form). - * 2. This method will include the submit element's name/value data (for the element that was - * used to submit the form). - * 3. This method binds the submit() method to the form for you. - * - * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely - * passes the options argument along after properly binding events for submit elements and - * the form itself. - */ -$.fn.ajaxForm = function(options) { + }; + + /** + * ajaxForm() provides a mechanism for fully automating form submission. + * + * The advantages of using this method instead of ajaxSubmit() are: + * + * 1: This method will include coordinates for elements (if the element + * is used to submit the form). + * 2. This method will include the submit element's name/value data (for the element that was + * used to submit the form). + * 3. This method binds the submit() method to the form for you. + * + * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely + * passes the options argument along after properly binding events for submit elements and + * the form itself. + */ + $.fn.ajaxForm = function(options) { options = options || {}; options.delegation = options.delegation && $.isFunction($.fn.on); // in jQuery 1.3+ we can fix mistakes with the ready state if (!options.delegation && this.length === 0) { - var o = { s: this.selector, c: this.context }; - if (!$.isReady && o.s) { - log('DOM not ready, queuing ajaxForm'); - $(function() { - $(o.s,o.c).ajaxForm(options); - }); - return this; - } - // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() - log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); + var o = { s: this.selector, c: this.context }; + if (!$.isReady && o.s) { + log('DOM not ready, queuing ajaxForm'); + $(function() { + $(o.s,o.c).ajaxForm(options); + }); return this; + } + // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() + log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); + return this; } if ( options.delegation ) { - $(document) - .off('submit.form-plugin', this.selector, doAjaxSubmit) - .off('click.form-plugin', this.selector, captureSubmittingElement) - .on('submit.form-plugin', this.selector, options, doAjaxSubmit) - .on('click.form-plugin', this.selector, options, captureSubmittingElement); - return this; + $(document) + .off('submit.form-plugin', this.selector, doAjaxSubmit) + .off('click.form-plugin', this.selector, captureSubmittingElement) + .on('submit.form-plugin', this.selector, options, doAjaxSubmit) + .on('click.form-plugin', this.selector, options, captureSubmittingElement); + return this; } return this.ajaxFormUnbind() - .bind('submit.form-plugin', options, doAjaxSubmit) - .bind('click.form-plugin', options, captureSubmittingElement); -}; + .bind('submit.form-plugin', options, doAjaxSubmit) + .bind('click.form-plugin', options, captureSubmittingElement); + }; // private event handlers -function doAjaxSubmit(e) { + function doAjaxSubmit(e) { /*jshint validthis:true */ var options = e.data; if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed - e.preventDefault(); - $(this).ajaxSubmit(options); + e.preventDefault(); + $(this).ajaxSubmit(options); } -} + } -function captureSubmittingElement(e) { + function captureSubmittingElement(e) { /*jshint validthis:true */ var target = e.target; var $el = $(target); if (!($el.is("[type=submit],[type=image]"))) { - // is this a child element of the submit el? (ex: a span within a button) - var t = $el.closest('[type=submit]'); - if (t.length === 0) { - return; - } - target = t[0]; + // is this a child element of the submit el? (ex: a span within a button) + var t = $el.closest('[type=submit]'); + if (t.length === 0) { + return; + } + target = t[0]; } var form = this; form.clk = target; if (target.type == 'image') { - if (e.offsetX !== undefined) { - form.clk_x = e.offsetX; - form.clk_y = e.offsetY; - } else if (typeof $.fn.offset == 'function') { - var offset = $el.offset(); - form.clk_x = e.pageX - offset.left; - form.clk_y = e.pageY - offset.top; - } else { - form.clk_x = e.pageX - target.offsetLeft; - form.clk_y = e.pageY - target.offsetTop; - } + if (e.offsetX !== undefined) { + form.clk_x = e.offsetX; + form.clk_y = e.offsetY; + } else if (typeof $.fn.offset == 'function') { + var offset = $el.offset(); + form.clk_x = e.pageX - offset.left; + form.clk_y = e.pageY - offset.top; + } else { + form.clk_x = e.pageX - target.offsetLeft; + form.clk_y = e.pageY - target.offsetTop; + } } // clear form vars setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100); -} + } // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm -$.fn.ajaxFormUnbind = function() { + $.fn.ajaxFormUnbind = function() { return this.unbind('submit.form-plugin click.form-plugin'); -}; - -/** - * formToArray() gathers form element data into an array of objects that can - * be passed to any of the following ajax functions: $.get, $.post, or load. - * Each object in the array has both a 'name' and 'value' property. An example of - * an array for a simple login form might be: - * - * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] - * - * It is this array that is passed to pre-submit callback functions provided to the - * ajaxSubmit() and ajaxForm() methods. - */ -$.fn.formToArray = function(semantic, elements) { + }; + + /** + * formToArray() gathers form element data into an array of objects that can + * be passed to any of the following ajax functions: $.get, $.post, or load. + * Each object in the array has both a 'name' and 'value' property. An example of + * an array for a simple login form might be: + * + * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] + * + * It is this array that is passed to pre-submit callback functions provided to the + * ajaxSubmit() and ajaxForm() methods. + */ + $.fn.formToArray = function(semantic, elements) { var a = []; if (this.length === 0) { - return a; + return a; } var form = this[0]; var els = semantic ? form.getElementsByTagName('*') : form.elements; if (!els) { - return a; + return a; } var i,j,n,v,el,max,jmax; for(i=0, max=els.length; i < max; i++) { - el = els[i]; - n = el.name; - if (!n || el.disabled) { - continue; + el = els[i]; + n = el.name; + if (!n) { + continue; + } + + if (semantic && form.clk && el.type == "image") { + // handle image inputs on the fly when semantic == true + if(!el.disabled && form.clk == el) { + a.push({name: n, value: $(el).val(), type: el.type }); + a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); } - - if (semantic && form.clk && el.type == "image") { - // handle image inputs on the fly when semantic == true - if(form.clk == el) { - a.push({name: n, value: $(el).val(), type: el.type }); - a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); - } - continue; + continue; + } + + v = $.fieldValue(el, true); + if (v && v.constructor == Array) { + if (elements) + elements.push(el); + for(j=0, jmax=v.length; j < jmax; j++) { + a.push({name: n, value: v[j]}); } - - v = $.fieldValue(el, true); - if (v && v.constructor == Array) { - if (elements) - elements.push(el); - for(j=0, jmax=v.length; j < jmax; j++) { - a.push({name: n, value: v[j]}); - } + } + else if (feature.fileapi && el.type == 'file' && !el.disabled) { + if (elements) + elements.push(el); + var files = el.files; + if (files.length) { + for (j=0; j < files.length; j++) { + a.push({name: n, value: files[j], type: el.type}); + } } - else if (feature.fileapi && el.type == 'file') { - if (elements) - elements.push(el); - var files = el.files; - if (files.length) { - for (j=0; j < files.length; j++) { - a.push({name: n, value: files[j], type: el.type}); - } - } - else { - // #180 - a.push({ name: n, value: '', type: el.type }); - } + else { + // #180 + a.push({ name: n, value: '', type: el.type }); } - else if (v !== null && typeof v != 'undefined') { - if (elements) - elements.push(el); - a.push({name: n, value: v, type: el.type, required: el.required}); + } + else if (v !== null && typeof v != 'undefined') { + if (elements) + elements.push(el); + a.push({name: n, value: v, type: el.type, required: el.required}); } } if (!semantic && form.clk) { - // input type=='image' are not found in elements array! handle it here - var $input = $(form.clk), input = $input[0]; - n = input.name; - if (n && !input.disabled && input.type == 'image') { - a.push({name: n, value: $input.val()}); - a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); - } + // input type=='image' are not found in elements array! handle it here + var $input = $(form.clk), input = $input[0]; + n = input.name; + if (n && !input.disabled && input.type == 'image') { + a.push({name: n, value: $input.val()}); + a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); + } } return a; -}; + }; -/** - * Serializes form data into a 'submittable' string. This method will return a string - * in the format: name1=value1&name2=value2 - */ -$.fn.formSerialize = function(semantic) { + /** + * Serializes form data into a 'submittable' string. This method will return a string + * in the format: name1=value1&name2=value2 + */ + $.fn.formSerialize = function(semantic) { //hand off to jQuery.param for proper encoding return $.param(this.formToArray(semantic)); -}; + }; -/** - * Serializes all field elements in the jQuery object into a query string. - * This method will return a string in the format: name1=value1&name2=value2 - */ -$.fn.fieldSerialize = function(successful) { + /** + * Serializes all field elements in the jQuery object into a query string. + * This method will return a string in the format: name1=value1&name2=value2 + */ + $.fn.fieldSerialize = function(successful) { var a = []; this.each(function() { - var n = this.name; - if (!n) { - return; - } - var v = $.fieldValue(this, successful); - if (v && v.constructor == Array) { - for (var i=0,max=v.length; i < max; i++) { - a.push({name: n, value: v[i]}); - } - } - else if (v !== null && typeof v != 'undefined') { - a.push({name: this.name, value: v}); + var n = this.name; + if (!n) { + return; + } + var v = $.fieldValue(this, successful); + if (v && v.constructor == Array) { + for (var i=0,max=v.length; i < max; i++) { + a.push({name: n, value: v[i]}); } + } + else if (v !== null && typeof v != 'undefined') { + a.push({name: this.name, value: v}); + } }); //hand off to jQuery.param for proper encoding return $.param(a); -}; - -/** - * Returns the value(s) of the element in the matched set. For example, consider the following form: - * - *
- * - * var v = $('input[type=text]').fieldValue(); - * // if no values are entered into the text inputs - * v == ['',''] - * // if values entered into the text inputs are 'foo' and 'bar' - * v == ['foo','bar'] - * - * var v = $('input[type=checkbox]').fieldValue(); - * // if neither checkbox is checked - * v === undefined - * // if both checkboxes are checked - * v == ['B1', 'B2'] - * - * var v = $('input[type=radio]').fieldValue(); - * // if neither radio is checked - * v === undefined - * // if first radio is checked - * v == ['C1'] - * - * The successful argument controls whether or not the field element must be 'successful' - * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). - * The default value of the successful argument is true. If this value is false the value(s) - * for each element is returned. - * - * Note: This method *always* returns an array. If no valid value can be determined the - * array will be empty, otherwise it will contain one or more values. - */ -$.fn.fieldValue = function(successful) { + }; + + /** + * Returns the value(s) of the element in the matched set. For example, consider the following form: + * + * + * + * var v = $('input[type=text]').fieldValue(); + * // if no values are entered into the text inputs + * v == ['',''] + * // if values entered into the text inputs are 'foo' and 'bar' + * v == ['foo','bar'] + * + * var v = $('input[type=checkbox]').fieldValue(); + * // if neither checkbox is checked + * v === undefined + * // if both checkboxes are checked + * v == ['B1', 'B2'] + * + * var v = $('input[type=radio]').fieldValue(); + * // if neither radio is checked + * v === undefined + * // if first radio is checked + * v == ['C1'] + * + * The successful argument controls whether or not the field element must be 'successful' + * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). + * The default value of the successful argument is true. If this value is false the value(s) + * for each element is returned. + * + * Note: This method *always* returns an array. If no valid value can be determined the + * array will be empty, otherwise it will contain one or more values. + */ + $.fn.fieldValue = function(successful) { for (var val=[], i=0, max=this.length; i < max; i++) { - var el = this[i]; - var v = $.fieldValue(el, successful); - if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) { - continue; - } - if (v.constructor == Array) - $.merge(val, v); - else - val.push(v); + var el = this[i]; + var v = $.fieldValue(el, successful); + if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) { + continue; + } + if (v.constructor == Array) + $.merge(val, v); + else + val.push(v); } return val; -}; + }; -/** - * Returns the value of the field element. - */ -$.fieldValue = function(el, successful) { + /** + * Returns the value of the field element. + */ + $.fieldValue = function(el, successful) { var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); if (successful === undefined) { - successful = true; + successful = true; } if (successful && (!n || el.disabled || t == 'reset' || t == 'button' || - (t == 'checkbox' || t == 'radio') && !el.checked || - (t == 'submit' || t == 'image') && el.form && el.form.clk != el || - tag == 'select' && el.selectedIndex == -1)) { - return null; + (t == 'checkbox' || t == 'radio') && !el.checked || + (t == 'submit' || t == 'image') && el.form && el.form.clk != el || + tag == 'select' && el.selectedIndex == -1)) { + return null; } if (tag == 'select') { - var index = el.selectedIndex; - if (index < 0) { - return null; - } - var a = [], ops = el.options; - var one = (t == 'select-one'); - var max = (one ? index+1 : ops.length); - for(var i=(one ? index : 0); i < max; i++) { - var op = ops[i]; - if (op.selected) { - var v = op.value; - if (!v) { // extra pain for IE... - v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value; - } - if (one) { - return v; - } - a.push(v); - } + var index = el.selectedIndex; + if (index < 0) { + return null; + } + var a = [], ops = el.options; + var one = (t == 'select-one'); + var max = (one ? index+1 : ops.length); + for(var i=(one ? index : 0); i < max; i++) { + var op = ops[i]; + if (op.selected) { + var v = op.value; + if (!v) { // extra pain for IE... + v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value; + } + if (one) { + return v; + } + a.push(v); } - return a; + } + return a; } return $(el).val(); -}; - -/** - * Clears the form data. Takes the following actions on the form's input fields: - * - input text fields will have their 'value' property set to the empty string - * - select elements will have their 'selectedIndex' property set to -1 - * - checkbox and radio inputs will have their 'checked' property set to false - * - inputs of type submit, button, reset, and hidden will *not* be effected - * - button elements will *not* be effected - */ -$.fn.clearForm = function(includeHidden) { + }; + + /** + * Clears the form data. Takes the following actions on the form's input fields: + * - input text fields will have their 'value' property set to the empty string + * - select elements will have their 'selectedIndex' property set to -1 + * - checkbox and radio inputs will have their 'checked' property set to false + * - inputs of type submit, button, reset, and hidden will *not* be effected + * - button elements will *not* be effected + */ + $.fn.clearForm = function(includeHidden) { return this.each(function() { - $('input,select,textarea', this).clearFields(includeHidden); + $('input,select,textarea', this).clearFields(includeHidden); }); -}; + }; -/** - * Clears the selected form elements. - */ -$.fn.clearFields = $.fn.clearInputs = function(includeHidden) { + /** + * Clears the selected form elements. + */ + $.fn.clearFields = $.fn.clearInputs = function(includeHidden) { var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list return this.each(function() { - var t = this.type, tag = this.tagName.toLowerCase(); - if (re.test(t) || tag == 'textarea') { - this.value = ''; - } - else if (t == 'checkbox' || t == 'radio') { - this.checked = false; + var t = this.type, tag = this.tagName.toLowerCase(); + if (re.test(t) || tag == 'textarea') { + this.value = ''; + } + else if (t == 'checkbox' || t == 'radio') { + this.checked = false; + } + else if (tag == 'select') { + this.selectedIndex = -1; } - else if (tag == 'select') { - this.selectedIndex = -1; - } - else if (t == "file") { - if (/MSIE/.test(navigator.userAgent)) { - $(this).replaceWith($(this).clone(true)); - } else { - $(this).val(''); - } - } - else if (includeHidden) { - // includeHidden can be the value true, or it can be a selector string - // indicating a special test; for example: - // $('#myForm').clearForm('.special:hidden') - // the above would clean hidden inputs that have the class of 'special' - if ( (includeHidden === true && /hidden/.test(t)) || - (typeof includeHidden == 'string' && $(this).is(includeHidden)) ) + else if (t == "file") { + if (/MSIE/.test(navigator.userAgent)) { + $(this).replaceWith($(this).clone()); + } else { + $(this).val(''); + } + } + else if (includeHidden) { + // includeHidden can be the value true, or it can be a selector string + // indicating a special test; for example: + // $('#myForm').clearForm('.special:hidden') + // the above would clean hidden inputs that have the class of 'special' + if ( (includeHidden === true && /hidden/.test(t)) || + (typeof includeHidden == 'string' && $(this).is(includeHidden)) ) this.value = ''; - } + } }); -}; + }; -/** - * Resets the form data. Causes all form elements to be reset to their original value. - */ -$.fn.resetForm = function() { + /** + * Resets the form data. Causes all form elements to be reset to their original value. + */ + $.fn.resetForm = function() { return this.each(function() { - // guard against an input with the name of 'reset' - // note that IE reports the reset function as an 'object' - if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) { - this.reset(); - } + // guard against an input with the name of 'reset' + // note that IE reports the reset function as an 'object' + if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) { + this.reset(); + } }); -}; + }; -/** - * Enables or disables any matching elements. - */ -$.fn.enable = function(b) { + /** + * Enables or disables any matching elements. + */ + $.fn.enable = function(b) { if (b === undefined) { - b = true; + b = true; } return this.each(function() { - this.disabled = !b; + this.disabled = !b; }); -}; + }; -/** - * Checks/unchecks any matching checkboxes or radio buttons and - * selects/deselects and matching option elements. - */ -$.fn.selected = function(select) { + /** + * Checks/unchecks any matching checkboxes or radio buttons and + * selects/deselects and matching option elements. + */ + $.fn.selected = function(select) { if (select === undefined) { - select = true; + select = true; } return this.each(function() { - var t = this.type; - if (t == 'checkbox' || t == 'radio') { - this.checked = select; - } - else if (this.tagName.toLowerCase() == 'option') { - var $sel = $(this).parent('select'); - if (select && $sel[0] && $sel[0].type == 'select-one') { - // deselect all other options - $sel.find('option').selected(false); - } - this.selected = select; + var t = this.type; + if (t == 'checkbox' || t == 'radio') { + this.checked = select; + } + else if (this.tagName.toLowerCase() == 'option') { + var $sel = $(this).parent('select'); + if (select && $sel[0] && $sel[0].type == 'select-one') { + // deselect all other options + $sel.find('option').selected(false); } + this.selected = select; + } }); -}; + }; // expose debug var -$.fn.ajaxSubmit.debug = false; + $.fn.ajaxSubmit.debug = false; // helper fn for console logging -function log() { + function log() { if (!$.fn.ajaxSubmit.debug) - return; + return; var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,''); if (window.console && window.console.log) { - window.console.log(msg); + window.console.log(msg); } else if (window.opera && window.opera.postError) { - window.opera.postError(msg); + window.opera.postError(msg); } -} + } -})( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto ); +})(jQuery); diff --git a/core/assets/vendor/jquery/jquery.js b/core/assets/vendor/jquery/jquery.js index ebc6c18..f389a3e 100644 --- a/core/assets/vendor/jquery/jquery.js +++ b/core/assets/vendor/jquery/jquery.js @@ -1,5 +1,5 @@ /*! - * jQuery JavaScript Library v2.0.3 + * jQuery JavaScript Library v2.0.0 * http://jquery.com/ * * Includes Sizzle.js @@ -9,7 +9,7 @@ * Released under the MIT license * http://jquery.org/license * - * Date: 2013-07-03T13:30Z + * Date: 2013-04-18 */ (function( window, undefined ) { @@ -46,7 +46,7 @@ var // List of deleted data cache ids, so we can reuse them core_deletedIds = [], - core_version = "2.0.3", + core_version = "2.0.0", // Save a reference to some core methods core_concat = core_deletedIds.concat, @@ -72,7 +72,7 @@ var // A simple way to check for HTML strings // Prioritize #id over' . t('This page provides a drag-and-drop interface for adding a block to a region, and for controlling the order of blocks within regions. To add a block to a region, or to configure its specific title and visibility settings, click the block title under Place blocks. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the Save blocks button at the bottom of the page.') . '
'; + $output = '' . t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the Save blocks button at the bottom of the page. Click the configure link next to each block to configure its specific title and visibility settings.') . '
'; $output .= '' . l(t('Demonstrate block regions (@theme)', array('@theme' => $themes[$demo_theme]->info['name'])), 'admin/structure/block/demo/' . $demo_theme) . '
'; return $output; } @@ -109,7 +109,7 @@ function block_permission() { * @todo Clarify the documentation for the per-plugin block admin links. */ function block_menu() { - $default_theme = Drupal::config('system.theme')->get('default'); + $default_theme = config('system.theme')->get('default'); $items['admin/structure/block'] = array( 'title' => 'Blocks', 'description' => 'Configure what block content appears in your site\'s sidebars and other regions.', @@ -130,34 +130,34 @@ function block_menu() { 'context' => MENU_CONTEXT_NONE, 'route_name' => 'block_admin_block_delete', ); - $items['admin/structure/block/add/%/%'] = array( - 'title' => 'Place block', - 'type' => MENU_VISIBLE_IN_BREADCRUMB, - 'route_name' => 'block_admin_add', - ); // Block administration is tied to the theme and plugin definition so // that the plugin can appropriately attach to this URL structure. // @todo D8: Use dynamic % arguments instead of static, hard-coded theme names // and plugin IDs to decouple the routes from these dependencies and allow // hook_menu_local_tasks() to check for the untranslated tab_parent path. // @see http://drupal.org/node/1067408 - foreach (list_themes() as $key => $theme) { - $items["admin/structure/block/list/$key"] = array( - 'title' => check_plain($theme->info['name']), - 'type' => $key == $default_theme ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, - 'route_name' => "block_admin_display.$key", - ); - $items["admin/structure/block/demo/$key"] = array( - 'title' => check_plain($theme->info['name']), - 'page callback' => 'block_admin_demo', - 'page arguments' => array($key), - 'type' => MENU_CALLBACK, - 'access callback' => '_block_themes_access', - 'access arguments' => array($key), - 'theme callback' => '_block_custom_theme', - 'theme arguments' => array($key), - 'file' => 'block.admin.inc', - ); + $themes = list_themes(); + foreach (drupal_container()->get('plugin.manager.system.plugin_ui')->getDefinitions() as $plugin_id => $plugin) { + list($plugin_base, $key) = explode(':', $plugin_id); + if ($plugin_base == 'block_plugin_ui') { + $theme = $themes[$key]; + $items['admin/structure/block/list/' . $plugin_id] = array( + 'title' => check_plain($theme->info['name']), + 'type' => $key == $default_theme ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, + 'route_name' => 'block_admin_display.' . $plugin_id + ); + $items['admin/structure/block/demo/' . $key] = array( + 'title' => check_plain($theme->info['name']), + 'page callback' => 'block_admin_demo', + 'page arguments' => array($key), + 'type' => MENU_CALLBACK, + 'access callback' => '_block_themes_access', + 'access arguments' => array($key), + 'theme callback' => '_block_custom_theme', + 'theme arguments' => array($key), + 'file' => 'block.admin.inc', + ); + } } return $items; } @@ -232,23 +232,26 @@ function block_page_build(&$page) { } else { // Append region description if we are rendering the regions demo page. - $visible_regions = array_keys(system_region_list($theme, REGIONS_VISIBLE)); - foreach ($visible_regions as $region) { - $description = '' . t('This page lists user-created blocks. These blocks are derived from block types. A block type can consist of different fields and display settings. From the block types tab you can manage these fields as well as create new block types.') . '
'; - return $output; - - case 'admin/structure/custom-blocks/types': - $output = '' . t('This page lists block types. A block type can consist of different fields and display settings. From here you can manage these fields as well as create new block types.') . '
'; - return $output; - - } -} - -/** * Implements hook_menu_local_tasks(). */ function custom_block_menu_local_tasks(&$data, $router_item, $root_path) { - if ($router_item['route_name'] == 'custom_block_list') { - // @todo Move to a LocalAction plugin when https://drupal.org/node/2045267 - // allows local actions to work with query strings. + // Add the "Add custom block" action link to the theme-specific block library + // listing page. + // @todo This should just be $root_path == 'admin/structure/block/list/%/add' + // but block_menu() registers static router paths instead of dynamic ones. + if (preg_match('@^admin/structure/block/list/(.*)/add$@', $root_path)) { $item = menu_get_item('block/add'); if ($item['access']) { - // Add a destination parameter. - $item['localized_options']['query']['destination'] = 'admin/structure/custom-blocks'; $data['actions']['block/add'] = array( '#theme' => 'menu_local_action', '#link' => $item, @@ -47,37 +28,15 @@ function custom_block_menu_local_tasks(&$data, $router_item, $root_path) { } /** - * Implements hook_menu_local_actions_alter(). - */ -function custom_block_menu_local_actions_alter(&$actions) { - if (isset($actions['local_action_static:custom_block_add_action'])) { - foreach (list_themes() as $theme => $theme_info) { - if ($theme_info->status) { - $actions['local_action_static:custom_block_add_action']['appears_on'][] = "block_admin_display.$theme"; - } - } - } -} - -/** * Implements hook_menu(). */ function custom_block_menu() { $items['admin/structure/custom-blocks'] = array( - 'title' => 'Custom blocks', - 'description' => 'Manage custom blocks.', - 'route_name' => 'custom_block_list', - ); - $items['admin/structure/custom-blocks/list'] = array( - 'title' => 'Blocks', - 'type' => MENU_DEFAULT_LOCAL_TASK, - ); - $items['admin/structure/custom-blocks/types'] = array( - 'title' => 'Types', + 'title' => 'Custom block types', + 'description' => 'Manage custom block types.', 'route_name' => 'custom_block_type_list', - 'type' => MENU_LOCAL_TASK, ); - $items['admin/structure/custom-blocks/types/add'] = array( + $items['admin/structure/custom-blocks/add'] = array( 'route_name' => 'custom_block_type_add', 'type' => MENU_SIBLING_LOCAL_TASK, 'weight' => 1, @@ -134,6 +93,21 @@ function custom_block_menu() { } /** + * Implements hook_local_actions(). + */ +function custom_block_local_actions() { + return array( + array( + 'route_name' => 'custom_block_type_add', + 'title' => t('Add custom block type'), + 'appears_on' => array( + 'custom_block_type_list', + ), + ), + ); +} + +/** * Implements hook_theme(). */ function custom_block_theme($existing, $type, $theme, $path) { @@ -188,7 +162,7 @@ function custom_block_entity_info_alter(&$types) { function custom_block_entity_bundle_info() { $bundles = array(); foreach (config_get_storage_names_with_prefix('custom_block.type.') as $config_name) { - $config = Drupal::config($config_name); + $config = config($config_name); $bundles['custom_block'][$config->get('id')]['label'] = $config->get('label'); } return $bundles; @@ -247,13 +221,34 @@ function custom_block_add_body_field($block_type_id, $label = 'Block body') { } /** + * Implements hook_form_FORM_ID_alter() for block_plugin_ui(). + */ +function custom_block_form_block_plugin_ui_alter(&$form, $form_state) { + foreach ($form['left']['plugin_library']['#rows'] as $plugin_id => &$row) { + // @todo Clean up when http://drupal.org/node/1874498 lands. + if (strpos($plugin_id, ':') === FALSE) { + continue; + } + list($base, $derivative) = explode(':', $plugin_id); + if ($base !== 'custom_block') { + continue; + } + $custom_block = entity_load_by_uuid('custom_block', $derivative); + $row['1']['data']['#links']['edit'] = array( + 'title' => t('Edit'), + 'href' => 'block/' . $custom_block->id(), + ); + } +} + +/** * Implements hook_admin_paths(). */ function custom_block_admin_paths() { $paths = array( 'block/add' => TRUE, 'block/add/*' => TRUE, - 'block/*' => TRUE, + 'block/*/edit' => TRUE, 'block/*/delete' => TRUE, 'admin/structure/custom-blocks/*' => TRUE, ); diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block/custom_block/custom_block.pages.inc index e50b297..ae7de30 100644 --- a/core/modules/block/custom_block/custom_block.pages.inc +++ b/core/modules/block/custom_block/custom_block.pages.inc @@ -24,14 +24,7 @@ function template_preprocess_custom_block_add_list(&$variables) { $variables['types'] = array(); foreach ($variables['content'] as $type) { $variables['types'][$type->id] = array(); - $query = array(); - if (($destination = drupal_get_destination()) && $destination['destination'] !== current_path()) { - // A destination parameter is set other than the current path so we - // respect that by adding it to the generated links. If the current path - // is returned, we ignore it as we don't want to end up back at block/add. - $query = $destination; - } - $variables['types'][$type->id]['link'] = l($type->label(), 'block/add/' . $type->id(), array('query' => $query)); + $variables['types'][$type->id]['link'] = l($type->label(), 'block/add/' . $type->id()); $variables['types'][$type->id]['description'] = filter_xss_admin($type->description); } } @@ -80,5 +73,5 @@ function custom_block_delete_form_submit($form, &$form_state) { drupal_set_message(t('Custom block %label has been deleted.', array('%label' => $block->label()))); watchdog('custom_block', 'Custom block %label has been deleted.', array('%label' => $block->label()), WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/custom-blocks'; + $form_state['redirect'] = 'admin/structure/block'; } diff --git a/core/modules/block/custom_block/custom_block.routing.yml b/core/modules/block/custom_block/custom_block.routing.yml index 52e1575..02bad13 100644 --- a/core/modules/block/custom_block/custom_block.routing.yml +++ b/core/modules/block/custom_block/custom_block.routing.yml @@ -1,5 +1,5 @@ custom_block_type_list: - pattern: '/admin/structure/custom-blocks/types' + pattern: '/admin/structure/custom-blocks' defaults: _entity_list: 'custom_block_type' requirements: @@ -35,7 +35,7 @@ custom_block_edit: custom_block: \d+ custom_block_type_add: - pattern: '/admin/structure/custom-blocks/types/add' + pattern: '/admin/structure/custom-blocks/add' defaults: _entity_form: 'custom_block_type.add' requirements: @@ -47,10 +47,3 @@ custom_block_type_edit: _entity_form: 'custom_block_type.edit' requirements: _entity_access: 'custom_block_type.update' - -custom_block_list: - pattern: '/admin/structure/custom-blocks' - defaults: - _entity_list: 'custom_block' - requirements: - _permission: 'administer blocks' diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php index eb58dd6..9ccf371 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php @@ -187,11 +187,11 @@ public function save(array $form, array &$form_state) { $form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->uuid->value . '/' . $theme; } else { - $form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->uuid->value . '/' . \Drupal::config('system.theme')->get('default'); + $form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->uuid->value . '/' . config('system.theme')->get('default'); } } else { - $form_state['redirect'] = 'admin/structure/custom-blocks'; + $form_state['redirect'] = 'admin/structure/block'; } } else { @@ -219,19 +219,4 @@ public function delete(array $form, array &$form_state) { $form_state['redirect'] = array('block/' . $block->id() . '/delete', array('query' => $destination)); } - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, array &$form_state) { - if ($this->entity->isNew()) { - // @todo Inject this once https://drupal.org/node/2060865 is in. - $exists = \Drupal::entityManager()->getStorageController('custom_block')->loadByProperties(array('info' => $form_state['values']['info'])); - if (!empty($exists)) { - form_set_error('info', t('A block with description %name already exists.', array( - '%name' => $form_state['values']['info'] - ))); - } - } - } - } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockListController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockListController.php deleted file mode 100644 index d2429b6..0000000 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockListController.php +++ /dev/null @@ -1,51 +0,0 @@ -uri(); - $operations['edit']['href'] = $uri['path']; - $operations['edit']['query']['destination'] = 'admin/structure/custom-blocks'; - } - return $operations; - } - -} diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php index 06e92a5..a98730e 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php @@ -101,7 +101,7 @@ public function save(array $form, array &$form_state) { watchdog('custom_block', 'Custom block type %label has been added.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit')); } - $form_state['redirect'] = 'admin/structure/custom-blocks/types'; + $form_state['redirect'] = 'admin/structure/custom-blocks'; } /** diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php index ed44d75..aaf2676 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php @@ -66,13 +66,4 @@ public function buildRow(EntityInterface $entity) { return $row; } - /** - * {@inheritdoc} - */ - public function render() { - // @todo Remove this once https://drupal.org/node/2032535 is in. - drupal_set_title(t('Custom block types')); - return parent::render(); - } - } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php index 4b7c220..7e595d2 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php @@ -60,7 +60,7 @@ public function getQuestion() { * {@inheritdoc} */ public function getCancelPath() { - return 'admin/structure/custom-blocks/types'; + return 'admin/structure/custom-blocks'; } /** @@ -90,7 +90,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU */ public function submit(array $form, array &$form_state) { $this->entity->delete(); - $form_state['redirect'] = 'admin/structure/custom-blocks/types'; + $form_state['redirect'] = 'admin/structure/custom-blocks'; drupal_set_message(t('Custom block type %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('custom_block', 'Custom block type %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php index 97722f6..6bc0f4d 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php @@ -24,7 +24,6 @@ * controllers = { * "storage" = "Drupal\custom_block\CustomBlockStorageController", * "access" = "Drupal\custom_block\CustomBlockAccessController", - * "list" = "Drupal\custom_block\CustomBlockListController", * "render" = "Drupal\custom_block\CustomBlockRenderController", * "form" = { * "add" = "Drupal\custom_block\CustomBlockFormController", diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php index 3ce4513..8beda0b 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php @@ -64,16 +64,6 @@ public function testCustomBlockCreation() { $blocks = entity_load_multiple_by_properties('custom_block', array('info' => $edit['info'])); $block = reset($blocks); $this->assertTrue($block, 'Custom Block found in database.'); - - // Check that attempting to create another block with the same value for - // 'info' returns an error. - $this->drupalPost('block/add/basic', $edit, t('Save')); - - // Check that the Basic block has been created. - $this->assertRaw(format_string('A block with description %name already exists.', array( - '%name' => $edit["info"] - ))); - $this->assertResponse(200); } /** @@ -157,9 +147,7 @@ public function testBlockDelete() { 'settings[label]' => $edit['info'], 'region' => 'sidebar_first', ); - $block = entity_load('custom_block', 1); - $url = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default'); - $this->drupalPost($url, $instance, t('Save block')); + $this->drupalPost(NULL, $instance, t('Save block')); $block = custom_block_load(1); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php index 7c1d7d5..da5ac4f 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php @@ -99,15 +99,13 @@ public function testBlockFields() { $this->field['field_name'] . '[und][0][title]' => 'Example.com' ); $this->drupalPost(NULL, $edit, t('Save')); - $block = entity_load('custom_block', 1); - $url = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default'); // Place the block. $instance = array( 'machine_name' => drupal_strtolower($edit['info']), 'settings[label]' => $edit['info'], 'region' => 'sidebar_first', ); - $this->drupalPost($url, $instance, t('Save block')); + $this->drupalPost(NULL, $instance, t('Save block')); // Navigate to home page. $this->drupalGet(' -
-
-
',
- ),
- ));
- $filter_format->save();
- }
-
/**
* Tests comment preview.
*/
@@ -73,7 +47,7 @@ function testCommentPreview() {
// Login as web user and add a signature and a user picture.
$this->drupalLogin($this->web_user);
- \Drupal::config('user.settings')->set('signatures', 1)->save();
+ config('user.settings')->set('signatures', 1)->save();
$test_signature = $this->randomName();
$edit['signature[value]'] = '' . $test_signature. '';
$image = current($this->drupalGetTestFiles('image'));
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php
index a8ca042..d4c170c 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php
@@ -37,7 +37,7 @@ function testCRUD() {
$storage = $this->container->get('config.storage');
$name = 'config_test.crud';
- $config = \Drupal::config($name);
+ $config = config($name);
$this->assertIdentical($config->isNew(), TRUE);
// Create a new configuration object.
@@ -58,8 +58,8 @@ function testCRUD() {
$actual_data = $storage->read($name);
$this->assertIdentical($actual_data, array('value' => 'instance-update'));
- // Verify a call to \Drupal::config() immediately returns the updated value.
- $new_config = \Drupal::config($name);
+ // Verify a call to config() immediately returns the updated value.
+ $new_config = config($name);
$this->assertIdentical($new_config->get(), $config->get());
$this->assertIdentical($config->isNew(), FALSE);
@@ -74,8 +74,8 @@ function testCRUD() {
$actual_data = $storage->read($name);
$this->assertIdentical($actual_data, FALSE);
- // Verify \Drupal::config() returns no data.
- $new_config = \Drupal::config($name);
+ // Verify config() returns no data.
+ $new_config = config($name);
$this->assertIdentical($new_config->get(), $config->get());
$this->assertIdentical($config->isNew(), TRUE);
@@ -88,36 +88,36 @@ function testCRUD() {
$actual_data = $storage->read($name);
$this->assertIdentical($actual_data, array('value' => 're-created'));
- // Verify a call to \Drupal::config() immediately returns the updated value.
- $new_config = \Drupal::config($name);
+ // Verify a call to config() immediately returns the updated value.
+ $new_config = config($name);
$this->assertIdentical($new_config->get(), $config->get());
$this->assertIdentical($config->isNew(), FALSE);
// Rename the configuration object.
$new_name = 'config_test.crud_rename';
$this->container->get('config.factory')->rename($name, $new_name);
- $renamed_config = \Drupal::config($new_name);
+ $renamed_config = config($new_name);
$this->assertIdentical($renamed_config->get(), $config->get());
$this->assertIdentical($renamed_config->isNew(), FALSE);
// Ensure that the old configuration object is removed from both the cache
// and the configuration storage.
- $config = \Drupal::config($name);
+ $config = config($name);
$this->assertIdentical($config->get(), array());
$this->assertIdentical($config->isNew(), TRUE);
// Test renaming when config.factory does not have the object in its static
// cache.
$name = 'config_test.crud_rename';
- $config = \Drupal::config($name);
+ $config = config($name);
$new_name = 'config_test.crud_rename_no_cache';
$this->container->get('config.factory')->clearStaticCache()->rename($name, $new_name);
- $renamed_config = \Drupal::config($new_name);
+ $renamed_config = config($new_name);
$this->assertIdentical($renamed_config->get(), $config->get());
$this->assertIdentical($renamed_config->isNew(), FALSE);
// Merge data into the configuration object.
- $new_config = \Drupal::config($new_name);
+ $new_config = config($new_name);
$expected_values = array(
'value' => 'herp',
'404' => 'derp',
@@ -136,7 +136,7 @@ function testNameValidation() {
$name = 'nonamespace';
$message = 'Expected ConfigNameException was thrown for a name without a namespace.';
try {
- \Drupal::config($name)->save();
+ config($name)->save();
$this->fail($message);
}
catch (ConfigNameException $e) {
@@ -147,7 +147,7 @@ function testNameValidation() {
$name = 'config_test.herman_melville.moby_dick_or_the_whale.harper_1851.now_small_fowls_flew_screaming_over_the_yet_yawning_gulf_a_sullen_white_surf_beat_against_its_steep_sides_then_all_collapsed_and_the_great_shroud_of_the_sea_rolled_on_as_it_rolled_five_thousand_years_ago';
$message = 'Expected ConfigNameException was thrown for a name longer than Config::MAX_NAME_LENGTH.';
try {
- \Drupal::config($name)->save();
+ config($name)->save();
$this->fail($message);
}
catch (ConfigNameException $e) {
@@ -159,7 +159,7 @@ function testNameValidation() {
foreach ($test_characters as $i => $c) {
try {
$name = 'namespace.object' . $c;
- $config = \Drupal::config($name);
+ $config = config($name);
$config->save();
}
catch (ConfigNameException $e) {
@@ -174,7 +174,7 @@ function testNameValidation() {
$name = 'namespace.object';
$message = 'ConfigNameException was not thrown for a valid object name.';
try {
- $config = \Drupal::config($name);
+ $config = config($name);
$config->save();
$this->pass($message);
}
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
index f97d6cf..7917731 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
@@ -166,11 +166,11 @@ function testListUI() {
$this->assertTitle('Test configuration | Drupal');
// Test for the table.
- $element = $this->xpath('//div[@class="l-content"]//table');
+ $element = $this->xpath('//div[@id="content"]//table');
$this->assertTrue($element, 'Configuration entity list table found.');
// Test the table header.
- $elements = $this->xpath('//div[@class="l-content"]//table/thead/tr/th');
+ $elements = $this->xpath('//div[@id="content"]//table/thead/tr/th');
$this->assertEqual(count($elements), 3, 'Correct number of table header cells found.');
// Test the contents of each th cell.
@@ -180,7 +180,7 @@ function testListUI() {
}
// Check the number of table row cells.
- $elements = $this->xpath('//div[@class="l-content"]//table/tbody/tr[@class="odd"]/td');
+ $elements = $this->xpath('//div[@id="content"]//table/tbody/tr[@class="odd"]/td');
$this->assertEqual(count($elements), 3, 'Correct number of table row cells found.');
// Check the contents of each row cell. The first cell contains the label,
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php
index ef840b3..f2e7965 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php
@@ -52,7 +52,7 @@ function testReadWriteConfig() {
$false_key = 'false';
// Attempt to read non-existing configuration.
- $config = \Drupal::config($name);
+ $config = config($name);
// Verify an configuration object is returned.
$this->assertEqual($config->getName(), $name);
@@ -66,7 +66,7 @@ function testReadWriteConfig() {
$this->assertIdentical($data, FALSE);
// Add a top level value
- $config = \Drupal::config($name);
+ $config = config($name);
$config->set($key, $value);
// Add a nested value
@@ -96,7 +96,7 @@ function testReadWriteConfig() {
$this->assertTrue($data);
// Read top level value
- $config = \Drupal::config($name);
+ $config = config($name);
$this->assertEqual($config->getName(), $name);
$this->assertTrue($config, 'Config object created.');
$this->assertEqual($config->get($key), 'bar', 'Top level configuration value found.');
@@ -134,7 +134,7 @@ function testReadWriteConfig() {
// Unset a nested value
$config->clear($nested_key);
$config->save();
- $config = \Drupal::config($name);
+ $config = config($name);
// Read unset top level value
$this->assertNull($config->get($key), 'Top level value unset.');
@@ -143,13 +143,13 @@ function testReadWriteConfig() {
$this->assertNull($config->get($nested_key), 'Nested value unset.');
// Create two new configuration files to test listing
- $config = \Drupal::config('foo.baz');
+ $config = config('foo.baz');
$config->set($key, $value);
$config->save();
// Test chained set()->save()
$chained_name = 'biff.bang';
- $config = \Drupal::config($chained_name);
+ $config = config($chained_name);
$config->set($key, $value)->save();
// Verify the database entry exists from a chained save.
@@ -177,7 +177,7 @@ function testReadWriteConfig() {
$this->assertEqual($files, array(), 'No files listed with the prefix \'bar\'.');
// Delete the configuration.
- $config = \Drupal::config($name);
+ $config = config($name);
$config->delete();
// Verify the database entry no longer exists.
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
index 59cd19c..9184bfb 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
@@ -80,10 +80,10 @@ function testImport() {
$this->assertText(t('There are no configuration changes.'));
// Verify site name has changed.
- $this->assertIdentical($new_site_name, \Drupal::config('system.site')->get('name'));
+ $this->assertIdentical($new_site_name, config('system.site')->get('name'));
// Verify that new config entity exists.
- $this->assertIdentical($original_dynamic_data, \Drupal::config($dynamic_name)->get());
+ $this->assertIdentical($original_dynamic_data, config($dynamic_name)->get());
// Verify the cache got cleared.
$this->assertTrue(isset($GLOBALS['hook_cache_flush']));
@@ -113,7 +113,7 @@ function testImportLock() {
$this->container->get('lock')->release($config_importer_lock);
// Verify site name has not changed.
- $this->assertNotEqual($new_site_name, \Drupal::config('system.site')->get('name'));
+ $this->assertNotEqual($new_site_name, config('system.site')->get('name'));
}
/**
@@ -163,7 +163,7 @@ function testImportDiff() {
function prepareSiteNameUpdate($new_site_name) {
$staging = $this->container->get('config.storage.staging');
// Create updated configuration object.
- $config_data = \Drupal::config('system.site')->get();
+ $config_data = config('system.site')->get();
$config_data['name'] = $new_site_name;
$staging->write('system.site', $config_data);
}
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php
index f51e221..05d8919 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php
@@ -72,10 +72,10 @@ function testNoImport() {
$dynamic_name = 'config_test.dynamic.dotted.default';
// Verify the default configuration values exist.
- $config = \Drupal::config($dynamic_name);
+ $config = config($dynamic_name);
$this->assertIdentical($config->get('id'), 'dotted.default');
- // Verify that a bare \Drupal::config() does not involve module APIs.
+ // Verify that a bare config() does not involve module APIs.
$this->assertFalse(isset($GLOBALS['hook_config_test']));
}
@@ -103,7 +103,7 @@ function testDeleted() {
$staging = $this->container->get('config.storage.staging');
// Verify the default configuration values exist.
- $config = \Drupal::config($dynamic_name);
+ $config = config($dynamic_name);
$this->assertIdentical($config->get('id'), 'dotted.default');
// Delete the file from the staging directory.
@@ -115,7 +115,7 @@ function testDeleted() {
// Verify the file has been removed.
$this->assertIdentical($storage->read($dynamic_name), FALSE);
- $config = \Drupal::config($dynamic_name);
+ $config = config($dynamic_name);
$this->assertIdentical($config->get('id'), NULL);
// Verify that appropriate module API hooks have been invoked.
@@ -160,7 +160,7 @@ function testNew() {
$this->configImporter->reset()->import();
// Verify the values appeared.
- $config = \Drupal::config($dynamic_name);
+ $config = config($dynamic_name);
$this->assertIdentical($config->get('label'), $original_dynamic_data['label']);
// Verify that appropriate module API hooks have been invoked.
@@ -199,18 +199,18 @@ function testUpdated() {
$staging->write($dynamic_name, $original_dynamic_data);
// Verify the active configuration still returns the default values.
- $config = \Drupal::config($name);
+ $config = config($name);
$this->assertIdentical($config->get('foo'), 'bar');
- $config = \Drupal::config($dynamic_name);
+ $config = config($dynamic_name);
$this->assertIdentical($config->get('label'), 'Default');
// Import.
$this->configImporter->reset()->import();
// Verify the values were updated.
- $config = \Drupal::config($name);
+ $config = config($name);
$this->assertIdentical($config->get('foo'), 'beer');
- $config = \Drupal::config($dynamic_name);
+ $config = config($dynamic_name);
$this->assertIdentical($config->get('label'), 'Updated');
// Verify that the original file content is still the same.
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php
index f9c79e3..3d4093d 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php
@@ -37,9 +37,9 @@ function testModuleInstallation() {
$default_configuration_entity = 'config_test.dynamic.dotted.default';
// Verify that default module config does not exist before installation yet.
- $config = \Drupal::config($default_config);
+ $config = config($default_config);
$this->assertIdentical($config->isNew(), TRUE);
- $config = \Drupal::config($default_configuration_entity);
+ $config = config($default_configuration_entity);
$this->assertIdentical($config->isNew(), TRUE);
// Install the test module.
@@ -47,9 +47,9 @@ function testModuleInstallation() {
$this->installConfig(array('config_test'));
// Verify that default module config exists.
- $config = \Drupal::config($default_config);
+ $config = config($default_config);
$this->assertIdentical($config->isNew(), FALSE);
- $config = \Drupal::config($default_configuration_entity);
+ $config = config($default_configuration_entity);
$this->assertIdentical($config->isNew(), FALSE);
// Verify that configuration import callback was invoked for the dynamic
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php
index 5431a96..ff48bf4 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php
@@ -40,19 +40,19 @@ function testIntegrationModuleReinstallation() {
module_enable(array('config_test'));
// Verify the configuration does not exist prior to installation.
- $config_static = \Drupal::config($default_config);
+ $config_static = config($default_config);
$this->assertIdentical($config_static->isNew(), TRUE);
- $config_entity = \Drupal::config($default_configuration_entity);
+ $config_entity = config($default_configuration_entity);
$this->assertIdentical($config_entity->isNew(), TRUE);
// Install the integration module.
module_enable(array('config_integration_test'));
// Verify that default module config exists.
- $config_static = \Drupal::config($default_config);
+ $config_static = config($default_config);
$this->assertIdentical($config_static->isNew(), FALSE);
$this->assertIdentical($config_static->get('foo'), 'default setting');
- $config_entity = \Drupal::config($default_configuration_entity);
+ $config_entity = config($default_configuration_entity);
$this->assertIdentical($config_entity->isNew(), FALSE);
$this->assertIdentical($config_entity->get('label'), 'Default integration config label');
@@ -61,7 +61,7 @@ function testIntegrationModuleReinstallation() {
$config_entity->set('label', 'Customized integration config label')->save();
// @todo FIXME: Setting config keys WITHOUT SAVING retains the changed config
- // object in memory. Every new call to \Drupal::config() MUST revert in-memory changes
+ // object in memory. Every new call to config() MUST revert in-memory changes
// that haven't been saved!
// In other words: This test passes even without this reset, but it shouldn't.
$this->container->get('config.factory')->reset();
@@ -71,10 +71,10 @@ function testIntegrationModuleReinstallation() {
module_enable(array('config_integration_test'));
// Verify that customized config exists.
- $config_static = \Drupal::config($default_config);
+ $config_static = config($default_config);
$this->assertIdentical($config_static->isNew(), FALSE);
$this->assertIdentical($config_static->get('foo'), 'customized setting');
- $config_entity = \Drupal::config($default_configuration_entity);
+ $config_entity = config($default_configuration_entity);
$this->assertIdentical($config_entity->isNew(), FALSE);
$this->assertIdentical($config_entity->get('label'), 'Customized integration config label');
@@ -83,11 +83,11 @@ function testIntegrationModuleReinstallation() {
module_uninstall(array('config_integration_test'));
// Verify the integration module's config was uninstalled.
- $config_static = \Drupal::config($default_config);
+ $config_static = config($default_config);
$this->assertIdentical($config_static->isNew(), TRUE);
// Verify the integration config still exists.
- $config_entity = \Drupal::config($default_configuration_entity);
+ $config_entity = config($default_configuration_entity);
$this->assertIdentical($config_entity->isNew(), FALSE);
$this->assertIdentical($config_entity->get('label'), 'Customized integration config label');
@@ -95,12 +95,12 @@ function testIntegrationModuleReinstallation() {
module_enable(array('config_integration_test'));
// Verify the integration module's config was re-installed.
- $config_static = \Drupal::config($default_config);
+ $config_static = config($default_config);
$this->assertIdentical($config_static->isNew(), FALSE);
$this->assertIdentical($config_static->get('foo'), 'default setting');
// Verify the customized integration config still exists.
- $config_entity = \Drupal::config($default_configuration_entity);
+ $config_entity = config($default_configuration_entity);
$this->assertIdentical($config_entity->isNew(), FALSE);
$this->assertIdentical($config_entity->get('label'), 'Customized integration config label');
}
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php
index 224340c..79f22a9 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php
@@ -42,19 +42,19 @@ public function setUp() {
function testConfigLocaleOverride() {
$name = 'config_test.system';
// The default language is en so the config key should be localised.
- $config = \Drupal::config($name);
+ $config = config($name);
$this->assertIdentical($config->get('foo'), 'en bar');
$this->assertIdentical($config->get('404'), 'herp');
// Ensure that we get the expected value when we avoid overrides.
config_context_enter('config.context.free');
- $config_admin = \Drupal::config($name);
+ $config_admin = config($name);
$this->assertIdentical($config_admin->get('foo'), 'bar');
$this->assertIdentical($config_admin->get('404'), 'herp');
// Leave the non override context.
config_context_leave();
- $config = \Drupal::config($name);
+ $config = config($name);
$this->assertIdentical($config->get('foo'), 'en bar');
$this->assertIdentical($config->get('404'), 'herp');
}
@@ -89,7 +89,7 @@ function testConfigLocaleUserOverride() {
$user_config_context = config_context_enter('Drupal\user\UserConfigContext');
$user_config_context->setAccount($account);
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'fr bar');
// Ensure the non-overriden value is still the same.
$this->assertIdentical($config->get('404'), 'herp');
@@ -99,7 +99,7 @@ function testConfigLocaleUserOverride() {
// in a user based language override context, the English language override
// applies due to the negotiated language for the page.
config_context_leave();
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'en bar');
$account = entity_create('user', array(
@@ -114,7 +114,7 @@ function testConfigLocaleUserOverride() {
$config_factory->enterContext($user_config_context->setAccount($account));
// Should not have to re-initialize the configuration object to get new
// overrides as the new context will have a different uuid.
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'de bar');
// Enter an english context on top of the german context.
@@ -128,24 +128,24 @@ function testConfigLocaleUserOverride() {
// Create a new user config context to stack on top of the existign one.
$en_user_config_context = config_context_enter('Drupal\user\UserConfigContext');
$en_user_config_context->setAccount($account);
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'en bar');
// Ensure that we get the expected value when we leave the english user
// context.
config_context_leave();
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'de bar');
// Ensure that we get the expected value when we leave the german user
// context.
config_context_leave();
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'en bar');
// Ensure that we cannot leave the default context.
config_context_leave();
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'en bar');
}
@@ -171,7 +171,7 @@ function testConfigLocaleLanguageOverride() {
$language = language_load('fr');
$language_config_context = config_context_enter('Drupal\language\LanguageConfigContext');
$language_config_context->setLanguage($language);
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'fr bar');
// Ensure the non-overridden value is still the same.
$this->assertIdentical($config->get('404'), 'herp');
@@ -181,7 +181,7 @@ function testConfigLocaleLanguageOverride() {
// in a language override context, the English language override
// applies due to the negotiated language for the page.
config_context_leave();
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'en bar');
$config_factory = \Drupal::service('config.factory');
@@ -189,7 +189,7 @@ function testConfigLocaleLanguageOverride() {
$config_factory->enterContext($language_config_context->setLanguage($language));
// Should not have to re-initialize the configuration object to get new
// overrides as the new context will have a different uuid.
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'de bar');
// Enter an english context on top of the german context.
@@ -197,24 +197,24 @@ function testConfigLocaleLanguageOverride() {
// Create a new language config context to stack on top of the existing one.
$en_language_config_context = config_context_enter('Drupal\language\LanguageConfigContext');
$en_language_config_context->setLanguage($language);
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'en bar');
// Ensure that we get the expected value when we leave the english
// language context.
config_context_leave();
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'de bar');
// Ensure that we get the expected value when we leave the german
// language context.
config_context_leave();
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'en bar');
// Ensure that we cannot leave the default context.
config_context_leave();
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'en bar');
}
@@ -248,7 +248,7 @@ function testConfigLocaleUserAndGlobalOverride() {
$user_config_context = config_context_enter('Drupal\user\UserConfigContext');
$user_config_context->setAccount($account);
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'fr bar');
// Ensure the value overriden from global $conf works.
$this->assertIdentical($config->get('404'), 'global herp');
@@ -258,21 +258,21 @@ function testConfigLocaleUserAndGlobalOverride() {
// in a user based language override context, the English language override
// applies due to the negotiated language for the page.
config_context_leave();
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'en bar');
// Global override should still apply.
$this->assertIdentical($config->get('404'), 'global herp');
// Ensure that we cannot leave the default context.
config_context_leave();
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), 'en bar');
// Global override should still apply.
$this->assertIdentical($config->get('404'), 'global herp');
// Ensure that we get the expected value when we avoid overrides.
config_context_enter('config.context.free');
- $config_admin = \Drupal::config('config_test.system');
+ $config_admin = config('config_test.system');
// Language override should not apply anymore.
$this->assertIdentical($config_admin->get('foo'), 'bar');
// Global override should not apply.
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverrideWebTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverrideWebTest.php
index 99bee07..204e274 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverrideWebTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverrideWebTest.php
@@ -47,7 +47,7 @@ function testSiteNameTranslation() {
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
// Save an override for the XX language.
- \Drupal::config('locale.config.xx.system.site')->set('name', 'XX site name')->save();
+ config('locale.config.xx.system.site')->set('name', 'XX site name')->save();
$this->drupalLogout();
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php
index a6016c3..e0748a7 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php
@@ -63,7 +63,7 @@ function testConfOverride() {
// Enter an override-free context to ensure the original data remains.
config_context_enter('config.context.free');
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), $expected_original_data['foo']);
$this->assertIdentical($config->get('baz'), $expected_original_data['baz']);
$this->assertIdentical($config->get('404'), $expected_original_data['404']);
@@ -71,7 +71,7 @@ function testConfOverride() {
// Get the configuration object in an overriden context (the one set by
// default).
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
// Verify that it contains the overridden data from $conf.
$this->assertIdentical($config->get('foo'), $conf['config_test.system']['foo']);
@@ -95,14 +95,14 @@ function testConfOverride() {
$config->save();
// Reload it and verify that it still contains overridden data from $conf.
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), $conf['config_test.system']['foo']);
$this->assertIdentical($config->get('baz'), $conf['config_test.system']['baz']);
$this->assertIdentical($config->get('404'), $conf['config_test.system']['404']);
// Enter an override-free context to ensure the original data remains saved.
config_context_enter('config.context.free');
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), $expected_original_data['foo']);
$this->assertIdentical($config->get('baz'), $expected_original_data['baz']);
$this->assertIdentical($config->get('404'), $expected_original_data['404']);
@@ -127,7 +127,7 @@ function testConfOverride() {
$this->assertIdentical($data['404'], $expected_new_data['404']);
// Verifiy the overrides are still working.
- $config = \Drupal::config('config_test.system');
+ $config = config('config_test.system');
$this->assertIdentical($config->get('foo'), $conf['config_test.system']['foo']);
$this->assertIdentical($config->get('baz'), $conf['config_test.system']['baz']);
$this->assertIdentical($config->get('404'), $conf['config_test.system']['404']);
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php
index 4a507d8..f29320f 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php
@@ -8,8 +8,6 @@
namespace Drupal\config\Tests;
use Drupal\Core\Config\TypedConfig;
-use Drupal\Core\TypedData\Type\IntegerInterface;
-use Drupal\Core\TypedData\Type\StringInterface;
use Drupal\simpletest\DrupalUnitTestBase;
/**
@@ -164,16 +162,14 @@ function testSchemaData() {
// Try some simple properties.
$meta = config_typed()->get('system.site');
$property = $meta->get('name');
- $this->assertTrue($property instanceof StringInterface, 'Got the right wrapper fo the site name property.');
+ $this->assertTrue(is_a($property, 'Drupal\Core\TypedData\Plugin\DataType\String'), 'Got the right wrapper fo the site name property.');
+ $this->assertEqual($property->getType(), 'label', 'Got the right string type for site name data.');
$this->assertEqual($property->getValue(), 'Drupal', 'Got the right string value for site name data.');
- $definition = $property->getDefinition();
- $this->assertTrue($definition['translatable'], 'Got the right translatability setting for site name data.');
$property = $meta->get('page')->get('front');
- $this->assertTrue($property instanceof StringInterface, 'Got the right wrapper fo the page.front property.');
+ $this->assertTrue(is_a($property, 'Drupal\Core\TypedData\Plugin\DataType\String'), 'Got the right wrapper fo the page.front property.');
+ $this->assertEqual($property->getType(), 'path', 'Got the right type for page.front data (undefined).');
$this->assertEqual($property->getValue(), 'user', 'Got the right value for page.front data.');
- $definition = $property->getDefinition();
- $this->assertTrue(empty($definition['translatable']), 'Got the right translatability setting for page.front data.');
// Check nested array of properties.
$list = $meta->get('page');
@@ -196,7 +192,7 @@ function testSchemaData() {
$uuid = key($effects->getValue());
$effect = $effects[$uuid];
$this->assertTrue(count($effect['data']) && $effect['id']->getValue() == 'image_scale', 'Got data for the image scale effect from metadata.');
- $this->assertTrue($effect['data']['width'] instanceof IntegerInterface, 'Got the right type for the scale effect width.');
+ $this->assertEqual($effect['data']['width']->getType(), 'integer', 'Got the right type for the scale effect width.');
$this->assertEqual($effect['data']['width']->getValue(), 480, 'Got the right value for the scale effect width.' );
// Finally update some object using a configuration wrapper.
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSnapshotTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSnapshotTest.php
index d9504b2..7315c53 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigSnapshotTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSnapshotTest.php
@@ -66,7 +66,7 @@ function testSnapshot() {
$this->assertFalse($active_snapshot_comparer->reset()->hasChanges());
// Change a configuration value in staging.
- $staging_data = \Drupal::config($config_name)->get();
+ $staging_data = config($config_name)->get();
$staging_data[$config_key] = $new_data;
$staging->write($config_name, $staging_data);
@@ -79,7 +79,7 @@ function testSnapshot() {
$this->configImporter()->import();
// Verify changed config was properly imported.
- $this->assertIdentical(\Drupal::config($config_name)->get($config_key), $new_data);
+ $this->assertIdentical(config($config_name)->get($config_key), $new_data);
// Verify that a new snapshot was created which and that it matches
// the active config.
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigUpgradeTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigUpgradeTest.php
index e95f134..f55921e 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigUpgradeTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigUpgradeTest.php
@@ -59,7 +59,7 @@ function testConfigurationUpdate() {
));
// Verify that variables have been converted and default values exist.
- $config = \Drupal::config('config_upgrade.test');
+ $config = config('config_upgrade.test');
$this->assertIdentical($config->get('foo'), $this->testContent);
$this->assertIdentical($config->get('parent.bar'), $this->testContent);
$this->assertIdentical($config->get('parent.baz'), 'Baz');
@@ -80,7 +80,7 @@ function testConfigurationUpdate() {
));
// Verify that new variables have been converted and existing still exist.
- $config = \Drupal::config('config_upgrade.test');
+ $config = config('config_upgrade.test');
$this->assertIdentical($config->get('foo'), $this->testContent);
$this->assertIdentical($config->get('parent.bar'), $this->testContent);
$this->assertIdentical($config->get('parent.baz'), 'Baz');
@@ -101,7 +101,7 @@ function testConfigurationUpdate() {
// For this test it is essential that update_variables_to_config has already
// run on the config object.
- \Drupal::config('config_upgrade.test')
+ config('config_upgrade.test')
->set('numeric_keys.403', '')
->set('numeric_keys.404', '')
->save();
@@ -118,6 +118,6 @@ function testConfigurationUpdate() {
'config_upgrade_404' => 'numeric_keys.404',
));
- $this->assertIdentical(\Drupal::config('config_upgrade.test')->get('numeric_keys'), array(403 => 'custom403', 404 => 'custom404'));
+ $this->assertIdentical(config('config_upgrade.test')->get('numeric_keys'), array(403 => 'custom403', 404 => 'custom404'));
}
}
diff --git a/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php b/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php
index 60ce433..d4d492a 100644
--- a/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php
@@ -28,7 +28,7 @@ function setUp() {
$this->invalidStorage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY] . '/nonexisting');
// FileStorage::listAll() requires other configuration data to exist.
- $this->storage->write('system.performance', \Drupal::config('system.performance')->get());
+ $this->storage->write('system.performance', config('system.performance')->get());
}
protected function read($name) {
diff --git a/core/modules/contact/contact.install b/core/modules/contact/contact.install
index 60b51b0..eaac51c 100644
--- a/core/modules/contact/contact.install
+++ b/core/modules/contact/contact.install
@@ -12,11 +12,11 @@
* Implements hook_install().
*/
function contact_install() {
- $site_mail = Drupal::config('system.site')->get('mail');
+ $site_mail = config('system.site')->get('mail');
if (empty($site_mail)) {
$site_mail = ini_get('sendmail_from');
}
- Drupal::config('contact.category.feedback')->set('recipients', array($site_mail))->save();
+ config('contact.category.feedback')->set('recipients', array($site_mail))->save();
}
/**
@@ -61,12 +61,12 @@ function contact_update_8001() {
$category->id = $category->cid;
// Save default category setting.
if ($category->selected) {
- Drupal::config('contact.settings')
+ config('contact.settings')
->set('default_category', $category->id)
->save();
}
// Save the config object.
- Drupal::config('contact.category.' . $category->id)
+ config('contact.category.' . $category->id)
->set('id', $category->id)
->set('uuid', $uuid->generate())
->set('label', $category->category)
diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module
index 74cfb1e..d8984e8 100644
--- a/core/modules/contact/contact.module
+++ b/core/modules/contact/contact.module
@@ -154,7 +154,7 @@ function _contact_personal_tab_access(UserInterface $account) {
}
// If the requested user did not save a preference yet, deny access if the
// configured default is disabled.
- elseif (!Drupal::config('contact.settings')->get('user_default_enabled')) {
+ elseif (!config('contact.settings')->get('user_default_enabled')) {
return FALSE;
}
@@ -167,7 +167,7 @@ function _contact_personal_tab_access(UserInterface $account) {
function contact_entity_bundle_info() {
$bundles = array();
foreach (config_get_storage_names_with_prefix('contact.category.') as $config_name) {
- $config = Drupal::config($config_name);
+ $config = config($config_name);
$bundles['contact_message'][$config->get('id')]['label'] = $config->get('label');
}
return $bundles;
@@ -264,7 +264,7 @@ function contact_mail($key, &$message, $params) {
$language = language_load($message['langcode']);
$variables = array(
- '!site-name' => Drupal::config('system.site')->get('name'),
+ '!site-name' => config('system.site')->get('name'),
'!subject' => $contact_message->getSubject(),
'!category' => !empty($params['contact_category']) ? $params['contact_category']->label() : NULL,
'!form-url' => url(current_path(), array('absolute' => TRUE, 'language' => $language)),
@@ -328,7 +328,7 @@ function contact_form_user_form_alter(&$form, &$form_state) {
$form['contact']['contact'] = array(
'#type' => 'checkbox',
'#title' => t('Personal contact form'),
- '#default_value' => isset($account_data) ? $account_data : Drupal::config('contact.settings')->get('user_default_enabled'),
+ '#default_value' => isset($account_data) ? $account_data : config('contact.settings')->get('user_default_enabled'),
'#description' => t('Allow other users to contact you via a personal contact form which keeps your e-mail address hidden. Note that some privileged users such as site administrators are still able to contact you even if you choose to disable this feature.'),
);
$form['actions']['submit']['#submit'][] = 'contact_user_profile_form_submit';
@@ -361,7 +361,7 @@ function contact_form_user_admin_settings_alter(&$form, &$form_state) {
'#type' => 'checkbox',
'#title' => t('Enable the personal contact form by default for new users.'),
'#description' => t('Changing this setting will not affect existing users.'),
- '#default_value' => Drupal::config('contact.settings')->get('user_default_enabled'),
+ '#default_value' => config('contact.settings')->get('user_default_enabled'),
);
// Add submit handler to save contact configuration.
$form['#submit'][] = 'contact_form_user_admin_settings_submit';
@@ -373,7 +373,7 @@ function contact_form_user_admin_settings_alter(&$form, &$form_state) {
* @see contact_form_user_admin_settings_alter()
*/
function contact_form_user_admin_settings_submit($form, &$form_state) {
- Drupal::config('contact.settings')
+ config('contact.settings')
->set('user_default_enabled', $form_state['values']['contact_default_status'])
->save();
}
diff --git a/core/modules/contact/contact.pages.inc b/core/modules/contact/contact.pages.inc
index c7b7539..52afd28 100644
--- a/core/modules/contact/contact.pages.inc
+++ b/core/modules/contact/contact.pages.inc
@@ -30,7 +30,7 @@ function contact_site_page(Category $category = NULL) {
if (!isset($category)) {
$categories = entity_load_multiple('contact_category');
- $default_category = Drupal::config('contact.settings')->get('default_category');
+ $default_category = config('contact.settings')->get('default_category');
if (isset($categories[$default_category])) {
$category = $categories[$default_category];
}
@@ -93,7 +93,7 @@ function contact_personal_page($recipient) {
* @see contact_personal_page()
*/
function contact_flood_control() {
- $config = Drupal::config('contact.settings');
+ $config = config('contact.settings');
$limit = $config->get('flood.limit');
$interval = $config->get('flood.interval');
if (!Drupal::service('flood')->isAllowed('contact', $limit, $interval)) {
diff --git a/core/modules/contact/lib/Drupal/contact/CategoryFormController.php b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
index bd12a66..5f2e78c 100644
--- a/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
+++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
@@ -21,7 +21,7 @@ public function form(array $form, array &$form_state) {
$form = parent::form($form, $form_state);
$category = $this->entity;
- $default_category = \Drupal::config('contact.settings')->get('default_category');
+ $default_category = config('contact.settings')->get('default_category');
$form['label'] = array(
'#type' => 'textfield',
@@ -108,7 +108,7 @@ public function save(array $form, array &$form_state) {
}
// Update the default category.
- $contact_config = \Drupal::config('contact.settings');
+ $contact_config = config('contact.settings');
if ($form_state['values']['selected']) {
$contact_config
->set('default_category', $category->id())
diff --git a/core/modules/contact/lib/Drupal/contact/CategoryListController.php b/core/modules/contact/lib/Drupal/contact/CategoryListController.php
index 7a6a513..820010f 100644
--- a/core/modules/contact/lib/Drupal/contact/CategoryListController.php
+++ b/core/modules/contact/lib/Drupal/contact/CategoryListController.php
@@ -66,7 +66,7 @@ public function buildRow(EntityInterface $entity) {
}
else {
$row['recipients'] = check_plain(implode(', ', $entity->recipients));
- $default_category = \Drupal::config('contact.settings')->get('default_category');
+ $default_category = config('contact.settings')->get('default_category');
$row['selected'] = ($default_category == $entity->id() ? t('Yes') : t('No'));
}
$row['operations']['data'] = $this->buildOperations($entity);
diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
index d41c959..5f2ede7 100644
--- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php
+++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
@@ -187,7 +187,7 @@ public function save(array $form, array &$form_state) {
drupal_mail('contact', 'page_autoreply', $sender->getEmail(), $language_interface->id, $params);
}
- \Drupal::service('flood')->register('contact', \Drupal::config('contact.settings')->get('flood.interval'));
+ \Drupal::service('flood')->register('contact', config('contact.settings')->get('flood.interval'));
if (!$message->isPersonal()) {
watchdog('contact', '%sender-name (@sender-from) sent an e-mail regarding %category.', array(
'%sender-name' => $sender->name,
diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
index 7e1bd71..61f1fb9 100644
--- a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
+++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
@@ -57,7 +57,7 @@ function setUp() {
$this->admin_user = $this->drupalCreateUser(array('administer contact forms', 'administer users'));
// Create some normal users with their contact forms enabled by default.
- \Drupal::config('contact.settings')->set('user_default_enabled', 1)->save();
+ config('contact.settings')->set('user_default_enabled', 1)->save();
$this->web_user = $this->drupalCreateUser(array('access user contact forms'));
$this->contact_user = $this->drupalCreateUser();
}
@@ -76,7 +76,7 @@ function testSendPersonalContactMessage() {
$this->assertEqual($mail['from'], $this->web_user->getEmail());
$this->assertEqual($mail['key'], 'user_mail');
$variables = array(
- '!site-name' => \Drupal::config('system.site')->get('name'),
+ '!site-name' => config('system.site')->get('name'),
'!subject' => $message['subject'],
'!recipient-name' => $this->contact_user->getUsername(),
);
@@ -181,7 +181,7 @@ function testPersonalContactAccess() {
*/
function testPersonalContactFlood() {
$flood_limit = 3;
- \Drupal::config('contact.settings')->set('flood.limit', $flood_limit)->save();
+ config('contact.settings')->set('flood.limit', $flood_limit)->save();
// Clear flood table in preparation for flood test and allow other checks to complete.
db_delete('flood')->execute();
@@ -198,7 +198,7 @@ function testPersonalContactFlood() {
// Submit contact form one over limit.
$this->drupalGet('user/' . $this->contact_user->id(). '/contact');
- $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => format_interval(\Drupal::config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.');
+ $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => format_interval(config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.');
// Test that the admin user can still access the contact form even though
// the flood limit was reached.
diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php
index 56b902e..42f4423 100644
--- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php
+++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php
@@ -44,7 +44,7 @@ function testSiteWideContact() {
$this->drupalLogin($admin_user);
$flood_limit = 3;
- \Drupal::config('contact.settings')
+ config('contact.settings')
->set('flood.limit', $flood_limit)
->set('flood.interval', 600)
->save();
@@ -110,7 +110,7 @@ function testSiteWideContact() {
$this->assertRaw(t('Category %label has been added.', array('%label' => $label)));
// Check that the category was created in site default language.
- $langcode = \Drupal::config('contact.category.' . $id)->get('langcode');
+ $langcode = config('contact.category.' . $id)->get('langcode');
$default_langcode = language_default()->id;
$this->assertEqual($langcode, $default_langcode);
@@ -119,15 +119,15 @@ function testSiteWideContact() {
// Test update contact form category.
$this->updateCategory($id, $label = $this->randomName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomName(30), FALSE);
- $config = \Drupal::config('contact.category.' . $id)->get();
+ $config = config('contact.category.' . $id)->get();
$this->assertEqual($config['label'], $label);
$this->assertEqual($config['recipients'], array($recipients[0], $recipients[1]));
$this->assertEqual($config['reply'], $reply);
- $this->assertNotEqual($id, \Drupal::config('contact.settings')->get('default_category'));
+ $this->assertNotEqual($id, config('contact.settings')->get('default_category'));
$this->assertRaw(t('Category %label has been updated.', array('%label' => $label)));
// Reset the category back to be the default category.
- \Drupal::config('contact.settings')->set('default_category', $id)->save();
+ config('contact.settings')->set('default_category', $id)->save();
// Ensure that the contact form is shown without a category selection input.
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form'));
@@ -182,7 +182,7 @@ function testSiteWideContact() {
$this->assertText(t('Message field is required.'));
// Test contact form with no default category selected.
- \Drupal::config('contact.settings')
+ config('contact.settings')
->set('default_category', '')
->save();
$this->drupalGet('contact');
@@ -202,7 +202,7 @@ function testSiteWideContact() {
// Submit contact form one over limit.
$this->drupalGet('contact');
$this->assertResponse(403);
- $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => \Drupal::config('contact.settings')->get('flood.limit'), '@interval' => format_interval(600))));
+ $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => config('contact.settings')->get('flood.limit'), '@interval' => format_interval(600))));
// Test listing controller.
$this->drupalLogin($admin_user);
@@ -376,7 +376,7 @@ function submitContact($name, $mail, $subject, $id, $message) {
$edit['mail'] = $mail;
$edit['subject'] = $subject;
$edit['message'] = $message;
- if ($id == \Drupal::config('contact.settings')->get('default_category')) {
+ if ($id == config('contact.settings')->get('default_category')) {
$this->drupalPost('contact', $edit, t('Send message'));
}
else {
diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactUpgradePathTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactUpgradePathTest.php
index b5785aa..4c61653 100644
--- a/core/modules/contact/lib/Drupal/contact/Tests/ContactUpgradePathTest.php
+++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactUpgradePathTest.php
@@ -60,7 +60,7 @@ public function testContactUpgrade() {
$this->assertEqual($contact_category->recipients, array('test1@example.com', 'test2@example.com'));
// Ensure that the default category has been maintained.
- $this->assertEqual(\Drupal::config('contact.settings')->get('default_category'), $default_contact_category, 'Default category upgraded.');
+ $this->assertEqual(config('contact.settings')->get('default_category'), $default_contact_category, 'Default category upgraded.');
// Check that no default config imported on upgrade.
$this->assertFalse(entity_load('contact_category', 'feedback'));
diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module
index 34e918c..bce6a02 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -19,7 +19,7 @@ function content_translation_help($path, $arg) {
case 'admin/help#content_translation':
$output = '';
$output .= '' . t('About') . '
';
- $output .= '' . t('The Content Translation module allows you to create and manage translations for your Drupal site content. You can specify which elements need to be translated at the content-type level for content items and comments, at the vocabulary level for taxonomy terms, and at the site level for user accounts. Other modules may provide additional elements that can be translated. For more information, see the online handbook entry for Content Translation.', array('!url' => 'http://drupal.org/documentation/modules/translation_entity')) . '
';
+ $output .= '' . t('The Content Translation module allows you to create and manage translations for your Drupal site content. You can specify which elements need to be translated at the content-type level for content items and comments, at the vocabulary level for taxonomy terms, and at the site level for user accounts. Other modules may provide additional elements that can be translated. For more information, see the online handbook entry for Content Translation.', array('!url' => 'http://drupal.org/documentation/modules/entity_translation')) . '
';
$output .= '' . t('Uses') . '
';
$output .= '';
$output .= '- ' . t('Enabling translation') . '
';
@@ -413,7 +413,7 @@ function content_translation_get_config_key($entity_type, $bundle, $setting) {
*/
function content_translation_get_config($entity_type, $bundle, $setting) {
$key = content_translation_get_config_key($entity_type, $bundle, $setting);
- return Drupal::config('content_translation.settings')->get($key);
+ return config('content_translation.settings')->get($key);
}
/**
@@ -430,7 +430,7 @@ function content_translation_get_config($entity_type, $bundle, $setting) {
*/
function content_translation_set_config($entity_type, $bundle, $setting, $value) {
$key = content_translation_get_config_key($entity_type, $bundle, $setting);
- return Drupal::config('content_translation.settings')->set($key, $value)->save();
+ return config('content_translation.settings')->set($key, $value)->save();
}
/**
diff --git a/core/modules/content_translation/css/content_translation.admin.css b/core/modules/content_translation/css/content_translation.admin.css
deleted file mode 100644
index cab64f8..0000000
--- a/core/modules/content_translation/css/content_translation.admin.css
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * @file
- * Styles for the content language administration page.
- */
-
-#language-content-settings-form table .bundle {
- width: 24%;
-}
-
-#language-content-settings-form table td.bundle {
- font-weight: bold;
-}
-
-#language-content-settings-form table .field,
-#language-content-settings-form table .column {
- width: 24%;
- padding-left: 3em;
-}
-
-#language-content-settings-form table .column {
- padding-left: 5em;
-}
-
-#language-content-settings-form table .field label,
-#language-content-settings-form table .column label {
- font-weight: normal;
-}
-
-#language-content-settings-form table .translatable {
- width: 1%;
-}
-
-#language-content-settings-form table .operations {
- width: 75%;
-}
diff --git a/core/modules/content_translation/css/translation_entity.admin.css b/core/modules/content_translation/css/translation_entity.admin.css
new file mode 100644
index 0000000..cab64f8
--- /dev/null
+++ b/core/modules/content_translation/css/translation_entity.admin.css
@@ -0,0 +1,35 @@
+/**
+ * @file
+ * Styles for the content language administration page.
+ */
+
+#language-content-settings-form table .bundle {
+ width: 24%;
+}
+
+#language-content-settings-form table td.bundle {
+ font-weight: bold;
+}
+
+#language-content-settings-form table .field,
+#language-content-settings-form table .column {
+ width: 24%;
+ padding-left: 3em;
+}
+
+#language-content-settings-form table .column {
+ padding-left: 5em;
+}
+
+#language-content-settings-form table .field label,
+#language-content-settings-form table .column label {
+ font-weight: normal;
+}
+
+#language-content-settings-form table .translatable {
+ width: 1%;
+}
+
+#language-content-settings-form table .operations {
+ width: 75%;
+}
diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php
index 474e543..20c894e 100644
--- a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php
+++ b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php
@@ -43,9 +43,9 @@ public function buildOptionsForm(&$form, &$form_state) {
}
/**
- * {@inheritdoc}
+ * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::render().
*/
- public function render(ResultRow $values) {
+ public function render($values) {
return $this->renderLink($this->getEntity($values), $values);
}
diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php
index c17bd06..919603e 100644
--- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php
+++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php
@@ -63,7 +63,7 @@ function testSettingsUI() {
'settings[comment][comment_node_article][translatable]' => TRUE,
);
$this->assertSettings('comment', 'comment_node_article', FALSE, $edit);
- $xpath_err = '//div[contains(@class, "error")]';
+ $xpath_err = '//div[@id="messages"]//div[contains(@class, "error")]';
$this->assertTrue($this->xpath($xpath_err), 'Enabling translation only for entity bundles generates a form error.');
// Test that the translation settings are not stored if a non-configurable
diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php
index 74b779b..a83be54 100644
--- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php
+++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php
@@ -190,7 +190,7 @@ protected function assertAuthoringInfo() {
'content_translation[created]' => '19/11/1978',
);
$this->drupalPost($path, $edit, $this->getFormSubmitAction($entity));
- $this->assertTrue($this->xpath('//div[contains(@class, "error")]//ul'), 'Invalid values generate a list of form errors.');
+ $this->assertTrue($this->xpath('//div[@id="messages"]//div[contains(@class, "error")]//ul'), 'Invalid values generate a list of form errors.');
$this->assertEqual($entity->translation[$langcode]['uid'] == $values[$langcode]['uid'], 'Translation author correctly kept.');
$this->assertEqual($entity->translation[$langcode]['created'] == $values[$langcode]['created'], 'Translation date correctly kept.');
}
diff --git a/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php b/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php
index 30de8f9..bc4a34d 100644
--- a/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php
+++ b/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php
@@ -9,7 +9,6 @@
use Drupal\Component\Annotation\PluginID;
use Drupal\views\Plugin\views\field\FieldPluginBase;
-use Drupal\views\ResultRow;
/**
* Provides a handler that adds contextual links.
@@ -64,14 +63,12 @@ public function preRender(&$values) {
}
/**
- * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::render().
- *
- * Renders the contextual fields.
+ * Render the contextual fields.
*
* @see contextual_preprocess()
* @see contextual_contextual_links_view_alter()
*/
- public function render(ResultRow $values) {
+ public function render($values) {
$links = array();
foreach ($this->options['fields'] as $field) {
$rendered_field = $this->view->style_plugin->getField($this->view->row_index, $field);
diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module
index eafc616..ebbcdd8 100644
--- a/core/modules/datetime/datetime.module
+++ b/core/modules/datetime/datetime.module
@@ -507,16 +507,11 @@ function form_type_datetime_value($element, $input = FALSE) {
$time_input .= ':00';
}
- try {
- $date = DrupalDateTime::createFromFormat(trim($date_format . ' ' . $time_format), trim($date_input . ' ' . $time_input), $timezone);
- }
- catch (\Exception $e) {
- $date = NULL;
- }
+ $date = new DrupalDateTime(trim($date_input . ' ' . $time_input), $timezone, trim($date_format . ' ' . $time_format));
$input = array(
'date' => $date_input,
'time' => $time_input,
- 'object' => $date,
+ 'object' => $date instanceOf DrupalDateTime && !$date->hasErrors() ? $date : NULL,
);
}
else {
@@ -841,7 +836,7 @@ function form_type_datelist_value($element, $input = FALSE, &$form_state = array
unset($input['ampm']);
}
$timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : NULL;
- $date = DrupalDateTime::createFromArray($input, $timezone);
+ $date = new DrupalDateTime($input, $timezone);
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {
date_increment_round($date, $increment);
}
@@ -1049,5 +1044,5 @@ function datetime_form_node_form_alter(&$form, &$form_state, $form_id) {
*/
function datetime_node_prepare_form(NodeInterface $node, $form_display, $operation, array &$form_state) {
// Prepare the 'Authored on' date to use datetime.
- $node->date = DrupalDateTime::createFromTimestamp($node->created);
+ $node->date = new DrupalDateTime($node->created);
}
diff --git a/core/modules/datetime/lib/Drupal/datetime/DateHelper.php b/core/modules/datetime/lib/Drupal/datetime/DateHelper.php
index 3f8b0f8..39c770e 100644
--- a/core/modules/datetime/lib/Drupal/datetime/DateHelper.php
+++ b/core/modules/datetime/lib/Drupal/datetime/DateHelper.php
@@ -259,7 +259,7 @@ public static function weekDaysAbbr1($required = FALSE) {
* An array of weekdays reordered to match the first day of the week.
*/
public static function weekDaysOrdered($weekdays) {
- $first_day = \Drupal::config('system.date')->get('first_day');
+ $first_day = config('system.date')->get('first_day');
if ($first_day > 0) {
for ($i = 1; $i <= $first_day; $i++) {
$last = array_shift($weekdays);
diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeItem.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeItem.php
index 558ca47..e3b0190 100644
--- a/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeItem.php
+++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeItem.php
@@ -11,7 +11,7 @@
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\Annotation\FieldType;
use Drupal\Core\Entity\Field\PrepareCacheInterface;
-use Drupal\field\FieldInterface;
+use Drupal\field\Plugin\Core\Entity\Field;
use Drupal\field\Plugin\Type\FieldType\ConfigFieldItemBase;
/**
@@ -57,7 +57,7 @@ public function getPropertyDefinitions() {
/**
* {@inheritdoc}
*/
- public static function schema(FieldInterface $field) {
+ public static function schema(Field $field) {
return array(
'columns' => array(
'value' => array(
@@ -76,7 +76,7 @@ public static function schema(FieldInterface $field) {
/**
* {@inheritdoc}
*/
- public function settingsForm(array $form, array &$form_state, $has_data) {
+ public function settingsForm(array $form, array &$form_state) {
$element = array();
$element['datetime_type'] = array(
@@ -122,14 +122,9 @@ public function prepareCache() {
$value = $this->get('value')->getValue();
if (!empty($value)) {
$storage_format = $this->getFieldSetting('datetime_type') == 'date' ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT;
- try {
- $date = DrupalDateTime::createFromFormat($storage_format, $value, DATETIME_STORAGE_TIMEZONE);
- if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {
- $this->set('date', $date);
- }
- }
- catch (\Exception $e) {
- // @todo Handle this.
+ $date = new DrupalDateTime($value, DATETIME_STORAGE_TIMEZONE, $storage_format);
+ if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {
+ $this->set('date', $date);
}
}
}
diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module
index 9bd8f7f..202cfcf 100644
--- a/core/modules/dblog/dblog.module
+++ b/core/modules/dblog/dblog.module
@@ -99,7 +99,7 @@ function dblog_page_build(&$page) {
*/
function dblog_cron() {
// Cleanup the watchdog table.
- $row_limit = Drupal::config('dblog.settings')->get('row_limit');
+ $row_limit = config('dblog.settings')->get('row_limit');
// For row limit n, get the wid of the nth row in descending wid order.
// Counting the most recent n rows avoids issues with wid number sequences,
@@ -169,7 +169,7 @@ function dblog_form_system_logging_settings_alter(&$form, $form_state) {
$form['dblog_row_limit'] = array(
'#type' => 'select',
'#title' => t('Database log messages to keep'),
- '#default_value' => Drupal::config('dblog.settings')->get('row_limit'),
+ '#default_value' => config('dblog.settings')->get('row_limit'),
'#options' => array(0 => t('All')) + drupal_map_assoc(array(100, 1000, 10000, 100000, 1000000)),
'#description' => t('The maximum number of messages to keep in the database log. Requires a cron maintenance task.', array('@cron' => url('admin/reports/status')))
);
@@ -183,5 +183,5 @@ function dblog_form_system_logging_settings_alter(&$form, $form_state) {
* @see dblog_form_system_logging_settings_alter()
*/
function dblog_logging_settings_submit($form, &$form_state) {
- Drupal::config('dblog.settings')->set('row_limit', $form_state['values']['dblog_row_limit'])->save();
+ config('dblog.settings')->set('row_limit', $form_state['values']['dblog_row_limit'])->save();
}
diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
index 4406383..59a40c3 100644
--- a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
+++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
@@ -90,7 +90,7 @@ private function verifyRowLimit($row_limit) {
$this->assertResponse(200);
// Check row limit variable.
- $current_limit = \Drupal::config('dblog.settings')->get('row_limit');
+ $current_limit = config('dblog.settings')->get('row_limit');
$this->assertTrue($current_limit == $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit)));
}
diff --git a/core/modules/editor/js/editor.js b/core/modules/editor/js/editor.js
index 18493d6..5893e11 100644
--- a/core/modules/editor/js/editor.js
+++ b/core/modules/editor/js/editor.js
@@ -60,10 +60,7 @@ Drupal.behaviors.editor = {
if (event.isDefaultPrevented()) {
return;
}
- // Detach the current editor (if any).
- if (settings.editor.formats[activeFormatID]) {
- Drupal.editorDetach(field, settings.editor.formats[activeFormatID], 'serialize');
- }
+ Drupal.editorDetach(field, settings.editor.formats[activeFormatID], 'serialize');
});
});
},
diff --git a/core/modules/email/lib/Drupal/email/Plugin/field/field_type/ConfigurableEmailItem.php b/core/modules/email/lib/Drupal/email/Plugin/field/field_type/ConfigurableEmailItem.php
index b346c4b..d107238 100644
--- a/core/modules/email/lib/Drupal/email/Plugin/field/field_type/ConfigurableEmailItem.php
+++ b/core/modules/email/lib/Drupal/email/Plugin/field/field_type/ConfigurableEmailItem.php
@@ -10,7 +10,7 @@
use Drupal\Core\Entity\Annotation\FieldType;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Entity\Plugin\DataType\EmailItem;
-use Drupal\field\FieldInterface;
+use Drupal\field\Plugin\Core\Entity\Field;
/**
* Plugin implementation of the 'email' field type.
@@ -40,7 +40,7 @@ class ConfigurableEmailItem extends EmailItem {
/**
* {@inheritdoc}
*/
- public static function schema(FieldInterface $field) {
+ public static function schema(Field $field) {
return array(
'columns' => array(
'value' => array(
diff --git a/core/modules/entity/entity.install b/core/modules/entity/entity.install
index 9cbd71e..af2aba1 100644
--- a/core/modules/entity/entity.install
+++ b/core/modules/entity/entity.install
@@ -25,7 +25,7 @@
*/
function _update_8000_entity_get_display($entity_type, $bundle, $view_mode) {
$id = $entity_type . '.' . $bundle . '.' . $view_mode;
- $config = Drupal::config("entity.display.$id");
+ $config = config("entity.display.$id");
if ($config->get()) {
return $config;
}
@@ -64,7 +64,7 @@ function _update_8000_entity_get_display($entity_type, $bundle, $view_mode) {
*/
function _update_8000_entity_get_form_display($entity_type, $bundle, $form_mode) {
$id = $entity_type . '.' . $bundle . '.' . $form_mode;
- $config = Drupal::config("entity.form_display.$id");
+ $config = config("entity.form_display.$id");
if ($config->get()) {
return $config;
}
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php
index c3107ec..1482d4e 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php
@@ -248,7 +248,7 @@ public function testUserHandler() {
),
);
- $user_values['anonymous']->name = \Drupal::config('user.settings')->get('anonymous');
+ $user_values['anonymous']->name = config('user.settings')->get('anonymous');
$users = array();
$user_labels = array();
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index c2eda35..3203f2e 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -191,7 +191,7 @@ function field_cron() {
field_sync_field_status();
// Do a pass of purging on deleted Field API data, if any exists.
- $limit = Drupal::config('field.settings')->get('purge_batch_size');
+ $limit = config('field.settings')->get('purge_batch_size');
field_purge_batch($limit);
}
@@ -726,9 +726,9 @@ function field_view_value(EntityInterface $entity, $field_name, $item, $display
*
* This function can be used by third-party modules that need to output an
* isolated field.
- * - Do not use inside node (or any other entity) templates; use
+ * - Do not use inside node (or other entities) templates, use
* render($content[FIELD_NAME]) instead.
- * - Do not use to display all fields in an entity; use
+ * - Do not use to display all fields in an entity, use
* field_attach_prepare_view() and field_attach_view() instead.
* - The field_view_value() function can be used to output a single formatted
* field value, without label or wrapping field markup.
diff --git a/core/modules/field/field.multilingual.inc b/core/modules/field/field.multilingual.inc
index 0442bbd..ca33a31 100644
--- a/core/modules/field/field.multilingual.inc
+++ b/core/modules/field/field.multilingual.inc
@@ -155,7 +155,7 @@ function field_content_languages() {
* Checks whether field language fallback is enabled.
*/
function field_language_fallback_enabled() {
- return language_multilingual() && Drupal::config('field.settings')->get('language_fallback');
+ return language_multilingual() && config('field.settings')->get('language_fallback');
}
/**
diff --git a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php
index e669900..bccc64b 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php
@@ -581,7 +581,7 @@ public function getFieldSettings() {
// the default field and instance settings, within $this.
$field_type_info = \Drupal::service('plugin.manager.entity.field.field_type')->getDefinition($this->type);
- $settings = $this->settings + $field_type_info['settings'] + $field_type_info['instance_settings'];
+ $settings = $field_type_info['instance_settings'] + $this->settings + $field_type_info['settings'];
return $settings;
}
@@ -594,14 +594,14 @@ public function getFieldSetting($setting_name) {
// We assume here that consecutive array_key_exists() is more efficient than
// calling getFieldSettings() when all we need is a single setting.
- if (array_key_exists($setting_name, $this->settings)) {
- return $this->settings[$setting_name];
+ if (array_key_exists($setting_name, $field_type_info['instance_settings'])) {
+ return $field_type_info['instance_settings'][$setting_name];
}
- elseif (array_key_exists($setting_name, $field_type_info['settings'])) {
- return $field_type_info['settings'][$setting_name];
+ elseif (array_key_exists($setting_name, $this->settings)) {
+ return $this->settings[$setting_name];
}
else {
- return $field_type_info['instance_settings'][$setting_name];
+ return $field_type_info['settings'][$setting_name];
}
}
diff --git a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php
index 1950a9f..9628256 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php
@@ -537,26 +537,6 @@ public function isFieldTranslatable() {
/**
* {@inheritdoc}
*/
- public function uri() {
- $path = \Drupal::entityManager()->getAdminPath($this->entity_type, $this->bundle);
-
- // Use parent URI as fallback, if path is empty.
- if (empty($path)) {
- return parent::uri();
- }
-
- return array(
- 'path' => $path . '/fields/' . $this->id(),
- 'options' => array(
- 'entity_type' => $this->entityType,
- 'entity' => $this,
- ),
- );
- }
-
- /**
- * {@inheritdoc}
- */
public function getFieldLabel() {
return $this->label();
}
diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigEntityReferenceItemBase.php b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigEntityReferenceItemBase.php
index 9244324..c451fdb 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigEntityReferenceItemBase.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigEntityReferenceItemBase.php
@@ -9,7 +9,7 @@
use Drupal\Core\Entity\Plugin\DataType\EntityReferenceItem;
use Drupal\field\Plugin\Type\FieldType\ConfigFieldItemInterface;
-use Drupal\field\FieldInterface;
+use Drupal\field\Plugin\Core\Entity\Field;
/**
* A common base class for configurable entity reference fields.
@@ -93,7 +93,7 @@ public function getPropertyDefinitions() {
* Copied from \Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem,
* since we cannot extend it.
*/
- public static function schema(FieldInterface $field) {
+ public static function schema(Field $field) {
$definition = \Drupal::service('plugin.manager.entity.field.field_type')->getDefinition($field->type);
$module = $definition['provider'];
module_load_install($module);
@@ -125,11 +125,11 @@ public function isEmpty() {
* Copied from \Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem,
* since we cannot extend it.
*/
- public function settingsForm(array $form, array &$form_state, $has_data) {
+ public function settingsForm(array $form, array &$form_state) {
if ($callback = $this->getLegacyCallback('settings_form')) {
// hook_field_settings_form() used to receive the $instance (not actually
// needed), and the value of field_has_data().
- return $callback($this->getInstance()->getField(), $this->getInstance(), $has_data);
+ return $callback($this->getInstance()->getField(), $this->getInstance(), $this->getInstance()->getField()->hasData());
}
return array();
}
diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigFieldItemBase.php b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigFieldItemBase.php
index 388ccbe..743ad5c 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigFieldItemBase.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigFieldItemBase.php
@@ -34,7 +34,7 @@ public function getInstance() {
/**
* {@inheritdoc}
*/
- public function settingsForm(array $form, array &$form_state, $has_data) {
+ public function settingsForm(array $form, array &$form_state) {
return array();
}
diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigFieldItemInterface.php b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigFieldItemInterface.php
index a584640..394ec01 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigFieldItemInterface.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigFieldItemInterface.php
@@ -8,7 +8,7 @@
namespace Drupal\field\Plugin\Type\FieldType;
use Drupal\Core\Entity\Field\FieldItemInterface;
-use Drupal\field\FieldInterface;
+use Drupal\field\Plugin\Core\Entity\Field;
/**
* Interface definition for 'configurable field type' plugins.
@@ -18,7 +18,7 @@
/**
* Returns the field instance definition.
*
- * @var \Drupal\field\FieldInstanceInterface
+ * @var \Drupal\field\Plugin\Core\Entity\FieldInstance
*/
public function getInstance();
@@ -29,7 +29,7 @@ public function getInstance();
* creation of the field. No field instances exist by then, and it is not
* possible to instantiate a FieldItemInterface object yet.
*
- * @param \Drupal\field\FieldInterface $field
+ * @param \Drupal\field\Plugin\Core\Entity\Field $field
* The field definition.
*
* @return array
@@ -54,31 +54,24 @@ public function getInstance();
* specify another field as related, only existing SQL tables,
* such as {taxonomy_term_data}.
*/
- public static function schema(FieldInterface $field);
+ public static function schema(Field $field);
/**
* Returns a form for the field-level settings.
*
* Invoked from \Drupal\field_ui\Form\FieldEditForm to allow administrators to
- * configure field-level settings.
- *
- * Field storage might reject field definition changes that affect the field
- * storage schema if the field already has data. When the $has_data parameter
- * is TRUE, the form should not allow changing the settings that take part in
- * the schema() method. It is recommended to set #access to FALSE on the
- * corresponding elements.
+ * configure field-level settings. If the field already has data, the form
+ * should only include the settings that are safe to change.
*
* @param array $form
* The form where the settings form is being included in.
* @param array $form_state
* The form state of the (entire) configuration form.
- * @param bool $has_data
- * TRUE if the field already has data, FALSE if not.
*
* @return
* The form definition for the field settings.
*/
- public function settingsForm(array $form, array &$form_state, $has_data);
+ public function settingsForm(array $form, array &$form_state);
/**
* Returns a form for the instance-level settings.
diff --git a/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php
index 26e0a10..f5ab447 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php
@@ -9,7 +9,7 @@
use Drupal\Core\Entity\Field\PrepareCacheInterface;
use Drupal\field\Plugin\Type\FieldType\ConfigFieldItemBase;
-use Drupal\field\FieldInterface;
+use Drupal\field\Plugin\Core\Entity\Field;
/**
* Plugin implementation for legacy field types.
@@ -29,7 +29,7 @@
/**
* {@inheritdoc}
*/
- public static function schema(FieldInterface $field) {
+ public static function schema(Field $field) {
$definition = \Drupal::service('plugin.manager.entity.field.field_type')->getDefinition($field->type);
$module = $definition['provider'];
module_load_install($module);
@@ -55,11 +55,11 @@ public function isEmpty() {
/**
* {@inheritdoc}
*/
- public function settingsForm(array $form, array &$form_state, $has_data) {
+ public function settingsForm(array $form, array &$form_state) {
if ($callback = $this->getLegacyCallback('settings_form')) {
// hook_field_settings_form() used to receive the $instance (not actually
// needed), and the value of field_has_data().
- return $callback($this->getInstance()->getField(), $this->getInstance(), $has_data);
+ return $callback($this->getInstance()->getField(), $this->getInstance(), $this->getInstance()->getField()->hasData());
}
return array();
}
diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
index 8e16c3e..70c2236 100644
--- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
@@ -64,7 +64,7 @@ function testCreateField() {
$this->assertEqual($field_config['settings'], $field_type['settings'], 'Default field settings have been written.');
// Ensure that default storage was set.
- $this->assertEqual($field_config['storage']['type'], \Drupal::config('field.settings')->get('default_storage'), 'The field type is properly saved.');
+ $this->assertEqual($field_config['storage']['type'], config('field.settings')->get('default_storage'), 'The field type is properly saved.');
// Guarantee that the name is unique.
try {
diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
index b263859..b7c600e 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
@@ -92,7 +92,7 @@ function testFieldFormSingle() {
$this->drupalGet('entity_test/add');
// Create token value expected for description.
- $token_description = check_plain(\Drupal::config('system.site')->get('name')) . '_description';
+ $token_description = check_plain(config('system.site')->get('name')) . '_description';
$this->assertText($token_description, 'Token replacement for description is displayed');
$this->assertFieldByName("{$field_name}[$langcode][0][value]", '', 'Widget is displayed');
$this->assertNoField("{$field_name}[$langcode][1][value]", 'No extraneous widget is displayed');
diff --git a/core/modules/field_sql_storage/field_sql_storage.install b/core/modules/field_sql_storage/field_sql_storage.install
index 5c9eef2..8d14ca8 100644
--- a/core/modules/field_sql_storage/field_sql_storage.install
+++ b/core/modules/field_sql_storage/field_sql_storage.install
@@ -96,7 +96,7 @@ function field_sql_storage_update_8000(&$sandbox) {
// Retrieve the next field definition. When the index exceeds the number of
// 'configuration' fields, use it to iterate on deleted fields.
if (isset($config_names[$sandbox['index']])) {
- $field_config = Drupal::config($config_names[$sandbox['index']])->get();
+ $field_config = config($config_names[$sandbox['index']])->get();
}
else {
$field_config = $deleted_fields[$sandbox['index'] - count($config_names)];
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php
index d2208a1..621c08d 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php
@@ -92,7 +92,7 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL,
$field_types = $this->fieldTypeManager->getDefinitions();
// Field prefix.
- $field_prefix = \Drupal::config('field_ui.settings')->get('field_prefix');
+ $field_prefix = config('field_ui.settings')->get('field_prefix');
$form += array(
'#entity_type' => $this->entity_type,
@@ -327,7 +327,7 @@ protected function validateAddNew(array $form, array &$form_state) {
$field_name = $field['field_name'];
// Add the field prefix.
- $field_name = \Drupal::config('field_ui.settings')->get('field_prefix') . $field_name;
+ $field_name = config('field_ui.settings')->get('field_prefix') . $field_name;
form_set_value($form['fields']['_add_new_field']['field_name'], $field_name, $form_state);
}
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php
index f40e32a..305596f 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php
@@ -138,7 +138,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac
// FieldItem.
$ids = (object) array('entity_type' => $this->instance['entity_type'], 'bundle' => $this->instance['bundle'], 'entity_id' => NULL);
$entity = _field_create_entity_from_ids($ids);
- $form['field']['settings'] += $this->getFieldItem($entity, $field['field_name'])->settingsForm($form, $form_state, $field->hasData());
+ $form['field']['settings'] += $this->getFieldItem($entity, $field['field_name'])->settingsForm($form, $form_state);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save field settings'));
diff --git a/core/modules/file/config/views.view.file_usage.yml b/core/modules/file/config/views.view.file_usage.yml
new file mode 100644
index 0000000..8b76872
--- /dev/null
+++ b/core/modules/file/config/views.view.file_usage.yml
@@ -0,0 +1,378 @@
+base_field: fid
+base_table: file_managed
+core: 8.x
+description: 'Displays file usage information for a given file.'
+status: '1'
+display:
+ page_1:
+ display_plugin: page
+ id: page_1
+ display_title: Page
+ position: '1'
+ display_options:
+ path: admin/content/files/usage/%
+ menu:
+ type: none
+ title: 'File usage'
+ description: 'Usages list for a given file.'
+ name: admin
+ weight: '0'
+ context: '0'
+ default:
+ display_plugin: default
+ id: default
+ display_title: Master
+ position: '1'
+ display_options:
+ access:
+ type: perm
+ options:
+ perm: 'access files overview'
+ cache:
+ type: none
+ options: { }
+ query:
+ type: views_query
+ options:
+ disable_sql_rewrite: '0'
+ distinct: '0'
+ slave: '0'
+ query_comment: ''
+ query_tags: { }
+ exposed_form:
+ type: basic
+ options:
+ submit_button: Apply
+ reset_button: '0'
+ reset_button_label: Reset
+ exposed_sorts_label: 'Sort by'
+ expose_sort_order: '1'
+ sort_asc_label: Asc
+ sort_desc_label: Desc
+ pager:
+ type: full
+ options:
+ items_per_page: '10'
+ offset: '0'
+ id: '0'
+ total_pages: ''
+ expose:
+ items_per_page: '0'
+ items_per_page_label: 'Items per page'
+ items_per_page_options: '5, 10, 20, 40, 60'
+ items_per_page_options_all: '0'
+ items_per_page_options_all_label: '- All -'
+ offset: '0'
+ offset_label: Offset
+ tags:
+ previous: '‹ previous'
+ next: 'next ›'
+ first: '« first'
+ last: 'last »'
+ quantity: '9'
+ style:
+ type: table
+ options:
+ grouping: { }
+ row_class: ''
+ default_row_class: '1'
+ row_class_special: '1'
+ override: '1'
+ sticky: '0'
+ summary: ''
+ columns:
+ entity_label: entity_label
+ type: type
+ module: module
+ count: count
+ info:
+ entity_label:
+ sortable: '1'
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: '0'
+ responsive: ''
+ type:
+ sortable: '1'
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: '0'
+ responsive: 'priority-medium'
+ module:
+ sortable: '0'
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: '0'
+ responsive: 'priority-low'
+ count:
+ sortable: '0'
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: '0'
+ responsive: ''
+ default: 'entity_label'
+ empty_table: '1'
+ row:
+ type: fields
+ fields:
+ entity_label:
+ id: entity_label
+ table: file_usage
+ field: entity_label
+ relationship: none
+ group_type: group
+ admin_label: ''
+ label: 'Entity'
+ exclude: '0'
+ alter:
+ alter_text: '0'
+ text: ''
+ make_link: '0'
+ path: ''
+ absolute: '0'
+ external: '0'
+ replace_spaces: '0'
+ path_case: none
+ trim_whitespace: '0'
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: '0'
+ max_length: ''
+ word_boundary: '1'
+ ellipsis: '1'
+ more_link: '0'
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: '0'
+ trim: '0'
+ preserve_tags: ''
+ html: '0'
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: '1'
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: '1'
+ empty: ''
+ hide_empty: '0'
+ empty_zero: '0'
+ hide_alter_empty: '1'
+ link_to_entity: '1'
+ plugin_id: file_usage_entity_label
+ type:
+ id: type
+ table: file_usage
+ field: type
+ relationship: none
+ group_type: group
+ admin_label: ''
+ label: 'Entity type'
+ exclude: '0'
+ alter:
+ alter_text: '0'
+ text: ''
+ make_link: '0'
+ path: ''
+ absolute: '0'
+ external: '0'
+ replace_spaces: '0'
+ path_case: none
+ trim_whitespace: '0'
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: '0'
+ max_length: ''
+ word_boundary: '1'
+ ellipsis: '1'
+ more_link: '0'
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: '0'
+ trim: '0'
+ preserve_tags: ''
+ html: '0'
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: '1'
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: '1'
+ empty: ''
+ hide_empty: '0'
+ empty_zero: '0'
+ hide_alter_empty: '1'
+ plugin_id: standard
+ module:
+ id: module
+ table: file_usage
+ field: module
+ relationship: none
+ group_type: group
+ admin_label: ''
+ label: 'Registering module'
+ exclude: '0'
+ alter:
+ alter_text: '0'
+ text: ''
+ make_link: '0'
+ path: ''
+ absolute: '0'
+ external: '0'
+ replace_spaces: '0'
+ path_case: none
+ trim_whitespace: '0'
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: '0'
+ max_length: ''
+ word_boundary: '1'
+ ellipsis: '1'
+ more_link: '0'
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: '0'
+ trim: '0'
+ preserve_tags: ''
+ html: '0'
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: '1'
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: '1'
+ empty: ''
+ hide_empty: '0'
+ empty_zero: '0'
+ hide_alter_empty: '1'
+ plugin_id: standard
+ count:
+ id: count
+ table: file_usage
+ field: count
+ relationship: none
+ group_type: group
+ admin_label: ''
+ label: 'Use count'
+ exclude: '0'
+ alter:
+ alter_text: '0'
+ text: ''
+ make_link: '0'
+ path: ''
+ absolute: '0'
+ external: '0'
+ replace_spaces: '0'
+ path_case: none
+ trim_whitespace: '0'
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: '0'
+ max_length: ''
+ word_boundary: '1'
+ ellipsis: '1'
+ more_link: '0'
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: '0'
+ trim: '0'
+ preserve_tags: ''
+ html: '0'
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: '1'
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: '1'
+ empty: ''
+ hide_empty: '0'
+ empty_zero: '0'
+ hide_alter_empty: '1'
+ set_precision: '0'
+ precision: '0'
+ decimal: .
+ separator: ','
+ format_plural: '0'
+ format_plural_singular: '1'
+ format_plural_plural: '@count'
+ prefix: ''
+ suffix: ''
+ plugin_id: numeric
+ filters: { }
+ sorts: { }
+ title: 'File usage'
+ header: { }
+ footer: { }
+ empty: { }
+ relationships: { }
+ arguments:
+ fid:
+ id: fid
+ table: file_managed
+ field: fid
+ relationship: none
+ group_type: group
+ admin_label: ''
+ default_action: 'not found'
+ exception:
+ value: all
+ title_enable: '0'
+ title: All
+ title_enable: '1'
+ title: 'File usage information for %1'
+ breadcrumb_enable: '0'
+ breadcrumb: ''
+ default_argument_type: fixed
+ default_argument_options:
+ argument: ''
+ default_argument_skip_url: '0'
+ summary_options:
+ base_path: ''
+ count: '1'
+ items_per_page: '25'
+ override: '0'
+ summary:
+ sort_order: asc
+ number_of_records: '0'
+ format: default_summary
+ specify_validation: '0'
+ validate:
+ type: none
+ fail: 'not found'
+ validate_options: { }
+ break_phrase: '0'
+ not: '0'
+ plugin_id: file_fid
+label: 'File usage'
+module: file
+id: file_usage
+tag: 'default'
+uuid: 360a2cdb-a14c-4b41-9827-3930a483caf8
+langcode: en
diff --git a/core/modules/file/config/views.view.files.yml b/core/modules/file/config/views.view.files.yml
index d88bd0a..b0b182d 100644
--- a/core/modules/file/config/views.view.files.yml
+++ b/core/modules/file/config/views.view.files.yml
@@ -8,7 +8,7 @@ display:
display_plugin: default
id: default
display_title: Master
- position: '0'
+ position: '1'
display_options:
access:
type: perm
@@ -36,23 +36,9 @@ display:
sort_asc_label: Asc
sort_desc_label: Desc
pager:
- type: mini
+ type: full
options:
items_per_page: '50'
- offset: '0'
- id: '0'
- total_pages: ''
- tags:
- previous: '‹ previous'
- next: 'next ›'
- expose:
- items_per_page: '0'
- items_per_page_label: 'Items per page'
- items_per_page_options: '5, 10, 20, 40, 60'
- items_per_page_options_all: '0'
- items_per_page_options_all_label: '- All -'
- offset: '0'
- offset_label: Offset
style:
type: table
options:
@@ -62,11 +48,8 @@ display:
row_class_special: '1'
override: '1'
sticky: '0'
- caption: ''
summary: ''
- description: ''
columns:
- fid: fid
filename: filename
filemime: filemime
filesize: filesize
@@ -74,13 +57,6 @@ display:
timestamp: timestamp
count: count
info:
- fid:
- sortable: '0'
- default_sort_order: asc
- align: ''
- separator: ''
- empty_column: '0'
- responsive: ''
filename:
sortable: '1'
default_sort_order: asc
@@ -464,7 +440,7 @@ display:
exposed: '1'
expose:
operator_id: filemime_op
- label: Filename
+ label: 'Filename'
description: ''
use_operator: '0'
operator: filename_op
@@ -581,11 +557,10 @@ display:
relationships: { }
arguments: { }
group_by: '1'
- show_admin_links: '1'
page_1:
display_plugin: page
id: page_1
- display_title: 'Files overview'
+ display_title: Page
position: '1'
display_options:
path: admin/content/files
@@ -596,357 +571,6 @@ display:
name: admin
weight: '0'
context: '0'
- display_description: ''
- defaults:
- pager: '1'
- pager_options: '1'
- page_2:
- display_plugin: page
- id: page_2
- display_title: 'File usage'
- position: '2'
- display_options:
- display_description: ''
- path: admin/content/files/usage/%
- empty: { }
- defaults:
- empty: '0'
- pager: '0'
- pager_options: '0'
- filters: '0'
- filter_groups: '0'
- fields: '0'
- group_by: '0'
- title: '0'
- arguments: '0'
- style: '0'
- row: '0'
- pager:
- type: mini
- options:
- items_per_page: '10'
- offset: '0'
- id: '0'
- total_pages: ''
- tags:
- previous: '‹ previous'
- next: 'next ›'
- expose:
- items_per_page: '0'
- items_per_page_label: 'Items per page'
- items_per_page_options: '5, 10, 20, 40, 60'
- items_per_page_options_all: '0'
- items_per_page_options_all_label: '- All -'
- offset: '0'
- offset_label: Offset
- pager_options: ''
- filters: { }
- filter_groups:
- operator: AND
- groups: { }
- fields:
- entity_label:
- id: entity_label
- table: file_usage
- field: entity_label
- relationship: none
- group_type: group
- admin_label: ''
- label: Entity
- exclude: '0'
- alter:
- alter_text: '0'
- text: ''
- make_link: '0'
- path: ''
- absolute: '0'
- external: '0'
- replace_spaces: '0'
- path_case: none
- trim_whitespace: '0'
- alt: ''
- rel: ''
- link_class: ''
- prefix: ''
- suffix: ''
- target: ''
- nl2br: '0'
- max_length: ''
- word_boundary: '1'
- ellipsis: '1'
- more_link: '0'
- more_link_text: ''
- more_link_path: ''
- strip_tags: '0'
- trim: '0'
- preserve_tags: ''
- html: '0'
- element_type: ''
- element_class: ''
- element_label_type: ''
- element_label_class: ''
- element_label_colon: '1'
- element_wrapper_type: ''
- element_wrapper_class: ''
- element_default_classes: '1'
- empty: ''
- hide_empty: '0'
- empty_zero: '0'
- hide_alter_empty: '1'
- link_to_entity: '1'
- plugin_id: entity_label
- provider: views
- type:
- id: type
- table: file_usage
- field: type
- relationship: none
- group_type: group
- admin_label: ''
- label: 'Entity type'
- exclude: '0'
- alter:
- alter_text: '0'
- text: ''
- make_link: '0'
- path: ''
- absolute: '0'
- external: '0'
- replace_spaces: '0'
- path_case: none
- trim_whitespace: '0'
- alt: ''
- rel: ''
- link_class: ''
- prefix: ''
- suffix: ''
- target: ''
- nl2br: '0'
- max_length: ''
- word_boundary: '1'
- ellipsis: '1'
- more_link: '0'
- more_link_text: ''
- more_link_path: ''
- strip_tags: '0'
- trim: '0'
- preserve_tags: ''
- html: '0'
- element_type: ''
- element_class: ''
- element_label_type: ''
- element_label_class: ''
- element_label_colon: '1'
- element_wrapper_type: ''
- element_wrapper_class: ''
- element_default_classes: '1'
- empty: ''
- hide_empty: '0'
- empty_zero: '0'
- hide_alter_empty: '1'
- plugin_id: standard
- provider: views
- module:
- id: module
- table: file_usage
- field: module
- relationship: none
- group_type: group
- admin_label: ''
- label: 'Registering module'
- exclude: '0'
- alter:
- alter_text: '0'
- text: ''
- make_link: '0'
- path: ''
- absolute: '0'
- external: '0'
- replace_spaces: '0'
- path_case: none
- trim_whitespace: '0'
- alt: ''
- rel: ''
- link_class: ''
- prefix: ''
- suffix: ''
- target: ''
- nl2br: '0'
- max_length: ''
- word_boundary: '1'
- ellipsis: '1'
- more_link: '0'
- more_link_text: ''
- more_link_path: ''
- strip_tags: '0'
- trim: '0'
- preserve_tags: ''
- html: '0'
- element_type: ''
- element_class: ''
- element_label_type: ''
- element_label_class: ''
- element_label_colon: '1'
- element_wrapper_type: ''
- element_wrapper_class: ''
- element_default_classes: '1'
- empty: ''
- hide_empty: '0'
- empty_zero: '0'
- hide_alter_empty: '1'
- plugin_id: standard
- provider: views
- count:
- id: count
- table: file_usage
- field: count
- relationship: none
- group_type: group
- admin_label: ''
- label: 'Use count'
- exclude: '0'
- alter:
- alter_text: '0'
- text: ''
- make_link: '0'
- path: ''
- absolute: '0'
- external: '0'
- replace_spaces: '0'
- path_case: none
- trim_whitespace: '0'
- alt: ''
- rel: ''
- link_class: ''
- prefix: ''
- suffix: ''
- target: ''
- nl2br: '0'
- max_length: ''
- word_boundary: '1'
- ellipsis: '1'
- more_link: '0'
- more_link_text: ''
- more_link_path: ''
- strip_tags: '0'
- trim: '0'
- preserve_tags: ''
- html: '0'
- element_type: ''
- element_class: ''
- element_label_type: ''
- element_label_class: ''
- element_label_colon: '1'
- element_wrapper_type: ''
- element_wrapper_class: ''
- element_default_classes: '1'
- empty: ''
- hide_empty: '0'
- empty_zero: '0'
- hide_alter_empty: '1'
- set_precision: '0'
- precision: '0'
- decimal: .
- separator: ','
- format_plural: '0'
- format_plural_singular: '1'
- format_plural_plural: '@count'
- prefix: ''
- suffix: ''
- plugin_id: numeric
- provider: views
- group_by: '0'
- title: 'File usage'
- arguments:
- fid:
- id: fid
- table: file_managed
- field: fid
- relationship: none
- group_type: group
- admin_label: ''
- default_action: 'not found'
- exception:
- value: all
- title_enable: '0'
- title: All
- title_enable: '1'
- title: 'File usage information for %1'
- breadcrumb_enable: '0'
- breadcrumb: ''
- default_argument_type: fixed
- default_argument_options:
- argument: ''
- default_argument_skip_url: '0'
- summary_options:
- base_path: ''
- count: '1'
- items_per_page: '25'
- override: '0'
- summary:
- sort_order: asc
- number_of_records: '0'
- format: default_summary
- specify_validation: '0'
- validate:
- type: none
- fail: 'not found'
- validate_options: { }
- break_phrase: '0'
- not: '0'
- plugin_id: file_fid
- provider: file
- style:
- type: table
- options:
- grouping: { }
- row_class: ''
- default_row_class: '1'
- row_class_special: '1'
- override: '1'
- sticky: '0'
- caption: ''
- summary: ''
- description: ''
- columns:
- entity_label: entity_label
- type: type
- module: module
- count: count
- info:
- entity_label:
- sortable: '1'
- default_sort_order: asc
- align: ''
- separator: ''
- empty_column: '0'
- responsive: ''
- type:
- sortable: '1'
- default_sort_order: asc
- align: ''
- separator: ''
- empty_column: '0'
- responsive: priority-medium
- module:
- sortable: '0'
- default_sort_order: asc
- align: ''
- separator: ''
- empty_column: '0'
- responsive: priority-low
- count:
- sortable: '0'
- default_sort_order: asc
- align: ''
- separator: ''
- empty_column: '0'
- responsive: ''
- default: entity_label
- empty_table: '1'
- row:
- type: fields
- options: { }
label: Files
module: file
id: files
diff --git a/core/modules/file/css/file.admin.css b/core/modules/file/css/file.admin.css
index 585ea62..24f90e1 100644
--- a/core/modules/file/css/file.admin.css
+++ b/core/modules/file/css/file.admin.css
@@ -9,7 +9,7 @@
*/
.form-managed-file .form-file,
.form-managed-file .form-submit {
- margin: 0 0.5em;
+ margin: 0;
}
.form-managed-file .progress-disabled {
display: inline;
diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc
index 3e3806e..6445527 100644
--- a/core/modules/file/file.field.inc
+++ b/core/modules/file/file.field.inc
@@ -414,7 +414,7 @@ function file_field_widget_process($element, &$form_state, $form) {
// Add the description field if enabled.
if ($element['#description_field'] && $item['fids']) {
- $config = Drupal::config('file.settings');
+ $config = config('file.settings');
$element['description'] = array(
'#type' => $config->get('description.type'),
'#title' => t('Description'),
diff --git a/core/modules/file/file.install b/core/modules/file/file.install
index 37b89ae..16611c2 100644
--- a/core/modules/file/file.install
+++ b/core/modules/file/file.install
@@ -303,7 +303,7 @@ function file_update_8002() {
*/
function file_update_8003() {
foreach (config_get_storage_names_with_prefix('field.field.') as $config_name) {
- $field_config = Drupal::config($config_name);
+ $field_config = config($config_name);
// Only update file fields that use the default SQL storage.
if (in_array($field_config->get('type'), array('file', 'image')) && $field_config->get('storage.type') == 'field_sql_storage') {
$field = new Field($field_config->get());
@@ -340,19 +340,3 @@ function file_update_8003() {
}
}
}
-
-/*
- * Convert the 'filesize' column in {file_managed} to a bigint.
- */
-function file_update_8004() {
- $spec = array(
- 'description' => 'The size of the file in bytes.',
- 'type' => 'int',
- 'size' => 'big',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
- );
- db_change_field('file_managed', 'filesize', 'filesize', $spec);
-}
-
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 018eef6..d37a1ba 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -9,6 +9,7 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Template\Attribute;
use Symfony\Component\HttpFoundation\JsonResponse;
+use Drupal\file\FileUsage\DatabaseFileUsageBackend;
use Drupal\file\FileUsage\FileUsageInterface;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
@@ -39,15 +40,6 @@ function file_help($path, $arg) {
}
/**
- * Implements hook_modules_uninstalled().
- */
-function file_modules_uninstalled($modules) {
- foreach ($modules as $module) {
- file_usage()->deleteByModule($module);
- }
-}
-
-/**
* Implements hook_menu().
*/
function file_menu() {
@@ -414,7 +406,7 @@ function file_validate_size(File $file, $file_limit = 0, $user_limit = 0) {
}
/**
- * Checks that the file is recognized by Image::getInfo() as an image.
+ * Checks that the file is recognized by image_get_info() as an image.
*
* @param Drupal\file\File $file
* A file entity.
@@ -427,8 +419,8 @@ function file_validate_size(File $file, $file_limit = 0, $user_limit = 0) {
function file_validate_is_image(File $file) {
$errors = array();
- $image = Drupal::service('image.factory')->get($file->getFileUri());
- if (!$image->getExtension()) {
+ $info = image_get_info($file->getFileUri());
+ if (!$info || empty($info['extension'])) {
$errors[] = t('Only JPEG, PNG and GIF images are allowed.');
}
@@ -462,19 +454,16 @@ function file_validate_image_resolution(File $file, $maximum_dimensions = 0, $mi
$errors = array();
// Check first that the file is an image.
- $image_factory = Drupal::service('image.factory');
- $image = $image_factory->get($file->getFileUri());
- if ($image->getExtension()) {
+ if ($info = image_get_info($file->getFileUri())) {
if ($maximum_dimensions) {
// Check that it is smaller than the given dimensions.
list($width, $height) = explode('x', $maximum_dimensions);
- if ($image->getWidth() > $width || $image->getHeight() > $height) {
+ if ($info['width'] > $width || $info['height'] > $height) {
// Try to resize the image to fit the dimensions.
- $image = $image_factory->get($file->getFileUri());
- if ($image->getResource()) {
- $image->scale($width, $height);
- $image->save();
- $file->filesize = $image->getFileSize();
+ if ($image = image_load($file->getFileUri())) {
+ image_scale($image, $width, $height);
+ image_save($image);
+ $file->filesize = $image->info['file_size'];
drupal_set_message(t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $maximum_dimensions)));
}
else {
@@ -486,7 +475,7 @@ function file_validate_image_resolution(File $file, $maximum_dimensions = 0, $mi
if ($minimum_dimensions) {
// Check that it is larger than the given dimensions.
list($width, $height) = explode('x', $minimum_dimensions);
- if ($image->getWidth() < $width || $image->getHeight() < $height) {
+ if ($info['width'] < $width || $info['height'] < $height) {
$errors[] = t('The image is too small; the minimum dimensions are %dimensions pixels.', array('%dimensions' => $minimum_dimensions));
}
}
@@ -875,7 +864,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination
// rename filename.php.foo and filename.php to filename.php.foo.txt and
// filename.php.txt, respectively). Don't rename if 'allow_insecure_uploads'
// evaluates to TRUE.
- if (!Drupal::config('system.file')->get('allow_insecure_uploads') && preg_match('/\.(php|pl|py|cgi|asp|js)(\.|$)/i', $file->getFilename()) && (substr($file->getFilename(), -4) != '.txt')) {
+ if (!config('system.file')->get('allow_insecure_uploads') && preg_match('/\.(php|pl|py|cgi|asp|js)(\.|$)/i', $file->getFilename()) && (substr($file->getFilename(), -4) != '.txt')) {
$file->setMimeType('text/plain');
$file->setFileUri($file->getFileUri() . '.txt');
$file->setFilename($file->getFilename() . '.txt');
@@ -1663,7 +1652,7 @@ function file_icon_url(File $file, $icon_directory = NULL) {
function file_icon_path(File $file, $icon_directory = NULL) {
// Use the default set of icons if none specified.
if (!isset($icon_directory)) {
- $icon_directory = Drupal::config('file.settings')->get('icon.directory');
+ $icon_directory = config('file.settings')->get('icon.directory');
}
// If there's an icon matching the exact mimetype, go for it.
diff --git a/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php b/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php
index 5b9b417..80163c4 100644
--- a/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php
+++ b/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php
@@ -46,7 +46,7 @@ public function __construct(Connection $connection, $table = 'file_usage') {
}
/**
- * {@inheritdoc}
+ * Implements Drupal\file\FileUsage\FileUsageInterface::add().
*/
public function add(File $file, $module, $type, $id, $count = 1) {
$this->connection->merge($this->tableName)
@@ -64,7 +64,7 @@ public function add(File $file, $module, $type, $id, $count = 1) {
}
/**
- * {@inheritdoc}
+ * Implements Drupal\file\FileUsage\FileUsageInterface::delete().
*/
public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1) {
// Delete rows that have a exact or less value to prevent empty rows.
@@ -99,7 +99,7 @@ public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1
}
/**
- * {@inheritdoc}
+ * Implements Drupal\file\FileUsage\FileUsageInterface::listUsage().
*/
public function listUsage(File $file) {
$result = $this->connection->select($this->tableName, 'f')
@@ -113,14 +113,4 @@ public function listUsage(File $file) {
}
return $references;
}
-
- /**
- * {@inheritdoc}
- */
- public function deleteByModule($module) {
- $this->connection->delete($this->tableName)
- ->condition('module', $module)
- ->execute();
- }
-
}
diff --git a/core/modules/file/lib/Drupal/file/FileUsage/FileUsageInterface.php b/core/modules/file/lib/Drupal/file/FileUsage/FileUsageInterface.php
index 1e06dbb..d9a248d 100644
--- a/core/modules/file/lib/Drupal/file/FileUsage/FileUsageInterface.php
+++ b/core/modules/file/lib/Drupal/file/FileUsage/FileUsageInterface.php
@@ -72,13 +72,4 @@ public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1
*
*/
public function listUsage(File $file);
-
- /**
- * Removes all records for a specific module; useful for uninstalling modules.
- *
- * @param string $module
- * The name of the module using files.
- */
- public function deleteByModule($module);
-
}
diff --git a/core/modules/file/lib/Drupal/file/Plugin/views/field/Extension.php b/core/modules/file/lib/Drupal/file/Plugin/views/field/Extension.php
index add942f..ff98cfd 100644
--- a/core/modules/file/lib/Drupal/file/Plugin/views/field/Extension.php
+++ b/core/modules/file/lib/Drupal/file/Plugin/views/field/Extension.php
@@ -9,7 +9,6 @@
use Drupal\Component\Annotation\PluginID;
use Drupal\views\Plugin\views\field\FieldPluginBase;
-use Drupal\views\ResultRow;
/**
* Returns a pure file extension of the file, for example 'module'.
@@ -42,10 +41,7 @@ public function buildOptionsForm(&$form, &$form_state) {
);
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
$value = $this->getValue($values);
if (!$this->options['extension_detect_tar']) {
if (preg_match('/\.([^\.]+)$/', $value, $match)) {
diff --git a/core/modules/file/lib/Drupal/file/Plugin/views/field/File.php b/core/modules/file/lib/Drupal/file/Plugin/views/field/File.php
index df5056f..bc492e2 100644
--- a/core/modules/file/lib/Drupal/file/Plugin/views/field/File.php
+++ b/core/modules/file/lib/Drupal/file/Plugin/views/field/File.php
@@ -66,10 +66,7 @@ protected function renderLink($data, ResultRow $values) {
return $data;
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
$value = $this->getValue($values);
return $this->renderLink($this->sanitizeValue($value), $values);
}
diff --git a/core/modules/file/lib/Drupal/file/Plugin/views/field/FileMime.php b/core/modules/file/lib/Drupal/file/Plugin/views/field/FileMime.php
index 8c6ab7e..1756460 100644
--- a/core/modules/file/lib/Drupal/file/Plugin/views/field/FileMime.php
+++ b/core/modules/file/lib/Drupal/file/Plugin/views/field/FileMime.php
@@ -8,7 +8,6 @@
namespace Drupal\file\Plugin\views\field;
use Drupal\Component\Annotation\PluginID;
-use Drupal\views\ResultRow;
/**
* Field handler to add rendering MIME type images as an option on the filemime field.
@@ -34,10 +33,7 @@ public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
$data = $values->{$this->field_alias};
if (!empty($this->options['filemime_image']) && $data !== NULL && $data !== '') {
$file_icon = array(
diff --git a/core/modules/file/lib/Drupal/file/Plugin/views/field/Status.php b/core/modules/file/lib/Drupal/file/Plugin/views/field/Status.php
index 4e17445..35179c4 100644
--- a/core/modules/file/lib/Drupal/file/Plugin/views/field/Status.php
+++ b/core/modules/file/lib/Drupal/file/Plugin/views/field/Status.php
@@ -9,7 +9,6 @@
use Drupal\Component\Annotation\PluginID;
use Drupal\views\Plugin\views\field\FieldPluginBase;
-use Drupal\views\ResultRow;
/**
* Field handler to translate a node type into its readable form.
@@ -20,10 +19,7 @@
*/
class Status extends FieldPluginBase {
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
$value = $this->getValue($values);
return _views_file_status($value);
}
diff --git a/core/modules/file/lib/Drupal/file/Plugin/views/field/Uri.php b/core/modules/file/lib/Drupal/file/Plugin/views/field/Uri.php
index 1191265..1ea01ed 100644
--- a/core/modules/file/lib/Drupal/file/Plugin/views/field/Uri.php
+++ b/core/modules/file/lib/Drupal/file/Plugin/views/field/Uri.php
@@ -8,7 +8,6 @@
namespace Drupal\file\Plugin\views\field;
use Drupal\Component\Annotation\PluginID;
-use Drupal\views\ResultRow;
/**
* Field handler to add rendering file paths as file URLs instead of as internal file URIs.
@@ -33,10 +32,7 @@ public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
$data = $values->{$this->field_alias};
if (!empty($this->options['file_download_path']) && $data !== NULL && $data !== '') {
$data = file_create_url($data);
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php b/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php
index e8a2f5d..2b2bc55 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php
@@ -94,7 +94,7 @@ function testFileListingPages() {
$this->assertLinkByHref(file_create_url($file->getFileUri()));
$this->assertLinkByHref('admin/content/files/usage/' . $file->id());
}
- $this->assertFalse(preg_match('/views-field-status priority-low\">\s*' . t('Temporary') . '/', $this->drupalGetContent()), 'All files are stored as permanent.');
+ $this->assertFalse(preg_match('/views-field-status priority-low\">\s*' . t('Temporary') . '/', $this->drupalGetContent()), t('All files are stored as permanent.'));
// Use one file two times and check usage information.
$orphaned_file = $nodes[1]->file->target_id;
@@ -112,6 +112,6 @@ function testFileListingPages() {
$this->assertRaw('admin/content/files/usage/' . $file->id() . '">' . $usage);
$result = $this->xpath("//td[contains(@class, 'views-field-status') and contains(text(), :value)]", array(':value' => t('Temporary')));
- $this->assertEqual(1, count($result), 'Unused file marked as temporary.');
+ $this->assertEqual(1, count($result), t('Unused file marked as temporary.'));
}
}
diff --git a/core/modules/file/lib/Drupal/file/Tests/RemoteFileSaveUploadTest.php b/core/modules/file/lib/Drupal/file/Tests/RemoteFileSaveUploadTest.php
index b9932b7..fb5e68b 100644
--- a/core/modules/file/lib/Drupal/file/Tests/RemoteFileSaveUploadTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/RemoteFileSaveUploadTest.php
@@ -27,6 +27,6 @@ public static function getInfo() {
function setUp() {
parent::setUp();
- \Drupal::config('system.file')->set('default_scheme', 'dummy-remote')->save();
+ config('system.file')->set('default_scheme', 'dummy-remote')->save();
}
}
diff --git a/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php b/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php
index 6246e5d..84261cb 100644
--- a/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php
@@ -180,7 +180,7 @@ function testHandleExtension() {
* Test dangerous file handling.
*/
function testHandleDangerousFile() {
- $config = \Drupal::config('system.file');
+ $config = config('system.file');
// Allow the .php extension and make sure it gets renamed to .txt for
// safety. Also check to make sure its MIME type was changed.
$edit = array(
@@ -224,7 +224,7 @@ function testHandleDangerousFile() {
*/
function testHandleFileMunge() {
// Ensure insecure uploads are disabled for this test.
- \Drupal::config('system.file')->set('allow_insecure_uploads', 0)->save();
+ config('system.file')->set('allow_insecure_uploads', 0)->save();
$this->image = file_move($this->image, $this->image->getFileUri() . '.foo.' . $this->image_extension);
// Reset the hook counters to get rid of the 'move' we just called.
diff --git a/core/modules/file/lib/Drupal/file/Tests/UsageTest.php b/core/modules/file/lib/Drupal/file/Tests/UsageTest.php
index 87806cc..17e51d8 100644
--- a/core/modules/file/lib/Drupal/file/Tests/UsageTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/UsageTest.php
@@ -53,44 +53,6 @@ function testGetUsage() {
}
/**
- * Tests file_usage()->deleteByModule().
- */
- function testDeleteByModule() {
- $file = $this->createFile();
- db_insert('file_usage')
- ->fields(array(
- 'fid' => $file->id(),
- 'module' => 'testing',
- 'type' => 'foo',
- 'id' => 1,
- 'count' => 1
- ))
- ->execute();
- db_insert('file_usage')
- ->fields(array(
- 'fid' => $file->id(),
- 'module' => 'testing',
- 'type' => 'bar',
- 'id' => 2,
- 'count' => 2
- ))
- ->execute();
- db_insert('file_usage')
- ->fields(array(
- 'fid' => $file->id(),
- 'module' => 'file',
- 'type' => 'bar',
- 'id' => 2,
- 'count' => 2
- ))
- ->execute();
-
- file_usage()->deleteByModule('testing');
-
- $this->assertIdentical(array('file' => array('bar' => array(2 => '2'))), file_usage()->listUsage($file), 'All records for the "testing" module have been deleted.');
- }
-
- /**
* Tests file_usage()->add().
*/
function testAddUsage() {
diff --git a/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php b/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php
index 5214aa4..8012c4d 100644
--- a/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php
@@ -87,9 +87,9 @@ function testFileValidateImageResolution() {
$errors = file_validate_image_resolution($this->image, '10x5');
$this->assertEqual(count($errors), 0, 'No errors should be reported when an oversized image can be scaled down.', 'File');
- $image = $this->container->get('image.factory')->get($this->image->getFileUri());
- $this->assertTrue($image->getWidth() <= 10, 'Image scaled to correct width.', 'File');
- $this->assertTrue($image->getHeight() <= 5, 'Image scaled to correct height.', 'File');
+ $info = image_get_info($this->image->getFileUri());
+ $this->assertTrue($info['width'] <= 10, 'Image scaled to correct width.', 'File');
+ $this->assertTrue($info['height'] <= 5, 'Image scaled to correct height.', 'File');
drupal_unlink('temporary://druplicon.png');
}
diff --git a/core/modules/filter/filter.install b/core/modules/filter/filter.install
index 8508e9d..b450c36 100644
--- a/core/modules/filter/filter.install
+++ b/core/modules/filter/filter.install
@@ -49,7 +49,7 @@ function filter_update_8001() {
$format['filters'] = $filters;
// Save the config object.
- $config = Drupal::config('filter.format.' . $id);
+ $config = config('filter.format.' . $id);
$config->setData($format);
$config->save();
}
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 58d3a07..1a0d9d1 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -584,7 +584,7 @@ function filter_fallback_format() {
// existing (and potentially unsafe) text format on the site automatically
// available to all users. Returning NULL at least guarantees that this
// cannot happen.
- return Drupal::config('filter.settings')->get('fallback_format');
+ return config('filter.settings')->get('fallback_format');
}
/**
@@ -839,7 +839,7 @@ function filter_process_format($element) {
// If multiple text formats are available, remove the fallback. The
// "always_show_fallback_choice" is a hidden variable that has no UI. It
// defaults to false.
- if (!Drupal::config('filter.settings')->get('always_show_fallback_choice')) {
+ if (!config('filter.settings')->get('always_show_fallback_choice')) {
$fallback_format = filter_fallback_format();
if ($element['#format'] !== $fallback_format && count($formats) > 1) {
unset($formats[$fallback_format]);
@@ -1209,7 +1209,7 @@ function _filter_url($text, $filter) {
// we cannot cleanly differ between protocols here without hard-coding MAILTO,
// so '//' is optional for all protocols.
// @see filter_xss_bad_protocol()
- $protocols = Drupal::config('system.filter')->get('protocols');
+ $protocols = config('system.filter')->get('protocols');
$protocols = implode(':(?://)?|', $protocols) . ':(?://)?';
$valid_url_path_characters = "[\p{L}\p{M}\p{N}!\*\';:=\+,\.\$\/%#\[\]\-_~@&]";
diff --git a/core/modules/filter/lib/Drupal/filter/FilterBag.php b/core/modules/filter/lib/Drupal/filter/FilterBag.php
index 0d521c6..599625c 100644
--- a/core/modules/filter/lib/Drupal/filter/FilterBag.php
+++ b/core/modules/filter/lib/Drupal/filter/FilterBag.php
@@ -7,8 +7,10 @@
namespace Drupal\filter;
+use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Plugin\DefaultPluginBag;
+use Drupal\Component\Utility\String;
/**
* A collection of filters.
@@ -46,8 +48,6 @@ public function getAll() {
// Retrieve all available filter plugin definitions.
if (!$this->definitions) {
$this->definitions = $this->manager->getDefinitions();
- // Do not allow the null filter to be used directly, only as a fallback.
- unset($this->definitions['filter_null']);
}
// Ensure that there is an instance of all available filters.
@@ -68,17 +68,25 @@ public function getAll() {
protected function initializePlugin($instance_id) {
// Filters have a 1:1 relationship to text formats and can be added and
// instantiated at any time.
- // @todo $configuration is the whole filter plugin instance configuration,
- // as contained in the text format configuration. The default
- // configuration is the filter plugin definition. Configuration should not
- // be contained in definitions. Move into a FilterBase::init() method.
- $configuration = $this->manager->getDefinition($instance_id);
- // Merge the actual configuration into the default configuration.
- if (isset($this->configurations[$instance_id])) {
- $configuration = NestedArray::mergeDeep($configuration, $this->configurations[$instance_id]);
+ $definition = $this->manager->getDefinition($instance_id);
+
+ if (isset($definition)) {
+ // $configuration is the whole filter plugin instance configuration, as
+ // contained in the text format configuration. The default configuration
+ // is the filter plugin definition.
+ // @todo Configuration should not be contained in definitions. Move into a
+ // FilterBase::init() method.
+ $configuration = $definition;
+ // Merge the actual configuration into the default configuration.
+ if (isset($this->configurations[$instance_id])) {
+ $configuration = NestedArray::mergeDeep($configuration, $this->configurations[$instance_id]);
+ }
+ $this->configurations[$instance_id] = $configuration;
+ parent::initializePlugin($instance_id);
+ }
+ else {
+ throw new PluginException(String::format("Unknown filter plugin ID '@filter'.", array('@filter' => $instance_id)));
}
- $this->configurations[$instance_id] = $configuration;
- parent::initializePlugin($instance_id);
}
/**
diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php b/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php
index e715e4a..98495d5 100644
--- a/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php
+++ b/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php
@@ -12,7 +12,6 @@
use Drupal\Core\Entity\EntityFormController;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Extension\ModuleHandlerInterface;
-use Drupal\filter\Plugin\Filter\FilterNull;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -116,14 +115,6 @@ public function form(array $form, array &$form_state) {
// Create filter plugin instances for all available filters, including both
// enabled/configured ones as well as new and not yet unconfigured ones.
$filters = $format->filters()->sort();
- foreach ($filters as $filter_id => $filter) {
- // When a filter is missing, it is replaced by the null filter. Remove it
- // here, so that saving the form will remove the missing filter.
- if ($filter instanceof FilterNull) {
- drupal_set_message(t('The %filter filter is missing, and will be removed once this format is saved.', array('%filter' => $filter_id)), 'warning');
- $filters->removeInstanceID($filter_id);
- }
- }
// Filter status.
$form['filters']['status'] = array(
diff --git a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php
index 0189bc5..3d9b649 100644
--- a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php
+++ b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php
@@ -40,13 +40,4 @@ public function __construct(\Traversable $namespaces) {
$this->factory = new ContainerFactory($this);
}
- /**
- * {@inheritdoc}
- */
- public function getDefinition($plugin_id) {
- $plugins = $this->getDefinitions();
- // If the requested filter is missing, use the null filter.
- return isset($plugins[$plugin_id]) ? $plugins[$plugin_id] : $plugins['filter_null'];
- }
-
}
diff --git a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php
index 04c312a..177ccdb 100644
--- a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php
+++ b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php
@@ -102,7 +102,7 @@ public function tips($long = FALSE) {
$output .= '' . t('This site allows HTML content. While learning all of HTML may feel intimidating, learning how to use a very small number of the most basic HTML "tags" is very easy. This table provides examples for each tag that is enabled on this site.') . '
';
$output .= '' . t('For more information see W3C\'s HTML Specifications or use your favorite search engine to find other sites that explain HTML.', array('@html-specifications' => 'http://www.w3.org/TR/html/')) . '
';
$tips = array(
- 'a' => array(t('Anchors are used to make links to other pages.'), '' . check_plain(\Drupal::config('system.site')->get('name')) . ''),
+ 'a' => array(t('Anchors are used to make links to other pages.'), '' . check_plain(config('system.site')->get('name')) . ''),
'br' => array(t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), t('Text with
line break')),
'p' => array(t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '' . t('Paragraph one.') . '
' . t('Paragraph two.') . '
'),
'strong' => array(t('Strong', array(), array('context' => 'Font weight')), '' . t('Strong', array(), array('context' => 'Font weight')) . ''),
diff --git a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterNull.php b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterNull.php
deleted file mode 100644
index b48ab23..0000000
--- a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterNull.php
+++ /dev/null
@@ -1,72 +0,0 @@
-logged) {
- $this->logged = TRUE;
- watchdog('filter', 'Missing filter plugin: %filter.', array('%filter' => $plugin_id), WATCHDOG_ALERT);
- }
- parent::__construct($configuration, $plugin_id, $plugin_definition);
- }
-
- /**
- * {@inheritdoc}
- */
- public function process($text, $langcode, $cache, $cache_id) {
- return '';
- }
-
- /**
- * {@inheritdoc}
- */
- public function getHTMLRestrictions() {
- // Nothing is allowed.
- return array('allowed' => array());
- }
-
- /**
- * {@inheritdoc}
- */
- public function tips($long = FALSE) {
- return t('Missing filter. All text is removed');
- }
-
-}
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
index 5f3f6fd..5039305 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
@@ -248,7 +248,7 @@ function testFilterAdmin() {
// Use plain text and see if it escapes all tags, whether allowed or not.
// In order to test plain text, we have to enable the hidden variable for
// "show_fallback_format", which displays plain text in the format list.
- \Drupal::config('filter.settings')
+ config('filter.settings')
->set('always_show_fallback_choice', TRUE)
->save();
$edit = array();
@@ -256,7 +256,7 @@ function testFilterAdmin() {
$this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->drupalGet('node/' . $node->id());
$this->assertText(check_plain($text), 'The "Plain text" text format escapes all HTML tags.');
- \Drupal::config('filter.settings')
+ config('filter.settings')
->set('always_show_fallback_choice', FALSE)
->save();
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
index d3461f3..cd5a762 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
@@ -431,7 +431,7 @@ function testUrlFilter() {
),
// Absolute URL protocols.
// The list to test is found in the beginning of _filter_url() at
- // $protocols = \Drupal::config('system.filter')->get('protocols')... (approx line 1555).
+ // $protocols = config('system.filter')->get('protocols')... (approx line 1555).
'
https://example.com,
ftp://ftp.example.com,
diff --git a/core/modules/forum/forum.admin.inc b/core/modules/forum/forum.admin.inc
index c63b21f..7b19630 100644
--- a/core/modules/forum/forum.admin.inc
+++ b/core/modules/forum/forum.admin.inc
@@ -18,7 +18,7 @@
*/
function forum_overview($form, &$form_state) {
module_load_include('inc', 'taxonomy', 'taxonomy.admin');
- $config = Drupal::config('forum.settings');
+ $config = config('forum.settings');
$vid = $config->get('vocabulary');
$vocabulary = entity_load('taxonomy_vocabulary', $vid);
diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install
index 60efc30..cd7ebdb 100644
--- a/core/modules/forum/forum.install
+++ b/core/modules/forum/forum.install
@@ -24,7 +24,7 @@ function forum_enable() {
// Create the forum vocabulary if it does not exist.
// @todo Change Forum module so forum.settings can contain the vocabulary's
// machine name.
- $config = Drupal::config('forum.settings');
+ $config = config('forum.settings');
// If the module was disabled only, the current config may contain a valid
// vocabulary ID already.
$vocabulary = entity_load('taxonomy_vocabulary', $config->get('vocabulary'));
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index 46921af..8c92381 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -237,7 +237,7 @@ function forum_entity_info(&$info) {
*/
function forum_entity_bundle_info_alter(&$bundles) {
// Take over URI construction for taxonomy terms that are forums.
- if ($vid = Drupal::config('forum.settings')->get('vocabulary')) {
+ if ($vid = config('forum.settings')->get('vocabulary')) {
if (isset($bundles['taxonomy_term'][$vid])) {
$bundles['taxonomy_term'][$vid]['uri_callback'] = 'forum_uri';
}
@@ -280,7 +280,7 @@ function forum_node_validate(EntityInterface $node, $form) {
// vocabulary is selected, not a "container" term.
if (!empty($node->taxonomy_forums[$langcode])) {
// Extract the node's proper topic ID.
- $containers = Drupal::config('forum.settings')->get('containers');
+ $containers = config('forum.settings')->get('containers');
foreach ($node->taxonomy_forums[$langcode] as $delta => $item) {
// If no term was selected (e.g. when no terms exist yet), remove the
// item.
@@ -450,7 +450,7 @@ function forum_permission() {
*/
function forum_taxonomy_term_delete(Term $term) {
// For containers, remove the tid from the forum_containers variable.
- $config = Drupal::config('forum.settings');
+ $config = config('forum.settings');
$containers = $config->get('containers');
$key = array_search($term->id(), $containers);
if ($key !== FALSE) {
@@ -569,7 +569,7 @@ function forum_field_storage_pre_update(EntityInterface $entity, &$skip_fields)
* Implements hook_form_BASE_FORM_ID_alter().
*/
function forum_form_taxonomy_vocabulary_form_alter(&$form, &$form_state, $form_id) {
- $vid = Drupal::config('forum.settings')->get('vocabulary');
+ $vid = config('forum.settings')->get('vocabulary');
$vocabulary = $form_state['controller']->getEntity();
if ($vid == $vocabulary->id()) {
$form['help_forum_vocab'] = array(
@@ -591,7 +591,7 @@ function forum_form_taxonomy_vocabulary_form_alter(&$form, &$form_state, $form_i
* Implements hook_form_FORM_ID_alter() for taxonomy_term_form().
*/
function forum_form_taxonomy_term_form_alter(&$form, &$form_state, $form_id) {
- $vid = Drupal::config('forum.settings')->get('vocabulary');
+ $vid = config('forum.settings')->get('vocabulary');
if (isset($form['vid']['#value']) && $form['vid']['#value'] == $vid) {
// Hide multiple parents select from forum terms.
$form['relations']['parent']['#access'] = FALSE;
@@ -673,7 +673,7 @@ function forum_forum_load($tid = NULL) {
return $cache[$tid];
}
- $config = Drupal::config('forum.settings');
+ $config = config('forum.settings');
$vid = $config->get('vocabulary');
// Load and validate the parent term.
@@ -988,7 +988,7 @@ function template_preprocess_forums(&$variables) {
$variables['forums'] = array();
}
- if ($variables['tid'] && array_search($variables['tid'], Drupal::config('forum.settings')->get('containers')) === FALSE) {
+ if ($variables['tid'] && array_search($variables['tid'], config('forum.settings')->get('containers')) === FALSE) {
$variables['topics'] = array(
'#theme' => 'forum_topic_list',
'#tid' => $variables['tid'],
@@ -1065,8 +1065,7 @@ function template_preprocess_forum_list(&$variables) {
}
$variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics;
}
- $forum_submitted = array('#theme' => 'forum_submitted', '#topic' => $forum->last_post);
- $variables['forums'][$id]->last_reply = drupal_render($forum_submitted);
+ $variables['forums'][$id]->last_reply = theme('forum_submitted', array('topic' => $forum->last_post));
}
$variables['pager'] = array(
@@ -1128,13 +1127,8 @@ function template_preprocess_forum_topic_list(&$variables) {
$variables['topics'][$id]->title = l($topic->title, 'node/' . $topic->id());
$variables['topics'][$id]->message = '';
}
- $forum_submitted = array('#theme' => 'forum_submitted', '#topic' => $topic);
- $variables['topics'][$id]->created = drupal_render($forum_submitted);
- $forum_submitted = array(
- '#theme' => 'forum_submitted',
- '#topic' => isset($topic->last_reply) ? $topic->last_reply : NULL,
- );
- $variables['topics'][$id]->last_reply = drupal_render($forum_submitted);
+ $variables['topics'][$id]->created = theme('forum_submitted', array('topic' => $topic));
+ $variables['topics'][$id]->last_reply = theme('forum_submitted', array('topic' => isset($topic->last_reply) ? $topic->last_reply : NULL));
$variables['topics'][$id]->new_text = '';
$variables['topics'][$id]->new_url = '';
@@ -1173,7 +1167,7 @@ function template_preprocess_forum_topic_list(&$variables) {
* - first_new: Indicates whether this is the first topic with new posts.
*/
function template_preprocess_forum_icon(&$variables) {
- $variables['hot_threshold'] = Drupal::config('forum.settings')->get('topics.hot_threshold');
+ $variables['hot_threshold'] = config('forum.settings')->get('topics.hot_threshold');
if ($variables['num_posts'] > $variables['hot_threshold']) {
$icon_status_class = $variables['new_posts'] ? 'hot-new' : 'hot';
@@ -1212,11 +1206,7 @@ function template_preprocess_forum_icon(&$variables) {
* - topic: The topic object.
*/
function template_preprocess_forum_submitted(&$variables) {
- $variables['author'] = '';
- if (isset($variables['topic']->uid)) {
- $username = array('#theme' => 'username', '#account' => user_load($variables['topic']->uid));
- $variables['author'] = drupal_render($username);
- }
+ $variables['author'] = isset($variables['topic']->uid) ? theme('username', array('account' => user_load($variables['topic']->uid))) : '';
$variables['time'] = isset($variables['topic']->created) ? format_interval(REQUEST_TIME - $variables['topic']->created) : '';
}
diff --git a/core/modules/forum/forum.pages.inc b/core/modules/forum/forum.pages.inc
index 3908f31..6278bf3 100644
--- a/core/modules/forum/forum.pages.inc
+++ b/core/modules/forum/forum.pages.inc
@@ -18,7 +18,7 @@
* @see forum_menu()
*/
function forum_page($forum_term = NULL) {
- $config = Drupal::config('forum.settings');
+ $config = config('forum.settings');
$vocabulary = entity_load('taxonomy_vocabulary', $config->get('vocabulary'));
if (!isset($forum_term)) {
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
index d09baf5..0171fb2 100644
--- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
@@ -240,7 +240,7 @@ function testForum() {
*/
function testAddOrphanTopic() {
// Must remove forum topics to test creating orphan topics.
- $vid = \Drupal::config('forum.settings')->get('vocabulary');
+ $vid = config('forum.settings')->get('vocabulary');
$tids = \Drupal::entityQuery('taxonomy_term')
->condition('vid', $vid)
->execute();
@@ -340,7 +340,7 @@ private function doAdminTests($user) {
*/
function editForumVocabulary() {
// Backup forum taxonomy.
- $vid = \Drupal::config('forum.settings')->get('vocabulary');
+ $vid = config('forum.settings')->get('vocabulary');
$original_vocabulary = entity_load('taxonomy_vocabulary', $vid);
// Generate a random name and description.
@@ -406,7 +406,7 @@ function createForum($type, $parent = 0) {
);
// Verify forum.
- $term = db_query("SELECT * FROM {taxonomy_term_data} t WHERE t.vid = :vid AND t.name = :name AND t.description = :desc", array(':vid' => \Drupal::config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description))->fetchAssoc();
+ $term = db_query("SELECT * FROM {taxonomy_term_data} t WHERE t.vid = :vid AND t.name = :name AND t.description = :desc", array(':vid' => config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description))->fetchAssoc();
$this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database');
// Verify forum hierarchy.
@@ -437,7 +437,7 @@ function deleteForum($tid) {
// Assert that the associated term has been removed from the
// forum_containers variable.
- $containers = \Drupal::config('forum.settings')->get('containers');
+ $containers = config('forum.settings')->get('containers');
$this->assertFalse(in_array($tid, $containers), 'The forum_containers variable has been updated.');
}
@@ -573,17 +573,13 @@ private function verifyForums($node_user, EntityInterface $node, $admin, $respon
$this->drupalGet('node/' . $node->id());
$this->assertResponse(200);
$this->assertTitle($node->label() . ' | Drupal', 'Forum node was displayed');
- $breadcrumb_build = array(
+ $breadcrumb = array(
l(t('Home'), NULL),
l(t('Forums'), 'forum'),
l($this->forumContainer['name'], 'forum/' . $this->forumContainer['tid']),
l($this->forum['name'], 'forum/' . $this->forum['tid']),
);
- $breadcrumb = array(
- '#theme' => 'breadcrumb',
- '#breadcrumb' => $breadcrumb_build,
- );
- $this->assertRaw(drupal_render($breadcrumb), 'Breadcrumbs were displayed');
+ $this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), 'Breadcrumbs were displayed');
// View forum edit node.
$this->drupalGet('node/' . $node->id() . '/edit');
@@ -632,19 +628,15 @@ private function verifyForumView($forum, $parent = NULL) {
$this->assertResponse(200);
$this->assertTitle($forum['name'] . ' | Drupal');
- $breadcrumb_build = array(
+ $breadcrumb = array(
l(t('Home'), NULL),
l(t('Forums'), 'forum'),
);
if (isset($parent)) {
- $breadcrumb_build[] = l($parent['name'], 'forum/' . $parent['tid']);
+ $breadcrumb[] = l($parent['name'], 'forum/' . $parent['tid']);
}
- $breadcrumb = array(
- '#theme' => 'breadcrumb',
- '#breadcrumb' => $breadcrumb_build,
- );
- $this->assertRaw(drupal_render($breadcrumb), 'Breadcrumbs were displayed');
+ $this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)));
}
/**
diff --git a/core/modules/help/help.module b/core/modules/help/help.module
index 9c86f45..36821c0 100644
--- a/core/modules/help/help.module
+++ b/core/modules/help/help.module
@@ -16,10 +16,15 @@ function help_menu() {
'weight' => 9,
);
- $items['admin/help/%'] = array(
- 'route_name' => 'help_page',
- 'type' => MENU_VISIBLE_IN_BREADCRUMB,
- );
+ $modules = Drupal::moduleHandler()->getImplementations('help');
+ ksort($modules);
+ foreach ($modules as $module) {
+ $items['admin/help/' . $module] = array(
+ 'title' => $module,
+ 'route_name' => 'help_page',
+ 'type' => MENU_VISIBLE_IN_BREADCRUMB,
+ );
+ }
return $items;
}
diff --git a/core/modules/help/lib/Drupal/help/Controller/HelpController.php b/core/modules/help/lib/Drupal/help/Controller/HelpController.php
index 9fb23a9..8bea58c 100644
--- a/core/modules/help/lib/Drupal/help/Controller/HelpController.php
+++ b/core/modules/help/lib/Drupal/help/Controller/HelpController.php
@@ -9,7 +9,6 @@
use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Controller routines for help routes.
@@ -99,8 +98,6 @@ protected function helpLinksAsList() {
*
* @return array
* A render array as expected by drupal_render().
- *
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function helpPage($name) {
$build = array();
@@ -135,11 +132,9 @@ public function helpPage($name) {
'#links' => $links,
);
}
- return $build;
- }
- else {
- throw new NotFoundHttpException();
}
+
+ return $build;
}
}
diff --git a/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php b/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php
index 62915f4..c5e56be 100644
--- a/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php
+++ b/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php
@@ -7,7 +7,6 @@
namespace Drupal\history\Plugin\views\field;
-use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\node\Plugin\views\field\Node;
@@ -69,10 +68,7 @@ public function query() {
parent::query();
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
// Let's default to 'read' state.
// This code shadows node_mark, but it reads from the db directly and
// we already have that info.
diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc
index a2280ff..ffde15d 100644
--- a/core/modules/image/image.admin.inc
+++ b/core/modules/image/image.admin.inc
@@ -70,18 +70,13 @@ function theme_image_style_effects($variables) {
function theme_image_style_preview($variables) {
$style = $variables['style'];
- $sample_image = Drupal::config('image.settings')->get('preview_image');
+ $sample_image = config('image.settings')->get('preview_image');
$sample_width = 160;
$sample_height = 160;
// Set up original file information.
$original_path = $sample_image;
- $image_factory = Drupal::service('image.factory');
- $original_image = $image_factory->get($original_path);
- $original_image = array(
- 'width' => $original_image->getWidth(),
- 'height' => $original_image->getHeight(),
- );
+ $original_image = image_get_info($original_path);
if ($original_image['width'] > $original_image['height']) {
$original_width = min($original_image['width'], $sample_width);
$original_height = round($original_width / $original_image['width'] * $original_image['height']);
@@ -90,18 +85,15 @@ function theme_image_style_preview($variables) {
$original_height = min($original_image['height'], $sample_height);
$original_width = round($original_height / $original_image['height'] * $original_image['width']);
}
- $original_image['style'] = 'width: ' . $original_width . 'px; height: ' . $original_height . 'px;';
+ $original_attributes = array_intersect_key($original_image, array('width' => '', 'height' => ''));
+ $original_attributes['style'] = 'width: ' . $original_width . 'px; height: ' . $original_height . 'px;';
// Set up preview file information.
$preview_file = $style->buildUri($original_path);
if (!file_exists($preview_file)) {
$style->createDerivative($original_path, $preview_file);
}
- $preview_image = $image_factory->get($preview_file);
- $preview_image = array(
- 'width' => $preview_image->getWidth(),
- 'height' => $preview_image->getHeight(),
- );
+ $preview_image = image_get_info($preview_file);
if ($preview_image['width'] > $preview_image['height']) {
$preview_width = min($preview_image['width'], $sample_width);
$preview_height = round($preview_width / $preview_image['width'] * $preview_image['height']);
@@ -110,7 +102,8 @@ function theme_image_style_preview($variables) {
$preview_height = min($preview_image['height'], $sample_height);
$preview_width = round($preview_height / $preview_image['height'] * $preview_image['width']);
}
- $preview_image['style'] = 'width: ' . $preview_width . 'px; height: ' . $preview_height . 'px;';
+ $preview_attributes = array_intersect_key($preview_image, array('width' => '', 'height' => ''));
+ $preview_attributes['style'] = 'width: ' . $preview_width . 'px; height: ' . $preview_height . 'px;';
// In the previews, timestamps are added to prevent caching of images.
$output = '';
@@ -119,8 +112,8 @@ function theme_image_style_preview($variables) {
$original_url = file_create_url($original_path);
$output .= '';
$output .= t('original') . ' (' . l(t('view actual size'), $original_url) . ')';
- $output .= '';
- $output .= '' . theme('image', array('uri' => $original_path, 'alt' => t('Sample original image'), 'title' => '', 'attributes' => $original_image)) . '';
+ $output .= '';
+ $output .= '' . theme('image', array('uri' => $original_path, 'alt' => t('Sample original image'), 'title' => '', 'attributes' => $original_attributes)) . '';
$output .= '' . $original_image['height'] . 'px';
$output .= '' . $original_image['width'] . 'px';
$output .= ''; // End preview-image.
@@ -130,8 +123,8 @@ function theme_image_style_preview($variables) {
$preview_url = file_create_url($preview_file) . '?cache_bypass=' . REQUEST_TIME;
$output .= '';
$output .= check_plain($style->label()) . ' (' . l(t('view actual size'), file_create_url($preview_file) . '?' . time()) . ')';
- $output .= '';
- $output .= '' . theme('image', array('uri' => $preview_url, 'alt' => t('Sample modified image'), 'title' => '', 'attributes' => $preview_image)) . '';
+ $output .= '';
+ $output .= '' . theme('image', array('uri' => $preview_url, 'alt' => t('Sample modified image'), 'title' => '', 'attributes' => $preview_attributes)) . '';
$output .= '' . $preview_image['height'] . 'px';
$output .= '' . $preview_image['width'] . 'px';
$output .= ''; // End preview-image.
diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc
index 4741a73..6cff0a3 100644
--- a/core/modules/image/image.field.inc
+++ b/core/modules/image/image.field.inc
@@ -226,14 +226,15 @@ function _image_field_resolution_validate($element, &$form_state) {
* Implements hook_field_presave().
*/
function image_field_presave(EntityInterface $entity, $field, $instance, $langcode, &$items) {
- $image_factory = Drupal::service('image.factory');
+
// Determine the dimensions if necessary.
foreach ($items as &$item) {
if (!isset($item['width']) || !isset($item['height'])) {
- $image = $image_factory->get(file_load($item['target_id'])->getFileUri());
- if ($image->getExtension()) {
- $item['width'] = $image->getWidth();
- $item['height'] = $image->getHeight();
+ $info = image_get_info(file_load($item['target_id'])->getFileUri());
+
+ if (is_array($info)) {
+ $item['width'] = $info['width'];
+ $item['height'] = $info['height'];
}
}
}
@@ -300,10 +301,11 @@ function image_field_widget_process($element, &$form_state, $form) {
$variables['height'] = $element['#value']['height'];
}
else {
- $image = Drupal::service('image.factory')->get($file->getFileUri());
- if ($image->getExtension()) {
- $variables['width'] = $image->getWidth();
- $variables['height'] = $image->getHeight();
+ $info = image_get_info($file->getFileUri());
+
+ if (is_array($info)) {
+ $variables['width'] = $info['width'];
+ $variables['height'] = $info['height'];
}
else {
$variables['width'] = $variables['height'] = NULL;
diff --git a/core/modules/image/image.install b/core/modules/image/image.install
index 39ddedf..1617e8c 100644
--- a/core/modules/image/image.install
+++ b/core/modules/image/image.install
@@ -6,6 +6,7 @@
*/
use Drupal\Component\Uuid\Uuid;
+use Drupal\field\Plugin\Core\Entity\Field;
/**
* Implements hook_install().
@@ -158,7 +159,7 @@ function image_update_8000() {
// Convert each style into a configuration object.
foreach ($styles as $name => $style) {
- $config = Drupal::config('image.style.' . $name);
+ $config = config('image.style.' . $name);
$config->set('name', $name);
$config->set('effects', $style['effects']);
$config->save();
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 28b7bc2..053075d 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -9,6 +9,7 @@
use Drupal\field\Plugin\Core\Entity\Field;
use Drupal\field\Plugin\Core\Entity\FieldInstance;
use Drupal\file\Plugin\Core\Entity\File;
+use Drupal\image\ImageStyleInterface;
use Drupal\image\Plugin\Core\Entity\ImageStyle;
use Drupal\field\FieldInterface;
use Drupal\field\FieldInstanceInterface;
@@ -267,16 +268,15 @@ function image_file_download($uri) {
$original_uri = file_uri_scheme($uri) . '://' . implode('/', $args);
// Check that the file exists and is an image.
- $image = Drupal::service('image.factory')->get($uri);
- if ($image->getExtension()) {
+ if ($info = image_get_info($uri)) {
// Check the permissions of the original to grant access to this image.
$headers = Drupal::moduleHandler()->invokeAll('file_download', array($original_uri));
// Confirm there's at least one module granting access and none denying access.
if (!empty($headers) && !in_array(-1, $headers)) {
return array(
// Send headers describing the image's size, and MIME-type...
- 'Content-Type' => $image->getMimeType(),
- 'Content-Length' => $image->getFileSize(),
+ 'Content-Type' => $info['mime_type'],
+ 'Content-Length' => $info['file_size'],
// By not explicitly setting them here, this uses normal Drupal
// Expires, Cache-Control and ETag headers to prevent proxy or
// browser caching of private images.
diff --git a/core/modules/image/lib/Drupal/image/Controller/ImageStyleDownloadController.php b/core/modules/image/lib/Drupal/image/Controller/ImageStyleDownloadController.php
index 8013962..34146c2 100644
--- a/core/modules/image/lib/Drupal/image/Controller/ImageStyleDownloadController.php
+++ b/core/modules/image/lib/Drupal/image/Controller/ImageStyleDownloadController.php
@@ -11,7 +11,6 @@
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
-use Drupal\Core\Image\ImageFactory;
use Drupal\Core\Lock\LockBackendInterface;
use Drupal\Core\StringTranslation\Translator\TranslatorInterface;
use Drupal\image\ImageStyleInterface;
@@ -50,13 +49,6 @@ class ImageStyleDownloadController extends FileDownloadController implements Con
protected $translator;
/**
- * The image factory.
- *
- * @var \Drupal\Core\Image\ImageFactory
- */
- protected $imageFactory;
-
- /**
* Constructs a ImageStyleDownloadController object.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
@@ -67,15 +59,12 @@ class ImageStyleDownloadController extends FileDownloadController implements Con
* The lock backend.
* @param \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translator
* The translator service.
- * @param \Drupal\Core\Image\ImageFactory $image_factory
- * The image factory.
*/
- public function __construct(ModuleHandlerInterface $module_handler, ConfigFactory $config_factory, LockBackendInterface $lock, TranslatorInterface $translator, ImageFactory $image_factory) {
+ public function __construct(ModuleHandlerInterface $module_handler, ConfigFactory $config_factory, LockBackendInterface $lock, TranslatorInterface $translator) {
parent::__construct($module_handler);
$this->configFactory = $config_factory;
$this->lock = $lock;
$this->translator = $translator;
- $this->imageFactory = $image_factory;
}
/**
@@ -86,8 +75,7 @@ public static function create(ContainerInterface $container) {
$container->get('module_handler'),
$container->get('config.factory'),
$container->get('lock'),
- $container->get('string_translation'),
- $container->get('image.factory')
+ $container->get('string_translation')
);
}
@@ -171,11 +159,11 @@ public function deliver(Request $request, $scheme, ImageStyleInterface $image_st
}
if ($success) {
- $image = $this->imageFactory->get($derivative_uri);
- $uri = $image->getSource();
+ $image = image_load($derivative_uri);
+ $uri = $image->source;
$headers += array(
- 'Content-Type' => $image->getMimeType(),
- 'Content-Length' => $image->getFileSize(),
+ 'Content-Type' => $image->info['mime_type'],
+ 'Content-Length' => $image->info['file_size'],
);
return new BinaryFileResponse($uri, 200, $headers);
}
diff --git a/core/modules/image/lib/Drupal/image/ImageEffectBag.php b/core/modules/image/lib/Drupal/image/ImageEffectBag.php
index 0624183..7d0c8eb 100644
--- a/core/modules/image/lib/Drupal/image/ImageEffectBag.php
+++ b/core/modules/image/lib/Drupal/image/ImageEffectBag.php
@@ -26,6 +26,17 @@ public function &get($instance_id) {
}
/**
+ * Removes an instance ID.
+ *
+ * @param string $instance_id
+ * An image effect instance IDs.
+ */
+ public function removeInstanceID($instance_id) {
+ unset($this->instanceIDs[$instance_id], $this->configurations[$instance_id]);
+ $this->remove($instance_id);
+ }
+
+ /**
* Updates the configuration for an image effect instance.
*
* If there is no plugin instance yet, a new will be instantiated. Otherwise,
diff --git a/core/modules/image/lib/Drupal/image/ImageEffectInterface.php b/core/modules/image/lib/Drupal/image/ImageEffectInterface.php
index 66b7f4e..19575e9 100644
--- a/core/modules/image/lib/Drupal/image/ImageEffectInterface.php
+++ b/core/modules/image/lib/Drupal/image/ImageEffectInterface.php
@@ -9,7 +9,6 @@
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
-use Drupal\Core\Image\ImageInterface;
/**
* Defines the interface for image effects.
@@ -19,13 +18,13 @@
/**
* Applies an image effect to the image object.
*
- * @param \Drupal\Core\Image\ImageInterface $image
- * An image file object.
+ * @param \stdClass $image
+ * An image object returned by image_load().
*
* @return bool
* TRUE on success. FALSE if unable to perform the image effect on the image.
*/
- public function applyEffect(ImageInterface $image);
+ public function applyEffect($image);
/**
* Determines the dimensions of the styled image.
diff --git a/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php
index 25e0b81..73976f9 100644
--- a/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php
+++ b/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php
@@ -281,8 +281,7 @@ public function createDerivative($original_uri, $derivative_uri) {
return FALSE;
}
- $image = \Drupal::service('image.factory')->get($original_uri);
- if (!$image->getResource()) {
+ if (!$image = image_load($original_uri)) {
return FALSE;
}
@@ -290,7 +289,7 @@ public function createDerivative($original_uri, $derivative_uri) {
$effect->applyEffect($image);
}
- if (!$image->save($derivative_uri)) {
+ if (!image_save($image, $derivative_uri)) {
if (file_exists($derivative_uri)) {
watchdog('image', 'Cached image file %destination already exists. There may be an issue with your rewrite configuration.', array('%destination' => $derivative_uri), WATCHDOG_ERROR);
}
diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php
index e46d2fa..11f228e 100644
--- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php
+++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php
@@ -8,7 +8,6 @@
namespace Drupal\image\Plugin\ImageEffect;
use Drupal\Core\Annotation\Translation;
-use Drupal\Core\Image\ImageInterface;
use Drupal\image\Annotation\ImageEffect;
/**
@@ -25,17 +24,17 @@ class CropImageEffect extends ResizeImageEffect {
/**
* {@inheritdoc}
*/
- public function applyEffect(ImageInterface $image) {
+ public function applyEffect($image) {
// Set sane default values.
$this->configuration += array(
'anchor' => 'center-center',
);
list($x, $y) = explode('-', $this->configuration['anchor']);
- $x = image_filter_keyword($x, $image->getWidth(), $this->configuration['width']);
- $y = image_filter_keyword($y, $image->getHeight(), $this->configuration['height']);
- if (!$image->crop($x, $y, $this->configuration['width'], $this->configuration['height'])) {
- watchdog('image', 'Image crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR);
+ $x = image_filter_keyword($x, $image->info['width'], $this->configuration['width']);
+ $y = image_filter_keyword($y, $image->info['height'], $this->configuration['height']);
+ if (!image_crop($image, $x, $y, $this->configuration['width'], $this->configuration['height'])) {
+ watchdog('image', 'Image crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit->getPluginId(), '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
return FALSE;
}
return TRUE;
diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/DesaturateImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/DesaturateImageEffect.php
index 912bec9..816ed3e 100644
--- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/DesaturateImageEffect.php
+++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/DesaturateImageEffect.php
@@ -8,7 +8,6 @@
namespace Drupal\image\Plugin\ImageEffect;
use Drupal\Core\Annotation\Translation;
-use Drupal\Core\Image\ImageInterface;
use Drupal\image\Annotation\ImageEffect;
use Drupal\image\ImageEffectBase;
@@ -32,9 +31,9 @@ public function transformDimensions(array &$dimensions) {
/**
* {@inheritdoc}
*/
- public function applyEffect(ImageInterface $image) {
- if (!$image->desaturate()) {
- watchdog('image', 'Image desaturate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR);
+ public function applyEffect($image) {
+ if (!image_desaturate($image)) {
+ watchdog('image', 'Image desaturate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit->getPluginId(), '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
return FALSE;
}
return TRUE;
diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ResizeImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ResizeImageEffect.php
index 766e5a7..484e6a0 100644
--- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ResizeImageEffect.php
+++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ResizeImageEffect.php
@@ -8,7 +8,6 @@
namespace Drupal\image\Plugin\ImageEffect;
use Drupal\Core\Annotation\Translation;
-use Drupal\Core\Image\ImageInterface;
use Drupal\image\Annotation\ImageEffect;
use Drupal\image\ConfigurableImageEffectInterface;
use Drupal\image\ImageEffectBase;
@@ -27,9 +26,9 @@ class ResizeImageEffect extends ImageEffectBase implements ConfigurableImageEffe
/**
* {@inheritdoc}
*/
- public function applyEffect(ImageInterface $image) {
- if (!$image->resize($this->configuration['width'], $this->configuration['height'])) {
- watchdog('image', 'Image resize failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR);
+ public function applyEffect($image) {
+ if (!image_resize($image, $this->configuration['width'], $this->configuration['height'])) {
+ watchdog('image', 'Image resize failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit->getPluginId(), '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
return FALSE;
}
return TRUE;
diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/RotateImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/RotateImageEffect.php
index fe563ae..dee537e 100644
--- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/RotateImageEffect.php
+++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/RotateImageEffect.php
@@ -8,7 +8,6 @@
namespace Drupal\image\Plugin\ImageEffect;
use Drupal\Core\Annotation\Translation;
-use Drupal\Core\Image\ImageInterface;
use Drupal\image\Annotation\ImageEffect;
use Drupal\image\ConfigurableImageEffectInterface;
use Drupal\image\ImageEffectBase;
@@ -27,7 +26,7 @@ class RotateImageEffect extends ImageEffectBase implements ConfigurableImageEffe
/**
* {@inheritdoc}
*/
- public function applyEffect(ImageInterface $image) {
+ public function applyEffect($image) {
// Set sane default values.
$this->configuration += array(
'degrees' => 0,
@@ -54,8 +53,8 @@ public function applyEffect(ImageInterface $image) {
$this->configuration['degrees'] = rand(-1 * $degrees, $degrees);
}
- if (!$image->rotate($this->configuration['degrees'], $this->configuration['bgcolor'])) {
- watchdog('image', 'Image rotate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR);
+ if (!image_rotate($image, $this->configuration['degrees'], $this->configuration['bgcolor'])) {
+ watchdog('image', 'Image rotate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit->getPluginId(), '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
return FALSE;
}
return TRUE;
diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleAndCropImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleAndCropImageEffect.php
index 39bd2ec..dfa5955 100644
--- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleAndCropImageEffect.php
+++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleAndCropImageEffect.php
@@ -8,7 +8,6 @@
namespace Drupal\image\Plugin\ImageEffect;
use Drupal\Core\Annotation\Translation;
-use Drupal\Core\Image\ImageInterface;
use Drupal\image\Annotation\ImageEffect;
/**
@@ -25,9 +24,9 @@ class ScaleAndCropImageEffect extends ResizeImageEffect {
/**
* {@inheritdoc}
*/
- public function applyEffect(ImageInterface $image) {
- if (!$image->scaleAndCrop($this->configuration['width'], $this->configuration['height'])) {
- watchdog('image', 'Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR);
+ public function applyEffect($image) {
+ if (!image_scale_and_crop($image, $this->configuration['width'], $this->configuration['height'])) {
+ watchdog('image', 'Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit->getPluginId(), '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
return FALSE;
}
return TRUE;
diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleImageEffect.php
index c7b2f53..47ada5a 100644
--- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleImageEffect.php
+++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleImageEffect.php
@@ -7,9 +7,8 @@
namespace Drupal\image\Plugin\ImageEffect;
+use Drupal\Component\Image\Image;
use Drupal\Core\Annotation\Translation;
-use Drupal\Component\Utility\Image;
-use Drupal\Core\Image\ImageInterface;
use Drupal\image\Annotation\ImageEffect;
/**
@@ -26,7 +25,7 @@ class ScaleImageEffect extends ResizeImageEffect {
/**
* {@inheritdoc}
*/
- public function applyEffect(ImageInterface $image) {
+ public function applyEffect($image) {
// Set sane default values.
$this->configuration += array(
'width' => NULL,
@@ -34,8 +33,8 @@ public function applyEffect(ImageInterface $image) {
'upscale' => FALSE,
);
- if (!$image->scale($this->configuration['width'], $this->configuration['height'], $this->configuration['upscale'])) {
- watchdog('image', 'Image scale failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR);
+ if (!image_scale($image, $this->configuration['width'], $this->configuration['height'], $this->configuration['upscale'])) {
+ watchdog('image', 'Image scale failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit->getPluginId(), '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
return FALSE;
}
return TRUE;
diff --git a/core/modules/image/lib/Drupal/image/Tests/FileMoveTest.php b/core/modules/image/lib/Drupal/image/Tests/FileMoveTest.php
index 13518e0..2fc0b68 100644
--- a/core/modules/image/lib/Drupal/image/Tests/FileMoveTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/FileMoveTest.php
@@ -7,12 +7,12 @@
namespace Drupal\image\Tests;
-use Drupal\simpletest\WebTestBase;
+use Drupal\system\Tests\Image\ToolkitTestBase;
/**
* Tests the file move function for images and image styles.
*/
-class FileMoveTest extends WebTestBase {
+class FileMoveTest extends ToolkitTestBase {
/**
* Modules to enable.
@@ -38,7 +38,7 @@ function testNormal() {
// Create derivative image.
$styles = entity_load_multiple('image_style');
- $style = reset($styles);
+ $style = image_style_load(key($styles));
$original_uri = $file->getFileUri();
$derivative_uri = $style->buildUri($original_uri);
$style->createDerivative($original_uri, $derivative_uri);
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php
index c136fa6..0ff6738 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php
@@ -35,7 +35,6 @@ public static function getInfo() {
* Test styled image dimensions cumulatively.
*/
function testImageDimensions() {
- $image_factory = $this->container->get('image.factory');
// Create a working copy of the file.
$files = $this->drupalGetTestFiles('image');
$file = reset($files);
@@ -54,9 +53,9 @@ function testImageDimensions() {
'height' => 20,
);
// Verify that the original image matches the hard-coded values.
- $image_file = $image_factory->get($original_uri);
- $this->assertEqual($image_file->getWidth(), $variables['width']);
- $this->assertEqual($image_file->getHeight(), $variables['height']);
+ $image_info = image_get_info($original_uri);
+ $this->assertEqual($image_info['width'], $variables['width']);
+ $this->assertEqual($image_info['height'], $variables['height']);
// Scale an image that is wider than it is high.
$effect = array(
@@ -76,9 +75,9 @@ function testImageDimensions() {
$this->drupalGet($url);
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
- $image_file = $image_factory->get($generated_uri);
- $this->assertEqual($image_file->getWidth(), 120);
- $this->assertEqual($image_file->getHeight(), 60);
+ $image_info = image_get_info($generated_uri);
+ $this->assertEqual($image_info['width'], 120);
+ $this->assertEqual($image_info['height'], 60);
// Rotate 90 degrees anticlockwise.
$effect = array(
@@ -97,9 +96,9 @@ function testImageDimensions() {
$this->drupalGet($url);
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
- $image_file = $image_factory->get($generated_uri);
- $this->assertEqual($image_file->getWidth(), 60);
- $this->assertEqual($image_file->getHeight(), 120);
+ $image_info = image_get_info($generated_uri);
+ $this->assertEqual($image_info['width'], 60);
+ $this->assertEqual($image_info['height'], 120);
// Scale an image that is higher than it is wide (rotated by previous effect).
$effect = array(
@@ -119,9 +118,9 @@ function testImageDimensions() {
$this->drupalGet($url);
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
- $image_file = $image_factory->get($generated_uri);
- $this->assertEqual($image_file->getWidth(), 45);
- $this->assertEqual($image_file->getHeight(), 90);
+ $image_info = image_get_info($generated_uri);
+ $this->assertEqual($image_info['width'], 45);
+ $this->assertEqual($image_info['height'], 90);
// Test upscale disabled.
$effect = array(
@@ -141,9 +140,9 @@ function testImageDimensions() {
$this->drupalGet($url);
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
- $image_file = $image_factory->get($generated_uri);
- $this->assertEqual($image_file->getWidth(), 45);
- $this->assertEqual($image_file->getHeight(), 90);
+ $image_info = image_get_info($generated_uri);
+ $this->assertEqual($image_info['width'], 45);
+ $this->assertEqual($image_info['height'], 90);
// Add a desaturate effect.
$effect = array(
@@ -159,9 +158,9 @@ function testImageDimensions() {
$this->drupalGet($url);
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
- $image_file = $image_factory->get($generated_uri);
- $this->assertEqual($image_file->getWidth(), 45);
- $this->assertEqual($image_file->getHeight(), 90);
+ $image_info = image_get_info($generated_uri);
+ $this->assertEqual($image_info['width'], 45);
+ $this->assertEqual($image_info['height'], 90);
// Add a random rotate effect.
$effect = array(
@@ -200,9 +199,9 @@ function testImageDimensions() {
$this->drupalGet($url);
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
- $image_file = $image_factory->get($generated_uri);
- $this->assertEqual($image_file->getWidth(), 30);
- $this->assertEqual($image_file->getHeight(), 30);
+ $image_info = image_get_info($generated_uri);
+ $this->assertEqual($image_info['width'], 30);
+ $this->assertEqual($image_info['height'], 30);
// Rotate to a non-multiple of 90 degrees.
$effect = array(
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
index a0a746f..2c1ae39 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
@@ -30,7 +30,7 @@ public static function getInfo() {
/**
* Tests CRUD for fields and fields instances with default images.
*/
- public function testDefaultImages() {
+ function testDefaultImages() {
// Create files to use as the default images.
$files = $this->drupalGetTestFiles('image');
$default_images = array();
@@ -52,22 +52,7 @@ public function testDefaultImages() {
'preview_image_style' => 'medium',
);
$instance = $this->createImageField($field_name, 'article', $field_settings, $instance_settings, $widget_settings);
-
- // The instance default image id should be 2.
- $this->assertEqual($instance->getFieldSetting('default_image'), $default_images['instance']->id());
-
- // Also test \Drupal\field\Plugin\Core\Entity\FieldInstance::getFieldSetting().
- $instance_field_settings = $instance->getFieldSettings();
- $this->assertEqual($instance_field_settings['default_image'], $default_images['instance']->id());
-
- $field = entity_load('field_entity', $field_name);
-
- // The field default image id should be 1.
- $this->assertEqual($field->getFieldSetting('default_image'), $default_images['field']->id());
-
- // Also test \Drupal\field\Plugin\Core\Entity\Field::getFieldSettings().
- $field_field_settings = $field->getFieldSettings();
- $this->assertEqual($field_field_settings['default_image'], $default_images['field']->id());
+ $field = field_info_field($field_name);
// Add another instance with another default image to the page content type.
$instance2 = entity_create('field_instance', array(
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldValidateTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldValidateTest.php
index e3d48bf..1cd0ce9 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldValidateTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldValidateTest.php
@@ -36,13 +36,12 @@ function testResolution() {
// big, so cycle through test image files until we have what we need.
$image_that_is_too_big = FALSE;
$image_that_is_too_small = FALSE;
- $image_factory = $this->container->get('image.factory');
foreach ($this->drupalGetTestFiles('image') as $image) {
- $image_file = $image_factory->get($image->uri);
- if ($image_file->getWidth() > $max_resolution) {
+ $info = image_get_info($image->uri);
+ if ($info['width'] > $max_resolution) {
$image_that_is_too_big = $image;
}
- if ($image_file->getWidth() < $min_resolution) {
+ if ($info['width'] < $min_resolution) {
$image_that_is_too_small = $image;
}
if ($image_that_is_too_small && $image_that_is_too_big) {
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php
index fdd3686..5e7472f 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php
@@ -30,11 +30,6 @@ class ImageItemTest extends FieldUnitTestBase {
*/
protected $image;
- /**
- * @var \Drupal\Core\Image\ImageFactory
- */
- protected $imageFactory;
-
public static function getInfo() {
return array(
'name' => 'Image field item API',
@@ -63,7 +58,6 @@ public function setUp() {
'uri' => 'public://example.jpg',
));
$this->image->save();
- $this->imageFactory = $this->container->get('image.factory');
}
/**
@@ -84,9 +78,9 @@ public function testImageItem() {
$this->assertEqual($entity->image_test->target_id, $this->image->id());
$this->assertEqual($entity->image_test->alt, $alt);
$this->assertEqual($entity->image_test->title, $title);
- $image = $this->imageFactory->get('public://example.jpg');
- $this->assertEqual($entity->image_test->width, $image->getWidth());
- $this->assertEqual($entity->image_test->height, $image->getHeight());
+ $info = image_get_info('public://example.jpg');
+ $this->assertEqual($entity->image_test->width, $info['width']);
+ $this->assertEqual($entity->image_test->height, $info['height']);
$this->assertEqual($entity->image_test->entity->id(), $this->image->id());
$this->assertEqual($entity->image_test->entity->uuid(), $this->image->uuid());
@@ -104,9 +98,9 @@ public function testImageItem() {
$entity->save();
$this->assertEqual($entity->image_test->entity->id(), $image2->id());
$this->assertEqual($entity->image_test->entity->getFileUri(), $image2->getFileUri());
- $image = $this->imageFactory->get('public://example-2.jpg');
- $this->assertEqual($entity->image_test->width, $image->getWidth());
- $this->assertEqual($entity->image_test->height, $image->getHeight());
+ $info = image_get_info('public://example-2.jpg');
+ $this->assertEqual($entity->image_test->width, $info['width']);
+ $this->assertEqual($entity->image_test->height, $info['height']);
$this->assertEqual($entity->image_test->alt, $new_alt);
// Check that the image item can be set to the referenced file directly.
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php
index 880ee6f..cae45d7 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php
@@ -109,7 +109,7 @@ function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_slash =
// Make the default scheme neither "public" nor "private" to verify the
// functions work for other than the default scheme.
- \Drupal::config('system.file')->set('default_scheme', 'temporary')->save();
+ config('system.file')->set('default_scheme', 'temporary')->save();
// Create the directories for the styles.
$directory = $scheme . '://styles/' . $this->style->id();
@@ -153,9 +153,9 @@ function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_slash =
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertRaw(file_get_contents($generated_uri), 'URL returns expected file.');
- $image = $this->container->get('image.factory')->get($generated_uri);
- $this->assertEqual($this->drupalGetHeader('Content-Type'), $image->getMimeType(), 'Expected Content-Type was reported.');
- $this->assertEqual($this->drupalGetHeader('Content-Length'), $image->getFileSize(), 'Expected Content-Length was reported.');
+ $generated_image_info = image_get_info($generated_uri);
+ $this->assertEqual($this->drupalGetHeader('Content-Type'), $generated_image_info['mime_type'], 'Expected Content-Type was reported.');
+ $this->assertEqual($this->drupalGetHeader('Content-Length'), $generated_image_info['file_size'], 'Expected Content-Length was reported.');
if ($scheme == 'private') {
$this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
$this->assertNotEqual(strpos($this->drupalGetHeader('Cache-Control'), 'no-cache'), FALSE, 'Cache-Control header contains \'no-cache\' to prevent caching.');
@@ -200,7 +200,7 @@ function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_slash =
// Allow insecure image derivatives to be created for the remainder of this
// test.
- \Drupal::config('image.settings')->set('allow_insecure_derivatives', TRUE)->save();
+ config('image.settings')->set('allow_insecure_derivatives', TRUE)->save();
// Create another working copy of the file.
$files = $this->drupalGetTestFiles('image');
@@ -213,7 +213,7 @@ function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_slash =
// Suppress the security token in the URL, then get the URL of a file that
// has not been created and try to create it. Check that the security token
// is not present in the URL but that the image is still accessible.
- \Drupal::config('image.settings')->set('suppress_itok_output', TRUE)->save();
+ config('image.settings')->set('suppress_itok_output', TRUE)->save();
$generated_uri = $this->style->buildUri($original_uri);
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$generate_url = $this->style->buildUrl($original_uri, $clean_url);
diff --git a/core/modules/image/tests/modules/image_module_test/lib/Drupal/image_module_test/Plugin/ImageEffect/NullTestImageEffect.php b/core/modules/image/tests/modules/image_module_test/lib/Drupal/image_module_test/Plugin/ImageEffect/NullTestImageEffect.php
index 52731fe..23b1931 100644
--- a/core/modules/image/tests/modules/image_module_test/lib/Drupal/image_module_test/Plugin/ImageEffect/NullTestImageEffect.php
+++ b/core/modules/image/tests/modules/image_module_test/lib/Drupal/image_module_test/Plugin/ImageEffect/NullTestImageEffect.php
@@ -8,7 +8,6 @@
namespace Drupal\image_module_test\Plugin\ImageEffect;
use Drupal\Core\Annotation\Translation;
-use Drupal\Core\Image\ImageInterface;
use Drupal\image\Annotation\ImageEffect;
use Drupal\image\ImageEffectBase;
@@ -25,7 +24,7 @@ class NullTestImageEffect extends ImageEffectBase {
/**
* {@inheritdoc}
*/
- public function applyEffect(ImageInterface $image) {
+ public function applyEffect($image) {
return TRUE;
}
diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc
index 979419e..041398e 100644
--- a/core/modules/language/language.admin.inc
+++ b/core/modules/language/language.admin.inc
@@ -284,7 +284,7 @@ function language_negotiation_configure_form() {
'#language_negotiation_info' => language_negotiation_info(),
);
$form['#language_types'] = array();
- $configurable = Drupal::config('system.language.types')->get('configurable');
+ $configurable = config('system.language.types')->get('configurable');
foreach ($form['#language_types_info'] as $type => $info) {
// Show locked language types only if they are configurable.
if (empty($info['locked']) || in_array($type, $configurable)) {
@@ -320,7 +320,7 @@ function language_negotiation_configure_form_table(&$form, $type) {
);
// Only show configurability checkbox for the unlocked language types.
if (empty($info['locked'])) {
- $configurable = Drupal::config('system.language.types')->get('configurable');
+ $configurable = config('system.language.types')->get('configurable');
$table_form['configurable'] = array(
'#type' => 'checkbox',
'#title' => t('Customize %language_name language detection to differ from User interface text language detection settings.', array('%language_name' => $info['name'])),
@@ -483,7 +483,7 @@ function theme_language_negotiation_configure_form($variables) {
function language_negotiation_configure_form_submit($form, &$form_state) {
$configurable_types = $form['#language_types'];
- $stored_values = Drupal::config('system.language.types')->get('configurable');
+ $stored_values = config('system.language.types')->get('configurable');
$customized = array();
$method_weights_type = array();
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index 4d2688c..66433d3 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -363,7 +363,7 @@ function language_configuration_element_submit(&$form, &$form_state) {
* - language_show: if the language element should be hidden or not.
*/
function language_save_default_configuration($entity_type, $bundle, $values = array()) {
- Drupal::config('language.settings')->set(language_get_default_configuration_settings_key($entity_type, $bundle), array('langcode' => $values['langcode'], 'language_show' => $values['language_show']))->save();
+ config('language.settings')->set(language_get_default_configuration_settings_key($entity_type, $bundle), array('langcode' => $values['langcode'], 'language_show' => $values['language_show']))->save();
}
/**
@@ -380,7 +380,7 @@ function language_save_default_configuration($entity_type, $bundle, $values = ar
* - language_show: if the language element is hidden or not.
*/
function language_get_default_configuration($entity_type, $bundle) {
- $configuration = Drupal::config('language.settings')->get(language_get_default_configuration_settings_key($entity_type, $bundle));
+ $configuration = config('language.settings')->get(language_get_default_configuration_settings_key($entity_type, $bundle));
if (is_null($configuration)) {
$configuration = array();
}
@@ -397,7 +397,7 @@ function language_get_default_configuration($entity_type, $bundle) {
* A string representing the bundle.
*/
function language_clear_default_configuration($entity_type, $bundle) {
- Drupal::config('language.settings')->clear(language_get_default_configuration_settings_key($entity_type, $bundle))->save();
+ config('language.settings')->clear(language_get_default_configuration_settings_key($entity_type, $bundle))->save();
}
/**
@@ -803,7 +803,7 @@ function language_preprocess_block(&$variables) {
* Drupal language codes as values.
*/
function language_get_browser_drupal_langcode_mappings() {
- $config = Drupal::config('language.mappings');
+ $config = config('language.mappings');
if ($config->isNew()) {
return array();
}
@@ -818,7 +818,7 @@ function language_get_browser_drupal_langcode_mappings() {
* Drupal language codes as values.
*/
function language_set_browser_drupal_langcode_mappings($mappings) {
- $config = Drupal::config('language.mappings');
+ $config = config('language.mappings');
$config->setData($mappings);
$config->save();
}
diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc
index 8834812..9e145bb 100644
--- a/core/modules/language/language.negotiation.inc
+++ b/core/modules/language/language.negotiation.inc
@@ -243,7 +243,7 @@ function language_from_user_admin(array $languages, Request $request = NULL) {
* A valid language code on success, FALSE otherwise.
*/
function language_from_session($languages) {
- $param = Drupal::config('language.negotiation')->get('session.parameter');
+ $param = config('language.negotiation')->get('session.parameter');
// Request parameter: we need to update the session parameter only if we have
// an authenticated user.
@@ -283,7 +283,7 @@ function language_from_url($languages, Request $request = NULL) {
return $language_url;
}
- switch (Drupal::config('language.negotiation')->get('url.source')) {
+ switch (config('language.negotiation')->get('url.source')) {
case LANGUAGE_NEGOTIATION_URL_PREFIX:
$request_path = urldecode(trim($request->getPathInfo(), '/'));
@@ -359,7 +359,7 @@ function language_from_url($languages, Request $request = NULL) {
*/
function language_url_fallback($language = NULL, $request = NULL, $language_type = Language::TYPE_INTERFACE) {
$default = language_default();
- $prefix = (Drupal::config('language.negotiation')->get('url.source') == LANGUAGE_NEGOTIATION_URL_PREFIX);
+ $prefix = (config('language.negotiation')->get('url.source') == LANGUAGE_NEGOTIATION_URL_PREFIX);
// If the default language is not configured to convey language information,
// a missing URL language information indicates that URL language should be
@@ -400,7 +400,7 @@ function language_switcher_url($type, $path) {
* Return the session language switcher block.
*/
function language_switcher_session($type, $path) {
- $param = Drupal::config('language.negotiation')->get('session.parameter');
+ $param = config('language.negotiation')->get('session.parameter');
$language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : language($type)->id;
$languages = language_list();
@@ -431,7 +431,7 @@ function language_switcher_session($type, $path) {
* Reads language prefixes and uses the langcode if no prefix is set.
*/
function language_negotiation_url_prefixes() {
- return Drupal::config('language.negotiation')->get('url.prefixes');
+ return config('language.negotiation')->get('url.prefixes');
}
/**
@@ -456,7 +456,7 @@ function language_negotiation_url_prefixes_update() {
* Saves language prefix settings.
*/
function language_negotiation_url_prefixes_save(array $prefixes) {
- Drupal::config('language.negotiation')
+ config('language.negotiation')
->set('url.prefixes', $prefixes)
->save();
}
@@ -465,14 +465,14 @@ function language_negotiation_url_prefixes_save(array $prefixes) {
* Reads language domains.
*/
function language_negotiation_url_domains() {
- return Drupal::config('language.negotiation')->get('url.domains');
+ return config('language.negotiation')->get('url.domains');
}
/**
* Saves the language domain settings.
*/
function language_negotiation_url_domains_save(array $domains) {
- Drupal::config('language.negotiation')
+ config('language.negotiation')
->set('url.domains', $domains)
->save();
}
@@ -489,7 +489,7 @@ function language_url_rewrite_session(&$path, &$options) {
global $user;
if (!$user->id()) {
$languages = language_list();
- $query_param = check_plain(Drupal::config('language.negotiation')->get('session.parameter'));
+ $query_param = check_plain(config('language.negotiation')->get('session.parameter'));
$query_value = isset($_GET[$query_param]) ? check_plain($_GET[$query_param]) : NULL;
$query_rewrite = isset($languages[$query_value]) && language_negotiation_method_enabled(LANGUAGE_NEGOTIATION_SESSION);
}
diff --git a/core/modules/language/lib/Drupal/language/Plugin/views/field/LanguageField.php b/core/modules/language/lib/Drupal/language/Plugin/views/field/LanguageField.php
index 671efd0..d1e9cc0 100644
--- a/core/modules/language/lib/Drupal/language/Plugin/views/field/LanguageField.php
+++ b/core/modules/language/lib/Drupal/language/Plugin/views/field/LanguageField.php
@@ -9,7 +9,6 @@
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Component\Annotation\PluginID;
-use Drupal\views\ResultRow;
/**
* Defines a field handler to translate a language into its readable form.
@@ -37,10 +36,7 @@ public function buildOptionsForm(&$form, &$form_state) {
);
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
// @todo: Drupal Core dropped native language until config translation is
// ready, see http://drupal.org/node/1616594.
$value = $this->getValue($values);
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
index e039341..555c198 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
@@ -159,7 +159,7 @@ function testUILanguageNegotiation() {
$this->runTest($test);
// An invalid language is selected.
- \Drupal::config('language.negotiation')->set('selected_langcode', NULL)->save();
+ config('language.negotiation')->set('selected_langcode', NULL)->save();
$test = array(
'language_negotiation' => array(LANGUAGE_NEGOTIATION_SELECTED),
'path' => 'admin/config',
@@ -171,7 +171,7 @@ function testUILanguageNegotiation() {
$this->runTest($test);
// No selected language is available.
- \Drupal::config('language.negotiation')->set('selected_langcode', $langcode_unknown)->save();
+ config('language.negotiation')->set('selected_langcode', $langcode_unknown)->save();
$test = array(
'language_negotiation' => array(LANGUAGE_NEGOTIATION_SELECTED),
'path' => 'admin/config',
@@ -367,7 +367,7 @@ protected function runTest($test) {
language_negotiation_set(Language::TYPE_INTERFACE, $method_weights);
}
if (!empty($test['language_negotiation_url_part'])) {
- \Drupal::config('language.negotiation')
+ config('language.negotiation')
->set('url.source', $test['language_negotiation_url_part'])
->save();
}
@@ -423,7 +423,7 @@ function testUrlLanguageFallback() {
$this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->name, 'The browser language is the URL active language');
// Check that URLs are rewritten using the given browser language.
- $fields = $this->xpath('//strong[@class="site-name"]/a[@rel="home" and @href=:url]', $args);
+ $fields = $this->xpath('//p[@id="site-name"]/strong/a[@rel="home" and @href=:url]', $args);
$this->assertTrue($fields[0] == 'Drupal', 'URLs are rewritten using the browser language.');
}
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
index 5266fd1..8379ca2 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
@@ -114,7 +114,7 @@ function testDomainNameNegotiationPort() {
$this->rebuildContainer();
// Enable domain configuration.
- \Drupal::config('language.negotiation')
+ config('language.negotiation')
->set('url.source', LANGUAGE_NEGOTIATION_URL_DOMAIN)
->save();
diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module
index c3386cf..267cdf3 100644
--- a/core/modules/language/tests/language_test/language_test.module
+++ b/core/modules/language/tests/language_test/language_test.module
@@ -47,10 +47,10 @@ function language_test_language_types_info_alter(array &$language_types) {
unset($language_types[Language::TYPE_CONTENT]['fixed']);
// By default languages are not configurable. Make Language::TYPE_CONTENT
// configurable.
- $configurable = Drupal::config('system.language.types')->get('configurable');
+ $configurable = config('system.language.types')->get('configurable');
if (!in_array(Language::TYPE_CONTENT, $configurable)) {
$configurable[] = Language::TYPE_CONTENT;
- Drupal::config('system.language.types')->set('configurable', $configurable)->save();
+ config('system.language.types')->set('configurable', $configurable)->save();
}
}
}
diff --git a/core/modules/layout/lib/Drupal/layout/Config/DisplayInterface.php b/core/modules/layout/lib/Drupal/layout/Config/DisplayInterface.php
index 4130f6c..916d897 100644
--- a/core/modules/layout/lib/Drupal/layout/Config/DisplayInterface.php
+++ b/core/modules/layout/lib/Drupal/layout/Config/DisplayInterface.php
@@ -41,7 +41,7 @@
* displays (e.g., by a "regular" page, by an administrative page, and within
* one or more dashboards). This function returns the block instances that
* have been added to this display. Each key of the returned array is the
- * block instance's configuration object name, and \Drupal::config() may be called on
+ * block instance's configuration object name, and config() may be called on
* it in order to retrieve the full configuration that is shared across all
* displays. For each key, the value is an array of display-specific
* configuration, primarily the 'region' and 'weight', and anything else that
diff --git a/core/modules/link/lib/Drupal/link/Plugin/field/field_type/LinkItem.php b/core/modules/link/lib/Drupal/link/Plugin/field/field_type/LinkItem.php
index 1fd42df..2a8d851 100644
--- a/core/modules/link/lib/Drupal/link/Plugin/field/field_type/LinkItem.php
+++ b/core/modules/link/lib/Drupal/link/Plugin/field/field_type/LinkItem.php
@@ -10,7 +10,7 @@
use Drupal\Core\Entity\Annotation\FieldType;
use Drupal\Core\Annotation\Translation;
use Drupal\field\Plugin\Type\FieldType\ConfigFieldItemBase;
-use Drupal\field\FieldInterface;
+use Drupal\field\Plugin\Core\Entity\Field;
/**
* Plugin implementation of the 'link' field type.
@@ -59,7 +59,7 @@ public function getPropertyDefinitions() {
/**
* {@inheritdoc}
*/
- public static function schema(FieldInterface $field) {
+ public static function schema(Field $field) {
return array(
'columns' => array(
'url' => array(
diff --git a/core/modules/locale/css/locale.admin.css b/core/modules/locale/css/locale.admin.css
index c1e05e9..bae704d 100644
--- a/core/modules/locale/css/locale.admin.css
+++ b/core/modules/locale/css/locale.admin.css
@@ -43,7 +43,7 @@
vertical-align: top
}
-.locale-translate-edit-form tr.changed {
+.locale-translate-edit-form .changed {
background: #ffb;
}
diff --git a/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php b/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php
index 826ba38..5669d8f 100644
--- a/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php
+++ b/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php
@@ -44,7 +44,7 @@ public function buildForm(array $form, array &$form_state) {
'#default_value' => $config->get('translation.check_disabled_modules'),
);
- if ($directory =\Drupal::config('locale.settings')->get('translation.path')) {
+ if ($directory =config('locale.settings')->get('translation.path')) {
$description = t('Translation files are stored locally in the %path directory. You can change this directory on the File system configuration page.', array('%path' => $directory, '@url' => url('admin/config/media/file-system')));
}
else {
diff --git a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php
index 6881092..075a815 100644
--- a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php
+++ b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php
@@ -106,7 +106,7 @@ protected function resolveCacheMiss($offset) {
// the exact list of strings used on a page. From a performance
// perspective that is a really bad idea, so we have no user
// interface for this. Be careful when turning this option off!
- if (\Drupal::config('locale.settings')->get('cache_strings')) {
+ if (config('locale.settings')->get('cache_strings')) {
$this->persist($offset);
}
return $value;
diff --git a/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php b/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php
index dd44492..b28748a 100644
--- a/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php
+++ b/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php
@@ -155,7 +155,7 @@ function getHeader() {
*/
function setHeader(PoHeader $header) {
$this->_header = $header;
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
$locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
// Check for options.
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php
index aa53fbb..414cde0 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php
@@ -136,7 +136,7 @@ function testConfigTranslation() {
$this->assertEqual($property->getValue(), $image_style_label, 'Got the right translation for image style name after translation');
// Quick test to ensure translation file exists.
- $this->assertEqual(\Drupal::config('locale.config.xx.image.style.medium')->get('label'), $image_style_label);
+ $this->assertEqual(config('locale.config.xx.image.style.medium')->get('label'), $image_style_label);
// Disable and uninstall the module.
$this->drupalPost('admin/modules', array('modules[Core][image][enable]' => FALSE), t('Save configuration'));
@@ -144,7 +144,7 @@ function testConfigTranslation() {
$this->drupalPost(NULL, array(), t('Uninstall'));
// Ensure that the translated configuration has been removed.
- $this->assertFalse(\Drupal::config('locale.config.xx.image.style.medium')->get('label'), 'Translated configuration for image module removed.');
+ $this->assertFalse(config('locale.config.xx.image.style.medium')->get('label'), 'Translated configuration for image module removed.');
}
}
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
index f8fb4c4..198207b 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
@@ -53,7 +53,7 @@ function testStandalonePoFile() {
$this->importPoFile($this->getPoFile(), array(
'langcode' => 'fr',
));
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
// The import should automatically create the corresponding language.
$this->assertRaw(t('The language %language has been created.', array('%language' => 'French')), 'The language has been automatically created.');
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
index 878444d..f81c916 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
@@ -34,7 +34,7 @@ function setUp() {
parent::setUp();
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- \Drupal::config('system.site')->set('page.front', 'node')->save();
+ config('system.site')->set('page.front', 'node')->save();
}
/**
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php
index 15a1c55..a03f1df 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php
@@ -98,11 +98,15 @@ function testGetPluralFormat() {
1 => 0,
0 => 1,
5 => 1,
+ 123 => 1,
+ 235 => 1,
),
'fr' => array(
1 => 0,
0 => 0,
5 => 1,
+ 123 => 1,
+ 235 => 1,
),
'hr' => array(
1 => 0,
@@ -110,6 +114,8 @@ function testGetPluralFormat() {
0 => 2,
2 => 1,
8 => 2,
+ 123 => 1,
+ 235 => 2,
),
'hu' => array(
1 => -1,
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php
index e391022..167fc6a 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php
@@ -216,7 +216,7 @@ function testStringTranslation() {
function testJavaScriptTranslation() {
$user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages'));
$this->drupalLogin($user);
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
$langcode = 'xx';
// The English name for the language. This will be translated.
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
index 1cfb538..e2d1109 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
@@ -50,7 +50,7 @@ function setUp() {
*/
function testUninstallProcess() {
$locale_module = array('locale', 'language');
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
$language = new Language(array(
'id' => 'fr',
'name' => 'French',
@@ -87,7 +87,7 @@ function testUninstallProcess() {
$edit = array('strings[' . $string->lid . '][translations][0]' => 'french translation');
$this->drupalPost('admin/config/regional/translate', $edit, t('Save translations'));
_locale_rebuild_js('fr');
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
$locale_javascripts = $this->container->get('state')->get('locale.translation.javascript') ?: array();
$js_file = 'public://' . $config->get('javascript.directory') . '/fr_' . $locale_javascripts['fr'] . '.js';
$this->assertTrue($result = file_exists($js_file), String::format('JavaScript file created: %file', array('%file' => $result ? $js_file : 'none')));
@@ -103,7 +103,7 @@ function testUninstallProcess() {
variable_set('language_negotiation_' . Language::TYPE_URL, language_language_negotiation_info());
// Change language negotiation settings.
- \Drupal::config('language.negotiation')
+ config('language.negotiation')
->set('url.source', LANGUAGE_NEGOTIATION_URL_PREFIX)
->set('session.parameter', TRUE)
->save();
@@ -136,8 +136,8 @@ function testUninstallProcess() {
$this->assertTrue($language_negotiation, String::format('URL language negotiation: %setting', array('%setting' => $language_negotiation ? 'none' : 'set')));
// Check language negotiation method settings.
- $this->assertFalse(\Drupal::config('language.negotiation')->get('url.source'), 'URL language negotiation method indicator settings cleared.');
- $this->assertFalse(\Drupal::config('language.negotiation')->get('session.parameter'), 'Visit language negotiation method settings cleared.');
+ $this->assertFalse(config('language.negotiation')->get('url.source'), 'URL language negotiation method indicator settings cleared.');
+ $this->assertFalse(config('language.negotiation')->get('session.parameter'), 'Visit language negotiation method settings cleared.');
// Check JavaScript parsed.
$javascript_parsed_count = count($this->container->get('state')->get('system.javascript_parsed') ?: array());
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php
index 46d082e..e8562ba 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php
@@ -69,7 +69,7 @@ function setUp() {
protected function setTranslationsDirectory($path) {
$this->tranlations_directory = $path;
file_prepare_directory($path, FILE_CREATE_DIRECTORY);
- \Drupal::config('locale.settings')->set('translation.path', $path)->save();
+ config('locale.settings')->set('translation.path', $path)->save();
}
/**
@@ -165,7 +165,7 @@ protected function makePoFile($path, $filename, $timestamp = NULL, $translations
* imported.
*/
protected function setTranslationFiles() {
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
// A flag is set to let the locale_test module replace the project data with
// a set of test projects which match the below project files.
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateCronTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateCronTest.php
index 90a914f..04dd4fd 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateCronTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateCronTest.php
@@ -46,7 +46,7 @@ function testUpdateCron() {
// Setup local and remote translations files.
$this->setTranslationFiles();
- \Drupal::config('locale.settings')->set('translation.default_filename', '%project-%version.%language._po')->save();
+ config('locale.settings')->set('translation.default_filename', '%project-%version.%language._po')->save();
// Update translations using batch to ensure a clean test starting point.
$this->drupalGet('admin/reports/translations/check');
@@ -108,8 +108,6 @@ function testUpdateCron() {
$queue = \Drupal::queue('locale_translation', TRUE);
$this->assertEqual($queue->numberOfItems(), 3, 'Queue holds tasks for one project.');
- // Ensure last checked is updated to a greater time than the initial value.
- sleep(1);
// Test: Execute cron and check if tasks are executed correctly.
// Run cron to process the tasks in the queue.
$this->drupalGet('admin/reports/status/run-cron');
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php
index 9f55abc..cb19716 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php
@@ -65,7 +65,7 @@ function testUpdateProjects() {
*/
function testUpdateProjectsHidden() {
module_load_include('compare.inc', 'locale');
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
// Make the test modules look like a normal custom module.
\Drupal::state()->set('locale.test_system_info_alter', TRUE);
@@ -97,7 +97,7 @@ function testUpdateProjectsHidden() {
* for local files only, check for both local and remote files.
*/
function testUpdateCheckStatus() {
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
// Set a flag to let the locale_test module replace the project data with a
// set of test projects.
\Drupal::state()->set('locale.test_projects_alter', TRUE);
@@ -149,7 +149,7 @@ function testUpdateCheckStatus() {
* - Import overwrite: all existing translations
*/
function testUpdateImportSourceRemote() {
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
// Build the test environment.
$this->setTranslationFiles();
@@ -211,7 +211,7 @@ function testUpdateImportSourceRemote() {
* - Import overwrite: all existing translations
*/
function testUpdateImportSourceLocal() {
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
// Build the test environment.
$this->setTranslationFiles();
@@ -265,7 +265,7 @@ function testUpdateImportSourceLocal() {
* - Import overwrite: only overwrite non-customized translations
*/
function testUpdateImportModeNonCustomized() {
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
// Build the test environment.
$this->setTranslationFiles();
@@ -301,7 +301,7 @@ function testUpdateImportModeNonCustomized() {
* - Import overwrite: don't overwrite any existing translation
*/
function testUpdateImportModeNone() {
- $config = \Drupal::config('locale.settings');
+ $config = config('locale.settings');
// Build the test environment.
$this->setTranslationFiles();
diff --git a/core/modules/locale/lib/Drupal/locale/TranslationsStream.php b/core/modules/locale/lib/Drupal/locale/TranslationsStream.php
index 5245bd4..34ef38e 100644
--- a/core/modules/locale/lib/Drupal/locale/TranslationsStream.php
+++ b/core/modules/locale/lib/Drupal/locale/TranslationsStream.php
@@ -20,7 +20,7 @@ class TranslationsStream extends LocalStream {
* Implements Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath()
*/
function getDirectoryPath() {
- return \Drupal::config('locale.settings')->get('translation.path');
+ return config('locale.settings')->get('translation.path');
}
/**
diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc
index 008cb50..91b7555 100644
--- a/core/modules/locale/locale.batch.inc
+++ b/core/modules/locale/locale.batch.inc
@@ -236,9 +236,11 @@ function locale_translation_http_check($uri) {
->send();
$result = array();
- // Return the effective URL if it differs from the requested.
- if ($response->getEffectiveUrl() != $uri) {
- $result['location'] = $response->getEffectiveUrl();
+ // In case of a permanent redirected response, return the final location.
+ if ($previous = $response->getPreviousResponse()) {
+ if ($previous->getStatusCode() == 301) {
+ $result['location'] = $previous->getLocation();
+ }
}
$result['last_modified'] = $response->getLastModified() ? strtotime($response->getLastModified()) : 0;
diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc
index 02731a4..8a15656 100644
--- a/core/modules/locale/locale.bulk.inc
+++ b/core/modules/locale/locale.bulk.inc
@@ -243,7 +243,7 @@ function locale_translate_export_form_submit($form, &$form_state) {
if (!empty($item)) {
$uri = tempnam('temporary://', 'po_');
$header = $reader->getHeader();
- $header->setProjectName(Drupal::config('system.site')->get('name'));
+ $header->setProjectName(config('system.site')->get('name'));
$header->setLanguageName($languageName);
$writer = new PoStreamWriter;
@@ -348,7 +348,7 @@ function locale_translate_get_interface_translation_files($projects = array(), $
// containing a project name and language code: {project}.{langcode}.po or
// {project}-{version}.{langcode}.po.
// Only files of known projects and languages will be returned.
- $directory = Drupal::config('locale.settings')->get('translation.path');
+ $directory = config('locale.settings')->get('translation.path');
$result = file_scan_directory($directory, '![a-z_]+(\-[0-9a-z\.\-\+]+|)\.[^\./]+\.po$!', array('recurse' => FALSE));
foreach ($result as $file) {
@@ -799,7 +799,7 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar
$batch_names[] = $name;
$i++;
// During installation the caching of configuration objects is disabled
- // so it is very expensive to initialize the Drupal::config() object on each request.
+ // so it is very expensive to initialize the config() object on each request.
// We batch a small number of configuration object upgrades together to
// improve the overall performance of the process.
if ($i % 20 == 0) {
diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc
index ed4664d..d0271bd 100644
--- a/core/modules/locale/locale.compare.inc
+++ b/core/modules/locale/locale.compare.inc
@@ -130,7 +130,7 @@ function locale_translation_project_list() {
$projects = &drupal_static(__FUNCTION__, array());
if (empty($projects)) {
module_load_include('compare.inc', 'update');
- $config = Drupal::config('locale.settings');
+ $config = config('locale.settings');
$projects = array();
$additional_whitelist = array(
@@ -195,9 +195,9 @@ function _locale_translation_prepare_project_list($data, $type) {
* - "server_pattern": URI containing po file pattern.
*/
function locale_translation_default_translation_server() {
- $pattern = Drupal::config('locale.settings')->get('translation.default_server_pattern');
+ $pattern = config('locale.settings')->get('translation.default_server_pattern');
// An additional check is required here. During the upgrade process
- // Drupal::config()->get() returns NULL. We use the defined value as fallback.
+ // config()->get() returns NULL. We use the defined value as fallback.
$pattern = $pattern ? $pattern : LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN;
return array(
diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install
index b830040..b781421 100644
--- a/core/modules/locale/locale.install
+++ b/core/modules/locale/locale.install
@@ -12,9 +12,9 @@
*/
function locale_install() {
// Create the interface translations directory and ensure it's writable.
- if (!$directory = Drupal::config('locale.settings')->get('translation.path')) {
+ if (!$directory = config('locale.settings')->get('translation.path')) {
$directory = conf_path() . '/files/translations';
- Drupal::config('locale.settings')->set('translation.path', $directory)->save();
+ config('locale.settings')->set('translation.path', $directory)->save();
}
file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
}
@@ -23,7 +23,7 @@ function locale_install() {
* Implements hook_uninstall().
*/
function locale_uninstall() {
- $config = Drupal::config('locale.settings');
+ $config = config('locale.settings');
// Delete all JavaScript translation files.
$locale_js_directory = 'public://' . $config->get('javascript.directory');
@@ -468,7 +468,7 @@ function locale_update_8002() {
*/
function locale_update_8003() {
$message = '';
- $config = Drupal::config('language.negotiation');
+ $config = config('language.negotiation');
$domains = $config->get('url.domains') ?: array();
// $used_domains keeps track of the domain names in use.
@@ -953,7 +953,7 @@ function locale_update_8016() {
foreach ($result as $format) {
$language = $format->language;
// Create config objects for the language if not yet done.
- Drupal::config("locale.config.$language.system.date_format." . $format->type)
+ config("locale.config.$language.system.date_format." . $format->type)
->set('pattern.php', $format->format)
->save();
}
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 01c9a4f..932b2a1 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -363,9 +363,12 @@ function locale_get_plural($count, $langcode = NULL) {
// $count and statically cache the result for the combination of language
// and count, since the result will always be identical.
if (!empty($plural_formulas[$langcode])) {
- // $n is used inside the expression in the eval().
- $n = $count;
- $plural_indexes[$langcode][$count] = @eval('return intval(' . $plural_formulas[$langcode]['formula'] . ');');
+ // Plural formulas are stored as an array for 0-199. 100 is the highest
+ // modulo used but storing 0-99 is not enough because below 100 we often
+ // find exceptions (1, 2, etc).
+ $index = $count > 199 ? 100 + ($count % 100) : $count;
+ $plural_indexes[$langcode][$count] = isset($plural_formulas[$langcode]['formula'][$index]) ? $plural_formulas[$langcode]['formula'][$index] : $plural_formulas[$langcode]['formula']['default'];
+
}
// In case there is no plural formula for English (no imported translation
// for English), use a default formula.
@@ -427,7 +430,7 @@ function locale_cron() {
// and a translatable language was set.
// Update tasks are added to the queue here but processed by Drupal's cron
// using the cron worker defined in locale_queue_info().
- if ($frequency = Drupal::config('locale.settings')->get('translation.update_interval_days') && locale_translatable_language_list()) {
+ if ($frequency = config('locale.settings')->get('translation.update_interval_days') && locale_translatable_language_list()) {
module_load_include('translation.inc', 'locale');
locale_cron_fill_queue();
}
@@ -519,7 +522,7 @@ function locale_system_update(array $components) {
// Skip running the translation imports if in the installer,
// because it would break out of the installer flow. We have
// built-in support for translation imports in the installer.
- if (!drupal_installation_attempted() && locale_translatable_language_list() && Drupal::config('locale.settings')->get('translation.import_enabled')) {
+ if (!drupal_installation_attempted() && locale_translatable_language_list() && config('locale.settings')->get('translation.import_enabled')) {
module_load_include('compare.inc', 'locale');
// Update the list of translatable projects and start the import batch.
@@ -595,7 +598,7 @@ function locale_js_alter(&$javascript) {
$language_interface = language(Language::TYPE_INTERFACE);
- $dir = 'public://' . Drupal::config('local.settings')->get('javascript.directory');
+ $dir = 'public://' . config('local.settings')->get('javascript.directory');
$parsed = Drupal::state()->get('system.javascript_parsed') ?: array();
$files = $new_files = FALSE;
@@ -696,7 +699,7 @@ function locale_library_info_alter(&$libraries, $module) {
'ui' => array(
'datepicker' => array(
'isRTL' => $language_interface->direction == Language::DIRECTION_RTL,
- 'firstDay' => Drupal::config('system.date')->get('first_day'),
+ 'firstDay' => config('system.date')->get('first_day'),
),
),
),
@@ -773,7 +776,7 @@ function locale_form_language_admin_add_form_alter(&$form, &$form_state) {
* Set a batch for a newly-added language.
*/
function locale_form_language_admin_add_form_alter_submit($form, $form_state) {
- if (Drupal::config('locale.settings')->get('translation.import_enabled')) {
+ if (config('locale.settings')->get('translation.import_enabled')) {
if (empty($form_state['values']['predefined_langcode']) || $form_state['values']['predefined_langcode'] == 'custom') {
$langcode = $form_state['values']['langcode'];
}
@@ -835,7 +838,7 @@ function locale_form_system_file_system_settings_alter(&$form, $form_state) {
$form['translation_path'] = array(
'#type' => 'textfield',
'#title' => t('Interface translations directory'),
- '#default_value' => Drupal::config('locale.settings')->get('translation.path'),
+ '#default_value' => config('locale.settings')->get('translation.path'),
'#maxlength' => 255,
'#description' => t('A local file system path where interface translation files will be stored.'),
'#required' => TRUE,
@@ -860,7 +863,7 @@ function locale_system_file_system_settings_submit(&$form, $form_state) {
locale_translation_clear_status();
}
- Drupal::config('locale.settings')
+ config('locale.settings')
->set('translation.path', $form_state['values']['translation_path'])
->save();
}
@@ -1095,7 +1098,7 @@ function locale_translation_clear_status() {
* when checking or importing translation files, FALSE otherwise.
*/
function locale_translation_use_remote_source() {
- return Drupal::config('locale.settings')->get('translation.use_source') == LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL;
+ return config('locale.settings')->get('translation.use_source') == LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL;
}
/**
@@ -1308,7 +1311,7 @@ function _locale_invalidate_js($langcode = NULL) {
* The language, the translation file should be (re)created for.
*/
function _locale_rebuild_js($langcode = NULL) {
- $config = Drupal::config('locale.settings');
+ $config = config('locale.settings');
if (!isset($langcode)) {
$language = language(Language::TYPE_INTERFACE);
}
diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc
index 30c7b0f..3c77ff0 100644
--- a/core/modules/locale/locale.translation.inc
+++ b/core/modules/locale/locale.translation.inc
@@ -236,7 +236,7 @@ function locale_translation_source_build($project, $langcode, $filename = NULL)
$source->timestamp = 0;
$source->last_checked = 0;
- $filename = $filename ? $filename : Drupal::config('locale.settings')->get('translation.default_filename');
+ $filename = $filename ? $filename : config('locale.settings')->get('translation.default_filename');
// If the server_pattern contains a remote file path we will check for a
// remote file. The local version of this file will only be checked if a
@@ -322,7 +322,7 @@ function locale_translation_build_server_pattern($project, $template) {
*/
function locale_cron_fill_queue() {
$updates = array();
- $config = Drupal::config('locale.settings');
+ $config = config('locale.settings');
// Determine which project+language should be updated.
$last = REQUEST_TIME - $config->get('translation.update_interval_days') * 3600 * 24;
@@ -425,7 +425,7 @@ function _locale_translation_source_compare($source1, $source2) {
* Array of translation import options.
*/
function _locale_translation_default_update_options() {
- $config = Drupal::config('locale.settings');
+ $config = config('locale.settings');
return array(
'customized' => LOCALE_NOT_CUSTOMIZED,
'overwrite_options' => array(
diff --git a/core/modules/menu/lib/Drupal/menu/Access/DeleteLinkAccessCheck.php b/core/modules/menu/lib/Drupal/menu/Access/DeleteLinkAccessCheck.php
new file mode 100644
index 0000000..45560dc
--- /dev/null
+++ b/core/modules/menu/lib/Drupal/menu/Access/DeleteLinkAccessCheck.php
@@ -0,0 +1,37 @@
+attributes->get('menu_link')) {
+ // Links defined via hook_menu may not be deleted. Updated items are an
+ // exception, as they can be broken.
+ return $menu_link->module !== 'system' || $menu_link->updated;
+ }
+ return FALSE;
+ }
+}
diff --git a/core/modules/menu/lib/Drupal/menu/MenuAccessController.php b/core/modules/menu/lib/Drupal/menu/MenuAccessController.php
new file mode 100644
index 0000000..b7128c0
--- /dev/null
+++ b/core/modules/menu/lib/Drupal/menu/MenuAccessController.php
@@ -0,0 +1,46 @@
+id()])) {
+ return FALSE;
+ }
+ }
+
+ if (in_array($operation, array('update', 'delete'))) {
+ return user_access('administer menu', $account);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
+ return user_access('administer menu', $account);
+ }
+
+}
diff --git a/core/modules/menu/lib/Drupal/menu/MenuFormController.php b/core/modules/menu/lib/Drupal/menu/MenuFormController.php
index 6573865..bedb08b 100644
--- a/core/modules/menu/lib/Drupal/menu/MenuFormController.php
+++ b/core/modules/menu/lib/Drupal/menu/MenuFormController.php
@@ -174,8 +174,10 @@ public function menuNameExists($value) {
*/
protected function actions(array $form, array &$form_state) {
$actions = parent::actions($form, $form_state);
+ $menu = $this->entity;
- $actions['delete']['#access'] = !$this->entity->isNew() && $this->entity->access('delete');
+ $system_menus = menu_list_system_menus();
+ $actions['delete']['#access'] = !$menu->isNew() && !isset($system_menus[$menu->id()]);
// Add the language configuration submit handler. This is needed because the
// submit button has custom submit handlers.
@@ -221,10 +223,8 @@ public function languageConfigurationSubmit(array &$form, array &$form_state) {
*/
public function save(array $form, array &$form_state) {
$menu = $this->entity;
- // @todo Get rid of menu_list_system_menus() https://drupal.org/node/1882552
- // Supposed menu item declared by hook_menu()
- // Should be moved to submitOverviewForm()
$system_menus = menu_list_system_menus();
+
if (!$menu->isNew() || isset($system_menus[$menu->id()])) {
$this->submitOverviewForm($form, $form_state);
}
@@ -354,27 +354,31 @@ protected function buildOverviewTreeForm($tree, $delta) {
);
// Build a list of operations.
$operations = array();
- $operations['edit'] = array(
+ $links = array();
+ $links['edit'] = array(
'title' => t('Edit'),
'href' => 'admin/structure/menu/item/' . $item['mlid'] . '/edit',
);
+ $operations['edit'] = array('#type' => 'link', '#title' => t('Edit'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/edit');
// Only items created by the menu module can be deleted.
- if ($item->access('delete')) {
- $operations['delete'] = array(
+ if ($item['module'] == 'menu' || $item['updated'] == 1) {
+ $links['delete'] = array(
'title' => t('Delete'),
'href' => 'admin/structure/menu/item/' . $item['mlid'] . '/delete',
);
+ $operations['delete'] = array('#type' => 'link', '#title' => t('Delete'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/delete');
}
// Set the reset column.
- elseif ($item->access('reset')) {
- $operations['reset'] = array(
+ elseif ($item['module'] == 'system' && $item['customized']) {
+ $links['reset'] = array(
'title' => t('Reset'),
'href' => 'admin/structure/menu/item/' . $item['mlid'] . '/reset',
);
+ $operations['reset'] = array('#type' => 'link', '#title' => t('Reset'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/reset');
}
$form[$mlid]['operations'] = array(
'#type' => 'operations',
- '#links' => $operations,
+ '#links' => $links,
);
}
diff --git a/core/modules/menu/lib/Drupal/menu/MenuListController.php b/core/modules/menu/lib/Drupal/menu/MenuListController.php
index a9db41e..139c40b 100644
--- a/core/modules/menu/lib/Drupal/menu/MenuListController.php
+++ b/core/modules/menu/lib/Drupal/menu/MenuListController.php
@@ -49,16 +49,16 @@ public function getOperations(EntityInterface $entity) {
if (isset($operations['edit'])) {
$operations['edit']['title'] = t('Edit menu');
- $operations['add'] = array(
- 'title' => t('Add link'),
- 'href' => $uri['path'] . '/add',
- 'options' => $uri['options'],
- 'weight' => 20,
- );
}
if (isset($operations['delete'])) {
$operations['delete']['title'] = t('Delete menu');
}
+ $operations['add'] = array(
+ 'title' => t('Add link'),
+ 'href' => $uri['path'] . '/add',
+ 'options' => $uri['options'],
+ 'weight' => 20,
+ );
return $operations;
}
diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
index 83f2bc3..1303f43 100644
--- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
+++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
@@ -161,7 +161,7 @@ function addCustomMenu() {
// Enable the custom menu block.
$menu_name = 'menu-' . $menu_name; // Drupal prepends the name with 'menu-'.
// Confirm that the custom menu block is available.
- $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default'));
+ $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add');
$this->assertText($label);
// Enable the block.
@@ -379,7 +379,7 @@ function testSystemMenuRename() {
// Make sure menu shows up with new name in block addition.
$default_theme = variable_get('theme_default', 'stark');
- $this->drupalget('admin/structure/block/list/' . $default_theme);
+ $this->drupalget('admin/structure/block/list/block_plugin_ui:' . $default_theme . '/add');
$this->assertText($edit['label']);
}
diff --git a/core/modules/menu/menu.install b/core/modules/menu/menu.install
index f1fc64d..ae94f90 100644
--- a/core/modules/menu/menu.install
+++ b/core/modules/menu/menu.install
@@ -80,7 +80,7 @@ function menu_update_8004() {
$result = db_query('SELECT * FROM {menu_custom}');
foreach ($result as $menu) {
// Save the config object.
- Drupal::config('menu.menu.' . $menu->menu_name)
+ config('menu.menu.' . $menu->menu_name)
->set('id', $menu->menu_name)
->set('uuid', $uuid->generate())
->set('label', $menu->title)
diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module
index 5d83382..6e208c3 100644
--- a/core/modules/menu/menu.module
+++ b/core/modules/menu/menu.module
@@ -125,6 +125,7 @@ function menu_menu() {
*/
function menu_entity_info(&$entity_info) {
$entity_info['menu']['controllers']['list'] = 'Drupal\menu\MenuListController';
+ $entity_info['menu']['controllers']['access'] = 'Drupal\menu\MenuAccessController';
$entity_info['menu']['uri_callback'] = 'menu_uri';
$entity_info['menu']['controllers']['form'] = array(
'add' => 'Drupal\menu\MenuFormController',
@@ -143,7 +144,7 @@ function menu_entity_bundle_info() {
$bundles = array();
$config_names = config_get_storage_names_with_prefix('menu.menu.');
foreach ($config_names as $config_name) {
- $config = Drupal::config($config_name);
+ $config = config($config_name);
$bundles['menu_link'][$config->get('id')] = array(
'label' => $config->get('label'),
);
@@ -236,7 +237,7 @@ function menu_menu_insert(Menu $menu) {
// Make sure the menu is present in the active menus variable so that its
// items may appear in the menu active trail.
// See menu_set_active_menu_names().
- $config = Drupal::config('system.menu');
+ $config = config('system.menu');
$active_menus = $config->get('active_menus_default') ?: array_keys(menu_get_menus());
if (!in_array($menu->id(), $active_menus)) {
@@ -312,7 +313,7 @@ function menu_parent_options(array $menus, MenuLink $menu_link = NULL, $type = N
// allow contrib modules to provide more scalable pattern choosers.
// hook_form_alter is too late in itself because all the possible parents are
// retrieved here, unless override_parent_selector is set to TRUE.
- if (Drupal::config('menu.settings')->get('override_parent_selector')) {
+ if (config('menu.settings')->get('override_parent_selector')) {
return array();
}
diff --git a/core/modules/menu/menu.routing.yml b/core/modules/menu/menu.routing.yml
index c5a0d10..d710470 100644
--- a/core/modules/menu/menu.routing.yml
+++ b/core/modules/menu/menu.routing.yml
@@ -24,28 +24,28 @@ menu_link_add:
defaults:
_content: '\Drupal\menu\Controller\MenuController::addLink'
requirements:
- _entity_create_access: 'menu_link'
+ _permission: 'administer menu'
menu_link_edit:
pattern: '/admin/structure/menu/item/{menu_link}/edit'
defaults:
_entity_form: 'menu_link'
requirements:
- _entity_access: 'menu_link.update'
+ _permission: 'administer menu'
menu_link_reset:
pattern: 'admin/structure/menu/item/{menu_link}/reset'
defaults:
_entity_form: 'menu_link.reset'
requirements:
- _entity_access: 'menu_link.reset'
+ _permission: 'administer menu'
menu_link_delete:
pattern: 'admin/structure/menu/item/{menu_link}/delete'
defaults:
_entity_form: 'menu_link.delete'
requirements:
- _entity_access: 'menu_link.delete'
+ _access_menu_delete_link: 'TRUE'
menu_menu_add:
pattern: '/admin/structure/menu/add'
diff --git a/core/modules/menu/menu.services.yml b/core/modules/menu/menu.services.yml
new file mode 100644
index 0000000..f68094f
--- /dev/null
+++ b/core/modules/menu/menu.services.yml
@@ -0,0 +1,5 @@
+services:
+ access_check.menu.delete_link:
+ class: Drupal\menu\Access\DeleteLinkAccessCheck
+ tags:
+ - { name: access_check }
diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php
deleted file mode 100644
index 664e7da..0000000
--- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php
+++ /dev/null
@@ -1,48 +0,0 @@
-hasPermission('administer menu');
- if ($access) {
- switch ($operation) {
- case 'reset':
- // Reset allowed for items defined via hook_menu() and customized.
- return $entity->module == 'system' && $entity->customized;
-
- case 'delete':
- // Only items created by the menu module can be deleted.
- return $entity->module == 'menu' || $entity->updated == 1;
-
- }
- }
- return $access;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
- return $account->hasPermission('administer menu');
- }
-
-}
diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php
index 9d58de9..8eb4458 100644
--- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php
+++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php
@@ -208,7 +208,7 @@ public function form(array $form, array &$form_state) {
protected function actions(array $form, array &$form_state) {
$element = parent::actions($form, $form_state);
$element['submit']['#button_type'] = 'primary';
- $element['delete']['#access'] = $this->entity->access('delete');
+ $element['delete']['#access'] = $this->entity->module == 'menu';
return $element;
}
diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php
index 3ff0fdf..2adf1b7 100644
--- a/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php
+++ b/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php
@@ -28,7 +28,6 @@
* module = "menu_link",
* controllers = {
* "storage" = "Drupal\menu_link\MenuLinkStorageController",
- * "access" = "Drupal\menu_link\MenuLinkAccessController",
* "render" = "Drupal\Core\Entity\EntityRenderController",
* "form" = {
* "default" = "Drupal\menu_link\MenuLinkFormController"
diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php
index ccc1dcc..c9649ef 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -69,7 +69,7 @@ public function form(array $form, array &$form_state) {
drupal_set_title(t('Edit @type @title', array('@type' => node_get_type_label($node), '@title' => $node->label())), PASS_THROUGH);
}
- $user_config = \Drupal::config('user.settings');
+ $user_config = config('user.settings');
// Some special stuff when previewing a node.
if (isset($form_state['node_preview'])) {
$form['#prefix'] = $form_state['node_preview'];
diff --git a/core/modules/node/lib/Drupal/node/NodeRenderController.php b/core/modules/node/lib/Drupal/node/NodeRenderController.php
index 1b234f7..e7fb844 100644
--- a/core/modules/node/lib/Drupal/node/NodeRenderController.php
+++ b/core/modules/node/lib/Drupal/node/NodeRenderController.php
@@ -30,7 +30,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang
parent::buildContent($entities, $displays, $view_mode, $langcode);
- foreach ($entities as $entity) {
+ foreach ($entities as $key => $entity) {
$bundle = $entity->bundle();
$display = $displays[$bundle];
diff --git a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php
index 54ae77f..6572ba9 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php
@@ -136,7 +136,7 @@ public function getBCEntity() {
*/
public static function preDelete(EntityStorageControllerInterface $storage_controller, array $entities) {
if (module_exists('search')) {
- foreach ($entities as $entity) {
+ foreach ($entities as $id => $entity) {
search_reindex($entity->nid->value, 'node');
}
}
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/Language.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/Language.php
index 1b7be8e..eb6cb14 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/field/Language.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/Language.php
@@ -9,7 +9,6 @@
use Drupal\node\Plugin\views\field\Node;
use Drupal\Component\Annotation\PluginID;
-use Drupal\views\ResultRow;
/**
* Field handler to translate a language into its readable form.
@@ -37,10 +36,7 @@ public function buildOptionsForm(&$form, &$form_state) {
);
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
// @todo: Drupal Core dropped native language until config translation is
// ready, see http://drupal.org/node/1616594.
$value = $this->getValue($values);
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php
index a4715a8..b19cdcb 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php
@@ -46,10 +46,7 @@ public function query() {
$this->addAdditionalFields();
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
if ($entity = $this->getEntity($values)) {
return $this->renderLink($entity, $values);
}
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/Node.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/Node.php
index 21a254c..7d5a44f 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/field/Node.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/Node.php
@@ -87,10 +87,7 @@ protected function renderLink($data, ResultRow $values) {
return $data;
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
$value = $this->getValue($values);
return $this->renderLink($this->sanitizeValue($value), $values);
}
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php
index 4ae0bef..68441f6 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php
@@ -7,8 +7,8 @@
namespace Drupal\node\Plugin\views\field;
-use Drupal\views\Plugin\views\field\ActionBulkForm;
use Drupal\Component\Annotation\PluginID;
+use Drupal\system\Plugin\views\field\BulkFormBase;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityManager;
@@ -17,7 +17,7 @@
*
* @PluginID("node_bulk_form")
*/
-class NodeBulkForm extends ActionBulkForm {
+class NodeBulkForm extends BulkFormBase {
/**
* Constructs a new NodeBulkForm object.
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/Path.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/Path.php
index 4c0c6c8..78ff114 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/field/Path.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/Path.php
@@ -9,7 +9,6 @@
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
-use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\Component\Annotation\PluginID;
@@ -54,10 +53,7 @@ public function query() {
$this->addAdditionalFields();
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
$nid = $this->getValue($values, 'nid');
return url("node/$nid", array('absolute' => $this->options['absolute']));
}
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/Type.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/Type.php
index 1f46301..d712928 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/field/Type.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/Type.php
@@ -9,7 +9,6 @@
use Drupal\node\Plugin\views\field\Node;
use Drupal\Component\Annotation\PluginID;
-use Drupal\views\ResultRow;
/**
* Field handler to translate a node type into its readable form.
@@ -52,10 +51,7 @@ function render_name($data, $values) {
return $this->sanitizeValue($data);
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
$value = $this->getValue($values);
return $this->renderLink($this->render_name($value, $values), $values);
}
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/row/Rss.php b/core/modules/node/lib/Drupal/node/Plugin/views/row/Rss.php
index 89c7940..4d824bd 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/row/Rss.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/row/Rss.php
@@ -100,7 +100,7 @@ public function render($row) {
$display_mode = $this->options['item_length'];
if ($display_mode == 'default') {
- $display_mode = \Drupal::config('system.rss')->get('items.view_mode');
+ $display_mode = config('system.rss')->get('items.view_mode');
}
// Load the specified node:
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
index ee55eb9..1200907 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
@@ -129,7 +129,7 @@ function testNodeAccessBasic() {
$access_user = $this->drupalCreateUser(array('access content', 'create article content', 'node test view', 'search content'));
$this->drupalLogin($access_user);
- foreach ($this->nodesByUser as $private_status) {
+ foreach ($this->nodesByUser as $uid => $private_status) {
foreach ($private_status as $nid => $is_private) {
$this->drupalGet('node/' . $nid);
$this->assertResponse(200);
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
index 287ec65..7b2cfe3 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
@@ -73,7 +73,7 @@ public function testCommentPager() {
*/
public function testForumPager() {
// Look up the forums vocabulary ID.
- $vid = \Drupal::config('forum.settings')->get('vocabulary');
+ $vid = config('forum.settings')->get('vocabulary');
$this->assertTrue($vid, 'Forum navigation vocabulary ID is set.');
// Look up the general discussion term.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
index cd5d89f..90592b0 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
@@ -104,10 +104,10 @@ function testFailedPageCreation() {
*/
function testUnpublishedNodeCreation() {
// Set the front page to the test page.
- \Drupal::config('system.site')->set('page.front', 'test-page')->save();
+ config('system.site')->set('page.front', 'test-page')->save();
// Set "Basic page" content type to be unpublished by default.
- \Drupal::config('node.type.page')->set('settings.node.options', array())->save();
+ config('node.type.page')->set('settings.node.options', array())->save();
// Create a node.
$edit = array();
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php
index 2a8f025..b52d825 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php
@@ -109,7 +109,7 @@ function testNodeFormButtons() {
// the initial order of buttons and/or status of the node when creating
// a node.
variable_set('node_options_article', array('promote'));
- \Drupal::config('node.type.article')->set('settings.node.options.status', 0)->save();
+ config('node.type.article')->set('settings.node.options.status', 0)->save();
// Verify the buttons on a node add form for an administrator.
$this->drupalLogin($this->admin_user);
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php
index 035c083..a1f3a75 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php
@@ -65,6 +65,7 @@ function testPagePostInfo() {
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the post information is displayed.
+ $node = $this->drupalGetNodeByTitle($edit["title"]);
$this->assertNoRaw('', 'Post information is not displayed.');
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php b/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php
index ececc4c..deaab8c 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php
@@ -28,7 +28,7 @@ function testPageView() {
$this->assertTrue(node_load($node->id()), 'Node created.');
// Try to edit with anonymous user.
- $this->drupalGet("node/$node->nid/edit");
+ $html = $this->drupalGet("node/$node->nid/edit");
$this->assertResponse(403);
// Create a user without permission to edit node.
diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php
index 09f9c93..edcf2b1 100644
--- a/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php
@@ -25,7 +25,7 @@ public static function getInfo() {
return array(
'name' => 'Node: Bulk form',
'description' => 'Tests a node bulk form.',
- 'group' => 'Views module integration',
+ 'group' => 'Views Modules',
);
}
diff --git a/core/modules/node/node.install b/core/modules/node/node.install
index 7b42475..84117d5 100644
--- a/core/modules/node/node.install
+++ b/core/modules/node/node.install
@@ -418,8 +418,8 @@ function node_uninstall() {
// Delete node type variables.
$types = config_get_storage_names_with_prefix('node.type.');
foreach ($types as $config_name) {
- $type = Drupal::config($config_name)->get('type');
- Drupal::config('language.settings')->clear('node. ' . $type . '.language.default_configuration')->save();
+ $type = config($config_name)->get('type');
+ config('language.settings')->clear('node. ' . $type . '.language.default_configuration')->save();
}
// Delete node search ranking variables.
@@ -640,7 +640,7 @@ function node_update_8007() {
$language_show = update_variable_get('node_type_language_show_' . $type, NULL);
if (isset($language_default) || isset($language_show)) {
$values = array('langcode' => $language_default, 'language_show' => $language_show);
- Drupal::config('language.settings')->set('node.' . $type . '.language.default_configuration', $values)->save();
+ config('language.settings')->set('node.' . $type . '.language.default_configuration', $values)->save();
}
}
}
@@ -1076,7 +1076,7 @@ function node_update_8020() {
$result = db_query('SELECT * FROM {node_type}')
->fetchAllAssoc('type', PDO::FETCH_ASSOC);
foreach ($result as $id => $node_type) {
- $config = Drupal::config('node.type.' . $id);
+ $config = config('node.type.' . $id);
// Node type.
$config->setData($node_type);
$config->set('uuid', $uuid->generate());
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 200c6f6..26f11a2 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -329,7 +329,7 @@ function node_type_get_names() {
$config_names = config_get_storage_names_with_prefix('node.type.');
$names = array();
foreach ($config_names as $config_name) {
- $config = Drupal::config($config_name);
+ $config = config($config_name);
$names[$config->get('type')] = $config->get('name');
}
cache()->set($cid, $names, CacheBackendInterface::CACHE_PERMANENT, array(
@@ -807,7 +807,7 @@ function node_permission() {
);
// Generate standard node permissions for all applicable node types.
- foreach (node_permissions_get_configured_types() as $type) {
+ foreach (node_permissions_get_configured_types() as $name => $type) {
$perms += node_list_permissions($type);
}
@@ -1489,7 +1489,7 @@ function node_modules_uninstalled($modules) {
// Remove module-specific settings from all node types.
$config_names = config_get_storage_names_with_prefix('node.type.');
foreach ($config_names as $config_name) {
- $config = Drupal::config($config_name);
+ $config = config($config_name);
$changed = FALSE;
foreach ($modules as $module) {
if ($config->get('settings.' . $module)) {
@@ -1572,7 +1572,7 @@ function node_block_access($block) {
function node_feed($nids = FALSE, $channel = array()) {
global $base_url;
$language_content = language(Language::TYPE_CONTENT);
- $rss_config = Drupal::config('system.rss');
+ $rss_config = config('system.rss');
if ($nids === FALSE) {
$nids = db_select('node_field_data', 'n')
@@ -1624,7 +1624,7 @@ function node_feed($nids = FALSE, $channel = array()) {
$channel_defaults = array(
'version' => '2.0',
- 'title' => Drupal::config('system.site')->get('name'),
+ 'title' => config('system.site')->get('name'),
'link' => $base_url,
'description' => $rss_config->get('channel.description'),
'language' => $language_content->id
@@ -1711,7 +1711,7 @@ function node_page_view(EntityInterface $node) {
* Implements hook_update_index().
*/
function node_update_index() {
- $limit = (int) Drupal::config('search.settings')->get('index.cron_limit');
+ $limit = (int) config('search.settings')->get('index.cron_limit');
$result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array('target' => 'slave'));
$nids = $result->fetchCol();
@@ -1914,9 +1914,9 @@ function node_form_system_site_information_settings_form_alter(&$form, &$form_st
$form['front_page']['default_nodes_main'] = array(
'#type' => 'select',
'#title' => t('Number of posts on front page'),
- '#default_value' => Drupal::config('node.settings')->get('items_per_page'),
+ '#default_value' => config('node.settings')->get('items_per_page'),
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
- '#access' => (Drupal::config('system.site')->get('page.front') == 'node'),
+ '#access' => (config('system.site')->get('page.front') == 'node'),
'#description' => t('The maximum number of posts displayed on overview pages such as the front page.'),
);
$form['#submit'][] = 'node_form_system_site_information_settings_form_submit';
@@ -1928,7 +1928,7 @@ function node_form_system_site_information_settings_form_alter(&$form, &$form_st
* @see node_form_system_site_information_settings_form_alter()
*/
function node_form_system_site_information_settings_form_submit($form, &$form_state) {
- Drupal::config('node.settings')
+ config('node.settings')
->set('items_per_page', $form_state['values']['default_nodes_main'])
->save();
}
@@ -2264,6 +2264,9 @@ function node_query_node_access_alter(AlterableInterface $query) {
if (!$op = $query->getMetaData('op')) {
$op = 'view';
}
+ if (!$langcode = $query->getMetaData('langcode')) {
+ $langcode = FALSE;
+ }
// If $account can bypass node access, or there are no node access modules,
// or the operation is 'view' and the $account has a global view grant
@@ -2606,6 +2609,6 @@ function node_library_info() {
*/
function node_system_info_alter(&$info, $file, $type) {
if ($type == 'module' && $file->name == 'translation') {
- $info['hidden'] = !module_exists('translation') && Drupal::config('system.module.disabled')->get('translation') === NULL;
+ $info['hidden'] = !module_exists('translation') && config('system.module.disabled')->get('translation') === NULL;
}
}
diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc
index 48ad45f..e66e10c 100644
--- a/core/modules/node/node.pages.inc
+++ b/core/modules/node/node.pages.inc
@@ -53,6 +53,7 @@ function node_add_page() {
*/
function theme_node_add_list($variables) {
$content = $variables['content'];
+ $output = '';
if ($content) {
$output = '';
@@ -210,6 +211,7 @@ function node_revision_overview($node) {
}
foreach ($revisions as $revision) {
$row = array();
+ $type = $node->type;
if ($revision->current_vid > 0) {
$username = array(
'#theme' => 'username',
diff --git a/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php b/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php
deleted file mode 100644
index 56b750d..0000000
--- a/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php
+++ /dev/null
@@ -1,69 +0,0 @@
- 'Node: Bulk form',
- 'description' => 'Tests the node bulk form plugin.',
- 'group' => 'Views module integration',
- );
- }
-
- /**
- * Tests the constructor assignment of actions.
- */
- public function testConstructor() {
- $actions = array();
-
- for ($i = 1; $i <= 2; $i++) {
- $action = $this->getMockBuilder('Drupal\system\Plugin\Core\Entity\Action')
- ->disableOriginalConstructor()
- ->getMock();
- $action->expects($this->any())
- ->method('getType')
- ->will($this->returnValue('node'));
- $actions[$i] = $action;
- }
-
- $action = $this->getMockBuilder('Drupal\system\Plugin\Core\Entity\Action')
- ->disableOriginalConstructor()
- ->getMock();
- $action->expects($this->any())
- ->method('getType')
- ->will($this->returnValue('user'));
- $actions[] = $action;
-
- $entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManager')
- ->disableOriginalConstructor()
- ->getMock();
- $storage_controller = $this->getMock('Drupal\Core\Entity\EntityStorageControllerInterface');
- $storage_controller->expects($this->any())
- ->method('loadMultiple')
- ->will($this->returnValue($actions));
-
- $entity_manager->expects($this->any())
- ->method('getStorageController')
- ->with('action')
- ->will($this->returnValue($storage_controller));
- $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', array(), $entity_manager);
-
- $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form);
- }
-
-}
diff --git a/core/modules/number/lib/Drupal/number/Plugin/field/field_type/DecimalItem.php b/core/modules/number/lib/Drupal/number/Plugin/field/field_type/DecimalItem.php
index 9271899..f6755e7 100644
--- a/core/modules/number/lib/Drupal/number/Plugin/field/field_type/DecimalItem.php
+++ b/core/modules/number/lib/Drupal/number/Plugin/field/field_type/DecimalItem.php
@@ -9,7 +9,7 @@
use Drupal\Core\Entity\Annotation\FieldType;
use Drupal\Core\Annotation\Translation;
-use Drupal\field\FieldInterface;
+use Drupal\field\Plugin\Core\Entity\Field;
use Drupal\Component\Utility\MapArray;
/**
@@ -51,7 +51,7 @@ public function getPropertyDefinitions() {
/**
* {@inheritdoc}
*/
- public static function schema(FieldInterface $field) {
+ public static function schema(Field $field) {
return array(
'columns' => array(
'value' => array(
@@ -67,9 +67,10 @@ public static function schema(FieldInterface $field) {
/**
* {@inheritdoc}
*/
- public function settingsForm(array $form, array &$form_state, $has_data) {
+ public function settingsForm(array $form, array &$form_state) {
$element = array();
$settings = $this->getFieldSettings();
+ $has_data = $this->getInstance()->getField()->hasData();
$element['precision'] = array(
'#type' => 'select',
diff --git a/core/modules/number/lib/Drupal/number/Plugin/field/field_type/FloatItem.php b/core/modules/number/lib/Drupal/number/Plugin/field/field_type/FloatItem.php
index 7a9850b..98bd97c 100644
--- a/core/modules/number/lib/Drupal/number/Plugin/field/field_type/FloatItem.php
+++ b/core/modules/number/lib/Drupal/number/Plugin/field/field_type/FloatItem.php
@@ -9,7 +9,7 @@
use Drupal\Core\Entity\Annotation\FieldType;
use Drupal\Core\Annotation\Translation;
-use Drupal\field\FieldInterface;
+use Drupal\field\Plugin\Core\Entity\Field;
/**
* Plugin implementation of the 'number_float' field type.
@@ -46,7 +46,7 @@ public function getPropertyDefinitions() {
/**
* {@inheritdoc}
*/
- public static function schema(FieldInterface $field) {
+ public static function schema(Field $field) {
return array(
'columns' => array(
'value' => array(
diff --git a/core/modules/number/lib/Drupal/number/Plugin/field/field_type/IntegerItem.php b/core/modules/number/lib/Drupal/number/Plugin/field/field_type/IntegerItem.php
index e7087bd..3c43df6 100644
--- a/core/modules/number/lib/Drupal/number/Plugin/field/field_type/IntegerItem.php
+++ b/core/modules/number/lib/Drupal/number/Plugin/field/field_type/IntegerItem.php
@@ -9,7 +9,7 @@
use Drupal\Core\Entity\Annotation\FieldType;
use Drupal\Core\Annotation\Translation;
-use Drupal\field\FieldInterface;
+use Drupal\field\Plugin\Core\Entity\Field;
/**
* Plugin implementation of the 'number_integer' field type.
@@ -46,7 +46,7 @@ public function getPropertyDefinitions() {
/**
* {@inheritdoc}
*/
- public static function schema(FieldInterface $field) {
+ public static function schema(Field $field) {
return array(
'columns' => array(
'value' => array(
diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module
index 52edcf8..2edb256 100644
--- a/core/modules/overlay/overlay.module
+++ b/core/modules/overlay/overlay.module
@@ -501,13 +501,13 @@ function overlay_overlay_parent_initialize() {
// Let the client side know which paths are administrative.
$paths = path_get_admin_paths();
foreach ($paths as &$type) {
- $type = str_replace('', Drupal::config('system.site')->get('page.front'), $type);
+ $type = str_replace('', config('system.site')->get('page.front'), $type);
}
drupal_add_js(array('overlay' => array('paths' => $paths)), 'setting');
$path_prefixes = array();
if (module_exists('language')) {
language_negotiation_include();
- if (Drupal::config('language.negotiation')->get('url.source') == LANGUAGE_NEGOTIATION_URL_PREFIX) {
+ if (config('language.negotiation')->get('url.source') == LANGUAGE_NEGOTIATION_URL_PREFIX) {
// Skip the empty string indicating the default language. We always accept
// paths without a prefix.
$path_prefixes = language_negotiation_url_prefixes();
diff --git a/core/modules/php/lib/Drupal/php/Plugin/Filter/Php.php b/core/modules/php/lib/Drupal/php/Plugin/Filter/Php.php
index 53b7a5e..88353ba 100644
--- a/core/modules/php/lib/Drupal/php/Plugin/Filter/Php.php
+++ b/core/modules/php/lib/Drupal/php/Plugin/Filter/Php.php
@@ -36,6 +36,7 @@ public function process($text, $langcode, $cache, $cache_id) {
* {@inheritdoc}
*/
public function tips($long = FALSE) {
+ global $base_url;
if ($long) {
$output = '' . t('Using custom PHP code') . '
';
$output .= '' . t('Custom PHP code may be embedded in some types of site content, including posts and blocks. While embedding PHP code inside a post or block is a powerful and flexible feature when used by a trusted user with PHP experience, it is a significant and dangerous security risk when used improperly. Even a small mistake when posting PHP code may accidentally compromise your site.') . '
';
diff --git a/core/modules/php/php.module b/core/modules/php/php.module
index 9baffe7..02fd1dd 100644
--- a/core/modules/php/php.module
+++ b/core/modules/php/php.module
@@ -70,7 +70,7 @@ function php_eval($code) {
// so code evaluated will not see the caller module as the current theme.
// If theme info is not initialized get the path from default theme.
if (!isset($theme_info)) {
- $theme_path = drupal_get_path('theme', Drupal::config('system.theme')->get('default'));
+ $theme_path = drupal_get_path('theme', config('system.theme')->get('default'));
}
else {
$theme_path = dirname($theme_info->filename);
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php
deleted file mode 100644
index af2aeb9..0000000
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php
+++ /dev/null
@@ -1,100 +0,0 @@
-entity, $this->fieldName, array('type' => $formatter));
- $rendered = "" . drupal_render($build) . '';
- $graph = new \EasyRdf_Graph($this->uri, $rendered, 'rdfa');
-
- $expected_value = array(
- 'type' => $object_type,
- 'value' => $value,
- );
- $this->assertTrue($graph->hasProperty($this->uri, $property, $expected_value), "Formatter $formatter exposes data correctly for {$this->fieldType} fields.");
- }
-
- /**
- * Creates the field for testing.
- */
- protected function createTestField() {
- entity_create('field_entity', array(
- 'field_name' => $this->fieldName,
- 'type' => $this->fieldType,
- ))->save();
- entity_create('field_instance', array(
- 'entity_type' => 'entity_test',
- 'field_name' => $this->fieldName,
- 'bundle' => 'entity_test',
- ))->save();
- }
-
- /**
- * Gets the absolute URI of an entity.
- *
- * @param \Drupal\Core\Entity\EntityNG $entity
- * The entity for which to generate the URI.
- *
- * @return string
- * The absolute URI.
- */
- protected function getAbsoluteUri($entity) {
- $uri_info = $entity->uri();
- return url($uri_info['path'], array('absolute' => TRUE));
- }
-}
diff --git a/core/modules/rdf/rdf.install b/core/modules/rdf/rdf.install
index 117c910..5bb8f67 100644
--- a/core/modules/rdf/rdf.install
+++ b/core/modules/rdf/rdf.install
@@ -23,7 +23,7 @@ function rdf_update_8000() {
$bundle = $row['bundle'];
// Create a config object for the mapping.
- $config = Drupal::config("rdf.mapping.$entity_type.$bundle")
+ $config = config("rdf.mapping.$entity_type.$bundle")
->set('id', "$entity_type.$bundle")
->set('uuid', $uuid->generate())
->set('targetEntityType', $entity_type)
diff --git a/core/modules/rest/config/rest.settings.yml b/core/modules/rest/config/rest.settings.yml
index 91c9a7b..2780a6d 100644
--- a/core/modules/rest/config/rest.settings.yml
+++ b/core/modules/rest/config/rest.settings.yml
@@ -14,13 +14,3 @@ resources:
# GET:
# supported_formats:
# - json
-#
-# To enable only specific authentication methods for an operation, list them
-# at supported_auth.
-# For example, the following config only allows Basic HTTP authenticated
-# requests for the POST method on the node entity.
-# resources:
-# entity:node:
-# POST:
-# supported_auth:
-# - http_basic
diff --git a/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php b/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php
index 4b9f9fb..b1bcb7c 100644
--- a/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php
+++ b/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php
@@ -72,11 +72,6 @@ public function dynamicRoutes(RouteBuildEvent $event) {
$collection->add("rest.$name", $route);
continue;
}
- // Check if there are authentication provider restrictions in the
- // configuration and apply them to the route.
- if (is_array($enabled_methods[$method]['supported_auth']) && !empty($enabled_methods[$method]['supported_auth'])) {
- $route->setOption('_auth', $enabled_methods[$method]['supported_auth']);
- }
// If there is no format requirement or if it matches the
// configuration also add the route.
$format_requirement = $route->getRequirement('_format');
diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php b/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php
index b829c7c..e851352 100644
--- a/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php
+++ b/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php
@@ -8,51 +8,13 @@
namespace Drupal\rest\Plugin;
use Drupal\Component\Plugin\PluginBase;
-use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
-use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
/**
* Common base class for resource plugins.
*/
-abstract class ResourceBase extends PluginBase implements ContainerFactoryPluginInterface, ResourceInterface {
-
- /**
- * The available serialization formats.
- *
- * @var array
- */
- protected $serializerFormats = array();
-
- /**
- * Constructs a Drupal\rest\Plugin\ResourceBase object.
- *
- * @param array $configuration
- * A configuration array containing information about the plugin instance.
- * @param string $plugin_id
- * The plugin_id for the plugin instance.
- * @param array $plugin_definition
- * The plugin implementation definition.
- * @param array $serializer_formats
- * The available serialization formats.
- */
- public function __construct(array $configuration, $plugin_id, array $plugin_definition, array $serializer_formats) {
- parent::__construct($configuration, $plugin_id, $plugin_definition);
- $this->serializerFormats = $serializer_formats;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->getParameter('serializer.formats')
- );
- }
+abstract class ResourceBase extends PluginBase implements ResourceInterface {
/**
* Implements ResourceInterface::permissions().
@@ -106,7 +68,8 @@ public function routes() {
case 'HEAD':
// Restrict GET and HEAD requests to the media type specified in the
// HTTP Accept headers.
- foreach ($this->serializerFormats as $format_name) {
+ $formats = drupal_container()->getParameter('serializer.formats');
+ foreach ($formats as $format_name) {
// Expose one route per available format.
//$format_route = new Route($route->getPattern(), $route->getDefaults(), $route->getRequirements());
$format_route = clone $route;
@@ -161,5 +124,4 @@ public function availableMethods() {
}
return $available;
}
-
}
diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php b/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php
index 0ad6b0f..6020634 100644
--- a/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php
+++ b/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php
@@ -7,35 +7,33 @@
namespace Drupal\rest\Plugin\Type;
-use Drupal\Core\Cache\CacheBackendInterface;
-use Drupal\Core\Extension\ModuleHandlerInterface;
-use Drupal\Core\Language\LanguageManager;
-use Drupal\Core\Plugin\DefaultPluginManager;
+use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
+use Drupal\Component\Plugin\Factory\ReflectionFactory;
+use Drupal\Component\Plugin\PluginManagerBase;
+use Drupal\Core\Plugin\Discovery\AlterDecorator;
+use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
/**
* Manages discovery and instantiation of resource plugins.
*/
-class ResourcePluginManager extends DefaultPluginManager {
+class ResourcePluginManager extends PluginManagerBase {
/**
- * Constructs a new \Drupal\rest\Plugin\Type\ResourcePluginManager object.
+ * Overrides Drupal\Component\Plugin\PluginManagerBase::__construct().
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
- * keyed by the corresponding namespace to look for plugin implementations.
- * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
- * Cache backend instance to use.
- * @param \Drupal\Core\Language\LanguageManager $language_manager
- * The language manager.
- * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
- * The module handler to invoke the alter hook with.
+ * keyed by the corresponding namespace to look for plugin implementations,
*/
- public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) {
- parent::__construct('Plugin/rest/resource', $namespaces);
+ public function __construct(\Traversable $namespaces) {
+ // Create resource plugin derivatives from declaratively defined resources.
+ $this->discovery = new AnnotatedClassDiscovery('Plugin/rest/resource', $namespaces);
+ $this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
+ $this->discovery = new AlterDecorator($this->discovery, 'rest_resource');
+ $this->discovery = new CacheDecorator($this->discovery, 'rest');
- $this->setCacheBackend($cache_backend, $language_manager, 'rest_plugins');
- $this->alterInfo($module_handler, 'rest_resource');
+ $this->factory = new ReflectionFactory($this->discovery);
}
/**
diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php
index 33a7e6b..694a422 100644
--- a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php
+++ b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php
@@ -9,11 +9,8 @@
use Drupal\Component\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
-use Drupal\Core\ContentNegotiation;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\PathPluginBase;
-use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\RouteCollection;
@@ -73,59 +70,16 @@ class RestExport extends PathPluginBase {
protected $mimeType;
/**
- * The content negotiation library.
- *
- * @var \Drupal\Core\ContentNegotiation
- */
- protected $contentNegotiation;
-
- /**
- * The request object.
- *
- * @var \Symfony\Component\HttpFoundation\Request
- */
- protected $request;
-
- /**
- * Constructs a Drupal\rest\Plugin\ResourceBase object.
- *
- * @param array $configuration
- * A configuration array containing information about the plugin instance.
- * @param string $plugin_id
- * The plugin_id for the plugin instance.
- * @param array $plugin_definition
- * The plugin implementation definition.
- * @param \Drupal\Core\ContentNegotiation $content_negotiation
- * The content negotiation library.
- * @param \Symfony\Component\HttpFoundation\Request $request
- * The request object.
- */
- public function __construct(array $configuration, $plugin_id, array $plugin_definition, ContentNegotiation $content_negotiation, Request $request) {
- parent::__construct($configuration, $plugin_id, $plugin_definition);
- $this->contentNegotiation = $content_negotiation;
- $this->request = $request;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->get('content_negotiation'),
- $container->get('request')
- );
- }
-
- /**
* {@inheritdoc}
*/
public function initDisplay(ViewExecutable $view, array &$display, array &$options = NULL) {
parent::initDisplay($view, $display, $options);
- $request_content_type = $this->contentNegotiation->getContentType($this->request);
+ $container = drupal_container();
+ $negotiation = $container->get('content_negotiation');
+ $request = $container->get('request');
+
+ $request_content_type = $negotiation->getContentType($request);
// Only use the requested content type if it's not 'html'. If it is then
// default to 'json' to aid debugging.
// @todo Remove the need for this when we have better content negotiation.
@@ -133,7 +87,7 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
$this->setContentType($request_content_type);
}
- $this->setMimeType($this->request->getMimeType($this->contentType));
+ $this->setMimeType($request->getMimeType($this->contentType));
}
/**
diff --git a/core/modules/rest/lib/Drupal/rest/Tests/AuthTest.php b/core/modules/rest/lib/Drupal/rest/Tests/AuthTest.php
deleted file mode 100644
index 6e637c4..0000000
--- a/core/modules/rest/lib/Drupal/rest/Tests/AuthTest.php
+++ /dev/null
@@ -1,107 +0,0 @@
- 'Resource authentication',
- 'description' => 'Tests authentication provider restrictions.',
- 'group' => 'REST',
- );
- }
-
- /**
- * Tests reading from an authenticated resource.
- */
- public function testRead() {
- $entity_type = 'entity_test';
-
- // Enable a test resource through GET method and basic HTTP authentication.
- $this->enableService('entity:' . $entity_type, 'GET', NULL, array('http_basic'));
-
- // Create an entity programmatically.
- $entity = $this->entityCreate($entity_type);
- $entity->save();
-
- // Try to read the resource as an anonymous user, which should not work.
- $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, $this->defaultMimeType);
- $this->assertResponse('401', 'HTTP response code is 401 when the request is not authenticated and the user is anonymous.');
- $this->assertText('A fatal error occurred: No authentication credentials provided.');
-
- // Create a user account that has the required permissions to read
- // resources via the REST API, but the request is authenticated
- // with session cookies.
- $permissions = $this->entityPermissions($entity_type, 'view');
- $permissions[] = 'restful get entity:' . $entity_type;
- $account = $this->drupalCreateUser($permissions);
- $this->drupalLogin($account);
-
- // Try to read the resource with session cookie authentication, which is
- // not enabled and should not work.
- $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, $this->defaultMimeType);
- $this->assertResponse('403', 'HTTP response code is 403 when the request is authenticated but not authorized.');
- $this->drupalLogout();
-
- // Now read it with the Basic authentication which is enabled and should
- // work.
- $response = $this->basicAuthGet('entity/' . $entity_type . '/' . $entity->id(), $account->getUsername(), $account->pass_raw);
- $this->assertResponse('200', 'HTTP response code is 200 for successfuly authorized requests.');
- $this->curlClose();
- }
-
- /**
- * Performs a HTTP request with Basic authentication.
- *
- * We do not use \Drupal\simpletest\WebTestBase::drupalGet because we need to
- * set curl settings for basic authentication.
- *
- * @param string $path
- * The request path.
- * @param string $username
- * The user name to authenticate with.
- * @param string $password
- * The password.
- *
- * @return string
- * Curl output.
- */
- protected function basicAuthGet($path, $username, $password) {
- $out = $this->curlExec(
- array(
- CURLOPT_HTTPGET => TRUE,
- CURLOPT_URL => url($path, array('absolute' => TRUE)),
- CURLOPT_NOBODY => FALSE,
- CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
- CURLOPT_USERPWD => $username . ':' . $password,
- )
- );
-
- $this->verbose('GET request to: ' . $path .
- '
' . $out);
-
- return $out;
- }
-
-}
diff --git a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php
index 0a75cb3..00ca7e5 100644
--- a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php
+++ b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php
@@ -33,7 +33,7 @@ public static function getInfo() {
* Tests several valid and invalid create requests on all entity types.
*/
public function testCreate() {
- $serializer = $this->container->get('serializer');
+ $serializer = drupal_container()->get('serializer');
$entity_types = array('entity_test', 'node');
foreach ($entity_types as $entity_type) {
diff --git a/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php b/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php
index db8feb2..6ad9000 100644
--- a/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php
+++ b/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php
@@ -192,12 +192,10 @@ protected function entityValues($entity_type) {
* The HTTP method to enable, e.g. GET, POST etc.
* @param string $format
* (Optional) The serialization format, e.g. hal_json.
- * @param array $auth
- * (Optional) The list of valid authentication methods.
*/
- protected function enableService($resource_type, $method = 'GET', $format = NULL, $auth = array()) {
+ protected function enableService($resource_type, $method = 'GET', $format = NULL) {
// Enable REST API for this entity type.
- $config = \Drupal::config('rest.settings');
+ $config = config('rest.settings');
$settings = array();
if ($resource_type) {
if ($format) {
@@ -207,15 +205,11 @@ protected function enableService($resource_type, $method = 'GET', $format = NULL
$settings[$resource_type][$method] = array();
}
}
- if (is_array($auth) && !empty($auth)) {
- $settings[$resource_type][$method]['supported_auth'] = $auth;
- }
-
$config->set('resources', $settings);
$config->save();
// Rebuild routing cache, so that the REST API paths are available.
- $this->container->get('router.builder')->rebuild();
+ drupal_container()->get('router.builder')->rebuild();
// Reset the Simpletest permission cache, so that the new resource
// permissions get picked up.
drupal_static_reset('checkPermissions');
diff --git a/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php
index b417f2a..0c17d6e 100644
--- a/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php
+++ b/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php
@@ -33,7 +33,7 @@ public static function getInfo() {
* Tests several valid and invalid partial update requests on test entities.
*/
public function testPatchUpdate() {
- $serializer = $this->container->get('serializer');
+ $serializer = drupal_container()->get('serializer');
// @todo once EntityNG is implemented for other entity types test all other
// entity types here as well.
$entity_type = 'entity_test';
diff --git a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php
index 48bf955..332310e 100644
--- a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php
+++ b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php
@@ -109,7 +109,7 @@ public function testSerializerResponses() {
$this->executeView($view);
// Get the serializer service.
- $serializer = $this->container->get('serializer');
+ $serializer = drupal_container()->get('serializer');
$entities = array();
foreach ($view->result as $row) {
diff --git a/core/modules/rest/rest.module b/core/modules/rest/rest.module
index a37bfe7..9fe2674 100644
--- a/core/modules/rest/rest.module
+++ b/core/modules/rest/rest.module
@@ -10,12 +10,14 @@
*/
function rest_permission() {
$permissions = array();
- $manager = Drupal::service('plugin.manager.rest');
- $resources = Drupal::config('rest.settings')->get('resources');
- if ($resources && $enabled = array_intersect_key($manager->getDefinitions(), $resources)) {
- foreach ($enabled as $key => $resource) {
- $plugin = $manager->getInstance(array('id' => $key));
- $permissions = array_merge($permissions, $plugin->permissions());
+ if (drupal_container()->has('plugin.manager.rest')) {
+ $manager = drupal_container()->get('plugin.manager.rest');
+ $resources = config('rest.settings')->get('resources');
+ if ($resources && $enabled = array_intersect_key($manager->getDefinitions(), $resources)) {
+ foreach ($enabled as $key => $resource) {
+ $plugin = $manager->getInstance(array('id' => $key));
+ $permissions = array_merge($permissions, $plugin->permissions());
+ }
}
}
return $permissions;
diff --git a/core/modules/rest/rest.services.yml b/core/modules/rest/rest.services.yml
index d238442..97817ad 100644
--- a/core/modules/rest/rest.services.yml
+++ b/core/modules/rest/rest.services.yml
@@ -1,14 +1,7 @@
services:
plugin.manager.rest:
class: Drupal\rest\Plugin\Type\ResourcePluginManager
- arguments: ['@container.namespaces', '@cache.rest', '@language_manager', '@module_handler']
- cache.rest:
- class: Drupal\Core\Cache\CacheBackendInterface
- tags:
- - { name: cache.bin }
- factory_method: get
- factory_service: cache_factory
- arguments: [rest]
+ arguments: ['@container.namespaces']
rest.route_subscriber:
class: Drupal\rest\EventSubscriber\RouteSubscriber
tags:
diff --git a/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php b/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php
deleted file mode 100644
index 8d0985a..0000000
--- a/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php
+++ /dev/null
@@ -1,90 +0,0 @@
-request = $request;
-
- $form['search_block_form'] = array(
- '#type' => 'search',
- '#title' => t('Search'),
- '#title_display' => 'invisible',
- '#size' => 15,
- '#default_value' => '',
- '#attributes' => array('title' => t('Enter the terms you wish to search for.')),
- );
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
-
- return $form;
- }
-
- /**
- * {@inheritdoc}
- */
- public function validateForm(array &$form, array &$form_state) {
- // No validation necessary at this time.
- }
-
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, array &$form_state) {
- // The search form relies on control of the redirect destination for its
- // functionality, so we override any static destination set in the request.
- // See http://drupal.org/node/292565.
- if ($this->request->query->has('destination')) {
- $this->request->query->remove('destination');
- }
-
- // Check to see if the form was submitted empty.
- // If it is empty, display an error message.
- // (This method is used instead of setting #required to TRUE for this field
- // because that results in a confusing error message. It would say a plain
- // "field is required" because the search keywords field has no title.
- // The error message would also complain about a missing #title field.)
- if ($form_state['values']['search_block_form'] == '') {
- form_set_error('keys', t('Please enter some keywords.'));
- }
-
- $form_id = $form['form_id']['#value'];
- $info = search_get_default_module_info();
- if ($info) {
- $form_state['redirect'] = 'search/' . $info['path'] . '/' . trim($form_state['values'][$form_id]);
- }
- else {
- form_set_error(NULL, t('Search is currently disabled.'), 'error');
- }
- }
-}
diff --git a/core/modules/search/lib/Drupal/search/Plugin/Block/SearchBlock.php b/core/modules/search/lib/Drupal/search/Plugin/Block/SearchBlock.php
index b692e5e..00f5b60 100644
--- a/core/modules/search/lib/Drupal/search/Plugin/Block/SearchBlock.php
+++ b/core/modules/search/lib/Drupal/search/Plugin/Block/SearchBlock.php
@@ -10,10 +10,6 @@
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
-use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
-use Drupal\search\Form\SearchBlockForm;
-use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\Request;
/**
* Provides a 'Search form' block.
@@ -24,23 +20,7 @@
* module = "search"
* )
*/
-class SearchBlock extends BlockBase implements ContainerFactoryPluginInterface {
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) {
- return new static($configuration, $plugin_id, $plugin_definition, $container->get('request'));
- }
-
- /**
- * Constructs a SearchBlock object.
- */
- public function __construct(array $configuration, $plugin_id, array $plugin_definition, Request $request) {
- parent::__construct($configuration, $plugin_id, $plugin_definition);
-
- $this->request = $request;
- }
+class SearchBlock extends BlockBase {
/**
* Overrides \Drupal\block\BlockBase::access().
@@ -53,7 +33,7 @@ public function access() {
* {@inheritdoc}
*/
public function build() {
- // Pass the current request to drupal_get_form for use in the buildForm.
- return drupal_get_form(new SearchBlockForm(), $this->request);
+ return array(drupal_get_form('search_block_form'));
}
+
}
diff --git a/core/modules/search/lib/Drupal/search/Plugin/views/field/Score.php b/core/modules/search/lib/Drupal/search/Plugin/views/field/Score.php
index e6646d1..9293694 100644
--- a/core/modules/search/lib/Drupal/search/Plugin/views/field/Score.php
+++ b/core/modules/search/lib/Drupal/search/Plugin/views/field/Score.php
@@ -9,7 +9,6 @@
use Drupal\views\Plugin\views\field\Numeric;
use Drupal\Component\Annotation\PluginID;
-use Drupal\views\ResultRow;
/**
* Field handler to provide simple renderer that allows linking to a node.
@@ -81,10 +80,7 @@ public function query() {
}
}
- /**
- * {@inheritdoc}
- */
- public function render(ResultRow $values) {
+ public function render($values) {
// Only render if we exist.
if (isset($this->tableAlias)) {
return parent::render($values);
diff --git a/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php b/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php
index 89b21e4..7461bdd 100644
--- a/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php
+++ b/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php
@@ -85,7 +85,7 @@ public function validateExposed(&$form, &$form_state) {
if (!empty($form_state['values'][$key])) {
$this->query_parse_search_expression($form_state['values'][$key]);
if (count($this->search_query->words()) == 0) {
- form_set_error($key, format_plural(\Drupal::config('search.settings')->get('index.minimum_word_size'), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
+ form_set_error($key, format_plural(config('search.settings')->get('index.minimum_word_size'), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
}
}
}
diff --git a/core/modules/search/lib/Drupal/search/SearchQuery.php b/core/modules/search/lib/Drupal/search/SearchQuery.php
index 8776bce..86887b7 100644
--- a/core/modules/search/lib/Drupal/search/SearchQuery.php
+++ b/core/modules/search/lib/Drupal/search/SearchQuery.php
@@ -200,7 +200,7 @@ protected function parseSearchExpression() {
// Classify tokens.
$or = FALSE;
$warning = '';
- $limit_combinations = \Drupal::config('search.settings')->get('and_or_limit');
+ $limit_combinations = config('search.settings')->get('and_or_limit');
// The first search expression does not count as AND.
$and_count = -1;
$or_count = 0;
@@ -323,7 +323,7 @@ protected function parseWord($word) {
$split = explode(' ', $word);
foreach ($split as $s) {
$num = is_numeric($s);
- if ($num || drupal_strlen($s) >= \Drupal::config('search.settings')->get('index.minimum_word_size')) {
+ if ($num || drupal_strlen($s) >= config('search.settings')->get('index.minimum_word_size')) {
if (!isset($this->words[$s])) {
$this->words[$s] = $s;
$num_new_scores++;
@@ -349,11 +349,11 @@ public function executeFirstPass() {
$this->parseSearchExpression();
if (count($this->words) == 0) {
- form_set_error('keys', format_plural(\Drupal::config('search.settings')->get('index.minimum_word_size'), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
+ form_set_error('keys', format_plural(config('search.settings')->get('index.minimum_word_size'), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
return FALSE;
}
if ($this->expressionsIgnored) {
- drupal_set_message(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => \Drupal::config('search.settings')->get('and_or_limit'))), 'warning');
+ drupal_set_message(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => config('search.settings')->get('and_or_limit'))), 'warning');
}
$this->executedFirstPass = TRUE;
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchEmbedFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchEmbedFormTest.php
index 4659260..ff822c6 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchEmbedFormTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchEmbedFormTest.php
@@ -50,7 +50,7 @@ function setUp() {
search_update_totals();
// Set up a dummy initial count of times the form has been submitted.
- $this->submit_count = \Drupal::config('search_embedded_form.settings')->get('submitted');
+ $this->submit_count = config('search_embedded_form.settings')->get('submitted');
$this->refreshVariables();
}
@@ -63,7 +63,7 @@ function testEmbeddedForm() {
array('name' => 'John'),
t('Send away'));
$this->assertText(t('Test form was submitted'), 'Form message appears');
- $count = \Drupal::config('search_embedded_form.settings')->get('submitted');
+ $count = config('search_embedded_form.settings')->get('submitted');
$this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct');
$this->submit_count = $count;
@@ -74,7 +74,7 @@ function testEmbeddedForm() {
array('name' => 'John'),
t('Send away'));
$this->assertText(t('Test form was submitted'), 'Form message appears');
- $count = \Drupal::config('search_embedded_form.settings')->get('submitted');
+ $count = config('search_embedded_form.settings')->get('submitted');
$this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct');
$this->submit_count = $count;
@@ -84,7 +84,7 @@ function testEmbeddedForm() {
array('keys' => 'foo'),
t('Search'));
$this->assertNoText(t('Test form was submitted'), 'Form message does not appear');
- $count = \Drupal::config('search_embedded_form.settings')->get('submitted');
+ $count = config('search_embedded_form.settings')->get('submitted');
$this->assertEqual($this->submit_count, $count, 'Form submission count is correct');
$this->submit_count = $count;
}
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php
index ab7a0c9..87414fa 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php
@@ -35,7 +35,7 @@ function setUp() {
// Login with sufficient privileges.
$this->drupalLogin($this->searching_user);
// Test with all search modules enabled.
- \Drupal::config('search.settings')->set('active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type'))->save();
+ config('search.settings')->set('active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type'))->save();
menu_router_rebuild();
}
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php
index 76958c6..0f3d574 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php
@@ -36,7 +36,7 @@ function testMatching() {
* Set up a small index of items to test against.
*/
function _setup() {
- \Drupal::config('search.settings')->set('index.minimum_word_size', 3)->save();
+ config('search.settings')->set('index.minimum_word_size', 3)->save();
for ($i = 1; $i <= 7; ++$i) {
search_index($i, SEARCH_TYPE, $this->getText($i), Language::LANGCODE_NOT_SPECIFIED);
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php
index e1021b4..d9ab415 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php
@@ -93,7 +93,7 @@ function setUp() {
*/
function testIndexingThrottle() {
// Index only 4 items per cron run.
- \Drupal::config('search.settings')->set('index.cron_limit', 4)->save();
+ config('search.settings')->set('index.cron_limit', 4)->save();
// Update the index. This does the initial processing.
node_update_index();
// Run the shutdown function. Testing is a unique case where indexing
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php
index 45bcadf..df72d2b 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php
@@ -37,7 +37,7 @@ function setUp() {
$this->drupalLogin($this->search_user);
// Enable the extra type module for searching.
- \Drupal::config('search.settings')->set('active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type'))->save();
+ config('search.settings')->set('active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type'))->save();
menu_router_rebuild();
}
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php
index 247096c..b9dede6 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php
@@ -60,7 +60,7 @@ function testSearchText() {
// Test a search input exceeding the limit of AND/OR combinations to test
// the Denial-of-Service protection.
- $limit = \Drupal::config('search.settings')->get('and_or_limit');
+ $limit = config('search.settings')->get('and_or_limit');
$keys = array();
for ($i = 0; $i < $limit + 1; $i++) {
$keys[] = $this->randomName(3);
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
index 6e223f6..887e997 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
@@ -78,7 +78,7 @@ function testRankings() {
$this->drupalPost(NULL, $edit, t('Save'));
// Enable counting of statistics.
- \Drupal::config('statistics.settings')->set('count_content_views', 1)->save();
+ config('statistics.settings')->set('count_content_views', 1)->save();
// Then View one of the nodes a bunch of times.
// Manually calling statistics.php, simulating ajax behavior.
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchTokenizerTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchTokenizerTest.php
index 361cebf..8e705d1 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchTokenizerTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchTokenizerTest.php
@@ -30,7 +30,7 @@ public static function getInfo() {
function testTokenizer() {
// Set the minimum word size to 1 (to split all CJK characters) and make
// sure CJK tokenizing is turned on.
- \Drupal::config('search.settings')
+ config('search.settings')
->set('index.minimum_word_size', 1)
->set('index.overlap_cjk', TRUE)
->save();
@@ -118,7 +118,7 @@ function testTokenizer() {
function testNoTokenizer() {
// Set the minimum word size to 1 (to split all CJK characters) and make
// sure CJK tokenizing is turned on.
- \Drupal::config('search.settings')
+ config('search.settings')
->set('minimum_word_size', 1)
->set('overlap_cjk', TRUE)
->save();
diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php
index 649a933..1a343d2 100644
--- a/core/modules/search/search.api.php
+++ b/core/modules/search/search.api.php
@@ -115,7 +115,7 @@ function hook_search_admin() {
// Note: reversed to reflect that higher number = higher ranking.
$options = drupal_map_assoc(range(0, 10));
- $ranks = Drupal::config('node.settings')->get('search_rank');
+ $ranks = config('node.settings')->get('search_rank');
foreach (Drupal::moduleHandler()->invokeAll('ranking') as $var => $values) {
$form['content_ranking']['factors'][$var] = array(
'#title' => $values['title'],
@@ -329,7 +329,7 @@ function hook_search_preprocess($text, $langcode = NULL) {
* When implementing this hook, your module should index content items that
* were modified or added since the last run. PHP has a time limit
* for cron, though, so it is advisable to limit how many items you index
- * per run using Drupal::config('search.settings')->get('index.cron_limit') (see
+ * per run using config('search.settings')->get('index.cron_limit') (see
* example below). Also, since the cron run could time out and abort in the
* middle of your run, you should update your module's internal bookkeeping on
* when items have last been indexed as you go rather than waiting to the end
@@ -338,7 +338,7 @@ function hook_search_preprocess($text, $langcode = NULL) {
* @ingroup search
*/
function hook_update_index() {
- $limit = (int) Drupal::config('search.settings')->get('index.cron_limit');
+ $limit = (int) config('search.settings')->get('index.cron_limit');
$result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit);
@@ -402,7 +402,7 @@ function callback_search_conditions($keys) {
if (!empty($_REQUEST['sample_search_keys'])) {
$conditions['sample_search_keys'] = $_REQUEST['sample_search_keys'];
}
- if ($force_keys = Drupal::config('sample_search.settings')->get('force_keywords')) {
+ if ($force_keys = config('sample_search.settings')->get('force_keywords')) {
$conditions['sample_search_force_keywords'] = $force_keys;
}
return $conditions;
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index fece768..b3f381c 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -252,7 +252,7 @@ function search_get_info($all = FALSE) {
}
// Return only modules that are set to active in search settings.
- return array_intersect_key($search_hooks, array_flip(Drupal::config('search.settings')->get('active_modules')));
+ return array_intersect_key($search_hooks, array_flip(config('search.settings')->get('active_modules')));
}
/**
@@ -263,7 +263,7 @@ function search_get_info($all = FALSE) {
*/
function search_get_default_module_info() {
$info = search_get_info();
- $default = Drupal::config('search.settings')->get('default_module');
+ $default = config('search.settings')->get('default_module');
if (isset($info[$default])) {
return $info[$default];
}
@@ -362,7 +362,7 @@ function search_cron() {
// to date.
drupal_register_shutdown_function('search_update_totals');
- foreach (Drupal::config('search.settings')->get('active_modules') as $module) {
+ foreach (config('search.settings')->get('active_modules') as $module) {
// Update word index
module_invoke($module, 'update_index');
}
@@ -423,7 +423,7 @@ function search_simplify($text, $langcode = NULL) {
search_invoke_preprocess($text, $langcode);
// Simple CJK handling
- if (Drupal::config('search.settings')->get('index.overlap_cjk')) {
+ if (config('search.settings')->get('index.overlap_cjk')) {
$text = preg_replace_callback('/[' . PREG_CLASS_CJK . ']+/u', 'search_expand_cjk', $text);
}
@@ -477,7 +477,7 @@ function search_simplify($text, $langcode = NULL) {
* Tokenized text, starting and ending with a space character.
*/
function search_expand_cjk($matches) {
- $min = Drupal::config('search.settings')->get('index.minimum_word_size');
+ $min = config('search.settings')->get('index.minimum_word_size');
$str = $matches[0];
$length = drupal_strlen($str);
// If the text is shorter than the minimum word size, don't tokenize it.
@@ -558,7 +558,7 @@ function search_invoke_preprocess(&$text, $langcode = NULL) {
* @ingroup search
*/
function search_index($sid, $module, $text, $langcode) {
- $minimum_word_size = Drupal::config('search.settings')->get('index.minimum_word_size');
+ $minimum_word_size = config('search.settings')->get('index.minimum_word_size');
// Link matching
global $base_url;
@@ -567,7 +567,7 @@ function search_index($sid, $module, $text, $langcode) {
// Multipliers for scores of words inside certain HTML tags. The weights are stored
// in a variable so that modules can overwrite the default weights.
// Note: 'a' must be included for link ranking to work.
- $tags = Drupal::config('search.settings')->get('index.tag_weights');
+ $tags = config('search.settings')->get('index.tag_weights');
// Strip off all ignored tags to speed up processing, but insert space before/after
// them to keep word boundaries.
@@ -991,6 +991,63 @@ function search_form($form, &$form_state, $action = '', $keys = '', $module = NU
}
/**
+ * Form constructor for the search block's search box.
+ *
+ * @param $form_id
+ * The unique string identifying the desired form.
+ *
+ * @see search_box_form_submit()
+ *
+ * @ingroup forms
+ */
+function search_box($form, &$form_state, $form_id) {
+ $form[$form_id] = array(
+ '#type' => 'search',
+ '#title' => t('Search'),
+ '#title_display' => 'invisible',
+ '#size' => 15,
+ '#default_value' => '',
+ '#attributes' => array('title' => t('Enter the terms you wish to search for.')),
+ );
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
+ $form['#submit'][] = 'search_box_form_submit';
+
+ return $form;
+}
+
+/**
+ * Form submission handler for search_box().
+ */
+function search_box_form_submit($form, &$form_state) {
+ // The search form relies on control of the redirect destination for its
+ // functionality, so we override any static destination set in the request.
+ // See http://drupal.org/node/292565.
+ if (isset($_GET['destination'])) {
+ unset($_GET['destination']);
+ }
+
+ // Check to see if the form was submitted empty.
+ // If it is empty, display an error message.
+ // (This method is used instead of setting #required to TRUE for this field
+ // because that results in a confusing error message. It would say a plain
+ // "field is required" because the search keywords field has no title.
+ // The error message would also complain about a missing #title field.)
+ if ($form_state['values']['search_block_form'] == '') {
+ form_set_error('keys', t('Please enter some keywords.'));
+ }
+
+ $form_id = $form['form_id']['#value'];
+ $info = search_get_default_module_info();
+ if ($info) {
+ $form_state['redirect'] = 'search/' . $info['path'] . '/' . trim($form_state['values'][$form_id]);
+ }
+ else {
+ form_set_error(NULL, t('Search is currently disabled.'), 'error');
+ }
+}
+
+/**
* Performs a search by calling hook_search_execute().
*
* @param $keys
@@ -1250,3 +1307,14 @@ function search_simplify_excerpt_match($key, $text, $offset, $boundary, $langcod
function _search_excerpt_match_filter($var) {
return strlen(trim($var[0]));
}
+
+/**
+ * Implements hook_forms().
+ */
+function search_forms() {
+ $forms['search_block_form']= array(
+ 'callback' => 'search_box',
+ 'callback arguments' => array('search_block_form'),
+ );
+ return $forms;
+}
diff --git a/core/modules/search/tests/modules/search_embedded_form/search_embedded_form.module b/core/modules/search/tests/modules/search_embedded_form/search_embedded_form.module
index d59f184..919d228 100644
--- a/core/modules/search/tests/modules/search_embedded_form/search_embedded_form.module
+++ b/core/modules/search/tests/modules/search_embedded_form/search_embedded_form.module
@@ -30,7 +30,7 @@ function search_embedded_form_menu() {
* @see search_embedded_form_form_submit().
*/
function search_embedded_form_form($form, &$form_state) {
- $count = Drupal::config('search_embedded_form.settings')->get('submitted');
+ $count = config('search_embedded_form.settings')->get('submitted');
$form['name'] = array(
'#type' => 'textfield',
@@ -56,7 +56,7 @@ function search_embedded_form_form($form, &$form_state) {
* Submit handler for search_embedded_form_form().
*/
function search_embedded_form_form_submit($form, &$form_state) {
- $config = Drupal::config('search_embedded_form.settings');
+ $config = config('search_embedded_form.settings');
$submit_count = (int) $config->get('submitted');
$config->set('submitted', $submit_count + 1)->save();
drupal_set_message(t('Test form was submitted'));
diff --git a/core/modules/search/tests/modules/search_extra_type/search_extra_type.module b/core/modules/search/tests/modules/search_extra_type/search_extra_type.module
index b405e9a..4435b44 100644
--- a/core/modules/search/tests/modules/search_extra_type/search_extra_type.module
+++ b/core/modules/search/tests/modules/search_extra_type/search_extra_type.module
@@ -91,7 +91,7 @@ function search_extra_type_search_admin() {
'bi' => t('Bistromathic'),
'ii' => t('Infinite Improbability'),
),
- '#default_value' => Drupal::config('search_extra_type.settings')->get('boost'),
+ '#default_value' => config('search_extra_type.settings')->get('boost'),
);
$form['#submit'][] = 'search_extra_type_admin_submit';
@@ -103,7 +103,7 @@ function search_extra_type_search_admin() {
* Form API callback: Save admin settings
*/
function search_extra_type_admin_submit($form, &$form_state) {
- Drupal::config('search_extra_type.settings')
+ config('search_extra_type.settings')
->set('boost', $form_state['values']['extra_type_settings']['boost'])
->save();
}
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php
index 0e275f7..a67b53b 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php
@@ -7,7 +7,10 @@
namespace Drupal\shortcut\Controller;
-use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Controller\ControllerInterface;
+use Drupal\Core\Entity\EntityManager;
+use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\Routing\PathBasedGeneratorInterface;
use Drupal\shortcut\ShortcutSetInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -17,7 +20,55 @@
/**
* Builds the page for administering shortcut sets.
*/
-class ShortcutSetController extends ControllerBase {
+class ShortcutSetController implements ControllerInterface {
+
+ /**
+ * The module handler.
+ *
+ * @var \Drupal\Core\Extension\ModuleHandlerInterface
+ */
+ protected $moduleHandler;
+
+ /**
+ * Stores the entity manager.
+ *
+ * @var \Drupal\Core\Entity\EntityManager
+ */
+ protected $entityManager;
+
+ /**
+ * The URL generator.
+ *
+ * @var \Drupal\Core\Routing\PathBasedGeneratorInterface
+ */
+ protected $urlGenerator;
+
+ /**
+ * Constructs a new \Drupal\shortcut\Controller\ShortCutController object.
+ *
+ * @param \Drupal\Core\Entity\EntityManager $entity_manager
+ * The entity manager.
+ * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
+ * The module handler.
+ * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator
+ * The URL generator.
+ */
+ public function __construct(EntityManager $entity_manager, ModuleHandlerInterface $module_handler, PathBasedGeneratorInterface $url_generator) {
+ $this->entityManager = $entity_manager;
+ $this->moduleHandler = $module_handler;
+ $this->urlGenerator = $url_generator;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('plugin.manager.entity'),
+ $container->get('module_handler'),
+ $container->get('url_generator')
+ );
+ }
/**
* Creates a new link in the provided shortcut set.
@@ -42,7 +93,7 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques
'link_title' => $title,
'link_path' => $link,
);
- $this->moduleHandler()->loadInclude('shortcut', 'admin.inc');
+ $this->moduleHandler->loadInclude('shortcut', 'admin.inc');
shortcut_admin_add_link($link, $shortcut_set);
if ($shortcut_set->save() == SAVED_UPDATED) {
drupal_set_message(t('Added a shortcut for %title.', array('%title' => $link['link_title'])));
@@ -50,7 +101,7 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques
else {
drupal_set_message(t('Unable to add a shortcut for %title.', array('%title' => $link['link_title'])));
}
- return new RedirectResponse($this->urlGenerator()->generateFromPath('', array('absolute' => TRUE)));
+ return new RedirectResponse($this->urlGenerator->generateFromPath('', array('absolute' => TRUE)));
}
throw new AccessDeniedHttpException();
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php
index 0d68469..4cfd030 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php
@@ -64,7 +64,7 @@ function testShortcutLinkAdd() {
*/
function testShortcutQuickLink() {
theme_enable(array('seven'));
- \Drupal::config('system.theme')->set('admin', 'seven')->save();
+ config('system.theme')->set('admin', 'seven')->save();
variable_set('node_admin_theme', TRUE);
$link = reset($this->set->links);
@@ -136,7 +136,7 @@ function testShortcutLinkDelete() {
*/
function testNoShortcutLink() {
// Change to a theme that displays shortcuts.
- \Drupal::config('system.theme')
+ config('system.theme')
->set('default', 'seven')
->save();
diff --git a/core/modules/shortcut/shortcut.api.php b/core/modules/shortcut/shortcut.api.php
index 27eecf3..8468c08 100644
--- a/core/modules/shortcut/shortcut.api.php
+++ b/core/modules/shortcut/shortcut.api.php
@@ -32,7 +32,7 @@
*/
function hook_shortcut_default_set($account) {
// Use a special set of default shortcuts for administrators only.
- if (in_array(Drupal::config('user.settings')->get('admin_role'), $account->getRoles())) {
+ if (in_array(config('user.settings')->get('admin_role'), $account->getRoles())) {
return 'admin-shortcuts';
}
}
diff --git a/core/modules/shortcut/shortcut.install b/core/modules/shortcut/shortcut.install
index 76e7097..d78fa3b 100644
--- a/core/modules/shortcut/shortcut.install
+++ b/core/modules/shortcut/shortcut.install
@@ -84,7 +84,7 @@ function shortcut_update_8000() {
->condition('menu_name', 'shortcut-set-1')
->execute();
}
- Drupal::config('shortcut.set.' . $set->set_name)
+ config('shortcut.set.' . $set->set_name)
->set('id', $set->set_name)
->set('label', $set->title)
->set('uuid', $uuid->generate())
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
index b55feee..54305c0 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
@@ -121,7 +121,7 @@ protected function setUp() {
$modules = call_user_func_array('array_merge_recursive', $modules);
$this->enableModules($modules, FALSE);
// In order to use theme functions default theme config needs to exist.
- \Drupal::config('system.theme')->set('default', 'stark');
+ config('system.theme')->set('default', 'stark');
}
protected function tearDown() {
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
index 04e98f1..4040625 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
@@ -702,7 +702,7 @@ protected function verbose($message) {
*/
public function run(array $methods = array()) {
TestServiceProvider::$currentTest = $this;
- $simpletest_config = \Drupal::config('simpletest.settings');
+ $simpletest_config = config('simpletest.settings');
$class = get_class($this);
if ($simpletest_config->get('verbose')) {
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
index a2788b1..1171d1e 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
@@ -191,7 +191,7 @@ function testInstallConfig() {
$this->enableModules(array('user'));
$this->installConfig(array('user'));
$this->assertTrue($this->container->get('config.storage')->exists('user.settings'));
- $this->assertTrue(\Drupal::config('user.settings')->get('register'));
+ $this->assertTrue(config('user.settings')->get('register'));
}
/**
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php
index 7aaf42f..03b4380 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php
@@ -61,7 +61,7 @@ function testInternalBrowser() {
$this->drupalGet('test-page');
$this->assertTrue($this->drupalGetHeader('Date'), 'An HTTP header was received.');
$this->assertTitle(t('Test page | @site-name', array(
- '@site-name' => \Drupal::config('system.site')->get('name'),
+ '@site-name' => config('system.site')->get('name'),
)));
$this->assertNoTitle('Foo');
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index f1f5336..ab24fc8 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -366,7 +366,7 @@ protected function drupalPlaceBlock($plugin_id, array $settings = array()) {
'plugin' => $plugin_id,
'region' => 'sidebar_first',
'machine_name' => strtolower($this->randomName(8)),
- 'theme' => \Drupal::config('system.theme')->get('default'),
+ 'theme' => config('system.theme')->get('default'),
'label' => $this->randomName(8),
'visibility' => array(),
'weight' => 0,
@@ -790,7 +790,7 @@ protected function setUp() {
// Set 'parent_profile' of simpletest to add the parent profile's
// search path to the child site's search paths.
// @see drupal_system_listing()
- \Drupal::config('simpletest.settings')->set('parent_profile', $this->originalProfile)->save();
+ config('simpletest.settings')->set('parent_profile', $this->originalProfile)->save();
// Collect modules to install.
$class = get_class($this);
@@ -814,7 +814,7 @@ protected function setUp() {
// Now make sure that the file path configurations are saved. This is done
// after we install the modules to override default values.
foreach ($variable_groups as $config_base => $variables) {
- $config = \Drupal::config($config_base);
+ $config = config($config_base);
foreach ($variables as $name => $value) {
$config->set($name, $value);
}
@@ -823,7 +823,7 @@ protected function setUp() {
variable_set('file_public_path', $this->public_files_directory);
// Use the test mail class instead of the default mail handler class.
- \Drupal::config('system.mail')->set('interface.default', 'Drupal\Core\Mail\VariableLog')->save();
+ config('system.mail')->set('interface.default', 'Drupal\Core\Mail\VariableLog')->save();
drupal_set_time_limit($this->timeLimit);
// Temporary fix so that when running from run-tests.sh we don't get an
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index 4004dd3..4df4683 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -579,7 +579,7 @@ function simpletest_generate_file($filename, $width, $lines, $type = 'binary-tex
function simpletest_clean_environment() {
simpletest_clean_database();
simpletest_clean_temporary_directories();
- if (Drupal::config('simpletest.settings')->get('clear_results')) {
+ if (config('simpletest.settings')->get('clear_results')) {
$count = simpletest_clean_results_table();
drupal_set_message(format_plural($count, 'Removed 1 test result.', 'Removed @count test results.'));
}
@@ -648,7 +648,7 @@ function simpletest_clean_temporary_directories() {
* The number of results removed.
*/
function simpletest_clean_results_table($test_id = NULL) {
- if (Drupal::config('simpletest.settings')->get('clear_results')) {
+ if (config('simpletest.settings')->get('clear_results')) {
if ($test_id) {
$count = db_query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id))->fetchField();
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php
index 6c70985..0ea34f1 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php
@@ -70,32 +70,33 @@ function setUp() {
* Verifies that the statistics settings page works.
*/
function testStatisticsSettings() {
- $config = \Drupal::config('statistics.settings');
+ $config = config('statistics.settings');
$this->assertFalse($config->get('count_content_views'), 'Count content view log is disabled by default.');
// Enable counter on content view.
$edit['statistics_count_content_views'] = 1;
$this->drupalPost('admin/config/system/statistics', $edit, t('Save configuration'));
- $config = \Drupal::config('statistics.settings');
+ $config = config('statistics.settings');
$this->assertTrue($config->get('count_content_views'), 'Count content view log is enabled.');
// Hit the node.
$this->drupalGet('node/' . $this->test_node->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->test_node->id();
- $post = array('nid' => $nid);
+ $post = http_build_query(array('nid' => $nid));
+ $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
- $this->client->post($stats_path, array(), $post)->send();
+ $this->client->post($stats_path, $headers, $post)->send();
// Hit the node again (the counter is incremented after the hit, so
// "1 view" will actually be shown when the node is hit the second time).
$this->drupalGet('node/' . $this->test_node->id());
- $this->client->post($stats_path, array(), $post)->send();
+ $this->client->post($stats_path, $headers, $post)->send();
$this->assertText('1 view', 'Node is viewed once.');
$this->drupalGet('node/' . $this->test_node->id());
- $this->client->post($stats_path, array(), $post)->send();
+ $this->client->post($stats_path, $headers, $post)->send();
$this->assertText('2 views', 'Node is viewed 2 times.');
}
@@ -103,15 +104,16 @@ function testStatisticsSettings() {
* Tests that when a node is deleted, the node counter is deleted too.
*/
function testDeleteNode() {
- \Drupal::config('statistics.settings')->set('count_content_views', 1)->save();
+ config('statistics.settings')->set('count_content_views', 1)->save();
$this->drupalGet('node/' . $this->test_node->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->test_node->id();
- $post = array('nid' => $nid);
+ $post = http_build_query(array('nid' => $nid));
+ $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
- $this->client->post($stats_path, array(), $post)->send();
+ $this->client->post($stats_path, $headers, $post)->send();
$result = db_select('node_counter', 'n')
->fields('n', array('nid'))
@@ -134,7 +136,7 @@ function testDeleteNode() {
* Tests that cron clears day counts and expired access logs.
*/
function testExpiredLogs() {
- \Drupal::config('statistics.settings')
+ config('statistics.settings')
->set('count_content_views', 1)
->save();
\Drupal::state()->set('statistics.day_timestamp', 8640000);
@@ -142,12 +144,13 @@ function testExpiredLogs() {
$this->drupalGet('node/' . $this->test_node->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->test_node->id();
- $post = array('nid' => $nid);
+ $post = http_build_query(array('nid' => $nid));
+ $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
- $this->client->post($stats_path, array(), $post)->send();
+ $this->client->post($stats_path, $headers, $post)->send();
$this->drupalGet('node/' . $this->test_node->id());
- $this->client->post($stats_path, array(), $post)->send();
+ $this->client->post($stats_path, $headers, $post)->send();
$this->assertText('1 view', 'Node is viewed once.');
// statistics_cron() will subtract
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
index 5c8fbbb..02bd8c2 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
@@ -54,13 +54,13 @@ function setUp() {
$this->node = $this->drupalCreateNode(array('title' => $this->randomName(255), 'uid' => $this->auth_user->id()));
// Enable page caching.
- $config = \Drupal::config('system.performance');
+ $config = config('system.performance');
$config->set('cache.page.use_internal', 1);
$config->set('cache.page.max_age', 300);
$config->save();
// Enable access logging.
- \Drupal::config('statistics.settings')
+ config('statistics.settings')
->set('count_content_views', 1)
->save();
@@ -85,10 +85,11 @@ function testLogging() {
$this->drupalGet($path);
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->node->id();
- $post = array('nid' => $nid);
+ $post = http_build_query(array('nid' => $nid));
+ $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
- $this->client->post($stats_path, array(), $post)->send();
+ $this->client->post($stats_path, $headers, $post)->send();
$this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Testing an uncached page.');
$node_counter = statistics_get($this->node->id());
$this->assertIdentical($node_counter['totalcount'], '1');
@@ -96,7 +97,7 @@ function testLogging() {
// Verify logging of a cached page.
$this->drupalGet($path);
// Manually calling statistics.php, simulating ajax behavior.
- $this->client->post($stats_path, array(), $post)->send();
+ $this->client->post($stats_path, $headers, $post)->send();
$this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Testing a cached page.');
$node_counter = statistics_get($this->node->id());
$this->assertIdentical($node_counter['totalcount'], '2');
@@ -105,7 +106,7 @@ function testLogging() {
$this->drupalLogin($this->auth_user);
$this->drupalGet($path);
// Manually calling statistics.php, simulating ajax behavior.
- $this->client->post($stats_path, array(), $post)->send();
+ $this->client->post($stats_path, $headers, $post)->send();
$node_counter = statistics_get($this->node->id());
$this->assertIdentical($node_counter['totalcount'], '3');
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTestBase.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTestBase.php
index 8ad4df2..f4d75f4 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTestBase.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTestBase.php
@@ -41,7 +41,7 @@ function setUp() {
$this->drupalLogin($this->blocking_user);
// Enable logging.
- \Drupal::config('statistics.settings')
+ config('statistics.settings')
->set('count_content_views', 1)
->save();
}
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/Views/IntegrationTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/Views/IntegrationTest.php
index f5f943a..604d053 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/Views/IntegrationTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/Views/IntegrationTest.php
@@ -80,11 +80,12 @@ public function testNodeCounterIntegration() {
$this->drupalGet('node/' . $this->node->id());
// Manually calling statistics.php, simulating ajax behavior.
// @see \Drupal\statistics\Tests\StatisticsLoggingTest::testLogging().
+ $post = http_build_query(array('nid' => $this->node->id()));
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$client = \Drupal::httpClient();
$client->setConfig(array('curl.options' => array(CURLOPT_TIMEOUT => 10)));
- $client->post($stats_path, array(), array('nid' => $this->node->id()))->send();
+ $client->post($stats_path, array(), $post)->send();
$this->drupalGet('test_statistics_integration');
$expected = statistics_get($this->node->id());
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index 1faf13e..c40fc6a 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -211,7 +211,7 @@ function statistics_node_predelete(EntityInterface $node) {
* Implements hook_ranking().
*/
function statistics_ranking() {
- if (Drupal::config('statistics.settings')->get('count_content_views')) {
+ if (config('statistics.settings')->get('count_content_views')) {
return array(
'views' => array(
'title' => t('Number of views'),
@@ -274,7 +274,7 @@ function statistics_library_info() {
* to count content views.
*/
function statistics_block_alter(&$definitions) {
- $statistics_count_content_views = Drupal::config('statistics.settings')->get('count_content_views');
+ $statistics_count_content_views = config('statistics.settings')->get('count_content_views');
if (empty($statistics_count_content_views)) {
unset($definitions['statistics_popular_block']);
}
diff --git a/core/modules/statistics/statistics.php b/core/modules/statistics/statistics.php
index 20a2ec9..22d2fb4 100644
--- a/core/modules/statistics/statistics.php
+++ b/core/modules/statistics/statistics.php
@@ -12,7 +12,7 @@
include_once dirname(dirname(__DIR__)) . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
-if (\Drupal::config('statistics.settings')->get('count_content_views')) {
+if (config('statistics.settings')->get('count_content_views')) {
$nid = filter_input(INPUT_POST, 'nid', FILTER_VALIDATE_INT);
if ($nid) {
db_merge('node_counter')
diff --git a/core/modules/syslog/syslog.install b/core/modules/syslog/syslog.install
index c9eb769..5b2c41a 100644
--- a/core/modules/syslog/syslog.install
+++ b/core/modules/syslog/syslog.install
@@ -11,7 +11,7 @@
function syslog_install() {
// The default facility setting depends on the operating system, so it needs
// to be set dynamically during installation.
- Drupal::config('syslog.settings')->set('facility', defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER)->save();
+ config('syslog.settings')->set('facility', defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER)->save();
}
/**
diff --git a/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module
index c46f58a..fe781c3 100644
--- a/core/modules/syslog/syslog.module
+++ b/core/modules/syslog/syslog.module
@@ -45,7 +45,7 @@ function syslog_help($path, $arg) {
* Implements hook_form_FORM_ID_alter().
*/
function syslog_form_system_logging_settings_alter(&$form, &$form_state) {
- $config = Drupal::config('syslog.settings');
+ $config = config('syslog.settings');
$help = module_exists('help') ? ' ' . l(t('More information'), 'admin/help/syslog') . '.' : NULL;
$form['syslog_identity'] = array(
'#type' => 'textfield',
@@ -78,7 +78,7 @@ function syslog_form_system_logging_settings_alter(&$form, &$form_state) {
* @see syslog_form_system_logging_settings_alter()
*/
function syslog_logging_settings_submit($form, &$form_state) {
- Drupal::config('syslog.settings')
+ config('syslog.settings')
->set('identity', $form_state['values']['syslog_identity'])
->set('facility', $form_state['values']['syslog_facility'])
->set('format', $form_state['values']['syslog_format'])
@@ -111,7 +111,7 @@ function syslog_watchdog(array $log_entry) {
global $base_url;
$log_init = &drupal_static(__FUNCTION__, FALSE);
- $config = Drupal::config('syslog.settings');
+ $config = config('syslog.settings');
if (!$log_init) {
$log_init = TRUE;
diff --git a/core/modules/system/config/system.filter.yml b/core/modules/system/config/system.filter.yml
index 12ce55a..3bfbd9a 100644
--- a/core/modules/system/config/system.filter.yml
+++ b/core/modules/system/config/system.filter.yml
@@ -4,7 +4,6 @@ protocols:
- ftp
- news
- nntp
- - tel
- telnet
- mailto
- irc
diff --git a/core/modules/system/css/system.plugin.ui.css b/core/modules/system/css/system.plugin.ui.css
new file mode 100644
index 0000000..c932788
--- /dev/null
+++ b/core/modules/system/css/system.plugin.ui.css
@@ -0,0 +1,29 @@
+#block-library .left-col,
+#block-library .right-col {
+ float:left;
+ width:66%;
+ height:100%;
+ background-color:#ffffff;
+}
+
+#block-library .right-col {
+ width:34%;
+ background-color:#f7f7f7;
+}
+
+#block-library .right-col h3 {
+ margin: 1em -20px;
+ background-color:#d7d7d7;
+ color:#333333;
+ padding:8px 15px;
+ font-size:1.1em;
+}
+
+#block-library .inside {
+ margin:0 20px;
+}
+
+#block-library .bottom-bar {
+ width:100%;
+ clear:both;
+}
diff --git a/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php b/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php
index 9c12bd0..a0cc981 100644
--- a/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php
+++ b/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php
@@ -32,7 +32,7 @@ public function access(Route $route, Request $request) {
watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
return FALSE;
}
- elseif (\Drupal::config('system.maintenance')->get('enabled')) {
+ elseif (config('system.maintenance')->get('enabled')) {
watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE);
return FALSE;
}
diff --git a/core/modules/system/lib/Drupal/system/Access/SystemPluginUiCheck.php b/core/modules/system/lib/Drupal/system/Access/SystemPluginUiCheck.php
new file mode 100644
index 0000000..db13644
--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Access/SystemPluginUiCheck.php
@@ -0,0 +1,55 @@
+pluginUiManager = $plugin_ui_manager;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function applies(Route $route) {
+ return array_key_exists('_access_system_plugin_ui', $route->getRequirements());
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function access(Route $route, Request $request) {
+ if ($request->attributes->get('plugin_id')) {
+ // Checks access for a given plugin using the plugin's access() method.
+ $plugin_ui = $this->pluginUiManager->createInstance($request->attributes->get('plugin_id'), array());
+ return $plugin_ui->access(NULL) ? static::ALLOW : static::DENY;
+ }
+ }
+
+}
diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemController.php b/core/modules/system/lib/Drupal/system/Controller/SystemController.php
new file mode 100644
index 0000000..bd71353
--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Controller/SystemController.php
@@ -0,0 +1,56 @@
+query->get('q');
+ $string_typed = Tags::explode($string_typed);
+ $string = Unicode::strtolower(array_pop($string_typed));
+ $matches = array();
+ if ($string) {
+ $plugin_ui = $this->container->get('plugin.manager.system.plugin_ui')->getDefinition($plugin_id);
+ $manager = $this->container->get($plugin_ui['manager']);
+ $titles = array();
+ foreach($manager->getDefinitions() as $plugin_id => $plugin) {
+ $titles[$plugin_id] = $plugin[$plugin_ui['title_attribute']];
+ }
+ $matches = preg_grep("/\b". $string . "/i", $titles);
+ }
+
+ return new JsonResponse($matches);
+ }
+
+}
diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php b/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php
index c34efad..af48c1f 100644
--- a/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php
+++ b/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php
@@ -53,7 +53,7 @@ public function __construct(SystemManager $systemManager) {
public function status() {
$requirements = $this->systemManager->listRequirements();
$this->systemManager->fixAnonymousUid();
- return array('#theme' => 'status_report', '#requirements' => $requirements);
+ return theme('status_report', array('requirements' => $requirements));
}
/**
diff --git a/core/modules/system/lib/Drupal/system/Form/CronForm.php b/core/modules/system/lib/Drupal/system/Form/CronForm.php
index 31c599b..dd83495 100644
--- a/core/modules/system/lib/Drupal/system/Form/CronForm.php
+++ b/core/modules/system/lib/Drupal/system/Form/CronForm.php
@@ -89,7 +89,6 @@ public function buildForm(array $form, array &$form_state) {
$form['cron']['cron_safe_threshold'] = array(
'#type' => 'select',
'#title' => t('Run cron every'),
- '#description' => t('More information about setting up scheduled tasks can be found by reading the cron tutorial on drupal.org.', array('@url' => url('http://drupal.org/cron'))),
'#default_value' => $config->get('threshold.autorun'),
'#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
);
diff --git a/core/modules/system/lib/Drupal/system/MenuAccessController.php b/core/modules/system/lib/Drupal/system/MenuAccessController.php
deleted file mode 100644
index 52b272d..0000000
--- a/core/modules/system/lib/Drupal/system/MenuAccessController.php
+++ /dev/null
@@ -1,47 +0,0 @@
-id()])) {
- return FALSE;
- }
- }
-
- if (in_array($operation, array('update', 'delete'))) {
- return $account->hasPermission('administer menu');
- }
- }
-
- /**
- * {@inheritdoc}
- */
- protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
- return $account->hasPermission('administer menu');
- }
-
-}
diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php
index d636ea3..1daf4bf 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php
@@ -18,7 +18,6 @@
* id = "system_menu_block",
* admin_label = @Translation("System Menu"),
* module = "system",
- * category = "menu",
* derivative = "Drupal\system\Plugin\Derivative\SystemMenuBlock"
* )
*/
diff --git a/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/DateFormat.php b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/DateFormat.php
index e853b9b..badf567 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/DateFormat.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/DateFormat.php
@@ -192,7 +192,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
foreach ($entities as $entity) {
$format_id = $entity->id();
foreach ($languages as $langcode => $data) {
- \Drupal::config("locale.config.$langcode.system.date_format.$format_id")->delete();
+ config("locale.config.$langcode.system.date_format.$format_id")->delete();
}
}
}
diff --git a/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Menu.php b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Menu.php
index ef690c2..f12e2a6 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Menu.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Menu.php
@@ -20,8 +20,7 @@
* label = @Translation("Menu"),
* module = "system",
* controllers = {
- * "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
- * "access" = "Drupal\system\MenuAccessController"
+ * "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
* },
* config_prefix = "menu.menu",
* entity_keys = {
diff --git a/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php
index c912400..d641862 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php
@@ -25,6 +25,7 @@ public function getDerivativeDefinitions(array $base_plugin_definition) {
// menu would otherwise clash with the 'main' page content block.
$menu_key = 'menu-' . $menu;
$this->derivatives[$menu_key] = $base_plugin_definition;
+ $this->derivatives[$menu_key]['delta'] = $menu_key;
// It is possible that users changed the menu label. Fall back on the
// built-in menu label if the entity was not found.
$entity = entity_load('menu', $menu);
diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php
index 2421004..06cb4a6 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php
@@ -10,7 +10,6 @@
use Drupal\Component\Plugin\PluginBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
-use Drupal\Core\Image\ImageInterface;
use Drupal\system\Plugin\ImageToolkitInterface;
/**
@@ -24,7 +23,7 @@
class GDToolkit extends PluginBase implements ImageToolkitInterface {
/**
- * {@inheritdoc}
+ * Implements \Drupal\system\Plugin\ImageToolkitInterface::settingsForm().
*/
public function settingsForm() {
$form['image_jpeg_quality'] = array(
@@ -33,150 +32,149 @@ public function settingsForm() {
'#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
'#min' => 0,
'#max' => 100,
- '#default_value' => \Drupal::config('system.image.gd')->get('jpeg_quality'),
+ '#default_value' => config('system.image.gd')->get('jpeg_quality'),
'#field_suffix' => t('%'),
);
return $form;
}
/**
- * {@inheritdoc}
+ * Implements \Drupal\system\Plugin\ImageToolkitInterface::settingsFormSubmit().
*/
public function settingsFormSubmit($form, &$form_state) {
- \Drupal::config('system.image.gd')
+ config('system.image.gd')
->set('jpeg_quality', $form_state['values']['gd']['image_jpeg_quality'])
->save();
}
/**
- * {@inheritdoc}
+ * Implements \Drupal\system\Plugin\ImageToolkitInterface::resize().
*/
- public function resize(ImageInterface $image, $width, $height) {
+ public function resize($image, $width, $height) {
$res = $this->createTmp($image, $width, $height);
- if (!imagecopyresampled($res, $image->getResource(), 0, 0, 0, 0, $width, $height, $image->getWidth(), $image->getHeight())) {
+ if (!imagecopyresampled($res, $image->resource, 0, 0, 0, 0, $width, $height, $image->info['width'], $image->info['height'])) {
return FALSE;
}
- imagedestroy($image->getResource());
+ imagedestroy($image->resource);
// Update image object.
- $image
- ->setResource($res)
- ->setWidth($width)
- ->setHeight($height);
+ $image->resource = $res;
+ $image->info['width'] = $width;
+ $image->info['height'] = $height;
return TRUE;
}
/**
- * {@inheritdoc}
+ * Implements \Drupal\system\Plugin\ImageToolkitInterface::rotate().
*/
- public function rotate(ImageInterface $image, $degrees, $background = NULL) {
+ public function rotate($image, $degrees, $background = NULL) {
// PHP installations using non-bundled GD do not have imagerotate.
if (!function_exists('imagerotate')) {
- watchdog('image', 'The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', array('%file' => $image->getSource()));
+ watchdog('image', 'The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', array('%file' => $image->source));
return FALSE;
}
+ $width = $image->info['width'];
+ $height = $image->info['height'];
+
// Convert the hexadecimal background value to a color index value.
if (isset($background)) {
$rgb = array();
for ($i = 16; $i >= 0; $i -= 8) {
$rgb[] = (($background >> $i) & 0xFF);
}
- $background = imagecolorallocatealpha($image->getResource(), $rgb[0], $rgb[1], $rgb[2], 0);
+ $background = imagecolorallocatealpha($image->resource, $rgb[0], $rgb[1], $rgb[2], 0);
}
// Set the background color as transparent if $background is NULL.
else {
// Get the current transparent color.
- $background = imagecolortransparent($image->getResource());
+ $background = imagecolortransparent($image->resource);
// If no transparent colors, use white.
if ($background == 0) {
- $background = imagecolorallocatealpha($image->getResource(), 255, 255, 255, 0);
+ $background = imagecolorallocatealpha($image->resource, 255, 255, 255, 0);
}
}
// Images are assigned a new color palette when rotating, removing any
// transparency flags. For GIF images, keep a record of the transparent color.
- if ($image->getExtension() == 'gif') {
- $transparent_index = imagecolortransparent($image->getResource());
+ if ($image->info['extension'] == 'gif') {
+ $transparent_index = imagecolortransparent($image->resource);
if ($transparent_index != 0) {
- $transparent_gif_color = imagecolorsforindex($image->getResource(), $transparent_index);
+ $transparent_gif_color = imagecolorsforindex($image->resource, $transparent_index);
}
}
- $image->setResource(imagerotate($image->getResource(), 360 - $degrees, $background));
+ $image->resource = imagerotate($image->resource, 360 - $degrees, $background);
// GIFs need to reassign the transparent color after performing the rotate.
if (isset($transparent_gif_color)) {
- $background = imagecolorexactalpha($image->getResource(), $transparent_gif_color['red'], $transparent_gif_color['green'], $transparent_gif_color['blue'], $transparent_gif_color['alpha']);
- imagecolortransparent($image->getResource(), $background);
+ $background = imagecolorexactalpha($image->resource, $transparent_gif_color['red'], $transparent_gif_color['green'], $transparent_gif_color['blue'], $transparent_gif_color['alpha']);
+ imagecolortransparent($image->resource, $background);
}
- $image
- ->setWidth(imagesx($image->getResource()))
- ->setHeight(imagesy($image->getResource()));
+ $image->info['width'] = imagesx($image->resource);
+ $image->info['height'] = imagesy($image->resource);
return TRUE;
}
/**
- * {@inheritdoc}
+ * Implements \Drupal\system\Plugin\ImageToolkitInterface::crop().
*/
- public function crop(ImageInterface $image, $x, $y, $width, $height) {
+ public function crop($image, $x, $y, $width, $height) {
$res = $this->createTmp($image, $width, $height);
- if (!imagecopyresampled($res, $image->getResource(), 0, 0, $x, $y, $width, $height, $width, $height)) {
+ if (!imagecopyresampled($res, $image->resource, 0, 0, $x, $y, $width, $height, $width, $height)) {
return FALSE;
}
// Destroy the original image and return the modified image.
- imagedestroy($image->getResource());
- $image
- ->setResource($res)
- ->setWidth($width)
- ->setHeight($height);
+ imagedestroy($image->resource);
+ $image->resource = $res;
+ $image->info['width'] = $width;
+ $image->info['height'] = $height;
return TRUE;
}
/**
- * {@inheritdoc}
+ * Implements \Drupal\system\Plugin\ImageToolkitInterface::desaturate().
*/
- public function desaturate(ImageInterface $image) {
+ public function desaturate($image) {
// PHP installations using non-bundled GD do not have imagefilter.
if (!function_exists('imagefilter')) {
- watchdog('image', 'The image %file could not be desaturated because the imagefilter() function is not available in this PHP installation.', array('%file' => $image->getSource()));
+ watchdog('image', 'The image %file could not be desaturated because the imagefilter() function is not available in this PHP installation.', array('%file' => $image->source));
return FALSE;
}
- return imagefilter($image->getResource(), IMG_FILTER_GRAYSCALE);
+ return imagefilter($image->resource, IMG_FILTER_GRAYSCALE);
}
/**
- * {@inheritdoc}
+ * Implements \Drupal\system\Plugin\ImageToolkitInterface::load().
*/
- public function load(ImageInterface $image) {
- $extension = str_replace('jpg', 'jpeg', $image->getExtension());
+ public function load($image) {
+ $extension = str_replace('jpg', 'jpeg', $image->info['extension']);
$function = 'imagecreatefrom' . $extension;
- if (function_exists($function) && $resource = $function($image->getSource())) {
- $image->setResource($resource);
- if (!imageistruecolor($resource)) {
+ if (function_exists($function) && $image->resource = $function($image->source)) {
+ if (!imageistruecolor($image->resource)) {
// Convert indexed images to true color, so that filters work
// correctly and don't result in unnecessary dither.
- $new_image = $this->createTmp($image, $image->getWidth(), $image->getHeight());
- imagecopy($new_image, $resource, 0, 0, 0, 0, $image->getWidth(), $image->getHeight());
- imagedestroy($resource);
- $image->setResource($new_image);
+ $new_image = $this->createTmp($image, $image->info['width'], $image->info['height']);
+ imagecopy($new_image, $image->resource, 0, 0, 0, 0, $image->info['width'], $image->info['height']);
+ imagedestroy($image->resource);
+ $image->resource = $new_image;
}
- return (bool) $image->getResource();
+ return (bool) $image->resource;
}
return FALSE;
}
/**
- * {@inheritdoc}
+ * Implements \Drupal\system\Plugin\ImageToolkitInterface::save().
*/
- public function save(ImageInterface $image, $destination) {
+ public function save($image, $destination) {
$scheme = file_uri_scheme($destination);
// Work around lack of stream wrapper support in imagejpeg() and imagepng().
if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
@@ -190,21 +188,21 @@ public function save(ImageInterface $image, $destination) {
$destination = drupal_realpath($destination);
}
- $extension = str_replace('jpg', 'jpeg', $image->getExtension());
+ $extension = str_replace('jpg', 'jpeg', $image->info['extension']);
$function = 'image' . $extension;
if (!function_exists($function)) {
return FALSE;
}
if ($extension == 'jpeg') {
- $success = $function($image->getResource(), $destination, \Drupal::config('system.image.gd')->get('jpeg_quality'));
+ $success = $function($image->resource, $destination, config('system.image.gd')->get('jpeg_quality'));
}
else {
// Always save PNG images with full transparency.
if ($extension == 'png') {
- imagealphablending($image->getResource(), FALSE);
- imagesavealpha($image->getResource(), TRUE);
+ imagealphablending($image->resource, FALSE);
+ imagesavealpha($image->resource, TRUE);
}
- $success = $function($image->getResource(), $destination);
+ $success = $function($image->resource, $destination);
}
// Move temporary local file to remote destination.
if (isset($permanent_destination) && $success) {
@@ -214,11 +212,11 @@ public function save(ImageInterface $image, $destination) {
}
/**
- * {@inheritdoc}
+ * Implements \Drupal\system\Plugin\ImageToolkitInterface::getInfo().
*/
- public function getInfo(ImageInterface $image) {
+ public function getInfo($image) {
$details = FALSE;
- $data = getimagesize($image->getSource());
+ $data = getimagesize($image->source);
if (isset($data) && is_array($data)) {
$extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
@@ -237,7 +235,7 @@ public function getInfo(ImageInterface $image) {
/**
* Creates a truecolor image preserving transparency from a provided image.
*
- * @param \Drupal\Core\Image\ImageInterface $image
+ * @param object $image
* An image object.
* @param int $width
* The new width of the new image, in pixels.
@@ -247,16 +245,16 @@ public function getInfo(ImageInterface $image) {
* @return resource
* A GD image handle.
*/
- public function createTmp(ImageInterface $image, $width, $height) {
+ public function createTmp($image, $width, $height) {
$res = imagecreatetruecolor($width, $height);
- if ($image->getExtension() == 'gif') {
+ if ($image->info['extension'] == 'gif') {
// Grab transparent color index from image resource.
- $transparent = imagecolortransparent($image->getResource());
+ $transparent = imagecolortransparent($image->resource);
if ($transparent >= 0) {
// The original must have a transparent color, allocate to the new image.
- $transparent_color = imagecolorsforindex($image->getResource(), $transparent);
+ $transparent_color = imagecolorsforindex($image->resource, $transparent);
$transparent = imagecolorallocate($res, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
// Flood with our new transparent color.
@@ -264,7 +262,7 @@ public function createTmp(ImageInterface $image, $width, $height) {
imagecolortransparent($res, $transparent);
}
}
- elseif ($image->getExtension() == 'png') {
+ elseif ($image->info['extension'] == 'png') {
imagealphablending($res, FALSE);
$transparency = imagecolorallocatealpha($res, 0, 0, 0, 127);
imagefill($res, 0, 0, $transparency);
@@ -279,7 +277,7 @@ public function createTmp(ImageInterface $image, $width, $height) {
}
/**
- * {@inheritdoc}
+ * Implements \Drupal\system\Plugin\ImageToolkitInterface::isAvailable().
*/
public static function isAvailable() {
if ($check = get_extension_funcs('gd')) {
diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitInterface.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitInterface.php
index 774f050..0b22f3c 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitInterface.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitInterface.php
@@ -7,43 +7,13 @@
namespace Drupal\system\Plugin;
-use Drupal\Component\Plugin\PluginInspectionInterface;
-use Drupal\Core\Image\ImageInterface;
-
-/**
- * @defgroup image Image toolkits
- * @{
- * Functions for image file manipulations.
- *
- * Drupal's image toolkits provide an abstraction layer for common image file
- * manipulations like scaling, cropping, and rotating. The abstraction frees
- * module authors from the need to support multiple image libraries, and it
- * allows site administrators to choose the library that's best for them.
- *
- * PHP includes the GD library by default so a GD toolkit is installed with
- * Drupal. Other toolkits like ImageMagick are available from contrib modules.
- * GD works well for small images, but using it with larger files may cause PHP
- * to run out of memory. In contrast the ImageMagick library does not suffer
- * from this problem, but it requires the ISP to have installed additional
- * software.
- *
- * Image toolkits are discovered using the Plugin system using
- * \Drupal\system\Plugin\ImageToolkitManager. The toolkit must then be enabled
- * using the admin/config/media/image-toolkit form.
- *
- * Only one toolkit may be selected at a time. If a module author wishes to call
- * a specific toolkit they can check that it is installed by calling
- * \Drupal\system\Plugin\ImageToolkitManager::getAvailableToolkits(), and then
- * calling its functions directly.
- */
-
/**
* Defines an interface for image toolkits.
*
* An image toolkit provides common image file manipulations like scaling,
* cropping, and rotating.
*/
-interface ImageToolkitInterface extends PluginInspectionInterface {
+interface ImageToolkitInterface {
/**
* Retrieves toolkit's settings form.
@@ -62,7 +32,7 @@ function settingsFormSubmit($form, &$form_state);
/**
* Scales an image to the specified size.
*
- * @param \Drupal\Core\Image\ImageInterface $image
+ * @param object $image
* An image object. The $image->resource, $image->info['width'], and
* $image->info['height'] values will be modified by this call.
* @param int $width
@@ -72,13 +42,15 @@ function settingsFormSubmit($form, &$form_state);
*
* @return bool
* TRUE or FALSE, based on success.
+ *
+ * @see image_resize()
*/
- function resize(ImageInterface $image, $width, $height);
+ function resize($image, $width, $height);
/**
* Rotates an image the given number of degrees.
*
- * @param \Drupal\Core\Image\ImageInterface $image
+ * @param object $image
* An image object. The $image->resource, $image->info['width'], and
* $image->info['height'] values will be modified by this call.
* @param int $degrees
@@ -92,13 +64,15 @@ function resize(ImageInterface $image, $width, $height);
*
* @return bool
* TRUE or FALSE, based on success.
+ *
+ * @see image_rotate()
*/
- function rotate(ImageInterface $image, $degrees, $background = NULL);
+ function rotate($image, $degrees, $background = NULL);
/**
* Crops an image.
*
- * @param \Drupal\Core\Image\ImageInterface $image
+ * @param object $image
* An image object. The $image->resource, $image->info['width'], and
* $image->info['height'] values will be modified by this call.
* @param int $x
@@ -115,50 +89,56 @@ function rotate(ImageInterface $image, $degrees, $background = NULL);
*
* @see image_crop()
*/
- function crop(ImageInterface $image, $x, $y, $width, $height);
+ function crop($image, $x, $y, $width, $height);
/**
* Converts an image resource to grayscale.
*
* Note that transparent GIFs loose transparency when desaturated.
*
- * @param \Drupal\Core\Image\ImageInterface $image
+ * @param object $image
* An image object. The $image->resource value will be modified by this
* call.
*
* @return bool
* TRUE or FALSE, based on success.
+ *
+ * @see image_desaturate()
*/
- function desaturate(ImageInterface $image);
+ function desaturate($image);
/**
* Creates an image resource from a file.
*
- * @param \Drupal\Core\Image\ImageInterface $image
+ * @param object $image
* An image object. The $image->resource value will populated by this call.
*
* @return bool
* TRUE or FALSE, based on success.
+ *
+ * @see image_load()
*/
- function load(ImageInterface $image);
+ function load($image);
/**
* Writes an image resource to a destination file.
*
- * @param \Drupal\Core\Image\ImageInterface $image
+ * @param object $image
* An image object.
* @param string $destination
* A string file URI or path where the image should be saved.
*
* @return bool
* TRUE or FALSE, based on success.
+ *
+ * @see image_save()
*/
- function save(ImageInterface $image, $destination);
+ function save($image, $destination);
/**
* Gets details about an image.
*
- * @param \Drupal\Core\Image\ImageInterface $image
+ * @param object $image
* An image object.
*
* @return array
@@ -169,9 +149,9 @@ function save(ImageInterface $image, $destination);
* - "extension": Commonly used file extension for the image.
* - "mime_type": MIME type ('image/jpeg', 'image/gif', 'image/png').
*
- * @see \Drupal\Core\Image\ImageInterface::processInfo()
+ * @see image_get_info()
*/
- function getInfo(ImageInterface $image);
+ function getInfo($image);
/**
* Verifies Image Toolkit is set up correctly.
diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php
index 5f00afb..f8e334d 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php
@@ -43,7 +43,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
* Object of the default toolkit, or FALSE on error.
*/
public function getDefaultToolkit() {
- $toolkit_id = \Drupal::config('system.image')->get('toolkit');
+ $toolkit_id = config('system.image')->get('toolkit');
$toolkits = $this->getAvailableToolkits();
if (!isset($toolkits[$toolkit_id]) || !class_exists($toolkits[$toolkit_id]['class'])) {
diff --git a/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php b/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php
new file mode 100644
index 0000000..077ee5b
--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php
@@ -0,0 +1,96 @@
+getPluginDefinition();
+ // @todo Find out how to let the manager be injected into the class.
+ if (class_exists($plugin_definition['manager'])) {
+ $manager = new $plugin_definition['manager']();
+ }
+ else {
+ $manager = drupal_container()->get($plugin_definition['manager']);
+ }
+ $plugins = $manager->getDefinitions();
+
+ $rows = array();
+ foreach ($plugins as $plugin_id => $display_plugin_definition) {
+ $rows[] = $this->row($plugin_id, $display_plugin_definition);
+ }
+ $form['plugins'] = array(
+ '#theme' => 'table',
+ '#header' => $this->tableHeader(),
+ '#rows' => $rows,
+ );
+
+ return $form;
+ }
+
+ /**
+ * Implements \Drupal\system\Plugin\PluginUIInterface::formValidate().
+ */
+ public function formValidate($form, &$form_state) {
+ }
+
+ /**
+ * Implements \Drupal\system\Plugin\PluginUIInterface::formSumbit().
+ */
+ public function formSubmit($form, &$form_state) {
+ }
+
+ /**
+ * Checks access for plugins of this type.
+ *
+ * @return bool
+ * Returns TRUE if plugins of this type can be accessed.
+ */
+ public function access() {
+ $definition = $this->getPluginDefinition();
+ return call_user_func_array($definition['access_callback'], $definition['access_arguments']);
+ }
+
+ /**
+ * Displays a plugin row for configuring plugins in the user interface.
+ *
+ * @param string $display_plugin_id
+ * The ID of the specific plugin definition being passed to us.
+ * @param array $display_plugin_definition
+ * The plugin definition associated with the passed $plugin_id.
+ *
+ * @return array
+ * An array that represents a table row in the final user interface output.
+ */
+ public function row($display_plugin_id, array $display_plugin_definition) {
+ $plugin_definition = $this->getPluginDefinition();
+ return array($display_plugin_definition['title'], l($plugin_definition['link_title'], $plugin_definition['config_path'] . '/' . $display_plugin_id));
+ }
+
+ /**
+ * Provides a theme_table compatible array of headers.
+ *
+ * @return array
+ * A theme_table compatible array of headers.
+ */
+ public function tableHeader() {
+ return array(t('Title'), t('Operations'));
+ }
+
+}
diff --git a/core/modules/system/lib/Drupal/system/Plugin/PluginUIInterface.php b/core/modules/system/lib/Drupal/system/Plugin/PluginUIInterface.php
new file mode 100644
index 0000000..9bc7629
--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Plugin/PluginUIInterface.php
@@ -0,0 +1,52 @@
+discovery = new AnnotatedClassDiscovery('Plugin/PluginUI', $namespaces);
+ $this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
+ $this->discovery = new AlterDecorator($this->discovery, 'plugin_ui');
+ $this->discovery = new CacheDecorator($this->discovery, 'plugin_ui');
+ $this->factory = new DefaultFactory($this->discovery);
+ }
+
+ /**
+ * Overrides \Drupal\Component\Plugin\PluginManagerBase::processDefinition().
+ */
+ public function processDefinition(&$definition, $plugin_id) {
+ $definition += array(
+ 'default_task' => TRUE,
+ 'task_title' => t('View'),
+ 'task_suffix' => 'view',
+ 'access_callback' => 'user_access',
+ );
+ }
+
+}
diff --git a/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php b/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php
index 87a7516..f7c5ea2 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php
@@ -10,7 +10,6 @@
use Drupal\Core\Entity\EntityManager;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\style\Table;
-use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -51,9 +50,9 @@ public static function create(ContainerInterface $container, array $configuratio
}
/**
- * {@inheritdoc}
+ * Overrides \Drupal\views\Plugin\views\Plugin\field\FieldPluginBase::render().
*/
- public function render(ResultRow $values) {
+ public function render($values) {
return '';
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php
index 7b86c56..e30b55c 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php
@@ -169,7 +169,8 @@ function testLazyLoad() {
// Verify the expected CSS file was added, both to drupalSettings, and as
// the second AJAX command for inclusion into the HTML.
- $this->assertEqual($new_css, $original_css + array($expected_css_basename => 1), format_string('Page state now has the %css file.', array('%css' => $expected['css'])));
+ // @todo Uncomment this assertion after fixing http://drupal.org/node/1941288.
+ //$this->assertEqual($new_css, $original_css + array($expected_css_basename => 1), format_string('Page state now has the %css file.', array('%css' => $expected['css'])));
$this->assertCommand(array_slice($commands, 1, 1), array('data' => $expected_css_html), format_string('Page now has the %css file.', array('%css' => $expected['css'])));
// Verify the expected JS file was added, both to drupalSettings, and as
@@ -178,7 +179,8 @@ function testLazyLoad() {
// unexpected JavaScript code, such as a jQuery.extend() that would
// potentially clobber rather than properly merge settings, didn't
// accidentally get added.
- $this->assertEqual($new_js, $original_js + array($expected['js'] => 1), format_string('Page state now has the %js file.', array('%js' => $expected['js'])));
+ // @todo Uncomment this assertion after fixing http://drupal.org/node/1941288.
+ //$this->assertEqual($new_js, $original_js + array($expected['js'] => 1), format_string('Page state now has the %js file.', array('%js' => $expected['js'])));
$this->assertCommand(array_slice($commands, 2, 1), array('data' => $expected_js_html), format_string('Page now has the %js file.', array('%js' => $expected['js'])));
}
@@ -189,7 +191,7 @@ function testLazyLoadOverriddenCSS() {
// The test theme overrides system.module.css without an implementation,
// thereby removing it.
theme_enable(array('test_theme'));
- \Drupal::config('system.theme')
+ config('system.theme')
->set('default', 'test_theme')
->save();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Batch/PageTest.php b/core/modules/system/lib/Drupal/system/Tests/Batch/PageTest.php
index f268e02..be6bcef 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Batch/PageTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Batch/PageTest.php
@@ -35,11 +35,11 @@ public static function getInfo() {
function testBatchProgressPageTheme() {
// Make sure that the page which starts the batch (an administrative page)
// is using a different theme than would normally be used by the batch API.
- \Drupal::config('system.theme')
+ config('system.theme')
->set('default', 'bartik')
->save();
theme_enable(array('seven'));
- \Drupal::config('system.theme')->set('admin', 'seven')->save();
+ config('system.theme')->set('admin', 'seven')->save();
// Log in as an administrator who can see the administrative theme.
$admin_user = $this->drupalCreateUser(array('view the administration theme'));
$this->drupalLogin($admin_user);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php
index 89d8ff4..ca2d7b3 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php
@@ -7,7 +7,6 @@
namespace Drupal\system\Tests\Bootstrap;
-use Symfony\Component\Routing\RequestContext;
use Drupal\simpletest\WebTestBase;
/**
@@ -35,44 +34,17 @@ public static function getInfo() {
function setUp() {
parent::setUp();
- \Drupal::config('system.site')
+ config('system.site')
->set('name', 'Drupal')
->set('page.front', 'test-page')
->save();
}
/**
- * Tests support for different cache items with different Accept headers.
- */
- function testAcceptHeaderRequests() {
- $config = \Drupal::config('system.performance');
- $config->set('cache.page.use_internal', 1);
- $config->set('cache.page.max_age', 300);
- $config->save();
-
- $url_generator = \Drupal::urlGenerator();
- $url_generator->setContext(new RequestContext());
- $accept_header_cache_uri = $url_generator->getPathFromRoute('system_test.page_cache_accept_header');
- $json_accept_header = array('Accept: application/json');
-
- $this->drupalGet($accept_header_cache_uri);
- $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'HTML page was not yet cached.');
- $this->drupalGet($accept_header_cache_uri);
- $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'HTML page was cached.');
- $this->assertRaw('oh hai this is html.
', 'The correct HTML response was returned.');
-
- $this->drupalGet($accept_header_cache_uri, array(), $json_accept_header);
- $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Json response was not yet cached.');
- $this->drupalGet($accept_header_cache_uri, array(), $json_accept_header);
- $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Json response was cached.');
- $this->assertRaw('{"content":"oh hai this is json"}', 'The correct Json response was returned.');
- }
-
- /**
* Tests support of requests with If-Modified-Since and If-None-Match headers.
*/
function testConditionalRequests() {
- $config = \Drupal::config('system.performance');
+ $config = config('system.performance');
$config->set('cache.page.use_internal', 1);
$config->set('cache.page.max_age', 300);
$config->save();
@@ -117,7 +89,7 @@ function testConditionalRequests() {
* Tests cache headers.
*/
function testPageCache() {
- $config = \Drupal::config('system.performance');
+ $config = config('system.performance');
$config->set('cache.page.use_internal', 1);
$config->set('cache.page.max_age', 300);
$config->set('response.gzip', 1);
@@ -177,7 +149,7 @@ function testPageCache() {
* mod_deflate Apache module.
*/
function testPageCompression() {
- $config = \Drupal::config('system.performance');
+ $config = config('system.performance');
$config->set('cache.page.use_internal', 1);
$config->set('cache.page.max_age', 300);
$config->set('response.gzip', 1);
@@ -200,20 +172,7 @@ function testPageCompression() {
$this->drupalGet('');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
$this->assertFalse($this->drupalGetHeader('Content-Encoding'), 'A Content-Encoding header was not sent.');
- $this->assertTitle(t('Test page | @site-name', array('@site-name' => \Drupal::config('system.site')->get('name'))), 'Site title matches.');
+ $this->assertTitle(t('Test page | @site-name', array('@site-name' => config('system.site')->get('name'))), 'Site title matches.');
$this->assertRaw('', 'Page was not compressed.');
-
- // Disable compression mode.
- $config->set('response.gzip', 0);
- $config->save();
-
- // Verify if cached page is still available for a client with compression support.
- $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate'));
- $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8)));
- $this->assertRaw('