本文整理匯總了PHP中AppBundle\Entity\Post::setContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP Post::setContent方法的具體用法?PHP Post::setContent怎麽用?PHP Post::setContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AppBundle\Entity\Post
的用法示例。
在下文中一共展示了Post::setContent方法的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: 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();
}
示例3: 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();
}
示例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: createAction
/**
* Creates a new Post entity.
*
* @Route("/", name="post_create")
* @Method("POST")
*/
public function createAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$post = new Post();
$post->setContent($request->getContent());
$em->persist($post);
$em->flush();
return new JsonResponse();
}
示例6: 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();
}
示例7: 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();
}
示例8: create
public function create($owner, Topic $topic, $content, $isSticky = false)
{
$entity = new Post();
$entity->setContent($content);
$entity->setUserId($owner);
$entity->setTopic($topic);
$entity->setIsSticky($isSticky);
$entityManager = $this->getEntityManager();
$entityManager->persist($entity);
$entityManager->flush();
return $entity;
}
示例9: 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();
}
示例10: 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);
}
示例11: 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();
}
示例12: 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();
}
示例13: 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;
}
示例14: load
public function load(ObjectManager $manager)
{
$p1 = new Post();
$p1->setPublicationDate(new \DateTime('20151201T12:00'));
$p1->setPublish(true);
$p1->setTitle('Installation de Symfony');
$p1->setAbstract("Ce tutoriel présente l'installation du framework symfony dans sa dernière version stable. C'est une base pour commencer à développer une application web avec. Il couvre l'installation du serveur apache, mysql ainsi que le langage php et l'interface d'administration de base de donnée phpmyadmin.");
$article = "Installer les prérequis";
$article = $article . "\n" . "----------------------";
$article = $article . "\n" . "";
$article = $article . "\n" . "```bash";
$article = $article . "\n" . "liste=\\";
$article = $article . "\n" . "apache2 \\";
$article = $article . "\n" . "php5 \\";
$article = $article . "\n" . "mysql-server \\";
$article = $article . "\n" . "libapache2-mod-php5 \\";
$article = $article . "\n" . "php5-mysql \\";
$article = $article . "\n" . "phpmyadmin \\";
$article = $article . "\n" . "php5-intl\"";
$article = $article . "\n" . "";
$article = $article . "\n" . "sudo apt-get install \$liste";
$article = $article . "\n" . "";
$article = $article . "\n" . "sudo sed -i -e 's/;date.timezone =/date.timezone = Europe\\/Paris/g' /etc/php5/apache2/php.ini";
$article = $article . "\n" . "sudo sed -i -e 's/;date.timezone =/date.timezone = Europe\\/Paris/g' /etc/php5/cli/php.ini";
$article = $article . "\n" . "```";
$article = $article . "\n" . "";
$article = $article . "\n" . "Installer symfony et un alias";
$article = $article . "\n" . "------------------------------";
$article = $article . "\n" . "";
$article = $article . "\n" . "```bash";
$article = $article . "\n" . "sudo curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony";
$article = $article . "\n" . "sudo chmod a+x /usr/local/bin/symfony";
$article = $article . "\n" . "echo alias sy=\\\"php app/console\\\" >> \$HOME/.bashrc";
$article = $article . "\n" . "```";
$article = $article . "\n" . "";
$article = $article . "\n" . "Installer composer";
$article = $article . "\n" . "------------------";
$article = $article . "\n" . "";
$article = $article . "\n" . "```bash";
$article = $article . "\n" . "curl -sS https://getcomposer.org/installer | php";
$article = $article . "\n" . "sudo mv composer.phar /usr/local/bin/composer";
$article = $article . "\n" . "```";
$article = $article . "\n" . "";
$article = $article . "\n" . "Sources :";
$article = $article . "\n" . "---------";
$article = $article . "\n" . "";
$article = $article . "\n" . "1. http://symfony.com/download";
$article = $article . "\n" . "2. http://doc.ubuntu-fr.org/composer";
$p1->setContent($article);
$p1->setAuthor($this->getReference('user-admin'));
$manager->persist($p1);
$manager->flush();
$p1 = new Post();
$p1->setPublicationDate(new \DateTime('20151202T12:00'));
$p1->setPublish(true);
$p1->setTitle('Installer et configurer un projet symfony');
$p1->setAbstract("Comment démarrer la toute base d'un projet symfony ? Cette article répond aux questions de configuration mail pour le dev, creation du projet, mise en relation de symfony avec sublime text. Il faut aussi gérer les droits que vous donner à apache ou autre serveur ! Sinon il ne pourra pas écrire dans le dossier de cache et de logs ainsi que les fichiers que vous uploaderez !");
$article = "Installation des fichiers";
$article = $article . "\n" . "-------------------------";
$article = $article . "\n" . "";
$article = $article . "\n" . "```bash";
$article = $article . "\n" . "# installe la dernière version LTS";
$article = $article . "\n" . "symfony new my_project lts";
$article = $article . "\n" . "cd my_project";
$article = $article . "\n" . "";
$article = $article . "\n" . "mkdir web/uploads";
$article = $article . "\n" . "HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\\ -f1`";
$article = $article . "\n" . "# ajouter les dossiers dans lesquels ils faut écrire";
$article = $article . "\n" . "sudo setfacl -R -m u:\"\$HTTPDUSER\":rwX -m u:`whoami`:rwX app/cache app/logs web/uploads";
$article = $article . "\n" . "sudo setfacl -dR -m u:\"\$HTTPDUSER\":rwX -m u:`whoami`:rwX app/cache app/logs web/uploads";
$article = $article . "\n" . "```";
$article = $article . "\n" . "";
$article = $article . "\n" . "Configuration des fichiers";
$article = $article . "\n" . "---------------------------";
$article = $article . "\n" . "";
$article = $article . "\n" . "### parameters.yml";
$article = $article . "\n" . "";
$article = $article . "\n" . "La base de donnée, c'est facile";
$article = $article . "\n" . "";
$article = $article . "\n" . "Pour les mails :";
$article = $article . "\n" . "```yml";
$article = $article . "\n" . "parameters:";
$article = $article . "\n" . " mailer_transport: gmail";
$article = $article . "\n" . " mailer_host: ~";
$article = $article . "\n" . " mailer_user: your_gmail_username";
$article = $article . "\n" . " mailer_password: your_gmail_password";
$article = $article . "\n" . "```";
$article = $article . "\n" . "";
$article = $article . "\n" . "### config.yml";
$article = $article . "\n" . "";
$article = $article . "\n" . "```yml";
$article = $article . "\n" . "parameters:";
$article = $article . "\n" . " locale: fr|en";
$article = $article . "\n" . "";
$article = $article . "\n" . "framework:";
$article = $article . "\n" . " ide: \"subl:///%%f:%%1\"";
$article = $article . "\n" . "```";
$article = $article . "\n" . "";
$article = $article . "\n" . "**Note :** Il faut installer le paquet \"subl protocol\" dans sublime text pour avoir les liens";
$article = $article . "\n" . "";
//.........這裏部分代碼省略.........
示例15: setContent
/**
* {@inheritDoc}
*/
public function setContent($content)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setContent', array($content));
return parent::setContent($content);
}