Open felixboehm opened 7 years ago
Thanks for pointing me in the right direction I've below added my code until now, but I always get that the issue: "PHP Fatal error: Uncaught Error: Class 'Symfony\Component\HttpKernel\KernelInterface' not found"
What do I need to change for the KernelInterface to be availible in my code ?
` <?php namespace AppBundle\Controller;
//Make kernael commands availible by using below frameworks
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
//Define The Class used to use the command
//class UserSyncBackendController extends Controller {
//Define the function used to execute the Command
function syncUserBackend(Kernelinterface $kernel){
//Create an application using the kernel
$application = new Application($kernel);
$application->setAutoExit(false);
//Create an input variable that will be sent to the kernel
$input = new ArrayInput(array(
//Define the message that will be sent to the kernel
'comand' => "occ user:sync 'OCA\User_LDAP\User_Proxy' -m 'remove' -n",
//Define the message limit if you want to limit the messages that are being sent
//'--mesage-limit' => $message,
));
//Create the output that will be filled with the output of the function
$output = new BufferedOutput();
//run the set up command on the kernel
$application->run($input, $output);
//Fetch the response of the command
$content = $output->fetch();
//Return the response
return new Response($content);
}
?>
To be clear the issue get thrown when I tried to create a kernel object, to send it to the function
$kernel = new KernelInterface()
$userSyncResult = syncUserBackend($kernel);
echo $userSyncResult;
The userSync doesn't use any KernelInterface, this comes from the example, right?
https://github.com/owncloud/core/blob/master/core/Command/User/SyncBackend.php#L57
The project managment has decided against the helpdesk triggerable user scan, since then I haven't invested any time in to this
Still thank you for the help Felix
You want to call this command, which is basically a
Symfony\Component\Console\Command\Command
https://github.com/owncloud/core/blob/master/core/Command/User/SyncBackend.phpHere is described how to call such a command directly via PHP: https://symfony.com/doc/current/console/command_in_controller.html