-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e987b0e
commit 0ee5696
Showing
10 changed files
with
200 additions
and
297 deletions.
There are no files selected for viewing
75 changes: 0 additions & 75 deletions
75
...Laravel/ClassPropertyProcessors/ReplaceLaravelCollectionByArrayClassPropertyProcessor.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Spatie\TypeScriptTransformer\Laravel; | ||
|
||
use Illuminate\Pagination\CursorPaginator; | ||
use Illuminate\Pagination\LengthAwarePaginator; | ||
use Spatie\LaravelData\CursorPaginatedDataCollection; | ||
use Spatie\LaravelData\PaginatedDataCollection; | ||
use Spatie\TypeScriptTransformer\References\ClassStringReference; | ||
use Spatie\TypeScriptTransformer\Support\TransformedCollection; | ||
use Spatie\TypeScriptTransformer\Transformed\Transformed; | ||
use Spatie\TypeScriptTransformer\TypeProviders\TypesProvider; | ||
use Spatie\TypeScriptTransformer\TypeScript\TypeReference; | ||
use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; | ||
use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGeneric; | ||
use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; | ||
use Spatie\TypeScriptTransformer\TypeScriptTransformerConfig; | ||
|
||
class LaravelDataTypesProvider implements TypesProvider | ||
{ | ||
public function provide(TypeScriptTransformerConfig $config, TransformedCollection $types): void | ||
{ | ||
$types->add( | ||
$this->paginatedCollection(), | ||
$this->cursorPaginatedCollection(), | ||
); | ||
} | ||
|
||
protected function paginatedCollection(): Transformed | ||
{ | ||
return new Transformed( | ||
new TypeScriptAlias( | ||
new TypeScriptGeneric( | ||
new TypeScriptIdentifier('PaginatedDataCollection'), | ||
[new TypeScriptIdentifier('TKey'), new TypeScriptIdentifier('TValue')], | ||
), | ||
new TypeReference(new ClassStringReference(LengthAwarePaginator::class)) | ||
), | ||
new ClassStringReference(PaginatedDataCollection::class), | ||
['Spatie', 'LaravelData'], | ||
true, | ||
); | ||
} | ||
|
||
protected function cursorPaginatedCollection(): Transformed | ||
{ | ||
return new Transformed( | ||
new TypeScriptAlias( | ||
new TypeScriptGeneric( | ||
new TypeScriptIdentifier('CursorPaginatedDataCollection'), | ||
[new TypeScriptIdentifier('TKey'), new TypeScriptIdentifier('TValue')], | ||
), | ||
new TypeReference(new ClassStringReference(CursorPaginator::class)) | ||
), | ||
new ClassStringReference(CursorPaginatedDataCollection::class), | ||
['Spatie', 'LaravelData'], | ||
true, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.