Skip to content

Commit 327da6f

Browse files
committed
Update
- removed: deprecated filter - added: filter to entry actions - added: support for mariadb database
1 parent c0d0edc commit 327da6f

File tree

13 files changed

+1406
-595
lines changed

13 files changed

+1406
-595
lines changed

app/Classes/XMLParser.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
namespace App\Classes;
3+
4+
use Exception;
5+
6+
class XMLParser
7+
{
8+
private $xmlFilePath;
9+
private $xmlObject;
10+
11+
public function __construct(string $xmlFilePath) {
12+
$this->xmlFilePath = $xmlFilePath;
13+
14+
$this->loadXML();
15+
}
16+
17+
private function loadXML() {
18+
if (!file_exists($this->xmlFilePath)) {
19+
throw new Exception("File not found: " . $this->xmlFilePath);
20+
}
21+
22+
libxml_use_internal_errors(true);
23+
$this->xmlObject = simplexml_load_file($this->xmlFilePath);
24+
if ($this->xmlObject === false) {
25+
$errors = libxml_get_errors();
26+
libxml_clear_errors();
27+
$errorMessages = [];
28+
foreach ($errors as $error) {
29+
$errorMessages[] = $error->message;
30+
}
31+
throw new Exception("Failed to load XML: " . implode(", ", $errorMessages));
32+
}
33+
}
34+
35+
public function getXMLObject() {
36+
return $this->xmlObject;
37+
}
38+
39+
// Example method to get data by tag name
40+
public function getDataByTagName(string $tagName) {
41+
if (isset($this->xmlObject->{$tagName})) {
42+
return $this->xmlObject->{$tagName};
43+
} else {
44+
throw new Exception("Tag not found: " . $tagName);
45+
}
46+
}
47+
}

app/Providers/TelescopeServiceProvider.php

Lines changed: 0 additions & 65 deletions
This file was deleted.

app/Services/CrudService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ class CrudService
152152
'updated_at' => DateCast::class,
153153
];
154154

155+
protected $model;
156+
155157
/**
156158
* Define permissions for using
157159
* the current resource
@@ -942,7 +944,7 @@ public function getEntries( $config = [] ): array
942944
* entries but make sure to keep the originals.
943945
*/
944946
if ( method_exists( $this, 'setActions' ) ) {
945-
$entry = Hook::addFilter( get_class( $this )::method( 'setActions' ), $this->setActions( $entry ) );
947+
Hook::addAction( get_class( $this )::method( 'setActions' ), $this->setActions( $entry ) );
946948
}
947949

948950
return $entry;

app/Services/ModulesService.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Services;
44

5+
use App\Classes\XMLParser;
56
use App\Events\ModulesAfterDisabledEvent;
67
use App\Events\ModulesAfterEnabledEvent;
78
use App\Events\ModulesAfterRemovedEvent;
@@ -26,8 +27,6 @@
2627
use Illuminate\Support\Facades\View;
2728
use Illuminate\Support\ServiceProvider;
2829
use Illuminate\Support\Str;
29-
use Laravie\Parser\Xml\Document;
30-
use Laravie\Parser\Xml\Reader;
3130
use PhpParser\Error;
3231
use PhpParser\ParserFactory;
3332
use SimpleXMLElement;
@@ -36,12 +35,8 @@ class ModulesService
3635
{
3736
private $modules = [];
3837

39-
private $xmlParser;
40-
4138
private Options $options;
4239

43-
private $modulesPath;
44-
4540
const CACHE_MIGRATION_LABEL = 'module-migration-';
4641

4742
public function __construct()
@@ -53,9 +48,6 @@ public function __construct()
5348
$this->options = app()->make( Options::class );
5449
}
5550

56-
$this->modulesPath = base_path( 'modules' ) . DIRECTORY_SEPARATOR;
57-
$this->xmlParser = new Reader( new Document );
58-
5951
/**
6052
* creates the directory modules
6153
* if that doesn't exists
@@ -141,16 +133,8 @@ public function __init( string $dir ): void
141133
$xmlContent = file_get_contents( $xmlConfigPath );
142134

143135
try {
144-
$xml = $this->xmlParser->extract( $xmlContent );
145-
$config = $xml->parse( [
146-
'namespace' => [ 'uses' => 'namespace' ],
147-
'version' => [ 'uses' => 'version' ],
148-
'author' => [ 'uses' => 'author' ],
149-
'description' => [ 'uses' => 'description' ],
150-
'dependencies' => [ 'uses' => 'dependencies' ],
151-
'name' => [ 'uses' => 'name' ],
152-
'core' => [ 'uses' => 'core' ],
153-
] );
136+
$parser = new XMLParser($xmlConfigPath);
137+
$config = ( array ) $parser->getXMLObject();
154138
} catch ( Exception $exception ) {
155139
throw new Exception( sprintf(
156140
__( 'Failed to parse the configuration file on the following path "%s"' ),

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
"fakerphp/faker": "^1.12",
1919
"gumlet/php-image-resize": "^2.0",
2020
"guzzlehttp/guzzle": "^7.0.1",
21-
"laravel/framework": "^10.0",
22-
"laravel/sanctum": "^3.2",
23-
"laravel/telescope": "^4.0",
21+
"laravel/framework": "^11.0",
22+
"laravel/reverb": "@beta",
23+
"laravel/sanctum": "^4.0",
2424
"laravel/tinker": "^2.0",
25-
"laravie/parser": "^2.1",
2625
"nikic/php-parser": "^5.0",
2726
"phpoffice/phpspreadsheet": "^2.0",
2827
"picqer/php-barcode-generator": "^2.1",
@@ -37,7 +36,7 @@
3736
"require-dev": {
3837
"laravel/pint": "^1.1.1",
3938
"mockery/mockery": "^1.3.1",
40-
"nunomaduro/collision": "^7.0",
39+
"nunomaduro/collision": "^8.1",
4140
"phpunit/phpunit": "^10.0",
4241
"spatie/laravel-ignition": "^2.0"
4342
},

0 commit comments

Comments
 (0)