You should write custom service and put logic inside. Doc: http://symfony.com/doc/current/book/service_container.html#what-is-a-service
UPDATE (Code example):
Les's configure service in the Container:
# app/config/config.yml
services:
your_service:
class: NRtworks\ChartOfAccountsBundle\Service\YourService
Now, your service class:
namespace NRtworks\ChartOfAccountsBundle\Service;
class YourService {
public function getAccountFromId(array $array)
{
return "true";
}
}
Now you could get this service from container like:
class SomeController extends Controller {
public function someMethod() {
$yourService = $this->get('your_service');
}
}
You can even inject your repository class to this service, like:
# app/config/config.yml
services:
app.accounTtree.repository:
class: Doctrine\ORM\EntityRepository
factory-service: doctrine.orm.entity_manager
factory-method: getRepository
arguments:
- "App\MainBundle\Entity\Gallery"
your_service:
class: NRtworks\ChartOfAccountsBundle\Service\YourService
calls:
- [ setRepository, ["@app.accounTtree.repository"]]
and just modify your service:
namespace NRtworks\ChartOfAccountsBundle\Service;
class YourService {
protected $repository;
public class setRepository($repository) {
$this->repository = $repository;
}
public function getAccountFromId(array $array)
{
return "true";
}
}