symfony-cmf/block-bundle

No identifier/path specified for Document

oste opened this issue · 7 comments

oste commented

I recently updated to symfony-cmf/BlockBundle 1.0.0-RC1 as the follow composer output shows
- Updating symfony-cmf/block-bundle (1.0.0-beta3 => 1.0.0-RC1)

When I did this I started getting the following fatal error:
FatalErrorException: Error: Class 'Symfony\Cmf\Bundle\BlockBundle\Document\ContainerBlock' not found in src/App/Document/CustomBlock.php

I thought that this would resolve if I swapped in the following ContainerBlock class
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ContainerBlock;

however I am now getting the following error
No identifier/path specified for Document "App\Document\CustomBlock" sub class of "Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ContainerBlock". Every Document must have an identifier/path.

Hoping someone can help steer me in the right direction, how can I add the identifier/path? Or am I going down the wrong path? Thanks

can you pastebin the mapping for your CustomBlock?

dbu commented

That is the correct class. did you enable persistence.phpcr: true in the block or core config?

----- Reply message -----
Von: "Mike Osterhout" notifications@github.com
An: "symfony-cmf/BlockBundle" BlockBundle@noreply.github.com
Betreff: [BlockBundle] No identifier/path specified for Document (#128)
Datum: Do., Aug. 29, 2013 06:25
I recently updated to symfony-cmf/BlockBundle 1.0.0-RC1 as the follow composer output shows

  • Updating symfony-cmf/block-bundle (1.0.0-beta3 => 1.0.0-RC1)

When I did this I started getting the following fatal error:
FatalErrorException: Error: Class 'Symfony\Cmf\Bundle\BlockBundle\Document\ContainerBlock' not found in src/App/Document/CustomBlock.php

I thought that this would resolve if I swapped in the following ContainerBlock class
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ContainerBlock;

however I am now getting the following error
No identifier/path specified for Document "App\Document\CustomBlock" sub class of "Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ContainerBlock". Every Document must have an identifier/path.

Hoping someone can help steer me in the right direction, how can I add the identifier/path? Or am I going down the wrong path? Thanks


Reply to this email directly or view it on GitHub.

oste commented

@dbu no I don't believe I have that set up. Looking at the Sandbox it looks like I might just need this

cmf_core:
    persistence:
        phpcr:
            enabled: true

@lsmith77 my custom block is a combination of a container block and a reference block. Looks like this - I was actually thinking that this could be part of the BlockBundle - but maybe it is not a common need to have a container block that can reference...

namespace App\Document;

use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ContainerBlock as ParentBlock;

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

/**
 * Block that is a reference to another block and acts like ContainerBlock
 *
 * @PHPCRODM\Document(referenceable=true)
 */
class ReferenceContainerBlock extends ParentBlock
{
    /** @PHPCRODM\ReferenceOne */
    private $referencedBlock;

    /** @PHPCRODM\String */
    protected $content;

    public function getType()
    {
        return 'cmf.block.reference';
    }

    public function getReferencedBlock()
    {
        return $this->referencedBlock;
    }

    public function setReferencedBlock($referencedBlock)
    {
        return $this->referencedBlock = $referencedBlock;
    }

is it now working after you enabled phpcr persistence?

oste commented

Yep, all systems appear to be go. Had to flush my db and update some mappings for createphp as well.

Thanks guys

dbu commented

great. don't hesitate to propose improvements to the doc if you see a place where the config should have been explained.

regarding your model: a ContainerBlock can contain ReferenceBlock s - not sure what exactly you needed here.

oste commented

Sounds great @dbu . I will take a look. Documentation is always important. Thankfully the sandbox is kind of self documenting, just takes a little longer ;)