| 1 |
<?php |
| 2 |
|
| 3 |
namespace Depicter\Database; |
| 4 |
|
| 5 |
use Depicter\Database\Repository\DocumentRepository; |
| 6 |
use WPEmerge\ServiceProviders\ServiceProviderInterface; |
| 7 |
|
| 8 |
/** |
| 9 |
* Load document data manager. |
| 10 |
*/ |
| 11 |
class DatabaseServiceProvider implements ServiceProviderInterface { |
| 12 |
|
| 13 |
/** |
| 14 |
* {@inheritDoc} |
| 15 |
*/ |
| 16 |
/** |
| 17 |
* {@inheritDoc} |
| 18 |
*/ |
| 19 |
public function register( $container ) { |
| 20 |
$container[ 'depicter.database.migration' ] = function () { |
| 21 |
return new Migration(); |
| 22 |
}; |
| 23 |
|
| 24 |
$container[ 'depicter.database.repository.document' ] = function () { |
| 25 |
return new DocumentRepository(); |
| 26 |
}; |
| 27 |
|
| 28 |
$app = $container[ WPEMERGE_APPLICATION_KEY ]; |
| 29 |
$app->alias( 'documentRepository', 'depicter.database.repository.document' ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* {@inheritDoc} |
| 34 |
*/ |
| 35 |
public function bootstrap( $container ) { |
| 36 |
register_activation_hook( DEPICTER_PLUGIN_FILE, [ $this, 'activate' ] ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Plugin activation. |
| 41 |
* |
| 42 |
* @return void |
| 43 |
*/ |
| 44 |
public function activate() { |
| 45 |
\Depicter::resolve( 'depicter.database.migration' )->migrate(true); |
| 46 |
} |
| 47 |
|
| 48 |
} |
| 49 |
|