I am trying to update a old custom module written for Drupal 7 for Drupal 8. I have used a lot of view functions like views_include() and views_get_view(). Are they all dropped in Drupal 8?

function validate_email($email) {   
    //pass the email to the filter
    $name = 'send_otp';
    $display = 'page_1';
    $alter = array('exposed' =>array('field_email_value' => $email));
    $view = views_get_view($name);
    $view->is_cacheable = FALSE;    
    if(isset($alter['exposed'])) {
        foreach($alter['exposed'] as $key => $valor) {
            $view->exposed_input[$key] = $valor;
    $output = $view->display_handler->preview();
    //if the result is empty
    if(empty($view->result)) {
        //return 0
        return 0;
    else {
        //return node id
        return $view->result[0]->nid;

Fatal error: Call to undefined function views_include() in /var/www/html/mdc-conference-backend/sites/all/modules/custom/rest/sendotp.php on line 43


1 Answer 1


views_get_view became Views::getView, and several others are now static methods on the Views class in the views module.

I don't think views_include is necessary anymore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.