comparison core/includes/common.inc @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 1fec387a4317
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
146 * parameter, if present. This can be either a relative or absolute URL. 146 * parameter, if present. This can be either a relative or absolute URL.
147 * However, for security, redirection to external URLs is not performed. 147 * However, for security, redirection to external URLs is not performed.
148 * If the query parameter isn't present, then the URL of the current 148 * If the query parameter isn't present, then the URL of the current
149 * request is returned. 149 * request is returned.
150 * 150 *
151 * @see \Drupal\Core\EventSubscriber\RedirectResponseSubscriber::checkRedirectUrl()
152 *
153 * @ingroup form_api 151 * @ingroup form_api
154 * 152 *
155 * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. 153 * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
156 * Use the redirect.destination service. 154 * Use the redirect.destination service.
155 *
156 * @see \Drupal\Core\EventSubscriber\RedirectResponseSubscriber::checkRedirectUrl()
157 * @see https://www.drupal.org/node/2448603
157 */ 158 */
158 function drupal_get_destination() { 159 function drupal_get_destination() {
159 return \Drupal::destination()->getAsArray(); 160 return \Drupal::destination()->getAsArray();
160 } 161 }
161 162
174 * @return bool 175 * @return bool
175 * TRUE if the address is in a valid format. 176 * TRUE if the address is in a valid format.
176 * 177 *
177 * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. 178 * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
178 * Use \Drupal::service('email.validator')->isValid(). 179 * Use \Drupal::service('email.validator')->isValid().
180 *
181 * @see https://www.drupal.org/node/2912661
179 */ 182 */
180 function valid_email_address($mail) { 183 function valid_email_address($mail) {
181 return \Drupal::service('email.validator')->isValid($mail); 184 return \Drupal::service('email.validator')->isValid($mail);
182 } 185 }
183 186
207 * because Drupal\Core\Template\Attribute expects those values to be 210 * because Drupal\Core\Template\Attribute expects those values to be
208 * plain-text strings. To pass a filtered URI to 211 * plain-text strings. To pass a filtered URI to
209 * Drupal\Core\Template\Attribute, call 212 * Drupal\Core\Template\Attribute, call
210 * \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() instead. 213 * \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() instead.
211 * 214 *
212 * @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols()
213 * @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol()
214 *
215 * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. 215 * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
216 * Use UrlHelper::stripDangerousProtocols() or UrlHelper::filterBadProtocol() 216 * Use UrlHelper::stripDangerousProtocols() or UrlHelper::filterBadProtocol()
217 * instead. UrlHelper::stripDangerousProtocols() can be used in conjunction 217 * instead. UrlHelper::stripDangerousProtocols() can be used in conjunction
218 * with \Drupal\Component\Utility\SafeMarkup::format() and an @variable 218 * with \Drupal\Component\Utility\SafeMarkup::format() and an @variable
219 * placeholder which will perform the necessary escaping. 219 * placeholder which will perform the necessary escaping.
220 * UrlHelper::filterBadProtocol() is functionality equivalent to check_url() 220 * UrlHelper::filterBadProtocol() is functionality equivalent to check_url()
221 * apart from the fact it is protected from double escaping bugs. Note that 221 * apart from the fact it is protected from double escaping bugs. Note that
222 * this method no longer marks its output as safe. 222 * this method no longer marks its output as safe.
223 *
224 * @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols()
225 * @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol()
226 * @see https://www.drupal.org/node/2560027
223 */ 227 */
224 function check_url($uri) { 228 function check_url($uri) {
225 return Html::escape(UrlHelper::stripDangerousProtocols($uri)); 229 return Html::escape(UrlHelper::stripDangerousProtocols($uri));
226 } 230 }
227 231
313 * display the page. 317 * display the page.
314 * 318 *
315 * @return 319 * @return
316 * A translated date string in the requested format. 320 * A translated date string in the requested format.
317 * 321 *
318 * @see \Drupal\Core\Datetime\DateFormatter::format()
319 *
320 * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. 322 * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
321 * Use \Drupal::service('date.formatter')->format(). 323 * Use \Drupal::service('date.formatter')->format().
324 *
325 * @see \Drupal\Core\Datetime\DateFormatter::format()
326 * @see https://www.drupal.org/node/1876852
322 */ 327 */
323 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) { 328 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
324 return \Drupal::service('date.formatter')->format($timestamp, $type, $format, $timezone, $langcode); 329 return \Drupal::service('date.formatter')->format($timestamp, $type, $format, $timezone, $langcode);
325 } 330 }
326 331
418 /** 423 /**
419 * Deletes old cached CSS files. 424 * Deletes old cached CSS files.
420 * 425 *
421 * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. 426 * @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
422 * Use \Drupal\Core\Asset\AssetCollectionOptimizerInterface::deleteAll(). 427 * Use \Drupal\Core\Asset\AssetCollectionOptimizerInterface::deleteAll().
428 *
429 * @see https://www.drupal.org/node/2317841
423 */ 430 */
424 function drupal_clear_css_cache() { 431 function drupal_clear_css_cache() {
425 \Drupal::service('asset.css.collection_optimizer')->deleteAll(); 432 \Drupal::service('asset.css.collection_optimizer')->deleteAll();
426 } 433 }
427 434
735 /** 742 /**
736 * Deletes old cached JavaScript files and variables. 743 * Deletes old cached JavaScript files and variables.
737 * 744 *
738 * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. 745 * @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
739 * Use \Drupal\Core\Asset\AssetCollectionOptimizerInterface::deleteAll(). 746 * Use \Drupal\Core\Asset\AssetCollectionOptimizerInterface::deleteAll().
747 *
748 * @see https://www.drupal.org/node/2317841
740 */ 749 */
741 function drupal_clear_js_cache() { 750 function drupal_clear_js_cache() {
742 \Drupal::service('asset.js.collection_optimizer')->deleteAll(); 751 \Drupal::service('asset.js.collection_optimizer')->deleteAll();
743 } 752 }
744 753
852 * 861 *
853 * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use the 862 * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use the
854 * 'renderer' service instead. 863 * 'renderer' service instead.
855 * 864 *
856 * @see \Drupal\Core\Render\RendererInterface::renderRoot() 865 * @see \Drupal\Core\Render\RendererInterface::renderRoot()
866 * @see https://www.drupal.org/node/2912696
857 */ 867 */
858 function drupal_render_root(&$elements) { 868 function drupal_render_root(&$elements) {
859 return \Drupal::service('renderer')->renderRoot($elements); 869 return \Drupal::service('renderer')->renderRoot($elements);
860 } 870 }
861 871
864 * 874 *
865 * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use the 875 * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use the
866 * 'renderer' service instead. 876 * 'renderer' service instead.
867 * 877 *
868 * @see \Drupal\Core\Render\RendererInterface::render() 878 * @see \Drupal\Core\Render\RendererInterface::render()
879 * @see https://www.drupal.org/node/2912696
869 */ 880 */
870 function drupal_render(&$elements, $is_recursive_call = FALSE) { 881 function drupal_render(&$elements, $is_recursive_call = FALSE) {
871 return \Drupal::service('renderer')->render($elements, $is_recursive_call); 882 return \Drupal::service('renderer')->render($elements, $is_recursive_call);
872 } 883 }
873 884
887 * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Avoid early 898 * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Avoid early
888 * rendering when possible or loop through the elements and render them as 899 * rendering when possible or loop through the elements and render them as
889 * they are available. 900 * they are available.
890 * 901 *
891 * @see drupal_render() 902 * @see drupal_render()
903 * @see https://www.drupal.org/node/2912757
892 */ 904 */
893 function drupal_render_children(&$element, $children_keys = NULL) { 905 function drupal_render_children(&$element, $children_keys = NULL) {
894 if ($children_keys === NULL) { 906 if ($children_keys === NULL) {
895 $children_keys = Element::children($element); 907 $children_keys = Element::children($element);
896 } 908 }
1000 * @param $type 1012 * @param $type
1001 * An element type as defined by an element plugin. 1013 * An element type as defined by an element plugin.
1002 * 1014 *
1003 * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. 1015 * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
1004 * Use \Drupal::service('element_info')->getInfo() instead. 1016 * Use \Drupal::service('element_info')->getInfo() instead.
1017 *
1018 * @see https://www.drupal.org/node/2235461
1005 */ 1019 */
1006 function element_info($type) { 1020 function element_info($type) {
1007 return \Drupal::service('element_info')->getInfo($type); 1021 return \Drupal::service('element_info')->getInfo($type);
1008 } 1022 }
1009 1023
1018 * (Optional) The value to return if the element type does not specify a 1032 * (Optional) The value to return if the element type does not specify a
1019 * value for the property. Defaults to NULL. 1033 * value for the property. Defaults to NULL.
1020 * 1034 *
1021 * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. 1035 * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
1022 * Use \Drupal::service('element_info')->getInfoProperty() instead. 1036 * Use \Drupal::service('element_info')->getInfoProperty() instead.
1037 *
1038 * @see https://www.drupal.org/node/2235461
1023 */ 1039 */
1024 function element_info_property($type, $property_name, $default = NULL) { 1040 function element_info_property($type, $property_name, $default = NULL) {
1025 return \Drupal::service('element_info')->getInfoProperty($type, $property_name, $default); 1041 return \Drupal::service('element_info')->getInfoProperty($type, $property_name, $default);
1026 } 1042 }
1027 1043
1110 $theme_handler->refreshInfo(); 1126 $theme_handler->refreshInfo();
1111 // In case the active theme gets requested later in the same request we need 1127 // In case the active theme gets requested later in the same request we need
1112 // to reset the theme manager. 1128 // to reset the theme manager.
1113 \Drupal::theme()->resetActiveTheme(); 1129 \Drupal::theme()->resetActiveTheme();
1114 1130
1115
1116 // Rebuild and reboot a new kernel. A simple DrupalKernel reboot is not 1131 // Rebuild and reboot a new kernel. A simple DrupalKernel reboot is not
1117 // sufficient, since the list of enabled modules might have been adjusted 1132 // sufficient, since the list of enabled modules might have been adjusted
1118 // above due to changed code. 1133 // above due to changed code.
1119 $files = []; 1134 $files = [];
1120 foreach ($module_data as $name => $extension) { 1135 foreach ($module_data as $name => $extension) {