Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
468 views
in Technique[技术] by (71.8m points)

orm - Unknown Entity namespace alias in symfony2

Hey I have two bundles in my symfony2 project. one is Bundle and the other one is PatentBundle.

My app/config/route.yml file is

MunichInnovationGroupPatentBundle:
resource: "@MunichInnovationGroupPatentBundle/Controller/"
type:     annotation
prefix:   /
defaults:  { _controller: "MunichInnovationGroupPatentBundle:Default:index" }

MunichInnovationGroupBundle:
resource: "@MunichInnovationGroupBundle/Controller/"
type:     annotation
prefix:   /v1
defaults:  { _controller: "MunichInnovationGroupBundle:Patent:index" }

login_check:
pattern:   /login_check

logout:
pattern:   /logout

inside my controller i have

<?php
namespace MunichInnovationGroupPatentBundleController;

use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentHttpFoundationRequest;
use JMSSecurityExtraPatentBundleAnnotationSecure;
use SymfonyComponentSecurityCoreExceptionAccessDeniedException;
use SymfonyBundleFrameworkBundleControllerController;
use SensioBundleFrameworkExtraBundleConfigurationMethod;
use SensioBundleFrameworkExtraBundleConfigurationRoute;
use SensioBundleFrameworkExtraBundleConfigurationTemplate;
use SymfonyComponentSecurityCoreSecurityContext;

use MunichInnovationGroupPatentBundleEntityLog;
use MunichInnovationGroupPatentBundleEntityUserPatent;
use MunichInnovationGroupPatentBundleEntityPmPortfolios;
use MunichInnovationGroupPatentBundleEntityUmUsers;
use MunichInnovationGroupPatentBundleEntityPmPatentgroups;
use MunichInnovationGroupPatentBundleFormPortfolioType;
use MunichInnovationGroupPatentBundleUtilSecurityHelper;
use Exception;
/**
 * Portfolio controller.
 * @Route("/portfolio")
 */
class PortfolioController extends Controller {
/**
 * Index action.
 *
 * @Route("/", name="v2_pm_portfolio")
 * @Template("MunichInnovationGroupPatentBundle:Portfolio:index.html.twig")
 */
   public function indexAction(Request $request) {
    $portfolios = $this->getDoctrine()
    ->getRepository('MunichInnovationGroupPatentBundle:PmPortfolios')
    ->findBy(array('user' => '$user_id'));

           // rest of the method
  }

Edit:

My Entity Class

<?php

 namespace MunichInnovationGroupPatentBundleEntity;

 use DoctrineORMMapping as ORM;

  /**
  * MunichInnovationGroupPatentBundleEntityPmPortfolios
  *
  * @ORMTable(name="pm_portfolios")
  * @ORMEntity
  */
  class PmPortfolios
  {
/**
 * @var string $id
 *
 * @ORMColumn(name="id", type="string", length=36, nullable=false)
 * @ORMId
 * @ORMGeneratedValue(strategy="UUID")
 */
private $id;

/**
 * @var string $portfolioName
 *
 * @ORMColumn(name="portfolio_name", type="string", length=255, nullable=false)
 */
private $portfolioName;

/**
 * @var text $description
 *
 * @ORMColumn(name="description", type="text", nullable=true)
 */
private $description;

/**
 * @var string $permalink
 *
 * @ORMColumn(name="permalink", type="string", length=255, nullable=false)
 */
private $permalink;

/**
 * @var string $sharingCode
 *
 * @ORMColumn(name="sharing_code", type="string", length=255, nullable=false)
 */
private $sharingCode;

/**
 * @var boolean $shared
 *
 * @ORMColumn(name="shared", type="boolean", nullable=false)
 */
private $shared;

/**
 * @var integer $sharedPortfolioCalls
 *
 * @ORMColumn(name="shared_portfolio_calls", type="integer", nullable=true)
 */
private $sharedPortfolioCalls;

/**
 * @var boolean $isDefault
 *
 * @ORMColumn(name="is_default", type="boolean", nullable=false)
 */
private $isDefault;

/**
 * @var UmUsers
 *
 * @ORMManyToOne(targetEntity="UmUsers")
 * @ORMJoinColumns({
 *   @ORMJoinColumn(name="user_id", referencedColumnName="id")
 * })
 */
private $user;



/**
 * Get id
 *
 * @return string 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set portfolioName
 *
 * @param string $portfolioName
 */
public function setPortfolioName($portfolioName)
{
    $this->portfolioName = $portfolioName;
}

/**
 * Get portfolioName
 *
 * @return string 
 */
public function getPortfolioName()
{
    return $this->portfolioName;
}

/**
 * Set description
 *
 * @param text $description
 */
public function setDescription($description)
{
    $this->description = $description;
}

/**
 * Get description
 *
 * @return text 
 */
public function getDescription()
{
    return $this->description;
}

/**
 * Set permalink
 *
 * @param string $permalink
 */
public function setPermalink($permalink)
{
    $this->permalink = $permalink;
}

/**
 * Get permalink
 *
 * @return string 
 */
public function getPermalink()
{
    return $this->permalink;
}

/**
 * Set sharingCode
 *
 * @param string $sharingCode
 */
public function setSharingCode($sharingCode)
{
    $this->sharingCode = $sharingCode;
}

/**
 * Get sharingCode
 *
 * @return string 
 */
public function getSharingCode()
{
    return $this->sharingCode;
}

/**
 * Set shared
 *
 * @param boolean $shared
 */
public function setShared($shared)
{
    $this->shared = $shared;
}

/**
 * Get shared
 *
 * @return boolean 
 */
public function getShared()
{
    return $this->shared;
}

/**
 * Set sharedPortfolioCalls
 *
 * @param integer $sharedPortfolioCalls
 */
public function setSharedPortfolioCalls($sharedPortfolioCalls)
{
    $this->sharedPortfolioCalls = $sharedPortfolioCalls;
}

/**
 * Get sharedPortfolioCalls
 *
 * @return integer 
 */
public function getSharedPortfolioCalls()
{
    return $this->sharedPortfolioCalls;
}

/**
 * Set isDefault
 *
 * @param boolean $isDefault
 */
public function setIsDefault($isDefault)
{
    $this->isDefault = $isDefault;
}

/**
 * Get isDefault
 *
 * @return boolean 
 */
public function getIsDefault()
{
    return $this->isDefault;
}

/**
 * Set user
 *
 * @param MunichInnovationGroupPatentBundleEntityUmUsers $user
 */
public function setUser(MunichInnovationGroupPatentBundleEntityUmUsers $user)
{
    $this->user = $user;
}

/**
 * Get user
 *
 * @return MunichInnovationGroupPatentBundleEntityUmUsers 
 */
public function getUser()
{
    return $this->user;
}

}

My bundle main class: MunichInnovationGroupPatentBundle.php

 <?php

  namespace MunichInnovationGroupPatentBundle;

  use SymfonyComponentHttpKernelBundleBundle;

  class MunichInnovationGroupPatentBundle extends Bundle
 {
 }

when i try to load localhost/web/app_dev.php/portfolio

It says

   Unknown Entity namespace alias 'MunichInnovationGroupPatentBundle'.

I am unable to figure out this error please help me if anyone has any idea I googled it a lot :(

Thanks in advance 500 Internal Server Error - ORMException

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Please, check your config.yml.

Reviewed in section mappings of entity_managers.
You should have something like MunichInnovationGroupPatentBundle: ~

That is:

doctrine:
    orm:
        entity_managers:
            defaults:
                mappings:
                    MunichInnovationGroupPatentBundle: ~

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...