original_string: public function add(array $data)
      {
          $result = null;
          $this->hook->attach('file.add.before', $data, $result, $this);
  
          if (isset($result)) {
              return (int) $result;
          }
  
          if (empty($data['mime_type'])) {
              $data['mime_type'] = mime_content_type(gplcart_file_absolute($data['path']));
          }
  
          if (empty($data['file_type'])) {
              $data['file_type'] = strtolower(strtok($data['mime_type'], '/'));
          }
  
          if (empty($data['title'])) {
              $data['title'] = basename($data['path']);
          }
  
          $data['created'] = $data['modified'] = GC_TIME;
          $result = $data['file_id'] = $this->db->insert('file', $data);
  
          $this->setTranslations($data, $this->translation_entity, 'file', false);
  
          $this->hook->attach('file.add.after', $data, $result, $this);
          return (int) $result;
      }
code: public function add(array $data)
      {
          $result = null;
          $this->hook->attach('file.add.before', $data, $result, $this);
  
          if (isset($result)) {
              return (int) $result;
          }
  
          if (empty($data['mime_type'])) {
              $data['mime_type'] = mime_content_type(gplcart_file_absolute($data['path']));
          }
  
          if (empty($data['file_type'])) {
              $data['file_type'] = strtolower(strtok($data['mime_type'], '/'));
          }
  
          if (empty($data['title'])) {
              $data['title'] = basename($data['path']);
          }
  
          $data['created'] = $data['modified'] = GC_TIME;
          $result = $data['file_id'] = $this->db->insert('file', $data);
  
          $this->setTranslations($data, $this->translation_entity, 'file', false);
  
          $this->hook->attach('file.add.after', $data, $result, $this);
          return (int) $result;
      }
code_tokens: public function add ( array $ data ) { $ result = null ; $ this -> hook -> attach ( 'file.add.before' , $ data , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( int ) $ result ; } if ( empty ( $ data [ 'mime_type' ] ) ) { $ data [ 'mime_type' ] = mime_content_type ( gplcart_file_absolute ( $ data [ 'path' ] ) ) ; } if ( empty ( $ data [ 'file_type' ] ) ) { $ data [ 'file_type' ] = strtolower ( strtok ( $ data [ 'mime_type' ] , '/' ) ) ; } if ( empty ( $ data [ 'title' ] ) ) { $ data [ 'title' ] = basename ( $ data [ 'path' ] ) ; } $ data [ 'created' ] = $ data [ 'modified' ] = GC_TIME ; $ result = $ data [ 'file_id' ] = $ this -> db -> insert ( 'file' , $ data ) ; $ this -> setTranslations ( $ data , $ this -> translation_entity , 'file' , false ) ; $ this -> hook -> attach ( 'file.add.after' , $ data , $ result , $ this ) ; return ( int ) $ result ; }
docstring: Adds a file to the database
  @param array $data
  @return integer
docstring_tokens: Adds a file to the database