InstallData.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved.
  4. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
  5. *
  6. * Glory to Ukraine! Glory to the heroes!
  7. */
  8. namespace Magefan\Blog\Setup;
  9. use Magefan\Blog\Model\Post;
  10. use Magefan\Blog\Model\PostFactory;
  11. use Magento\Framework\Module\Setup\Migration;
  12. use Magento\Framework\Setup\InstallDataInterface;
  13. use Magento\Framework\Setup\ModuleContextInterface;
  14. use Magento\Framework\Setup\ModuleDataSetupInterface;
  15. /**
  16. * @codeCoverageIgnore
  17. */
  18. class InstallData implements InstallDataInterface
  19. {
  20. /**
  21. * Post factory
  22. *
  23. * @var \Magefan\Blog\Model\PostFactory
  24. */
  25. private $_postFactory;
  26. /**
  27. * Init
  28. *
  29. * @param \Magefan\Blog\Model\PostFactory $postFactory
  30. */
  31. public function __construct(\Magefan\Blog\Model\PostFactory $postFactory)
  32. {
  33. $this->_postFactory = $postFactory;
  34. }
  35. /**
  36. * {@inheritdoc}
  37. * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  38. */
  39. public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
  40. {
  41. $data = [
  42. 'title' => 'Hello world!',
  43. 'meta_keywords' => 'magento 2 blog',
  44. 'meta_description' => 'Magento 2 blog default post.',
  45. 'identifier' => 'hello-world',
  46. 'content_heading' => 'Hello world!',
  47. 'content' => '<p>Welcome to <a title="Magefan - solutions for Magento 2" href="http://magefan.com/" target="_blank">Magefan</a> <a title="Magento 2 Blog extension" href="https://magefan.com/magento2-blog-extension/" target="_blank">blog extension for Magento&reg; 2</a>. This is your first post. Edit or delete it, then start blogging!</p>
  48. <p><!-- pagebreak --></p>
  49. <p>Please also read&nbsp;<a title="Magento 2 Blog online documentation" href="http://magefan.com/docs/magento-2-blog/" target="_blank">Online documentation</a>&nbsp;and&nbsp;<a href="http://magefan.com/blog/add-read-more-tag-to-blog-post-content/" target="_blank">How to add "read more" tag to post content</a></p>
  50. <p>Follow Magefan on:</p>
  51. <p><a title="Blog Extension for Magento 2 code" href="https://github.com/magefan/module-blog" target="_blank">GitHub</a>&nbsp;|&nbsp;<a href="https://twitter.com/magento2fan" target="_blank">Twitter</a>&nbsp;|&nbsp;<a href="https://www.facebook.com/magefan/" target="_blank">Facebook</a>&nbsp;|&nbsp;<a href="https://plus.google.com/+Magefan_Magento_2/posts/" target="_blank">Google +</a></p>',
  52. 'store_ids' => [0]
  53. ];
  54. $this->_postFactory->create()->setData($data)->save();
  55. }
  56. }