1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the FOS User Util package. |
5
|
|
|
* |
6
|
|
|
* (c) Jean-Bernard Addor |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace FosUserUtil\Doctrine\DBAL; |
13
|
|
|
|
14
|
|
|
use Doctrine\DBAL\Schema\Schema; |
15
|
|
|
|
16
|
|
|
class SchemaBuilder |
17
|
|
|
{ |
18
|
|
|
protected $schema; |
19
|
|
|
|
20
|
2 |
|
public function __construct(Schema $schema) |
21
|
|
|
{ |
22
|
2 |
|
$this->schema = $schema; |
23
|
2 |
|
} |
24
|
|
|
|
25
|
1 |
|
public function userTable() |
26
|
|
|
{ |
27
|
1 |
|
$UserTable = $this->schema->createTable('http_user'); |
28
|
1 |
|
$UserTable->addColumn('uuid', 'guid'); |
29
|
1 |
|
$UserTable->setPrimaryKey(['uuid']); |
30
|
|
|
// $UserTable->addColumn('deleted', 'datetime', ['notnull' => false]); |
|
|
|
|
31
|
|
|
//^ Users should not be able to delete this, probably. |
32
|
1 |
|
$UserTable->addColumn('username', 'string', ['length' => 180]); |
33
|
1 |
|
$UserTable->addColumn('username_canonical', 'string', ['length' => 180]); |
34
|
1 |
|
$UserTable->addUniqueIndex(['username_canonical'], 'username_canonical_unique_index'); // name probably not needed |
35
|
1 |
|
$UserTable->addColumn('email', 'string', ['length' => 180]); |
36
|
1 |
|
$UserTable->addColumn('email_canonical', 'string', ['length' => 180]); |
37
|
1 |
|
$UserTable->addUniqueIndex(['email_canonical'], 'email_canonical_unique_index'); // name probably not needed |
38
|
1 |
|
$UserTable->addColumn('enabled', 'boolean'); |
39
|
1 |
|
$UserTable->addColumn('salt', 'string', ['notnull' => false]); // 'length' => 255 |
|
|
|
|
40
|
1 |
|
$UserTable->addColumn('password', 'string'); // 'length' => 255 |
|
|
|
|
41
|
1 |
|
$UserTable->addColumn('last_login', 'datetime', ['notnull' => false]); |
42
|
1 |
|
$UserTable->addColumn('confirmation_token', 'string', ['length' => 180, 'notnull' => false]); |
43
|
1 |
|
$UserTable->addUniqueIndex(['confirmation_token'], 'confirmation_token_unique_index'); // name probably not needed |
44
|
1 |
|
$UserTable->addColumn('password_requested_at', 'datetime', ['notnull' => false]); |
45
|
1 |
|
$UserTable->addColumn('roles', 'array'); |
46
|
|
|
|
47
|
1 |
|
return $UserTable; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
// https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/config/doctrine-mapping/User.orm.xml |
52
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.