nystudio107 /
craft-connect
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Connect plugin for Craft CMS 3.x |
||
| 4 | * |
||
| 5 | * Allows you to connect to external databases and perform db queries |
||
| 6 | * |
||
| 7 | * @link https://nystudio107.com/ |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 8 | * @copyright Copyright (c) 2018 nystudio107 |
||
|
0 ignored issues
–
show
|
|||
| 9 | */ |
||
|
0 ignored issues
–
show
|
|||
| 10 | |||
| 11 | namespace nystudio107\connect\models; |
||
| 12 | |||
| 13 | use craft\base\Model; |
||
| 14 | use craft\validators\ArrayValidator; |
||
| 15 | |||
| 16 | /** |
||
|
0 ignored issues
–
show
|
|||
| 17 | * @author nystudio107 |
||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||
| 18 | * @package Connect |
||
|
0 ignored issues
–
show
|
|||
| 19 | * @since 1.0.0 |
||
|
0 ignored issues
–
show
|
|||
| 20 | */ |
||
|
0 ignored issues
–
show
|
|||
| 21 | class Settings extends Model |
||
| 22 | { |
||
| 23 | // Public Properties |
||
| 24 | // ========================================================================= |
||
| 25 | |||
| 26 | /** |
||
|
0 ignored issues
–
show
|
|||
| 27 | * @var array the database connections |
||
| 28 | */ |
||
| 29 | public $connections = []; |
||
| 30 | |||
| 31 | // Public Methods |
||
| 32 | // ========================================================================= |
||
| 33 | |||
| 34 | public function init() |
||
|
0 ignored issues
–
show
|
|||
| 35 | { |
||
| 36 | // Fill in some sane defaults if none are provided |
||
| 37 | if (empty($this->connections)) { |
||
| 38 | $this->connections = [ |
||
| 39 | 'remote' => [ |
||
| 40 | 'driver' => getenv('REMOTE_DB_DRIVER'), |
||
| 41 | 'server' => getenv('REMOTE_DB_SERVER'), |
||
| 42 | 'user' => getenv('REMOTE_DB_USER'), |
||
| 43 | 'password' => getenv('REMOTE_DB_PASSWORD'), |
||
| 44 | 'database' => getenv('REMOTE_DB_DATABASE'), |
||
| 45 | 'schema' => getenv('REMOTE_DB_SCHEMA'), |
||
| 46 | 'tablePrefix' => getenv('REMOTE_DB_TABLE_PREFIX'), |
||
| 47 | 'port' => getenv('REMOTE_DB_PORT') |
||
| 48 | ], |
||
| 49 | ]; |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
|
0 ignored issues
–
show
|
|||
| 54 | * @inheritdoc |
||
| 55 | */ |
||
|
0 ignored issues
–
show
|
|||
| 56 | public function rules() |
||
| 57 | { |
||
| 58 | return [ |
||
| 59 | ['connections', ArrayValidator::class], |
||
| 60 | ]; |
||
| 61 | } |
||
| 62 | } |
||
| 63 |