Sfoglia il codice sorgente

simplify sample code

the getSubject() method does pretty much what is shown in the example.
Grégoire Paris 10 anni fa
parent
commit
923b13ccb2
1 ha cambiato i file con 1 aggiunte e 3 eliminazioni
  1. 1 3
      Resources/doc/cookbook/recipe_custom_action.rst

+ 1 - 3
Resources/doc/cookbook/recipe_custom_action.rst

@@ -100,9 +100,7 @@ to implement a ``clone`` action.
     {
         public function cloneAction()
         {
-            $id = $this->get('request')->get($this->admin->getIdParameter());
-
-            $object = $this->admin->getObject($id);
+            $object = $this->admin->getSubject();
 
             if (!$object) {
                 throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));