Giter Club home page Giter Club logo

Comments (2)

ericadeefox avatar ericadeefox commented on September 26, 2024

So, I keep getting this TypeError: Argument 1 passed to Cake\ORM\Table::save() must implement interface Cake\Datasource\EntityInterface, null given, called in /var/www/html/muncie_events3/src/Controller/MailingListController.php on line 114

Lines 111-116 of MailingListController.php::join():

        if ($this->request->is('post')) {
            $mailingList = $this->MailingList->patchEntity($mailingList, $this->request->getData());
            $newList = $this->__readFormData($mailingList);
            if ($this->MailingList->save($newList)) {
                $this->Flash->success(__('The mailing list has been saved.'));
            }

And the aforementioned __readFormData function:

    private function __readFormData($mailingList)
    {
        $newList = TableRegistry::get('MailingList');
        $mailingList['email'] = strtolower(trim($mailingList['email']));
        $newList->email = $mailingList['email'];

        // If joining for the first time with default settings
        if (isset($mailingList['settings'])) {
            if ($mailingList['settings'] == 'default') {
                $newList->weekly = 1;
                $newList->all_categories = 1;
                return;
            }
        }

        // All event types
        // If the user did not select 'all events', but has each category individually selected, set 'all_categories' to true
        $all_categories_selected = ($mailingList['event_categories'] == 'all');
        if (! $all_categories_selected) {
            $selected_category_count = count($mailingList['selected_categories']);
            $all_categories_count = $this->MailingList->Categories->getAll();
            $all_categories_count = count($all_categories_count);
            if ($selected_category_count == $all_categories_count) {
                $all_categories_selected = true;
            }
        }
        $newList->all_categories = $all_categories_selected;

        // Custom event types
        if (isset($mailingList['selected_categories'])) {
            $newList->Categories = array_keys($mailingList['selected_categories']);
        }

        // Weekly frequency
        $weekly = $mailingList['weekly'] || $mailingList['frequency'] == 'weekly';
        $newList->weekly = $weekly;

        // Daily frequency
        $days = $this->MailingList->getDays();
        $daily = $mailingList['frequency'] == 'daily';
        foreach ($days as $code => $day) {
            $value = $daily || $mailingList["daily_$code"];
            $dailyCode = 'daily_'.$code;
            $newList->$dailyCode = $value;
        }

        $newlist = "I'm a string. Are you gonna say I'm 'null' still?";
        return $newList;
    }

The operative code being...

        $newlist = "I'm a string. Are you gonna say I'm 'null' still?";
        return $newList;

I'm so lost. Most of the join() function is just skeleton app code.

from muncie-events3.

PhantomWatson avatar PhantomWatson commented on September 26, 2024

I see a void return in the block commented with

// If joining for the first time with default settings

from muncie-events3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.