Skip to content

Commit

Permalink
Importing Drupal7 blog
Browse files Browse the repository at this point in the history
  • Loading branch information
oschettler committed May 5, 2018
1 parent b5c9198 commit c998d82
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -45,7 +45,8 @@
],
"psr-4": {
"Knowfox\\": "app/",
"Knowfox\\Entangle\\": "packages/knowfox/entangle/src/"
"Knowfox\\Entangle\\": "packages/knowfox/entangle/src/",
"Knowfox\\Drupal7\\": "packages/knowfox/drupal7/src/"
}
},
"autoload-dev": {
Expand Down
1 change: 1 addition & 0 deletions config/app.php
Expand Up @@ -173,6 +173,7 @@
Folklore\GraphQL\ServiceProvider::class,

Knowfox\Entangle\ServiceProvider::class,
Knowfox\Drupal7\ServiceProvider::class,

/*
* Application Service Providers...
Expand Down
19 changes: 19 additions & 0 deletions config/database.php
Expand Up @@ -57,6 +57,25 @@
'engine' => null,
],


'd7' => [
'driver' => 'mysql',
'host' => env('DB_D7_HOST', '127.0.0.1'),
'port' => env('DB_D7_PORT', '3306'),
'database' => env('DB_D7_DATABASE', 'forge'),
'username' => env('DB_D7_USERNAME', 'forge'),
'password' => env('DB_D7_PASSWORD', ''),
/*
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
*/
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],

'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
Expand Down
28 changes: 28 additions & 0 deletions packages/knowfox/drupal7/composer.json
@@ -0,0 +1,28 @@
{
"name": "knowfox/drupal7",
"description": "Import the Drupal7 blog from https://olav.net .",
"type": "library",
"require": {
"illuminate/support": "^5.5"
},
"license": "GPL v3",
"authors": [
{
"name": "Olav Schettler",
"email": "olav@schettler.net"
}
],
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"Knowfox\\Drupal7\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Knowfox\\Drupal7\\ServiceProvider"
]
}
}
}
39 changes: 39 additions & 0 deletions packages/knowfox/drupal7/src/Commands/ImportDrupal7.php
@@ -0,0 +1,39 @@
<?php

namespace Knowfox\Drupal7\Commands;

use Illuminate\Console\Command;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Support\Facades\Config;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Cookie\CookieJar;
use Knowfox\Entangle\Models\ImportedEvent;
use Knowfox\Entangle\Models\ImportedUser;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class ImportDrupal7 extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'drupal7:import';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Import Drupal7 nodes from a MySQL database';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle() {
$this->info("Importing from database " . env('DB_D7_DATABASE') . '...');
$this->info('Done.');
}
}
11 changes: 11 additions & 0 deletions packages/knowfox/drupal7/src/Models/ImportedNode.php
@@ -0,0 +1,11 @@
<?php

namespace Knowfox\Drupal7\Models;

use Illuminate\Database\Eloquent\Model;

class ImportedNode extends Model
{
protected $connection = 'd7';
protected $table = 'node';
}
28 changes: 28 additions & 0 deletions packages/knowfox/drupal7/src/ServiceProvider.php
@@ -0,0 +1,28 @@
<?php

namespace Knowfox\Drupal7;

use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
use Knowfox\Drupal7\Commands\ImportDrupal7;

class ServiceProvider extends IlluminateServiceProvider
{
protected function mergeConfigRecursiveFrom($path, $key)
{
$config = $this->app['config']->get($key, []);
$this->app['config']->set($key, array_merge_recursive(require $path, $config));
}

public function boot()
{
if ($this->app->runningInConsole()) {
$this->commands([
ImportDrupal7::class,
]);
}
}

public function register()
{
}
}

0 comments on commit c998d82

Please sign in to comment.