If it is a shared function between two controllers, why not create a shared service class that both controllers use?
For example, CartFunctions.php
<?php
// src/AppBundle/Classes/CartFunctions.php
namespace AppBundle\Classes\CartFunctions;
class CartFunctions
{
public function __construct()
{
// optional DI of other things if required
}
private function onlinecoupontrancation($params)
{
$foo = true;
// whatever you want to do
return $foo;
}
}
Create this as a service, instructions here
Something like;
app/config/services.yml
services:
cart.functions:
class: AppBundle\CartFunctions
arguments: []
So in your controllers;
public function cartAction($params)
{
// other stuff ...
$cartFunctions = $this->get('cart.functions');
$foo = $cartFunctions->onlinecoupontrancation($params);
}