-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ResourceBundle] Default Form builder for PHPCR-ODM #5039
Conversation
'autocreate' => false, | ||
], | ||
$metadata->hasParameter('options') ? $metadata->getParameter('options') : [] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have options handled in some way that provided defaults and disallowed specification of non-valid keys.
ee4591d
to
d50d44c
Compare
{ | ||
$classMetadata = $this->documentManager->getClassMetadata($metadata->getClass('model')); | ||
|
||
// the field mappings should only contain standard value mappings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. but sadly they don't ...
$defaultFormBuilderDefinition->setArguments([ | ||
new Reference($metadata->getServiceId('manager')), | ||
$options['default_parent_path'], | ||
$options['autocreate'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There options only apply to the DefaultFormBuilder
- which means that as soon as the user creates a custom form type these values become meaningless.
I wonder if these should be implemented as a PHPCR-ODM EventSubscribers instead.
@@ -17,6 +17,8 @@ | |||
use Symfony\Component\DependencyInjection\ContainerBuilder; | |||
use Symfony\Component\DependencyInjection\Definition; | |||
use Symfony\Component\DependencyInjection\Reference; | |||
use Sylius\Bundle\ResourceBundle\Doctrine\ODM\PHPCR\EventListener\Subscriber\NameResolverListener; | |||
use Sylius\Bundle\ResourceBundle\Doctrine\ODM\PHPCR\EventListener\Subscriber\DefaultPathListener; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dd
8d9f822
to
31979b0
Compare
[ | ||
'default_parent_path' => null, | ||
'autocreate' => false, | ||
'force' => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to force_default_parent
Updated, refactored to have an event listener-per-resource and added specs. This is now ready-for-review. |
- Automatic generation of form - Option to specify default path - Resolve node name conflicts and normalize the path
31979b0
to
325632d
Compare
ping @pjedrzejewski |
325632d
to
3fc5987
Compare
@dantleech Looks good to me! Waiting for last tweaks and it is good to go. 👍 Nice work! We will be using all the PHPCR stuff for grids and resources in the new admin, your work has been a huge help! |
3fc5987
to
d356423
Compare
if ($diff = array_diff(array_keys($metadataOptions), array_keys($defaultOptions))) { | ||
throw new InvalidArgumentException(sprintf( | ||
'Unknown PHPCR-ODM configuration options: "%s"', | ||
implode('", "', $diff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the options and added this sanity check.
Great work, thank you Dan! 👍 |
Thanks! I am currently working on a CMS which uses only Sylius Resource/Grid + Symfony CMF, with the aim of providing an alternative to Sonata Admin. So expect more contributions :) |
[ResourceBundle] Default Form builder for PHPCR-ODM
This PR adds a
DefaultFormBuilder
for the PHPCR-ODM resource.In addition, because of the tree nature of PHPCR I have added three event
listeners which: handle the default parent path, resolve name conflcits and
remove invalid characters from the node name.
These are configured in the resource config: