Sylius: Extend cmf page model

Created on 20 Jun 2016  路  2Comments  路  Source: Sylius/Sylius

hi

how to extend the model for cmf page ?

I would like to add some properties on it, and don't find how to do it.

i try like this:

<?php

namespace St\AppBundle\Document;

use Symfony\Cmf\Bundle\ContentBundle\Model\StaticContentBase as CmfBaseStaticContent;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;

/**
 * @PHPCR\Document()
 */
class StaticContent extends CmfBaseStaticContent
{

    /**
     * @var
     */
    protected $toto;

    /**
     * @return mixed
     */
    public function getToto()
    {
        return $this->toto;
    }

    /**
     * @param mixed $toto
     */
    public function setToto($toto)
    {
        $this->toto = $toto;
    }


    /**
     * @PHPCR\Id()
     */
    protected $id;

    /**
     * @PHPCR\ParentDocument()
     */
    protected $parent;
}

but i got this error: Property 'id' in 'St\AppBundle\Document\StaticContent' is declared twice.

Help Wanted

Most helpful comment

All 2 comments

found it !

just do like this

<?php

namespace St\AppBundle\Document;

use Sylius\Bundle\ContentBundle\Document\StaticContent as BaseStaticContent;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;

/**
 * @PHPCR\Document()
 */
class StaticContent extends BaseStaticContent
{

    /**
     * @PHPCR\String()
     */
    protected $metaTitle;

    /**
     * @return mixed
     */
    public function getMetaTitle()
    {
        return $this->metaTitle;
    }

    /**
     * @param mixed $metaTitle
     */
    public function setMetaTitle($metaTitle)
    {
        $this->metaTitle = $metaTitle;
    }
}
sylius_content:
    driver: doctrine/phpcr-odm
    resources:
        static_content:
            classes:
                repository: Sylius\Bundle\ContentBundle\Doctrine\ODM\PHPCR\StaticContentRepository
                model: St\AppBundle\Document\StaticContent
                form:
                    default: St\AppBundle\Form\Type\StaticContentType
                    choice: Sylius\Bundle\ContentBundle\Form\Type\StaticContentChoiceType

cmf_content:
    persistence:
        phpcr:
            content_basepath: /cms/pages
            document_class: St\AppBundle\Document\StaticContent
    default_template: "SyliusWebBundle:Frontend/StaticContent:show.html.twig"

and add it to the vue and don't forget the rdf-mappings

change your old properties in the DB if needed, if not, you can't see your pages

That's all !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xleliberty picture xleliberty  路  3Comments

inssein picture inssein  路  3Comments

stefandoorn picture stefandoorn  路  3Comments

inssein picture inssein  路  3Comments

reyostallenberg picture reyostallenberg  路  3Comments