Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from abr4xas/main
Browse files Browse the repository at this point in the history
small fixes
  • Loading branch information
martin-ro authored Jun 26, 2024
2 parents dd80709 + 4b2955b commit ee381e3
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ class MyBlock extends PageBlock

and its corresponding blade component view:
```html
@props([
//
])

<div>
//
</div>

```

## Using Page Blocks in your template
Expand All @@ -70,4 +75,4 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@
"php": "^8.2",
"filament/filament": "^3.0-stable",
"illuminate/contracts": "^10.0 | ^11.0",
"spatie/laravel-package-tools": "^1.13.5"
"spatie/laravel-package-tools": "^1.16.4"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.0",
"spatie/laravel-ray": "^1.26"
"laravel/pint": "^1.16.1",
"nunomaduro/collision": "^8.1.1||^7.10.0",
"orchestra/testbench": "^9.1.2||^8.22.0",
"pestphp/pest": "^2.34.8",
"pestphp/pest-plugin-arch": "^2.7",
"pestphp/pest-plugin-laravel": "^2.4",
"spatie/laravel-ray": "^1.36.2"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/MakePageBlockCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function handle(): int

$this->copyStubToApp('PageBlock', $path, [
'class' => $pageBlockClass,
'namespace' => 'App\\Filament\\PageBlocks'.($pageBlockNamespace !== '' ? "\\{$pageBlockNamespace}" : ''),
'namespace' => 'App\\Filament\\PageBlocks' . ($pageBlockNamespace !== '' ? "\\{$pageBlockNamespace}" : ''),
'label' => $label,
'shortName' => $shortName,
]);
Expand Down
9 changes: 9 additions & 0 deletions src/Exceptions/InvalidClassTypeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace MartinRo\FilamentPageBlocks\Exceptions;

use Exception;

final class InvalidClassTypeException extends Exception {}
5 changes: 3 additions & 2 deletions src/FilamentPageBlocksManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Exception;
use Illuminate\Support\Collection;
use InvalidArgumentException;
use MartinRo\FilamentPageBlocks\Exceptions\InvalidClassTypeException;

class FilamentPageBlocksManager
{
Expand All @@ -29,15 +30,15 @@ public function register(string $class, string $baseClass): void
{
match ($baseClass) {
PageBlock::class => static::registerPageBlock($class),
default => throw new Exception('Invalid class type'),
default => throw new InvalidClassTypeException('Invalid class type'),
};
}

/** @param class-string $pageBlock */
public function registerPageBlock(string $pageBlock): void
{
if (! is_subclass_of($pageBlock, PageBlock::class)) {
throw new InvalidArgumentException("{$pageBlock} must extend ".PageBlock::class);
throw new InvalidArgumentException("{$pageBlock} must extend " . PageBlock::class);
}

$this->pageBlocks->put($pageBlock::getName(), $pageBlock);
Expand Down
2 changes: 1 addition & 1 deletion src/FilamentPageBlocksServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function registerComponentsFromDirectory(string $baseClass, array $reg
collect($filesystem->allFiles($directory))
->map(function (SplFileInfo $file) use ($namespace): string {
$variableNamespace = $namespace->contains('*') ? str_ireplace(
['\\'.$namespace->before('*'), $namespace->after('*')],
['\\' . $namespace->before('*'), $namespace->after('*')],
['', ''],
Str::of($file->getPath())
->after(base_path())
Expand Down
2 changes: 1 addition & 1 deletion src/PageBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function getComponent(): string
return static::$component;
}

return 'page-blocks.'.static::getName();
return 'page-blocks.' . static::getName();
}

public static function getName(): string
Expand Down
6 changes: 3 additions & 3 deletions stubs/PageBlockView.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

?>
@props([
//
])

<div>
//
Expand Down

0 comments on commit ee381e3

Please sign in to comment.