Skip to content

Commit

Permalink
Init (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobWez98 authored Jul 28, 2022
1 parent 007fcf8 commit 2f2cda6
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Rapidez Statamic

## Requirements

You have to have `statamic/cms` installed in your laravel application. Installation guide is found [here](https://statamic.dev/installing/laravel).

## Installation

```
composer require rapidez/statamic
```

### Routing

As Rapidez uses route fallbacks to allow routes to be added with lower priority then Magento routes, this package is used to fix this, as statamic routes on itself will overwrite your Magento routes. Make sure default Statamic routing is disabled in `config/statamic/routes.php`:

```php

'enabled' => false,

```

## License

GNU General Public License v3. Please see [License File](LICENSE) for more information.
42 changes: 42 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "rapidez/statamic",
"description": "Rapidez Statamic",
"keywords": [
"rapidez",
"statamic"
],
"homepage": "https://rapidez.io",
"license": "GPL-3.0",
"authors": [
{
"name": "Bob Wezelman",
"email": "bob@justbetter.nl",
"homepage": "https://justbetter.nl",
"role": "Developer"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.0|^8.1",
"statamic/cms": "^3.3"
},
"autoload": {
"psr-4": {
"Rapidez\\Statamic\\": "src"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"pixelfear/composer-dist-plugin": true
}
},
"extra": {
"laravel": {
"providers": [
"Rapidez\\Statamic\\RapidezStatamicServiceProvider"
]
}
}
}
10 changes: 10 additions & 0 deletions routes/fallback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
use Statamic\Facades\Data;

if ($entry = Data::findByRequestUrl(request()->url())) {
if (View::exists($entry->get('template'))) {
echo view($entry->get('template'), $entry->data());
} else if (View::exists(str($entry->structure()->handle())->singular()->toString())) {
echo view(str($entry->structure()->handle())->singular()->toString(), $entry->data());
}
}
14 changes: 14 additions & 0 deletions src/RapidezStatamicServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rapidez\Statamic;

use Illuminate\Support\ServiceProvider;
use TorMorten\Eventy\Facades\Eventy;

class RapidezStatamicServiceProvider extends ServiceProvider
{
public function boot()
{
Eventy::addFilter('routes', fn ($routes) => array_merge($routes ?: [], [__DIR__.'/../routes/fallback.php']));
}
}

0 comments on commit 2f2cda6

Please sign in to comment.