private function createArticle($article) { $text = $article; $article = new Article(); $article->setPath('/' . $text); $article->setTitle($text); $article->setBody("This article is about '{$text}' and its really great and all"); return $article; }
/** * alternatively use class="LiipHelloBundle:Article", but this has a bit more overhead * * @ParamConverter("article", class="Liip\HelloBundle\Document\Article") */ public function converterAction(Article $article = null) { $view = new View(); $view->setTemplate(new TemplateReference('LiipHelloBundle', 'Hello', 'index')); $name = $article ? 'found: ' . $article->getTitle() : 'No found'; $view->setData(array('name' => $name)); $viewHandler = $this->container->get('my_view'); return $viewHandler->handle($view); }
public function validationFailureAction() { $validator = $this->validator; $article = new Article(); //$article->setPath('/foo'); $article->setTitle('The path was set'); $article->setBody('Disable the setPath() call to get a validation error example'); $view = new View(); $errors = $validator->validate($article); if (count($errors)) { $view->setStatusCode(400); $view->setData($errors); } else { $view->setData($article); } return $this->viewHandler->handle($view); }
public function serializeJsonLd(JsonSerializationVisitor $visitor, Article $article, array $type) { $visitor->setRoot(array('@' => $article->getFullpath(), 'a' => 'sioc:Post', 'dcterms:partOf' => $article->getBasePath(), 'dcterms:title' => $article->getTitle(), 'sioc:content' => $article->getBody())); }