<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

/**
 * Upgrade ciext module to version 3.0.1
 *
 * @author Igor Ratsun
 */
class Ciext_upgrade_3_0_0 extends Abstract_upgrade
{

    public function up()
    {
        $file = APPPATH . 'config' . DIRECTORY_SEPARATOR . 'events.php';
        if (!file_exists($file)) {
            file_put_contents($file, $this->get_file_data());
        }

        return file_exists($file) ? '3.0.1' : '3.0.0';
    }

    public function down()
    {
        return '3.0.0';
    }

    protected function get_file_data()
    {
        return '<?php
defined(\'BASEPATH\') OR exit(\'No direct script access allowed\');

/*
| -------------------------------------------------------------------
|  Auto-attach listeners to models
| -------------------------------------------------------------------
| Prototype:
|
|    $config[\'events_models\'] = [
|        \'foo_model1\' => [
|            \'implements of SplObserver library\',
|        ]
|    ];
|
*/
$config[\'events_models\'] = [];';
    }

}
