function salvarFuncionalidade($Funcionalidades, $grupo) { $DAO = new GrupoFuncionalidadeDAO(); $gf = new GrupoFuncionalidade(); foreach ($Funcionalidades as $item) { $gf->setIdGrupo($grupo); $gf->setIdFuncionalidade($item); $gf->setIdUsuario(userId()); $retorno = $DAO->Gravar($gf); if (!$retorno) { print_r($retorno); die; } } return true; }
/** * Store the object and its aggregates */ public function store() { // store the object itself parent::store(); // delete the related System_groupSystem_program objects $criteria = new TCriteria(); $criteria->add(new TFilter('grupo_id', '=', $this->id)); $repository = new TRepository('GrupoFuncionalidade'); $repository->delete($criteria); // store the related System_groupSystem_program objects if ($this->funcionalidades) { foreach ($this->funcionalidades as $funcionalidade) { $grupo_funcionalidade = new GrupoFuncionalidade(); $grupo_funcionalidade->funcionalidade_id = $funcionalidade->id; $grupo_funcionalidade->grupo_id = $this->id; $grupo_funcionalidade->store(); } } }