示例#1
0
 /**
  * @inheritDoc
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     parent::configureOptions($resolver);
     $resolver->setDefault('methods', function (Options $options, array $previousValue) {
         return $options['rest_route'] ? ['POST'] : $previousValue;
     });
     $resolver->setDefault('pattern', function (Options $options) {
         return $options['rest_route'] ? '.{_format}' : '/add.{_format}';
     });
     $resolver->setDefault('defaults', function (Options $options) {
         $format = $options['rest_route'] ? 'json' : 'html';
         return ['_format' => $format];
     });
 }
示例#2
0
 /**
  * @inheritDoc
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     parent::configureOptions($resolver);
     $resolver->setDefault('methods', function (Options $options, $previousValue) {
         if ($options['rest_route']) {
             return ['POST'];
         }
         return $previousValue;
     });
     $resolver->setDefault('pattern', function (Options $options) {
         if ($options['rest_route']) {
             return '/';
         }
         return '/add';
     });
 }
示例#3
0
 /**
  * @inheritDoc
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     parent::configureOptions($resolver);
     $resolver->setDefault('requirements', ['id' => '\\d+']);
     $resolver->setDefault('pattern', function (Options $options) {
         if ($options['rest_route']) {
             return '/{id}';
         }
         return '/edit/{id}';
     });
     $resolver->setDefault('methods', function (Options $options, $previousValue) {
         if ($options['rest_route']) {
             return ['PUT'];
         }
         return $previousValue;
     });
 }