mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-08-02 12:16:06 -04:00
70 lines
2.3 KiB
PHP
70 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Theme\Services;
|
|
|
|
class AugmentationService
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->addToggleToMainMenu();
|
|
$this->addToggleToMenu();
|
|
}
|
|
|
|
public function addToggleToMainMenu()
|
|
{
|
|
$path = resource_path('views/frontend/amazy/partials/_mainmenu.blade.php');
|
|
if (file_exists($path)) {
|
|
$update = false;
|
|
$content = file_get_contents($path);
|
|
if (!preg_match("/\@include\('theme::toggle'\)/", $content)) {
|
|
$matches = null;
|
|
preg_match('/<div class="mobile_menu d-block d-lg-none"><\/div>/', $content, $matches);
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "
|
|
@if (isModuleActive('Theme'))
|
|
@include('theme::toggle')
|
|
@endif
|
|
";
|
|
$code = $snippet.$code;
|
|
$content = preg_replace('/<div class="mobile_menu d-block d-lg-none"><\/div>/', $code, $content);
|
|
//file_put_contents($path, $content);
|
|
$update = true;
|
|
}
|
|
}
|
|
|
|
if ($update) {
|
|
file_put_contents($path, $content);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function addToggleToMenu()
|
|
{
|
|
$path = resource_path('/views/backEnd/partials/_menu.blade.php');
|
|
if (file_exists($path)) {
|
|
$update = false;
|
|
$content = file_get_contents($path);
|
|
if (!preg_match("/\@include\('theme::toggle'\)/", $content)) {
|
|
$matches = null;
|
|
preg_match("/<div class=\"header_notification_warp d-flex align-items-center\">/", $content, $matches);
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "
|
|
@if (isModuleActive('Theme'))
|
|
@include('theme::toggle')
|
|
@endif
|
|
";
|
|
$code = $code.$snippet;
|
|
$content = preg_replace("/<div class=\"header_notification_warp d-flex align-items-center\">/", $code, $content);
|
|
$update = true;
|
|
}
|
|
}
|
|
|
|
if ($update) {
|
|
file_put_contents($path, $content);
|
|
}
|
|
}
|
|
}
|
|
}
|