Преглед на файлове

rename setGroup to setGroups and use plural in general

Christian Stocker преди 13 години
родител
ревизия
97c25dddc9
променени са 5 файла, в които са добавени 17 реда и са изтрити 21 реда
  1. 4 4
      Annotation/Group.php
  2. 2 6
      Metadata/Driver/AnnotationDriver.php
  3. 3 3
      Metadata/PropertyMetadata.php
  4. 3 3
      Serializer/Exclusion/GroupExclusionStrategy.php
  5. 5 5
      Serializer/Serializer.php

+ 4 - 4
Annotation/Group.php

@@ -24,15 +24,15 @@ use JMS\SerializerBundle\Exception\RuntimeException;
  * @Annotation
  * @Target("PROPERTY")
  */
-final class Group
+final class Groups
 {
-    public $group;
+    public $groups;
 
     public function __construct(array $values)
     {
         if (!isset($values['value']) || !is_array($values['value'])) {
-            throw new RuntimeException('$group must be a array.');
+            throw new RuntimeException('$groups must be a array.');
         }
-        $this->group = $values['value'];
+        $this->groups = $values['value'];
     }
 }

+ 2 - 6
Metadata/Driver/AnnotationDriver.php

@@ -20,8 +20,6 @@ namespace JMS\SerializerBundle\Metadata\Driver;
 
 use JMS\SerializerBundle\Annotation\AccessorOrder;
 
-use JMS\SerializerBundle\Annotation\Groups;
-
 use JMS\SerializerBundle\Annotation\Accessor;
 
 use JMS\SerializerBundle\Annotation\AccessType;
@@ -38,7 +36,7 @@ use Metadata\MethodMetadata;
 use Doctrine\Common\Annotations\Reader;
 use JMS\SerializerBundle\Annotation\Type;
 use JMS\SerializerBundle\Annotation\Exclude;
-use JMS\SerializerBundle\Annotation\Group;
+use JMS\SerializerBundle\Annotation\Groups;
 use JMS\SerializerBundle\Annotation\Expose;
 use JMS\SerializerBundle\Annotation\SerializedName;
 use JMS\SerializerBundle\Annotation\Until;
@@ -100,8 +98,6 @@ class AnnotationDriver implements DriverInterface
                         $propertyMetadata->serializedName = $annot->name;
                     } else if ($annot instanceof Expose) {
                         $isExpose = true;
-                    } else if ($annot instanceof Group) {
-                        $propertyMetadata->group = $annot->group;
                     } else if ($annot instanceof Exclude) {
                         $isExclude = true;
                     } else if ($annot instanceof Type) {
@@ -124,7 +120,7 @@ class AnnotationDriver implements DriverInterface
                     } else if ($annot instanceof Accessor) {
                         $accessor = array($annot->getter, $annot->setter);
                     } else if ($annot instanceof Groups) {
-                        $propertyMetadata->setGroups($annot->names);
+                        $propertyMetadata->groups = $annot->groups;
                     } else if ($annot instanceof Inline) {
                         $propertyMetadata->inline = true;
                     } else if ($annot instanceof ReadOnly) {

+ 3 - 3
Metadata/PropertyMetadata.php

@@ -27,7 +27,7 @@ class PropertyMetadata extends BasePropertyMetadata
 
     public $sinceVersion;
     public $untilVersion;
-    public $group;
+    public $groups;
     public $serializedName;
     public $type;
     public $xmlCollection = false;
@@ -74,7 +74,7 @@ class PropertyMetadata extends BasePropertyMetadata
         return serialize(array(
             $this->sinceVersion,
             $this->untilVersion,
-            $this->group,
+            $this->groups,
             $this->serializedName,
             $this->type,
             $this->xmlCollection,
@@ -96,7 +96,7 @@ class PropertyMetadata extends BasePropertyMetadata
         list(
             $this->sinceVersion,
             $this->untilVersion,
-            $this->group,
+            $this->groups,
             $this->serializedName,
             $this->type,
             $this->xmlCollection,

+ 3 - 3
Serializer/Exclusion/GroupExclusionStrategy.php

@@ -21,7 +21,7 @@ namespace JMS\SerializerBundle\Serializer\Exclusion;
 use JMS\SerializerBundle\Metadata\ClassMetadata;
 use JMS\SerializerBundle\Metadata\PropertyMetadata;
 
-class GroupExclusionStrategy implements ExclusionStrategyInterface
+class GroupsExclusionStrategy implements ExclusionStrategyInterface
 {
     private $groups = array();
 
@@ -46,8 +46,8 @@ class GroupExclusionStrategy implements ExclusionStrategyInterface
      */
     public function shouldSkipProperty(PropertyMetadata $property)
     {
-        if ($this->groups && $property->group) {
-            foreach ($property->group as $group) {
+        if ($this->groups && $property->groups) {
+            foreach ($property->groups as $group) {
                 if (isset($this->groups[$group])) {
                     return false;
                 }

+ 5 - 5
Serializer/Serializer.php

@@ -22,7 +22,7 @@ use JMS\SerializerBundle\Exception\UnsupportedFormatException;
 use Metadata\MetadataFactoryInterface;
 use JMS\SerializerBundle\Exception\InvalidArgumentException;
 use JMS\SerializerBundle\Serializer\Exclusion\VersionExclusionStrategy;
-use JMS\SerializerBundle\Serializer\Exclusion\GroupExclusionStrategy;
+use JMS\SerializerBundle\Serializer\Exclusion\GroupsExclusionStrategy;
 use JMS\SerializerBundle\Serializer\Exclusion\ExclusionStrategyInterface;
 
 class Serializer implements SerializerInterface
@@ -55,15 +55,15 @@ class Serializer implements SerializerInterface
         $this->exclusionStrategy = new VersionExclusionStrategy($version);
     }
     
-    public function setGroup($group)
+    public function setGroups($groups)
     {
-        if (null === $group) {
-            $this->group = null;
+        if (null === $groups) {
+            $this->exclusionStrategy = null;
 
             return;
         }
 
-        $this->exclusionStrategy = new GroupExclusionStrategy($group);
+        $this->exclusionStrategy = new GroupsExclusionStrategy($groups);
     }
 
     public function serialize($data, $format)