Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddPaypalShortcuts.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
20  const PAYPAL_SHORTCUT_BLOCK = \Magento\Braintree\Block\Paypal\Button::class;
21 
28  public function execute(Observer $observer)
29  {
30  // Remove button from catalog pages
31  if ($observer->getData('is_catalog_product')) {
32  return;
33  }
34 
36  $shortcutButtons = $observer->getEvent()->getContainer();
37 
38  $shortcut = $shortcutButtons->getLayout()->createBlock(self::PAYPAL_SHORTCUT_BLOCK);
39 
40  $shortcutButtons->addShortcut($shortcut);
41  }
42 }