original_string: public function prePersist(EventArgs $args)
      {
          $em = $args->getEntityManager();
          $object = $args->getObject();
          $class = get_class($object);
          $meta = $em->getClassMetadata($class);
  
          $reflectionClass = $meta->getReflectionClass();
  
          if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Sortable')) {
              return;
          } // return if current entity doesn't use Sortable trait
  
          if ($object->getSortRank()) {
              return;
          }
  
          $maxPos = $this->getMaxPosition($em, $meta);
          $maxPos = $maxPos ? $maxPos + 1000 : 65536;
  
          $object->setSortRank($maxPos);
          $this->maxPositions[$class] = $maxPos;
      }
code: public function prePersist(EventArgs $args)
      {
          $em = $args->getEntityManager();
          $object = $args->getObject();
          $class = get_class($object);
          $meta = $em->getClassMetadata($class);
  
          $reflectionClass = $meta->getReflectionClass();
  
          if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Sortable')) {
              return;
          } // return if current entity doesn't use Sortable trait
  
          if ($object->getSortRank()) {
              return;
          }
  
          $maxPos = $this->getMaxPosition($em, $meta);
          $maxPos = $maxPos ? $maxPos + 1000 : 65536;
  
          $object->setSortRank($maxPos);
          $this->maxPositions[$class] = $maxPos;
      }
code_tokens: public function prePersist ( EventArgs $ args ) { $ em = $ args -> getEntityManager ( ) ; $ object = $ args -> getObject ( ) ; $ class = get_class ( $ object ) ; $ meta = $ em -> getClassMetadata ( $ class ) ; $ reflectionClass = $ meta -> getReflectionClass ( ) ; if ( ! $ reflectionClass || ! $ this -> hasTrait ( $ reflectionClass , 'Blast\BaseEntitiesBundle\Entity\Traits\Sortable' ) ) { return ; } // return if current entity doesn't use Sortable trait if ( $ object -> getSortRank ( ) ) { return ; } $ maxPos = $ this -> getMaxPosition ( $ em , $ meta ) ; $ maxPos = $ maxPos ? $ maxPos + 1000 : 65536 ; $ object -> setSortRank ( $ maxPos ) ; $ this -> maxPositions [ $ class ] = $ maxPos ; }
docstring: Compute sortRank for entities that are created.
  
  @param EventArgs $args
docstring_tokens: Compute sortRank for entities that are created .