Nie ma sprawy.
\Apps\BaseBundle\Util\Event\Ranking::actualizeAll
public function actualizeAllForContent(\Apps\BaseBundle\Entity\Content $Content,
\Doctrine\ORM\EntityManager $em,
$type = 'all'){
if($type == 'all' || $type == Ranking::DAILY){
$this->actualizeDailyPoints($Content, $em);
}
if($type == 'all' || $type == Ranking::WEEKLY){
$this->actualizeWeeklyPoints($Content, $em);
}
if($type == 'all' || $type == Ranking::MONTHLY){
$this->actualizeMonthlyPoints($Content, $em);
}
}
\Apps\BaseBundle\Util\Event\Ranking::actualizeDailyPoints
public function actualizeDailyPoints(\Apps\BaseBundle\Entity\Content $Content,
\Doctrine\ORM\EntityManager $em){
try{
$contentRankingRepo = $em->getRepository('AppsBaseBundle:ContentRanking');
$contentRankingRepo->actualizeDailyPoints($Content);
} catch (\Exception $e){
}
}
AppsBaseBundle:ContentRanking->actualizeDailyPoints
function actualizeDailyPoints(\Apps\BaseBundle\Entity\Content $Content){
$em = $this->getEntityManager();
$Rankimg = new Ranking();
$daylyPoints = $Rankimg->getSumForDay($Content, $this->getEntityManager());
$Ranking = $this->findOneBy(array('content_id'=>$Content->getId(), 'type'=> Ranking::DAILY,
'date'=>new \DateTime('now')));
if(! $Ranking){
$Ranking = new \Apps\BaseBundle\Entity\ContentRanking();
$Ranking->setContentId($Content->getId());
$Ranking->setDate(new \DateTime('now'));
$Ranking->setType(Ranking::DAILY);
}
$Ranking->setPoints($daylyPoints);
$em = $this->getEntityManager();
$em->persist($Ranking);
$em->flush();
//echo $points;
}
Log (Repository)
class LogRepository extends EntityRepository{
public function addLog($place,$description,$type){
$Log = new \Apps\BaseBundle\Entity\Log();
$Log->setDateTime(new \DateTime('now'));
$Log->setType($type);
$Log->setPlace($place);
$Log->setDescription($description);
$em = $this->getEntityManager();
$em->persist($Log);
$em->flush();
}
}
CronCommand::endOfTheDay - jest tu bez znaczenia - wykonuje się raz na dobę - o północy. Przy testowaninu nie jest uruchamiany.
Ok. Znalazlem problem. Zostawie dla potomnych.
Okazało się, że w metodzie:
AppsBaseBundle:ContentRanking->actualizeDailyPoints
function actualizeDailyPoints(\Apps\BaseBundle\Entity\Content $Content){
$em = $this->getEntityManager();
$Rankimg = new Ranking();
$daylyPoints = $Rankimg->getSumForDay($Content, $this->getEntityManager());
$Ranking = $this->findOneBy(array('content_id'=>$Content->getId(), 'type'=> Ranking::DAILY,
'date'=>new \DateTime('now')));
if(! $Ranking){
$Ranking = new \Apps\BaseBundle\Entity\ContentRanking();
$Ranking->setContentId($Content->getId());
$Ranking->setDate(new \DateTime('now'));
$Ranking->setType(Ranking::DAILY);
}
$Ranking->setPoints($daylyPoints);
$em = $this->getEntityManager();
$em->persist($Ranking);
$em->flush();
//echo $points;
}
w tym wierszu:
$Ranking->setContentId($Content->getId());
podawałem ID contentu. Niestety mam też zmapowaną relację do Contentu. Wyglądało to najprawdopodobniej tak, że ja mu podałem ID a on go nie wiadomo dlaczego nie zapisał.
Zamieniłem ten wpis na:
$Ranking->setContent($Content);
i wszystko lata.
Pozdrawiam szanowne grono.