*
* @return ORMInvalidArgumentException
*/
public static function invalidObject($context, $given, $parameterIndex = 1)
{
return new self($context . ' expects parameter ' . $parameterIndex .
' to be an entity object, ' . gettype($given) . ' given.');
}
/** @return ORMInvalidArgumentException */
public static function invalidCompositeIdentifier()
* @throws ORMException
*/
public function remove($entity)
{
if (! is_object($entity)) {
throw ORMInvalidArgumentException::invalidObject('EntityManager#remove()', $entity);
}
$this->errorIfClosed();
$this->unitOfWork->remove($entity);
#[Route('article/deletearticle/{id}', name: 'deletearticle')]
public function deletearticleAction(ArticleRepository $articlerep,$id): Response {
$article= $articlerep->find($id);
$this->entityManager->remove($article);
$this->entityManager->flush();
$this->addFlash('success', "Article has been deleted");
return $this->redirectToRoute('article_create');
}
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
$controller = $event->getController();
$arguments = $event->getArguments();
// call controller
$response = $controller(...$arguments);
// view
if (!$response instanceof Response) {
$event = new ViewEvent($this, $request, $type, $response, $event);
$this->dispatcher->dispatch($event, KernelEvents::VIEW);
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
$this->requestStack->push($request);
$response = null;
try {
return $response = $this->handleRaw($request, $type);
} catch (\Throwable $e) {
if ($e instanceof \Error && !$this->handleAllThrowables) {
throw $e;
}
$this->boot();
++$this->requestStackSize;
$this->resetServices = true;
try {
return $this->getHttpKernel()->handle($request, $type, $catch);
} finally {
--$this->requestStackSize;
}
}
) {
}
public function run(): int
{
$response = $this->kernel->handle($this->request);
if (Kernel::VERSION_ID >= 60400) {
$response->send(false);
if (\function_exists('fastcgi_finish_request') && !$this->debug) {
$app = $app(...$args);
exit(
$runtime
->getRunner($app)
->run()
);
<?php
umask(0000);
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
ORMInvalidArgumentException
|
---|
Doctrine\ORM\ORMInvalidArgumentException: EntityManager#remove() expects parameter 1 to be an entity object, NULL given. at vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php:190 at Doctrine\ORM\ORMInvalidArgumentException::invalidObject() (vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:690) at Doctrine\ORM\EntityManager->remove() (src/Controller/ArticleController.php:2107) at App\Controller\ArticleController->deletearticleAction() (vendor/symfony/http-kernel/HttpKernel.php:181) at Symfony\Component\HttpKernel\HttpKernel->handleRaw() (vendor/symfony/http-kernel/HttpKernel.php:76) at Symfony\Component\HttpKernel\HttpKernel->handle() (vendor/symfony/http-kernel/Kernel.php:197) at Symfony\Component\HttpKernel\Kernel->handle() (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (vendor/autoload_runtime.php:29) at require_once('/usr/www/users/smartm/vendor/autoload_runtime.php') (public/index.php:5) |