<commit_before><?php

class Edge_CheckoutNewsletter_Model_Newsletter
{
    public function setSubscribeToNewsletterStatus(Varien_Event_Observer $observer)
    {
        $controllerAction = $observer->getEvent()->getControllerAction();
        if ($controllerAction) {
            $newsletterCheckbox = $controllerAction->getRequest()->getPost('subscribe_to_newsletter');
            Mage::getModel('core/session')->setNewsletterChecked((bool)$newsletterCheckbox);
        }
    }

    public function subscribeToNewsletter(Varien_Event_Observer $observer)
    {
        $quote = $observer->getEvent()->getQuote();
        if (in_array($quote->getCheckoutMethod(), array('login_in', 'guest')) && Mage::getModel('core/session')->getNewsletterChecked()) {
            Mage::getModel('newsletter/subscriber')->subscribe($quote->getBillingAddress()->getEmail());
            Mage::getModel('core/session')->unsNewsletterChecked();
        }
    }
}<commit_msg>SagePay FIX checkout/session to checkout/type_onepage->getCheckout()<commit_after><?php

class Edge_CheckoutNewsletter_Model_Newsletter
{
    public function setSubscribeToNewsletterStatus(Varien_Event_Observer $observer)
    {
        $controllerAction = $observer->getEvent()->getControllerAction();
        if ($controllerAction) {
            $newsletterCheckbox = $controllerAction->getRequest()->getPost('subscribe_to_newsletter');
            Mage::getModel('checkout/type_onepage')->getCheckout()->setNewsletterChecked((bool)$newsletterCheckbox);
        }
    }

    public function subscribeToNewsletter(Varien_Event_Observer $observer)
    {
        $quote = $observer->getEvent()->getQuote();
        if (in_array($quote->getCheckoutMethod(), array('login_in', 'guest')) &&
            Mage::getModel('checkout/type_onepage')->getCheckout()->getNewsletterChecked())
        {
            Mage::getModel('newsletter/subscriber')->subscribe($quote->getBillingAddress()->getEmail());
            Mage::getModel('checkout/type_onepage')->getCheckout()->unsNewsletterChecked();
        }
    }
}
{'fraction_non_alphanumeric': 0.14487117160913954, 'fraction_numerical': 0.0, 'mean_word_length': 4.290488431876606, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2401592', 'n_tokens_mistral': 575, 'n_tokens_neox': 556, 'n_words': 58}