本文整理汇总了PHP中AppBundle\Entity\Post::setTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::setTitle方法的具体用法?PHP Post::setTitle怎么用?PHP Post::setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\Post
的用法示例。
在下文中一共展示了Post::setTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load(ObjectManager $manager)
{
$faker = Factory::create();
for ($i = 0; $i < 50; $i++) {
static $id = 1;
$post = new Post();
$post->setTitle($faker->sentence);
$post->setAuthorEmail('user_admin@blog.com');
$post->setImageName("images/post/foto{$id}.jpg");
$post->setContent($faker->realText($maxNbChars = 5000, $indexSize = 2));
$marks = array();
for ($q = 0; $q < rand(1, 10); $q++) {
$marks[] = rand(1, 5);
}
$post->setMarks($marks);
$post->addMark(5);
$manager->persist($post);
$this->addReference("{$id}", $post);
$id = $id + 1;
$rand = rand(3, 7);
for ($j = 0; $j < $rand; $j++) {
$comment = new Comment();
$comment->setAuthorEmail('user_user@blog.com');
$comment->setCreatedBy('user_user');
$comment->setContent($faker->realText($maxNbChars = 500, $indexSize = 2));
$comment->setPost($post);
$post->getComments()->add($comment);
$manager->persist($comment);
$manager->flush();
}
}
$manager->flush();
}
示例2: loadPosts
private function loadPosts(ObjectManager $manager)
{
$category = new Category();
$category->setName('Improvements');
foreach (range(1, 5) as $i) {
$post = new Post();
$post->setTitle($this->getRandomPostTitle());
$post->setSummary($this->getRandomPostSummary());
$post->setSlug($this->container->get('slugger')->slugify($post->getTitle()));
$post->setContent($this->getPostContent());
$post->setAuthorEmail('a.martynenko@levi9.com');
$post->setPublishedAt(new \DateTime('now - ' . $i . 'days'));
$post->setState($this->getRandomState());
$post->setCategory($category);
foreach (range(1, 5) as $j) {
$comment = new Comment();
$comment->setAuthorEmail('d.kiprushev@levi9.com');
$comment->setPublishedAt(new \DateTime('now + ' . ($i + $j) . 'seconds'));
$comment->setContent($this->getRandomCommentContent());
$comment->setPost($post);
$manager->persist($comment);
$post->addComment($comment);
}
if (rand(0, 1)) {
$vote = new Vote();
$vote->setAuthorEmail(rand(0, 1) ? 'a.martynenko@levi9.com' : 'd.kiprushev@levi9.com');
$vote->setPost($post);
$vote->setVote(rand(0, 1));
}
$manager->persist($post);
$category->addPost($post);
}
$manager->flush();
}
示例3: loadPosts
private function loadPosts(ObjectManager $manager)
{
foreach (range(1, 30) as $i) {
$post = new Post();
$post->setTitle('Sed ut perspiciatis unde');
$post->setAlias('Sed ut perspiciatis unde');
$post->setIntrotext('Sed ut perspicantium, tocto beatae vitae dicta sunt explicabo. ');
$post->setSlug($this->container->get('slugger')->slugify($post->getTitle()));
$post->setBody('Sed ut is iste uasi architecto beatae vitae dicta sunt explicabo. ');
$post->setAuthorEmail('anna_admin@symfony.com');
$post->setPublishedAt(new \DateTime('now - ' . $i . 'days'));
$post->setState(1);
$post->setImages('test.jpg');
foreach (range(1, 5) as $j) {
$comment = new Comment();
$comment->setAuthorEmail('john_user@symfony.com');
$comment->setPublishedAt(new \DateTime('now + ' . ($i + $j) . 'seconds'));
$comment->setContent('Sed ut perspiciatis undedasdadasd');
$comment->setPost($post);
$manager->persist($comment);
$post->addComment($comment);
}
$manager->persist($post);
}
$manager->flush();
}
示例4: createAction
/**
* @Route("/create", name="create_objects")
*
* @Rest\View()
*
* @return Response
*/
public function createAction()
{
// We need an entity manager here
$em = $this->getDoctrine()->getManager();
// First, we try to create a post
$post = new Post();
$post->setTitle('Hello World');
$post->setContent('This is a hello world post');
$post->setCreated(new \DateTime());
$em->persist($post);
// Create new post log object
$postLog = new PostLog();
$postLog->setMessage('A new post was created');
$postLog->setCreated(new \DateTime());
$postLog->setParent($post);
$em->persist($postLog);
// Try to create a category
$category = new Category();
$category->setTitle('A Category');
$category->setDescription('A category to created');
$em->persist($category);
// Create new category log object
$categoryLog = new CategoryLog();
$categoryLog->setMessage('A new category was created');
$categoryLog->setCreated(new \DateTime());
$categoryLog->setParent($category);
$em->persist($categoryLog);
// Actually store all the entities to the database
// to get id of the post and the category
$em->flush();
return ['Done'];
}
示例5: load
public function load(ObjectManager $manager)
{
// TODO: Implement load() method.
$category = new Category();
$category->setName('Default');
$manager->persist($category);
foreach (range(1, 100) as $i) {
$post = new Post();
$post->setTitle($this->getPostTitle());
$post->setSlug($this->container->get('slugger')->slugify($post->getTitle()));
$post->setImage('post.jpeg');
$post->setContent($this->getPostContent());
$post->setAuthor('gunyem');
$post->setCreated(new \DateTime('now - ' . $i . 'days'));
$post->setUpdated(new \DateTime('now - ' . $i . 'days'));
$post->setCategory($category);
foreach (range(1, 10) as $j) {
$comment = new Comment();
$comment->setPost($post);
$comment->setContent($this->getPostTitle());
$comment->setAuthor('gunyem');
$comment->setCreated(new \DateTime('now + ' . ($i + $j) . 'seconds'));
$manager->persist($comment);
$post->createComment($comment);
}
$manager->persist($post);
}
$manager->flush();
}
示例6: loadPosts
private function loadPosts(ObjectManager $manager)
{
$passwordEncoder = $this->container->get('security.password_encoder');
$user = new User();
$user->setUsername('vvasia');
$user->setDisplayName('Vasia Vasin');
$user->setEmail('v.vasin_fake@levi9.com');
$user->setUuid('uuid');
$encodedPassword = $passwordEncoder->encodePassword($user, 'password');
$user->setPassword($encodedPassword);
$user->setRoles(['ROLE_USER']);
$manager->persist($user);
$manager->flush();
/** @var User $author */
$author = $manager->getRepository('AppBundle:User')->findOneBy(['email' => 'fakeuser2@levi9.com']);
foreach (range(1, 10) as $i) {
$post = new Post();
$post->setTitle($this->getRandomPostTitle() . ' ' . uniqid())->setSummary($this->getRandomPostSummary())->setSlug($this->container->get('slugger')->slugify($post->getTitle()))->setContent($this->getPostContent())->setAuthor($author)->setPublishedAt(new \DateTime('now - ' . $i . 'days'))->setState($this->getRandomState())->setCategory($category);
foreach (range(1, 5) as $j) {
$comment = new Comment();
$comment->setUser($user)->setPublishedAt(new \DateTime('now + ' . ($i + $j) . 'seconds'))->setContent($this->getRandomCommentContent())->setPost($post);
$manager->persist($comment);
$post->addComment($comment);
}
if (rand(0, 1)) {
$vote = new Vote();
$vote->setAuthorEmail(rand(0, 1) ? 'fakeuser2@levi9.com' : 'fakeuser1@levi9.com');
$vote->setPost($post);
$vote->setVote(rand(0, 1));
}
$manager->persist($post);
$category->addPost($post);
}
$manager->flush();
}
示例7: load
public function load(ObjectManager $manager)
{
$repo = new Post();
$repo->setTitle('Post title 1');
$manager->persist($repo);
$repo = new Post();
$repo->setTitle('Post title 2');
$manager->persist($repo);
$manager->flush();
}
示例8: load
public function load(ObjectManager $manager)
{
$post = new Post();
$post->setTitle('test test');
$post->setSlug('test-test');
$post->setContent('przykladowy wpis');
$post->setAuthor('bart');
$manager->persist($post);
$manager->flush();
}
示例9: load
public function load(ObjectManager $manager)
{
foreach ($this->getData() as $payload) {
$post = new Entity\Post();
$post->setTitle($payload[0]);
$post->setContent($payload[1]);
$post->setCreated($payload[2]);
$manager->persist($post);
}
$manager->flush();
}
示例10: load
public function load(ObjectManager $manager)
{
$faker = new Faker\Generator();
$faker->addProvider(new Faker\Provider\en_US\Text($faker));
$faker->addProvider(new Faker\Provider\Lorem($faker));
for ($i = 1; $i <= 100; $i++) {
$post = new Post();
$post->setTitle($faker->sentence(4));
$post->setBody($faker->realText(500));
$manager->persist($post);
}
$manager->flush();
}
示例11: load
function load(ObjectManager $manager)
{
$i = 1;
while ($i < +100) {
$post = new Post();
$post->setTitle('Titre du post n°' . $i);
$post->setBody('Corps du post');
$post->setIsPublished($i % 2);
$manager->persist($post);
$i++;
}
$manager->flush();
}
示例12: load
public function load(ObjectManager $manager)
{
$faker = \Faker\Factory::create();
for ($i = 1; $i <= 1000; $i++) {
$post = new Post();
$post->setTitle($faker->sentence(15));
$post->setLead($faker->text(300));
$post->setContent($faker->text(700));
$post->setCreatedAt($faker->dateTimeThisMonth);
$manager->persist($post);
}
$manager->flush();
}
示例13: create
public function create(User $user, $title, $url, $tag)
{
if ($errors = $this->getErrors($title, $url, $tag)) {
throw new ServiceException($errors);
}
$post = new Post();
$post->setUser($user);
$post->setTitle($title);
$post->setUrl($url);
$post->setTag($this->formatTag($tag));
$post->setUpvoteTotal(0);
$post->setCreatedAt(new \DateTime());
return $this->repository->create($post);
}
示例14: testRabbitMQ
public function testRabbitMQ()
{
$client = static::createClient();
$post = new Post();
$post->setTitle('Lorem ipsum dolor');
$post->setSlug('Lorem-ipsum-dolor');
$post->setSummary('Lorem ipsum dolor sit amet consectetur adipiscing elit Urna nisl sollicitudin');
$post->setContent('Lorem ipsum dolor sit amet consectetur adipiscing elit Urna nisl sollicitudin');
$post->setAuthorEmail('anna_admin@symfony.com');
$this->entityManager->persist($post);
$this->entityManager->flush();
$client->request('POST', '/post/generate_pdf/' . $post->getId());
$this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
$pdfName = json_decode($client->getResponse()->getContent(), true)['pdfName'];
$this->entityManager->remove($post);
$this->entityManager->flush();
$pdfPath = self::$kernel->getRootDir() . '/../web/downloads/pdf/' . $pdfName . '.pdf';
sleep(2);
$this->assertTrue(file_exists($pdfPath));
unlink($pdfPath);
}
示例15: testElasticSearch
public function testElasticSearch()
{
$client = self::createClient();
$crawler = $client->request('GET', '/blog/search-results?q=odio');
$this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
$this->assertEquals('Results for <b>odio</b> (5)', $crawler->filter('h2#results-info>span')->html());
$randnumber = rand();
$post = new Post();
$post->setTitle('Elasticsearch rocks ' . $randnumber);
$post->setSlug('elasticsearch-rocks-' . $randnumber);
$post->setSummary('Lorem ipsum dolor sit amet consectetur adipiscing elit Urna nisl sollicitudin');
$post->setContent('Lorem ipsum dolor sit amet consectetur adipiscing elit Urna nisl sollicitudin');
$post->setAuthorEmail('anna_admin@symfony.com');
$this->entityManager->persist($post);
$this->entityManager->flush();
self::populateElasticSearchIndices();
$crawler = $client->request('GET', '/blog/search-results?q=Elasticsearch rocks ' . $randnumber);
$this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
$this->assertEquals('Results for <b>Elasticsearch rocks ' . $randnumber . '</b> (1)', $crawler->filter('h2#results-info>span')->html());
$this->entityManager->remove($post);
$this->entityManager->flush();
}