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

doc: add migration guid + remove obsolete properties $headers/$secret… #238

Merged
merged 1 commit into from
Aug 8, 2023
Merged
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: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[7.0.0](#v7.0.0) / [unreleased]
==================
* BREAKING: Replace static `Podio` client with instantiable `PodioClient` class. #228
* BREAKING: Replace update/save methods on instances with static methods #234
* BREAKING: Replace `save` (and `completed`/`incompleted`/`destroy` on `PodioTask`) methods on instances with static methods #234
* BREAKING: Remove obsolete `PodioClient::secret` and `PodioClient::headers` properties.
* BREAKING: `Podio::debug` changed from public to protected: use `PodioClient::set_debug(..)`
* See [migration guide](https://github.com/podio-community/podio-php/blob/master/MIGRATION_GUIDE_v7.md) for details.

[6.1.1](#v6.1.1) / 2023-06-12
==================
Expand Down
54 changes: 54 additions & 0 deletions MIGRATION_GUIDE_v7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Migration Guide for updating from v6 to v7

1. Instead of calling `Podio::setup(..)` you should create an instance of `PodioClient` and pass it to other methods.
```php
// Before:
Podio::setup($client_id, $client_secret, $options);
Podio::authenticate_with_password($username, $password);

// After:
$client = new PodioClient($client_id, $client_secret, $options);
$client->authenticate_with_password($username, $password);
```
2. All operations take an instance of `PodioClient` as the first argument.
```php
// Before:
PodioItem::get(123);

// After:
PodioItem::get($client, 123);
```
3. All operations are now static methods on the model classes.
```php
// Before:
$item->save();

// After:
PodioItem::save($client, $item);
```
Besides the `save` methods in almost all objects, the following methods have changed:
```php
// Before:
$podioTask->completed();
// After:
PodioTask::complete($client, $podioTask->task_id);

// Before:
$podioTask->incompleted();
// After:
PodioTask::incomplete($client, $podioTask->task_id);

// Before:
$podioTask->destroy();
// After:
PodioTask::delete($client, $podioTask->task_id);
```

## Notes

The following regex might help you find all relevant places in your codebase:

```regex
Podio\w*::\w+\(|->save\(|->completed\(\)|->incompleted\(\)|->destroy\(\)
```

2 changes: 0 additions & 2 deletions Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ require __DIR__ . '/vendor/autoload.php';

$client = new PodioClient($client_id, $client_secret);
$client->authenticate_with_app($app_id, $app_token);
$items = PodioItem::filter($app_id, $client);
$items = PodioItem::filter($client, $app_id);

print "My app has " . count($items) . " items";
print "My app has " . $items->total . " items";
```

## Contribute
Expand Down
5 changes: 2 additions & 3 deletions lib/PodioClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ class PodioClient
protected $debug = false;
public $logger;
public $session_manager;
/** @var ?PodioResponse */
public $last_response;
public $auth_type;
/** @var \GuzzleHttp\Client */
public $http_client;
protected $url;
protected $client_id;
protected $client_secret;
protected $secret;
protected $headers;
/** @var \Psr\Http\Message\ResponseInterface */
private $last_http_response;

public const VERSION = '6.1.0';
public const VERSION = '7.0.0';

public const GET = 'GET';
public const POST = 'POST';
Expand Down