Browse Source

Remove deprecations.

mscherer 7 years ago
parent
commit
b47190a48b

+ 1 - 1
docs/Behavior/Passwordable.md

@@ -109,7 +109,7 @@ use Tools\Controller\Controller;
 class UsersController extends Controller {
 
 	public function edit() {
-		$uid = $this->request->session()->read('Auth.User.id');
+		$uid = $this->request->getSession()->read('Auth.User.id');
 		$user = $this->Users->get($uid);
 		$this->Users->addBehavior('Tools.Passwordable', ['require' => false]);
 

+ 2 - 2
docs/Behavior/Reset.md

@@ -67,11 +67,11 @@ $this->out('Done: ' . $res);
 The callback method (in this case just statically, as we didnt want to mess with the model itself):
 ```php
 public static function prepMessage(array $row) {
-    if (empty($row['Message']['data_array']['GUEST_FIRST_NAME'])) {
+    if (empty($row['data_array']['GUEST_FIRST_NAME'])) {
         return [];
     }
 
-    $row['Message']['guest_name'] = $row['Message']['data_array']['GUEST_FIRST_NAME'] . ' ' . $row['Message']['data_array']['GUEST_LAST_NAME'];
+    $row['guest_name'] = $row['data_array']['GUEST_FIRST_NAME'] . ' ' . $row['data_array']['GUEST_LAST_NAME'];
     return $row;
 }
 ```

+ 6 - 5
docs/I18n/I18n.md

@@ -10,7 +10,7 @@ Set up a default language in your configs:
 		'language' => 'de',
 	],
 ```
-Any `Configure::read('Config.language')` or `I18n::locale()` call should return that default language.
+Any `Configure::read('Config.language')` or `I18n::getLocale()` call should return that default language.
 
 
 ## Detecting the user language
@@ -36,7 +36,7 @@ In your AppController you can now do:
 		parent::initialize();
 
 		// First check the session
-		$language = $this->request->session()->read('Config.language');
+		$language = $this->request->getSession()->read('Config.language');
 		// Then check the browser preference for the whitelisted languages
 		if (!$language) {
 			$language = Language::findFirstMatch(Configure::read('Config.supportedLanguages'));
@@ -44,18 +44,18 @@ In your AppController you can now do:
 		// Overwrite the system default
 		if ($language) {
 			Configure::write('Config.language', substr($language, 0, 2));
-			I18n::locale($language);
+			I18n::setLocale($language);
 		}
 ```
 
 You then just need a switch on the website that allows the other to change the language (by writing it into the session):
 ```php
-<?php if (Configure::read('Config.language') === 'de') {
+<?php if ($this->Configure->read('Config.language') === 'de') {
 	echo $this->Html->image('flag_de.png', ['title' => __('German')]);
 } else {
 	echo $this->Form->postLink($this->Html->image('flag_de.png'), ['prefix' => false, 'plugin' => 'Tools', 'controller' => 'ShuntRequest', 'action' => 'language', 'de'], ['block' => true, 'escape' => false, 'title' => __('German')]);
 } ?>
-<?php if (Configure::read('Config.language') === 'en') {
+<?php if ($this->Configure->read('Config.language') === 'en') {
 	echo $this->Html->image('flag_en.png', ['title' => __('English')]);
 } else {
 	echo $this->Form->postLink($this->Html->image('flag_en.png'), ['prefix' => false, 'plugin' => 'Tools', 'controller' => 'ShuntRequest', 'action' => 'language', 'en'], ['block' => true, 'escape' => false, 'title' => __('English')]);
@@ -63,6 +63,7 @@ You then just need a switch on the website that allows the other to change the l
 ```
 
 Make sure you included the routes for the Tools plugin for this to work or set them up manually in the `src/Config/routes.php` file.
+This example also uses [Shim.Configure helper](https://github.com/dereuromark/cakephp-shim) to avoid use statements.
 
 
 ## Using language in URLs

+ 3 - 3
src/Controller/Component/MobileComponent.php

@@ -99,10 +99,10 @@ class MobileComponent extends Component {
 
 		if ($mobileOverwrite !== null) {
 			if ($mobileOverwrite === '-1') {
-				$this->request->session()->delete('User.mobile');
+				$this->request->getSession()->delete('User.mobile');
 			} else {
 				$wantsMobile = (bool)$mobileOverwrite;
-				$this->request->session()->write('User.mobile', (int)$wantsMobile);
+				$this->request->getSession()->write('User.mobile', (int)$wantsMobile);
 			}
 		}
 		$this->isMobile();
@@ -125,7 +125,7 @@ class MobileComponent extends Component {
 		if ($this->isMobile === null) {
 			$this->isMobile();
 		}
-		$forceMobile = $this->request->session()->read('User.mobile');
+		$forceMobile = $this->request->getSession()->read('User.mobile');
 
 		if ($forceMobile !== null && !$forceMobile) {
 			$this->setMobile = false;

+ 3 - 2
src/Controller/ShuntRequestController.php

@@ -27,6 +27,7 @@ class ShuntRequestController extends AppController {
 	 *
 	 * @param string|null $language
 	 * @return \Cake\Http\Response
+	 * @throws \RuntimeException
 	 */
 	public function language($language = null) {
 		$this->request->allowMethod(['post']);
@@ -45,8 +46,8 @@ class ShuntRequestController extends AppController {
 		}
 		$language = $allowedLanguages[$language];
 
-		$this->request->session()->write('Config.language', $language['locale']);
-		I18n::locale($language['locale']);
+		$this->request->getSession()->write('Config.language', $language['locale']);
+		I18n::setLocale($language['locale']);
 		$this->Flash->success(__d('tools', 'Language switched to {0}', $language['name']));
 		return $this->redirect($this->referer('/', true));
 	}

+ 3 - 3
src/Mailer/Mailer.php

@@ -35,11 +35,11 @@ class Mailer extends CakeMailer {
 	 * @return void
 	 */
 	protected function fixateLocale() {
-		$this->locale = I18n::locale();
+		$this->locale = I18n::getLocale();
 
 		$primaryLocale = $this->getPrimaryLocale();
 		if ($primaryLocale && $primaryLocale !== $this->locale) {
-			I18n::locale($primaryLocale);
+			I18n::setLocale($primaryLocale);
 		}
 	}
 
@@ -51,7 +51,7 @@ class Mailer extends CakeMailer {
 	protected function restoreLocale() {
 		$primaryLocale = $this->getPrimaryLocale();
 		if ($primaryLocale && $primaryLocale !== $this->locale) {
-			I18n::locale($this->locale);
+			I18n::setLocale($this->locale);
 		}
 	}
 

+ 5 - 5
tests/TestCase/Model/Behavior/SluggedBehaviorTest.php

@@ -158,13 +158,13 @@ class SluggedBehaviorTest extends TestCase {
 	}
 
 	/**
-	 * Test that fieldList doesnt mess with slug storing.
+	 * Test that fields doesnt mess with slug storing.
 	 *
 	 * @return void
 	 */
-	public function testFieldList() {
+	public function testFields() {
 		// field list is only relevant for newEntity(), not for what the behavior does
-		$entity = $this->articles->newEntity(['title' => 'Some title'], ['fieldList' => ['title']]);
+		$entity = $this->articles->newEntity(['title' => 'Some title'], ['fields' => ['title']]);
 
 		$result = $this->articles->save($entity);
 		$this->assertEquals('Some-title', $result->get('slug'));
@@ -177,7 +177,7 @@ class SluggedBehaviorTest extends TestCase {
 	 */
 	public function testNeedsSlugUpdate() {
 		// No title change
-		$entity = $this->articles->newEntity(['title' => 'Some title'], ['fieldList' => []]);
+		$entity = $this->articles->newEntity(['title' => 'Some title'], ['fields' => []]);
 		$result = $this->articles->needsSlugUpdate($entity);
 		$this->assertFalse($result);
 
@@ -614,7 +614,7 @@ class SluggedBehaviorTest extends TestCase {
 	 */
 	public function testSlugGenerationWithVirualField() {
 		$this->articles->removeBehavior('Slugged');
-		$this->articles->entityClass('\App\Model\Entity\SluggedArticle');
+		$this->articles->setEntityClass('\App\Model\Entity\SluggedArticle');
 		$this->articles->addBehavior('Tools.Slugged', [
 			'label' => [
 				'title',

+ 1 - 1
tests/TestCase/Model/Table/TableTest.php

@@ -54,7 +54,7 @@ class TableTest extends TestCase {
 		$is = $this->Users->find('count');
 		$this->assertEquals(4, $is);
 
-		$config = ConnectionManager::config('test');
+		$config = ConnectionManager::getConfig('test');
 		if ((strpos($config['driver'], 'Mysql') !== false)) {
 			$is = $this->Users->getNextAutoIncrement();
 			$this->assertEquals(5, $is);