I've been trying to get an existing project working on local copy but have been countering alot of problems with the ODM and the dependencies.
I'm encountering this Sluggable issue :
[Semantical Error] The annotation "@Gedmo\Mapping\Annotation\Sluggable" in property
Cereals\ProductBundle\Document\Category\Specialty::$name does not exist, or could not be
auto-loaded.
And my Cereals...\Specialty file is such:
<?php
namespace Cereals\ProductBundle\Document\Category;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @MongoDB\Document(collection="Specialty",
repositoryClass="Cereals\ProductBundle\Repository\SpecialtyRepository")
*/
class Specialty
{
/**
* @MongoDB\Id(strategy="auto")
*/
protected $id;
/**
* @Gedmo\Sluggable
* @MongoDB\Index(order="asc")
* @MongoDB\String
*/
protected $name;
/**
* @MongoDB\String
* @MongoDB\UniqueIndex
* @Gedmo\Slug
*/
protected $slug;
/**
* @MongoDB\String
*/
I understand from Googling that there are some syntax updates for doctrine 2.1.x and I've used the new annotations for the @Gedmo\Mapping\Annotation\Sluggable here too.
Still the Semantical Error turns up.
Can anyone point some directions ? Thanks !
The @Gedmo\Sluggable
annotation does not exisit. If you look in this folder, you will see this anottation is not implemented.
Actually, You can define your class like that:
<?php
namespace Cereals\ProductBundle\Document\Category;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @MongoDB\Document(collection="Specialty",
repositoryClass="Cereals\ProductBundle\Repository\SpecialtyRepository")
*/
class Specialty
{
/**
* @MongoDB\Id(strategy="auto")
*/
protected $id;
/**
* @MongoDB\Index(order="asc")
* @MongoDB\String
*/
protected $name;
/**
* @MongoDB\String
* @MongoDB\UniqueIndex
* @Gedmo\Slug(fields={"name"})
*/
protected $slug;
}
The @Gedmo\Slug
annotation needs the properties which will be used for the slug generation.