protected function addOrEditObject($data = [], $redirect = TRUE)
	{
		try {
			if ($this->detailObject) {
				// Edit object
				$this->canUser('edit');
				$this->mainManager->edit($this->detailObject->id, $data);
				$this->flashMessage('Object saved');

			} else {
				// Add object
				$this->canUser('add');
				$this->mainManager->add($data);
				$this->flashMessage('Object added');
			}

		} catch (\Exception $e) {
			$this->flashMessage('Upps.', 'error');
		}

		if ($redirect) {
			$this->redirect('default');
		}

	}
protected function addOrEditObject($data = [], $redirect = TRUE)
	{
		try {
			if ($this->detailObject) {
				// Edit object
				$this->canUser('edit');
				$this->mainManager->edit($this->detailObject->id, $data);
				$this->flashMessage('Object saved');

			} else {
				// Add object
				$this->canUser('add');
				$this->mainManager->add($data);
				$this->flashMessage('Object added');
			}

		} catch (\Exception $e) {
			$this->flashMessage('Upps.', 'error');
		}

		if ($redirect) {
			$this->redirect('default');
		}

	}
protected function addOrEditObject ( $ data = [ ] , $ redirect = TRUE ) { try { if ( $ this -> detailObject ) { // Edit object $ this -> canUser ( 'edit' ) ; $ this -> mainManager -> edit ( $ this -> detailObject -> id , $ data ) ; $ this -> flashMessage ( 'Object saved' ) ; } else { // Add object $ this -> canUser ( 'add' ) ; $ this -> mainManager -> add ( $ data ) ; $ this -> flashMessage ( 'Object added' ) ; } } catch ( \ Exception $ e ) { $ this -> flashMessage ( 'Upps.' , 'error' ) ; } if ( $ redirect ) { $ this -> redirect ( 'default' ) ; } }
Simple implementation add or edit object

@param array $data
@param bool $redirect
Simple implementation add or edit object