Пример #1
0
 public function load(ObjectManager $manager)
 {
     $articleDev = new Article();
     $articleDev->setTitle("Title for demo Web Dev article");
     $articleDev->setSummary("This is a summary Dev");
     $articleDev->setContent("This is some dummy data for the web development article content.");
     $articleDev->setMainImage("http://i.imgur.com/oPcT6TC.jpg");
     $articleDev->setSlug("demo-article-dev");
     $articleDev->setCategory("development");
     $articleDev->setDatePosted(new \DateTime("2016-01-01 01:01:01"));
     $articleDev->setTitleColour("black-title");
     $manager->persist($articleDev);
     $articleManager = new Article();
     $articleManager->setTitle("Title for Project Management Web article");
     $articleManager->setSummary("This is a summary Management");
     $articleManager->setContent("This is some dummy data for the project management article content.");
     $articleManager->setMainImage("http://i.imgur.com/3O2kOG4.jpg");
     $articleManager->setSlug("demo-article-manager");
     $articleManager->setCategory("management");
     $articleManager->setDatePosted(new \DateTime("2016-02-02 02:02:02"));
     $articleManager->setTitleColour("white-title");
     $manager->persist($articleManager);
     $articleMarketing = new Article();
     $articleMarketing->setTitle("Title for demo Marketing article");
     $articleMarketing->setSummary("This is a summary Marketing");
     $articleMarketing->setContent('
                 <p>Never in all their history have men been able truly to conceive of the world as one: a single sphere, a globe, having the qualities of a globe, a round earth in which all the directions eventually meet, in which there is no center because every point, or none, is center — an equal earth which all men occupy as equals. The airman\'s earth, if free men make it, will be truly round: a globe in practice, not in theory.</p>
                 <p>Science cuts two ways, of course; its products can be used for both good and evil. But there\'s no turning back from science. The early warnings about technological dangers also come from science.</p>
                 <h2 class="section-heading">The Final Frontier</h2>
                 <p>Spaceflights cannot be stopped. This is not the work of any one man or even a group of men. It is a historical process which mankind is carrying out in accordance with the natural laws of human development.</p>
                 <a href="#">
                     <img class="img-responsive" src="http://blackrockdigital.github.io/startbootstrap-clean-blog/img/post-sample-image.jpg" alt="">
                 </a>
                 <span class="caption text-muted">To go places and do things that have never been done before – that’s what living is all about.</span>
                 <p>Space, the final frontier. These are the voyages of the Starship Enterprise. Its five-year mission: to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before.</p>
                 <p>As I stand out here in the wonders of the unknown at Hadley, I sort of realize there’s a fundamental truth to our nature, Man must explore, and this is exploration at its greatest.</p>
                 <p>Placeholder text by <a href="http://spaceipsum.com/">Space Ipsum</a>. Photographs by <a href="https://www.flickr.com/photos/nasacommons/">NASA on The Commons</a>.</p>
                 ');
     $articleMarketing->setMainImage("http://i.imgur.com/fOg16kD.jpg");
     $articleMarketing->setSlug("demo-article-marketing");
     $articleMarketing->setCategory("online-marketing");
     $articleMarketing->setDatePosted(new \DateTime("2016-03-03 03:03:03"));
     $articleMarketing->setTitleColour("black-title");
     $manager->persist($articleMarketing);
     $manager->flush();
 }
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     for ($i = 0; $i < 3; $i++) {
         $article = new Article();
         $article->setTitle('Article de test ' . $i);
         $article->setSlug($article->getTitle());
         $article->setContent($this->articleContent[$i]);
         $article->setExtract($this->articleExtract[$i]);
         $article->setCategory($this->getReference('category'));
         $article->setAuthor($this->getReference('user'));
         $article->setPictureName('default-image-' . $i . '.jpg');
         $manager->persist($article);
         // Reference added once
         if ($i == 0) {
             $this->addReference('article', $article);
         }
     }
     $manager->flush();
 }
