Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated methods #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2

install:
- composer self-update
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CakeSoftDelete plugin for CakePHP

[![Build status](https://api.travis-ci.org/PGBI/cakephp3-soft-delete.png?branch=master)](https://travis-ci.org/PGBI/cakephp3-soft-delete)
[![Build status](https://api.travis-ci.org/fredckl/cakephp3-soft-delete.png?branch=master)](https://travis-ci.org/fredckl/cakephp3-soft-delete)

------------
> Original source from [PGBI](https://github.com/pgbi/cakephp3-soft-delete)
------------

## Purpose

Expand All @@ -18,7 +22,7 @@ You can install this plugin into your CakePHP application using [composer](http:
Update your composer file to include this plugin:

```
composer require pgbi/cakephp3-soft-delete "~1.0"
composer require fredckl/cakephp3-soft-delete "~2.0"
```

## Configuration
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "pgbi/cakephp3-soft-delete",
"name": "fredckl/cakephp3-soft-delete",
"description": "SoftDelete plugin for CakePHP",
"keywords": ["cakephp", "cakephp 3", "plugin", "soft", "delete", "deletable"],
"homepage": "https://github.com/pgbi/cakephp3-soft-delete",
"homepage": "https://github.com/fredckl/cakephp3-soft-delete",
"type": "cakephp-plugin",
"license": "MIT",
"support": {
"source": "https://github.com/pgbi/cakephp3-soft-delete"
"source": "https://github.com/fredckl/cakephp3-soft-delete"
},
"require": {
"php": ">=5.4",
"cakephp/plugin-installer": "*",
"cakephp/cakephp": "~3.0"
"cakephp/cakephp": "~3.5"
},
"require-dev": {
"phpunit/phpunit": "*"
"phpunit/phpunit": "^5|^6"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 5 additions & 5 deletions src/Model/Table/SoftDeleteTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public function getSoftDeleteField()
$field = 'deleted';
}

if ($this->schema()->column($field) === null) {
if ($this->getSchema()->getColumn($field) === null) {
throw new MissingColumnException(
__('Configured field `{0}` is missing from the table `{1}`.',
$field,
$this->alias()
$this->getAlias()
)
);
}
Expand All @@ -36,7 +36,7 @@ public function getSoftDeleteField()

public function query()
{
return new Query($this->connection(), $this);
return new Query($this->getConnection(), $this);
}

/**
Expand All @@ -57,7 +57,7 @@ protected function _processDelete($entity, $options)
return false;
}

$primaryKey = (array)$this->primaryKey();
$primaryKey = (array)$this->getPrimaryKey();
if (!$entity->has($primaryKey)) {
$msg = 'Deleting requires all primary key values.';
throw new \InvalidArgumentException($msg);
Expand Down Expand Up @@ -125,7 +125,7 @@ public function hardDelete(EntityInterface $entity)
if(!$this->delete($entity)) {
return false;
}
$primaryKey = (array)$this->primaryKey();
$primaryKey = (array)$this->getPrimaryKey();
$query = $this->query();
$conditions = (array)$entity->extract($primaryKey);
$statement = $query->delete()
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function triggerBeforeFind()
if (!$this->_beforeFindFired && $this->_type === 'select') {
parent::triggerBeforeFind();

$repository = $this->repository();
$repository = $this->getRepository();
$options = $this->getOptions();

if (!is_array($options) || !in_array('withDeleted', $options)) {
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Model/Table/SoftDeleteTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class SoftDeleteBehaviorTest extends TestCase
* @var array
*/
public $fixtures = [
'plugin.SoftDelete.users',
'plugin.SoftDelete.posts',
'plugin.SoftDelete.tags',
'plugin.SoftDelete.posts_tags'
'plugin.SoftDelete.Users',
'plugin.SoftDelete.Posts',
'plugin.SoftDelete.Tags',
'plugin.SoftDelete.PostsTags'
];

/**
Expand Down Expand Up @@ -86,7 +86,7 @@ public function testFindWithOrWhere()
$user = $this->usersTable->get(2);
$this->usersTable->delete($user);

$query = $this->usersTable->find()->where(['id' => 1])->orWhere(['id' => 2]);
$query = $this->usersTable->find()->where(['OR' => [['id' => 1], ['id' => 2]]]);
$this->assertEquals(1, $query->count());
}

Expand Down
8 changes: 4 additions & 4 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
use Cake\Cache\Cache;
use Cake\Core\Configure;
use Cake\Core\Plugin;
Expand Down Expand Up @@ -52,7 +52,7 @@
'defaults' => 'php'
]);

Cache::config([
Cache::setConfig([
'_cake_core_' => [
'engine' => 'File',
'prefix' => 'cake_core_',
Expand All @@ -76,7 +76,7 @@
putenv('db_dsn=sqlite::memory:');
}

ConnectionManager::config('test', [
ConnectionManager::setConfig('test', [
'className' => 'Cake\Database\Connection',
'driver' => getenv('db_class'),
'dsn' => getenv('db_dsn'),
Expand All @@ -86,7 +86,7 @@
'timezone' => 'UTC'
]);

Log::config([
Log::setConfig([
'debug' => [
'engine' => 'Cake\Log\Engine\FileLog',
'levels' => ['notice', 'info', 'debug'],
Expand Down