Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pôle IS
Bundles Symfony 2
ng-model-generator-bundle
Commits
c0654989
Commit
c0654989
authored
Apr 06, 2020
by
Guillaume Perréal
Browse files
Rend bloquantes les erreurs de mapping.
Mais améliore les messages d'erreurs.
parent
6873ed0f
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/php/ModelGenerator.php
View file @
c0654989
...
...
@@ -269,8 +269,8 @@ final class ModelGenerator
if
(
$repo
)
{
$repositories
[
$repo
->
getName
()]
=
$repo
;
}
}
catch
(
Exception
$ex
)
{
printf
(
"E
rror w
hile mapping
%s: %s
\n
%s
\n
"
,
$class
,
$ex
->
getMessage
(),
$ex
->
getTraceAsString
()
);
}
catch
(
\
Throwable
$ex
)
{
throw
new
DomainException
(
s
printf
(
'e
rror w
ith resource `
%s
`
: %s
'
,
$resourceMeta
->
getBaseName
()
,
$ex
->
getMessage
()
),
0
,
$ex
);
}
}
...
...
src/php/SerializationMapper.php
View file @
c0654989
...
...
@@ -103,21 +103,33 @@ final class SerializationMapper implements TypeFactoryInterface
{
if
(
class_exists
(
$name
))
{
$class
=
PHPClass
::
get
(
$name
);
if
(
$this
->
serialization
->
hasRepresentationOf
(
$class
))
{
$repr
=
$this
->
serialization
->
getRepresentationOf
(
$class
);
return
$this
->
defer
(
$repr
->
getName
())
->
resolveWith
(
function
()
use
(
$repr
)
{
return
$this
->
mapRepresentation
(
$repr
);
}
);
return
$this
->
deferredMapping
(
$name
,
$repr
->
getName
(),
function
()
use
(
$repr
)
{
return
$this
->
mapRepresentation
(
$repr
);
});
}
}
return
$this
->
typeFactory
->
get
(
$name
);
}
private
function
deferredMapping
(
string
$name
,
string
$actualName
,
callable
$mapper
):
Type
{
return
$this
->
defer
(
$actualName
)
->
resolveWith
(
function
()
use
(
$name
,
$mapper
)
{
try
{
return
$mapper
();
}
catch
(
\
Throwable
$ex
)
{
throw
new
DomainException
(
sprintf
(
'error with %s: %s'
,
$name
,
$ex
->
getMessage
()),
0
,
$ex
);
}
}
);
}
public
function
getResourceData
():
array
{
$resource
=
$this
->
serialization
->
getRoot
();
...
...
src/php/TypeFactory.php
View file @
c0654989
...
...
@@ -56,7 +56,7 @@ final class TypeFactory implements TypeFactoryInterface, \IteratorAggregate
}
if
(
!
isset
(
$this
->
types
[
$name
]))
{
throw
new
TypeNotFoundException
(
"
unknown type
${name}"
);
throw
new
TypeNotFoundException
(
"
type not defined:
${name}"
);
}
return
$this
->
types
[
$name
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment