本文整理匯總了PHP中AppBundle\Entity\Post::setSlug方法的典型用法代碼示例。如果您正苦於以下問題:PHP Post::setSlug方法的具體用法?PHP Post::setSlug怎麽用?PHP Post::setSlug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AppBundle\Entity\Post
的用法示例。
在下文中一共展示了Post::setSlug方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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();
}
示例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: 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();
}
示例5: 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);
}
示例6: 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();
}
示例7: loadPosts
private function loadPosts(ObjectManager $manager)
{
foreach (range(1, 10) 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('anna_admin@symfony.com');
$post->setPublishedAt(new \DateTime('now - ' . $i . 'days'));
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($this->getRandomCommentContent());
$comment->setPost($post);
$manager->persist($comment);
$post->addComment($comment);
}
$manager->persist($post);
}
$manager->flush();
}
示例8: getExamplePostEntity
public function getExamplePostEntity()
{
$post = new Post();
$post->setTitle('Eros diam egestas libero eu vulputate risus');
$post->setSlug('eros-diam-egestas-libero-eu-vulputate-risus');
$post->setSummary('Sed varius a risus eget aliquam Pellentesque et sapien pulvinar consectetur In
hac habitasse platea dictumst Urna nisl sollicitudin id varius orci quam id turpis Ut eleifend mauris
et risus ultrices egestas Aliquam sodales odio id eleifend tristique Ut suscipit posuere justo at
vulputate');
$post->setContent('Lorem ipsum dolor sit amet consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et **dolore magna aliqua**: Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.');
$post->setAuthorEmail('anna_admin@symfony.com');
$this->entityManager->persist($post);
$this->entityManager->flush();
return $post;
}
示例9: setSlug
/**
* {@inheritDoc}
*/
public function setSlug($slug)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setSlug', [$slug]);
return parent::setSlug($slug);
}
示例10: setSlug
/**
* Slugify the post's title.
*
* @param Post $post
*/
private function setSlug(Post $post)
{
$title = $post->getTitle();
$slugify = $this->getConfigurationPool()->getContainer()->get('slugify');
$post->setSlug($slugify->slugify($title));
}