Skip to content

Commit c93aab6

Browse files
authored
Update dependencies (#134)
1 parent ce04ffb commit c93aab6

File tree

5 files changed

+46
-30
lines changed

5 files changed

+46
-30
lines changed

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
"require": {
2323
"php": "^8.0",
2424
"cebe/markdown": "^1.2@dev",
25+
"cycle/database": "^2.0",
26+
"cycle/entity-behavior": "^1.0",
2527
"cycle/orm": "^2.0",
28+
"doctrine/collections": "^1.6",
2629
"httpsoft/http-message": "^1.0.5",
2730
"myclabs/php-enum": "^1.7",
2831
"psr/container": "^2.0",
@@ -45,7 +48,7 @@
4548
"yiisoft/factory": "^1.0",
4649
"yiisoft/files": "^2.0",
4750
"yiisoft/http": "^1.2",
48-
"yiisoft/injector": "^1.0",
51+
"yiisoft/injector": "^1.1",
4952
"yiisoft/log": "^2.0",
5053
"yiisoft/log-target-file": "^2.0",
5154
"yiisoft/request-body-parser": "^1.1",
@@ -72,7 +75,7 @@
7275
"codeception/lib-innerbrowser": "^3.0",
7376
"codeception/module-asserts": "^3.0",
7477
"codeception/module-cli": "^2.0",
75-
"codeception/module-db": "^2.0",
78+
"codeception/module-db": "^3.0",
7679
"codeception/module-phpbrowser": "^3.0",
7780
"codeception/module-rest": "^3.0",
7881
"phpunit/phpunit": "^9.5",

config/common/cycle.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Cycle\Database\DatabaseManager;
6+
use Cycle\ORM\Collection\DoctrineCollectionFactory;
7+
use Cycle\ORM\Factory;
8+
use Cycle\ORM\FactoryInterface;
9+
10+
/** @var array $params */
11+
12+
return [
13+
// Replace Factory definition to redefine default collection type
14+
// Todo: remove with https://github.com/yiisoft/yii-cycle/issues/111
15+
FactoryInterface::class => static function (DatabaseManager $dbManager, Spiral\Core\FactoryInterface $factory) {
16+
return new Factory(
17+
$dbManager,
18+
null,
19+
$factory,
20+
new DoctrineCollectionFactory()
21+
);
22+
},
23+
];

config/params.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Yiisoft\Yii\Cycle\Command\Schema;
1010
use Yiisoft\Yii\Cycle\Command\Migration;
1111
use Yiisoft\Yii\Cycle\Schema\Conveyor\AttributedSchemaConveyor;
12+
use Yiisoft\Yii\Cycle\Schema\Provider\FromConveyorSchemaProvider;
13+
use Yiisoft\Yii\Cycle\Schema\Provider\PhpFileSchemaProvider;
1214
use Yiisoft\Yii\Cycle\Schema\SchemaProviderInterface;
1315
use Yiisoft\Yii\Middleware\SubFolder;
1416

@@ -79,8 +81,8 @@
7981
'sqlite' => new \Cycle\Database\Config\SQLiteDriverConfig(
8082
connection: new \Cycle\Database\Config\SQLite\FileConnectionConfig(
8183
database: $_ENV['YII_ENV'] === 'production'
82-
? '@data/db/database.db'
83-
: 'sqlite:@tests/_data/database.db'
84+
? dirname(__DIR__) . '/data/db/database.db'
85+
: dirname(__DIR__) . '/tests/_data/database.db'
8486
)
8587
),
8688
],
@@ -117,12 +119,12 @@
117119
// \Yiisoft\Yii\Cycle\Schema\Provider\SimpleCacheSchemaProvider::class => ['key' => 'cycle-orm-cache-key'],
118120

119121
// Store generated Schema in the file
120-
\Yiisoft\Yii\Cycle\Schema\Provider\PhpFileSchemaProvider::class => [
121-
'mode' => \Yiisoft\Yii\Cycle\Schema\Provider\PhpFileSchemaProvider::MODE_WRITE_ONLY,
122-
'file' => 'runtime/schema.php',
122+
PhpFileSchemaProvider::class => [
123+
'mode' => PhpFileSchemaProvider::MODE_WRITE_ONLY,
124+
'file' => '@runtime/schema.php',
123125
],
124126

125-
\Yiisoft\Yii\Cycle\Schema\Provider\FromConveyorSchemaProvider::class => [
127+
FromConveyorSchemaProvider::class => [
126128
'generators' => [
127129
Cycle\Schema\Generator\SyncTables::class, // sync table changes to database
128130
],

src/User/User.php

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,30 @@
66

77
use Cycle\Annotated\Annotation\Column;
88
use Cycle\Annotated\Annotation\Entity;
9-
use Cycle\Annotated\Annotation\Table;
109
use Cycle\Annotated\Annotation\Table\Index;
10+
use Cycle\ORM\Entity\Behavior\CreatedAt;
11+
use Cycle\ORM\Entity\Behavior\UpdatedAt;
1112
use DateTimeImmutable;
1213
use Yiisoft\Auth\IdentityInterface;
1314
use Yiisoft\Security\PasswordHasher;
1415
use Yiisoft\Security\Random;
1516

16-
/**
17-
* @Entity(repository="App\User\UserRepository", mapper="Yiisoft\Yii\Cycle\Mapper\TimestampedMapper")
18-
* @Table(
19-
* indexes={
20-
* @Index(columns={"login"}, unique=true),
21-
* @Index(columns={"token"}, unique=true)
22-
* }
23-
* )
24-
*/
17+
#[Entity(repository: UserRepository::class)]
18+
#[Index(columns: ['login', 'token'], unique: true)]
19+
#[CreatedAt(field: 'created_at', column: 'created_at')]
20+
#[UpdatedAt(field: 'updated_at', column: 'updated_at')]
2521
class User implements IdentityInterface
2622
{
27-
/**
28-
* @Column(type="primary")
29-
*/
23+
#[Column(type: 'primary')]
3024
private ?int $id = null;
3125

32-
/**
33-
* @Column(type="string(128)")
34-
*/
26+
#[Column(type: 'string(128)')]
3527
private string $token;
3628

37-
/**
38-
* @Column(type="string(48)")
39-
*/
29+
#[Column(type: 'string(48)')]
4030
private string $login;
4131

42-
/**
43-
* @Column(type="string")
44-
*/
32+
#[Column(type: 'string')]
4533
private string $passwordHash;
4634

4735
/**

tests/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)