Пример #3
0
 /**
  * @Given there are articles:
  */
 public function thereAreArticles(TableNode $table)
 {
     $em = $this->getContainer()->get('doctrine')->getManager();
     $i = 1;
     foreach ($table->getHash() as $row) {
         $article = new Article();
         $article->setTitle($row['title']);
         $article->setCategory($this->findArticleCategory(['name' => $row['category']]));
         $article->setIdAuthor(1);
         $article->setSlug($row['title']);
         $em->persist($article);
         $em->flush();
         $this->getParameterBag()->set(sprintf('ARTICLE_%s_ID', $i), $article->getIdArticle());
         $i++;
     }
 }
 /**
  * {@inheritDoc}
  */
 public function setCategory($category)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCategory', array($category));
     return parent::setCategory($category);
 }
Пример #5
0
 public function postCategoryArticlesAction(Request $request, $category)
 {
     $entityManager = $this->getDoctrine()->getEntityManager();
     $repository = $entityManager->getRepository('AppBundle:ArticleCategory');
     $categoryEntity = $repository->findOneBy(['slug' => $category]);
     //        $category = new ArticleCategory();
     //        print_r($category);
     $title = $request->request->get('title');
     $slug = $request->request->get('slug');
     $number = random_int(1, 100);
     $article = new Article();
     $article->setCategory($categoryEntity);
     //        $article->setIdArticleTemplate(null);
     $article->setIdAuthor(140);
     $article->setTitle($title . $number);
     $article->setSlug($slug . $number);
     $article->setMarkup('<p>To bedzie długi artykul...</p>');
     $article->setMarkup('To bedzie długi artykul...');
     $article->setCreationDate(new \DateTime());
     //        $article->setModificationDate();
     //        $article->setRated();
     //        $article->getSum();
     //        print_r($article);
     //        $article->setIdArticleCategory(86);
     //        $article->setIdArticleTemplate(1);
     $entityManager->persist($article);
     $entityManager->flush();
     $view = $this->view($article, 201);
     return $this->handleView($view);
 }
