isActive() 공개 메소드

If no parameter is passed, then return active page mode.
public isActive ( string $mode = null ) : boolean | string
$mode string Optionally ask for specific mode
리턴 boolean | string
예제 #1
0
파일: CRUD.php 프로젝트: atk4/atk4
 /**
  * Returns if CRUD is in editing mode or not. It's preferable over
  * checking if($grid->form).
  *
  * @param string $mode Specify which editing mode you expect
  *
  * @return bool true if editing.
  */
 public function isEditing($mode = null)
 {
     $page_mode = $this->virtual_page->isActive();
     // Requested edit, but not allowed
     if ($page_mode == 'edit' && !$this->allow_edit) {
         throw $this->exception('Editing is not allowed');
     }
     // Requested add but not allowed
     if ($page_mode == 'add' && !$this->allow_add) {
         throw $this->exception('Adding is not allowed');
     }
     // Request matched argument exactly
     if (!is_null($mode)) {
         return $mode === $page_mode;
     }
     // Argument was blank, then edit/add is OK
     return (bool) $page_mode;
 }