Knp\Bundle\KnpBundlesBundle\Entity\Bundle::hasChanges PHP Method

hasChanges() public method

public hasChanges ( ) : boolean
return boolean
    public function hasChanges()
    {
        if ($this->getLatestScoreDetails()) {
            return $this->getLatestScoreDetails()->getHash() !== $this->getStatusHash();
        }
        return true;
    }

Usage Example

 /**
  * Updates bundle score
  *
  * @param Bundle $bundle
  * @param object $repository
  */
 private function updateScore(Bundle $bundle, $repository)
 {
     if (!$bundle->hasChanges()) {
         return;
     }
     $score = $repository->findOneBy(array('date' => new \DateTime(), 'bundle' => $bundle->getId()));
     if (!$score) {
         $score = new Score();
         $score->setBundle($bundle);
     }
     $score->setValue($bundle->getScore());
     $this->em->persist($score);
     $this->em->flush();
 }