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; }
public function serializerAction() { $article = new Article(); $article->setPath('/foo'); $article->setTitle('Example use of the default handlers'); $article->setBody("Read up on JMSSerializerBundle to see how what other handlers exist "); $view = new View(); $view->setData($article); $context = new SerializationContext(); $context->setVersion('2.1'); $context->setGroups(array('data')); $view->setSerializationContext($context); return $this->viewHandler->handle($view); }