123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Braintree\Observer;
- use Magento\Framework\Event\Observer;
- use Magento\Catalog\Block\ShortcutButtons;
- use Magento\Framework\Event\ObserverInterface;
- /**
- * Class AddPaypalShortcuts
- */
- class AddPaypalShortcuts implements ObserverInterface
- {
- /**
- * Block class
- */
- const PAYPAL_SHORTCUT_BLOCK = \Magento\Braintree\Block\Paypal\Button::class;
- /**
- * Add Braintree PayPal shortcut buttons
- *
- * @param Observer $observer
- * @return void
- */
- public function execute(Observer $observer)
- {
- // Remove button from catalog pages
- if ($observer->getData('is_catalog_product')) {
- return;
- }
- /** @var ShortcutButtons $shortcutButtons */
- $shortcutButtons = $observer->getEvent()->getContainer();
- $shortcut = $shortcutButtons->getLayout()->createBlock(self::PAYPAL_SHORTCUT_BLOCK);
- $shortcutButtons->addShortcut($shortcut);
- }
- }
|