-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to publish artifact package via API or composer push plugin
- Loading branch information
Showing
19 changed files
with
338 additions
and
62 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Packeton\Exception; | ||
|
||
use Symfony\Component\Form\FormInterface; | ||
|
||
class ValidationException extends \RuntimeException implements DebugHttpExceptionInterface | ||
{ | ||
private array $errors = []; | ||
|
||
public static function create(string $message, FormInterface|array $errors = [], ?\Throwable $previous = null): static | ||
{ | ||
$exception = new static($message, 400, $previous); | ||
$exception->errors = $errors instanceof FormInterface ? $exception->getErrors($errors) : $errors; | ||
|
||
return $exception; | ||
} | ||
|
||
private function getErrors(FormInterface $form): array | ||
{ | ||
$errors = $base = []; | ||
|
||
foreach ($form->getErrors() as $error) { | ||
$base[] = $error->getMessage(); | ||
} | ||
foreach ($form as $child) { | ||
foreach ($child->getErrors(true) as $error) { | ||
$errors[$child->getName()] = $error->getMessage(); | ||
} | ||
} | ||
if (count($base) > 0) { | ||
$errors['root'] = implode("\n", $base); | ||
} | ||
|
||
return $errors; | ||
} | ||
|
||
public function getFormErrors(): array | ||
{ | ||
return $this->errors; | ||
} | ||
} |
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,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Packeton\Exception; | ||
|
||
class ZipballException extends \RuntimeException implements DebugHttpExceptionInterface | ||
{ | ||
} |
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.