eZPersistentObject - foreign_class

Author Message

Thiago Campos Viana

Wednesday 09 February 2011 6:15:22 am

Hello

I'm just wondering what this attribute does. I opened the ezcontentclass.php file and there's a block:

'initial_language_id' => array( 'name' => "InitialLanguageID",
'datatype' => 'integer',
'default' => 0,
'required' => true,
'foreign_class' => 'eZContentLanguage',
'foreign_attribute' => 'id',
'multiplicity' => '1..*' ),

Then I opened kernel_schema.sql and there's no foreign key specification there, so I supposed that the control of foreign key attribute values is done by eZPersistentObject class and not by the database.

So I created two database tables, without specifying foreign keys attributes, and two classes that extends eZPersistentObject, just to test if the code would give me an error when I tried to store a object that has a value wich I specified defining 'foreign_class' attribute, and code just works, it stores a new table row even if the referenced eZPersistentObject class has no objects with the key I specified for the new object.

So what 'foreign_class' does?

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br

Gaetano Giunta

Wednesday 09 February 2011 12:47:15 pm

So that in the future we can take advantage of it ;-)

Principal Consultant International Business
Member of the Community Project Board

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.