2016-07-05 26 views
-1

我安装了StofDoctrineExtensionsBundlelink相同。 相反,页面渲染非常缓慢,因为大约5分钟。我只需要用户实体(FOSUSERBUNDLE)中的slugable funcionality。我认为没有某些元素,它会更快地工作。SYMFONY2易损最小配置

什么是最低配置只能用此软件包运行sluggable。是否需要所有映射(请参阅link)?我想要config.yml的例子。

编辑 添加监听后,我config.yml样子:

... 
    orm: 
     default_entity_manager: default 
     auto_generate_proxy_classes: "%kernel.debug%" 
     entity_managers: 
      default: 
       connection: default 
       mappings: 
        AppBundle: ~ 
        gedmo_translatable: 
         type: annotation 
         prefix: Gedmo\Translatable\Entity 
         dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity" 
         alias: GedmoTranslatable # (optional) it will default to the name set for the mapping 
         is_bundle: false 
        gedmo_translator: 
         type: annotation 
         prefix: Gedmo\Translator\Entity 
         dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity" 
         alias: GedmoTranslator # (optional) it will default to the name set for the mapping 
         is_bundle: false 
        gedmo_loggable: 
         type: annotation 
         prefix: Gedmo\Loggable\Entity 
         dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity" 
         alias: GedmoLoggable # (optional) it will default to the name set for the mappingmapping 
         is_bundle: false 
        gedmo_tree: 
         type: annotation 
         prefix: Gedmo\Tree\Entity 
         dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity" 
         alias: GedmoTree # (optional) it will default to the name set for the mapping 
         is_bundle: false 

... 
stof_doctrine_extensions: 
    class: 
     sluggable:  ~ 
... 

我的实体与slugg:

namespace AppBundle\Entity; 
use Gedmo\Mapping\Annotation as Gedmo; 
use Doctrine\ORM\Mapping as ORM; 

/** 
* Profile 
* 
* @ORM\Table(name="profile") 
* @ORM\Entity(repositoryClass="AppBundle\Repository\ProfileRepository") 
*/ 
class Profile 
{ 
    /** 
    * @var int 
    * 
    * @ORM\Column(name="id", type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

    /** 
    * @var string 
    * 
    * @ORM\Column(name="name", type="string", length=150, nullable=true) 
    */ 
    private $name; 
    /** 
    * @Gedmo\Slug(fields={"title", "name"}) 
    * @ORM\Column(length=128, unique=true) 
    */ 
    private $slug; 
    /** 
    * @var string 
    * 
    * @ORM\Column(name="city", type="string", length=150, nullable=true) 
    */ 
    private $city; 

    /** 
    * @var string 
    * 
    * @ORM\Column(name="voivodeship", type="string", length=50, nullable=true) 
    */ 
    private $voivodeship; 

    /** 
    * @var string 
    * 
    * @ORM\Column(name="description", type="text", nullable=true) 
    */ 
    private $description; 

    /** 
    * @var string 
    * 
    * @ORM\Column(name="category", type="string", length=100, nullable=true) 
    */ 
    private $category; 


    /** 
    * 
    * @ORM\OneToOne(targetEntity="User", cascade={"persist"}) 
    * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true) 
    */ 
    protected $user; 
    /** 
    * Get id 
    * 
    * @return int 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 

    /** 
    * Set name 
    * 
    * @param string $name 
    * 
    * @return Profile 
    */ 
    public function setName($name) 
    { 
     $this->name = $name; 

     return $this; 
    } 

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

    /** 
    * Set city 
    * 
    * @param string $city 
    * 
    * @return Profile 
    */ 
    public function setCity($city) 
    { 
     $this->city = $city; 

     return $this; 
    } 

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

    /** 
    * Set voivodeship 
    * 
    * @param string $voivodeship 
    * 
    * @return Profile 
    */ 
    public function setVoivodeship($voivodeship) 
    { 
     $this->voivodeship = $voivodeship; 

     return $this; 
    } 

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

    /** 
    * Set description 
    * 
    * @param string $description 
    * 
    * @return Profile 
    */ 
    public function setDescription($description) 
    { 
     $this->description = $description; 

     return $this; 
    } 

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

    /** 
    * Set category 
    * 
    * @param string $category 
    * 
    * @return Profile 
    */ 
    public function setCategory($category) 
    { 
     $this->category = $category; 

     return $this; 
    } 

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

    /** 
    * Set user 
    * 
    * @param \AppBundle\Entity\User $user 
    * 
    * @return Profile 
    */ 
    public function setUser(\AppBundle\Entity\User $user = null) 
    { 
     $this->user = $user; 

     return $this; 
    } 

    /** 
    * Get user 
    * 
    * @return \AppBundle\Entity\User 
    */ 
    public function getUser() 
    { 
     return $this->user; 
    } 
    /** 
    * Get slug 
    * 
    * @return string 
    */ 
    public function getSlug() 
    { 
     return $this->slug; 
    } 
} 

现在现场没有产生。装修一新的数据库,并没有任何帮助

回答

1

我已经修改侦听器定义来自阿尔萨斯的答案,它的工作现在。

# app/config/config.yml 
stof_doctrine_extensions: 
default_locale: en 
orm: 
    default: 
     tree: false 
     timestampable: false 
     sluggable: true 
     translatable: false 
1

你只需要激活sluggable听众:

# app/config/config.yml 
stof_doctrine_extensions: 
    class: 
     sluggable:  ~ 

并创建蛞蝓属性:

<?php 
namespace Entity; 

use Gedmo\Mapping\Annotation as Gedmo; 
use Doctrine\ORM\Mapping as ORM; 

/** 
* @ORM\Table(name="articles") 
* @ORM\Entity 
*/ 
class Entity 
{ 
    ... 

    /** 
    * @Gedmo\Slug(fields={"username"}) 
    * @ORM\Column(length=128, unique=true) 
    */ 
    private $slug; 

    ... 
} 
+0

添加监听器后没有任何改变。我完成了我的文件的问题 –

+0

你只需要我写的东西。请删除映射中的每个侦听器... – Alsatian

+0

并且不要忘记删除所有不想使用的错误配置(常规4)创建的SQL表。 – Alsatian