Node::_findViewById PHP Method

_findViewById() protected method

Find a single node by id
protected _findViewById ( $state, $query, $results = [] )
    protected function _findViewById($state, $query, $results = array())
    {
        if ($state == 'after') {
            if (isset($results[0])) {
                return $results[0];
            }
            return $results;
        }
        if ($query['conditions'] === null) {
            $query = Hash::merge($query, array('conditions' => array()));
        }
        $keys = array('id' => null, 'roleId' => null);
        $args = array_merge($keys, array_intersect_key($query, $keys));
        $query = array_diff_key($query, $args);
        $visibilityRolesField = $this->escapeField('visibility_roles');
        $query = Hash::merge(array('conditions' => array($this->escapeField() => $args['id'], $this->escapeField('status') => $this->status(), 'OR' => array($visibilityRolesField => '', $visibilityRolesField . ' LIKE' => '%"' . $args['roleId'] . '"%')), 'contain' => array('Meta', 'Taxonomy' => array('Term', 'Vocabulary'), 'User'), 'cache' => array('name' => 'node_' . $args['roleId'] . '_' . $args['id'], 'config' => 'nodes_view')), $query);
        return $query;
    }