phpbb\notification\type\topic::create_insert_array PHP Method

create_insert_array() public method

Function for preparing the data for insertion in an SQL query (The service handles insertion)
public create_insert_array ( array $post, array $pre_create_data = [] ) : array
$post array Data from submit_post
$pre_create_data array Data from pre_create_insert_array()
return array Array of data ready to be inserted into the database
    public function create_insert_array($post, $pre_create_data = array())
    {
        $this->set_data('poster_id', $post['poster_id']);
        $this->set_data('topic_title', $post['topic_title']);
        $this->set_data('post_username', $post['poster_id'] == ANONYMOUS ? $post['post_username'] : '');
        $this->set_data('forum_name', $post['forum_name']);
        $this->notification_time = $post['post_time'];
        // Topics can be "read" before they are public (while awaiting approval).
        // Make sure that if the user has read the topic, it's marked as read in the notification
        if ($this->inherit_read_status && isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) {
            $this->notification_read = true;
        }
        return parent::create_insert_array($post, $pre_create_data);
    }

Usage Example

 /**
  * Function for preparing the data for insertion in an SQL query
  * (The service handles insertion)
  *
  * @param array $post Data from submit_post
  * @param array $pre_create_data Data from pre_create_insert_array()
  *
  * @return array Array of data ready to be inserted into the database
  */
 public function create_insert_array($post, $pre_create_data = array())
 {
     $data = parent::create_insert_array($post, $pre_create_data);
     $this->notification_time = $data['notification_time'] = time();
     return $data;
 }
All Usage Examples Of phpbb\notification\type\topic::create_insert_array