gabriel преди 8 години
родител
ревизия
34bc66fa8f
променени са 1 файла, в които са добавени 87 реда и са изтрити 0 реда
  1. 87 0
      README.md

+ 87 - 0
README.md

@@ -0,0 +1,87 @@
+# OwnerVoterBundle
+
+- [Installation](#installation)
+- [Traits](#traits)
+- [Validator](#validators)
+
+## Installation
+
+**composer.json**:
+
+```javascript
+"repositories": [
+    {
+        "type": "vcs",
+        "url":  "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/OwnerVoter.git"
+    }
+],
+"require": {
+    "ik/owner-voter-bundle": "dev-master"
+},
+```
+
+**app/AppKernel.php**:
+
+```php
+public function registerBundles()
+{
+    $bundles = [
+        new OwnerVoterBundle\OwnerVoterBundle(),
+    ];
+    .
+    .
+}
+```
+
+**app/config/config.yml**:
+
+```yml
+imports:
+    - { resource: "@ExtraBundle/Resources/config/services.yml" }
+```
+
+## Traits
+
+- **Entity\Traits\OwnerVoterTrait**: Agrega el campo owner de tipo string con el nombre de usuario que se utilizará para chequear los permisos con Voter.
+
+```php
+use OwnerVoterBundle\Entity\Traits\OwnerVoterTrait;
+
+/**
+ * @ORM\Entity
+ */
+class Workflow
+{
+
+    use OwnerVoterTrait;
+
+```
+
+Luego ejecutar 
+
+```bash
+$ bin/console doctrine:schema:update --force
+```
+
+
+```php
+
+use Symfony\Component\Validator\Constraints as Assert;
+
+...
+
+    /**
+     * @var string $extraData
+     *
+     * @ORM\Column(type="string", length=128, nullable=false)
+     * 
+     * @Assert\NotBlank(
+     *   message="",
+     *   payload={"field"="owner"}
+     * )
+     */
+    private $owner;
+
+```
+La option **payload={"field"="owner"}**, es requerida, es el nombre del campo en el cual se quiere agregar el mensaje de error de validación.
+