<commit_before><?php
namespace Notes\View\Cell;

use Cake\View\Cell;

class NotesCell extends Cell
{
    /**
     * Pass record specific notes to the View, based on current user and visibility.
     *
     * @param  string $relatedModel related model name
     * @param  string $relatedId related record id
     * @return void
     */
    public function recordNotes($relatedModel, $relatedId)
    {
        $currentUser = $this->request->session()->read('Auth.User');
        $this->loadModel('Notes.Notes');
        $notes = $this->Notes->find('all')
            ->contain([
                'Users'
            ])
            ->where([
                'Notes.user_id' => $currentUser['id']
            ])
            ->orWhere([
                'Notes.shared' => $this->Notes->getPublicShared()
            ])
            ->andWhere([
                'Notes.related_model' => $relatedModel,
                'Notes.related_id' => $relatedId
            ])
            ->order([
                'Notes.modified' => 'DESC'
            ]);
        $types = $this->Notes->getTypes();
        $shared = $this->Notes->getShared();

        $this->set(compact('currentUser', 'notes', 'types', 'shared'));
    }
}
<commit_msg>pass related model and id to record notes cell (task #3151)<commit_after><?php
namespace Notes\View\Cell;

use Cake\View\Cell;

class NotesCell extends Cell
{
    /**
     * Pass record specific notes to the View, based on current user and visibility.
     *
     * @param  string $relatedModel related model name
     * @param  string $relatedId related record id
     * @return void
     */
    public function recordNotes($relatedModel, $relatedId)
    {
        $currentUser = $this->request->session()->read('Auth.User');
        $this->loadModel('Notes.Notes');
        $notes = $this->Notes->find('all')
            ->contain([
                'Users'
            ])
            ->where([
                'Notes.user_id' => $currentUser['id']
            ])
            ->orWhere([
                'Notes.shared' => $this->Notes->getPublicShared()
            ])
            ->andWhere([
                'Notes.related_model' => $relatedModel,
                'Notes.related_id' => $relatedId
            ])
            ->order([
                'Notes.modified' => 'DESC'
            ]);
        $types = $this->Notes->getTypes();
        $shared = $this->Notes->getShared();

        $this->set(compact('relatedModel', 'relatedId', 'notes', 'types', 'shared'));
    }
}

{'fraction_non_alphanumeric': 0.15292233787029624, 'fraction_numerical': 0.0016012810248198558, 'mean_word_length': 1.7953020134228188, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '6245864', 'n_tokens_mistral': 719, 'n_tokens_neox': 675, 'n_words': 149}