i have a service that return for me true in the node (article) successfully create and false if something wrong , but in the controller i am getting this error 'LogicException : The controller must return a response (success ! given). dans Symfony\Component\HttpKernel\HttpKernel->handleRaw() (ligne 169 de /var/www/html/vendor/symfony/http-kernel/HttpKernel.php).'
can anyone tell me where is the problem in the controller return of my code please ?
service
public function createArticle()
{
$node = Node::create(array(
'type' => 'article custom',
'title' => 'article custom',
'langcode' => 'fr',
'uid' => '1',
'status' => 1,
'field_fields' => array(),
));
$node->save();
if($node)
return true;
else
return false;
}
the controller methode
public function myPageCreate()
{
$service = \Drupal::service('mymodule.ran');
$createnode = $service->createArticle();
if($createnode)
return 'success !';
else
return 'somthing wrong !';
}