Пример #6
0
 public function load(ObjectManager $manager)
 {
     $article1 = new Article();
     $article1->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-09-24 13:53:00'));
     $article1->setTitle('Export datas to a csv file with Symfony2');
     $article1->setCategory($this->getReference('category_3'));
     $article1->setContent('I recently had to export a huge set of data to a csv file. This is easy and fast to do if you don’t care about memory and User Experience. I wanted the memory consumption does not increase with the volume of data.
         I got inspiration from this post (in French) but, in spite of what is written in the post, some tests with the memory_get_usage function proved that the memory consumption increased quickly with the number of datas.
     ');
     $article1->setTags(array('CSV', 'Symfony2'));
     $manager->persist($article1);
     $article2 = new Article();
     $article2->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-09-24 13:53:00'));
     $article2->setTitle('How to use WSSE in Android app');
     $article2->setCategory($this->getReference('category_1'));
     $article2->setContent('After publishing an article about WSSE configuration in Symfony2, we received a lot of questions about using WSSE in Android application. We hope this article will answer some of these questions!
         Note that we will only speak about WSSE and not about designing a rest client in Android application.
     ');
     $article2->setTags(array('WSSE', 'Android'));
     $manager->persist($article2);
     $article3 = new Article();
     $article3->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-09-13 10:57:00'));
     $article3->setTitle('Create a custom form theme block with Twig');
     $article3->setCategory($this->getReference('category_3'));
     $article3->setContent('I wanted to use the following block. As you see, in addition to the specific p element, the div and their specific classes, the big difference with the native Twig form_row method is that the radio labels are not in a label tag (but there is a label tag for the parent form field).
     ');
     $article3->setTags(array('Twig', 'Symfony2'));
     $manager->persist($article3);
     $article4 = new Article();
     $article4->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-10-17 11:34:00'));
     $article4->setTitle('Efficient Elasticsearch indexing configuration');
     $article4->setCategory($this->getReference('category_2'));
     $article4->setContent('This post is about elasticsearch which is a great search engine.
         The biggest difficulty we meet is that we do not know how to configure it to have relevant search results. Another difficulty is (sorry to say that), the documentation is not very well done. Ok, it’s my opinion and I can’t denied we found usefull information in it, but information are sometimes difficult to find.
     ');
     $article4->setTags(array('Elasticsearch'));
     $manager->persist($article4);
     $article5 = new Article();
     $article5->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-09-24 13:53:00'));
     $article5->setTitle('Configure WSSE on Symfony2 with FOSRestBundle');
     $article5->setCategory($this->getReference('category_1'));
     $article5->setContent('The client–server communication is further constrained by no client context being stored on the server between requests. Each request from any client contains all of the information necessary to service the request, and any session state is held in the client.
     ');
     $article5->setTags(array('Symfony2', 'WSSE'));
     $manager->persist($article5);
     $article6 = new Article();
     $article6->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-06-21 16:24:00'));
     $article6->setTitle('How to keep your translations well organized in Symfony2');
     $article6->setCategory($this->getReference('category_3'));
     $article6->setContent('We are working at the moment on a big internationalized project, and we have consequently many translations in our application. These translations are dispatched in many bundles (7 for now) and are used throughout the application. At the begining of the development, we hadn’t any specific organisation for the translations and we put the translation in a random bundle (the one on which we were working, most of the time).');
     $article6->setTags(array('Symfony2'));
     $manager->persist($article6);
     $article7 = new Article();
     $article7->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-05-31 15:13:00'));
     $article7->setTitle('Install Rest in Symfony2 existing application');
     $article7->setCategory($this->getReference('category_1'));
     $article7->setContent('As we needed a connection between a Symfony2 web application and an Android application, we had to learn and understand how to make this in a simple and secured way, based on our existing entities.
         We chose WSSE for security access, FOSRestBundle for datas restitution and JMSSerializerBundle for serialization. 
     ');
     $article7->setTags(array('Symfony2', 'REST'));
     $manager->persist($article7);
     $article8 = new Article();
     $article8->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-04-21 11:44:00'));
     $article8->setTitle('DateTimePicker field type with Symfony2 and jQuery');
     $article8->setCategory($this->getReference('category_3'));
     $article8->setContent('In this third post, we’ll explain how to create a great custom field type that uses jQuery DatePicker to handle date input, and then, how to extend it to create a datetime field type. And the best? The datepicker is localized according to the user’s locale.
     ');
     $article8->setTags(array('Symfony2', 'jQuery'));
     $manager->persist($article8);
     $article9 = new Article();
     $article9->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-04-21 11:44:00'));
     $article9->setTitle('Currency Change rates update on Symfony2 using openexchangerates.org API');
     $article9->setCategory($this->getReference('category_3'));
     $article9->setContent('In this post, we’ll explain how to create and maintain a database with currencies and change rates.
         In order to update our changes rates, we will user openexchangerates.org solution. (Exists as free, premium and pro)
     ');
     $article9->setTags(array('Symfony2', 'Currency'));
     $manager->persist($article9);
     $article10 = new Article();
     $article10->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2012-11-05 11:00:00'));
     $article10->setTitle('Create a breadcrumb menu with KnpMenuBundle');
     $article10->setCategory($this->getReference('category_3'));
     $article10->setContent('In this first post, I’ll explain how to make a breadcrumb menu with the great KnpMenuBundle. The documentation explains the basics and how to make a common menu, but a breadcrumb menu has a particular behaviour.
     ');
     $article10->setTags(array('Symfony2', 'KnpMenuBundle'));
     $manager->persist($article10);
     $article11 = new Article();
     $article11->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-05-29 17:39:00'));
     $article11->setTitle('Create new log file/channel for a Symfony2 Service (With monolog)');
     $article11->setCategory($this->getReference('category_3'));
     $article11->setContent('In this article about WSSE and Rest, we describe how to create a new log file/channel with monolog in Symfony2
     ');
     $article11->setTags(array('WSSE', 'REST', 'Symfony2'));
     $manager->persist($article11);
     $article12 = new Article();
     $article12->setPublishedAt(\DateTime::createFromFormat('Y-m-d H:i:s', '2013-05-29 17:39:00'));
     $article12->setTitle('Java');
     $article12->setCategory($this->getReference('category_4'));
     $article12->setContent('What is Java ?');
     $article12->setTags(array('Java'));
     $manager->persist($article12);
     $manager->flush();
 }