<?php
/**
 * This file is part of the JustKnit package.
 *
 * @copyright JustKnit (Iris Hammer) <iris@justknit.de>
 * @license All rights reserved (@https://dejure.org/gesetze/UrhG/69a.html)
 * Created on 03-20-2023
 *
 * @package justknit
 */

use xPDO\Transport\xPDOTransport;

/**
 * Include bootstrap when installing the package
 *
 * @package justknit
 * @subpackage build
 */

if ($object->xpdo) {
    $modx = &$object->xpdo;
    $success = true;

    switch ($options[xPDOTransport::PACKAGE_ACTION]) {
        case xPDOTransport::ACTION_INSTALL:
            $corePath = $modx->getOption(
                'justknit.core_path',
                null,
                $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/justknit/'
            );
            $bootstrap = $corePath . 'bootstrap.php';
            if (file_exists($bootstrap)) {
                $namespace = [];
                $namespace['path'] = $corePath;
                require $bootstrap;
            } else {
                $success = false;
                $modx->log(modX::LOG_LEVEL_ERROR, 'Could not include bootstrap.php from path: ' . $corePath);
            }
    }
}
unset($corePath, $bootstrap);
return $success;
