Cake\ORM\Association\BelongsToMany::junctionConditions PHP Method

junctionConditions() protected method

Returns filtered conditions that specifically reference the junction table.
protected junctionConditions ( ) : array
return array
    protected function junctionConditions()
    {
        if ($this->_junctionConditions !== null) {
            return $this->_junctionConditions;
        }
        $matching = [];
        $conditions = $this->conditions();
        if (!is_array($conditions)) {
            return $matching;
        }
        $alias = $this->_junctionAssociationName() . '.';
        foreach ($conditions as $field => $value) {
            $isString = is_string($field);
            if ($isString && strpos($field, $alias) === 0) {
                $matching[$field] = $value;
            }
            // Assume that operators contain junction conditions.
            // Trying to munge complex conditions could result in incorrect queries.
            if ($isString && in_array(strtoupper($field), ['OR', 'NOT', 'AND', 'XOR'])) {
                $matching[$field] = $value;
            }
        }
        return $this->_junctionConditions = $matching;
    }