-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgenerate-service-provider.php
37 lines (25 loc) · 1.22 KB
/
generate-service-provider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use BladeComponents\Undraw\Api\Illustration;
use BladeComponents\Undraw\Api\IllustrationsRequest;
use BladeComponents\Undraw\Api\IllustrationsResponse;
use BladeComponents\Undraw\Api\UndrawClient;
require 'vendor/autoload.php';
$undrawClient = new UndrawClient();
$illustrationsRequest = new IllustrationsRequest($undrawClient);
$hasMore = true;
$page = 0;
$componentList = [];
while ($hasMore) {
$illustrationsResponse = new IllustrationsResponse($illustrationsRequest->page($page));
$hasMore = $illustrationsResponse->hasMore();
$page = $illustrationsResponse->nextPage();
/** @var Illustration $illustration */
foreach ($illustrationsResponse->illustrations() as $illustration) {
$className = sprintf('\BladeComponents\Undraw\Components\Illustrations\Undraw%sComponent::class', $illustration->studly());
$componentList[] = sprintf("%s => '%s'", $className, $illustration->slug());
}
}
sort($componentList);
$dummyServiceProvider = file_get_contents('stubs/UndrawServiceProvider.stub');
$content = str_replace('DummyComponentList', implode(',' . PHP_EOL . ' ', $componentList).',', $dummyServiceProvider);
file_put_contents('src/Providers/UndrawServiceProvider.php', $content);