src/Money/Module/Account/Controller/Account.php
public function edit()
    {
        $session = Session::getInstance();

        //~ Breadcrumb
        $this->breadcrumb->add((new BreadcrumbItem('Edit'))->setIcon('edit')->setIsActive(true));
        $this->navMenu->getItem('Edit')->setIsActive(true);

        //~ Content
        $this->dataCollection->add('title', 'Edit Bank Account');

        $accountId = $this->route->getParameterCollection()->getByName('id')->getValue();

        $bankMapper = new BankMapper(Database::get('money'));
        $list       = $bankMapper->select();
        $banks      = array();
        foreach ($list as $bank) {
            $banks[$bank->getId()] = $bank;
        }

        $mapper   = new AccountMapper(Database::get('money'));

        $accountsAll = $mapper->findAllAccountByUserId((int) $session->get('id'));
        $accounts = array();
        foreach ($accountsAll as $account) {

            if (!isset($accounts[$account->getBankId()])) {
                $accounts[$account->getBankId()] = array();
            }

            $accounts[$account->getBankId()][] = $account;
        }

        $account  = $mapper->findById($accountId);

        if ($account->getAccountUser()->getUserId() !== (int) $session->get('id')) {
            throw new \Exception('Not allowed!');
        }

        $server = Server::getInstance();
        $post   = Post::getInstance();

        if ($server->isPost()) {
            if ($post->get('action', '') === 'save') {
                $account->setName($post->get('account_name'));
                $account->setBankId((int) $post->get('bank_id'));
                $account->setAmount((float) $post->get('account_amount'));
                $account->setIsMain((bool) $post->get('account_is_main'));
                $account->setIdParent((int) $post->get('account_id_parent'));
                $mapper->update($account);

                $this->notifications->add(new NotificationBootstrap('Bank Account has been updated !'));
            } else {
                $this->checkDelete();
            }
        }

        $this->dataCollection->add('banks', $banks);
        $this->dataCollection->add('accounts', $accounts);
        $this->dataCollection->add('account', $account);

        return $this->getResponse('Edit');
    }
public function edit()
    {
        $session = Session::getInstance();

        //~ Breadcrumb
        $this->breadcrumb->add((new BreadcrumbItem('Edit'))->setIcon('edit')->setIsActive(true));
        $this->navMenu->getItem('Edit')->setIsActive(true);

        //~ Content
        $this->dataCollection->add('title', 'Edit Bank Account');

        $accountId = $this->route->getParameterCollection()->getByName('id')->getValue();

        $bankMapper = new BankMapper(Database::get('money'));
        $list       = $bankMapper->select();
        $banks      = array();
        foreach ($list as $bank) {
            $banks[$bank->getId()] = $bank;
        }

        $mapper   = new AccountMapper(Database::get('money'));

        $accountsAll = $mapper->findAllAccountByUserId((int) $session->get('id'));
        $accounts = array();
        foreach ($accountsAll as $account) {

            if (!isset($accounts[$account->getBankId()])) {
                $accounts[$account->getBankId()] = array();
            }

            $accounts[$account->getBankId()][] = $account;
        }

        $account  = $mapper->findById($accountId);

        if ($account->getAccountUser()->getUserId() !== (int) $session->get('id')) {
            throw new \Exception('Not allowed!');
        }

        $server = Server::getInstance();
        $post   = Post::getInstance();

        if ($server->isPost()) {
            if ($post->get('action', '') === 'save') {
                $account->setName($post->get('account_name'));
                $account->setBankId((int) $post->get('bank_id'));
                $account->setAmount((float) $post->get('account_amount'));
                $account->setIsMain((bool) $post->get('account_is_main'));
                $account->setIdParent((int) $post->get('account_id_parent'));
                $mapper->update($account);

                $this->notifications->add(new NotificationBootstrap('Bank Account has been updated !'));
            } else {
                $this->checkDelete();
            }
        }

        $this->dataCollection->add('banks', $banks);
        $this->dataCollection->add('accounts', $accounts);
        $this->dataCollection->add('account', $account);

        return $this->getResponse('Edit');
    }
Main controller action.

@return Template