here is my little story: I am using DoctrinExtensions Tree on my entity account. The user can edit the tree in the UI and then save it. I send back back to the PHP an array of all the accounts. Then I want to rebuilt it as a tree and save/edit the accounts with the methods of the extension.
So I want to compare the UI returned array with my original tree from the db. I get the data by doing something like this:
$repo = $em->getRepository('NRtworksChartOfAccountsBundle:Accounttree');
$arrayTree = $repo->findAll();
So I have my tree in an array. What I want now is to find an object within this array by itsd ID. I know how to write the function, but in the MVC I don't know what's the right place to write it and call it from, nor if it's the correct way.
I tried to create a folder "Model" and a file Functions.php like this:
namespace NRtworks\ChartOfAccountsBundle\Model;
function get_account_from_id($array)
{
return "true";
}
and then call it from my controller
use NRtworks\ChartOfAccountsBundle\Model\Functions;
get_account_from_id($arrayTree);
But that doesn't work. Please advise on how I should do this and if there is a more correct way in the scope of the MVC idea.
thanks