Skip to content

Commit

Permalink
#37231 removed bootstrap.php
Browse files Browse the repository at this point in the history
  • Loading branch information
mbe1987 committed Dec 16, 2024
1 parent 8e303ba commit 819c4e2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 59 deletions.
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.

0 comments on commit 819c4e2

Please sign in to comment.