add('randomId') ->add('redirectUris', CollectionType::class, array( 'entry_type' => null, 'allow_add' => true, 'allow_delete' => true, 'required' => true, )) ->add('secret') ->add('allowedGrantTypes', ChoiceType::class, array( 'choices' => OAuthClient::getGrantTypesChoices(), 'multiple' => true, 'expanded' => true, 'required' => true, )) ; } /** * @param DatagridMapper $datagridMapper */ protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper ->add('id') ->add('randomId') ->add('redirectUris') ->add('secret') ->add('allowedGrantTypes') ; } /** * @param ListMapper $listMapper */ protected function configureListFields(ListMapper $listMapper) { unset($this->listModes['mosaic']); $listMapper ->add('id') ->addIdentifier('randomId') ->add('redirectUris', 'array', array( 'template' => 'BaseOAuthServerBundle:OAuthClient:list_field_redirect_uris.html.twig', )) ->add('secret') ->add('allowedGrantTypes', 'array', array( 'template' => 'BaseOAuthServerBundle:OAuthClient:list_field_allowed_grant_types.html.twig', )) ; } /** * @param OauthClient $oauthclient */ public function preUpdate($oauthclient) { // Reindexar array de URIs $uris = $oauthclient->getRedirectUris(); $uris = array_values($uris); $oauthclient->setRedirectUris($uris); // Reindexar array de allowedGrantTypes $algt = $oauthclient->getAllowedGrantTypes(); $algt = array_values($algt); $oauthclient->setAllowedGrantTypes($algt); } }