Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ on:

jobs:
testsuite:
uses: ADmad/.github/.github/workflows/testsuite-with-db.yml@master
uses: ADmad/.github/.github/workflows/testsuite-with-db.yml@cake6
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

cs-stan:
uses: ADmad/.github/.github/workflows/cs-stan.yml@master
uses: ADmad/.github/.github/workflows/cs-stan.yml@cake6
secrets: inherit
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,35 @@ query to order by the position field if an order clause has not already been set

### Methods

CakePHP 6 no longer forwards behavior methods through the table. Call the
behavior directly using `$modelObject->getBehavior('Sequence')`. When migrating
from CakePHP 5, update calls to `moveUp()`, `moveDown()`, and `setOrder()` as shown
below. Automatic ordering on find, save, and delete continues to work by adding
the behavior to the table.

#### moveUp(\Cake\Datasource\EntityInterface $entity)
Move up record by one position:

```php
$modelObject->moveUp($entity);
$modelObject->getBehavior('Sequence')->moveUp($entity);
```

#### moveDown(\Cake\Datasource\EntityInterface $entity)
Move down record by one position:

```php
$modelObject->moveDown($entity);
$modelObject->getBehavior('Sequence')->moveDown($entity);
```

#### setOrder(array $record)
#### setOrder(array $records)
Set order for list of records provided. Records can be provided as array of
entities or array of associative arrays like `[['id' => 1], ['id' => 2]]` or
array of primary key values like `[1, 2]`.

```php
$modelObject->getBehavior('Sequence')->setOrder([3, 1, 2]);
```

## Acknowledgement

Shout out to @neilcrookes for his wonderful Sequence Behavior for CakePHP 1.3
Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"type": "cakephp-plugin",
"license": "MIT",
"require": {
"cakephp/orm": "^5.0"
"php": ">=8.5",
"cakephp/orm": "^6.0@dev"
},
"require-dev": {
"cakephp/cakephp": "^5.0",
"phpunit/phpunit": "^10.5.58 || ^11.5.3 || ^12.4"
"cakephp/cakephp": "^6.0@dev",
"phpunit/phpunit": "^13.0"
},
"autoload": {
"psr-4": {
Expand All @@ -28,5 +29,7 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
8 changes: 7 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.0/phpunit.xsd"
cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="ADmad/Sequence TestSuite">
<directory>./tests/TestCase</directory>
Expand Down
Loading
Loading