-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from digitaldreams/develop
Develop
- Loading branch information
Showing
46 changed files
with
966 additions
and
364 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
symfonycasts_reset_password: | ||
request_password_repository: App\Repository\ResetPasswordRequestRepository | ||
request_password_repository: App\Persistence\Repository\ResetPasswordRequestRepository |
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,13 @@ | ||
<?php | ||
|
||
namespace App\Attribute; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
readonly class FillDto | ||
{ | ||
public function __construct() | ||
{ | ||
} | ||
} |
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,55 @@ | ||
<?php | ||
|
||
namespace App\Attribute; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; | ||
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; | ||
|
||
use function Symfony\Component\String\u; | ||
|
||
class FillDtoResolver implements ValueResolverInterface | ||
{ | ||
|
||
public function resolve(Request $request, ArgumentMetadata $argument): iterable | ||
{ | ||
$attribute = $argument->getAttributesOfType( | ||
FillDto::class, | ||
ArgumentMetadata::IS_INSTANCEOF | ||
)[0] ?? null; | ||
|
||
if (!$attribute) { | ||
return []; | ||
} | ||
|
||
$fillDto = $argument->getAttributesOfType(FillDto::class, ArgumentMetadata::IS_INSTANCEOF)[0]; | ||
|
||
if ($argument->isVariadic()) { | ||
throw new \LogicException( | ||
sprintf('Mapping variadic argument "$%s" is not supported.', $argument->getName()) | ||
); | ||
} | ||
$reflectionClass = new \ReflectionClass($argument->getType()); | ||
$dtoClass = $reflectionClass->newInstanceWithoutConstructor(); | ||
|
||
$queryParams = $request->query->all(); | ||
$requestParams = $request->request->all(); | ||
foreach (array_merge($queryParams, $requestParams) as $property => $value) { | ||
$attribute = u($property)->camel(); | ||
if (property_exists($dtoClass, $attribute)) { | ||
$reflectionProperty = $reflectionClass->getProperty($attribute); | ||
$reflectionProperty->setValue($dtoClass, $value); | ||
} | ||
} | ||
$files = $request->files->all(); | ||
foreach ($files as $fileKey => $file) { | ||
$attribute = u($fileKey)->camel(); | ||
if (property_exists($dtoClass, $attribute)) { | ||
$reflectionProperty = $reflectionClass->getProperty($attribute); | ||
$reflectionProperty->setValue($dtoClass, $file); | ||
} | ||
} | ||
|
||
return [$dtoClass]; | ||
} | ||
} |
Empty file.
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
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.