Skip to content

Instantly share code, notes, and snippets.

@rande
Created January 24, 2011 12:07
Show Gist options
  • Save rande/793131 to your computer and use it in GitHub Desktop.
Save rande/793131 to your computer and use it in GitHub Desktop.
diff --git a/Document/UserManager.php b/Document/UserManager.php
index ef28089..c5d5b2d 100644
--- a/Document/UserManager.php
+++ b/Document/UserManager.php
@@ -19,11 +19,13 @@ class UserManager extends BaseUserManager
{
parent::__construct($encoder, $algorithm, $canonicalizer);
- $this->dm = $dm;
- $this->repository = $dm->getRepository($class);
+ if (class_exists($class)) {
+ $this->dm = $dm;
+ $this->repository = $dm->getRepository($class);
- $metadata = $dm->getClassMetadata($class);
- $this->class = $metadata->name;
+ $metadata = $dm->getClassMetadata($class);
+ $this->class = $metadata->name;
+ }
}
/**
diff --git a/Entity/UserManager.php b/Entity/UserManager.php
index 02ecf1c..c1ac0e4 100644
--- a/Entity/UserManager.php
+++ b/Entity/UserManager.php
@@ -19,11 +19,13 @@ class UserManager extends BaseUserManager
{
parent::__construct($encoder, $algorithm, $canonicalizer);
- $this->em = $em;
- $this->repository = $em->getRepository($class);
+ if (class_exists($class)) {
+ $this->em = $em;
+ $this->repository = $em->getRepository($class);
- $metadata = $em->getClassMetadata($class);
- $this->class = $metadata->name;
+ $metadata = $em->getClassMetadata($class);
+ $this->class = $metadata->name;
+ }
}
/**
diff --git a/FOSUserBundle.php b/FOSUserBundle.php
index 4103ed8..9960cf6 100644
--- a/FOSUserBundle.php
+++ b/FOSUserBundle.php
@@ -16,8 +16,11 @@ class FOSUserBundle extends Bundle
{
public function boot()
{
+
$class = $this->container->get('fos_user.user_manager')->getClass();
- call_user_func(array($class, 'setCanonicalizer'), $this->container->get('fos_user.util.canonicalizer'));
+ if ($class) {
+ call_user_func(array($class, 'setCanonicalizer'), $this->container->get('fos_user.util.canonicalizer'));
+ }
}
public function getNamespace()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment