jmunozco
jmunozco

Reputation: 695

Attempted to load class "Doctrine_Core"

I'm trying to follow these steps: http://docs.doctrine-project.org/projects/doctrine1/en/latest/en/manual/hierarchical-data.html

Please, correct me if I am wrong. Firstly, I've created this class in AppBundle/Model route:

namespace AppBundle\Model;


class Item extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->hasColumn('name', 'string', 255);
    }

    public function setUp()
    {
        $this->actAs('NestedSet');
    }
}

And then I use it in a controller like this:

$treeObject = Doctrine_Core::getTable('Category')->getTree();

I have two questions: - Where do I have to define the Category table and how - With this previous code I ran into this error: Attempted to load class "Doctrine_Core" from namespace "AppBundle\Controller\Admin

Any idea please? Thanks

Upvotes: 0

Views: 917

Answers (3)

mmmm
mmmm

Reputation: 3938

Doctrine has it's bundle for Symfony, that allows to store all config data in YML. https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html - it has "Tree extension" and it is exactly what you're looking for.

Upvotes: 1

jmunozco
jmunozco

Reputation: 695

Ok, I followed these steps:

  1. Install this: http://symfony.com/doc/master/bundles/StofDoctrineExtensionsBundle/index.html
  2. Don't forget to set up the configuration for the extensions, in this case for tree like this in config.yml:

    stof_doctrine_extensions:
      orm:
        default:
           tree: true
    

Upvotes: 0

Tomasz Madeyski
Tomasz Madeyski

Reputation: 10890

Classes Doctrine_Record and Doctrine_Core are part of Doctrine in 1.x version, Symfony2 is using Doctrine 2.x which is completely different than 1.x version. For example Doctrine 2.x does not use Active Record approach and this is what you are trying to use. In Doctrine 2 Model classes (Entities) don't extend any class

Check this piece of doc how to use Doctrine2 in Symfony2

Upvotes: 1

Related Questions