<commit_before><?php

if (!defined('_PS_VERSION_')) {
    exit;
}

/**
 * Migrations
 *
 * @author <NAME> <<EMAIL>>
 */
class Migrations extends Module
{

    /**
     * @var boolean $_errors error
     */
    protected $_errors = false;

    /**
     * Construct
     */
    public function __construct()
    {
        $this->name      = 'migrations';
        $this->version   = '1.0';
        $this->author    = '<NAME>';
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('Migrations');

        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
    }

    /**
     * Install
     *
     * @return bool
     */
    public function install()
    {
        if (!parent::install() || !$this->databaseUpdate('install')) {
            return false;
        }

        return true;
    }

    /**
     * Un install
     *
     * @return bool
     */
    public function uninstall()
    {
        if (!parent::uninstall() || !$this->databaseUpdate('uninstall')) {
            return false;
        }

        return true;
    }

    /**
     * Get content
     *
     * @return string
     */
    public function getContent()
    {
        if (Tools::isSubmit('generate')) {
            $this->generateMigration();
        }

        if (Tools::isSubmit('migrate')) {
            $this->executeMigrations();
        }

        return $this->renderForm();
    }

    /**
     * Render custom form
     *
     * @return string
     */
    private function renderForm()
    {
        $fieldsForm = array(
            'form' => array(
                'buttons' => array(
                    'generate' => array(
                        'title' => $this->l('Generate migration'),
                        'type'  => 'submit',
                        'name'  => 'generate',
                        'class' => 'btn btn-default pull-right',<commit_msg>Add custom hooks for module<commit_after><?php

if (!defined('_PS_VERSION_')) {
    exit;
}

/**
 * Migrations
 *
 * @author <NAME> <<EMAIL>>
 */
class Migrations extends Module
{

    /**
     * @var boolean $_errors error
     */
    protected $_errors = false;

    /**
     * Construct
     */
    public function __construct()
    {
        $this->name      = 'migrations';
        $this->version   = '1.0';
        $this->author    = '<NAME>';
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('Migrations');

        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
    }

    /**
     * Install
     *
     * @return bool
     */
    public function install()
    {
        if (!parent::install()
            || !$this->registerHook('generateMigrations')
            || !$this->registerHook('executeMigrations')
            || !$this->databaseUpdate('install')
        ) {
            return false;
        }

        return true;
    }

    /**
     * Un install
     *
     * @return bool
     */
    public function uninstall()
    {
        if (!parent::uninstall() || !$this->databaseUpdate('uninstall')) {
            return false;
        }

        return true;
    }

    /**
     * Hook display generate migrations
     */
    public function hookGenerateMigrations()
    {
        $this->generateMigration();
    }

    /**
     * Hook display execute migrations
     */
    public function hookExecuteMigrations()
    {
        $this->executeMigrations();
    }

    /**
     * Get content
     *
     * @return string
     */
    public function getContent()
    {
        if (Tools::isSubmit('generate')) {
            Hook::exec('generateMigrations');
        }

        if (Tools::isSubmit('migrate')) {
            Hook::exec('executeMigrations');
        }

        return $this->renderForm();
    }

    /**
     * Render custom form
     *
     * @return string
     */
    private function renderForm()
    {
        $fieldsForm = array(
            'form' => array(
                'buttons' => array(
                    'generate' => array(
                        'title' => $this->l('Generate migration'),
                        'type'  => 'submit',
                        'name'  => 'generate',
                        'class' => 'btn btn-default pull-right',
{'fraction_non_alphanumeric': 0.15001164686699278, 'fraction_numerical': 0.0009317493594223154, 'mean_word_length': 1.5258823529411765, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4960240', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1195, 'n_words': 243}