Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9248379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:55:58+00:00 2026-06-18T09:55:58+00:00

When clicking on a link, I pass an object id in My AlbumController I

  • 0

When clicking on a link, I pass an object id in My AlbumController I have :

<?php

namespace YM\TestBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class AlbumController extends Controller
{
    public function deleteAction($id)
    {

        if ($id > 0) {
            // We get the EntityManager
            $em = $this->getDoctrine()
                       ->getEntityManager();

            // We get the Entity that matches id: $id
            $article = $em->getRepository('YMTestBundle:Album')
                          ->find($id);

            // If the Album doesn't exist, we throw out a 404 error
            if ($article == null) {
              throw $this->createNotFoundException('Album[id='.$id.'] do not exist');
            }


              // We delete the article
            $em->remove($article);
            $em->flush();

            $this->get('session')->getFlashBag()->add('info', 'Album deleted successfully');

              // Puis on redirige vers l'accueil
              return $this->redirect( $this->generateUrl('ymtest_Artist') );
        }
        return $this->redirect( $this->generateUrl('ymtest_dashboard') );
    }
}

And it works.

But is saw something on stackoverflow, where they pass an object (I heard S2 is able to find it itself) that I’d like to reproduce:

<?php

namespace YM\TestBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class AlbumController extends Controller
{
    public function deleteAction(Album $album)
    {
        // We get the EntityManager
        $em = $this->getDoctrine()
                   ->getEntityManager();

        // If the Album doesn't exist, we throw out a 404 error
        if ($lbum == null) {
          throw $this->createNotFoundException('Album[id='.$id.'] do not exist');
        }


          // We delete the article
        $em->remove($album);
        $em->flush();

        $this->get('session')->getFlashBag()->add('info', 'Album deleted successfully');

          // Puis on redirige vers l'accueil
          return $this->redirect( $this->generateUrl('ymtest_Artist') );

        return $this->redirect( $this->generateUrl('ymtest_dashboard') );
    }
}

But it doesn’t work, I have :

Class YM\TestBundle\Controller\Album does not exist

Why ?
Thx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:55:59+00:00Added an answer on June 18, 2026 at 9:55 am

    First you forgot about use statement:

    use  YM\TestBundle\Entity\Album;
    

    In your case symfony looks for Album class in current namespace (which is Controller).

    Moveover you may want read more about ParamConverter (the mechanism which you ask about):

    http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html

    Try add something like that to your method annotation (And don’t forgot about appropriate namespace for this annotation):

    use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
    
    (...)
    
    /**
     * @ParamConverter("album", class="YMTestBundle:Album")
     */
    public function deleteAction(Album $album)
    {
       (...)
    

    :

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page in which i have provided a link clicking on which
I have a timer in my JavaScript which needs to emulate clicking a link
I have this link: <a href=data:application/pdf;base64,JVBERi0x...KJSVFT0YK>PDF</a> In Safari on MacOsX, clicking the link instantly
i have a website where i provicde a link. On clicking the link a
I have a user control with a More Info link. When clicking that link,
I have a link and on clicking it, a function is called. In that
I'm having problems adding a new table row by clicking the link_to_add function link.
I'm having an issue with showing a div after clicking a link. When I
I my application i am having three links, on clicking the link i need
Clicking a breadcrumb link in github will trigger the directory view area to transition

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.