Skip to content

Commit f632c14

Browse files
committed
Initial Commit
0 parents  commit f632c14

19 files changed

+1136
-0
lines changed

README.md

Whitespace-only changes.

composer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "pderas/vuex-hydrate",
3+
"description": "A Vuex plugin to hydrate your vuex store from PHP.",
4+
"keywords": ["vuex", "hydrate", "laravel"],
5+
"homepage": "https://github.com/PDERAS/vuex-hydrate",
6+
"type": "library",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Drew Bindon",
11+
"email": "[email protected]"
12+
}
13+
],
14+
"require": {
15+
"php": "^7.2"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"Pderas\\VuexHydrate": "src/"
20+
},
21+
"files": [
22+
"src/helpers.php"
23+
]
24+
},
25+
"extra": {
26+
"laravel": {
27+
"providers": [
28+
"Pderas\\VuexHydrate\\VuexHydrateServiceProvider"
29+
],
30+
"aliases": {
31+
"Vuex": "Pderas\\VuexHydrate\\Facades\\Vuex"
32+
}
33+
}
34+
},
35+
"minimum-stability": "dev"
36+
}

src/Commands/MakeModuleLoader.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Pderas\VuexHydrate\Commands;
6+
7+
use Illuminate\Console\Command;
8+
use Illuminate\Support\Str;
9+
10+
class MakeModuleLoader extends Command
11+
{
12+
/**
13+
* The console command name.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'make:loader
18+
{module : Vuex module namespace}';
19+
20+
/**
21+
* Hides the command from the php artisan route helper.
22+
*/
23+
protected function configure(): void
24+
{
25+
//
26+
}
27+
28+
/**
29+
* Execute the console command.
30+
*/
31+
public function handle(): void
32+
{
33+
$module = Str::studly($this->argument('module'));
34+
35+
file_put_contents(
36+
app_path("VuexLoaders/{$module}ModuleLoader.php"),
37+
$this->compileModuleLoaderStub($module)
38+
);
39+
}
40+
41+
protected function compileModuleLoaderStub($module)
42+
{
43+
$namespaced = str_replace(
44+
'{{namespace}}',
45+
$this->laravel->getNamespace(),
46+
file_get_contents(__DIR__.'/../stubs/ModuleLoader.stub')
47+
);
48+
49+
return str_replace('{{module}}', $module, $namespaced);
50+
}
51+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Pderas\VuexHydrate\Exceptions;
4+
5+
use Exception;
6+
7+
class VuexInvalidKeyException extends Exception {
8+
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Pderas\VuexHydrate\Exceptions;
4+
5+
use Exception;
6+
7+
class VuexInvalidModuleException extends Exception {
8+
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Pderas\VuexHydrate\Exceptions;
4+
5+
use Exception;
6+
7+
class VuexInvalidStateException extends Exception {
8+
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Pderas\VuexHydrate\Exceptions;
4+
5+
use Exception;
6+
7+
class VuexMissingRequiredParameter extends Exception {
8+
9+
}

src/Facades/Vuex.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Pderas\VuexHydrate\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
use Pderas\VuexHydrate\Factories\VuexFactory;
7+
8+
class Vuex extends Facade {
9+
protected static function getFacadeAccessor()
10+
{
11+
return VuexFactory::class;
12+
}
13+
}

0 commit comments

Comments
 (0)