Files
wticreatorstudio/Modules/RegistrationAgreement/Services/AugmentationService.php
T
2024-02-12 22:54:20 -05:00

41 lines
1.5 KiB
PHP

<?php
namespace Modules\RegistrationAgreement\Services;
class AugmentationService
{
public function __construct() {
$this->addAgreementCheckbox();
}
public static function addAgreementCheckbox() {
if (isModuleActive('RegistrationFormSteps')) {
$path = module_path('RegistrationFormSteps', 'Resources/views/customer/steps/_summary.blade.php');
if (file_exists($path)) {
$update = false;
$content = file_get_contents($path);
if (!preg_match("/@include\('registrationagreement::components\.agreement_checkbox'\)/", $content)) {
$matches = null;
preg_match("/@include\('registrationformsteps::payments\.stripe_payment'\)/", $content, $matches);
if (count($matches) > 0) {
$code = $matches[0];
$snippet = "
@if (isModuleActive('RegistrationFormSteps'))
@include('registrationagreement::components.agreement_checkbox')
@endif
@include('registrationformsteps::payments.stripe_payment')
";
$code = $snippet;
$content = preg_replace("/@include\('registrationformsteps::payments\.stripe_payment'\)/", $code, $content);
$update = true;
}
}
if ($update) {
file_put_contents($path, $content);
}
}
}
}
}