/** * Conditionally adds a condition to the passed Query that will make it find * records where there is no match with this association. * * @param \Cake\Database\Query $query The query to modify * @param array $options Options array containing the `negateMatch` key. * @return void */ protected function _appendNotMatching($query, $options) { $target = $this->_targetTable; if (!empty($options['negateMatch'])) { $primaryKey = $query->aliasFields((array) $target->primaryKey(), $this->_name); $query->andWhere(function ($exp) use($primaryKey) { array_map([$exp, 'isNull'], $primaryKey); return $exp; }); } }