PHP Classes

File: main.php

Recommend this page to a friend!
  Classes of Necip   NCP Search   main.php   Download  
File: main.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: NCP Search
Manipulate data items stored in ElasticSearch
Author: By
Last change:
Date: 5 years ago
Size: 890 bytes


Class file image Download

// initialize ncp_search table once with all tables which has to be indexed in the main function
NCPSearch::insert_ncp_search_items(UserModel::model()->findAll(), "user", ["login", "mail", "name_last", "name_first"]);
NCPSearch::insert_ncp_search_items(DepartmentModel::model()->findAll(), "department", ["title", "description"]);
NCPSearch::insert_ncp_search_items(ObjectModel::model()->findAll(), "object", ["title", "description"]);

// for each model
class Object : Model
  function afterSave() {
     // insert this code to synchronize the informations on ncp_index
     if ($this->status === ObjectStatus::DELETED)
            NCPSearch::delete_ncp_search_item($this, "object");
            NCPSearch::update_ncp_search_item($this, "object", ["title", "description"]);