setSortableBy() public method

Set list of relative properties that this relationship can be sorted by
public setSortableBy ( array $sortable_by )
$sortable_by array
コード例 #1
0
 /**
  * Create a relationship from an annotation
  *
  * @param string                         $name
  * @param RelationshipType               $type
  * @param AbstractRelationshipAnnotation $annotation
  * @return Relationship
  */
 private function createRelationship($name, RelationshipType $type, AbstractRelationshipAnnotation $annotation)
 {
     $target = new AnnotationMetadataParser($annotation->target);
     $relationship = new Relationship($name, $type);
     $relationship->setSource($this->reflection_obj->name)->setTarget($annotation->target)->setSourceTable($this->getTableName())->setTargetTable($target->getTableName())->setGetter($annotation->getter)->setSetter($annotation->setter)->setInversedBy($annotation->inversed_by);
     if ($annotation instanceof AbstractSortableRelationshipAnnotation && $annotation->sortable_by) {
         $sortables = [];
         foreach ($annotation->sortable_by as $sortable) {
             if ($sortable instanceof SortableAnnotation) {
                 $conditions = [];
                 foreach ($sortable->conditions as $condition) {
                     if ($condition instanceof ConditionAnnotation) {
                         $this->testConditionAnnotation($condition);
                         $conditions[] = new Condition($condition->column, $condition->method, $condition->value, $condition->comparison);
                     } else {
                         throw new UnexpectedValueException(self::ERR_UNKNOWN_CONDITION);
                     }
                 }
                 $sortables[] = new Sortable($sortable->column, $conditions, $sortable->name);
             } elseif (is_string($sortable)) {
                 $sortables[] = new Sortable($sortable);
             } else {
                 throw new UnexpectedValueException(self::ERR_UNKNOWN_SORTABLE);
             }
         }
         $relationship->setSortableBy($sortables);
     }
     return $relationship;
 }