Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#37231 removed bootstrap.php #14

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions src/modules/mo/mo_dhl/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Install
*/
public static function onActivate()
{
static::addBootstrapLoader();
static::ensureConfigVariableNameLength();
static::addTables();
static::addColumns();
Expand All @@ -43,44 +42,6 @@ protected static function ensureDocumentsFolderExists()
}
}

/**
* Adds a line to the functions.php in the modules directory to ensure that the bootstrap is included.
*/
protected static function addBootstrapLoader()
{
$lines = file_exists(static::getFunctionsFile()) ? file(static::getFunctionsFile(), FILE_IGNORE_NEW_LINES) : ['<?php'];
$bootstrapLoader = static::getBootstrapLoaderStatement();

if (in_array($bootstrapLoader, $lines, true)) {
return;
}

$lineOfClosingTag = array_search('?>', $lines, true);
if ($lineOfClosingTag !== false) {
$lines = array_slice($lines, 0, $lineOfClosingTag);
}
$lines[] = $bootstrapLoader;

file_put_contents(static::getFunctionsFile(), implode(PHP_EOL, $lines) . PHP_EOL);
}

/**
* @return string
*/
protected static function getFunctionsFile()
{
return OX_BASE_PATH . 'modules/functions.php';
}

/**
* @return string
*/
protected static function getBootstrapLoaderStatement()
{
$comment = 'This line was automatically generated.';
return "require_once __DIR__ . '/mo/mo_dhl/bootstrap.php'; // {$comment}";
}

/**
* Add a new column with specified type to a table.
*
Expand Down Expand Up @@ -134,27 +95,9 @@ protected static function cleanUp()
*/
public static function onDeactivate()
{
static::removeBootstrapLoader();
static::cleanUp();
}

/**
* Removes the line in the functions.php in the modules directory that loads the bootstrap, in case this line
* exists.
*/
protected static function removeBootstrapLoader()
{
if (!file_exists(static::getFunctionsFile())) {
return;
}

$lines = file(static::getFunctionsFile(), FILE_IGNORE_NEW_LINES);
$lineOfBootstrapLoader = array_search(static::getBootstrapLoaderStatement(), $lines, true);
if ($lineOfBootstrapLoader !== false) {
unset($lines[$lineOfBootstrapLoader]);
}
file_put_contents(static::getFunctionsFile(), implode(PHP_EOL, $lines) . PHP_EOL);
}

/**
* @throws \Exception
Expand Down
2 changes: 0 additions & 2 deletions src/modules/mo/mo_dhl/bootstrap.php

This file was deleted.

Loading