PUGX / PUGXMultiUserBundle

An extension for FOSUserBundle to handle users of different types. Compatible with Doctrine ORM.
163 stars 96 forks source link

Argument 3 passed to PUGX\MultiUserBundle\Controller\RegistrationManager #82

Closed ezpoko closed 9 years ago

ezpoko commented 9 years ago

Hi,

I'm training to register a new user but can't do it due to the following catchable error.

Catchable Fatal Error: Argument 3 passed to PUGX\MultiUserBundle\Controller\RegistrationManager::__construct() must be an instance of FOS\UserBundle\Controller\RegistrationController Any help will be appreciable. Thanks.
leopro commented 9 years ago

What do you got instead of FOS\UserBundle\Controller\RegistrationController ?

ezpoko commented 9 years ago

Thanks for your answer. But what do you really mean? Here is the all error :

Catchable Fatal Error: Argument 3 passed to PUGX\MultiUserBundle\Controller\RegistrationManager::__construct() must be an instance of FOS\UserBundle\Controller\RegistrationController, instance of BB\UserBundle\Controller\RegistrationController given, called in D:\www\dev.localhost\app\cache\dev\appDevDebugProjectContainer.php on line 2630 and defined

The error occured even if the cache is cleared. I'm using symfony 2.60

Thanks

leopro commented 9 years ago

The error is quite clear:

must be an instance of FOS\UserBundle\Controller\RegistrationController, instance of BB\UserBundle\Controller\RegistrationController given

ezpoko commented 9 years ago
    use Doctrine\ORM\Mapping as ORM;
    use FOS\UserBundle\Model\GroupInterface;
    use FOS\UserBundle\Model\User as BaseUser;

    /**
     * @ORM\Entity
     * @ORM\Table(name="fos_user")
     * @ORM\InheritanceType("JOINED")
     * @ORM\DiscriminatorColumn(name="type", type="string")
     * @ORM\DiscriminatorMap({"administrator" = "Administrator", "employee" = "Employee", "participant" = "Participant", "recruiter" = "Recruiter", "individual" = "Individual"})
     * @ORM\HasLifecycleCallbacks()
     * @ORM\Entity(repositoryClass="BB\UserBundle\Entity\UserRepository")
     *
     */
    abstract class User extends BaseUser
    {
    }

      /**
     * Employee
     *
     * @ORM\Table(name="employee")
     * @ORM\Entity(repositoryClass="BB\UserBundle\Entity\EmployeeRepository")
     * @UniqueEntity(fields = "username", targetClass = "BB\UserBundle\Entity\User", message="fos_user.username.already_used")
     * @UniqueEntity(fields = "email", targetClass = "BB\UserBundle\Entity\User", message="fos_user.email.already_used")
     */
    class Employee extends User
    {
    }

      namespace BB\UserBundle\Controller;

    use Symfony\Bundle\FrameworkBundle\Controller\Controller;

    class RegistrationEmployeeController extends Controller
    {

            /**
             * Add a new Employee
             * @return type
             */
            public function registerAction()
            {
                    return $this->container
                                            ->get('pugx_multi_user.registration_manager')
                                            ->register('BB\UserBundle\Entity\Employee');
            }

    }

Where's the mistake ?

garak commented 9 years ago

You must extends FOS\UserBundle\Controller\RegistrationController

ezpoko commented 9 years ago

The problem is solved. Thanks a lot.