Prechádzať zdrojové kódy

Merge pull request #3379 from mcwebb/master

add more config info to Lock Protection cookbook
Oskar Stark 9 rokov pred
rodič
commit
f518483f57

+ 44 - 0
Resources/doc/cookbook/recipe_lock_protection.rst

@@ -29,6 +29,50 @@ You can enable it in your ``sonata_admin`` configuration :
         sonata_admin:
             options:
                 lock_protection: true
+                
+You must also configure each entity that you want to support by adding a field called ``$version`` on which the Doctrine ``Version`` feature is activated.
+
+Using Annotations:
+
+.. code-block:: php
+
+    <?php
+    // src/AppBundle/Entity/Car.php
+    namespace AppBundle\Entity\Car;
+    
+    use Doctrine\ORM\Mapping as ORM;
+
+    class Car
+    {
+        // ...
+        
+        /**
+         * @ORM\Column(type="integer")
+         * @ORM\Version
+         */
+        protected $version;
+        
+        // ...
+    }
+
+Using XML:
+
+.. code-block:: xml
+
+    <?xml version="1.0" encoding="utf-8"?>
+    <!-- src/AppBundle/Resources/orm/Car.orm.xml -->
+    <doctrine-mapping>
+        <entity name="AppBundle\Entity\Car">
+            <!-- ... -->
+    
+            <field name="version" type="integer" version="true" />
+    
+            <!-- ... -->
+        </entity>
+    </doctrine-mapping>
+    
+
+For more information about this visit the `Doctrine docs <http://doctrine-orm.readthedocs.org/en/latest/reference/transactions-and-concurrency.html?highlight=optimistic#optimistic-locking>`_
 
 .. note::