csDoctrineActAsCategorizablePlugin - 1.0.0

A plugin that adds categories to your model

You are currently browsing
the website for symfony 1

Visit the Symfony2 website

« Back to the Plugins Home


Forgot your password?
Create an account



advanced search
Information Readme Releases Changelog Contribute
Show source



This behavior permits to assign categories to doctrine models


  • add a category to an object
  • allows for Nested categories using the Doctrine Nested Set Behavior

  • Overview Because multiple unrelated objects can be categorized in a single project, by default this plugin separates each individual model assigned this behavior into its own Category set. This can be customized (see below)

  • Other Options:

You can set the root name of your category (default is the name of the model appended with '_Root') This is useful when you want two models to have identical directory structures

        Categorizable:      {   root:   Gallery_Root }
            Categorizable:  {   root:   Gallery_Root }

The above models will now pull from the same set of categories

You can change the local ID to another name (default is category_id)

        category_id:        my_id 

Use the following functions when manipulating your category objects:

Table Methods

//Saves the category specified to the appropriate category tree             
//Removes the category safely from the category tree.

Object Methods

//Saves the category specified to the appropriate category tree and assigns it to your object
//assigns the specified category to your object

Category Methods

//returns the assigned parent category (excluding the category tree root)
//returns a collection of sub categories for the category
//sets the $child category as a direct descendent of $category
//sets the $category category as a direct descendent of $parent

Category Table Methods

//returns a Category object with the specified name

*variable is mixed, can either be string or Category types

Philosophy of the stuff

  • categorizable models must have a primary key
  • categories are saved when the object is saved

Get it installed

  • go to your project's root
  • Install the plugin:

    actAs: [Categorizable] to model you want to be categorized

  • rebuild the model:

    ./symfony doctrine-build-all

  • clear cache:

    ./symfony cc