Browse Source

Remove deprecations.

mscherer 7 years ago
parent
commit
6b20e9fbc2

+ 1 - 1
README.md

@@ -11,7 +11,7 @@ A CakePHP plugin containing several useful tools that can be used in many projec
 
 ## Version notice
 
-This master branch only works for **CakePHP 3.5+** - please use the 2.x branch for CakePHP 2.x!
+This master branch only works for **CakePHP 3.6+** - please use the 2.x branch for CakePHP 2.x!
 
 ## What is this plugin for?
 

+ 1 - 1
composer.json

@@ -14,7 +14,7 @@
 	],
 	"require":{
 		"php": ">=5.6",
-		"cakephp/cakephp": "^3.5.10",
+		"cakephp/cakephp": "^3.6.0",
 		"dereuromark/cakephp-shim": "^1.6"
 	},
 	"require-dev":{

+ 1 - 1
src/Auth/MultiColumnAuthenticate.php

@@ -12,7 +12,7 @@ use Cake\ORM\TableRegistry;
  * can be checked against multiple table columns, for instance username and email
  *
  * ```
- *    $this->Auth->config('authenticate', [
+ *    $this->Auth->setConfig('authenticate', [
  *        'Tools.MultiColumn' => [
  *            'fields' => [
  *                'username' => 'login',

+ 1 - 1
src/Model/Behavior/BitmaskedBehavior.php

@@ -357,7 +357,7 @@ class BitmaskedBehavior extends Behavior {
 		$contain = Text::insert($contain, [$bitmask, $bitmask]);
 
 		// Hack for Postgres for now
-		$connection = $this->_table->connection();
+		$connection = $this->_table->getConnection();
 		$config = $connection->config();
 		if ((strpos($config['driver'], 'Postgres') !== false)) {
 			return ['("' . $this->_table->getAlias() . '"."' . $field . '"' . $contain . ')'];

+ 5 - 5
src/Model/Behavior/ResetBehavior.php

@@ -108,7 +108,7 @@ class ResetBehavior extends Behavior {
 		if (!$this->_config['updateTimestamp']) {
 			$fields = ['modified', 'updated'];
 			foreach ($fields as $field) {
-				if ($this->_table->schema()->column($field)) {
+				if ($this->_table->getSchema()->getColumn($field)) {
 					$defaults['fields'][] = $field;
 					$updateFields[] = $field;
 					break;
@@ -127,14 +127,14 @@ class ResetBehavior extends Behavior {
 		while (($records = $this->_table->find('all', $params)->toArray())) {
 			foreach ($records as $record) {
 				$fieldList = $params['fields'];
-				if ($this->config('updateFields')) {
-					$fieldList = $this->config('updateFields');
+				if ($this->getConfig('updateFields')) {
+					$fieldList = $this->getConfig('updateFields');
 					if (!$this->_config['updateTimestamp']) {
 						$fieldList = array_merge($updateFields, $fieldList);
 					}
 				}
-				if ($fieldList && !in_array($this->_table->primaryKey(), $fieldList)) {
-					$fieldList[] = $this->_table->primaryKey();
+				if ($fieldList && !in_array($this->_table->getPrimaryKey(), $fieldList)) {
+					$fieldList[] = $this->_table->getPrimaryKey();
 				}
 
 				if ($this->_config['callback']) {

+ 7 - 7
src/Model/Behavior/SluggedBehavior.php

@@ -354,8 +354,8 @@ class SluggedBehavior extends Behavior {
 		$defaults = [
 			'page' => 1,
 			'limit' => 100,
-			'fields' => array_merge([$this->_table->primaryKey()], $this->_config['label']),
-			'order' => $this->_table->displayField() . ' ASC',
+			'fields' => array_merge([$this->_table->getPrimaryKey()], $this->_config['label']),
+			'order' => $this->_table->getDisplayField() . ' ASC',
 			'conditions' => $this->_config['scope'],
 			'overwrite' => true,
 		];
@@ -366,17 +366,17 @@ class SluggedBehavior extends Behavior {
 			set_time_limit(max($max, $count / 100));
 		}
 
-		$this->config($params, null, false);
+		$this->setConfig($params, null, false);
 		while (($records = $this->_table->find('all', $params)->toArray())) {
 			/** @var \Cake\ORM\Entity $record */
 			foreach ($records as $record) {
 				$record->isNew(true);
 				$options = [
 					'validate' => true,
-					'fieldList' => array_merge([$this->_table->primaryKey(), $this->_config['field']], $this->_config['label'])
+					'fieldList' => array_merge([$this->_table->getPrimaryKey(), $this->_config['field']], $this->_config['label'])
 				];
 				if (!$this->_table->save($record, $options)) {
-					throw new RuntimeException(print_r($record->errors(), true));
+					throw new RuntimeException(print_r($record->getErrors(), true));
 				}
 			}
 			$params['page']++;
@@ -396,7 +396,7 @@ class SluggedBehavior extends Behavior {
 	 * @return void
 	 */
 	protected function _multiSlug(EntityInterface $entity) {
-		$label = $this->config('label');
+		$label = $this->getConfig('label');
 		$field = current($label);
 		$fields = (array)$entity->get($field);
 
@@ -412,7 +412,7 @@ class SluggedBehavior extends Behavior {
 
 			$locale[$locale] = $res;
 		}
-		$entity->set($this->config('slugField'), $locale);
+		$entity->set($this->getConfig('slugField'), $locale);
 	}
 
 	/**

+ 1 - 1
src/Model/Behavior/ToggleBehavior.php

@@ -151,7 +151,7 @@ class ToggleBehavior extends Behavior {
 	 * @return array
 	 */
 	protected function buildConditions(EntityInterface $entity) {
-		$conditions = $this->config('scope');
+		$conditions = $this->getConfig('scope');
 		$scopeFields = (array)$this->getConfig('scopeFields');
 		foreach ($scopeFields as $scopeField) {
 			$conditions[$scopeField] = $entity->get($scopeField);

+ 2 - 2
src/View/Helper/FormatHelper.php

@@ -282,7 +282,7 @@ class FormatHelper extends Helper {
 		$options += $defaults;
 
 		$type = $icon;
-		if ($this->config('autoPrefix') && empty($options['iconNamespace'])) {
+		if ($this->getConfig('autoPrefix') && empty($options['iconNamespace'])) {
 			$namespace = $this->detectNamespace($icon);
 			if ($namespace) {
 				$options['iconNamespace'] = $namespace;
@@ -308,7 +308,7 @@ class FormatHelper extends Helper {
 	 * @return string|null
 	 */
 	protected function detectNamespace($icon) {
-		foreach ((array)$this->config('iconNamespaces') as $namespace) {
+		foreach ((array)$this->getConfig('iconNamespaces') as $namespace) {
 			if (strpos($icon, $namespace . '-') !== 0) {
 				continue;
 			}

+ 1 - 1
tests/TestCase/Auth/MultiColumnAuthenticateTest.php

@@ -111,7 +111,7 @@ class MultiColumnAuthenticateTest extends TestCase {
 	 * @return void
 	 */
 	public function testAuthenticateScopeFail() {
-		$this->auth->config('scope', ['user_name' => 'nate']);
+		$this->auth->setConfig('scope', ['user_name' => 'nate']);
 		$request = new Request('posts/index');
 		$request->data = [
 			'user_name' => 'mariano',

+ 6 - 6
tests/TestCase/Controller/Component/MobileComponentTest.php

@@ -80,7 +80,7 @@ class MobileComponentTest extends TestCase {
 	 * @return void
 	 */
 	public function testMobileNotMobile() {
-		$this->Controller->Mobile->config('on', 'initialize');
+		$this->Controller->Mobile->setConfig('on', 'initialize');
 		$this->Controller->Mobile->initialize([]);
 		$this->assertFalse($this->Controller->Mobile->isMobile);
 	}
@@ -92,7 +92,7 @@ class MobileComponentTest extends TestCase {
 		$this->Controller->request->query['mobile'] = 1;
 
 		$this->Controller->Mobile->beforeFilter($this->event);
-		$session = $this->Controller->request->session()->read('User');
+		$session = $this->Controller->request->getSession()->read('User');
 		$this->assertSame(['mobile' => 1], $session);
 
 		$this->Controller->Mobile->setMobile();
@@ -110,7 +110,7 @@ class MobileComponentTest extends TestCase {
 		$this->Controller->request->query['mobile'] = 0;
 
 		$this->Controller->Mobile->beforeFilter($this->event);
-		$session = $this->Controller->request->session()->read('User');
+		$session = $this->Controller->request->getSession()->read('User');
 		$this->assertSame(['mobile' => 0], $session);
 
 		$this->Controller->Mobile->setMobile();
@@ -157,7 +157,7 @@ class MobileComponentTest extends TestCase {
 	 * @return void
 	 */
 	public function testMobileFakeMobileAuto() {
-		$this->Controller->Mobile->config('auto', true);
+		$this->Controller->Mobile->setConfig('auto', true);
 		$_SERVER['HTTP_USER_AGENT'] = 'Some Android device';
 
 		$this->Controller->Mobile->beforeFilter($this->event);
@@ -172,7 +172,7 @@ class MobileComponentTest extends TestCase {
 	 * @return void
 	 */
 	public function testMobileVendorEngineCake() {
-		$this->Controller->Mobile->config('engine', '');
+		$this->Controller->Mobile->setConfig('engine', '');
 		$_SERVER['HTTP_USER_AGENT'] = 'Some Android device';
 
 		$this->Controller->Mobile->beforeFilter($this->event);
@@ -217,7 +217,7 @@ class MobileComponentTest extends TestCase {
 		$closure = function() {
 			return $_SERVER['HTTP_USER_AGENT'] === 'Foo';
 		};
-		$this->Controller->Mobile->config('engine', $closure);
+		$this->Controller->Mobile->setConfig('engine', $closure);
 		$_SERVER['HTTP_USER_AGENT'] = 'Foo';
 
 		$this->Controller->Mobile->beforeFilter($this->event);

+ 1 - 1
tests/TestCase/Error/Middleware/ErrorHandlerMiddlewareTest.php

@@ -3,8 +3,8 @@
 namespace Tools\Test\TestCase\Error\Middleware;
 
 use Cake\Core\Configure;
+use Cake\Http\Exception\NotFoundException;
 use Cake\Http\ServerRequest;
-use Cake\Network\Exception\NotFoundException;
 use Tools\Error\Middleware\ErrorHandlerMiddleware;
 use Tools\TestSuite\TestCase;
 use Tools\TestSuite\ToolsTestTrait;

+ 2 - 2
tests/TestCase/Model/Behavior/BitmaskedBehaviorTest.php

@@ -225,7 +225,7 @@ class BitmaskedBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function testContains() {
-		$config = $this->Comments->connection()->config();
+		$config = $this->Comments->getConnection()->config();
 		$isPostgres = strpos($config['driver'], 'Postgres') !== false;
 
 		$res = $this->Comments->containsBit(BitmaskedComment::STATUS_PUBLISHED);
@@ -256,7 +256,7 @@ class BitmaskedBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function testNotContains() {
-		$config = $this->Comments->connection()->config();
+		$config = $this->Comments->getConnection()->config();
 		$isPostgres = strpos($config['driver'], 'Postgres') !== false;
 
 		$res = $this->Comments->containsNotBit(BitmaskedComment::STATUS_PUBLISHED);

+ 8 - 1
tests/TestCase/Model/Behavior/SluggedBehaviorTest.php

@@ -22,6 +22,11 @@ class SluggedBehaviorTest extends TestCase {
 	];
 
 	/**
+	 * @var \Cake\ORM\Table|\Tools\Model\Behavior\SluggedBehavior
+	 */
+	protected $articles;
+
+	/**
 	 * setup
 	 *
 	 * @return void
@@ -83,8 +88,10 @@ class SluggedBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function testAddUniqueMultipleLabels() {
+		/** @var \Tools\Model\Behavior\SluggedBehavior $sluggedBehavior */
+		$sluggedBehavior = $this->articles->behaviors()->Slugged;
 		//$this->articles->behaviors()->Slugged->config('label', ''); // Hack necessary right now to avoid title showing up twice
-		$this->articles->behaviors()->Slugged->configShallow(['mode' => 'ascii', 'unique' => true, 'label' => ['title', 'long_title']]);
+		$sluggedBehavior->configShallow(['mode' => 'ascii', 'unique' => true, 'label' => ['title', 'long_title']]);
 
 		$entity = $this->_getEntity(null, null, ['long_title' => 'blae']);
 		$result = $this->articles->save($entity);

+ 2 - 2
tests/TestCase/View/Helper/FormatHelperTest.php

@@ -92,7 +92,7 @@ class FormatHelperTest extends TestCase {
 	 * @return void
 	 */
 	public function testIconWithCustomFontIcon() {
-		$this->Format->config('fontIcons', ['edit' => 'fax fax-pen']);
+		$this->Format->setConfig('fontIcons', ['edit' => 'fax fax-pen']);
 		$result = $this->Format->icon('edit');
 		$expected = '<i class="icon icon-edit fax fax-pen" title="' . __d('tools', 'Edit') . '" data-placement="bottom" data-toggle="tooltip"></i>';
 		$this->assertEquals($expected, $result);
@@ -102,7 +102,7 @@ class FormatHelperTest extends TestCase {
 	 * @return void
 	 */
 	public function testIconWithPrefixedIcon() {
-		$this->Format->config('iconNamespaces', ['fa', 'glyphicon']);
+		$this->Format->setConfig('iconNamespaces', ['fa', 'glyphicon']);
 		$result = $this->Format->icon('glyphicon-foo');
 		$expected = '<i class="icon icon-glyphicon-foo glyphicon glyphicon-foo" title="' . __d('tools', 'Foo') . '" data-placement="bottom" data-toggle="tooltip"></i>';
 		$this->assertEquals($expected, $result);

+ 4 - 4
tests/bootstrap.php

@@ -37,8 +37,8 @@ Cake\Core\Configure::write('debug', true);
 Cake\Core\Configure::write('Config', [
 		'adminEmail' => 'test@example.com',
 		'adminName' => 'Mark']);
-Cake\Network\Email\Email::config('default', ['transport' => 'Debug']);
-Cake\Network\Email\Email::configTransport('Debug', [
+Cake\Mailer\Email::setConfig('default', ['transport' => 'Debug']);
+Cake\Mailer\Email::setConfigTransport('Debug', [
 		'className' => 'Debug'
 ]);
 
@@ -70,7 +70,7 @@ $cache = [
 	]
 ];
 
-Cake\Cache\Cache::config($cache);
+Cake\Cache\Cache::setConfig($cache);
 
 Cake\Core\Plugin::load('Tools', ['path' => ROOT . DS, 'bootstrap' => true]);
 
@@ -83,7 +83,7 @@ if (!getenv('db_class')) {
 	//putenv('db_dsn=postgres://postgres@127.0.0.1/test');
 }
 
-Cake\Datasource\ConnectionManager::config('test', [
+Cake\Datasource\ConnectionManager::setConfig('test', [
 	'className' => 'Cake\Database\Connection',
 	'driver' => getenv('db_class'),
 	'dsn' => getenv('db_dsn'),