예제 #1
0
 /**
  * Parse data to the entity
  *
  * @param \skouat\ppde\entity\main $entity The entity object
  * @param string                   $run_before_insert
  *
  * @return string $log_action
  * @access protected
  */
 protected function add_edit_data($entity, $run_before_insert = '')
 {
     if ($entity->get_id()) {
         // Save the edited item entity to the database
         $entity->save($entity->check_required_field());
         $log_action = 'UPDATED';
     } else {
         // Insert the data to the database
         $entity->insert($run_before_insert);
         // Get the newly inserted identifier
         $id = $entity->get_id();
         // Reload the data to return a fresh entity
         $entity->load($id);
         $log_action = 'ADDED';
     }
     return $log_action;
 }
예제 #2
0
 /**
  * @param \skouat\ppde\entity\main $entity The entity object
  *
  * @return bool
  * @access protected
  */
 protected function is_added_data_exists($entity)
 {
     return $entity->data_exists($entity->build_sql_data_exists()) && $this->request->variable('action', '') === 'add';
 }