src/Money/Module/Account/Controller/Account.php
public function create()
    {
        $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', 'Create Bank Account');

        $bankMapper = new BankMapper(Database::get('money'));
        $banks      = $bankMapper->select();

        $mapper   = new AccountMapper(Database::get('money'));
        $accounts = $mapper->findAllAccountByUserId((int) $session->get('id'));

        $account = $mapper->newDataInstance();

        $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->insert($account);

                $mapperAccountUser = new AccountUserMapper(Database::get('money'));
                $accountUser = $mapperAccountUser->newDataInstance();
                $accountUser->setUserId((int) $session->get('id'));
                $accountUser->setAccountId($account->getId());
                $mapperAccountUser->insert($accountUser);

                $session->setEphemeral('notification', serialize(new NotificationBootstrap('Bank account has been created!')));

                Server::getInstance()->redirect('/account/edit/' . $account->getId());
            } else {
                $this->checkDelete();
            }
        };

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

        return $this->getResponse('Edit');
    }
public function create()
    {
        $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', 'Create Bank Account');

        $bankMapper = new BankMapper(Database::get('money'));
        $banks      = $bankMapper->select();

        $mapper   = new AccountMapper(Database::get('money'));
        $accounts = $mapper->findAllAccountByUserId((int) $session->get('id'));

        $account = $mapper->newDataInstance();

        $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->insert($account);

                $mapperAccountUser = new AccountUserMapper(Database::get('money'));
                $accountUser = $mapperAccountUser->newDataInstance();
                $accountUser->setUserId((int) $session->get('id'));
                $accountUser->setAccountId($account->getId());
                $mapperAccountUser->insert($accountUser);

                $session->setEphemeral('notification', serialize(new NotificationBootstrap('Bank account has been created!')));

                Server::getInstance()->redirect('/account/edit/' . $account->getId());
            } 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