Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreateDefaultPages.php
Go to the documentation of this file.
1 <?php
8 
13 
19 {
23  private $pageFactory;
24 
28  private $moduleDataSetup;
29 
35  public function __construct(
36  \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
37  \Magento\Cms\Model\PageFactory $pageFactory
38  ) {
39  $this->pageFactory = $pageFactory;
40  $this->moduleDataSetup = $moduleDataSetup;
41  }
42 
47  public function apply()
48  {
49  $cmsPages = [
50  [
51  'title' => '404 Not Found',
52  'page_layout' => '2columns-right',
53  'meta_keywords' => 'Page keywords',
54  'meta_description' => 'Page description',
55  'identifier' => 'no-route',
56  'content_heading' => 'Whoops, our bad...',
57  'content' => "<dl>\r\n<dt>The page you requested was not found, and we have a fine guess why.</dt>\r\n"
58  . "<dd>\r\n<ul class=\"disc\">\r\n<li>If you typed the URL directly, please make sure the spelling"
59  . " is correct.</li>\r\n<li>If you clicked on a link to get here, the link is outdated.</li>\r\n"
60  . "</ul></dd>\r\n</dl>\r\n<dl>\r\n<dt>What can you do?</dt>\r\n<dd>Have no fear, help is near!"
61  . " There are many ways you can get back on track with Magento Store.</dd>\r\n<dd>\r\n"
62  . "<ul class=\"disc\">\r\n<li><a href=\"#\" onclick=\"history.go(-1); return false;\">Go back</a> "
63  . "to the previous page.</li>\r\n<li>Use the search bar at the top of the page to search for your"
64  . " products.</li>\r\n<li>Follow these links to get you back on track!<br />"
65  . "<a href=\"{{store url=\"\"}}\">Store Home</a> <span class=\"separator\">|</span> "
66  . "<a href=\"{{store url=\"customer/account\"}}\">My Account</a></li></ul></dd></dl>\r\n",
67  'is_active' => 1,
68  'stores' => [0],
69  'sort_order' => 0
70  ],
71  [
72  'title' => 'Home page',
73  'page_layout' => '1column',
74  'identifier' => 'home',
75  'content_heading' => 'Home Page',
76  'content' => "<p>CMS homepage content goes here.</p>\r\n",
77  'is_active' => 1,
78  'stores' => [0],
79  'sort_order' => 0
80  ],
81  [
82  'title' => 'Enable Cookies',
83  'page_layout' => '1column',
84  'identifier' => 'enable-cookies',
85  'content_heading' => 'What are Cookies?',
86  'content' => "<div class=\"enable-cookies cms-content\">\r\n<p>\"Cookies\" are little pieces of data"
87  . " we send when you visit our store. Cookies help us get to know you better and personalize your"
88  . " experience. Plus they help protect you and other shoppers from fraud.</p>\r\n"
89  . "<p style=\"margin-bottom: 20px;\">Set your browser to accept cookies so you can buy items, "
90  . "save items, and receive customized recommendations. Here’s how:</p>\r\n<ul>\r\n<li>"
91  . "<a href=\"https://support.google.com/accounts/answer/61416?hl=en\" target=\"_blank\">Google "
92  . "Chrome</a></li>\r\n<li>"
93  . "<a href=\"http://windows.microsoft.com/en-us/internet-explorer/delete-manage-cookies\""
94  . " target=\"_blank\">Internet Explorer</a></li>\r\n<li>"
95  . "<a href=\"http://support.apple.com/kb/PH19214\" target=\"_blank\">Safari</a></li>\r\n<li>"
96  . "<a href=\"https://support.mozilla.org/en-US/kb/enable-and-disable-cookies-website-preferences\""
97  . " target=\"_blank\">Mozilla/Firefox</a></li>\r\n</ul>\r\n</div>",
98  'is_active' => 1,
99  'stores' => [0]
100  ]
101  ];
102 
106  foreach ($cmsPages as $data) {
107  $this->createPage()->setData($data)->save();
108  }
109  $pageContent = <<<EOD
110 <div class="privacy-policy cms-content">
111  <div class="message info">
112  <span>
113  Please replace this text with your Privacy Policy.
114  Please add any additional cookies your website uses below (e.g. Google Analytics).
115  </span>
116  </div>
117  <p>
118  This privacy policy sets out how this website (hereafter "the Store") uses and protects any information that
119  you give the Store while using this website. The Store is committed to ensuring that your privacy is protected.
120  Should we ask you to provide certain information by which you can be identified when using this website, then
121  you can be assured that it will only be used in accordance with this privacy statement. The Store may change
122  this policy from time to time by updating this page. You should check this page from time to time to ensure
123  that you are happy with any changes.
124  </p>
125  <h2>What we collect</h2>
126  <p>We may collect the following information:</p>
127  <ul>
128  <li>name</li>
129  <li>contact information including email address</li>
130  <li>demographic information such as postcode, preferences and interests</li>
131  <li>other information relevant to customer surveys and/or offers</li>
132  </ul>
133  <p>
134  For the exhaustive list of cookies we collect see the <a href="#list">List of cookies we collect</a> section.
135  </p>
136  <h2>What we do with the information we gather</h2>
137  <p>
138  We require this information to understand your needs and provide you with a better service,
139  and in particular for the following reasons:
140  </p>
141  <ul>
142  <li>Internal record keeping.</li>
143  <li>We may use the information to improve our products and services.</li>
144  <li>
145  We may periodically send promotional emails about new products, special offers or other information which we
146  think you may find interesting using the email address which you have provided.
147  </li>
148  <li>
149  From time to time, we may also use your information to contact you for market research purposes.
150  We may contact you by email, phone, fax or mail. We may use the information to customise the website
151  according to your interests.
152  </li>
153  </ul>
154  <h2>Security</h2>
155  <p>
156  We are committed to ensuring that your information is secure. In order to prevent unauthorised access or
157  disclosure, we have put in place suitable physical, electronic and managerial procedures to safeguard and
158  secure the information we collect online.
159  </p>
160  <h2>How we use cookies</h2>
161  <p>
162  A cookie is a small file which asks permission to be placed on your computer's hard drive.
163  Once you agree, the file is added and the cookie helps analyse web traffic or lets you know when you visit
164  a particular site. Cookies allow web applications to respond to you as an individual. The web application
165  can tailor its operations to your needs, likes and dislikes by gathering and remembering information about
166  your preferences.
167  </p>
168  <p>
169  We use traffic log cookies to identify which pages are being used. This helps us analyse data about web page
170  traffic and improve our website in order to tailor it to customer needs. We only use this information for
171  statistical analysis purposes and then the data is removed from the system.
172  </p>
173  <p>
174  Overall, cookies help us provide you with a better website, by enabling us to monitor which pages you find
175  useful and which you do not. A cookie in no way gives us access to your computer or any information about you,
176  other than the data you choose to share with us. You can choose to accept or decline cookies.
177  Most web browsers automatically accept cookies, but you can usually modify your browser setting
178  to decline cookies if you prefer. This may prevent you from taking full advantage of the website.
179  </p>
180  <h2>Links to other websites</h2>
181  <p>
182  Our website may contain links to other websites of interest. However, once you have used these links
183  to leave our site, you should note that we do not have any control over that other website.
184  Therefore, we cannot be responsible for the protection and privacy of any information which you provide whilst
185  visiting such sites and such sites are not governed by this privacy statement.
186  You should exercise caution and look at the privacy statement applicable to the website in question.
187  </p>
188  <h2>Controlling your personal information</h2>
189  <p>You may choose to restrict the collection or use of your personal information in the following ways:</p>
190  <ul>
191  <li>
192  whenever you are asked to fill in a form on the website, look for the box that you can click to indicate
193  that you do not want the information to be used by anybody for direct marketing purposes
194  </li>
195  <li>
196  if you have previously agreed to us using your personal information for direct marketing purposes,
197  you may change your mind at any time by letting us know using our Contact Us information
198  </li>
199  </ul>
200  <p>
201  We will not sell, distribute or lease your personal information to third parties unless we have your permission
202  or are required by law to do so. We may use your personal information to send you promotional information
203  about third parties which we think you may find interesting if you tell us that you wish this to happen.
204  </p>
205  <p>
206  You may request details of personal information which we hold about you under the Data Protection Act 1998.
207  A small fee will be payable. If you would like a copy of the information held on you please email us this
208  request using our Contact Us information.
209  </p>
210  <p>
211  If you believe that any information we are holding on you is incorrect or incomplete,
212  please write to or email us as soon as possible, at the above address.
213  We will promptly correct any information found to be incorrect.
214  </p>
215  <h2><a name="list"></a>List of cookies we collect</h2>
216  <p>The table below lists the cookies we collect and what information they store.</p>
217  <table class="data-table data-table-definition-list">
218  <thead>
219  <tr>
220  <th>COOKIE name</th>
221  <th>COOKIE Description</th>
222  </tr>
223  </thead>
224  <tbody>
225  <tr>
226  <th>CART</th>
227  <td>The association with your shopping cart.</td>
228  </tr>
229  <tr>
230  <th>CATEGORY_INFO</th>
231  <td>Stores the category info on the page, that allows to display pages more quickly.</td>
232  </tr>
233  <tr>
234  <th>COMPARE</th>
235  <td>The items that you have in the Compare Products list.</td>
236  </tr>
237  <tr>
238  <th>CUSTOMER</th>
239  <td>An encrypted version of your customer id with the store.</td>
240  </tr>
241  <tr>
242  <th>CUSTOMER_AUTH</th>
243  <td>An indicator if you are currently logged into the store.</td>
244  </tr>
245  <tr>
246  <th>CUSTOMER_INFO</th>
247  <td>An encrypted version of the customer group you belong to.</td>
248  </tr>
249  <tr>
250  <th>CUSTOMER_SEGMENT_IDS</th>
251  <td>Stores the Customer Segment ID</td>
252  </tr>
253  <tr>
254  <th>EXTERNAL_NO_CACHE</th>
255  <td>A flag, which indicates whether caching is disabled or not.</td>
256  </tr>
257  <tr>
258  <th>FORM_KEY</th>
259  <td>Stores form key used by page cache functionality.</td>
260  </tr>
261  <tr>
262  <th>FRONTEND</th>
263  <td>Your session ID on the server.</td>
264  </tr>
265  <tr>
266  <th>GUEST-VIEW</th>
267  <td>Allows guests to edit their orders.</td>
268  </tr>
269  <tr>
270  <th>LAST_CATEGORY</th>
271  <td>The last category you visited.</td>
272  </tr>
273  <tr>
274  <th>LAST_PRODUCT</th>
275  <td>The most recent product you have viewed.</td>
276  </tr>
277  <tr>
278  <th>NEWMESSAGE</th>
279  <td>Indicates whether a new message has been received.</td>
280  </tr>
281  <tr>
282  <th>NO_CACHE</th>
283  <td>Indicates whether it is allowed to use cache.</td>
284  </tr>
285  <tr>
286  <th>PERSISTENT_SHOPPING_CART</th>
287  <td>A link to information about your cart and viewing history if you have asked the site.</td>
288  </tr>
289  <tr>
290  <th>RECENTLYCOMPARED</th>
291  <td>The items that you have recently compared.</td>
292  </tr>
293  <tr>
294  <th>STF</th>
295  <td>Information on products you have emailed to friends.</td>
296  </tr>
297  <tr>
298  <th>STORE</th>
299  <td>The store view or language you have selected.</td>
300  </tr>
301  <tr>
302  <th>USER_ALLOWED_SAVE_COOKIE</th>
303  <td>Indicates whether a customer allowed to use cookies.</td>
304  </tr>
305  <tr>
306  <th>VIEWED_PRODUCT_IDS</th>
307  <td>The products that you have recently viewed.</td>
308  </tr>
309  <tr>
310  <th>WISHLIST</th>
311  <td>An encrypted list of products added to your Wish List.</td>
312  </tr>
313  <tr>
314  <th>WISHLIST_CNT</th>
315  <td>The number of items in your Wish List.</td>
316  </tr>
317  </tbody>
318  </table>
319 </div>
320 EOD;
321  $privacyPageData = [
322  'title' => 'Privacy and Cookie Policy',
323  'content_heading' => 'Privacy and Cookie Policy',
324  'page_layout' => '1column',
325  'identifier' => 'privacy-policy-cookie-restriction-mode',
326  'content' => $pageContent,
327  'is_active' => 1,
328  'stores' => [0],
329  'sort_order' => 0,
330  ];
331  $this->createPage()->setData($privacyPageData)->save();
332  $footerLinksBlock = $this->createPage()->load('footer_links', 'identifier');
333  if ($footerLinksBlock->getId()) {
334  $content = $footerLinksBlock->getContent();
335  if (preg_match('/<ul>(.*?)<\\/ul>/ims', $content)) {
336  $content = preg_replace('/<li class="last">/ims', '<li>', $content);
337  $replacment = '<li class="last privacy">' .
338  "<a href=\"{{store direct_url=\"privacy-policy-cookie-restriction-mode\"}}\">" .
339  __('Privacy and Cookie Policy') . "</a></li>\r\n</ul>";
340  $content = preg_replace('/<\\/ul>/ims', $replacment, $content);
341  $footerLinksBlock->setContent($content)->save();
342  }
343  }
344  $installer = $this->moduleDataSetup->createMigrationSetup();
345  $this->moduleDataSetup->startSetup();
346  $installer->appendClassAliasReplace(
347  'cms_block',
348  'content',
349  Migration::ENTITY_TYPE_BLOCK,
350  Migration::FIELD_CONTENT_TYPE_WIKI,
351  ['block_id']
352  );
353  $installer->appendClassAliasReplace(
354  'cms_page',
355  'content',
356  Migration::ENTITY_TYPE_BLOCK,
357  Migration::FIELD_CONTENT_TYPE_WIKI,
358  ['page_id']
359  );
360  $installer->appendClassAliasReplace(
361  'cms_page',
362  'layout_update_xml',
363  Migration::ENTITY_TYPE_BLOCK,
364  Migration::FIELD_CONTENT_TYPE_XML,
365  ['page_id']
366  );
367  $installer->appendClassAliasReplace(
368  'cms_page',
369  'custom_layout_update_xml',
370  Migration::ENTITY_TYPE_BLOCK,
371  Migration::FIELD_CONTENT_TYPE_XML,
372  ['page_id']
373  );
374  $installer->doUpdateClassAliases();
375  $this->moduleDataSetup->endSetup();
376  }
377 
381  public static function getDependencies()
382  {
383  return [];
384  }
385 
389  public static function getVersion()
390  {
391  return '2.0.0';
392  }
393 
397  public function getAliases()
398  {
399  return [];
400  }
401 
407  private function createPage()
408  {
409  return $this->pageFactory->create();
410  }
411 }
__construct(\Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup, \Magento\Cms\Model\PageFactory $pageFactory)
taxRateField find('.mselect-list') .on( 'click.mselect-edit'
Definition: edit.phtml:162
EOD
Definition: website.php:20
taxRateField this edit on("click.mselect-delete", ".mselect-delete", function() { if(!confirm('<?=/*@escapeNotVerified */__( 'Do you really want to delete this tax rate?') ?>')) { return;} var that=$(this), select=that.closest('.mselect-list').prev(), rateValue=that.parent().find( 'input[type="checkbox"]').val();$( 'body').trigger( 'processStart');var ajaxOptions={ type:'POST', data:{ tax_calculation_rate_id:rateValue, form_key:$( 'input[name="form_key"]').val() }, dataType:'json', url:'<?=/*@escapeNotVerified */$block->getTaxRateDeleteUrl() ?>', success:function(result, status) { $( 'body').trigger( 'processStop');if(result.success) { that.parent().remove();select.find( 'option').each(function() { if(this.value===rateValue) { $(this).remove();} });select.trigger( 'change.hiddenSelect');} else { if(result.error_message) alert({ content:result.error_message });else alert({ content:'<?=/*@escapeNotVerified */__( 'An error occurred') ?>' });} }, error:function() { $( 'body').trigger( 'processStop');alert({ content:'<?=/*@escapeNotVerified */__( 'An error occurred') ?>' });} };$.ajax(ajaxOptions);}) .on( 'click.mselectAdd'
Definition: edit.phtml:164