Browse Source

Merge branch '3.next' into 4.x

ADmad 7 years ago
parent
commit
38aff204ea

+ 2 - 0
src/Database/Schema/Collection.php

@@ -74,6 +74,8 @@ class Collection implements CollectionInterface
     /**
      * Get the column metadata for a table.
      *
+     * The name can include a database schema name in the form 'schema.table'.
+     *
      * Caching will be applied if `cacheMetadata` key is present in the Connection
      * configuration options. Defaults to _cake_model_ when true.
      *

+ 1 - 1
src/I18n/PluralRules.php

@@ -119,7 +119,7 @@ class PluralRules
         'th' => 0,
         'ti' => 2,
         'tk' => 1,
-        'tr' => 0,
+        'tr' => 1,
         'uk' => 3,
         'ur' => 1,
         'vi' => 0,

+ 5 - 0
src/ORM/Table.php

@@ -343,6 +343,9 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
     /**
      * Sets the database table name.
      *
+     * This can include the database schema name in the form 'schema.table'.
+     * If the name must be quoted, enable automatic identifier quoting.
+     *
      * @param string $table Table name.
      * @return $this
      */
@@ -356,6 +359,8 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
     /**
      * Returns the database table name.
      *
+     * This can include the database schema name if set using `setTable()`.
+     *
      * @return string
      */
     public function getTable(): string

+ 12 - 5
src/ORM/TableRegistry.php

@@ -26,12 +26,15 @@ use Cake\ORM\Locator\LocatorInterface;
  *
  * ### Configuring instances
  *
- * You may need to configure your table objects, using TableRegistry you can
+ * You may need to configure your table objects. Using the `TableLocator` you can
  * centralize configuration. Any configuration set before instances are created
  * will be used when creating instances. If you modify configuration after
  * an instance is made, the instances *will not* be updated.
  *
  * ```
+ * TableRegistry::getTableLocator()->setConfig('Users', ['table' => 'my_users']);
+ *
+ * // Prior to 3.6.0
  * TableRegistry::config('Users', ['table' => 'my_users']);
  * ```
  *
@@ -40,12 +43,16 @@ use Cake\ORM\Locator\LocatorInterface;
  *
  * ### Getting instances
  *
- * You can fetch instances out of the registry using get(). One instance is stored
- * per alias. Once an alias is populated the same instance will always be returned.
- * This is used to make the ORM use less memory and help make cyclic references easier
- * to solve.
+ * You can fetch instances out of the registry through the `TableLocator`.
+ * {@link TableLocator::get()}
+ * One instance is stored per alias. Once an alias is populated the same
+ * instance will always be returned. This reduces the ORM memory cost and
+ * helps make cyclic references easier to solve.
  *
  * ```
+ * $table = TableRegistry::getTableLocator()->get('Users', $config);
+ *
+ * // Prior to 3.6.0
  * $table = TableRegistry::get('Users', $config);
  * ```
  */

+ 8 - 7
src/View/Cell.php

@@ -180,12 +180,6 @@ abstract class Cell implements EventDispatcherInterface
 
             $builder = $this->viewBuilder();
 
-            if ($template !== null &&
-                strpos($template, '/') === false &&
-                strpos($template, '.') === false
-            ) {
-                $template = Inflector::underscore($template);
-            }
             if ($template !== null) {
                 $builder->setTemplate($template);
             }
@@ -205,7 +199,14 @@ abstract class Cell implements EventDispatcherInterface
             try {
                 return $view->render($template, false);
             } catch (MissingTemplateException $e) {
-                throw new MissingCellTemplateException($name, $template, $e->getAttributes()['paths'], null, $e);
+                $attributes = $e->getAttributes();
+                throw new MissingCellTemplateException(
+                    $name,
+                    basename($attributes['file']),
+                    $attributes['paths'],
+                    null,
+                    $e
+                );
             }
         };
 

+ 4 - 6
templates/Error/missing_cell_template.php

@@ -12,31 +12,29 @@
  * @since         3.0.0
  * @license       https://opensource.org/licenses/mit-license.php MIT License
  */
-use Cake\Utility\Inflector;
-
 $this->layout = 'dev_error';
 
 $this->assign('templateName', 'missing_cell_view.php');
 $this->assign('title', 'Missing Cell View');
 
 $this->start('subheading');
-printf('The view for <em>%sCell</em> was not be found.', h(Inflector::camelize($name)));
+printf('The view for <em>%sCell</em> was not be found.', h($name));
 $this->end();
 
 $this->start('file');
 ?>
 <p>
-    Confirm you have created the file: "<?= h($file . $this->_ext) ?>"
+    Confirm you have created the file: "<?= h($file) ?>"
     in one of the following paths:
 </p>
 <ul>
 <?php
     $paths = $this->_paths($this->plugin);
-    foreach ($paths as $path):
+    foreach ($paths as $path) :
         if (strpos($path, CORE_PATH) !== false) {
             continue;
         }
-        echo sprintf('<li>%sCell/%s/%s</li>', h($path), h($name), h($file . $this->_ext));
+        echo sprintf('<li>%sCell/%s/%s</li>', h($path), h($name), h($file));
     endforeach;
 ?>
 </ul>

+ 3 - 0
tests/TestCase/I18n/PluralRulesTest.php

@@ -117,6 +117,9 @@ class PluralRulesTest extends TestCase
             ['cy', 10, 2],
             ['cy', 11, 3],
             ['cy', 8, 3],
+            ['tr', 0, 1],
+            ['tr', 1, 0],
+            ['tr', 2, 1],
         ];
     }
 

+ 2 - 2
tests/TestCase/View/CellTest.php

@@ -203,13 +203,13 @@ class CellTest extends TestCase
 
         $e = null;
         try {
-            $cell->render('derp');
+            $cell->render('fooBar');
         } catch (MissingCellTemplateException $e) {
         }
 
         $this->assertNotNull($e);
         $message = $e->getMessage();
-        $this->assertStringContainsString("Cell template file 'derp' could not be found.", $message);
+        $this->assertStringContainsString("Cell template file 'foo_bar.php' could not be found.", $message);
         $this->assertStringContainsString('The following paths', $message);
         $this->assertStringContainsString(ROOT . DS . 'templates', $message);
         $this->assertInstanceOf(MissingTemplateException::class, $e->getPrevious());