<?php
/**
 * NHS installer
 *
 * Adds required settings to site as they are pushed live with settings.db.php
 * Rest of the changes are populated through migrations
 *
 * @author: Uldis Zvirbulis <uldis.zvirbulis@mtcmedia.co.uk>
 *
 */

echo 'yyy';
exit;
use Mtc\Core\Setting;

$data = [
    [
        'key' => 'NHS_ENABLED',
        'type' => 'bool',
        'value' => true,
        'module' => 'NHS',
        'description' => 'Enable / Disable NHS plugin',
        'created_at' => new \DateTime(),
    ]
];

foreach ($data as $key => $values) {
    if (defined($values['key'])) {
        unset($data[$key]);
    }
}

Setting::Insert($data);

$source = __DIR__ . '/20171010-1-AddNHSTables.php';
$destination = SITE_PATH . '/migrations/20171010-1-AddNHSTables.php';

// Copy the migration file over to migrations dir
if (!file_exists($destination)) {
    copy($source, $destination);

    exec('/usr/local/bin/php ' . SITE_PATH . '/migrations.php');
}
