Exemplo n.º 1
0
 public function getDefaultDiffTarget()
 {
     if ($this->isFinal() && $this->isLatest()) {
         $latest_terms = TermsQuery::create()->latest()->find();
         $terms = $latest_terms->getNext();
     } else {
         $terms = Terms::getLatest();
     }
     return $terms;
 }
 public function validate($value, Constraint $constraint)
 {
     $terms = Terms::getLatest();
     if ($terms->getId() !== $value) {
         if ($this->context instanceof ExecutionContextInterface) {
             $this->context->buildViolation($constraint->message)->addViolation();
         } else {
             // 2.4 API
             $this->context->addViolation($constraint->message);
         }
     }
 }
 /**
  * @Route("/diff", name="cp_terms_diff")
  * @Template()
  */
 public function diffAction(Request $request)
 {
     if ($this->container->has('cp_terms.entity_finder')) {
         $entity_finder = $this->container->get('cp_terms.entity_finder');
         $entity = $entity_finder->findEntity();
     } else {
         throw $this->createNotFoundException('Page not found.');
     }
     $terms_last_agreed = $entity->getLastAgreedTerms();
     $terms_latest = Terms::getLatest();
     if (!$terms_last_agreed || $terms_last_agreed == $terms_latest) {
         // users don't get here unless direct url to this page is entered
         return $this->redirect($this->generateUrl('cp_terms'));
     }
     $theme = $this->container->getParameter('cp_terms.diff.theme');
     return array('terms' => $terms_last_agreed, 'terms_latest' => $terms_latest, 'theme' => $theme);
 }