Browse Source

Add BC layer for WidgetRegistry

Raúl Arellano 8 years ago
parent
commit
fa8ca66b6e
2 changed files with 39 additions and 0 deletions
  1. 21 0
      src/View/Helper/FormHelper.php
  2. 18 0
      src/View/Widget/WidgetRegistry.php

+ 21 - 0
src/View/Helper/FormHelper.php

@@ -25,6 +25,7 @@ use Cake\View\Helper;
 use Cake\View\StringTemplateTrait;
 use Cake\View\View;
 use Cake\View\Widget\WidgetLocator;
+use Cake\View\Widget\WidgetRegistry;
 use DateTime;
 use RuntimeException;
 use Traversable;
@@ -262,6 +263,11 @@ class FormHelper extends Helper
     {
         $locator = null;
         $widgets = $this->_defaultWidgets;
+        if (isset($config['registry'])) {
+            deprecationWarning('`registry` config key is deprecated in FormHelper, use `locator` instead.');
+            $config['locator'] = $config['registry'];
+            unset($config['registry']);
+        }
         if (isset($config['locator'])) {
             $locator = $config['locator'];
             unset($config['locator']);
@@ -283,6 +289,21 @@ class FormHelper extends Helper
     /**
      * Set the widget registry the helper will use.
      *
+     * @param \Cake\View\Widget\WidgetRegistry|null $instance The registry instance to set.
+     * @param array $widgets An array of widgets
+     * @return \Cake\View\Widget\WidgetRegistry
+     * @deprecated 3.6.0 Use FormHelper::widgetLocator() instead.
+     */
+    public function widgetRegistry(WidgetRegistry $instance = null, $widgets = [])
+    {
+        deprecationWarning('widgetRegistry is deprecated, use widgetLocator instead.');
+
+        return $this->widgetLocator($instance, $widgets);
+    }
+
+    /**
+     * Set the widget registry the helper will use.
+     *
      * @param \Cake\View\Widget\WidgetLocator|null $instance The locator instance to set.
      * @param array $widgets An array of widgets
      * @return \Cake\View\Widget\WidgetLocator

+ 18 - 0
src/View/Widget/WidgetRegistry.php

@@ -0,0 +1,18 @@
+<?php
+/**
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
+ * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
+ *
+ * Licensed under The MIT License
+ * For full copyright and license information, please see the LICENSE.txt
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
+ * @link          https://cakephp.org CakePHP(tm) Project
+ * @since         3.0.0
+ * @license       https://opensource.org/licenses/mit-license.php MIT License
+ */
+// @deprecated Add backwards compat alias.
+class_alias('Cake\View\Widget\WidgetLocator', 'Cake\View\Widget\WidgetRegistry');
+
+deprecationWarning('Use Cake\View\Widget\WidgetLocator instead of Cake\View\Widget\WidgetRegistry.');