10.04.2018 Views

Doctrine_manual-1-2-en

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 12: YAML Schema Files 202<br />

type: string(255)<br />

actAs:<br />

Timestampable:<br />

Sluggable:<br />

fields: [username]<br />

name: slug # defaults to 'slug'<br />

type: string # defaults to 'clob'<br />

l<strong>en</strong>gth: 255 # defaults to null. clob doesn't require a l<strong>en</strong>gth<br />

The options specified on the Sluggable behavior above are optional as they will use defaults<br />

values if you do not specify anything. Since they are defaults it is not necessary to type it<br />

out all the time.<br />

Listing<br />

12-14<br />

---<br />

User:<br />

connection: connection1<br />

columns:<br />

# ...<br />

actAs: [Timestampable, Sluggable]<br />

Listing<br />

12-15<br />

Listing<br />

12-16<br />

List<strong>en</strong>ers<br />

If you have a list<strong>en</strong>er you'd like attached to a model, you can specify them directly in the yml<br />

as well.<br />

---<br />

User:<br />

list<strong>en</strong>ers: [ MyCustomList<strong>en</strong>er ]<br />

columns:<br />

id:<br />

type: integer(4)<br />

primary: true<br />

autoincrem<strong>en</strong>t: true<br />

contact_id:<br />

type: integer(4)<br />

username:<br />

type: string(255)<br />

password:<br />

type: string(255)<br />

The above syntax will g<strong>en</strong>erated a base class that looks something like the following:<br />

class BaseUser ext<strong>en</strong>ds <strong>Doctrine</strong>_Record<br />

{<br />

// ...<br />

}<br />

public setUp()<br />

{<br />

// ...<br />

$this->addList<strong>en</strong>er(new MyCustomList<strong>en</strong>er());<br />

}<br />

----------------- Brought to you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!