Wednesday 29 July 2009 11:33:09 am - 11 replies
Most Content Management System requirements can be fulfilled by eZ Publish without any custom PHP coding. But sooner or later experienced eZ Publish implementers get to the point where a project needs some special functionality and it becomes necessary to develop extensions.
(This tutorial was initially published on 21/01/2008, and refreshed to match the 4.x series on 10/12/2010)
Thursday 31 December 2009 9:11:29 pm
The code on page 8 which reads:
-----------------------------------------------
class JACExtensionData extends eZPersistentObject
{
/*!
Konstruktor
*/
function JACExtensionData( $row )
{
$this->eZPersistentObject( $row );
}
/*!
Definition of the data object structure /of the structure of the database table
*/
function definition()
---------------------------------------------
In eZ Publish 4.x should be:
-------------------------------------------
class JACExtensionData extends eZPersistentObject
{
/*!
Konstruktor
*/
function JACExtensionData( $row )
{
$this->eZPersistentObject( $row );
}
/*!
Definition of the data object structure /of the structure of the database table
*/
static function definition()
------------------------------------------------
Then it works!
Friday 22 October 2010 1:15:37 pm
For an extension that adds one or more tables to the db, it is important to create a share/db_schema.dba file where these new tables are described.
This way when the admin goes to the "Setup/Upgrade Check/Check db consistency" page
- he will note get a suggestion to drop the table
- he will get a suggestion with the sql command to create the table if the table does not exist
This is true since eZP 4.3
The format for db_schema.dba is propietary to eZ. You can find examples in ezfind, ezflow and other extensions from eZ Systems
To generate that file you can use the ezsqldumpschema.php script. Take care: right now it will create a file with the definition of the whole db, so you should either use it in a db where you only have your new table(s) or clean up by hand the generated .dba file
Modified on Friday 22 October 2010 1:16:35 pm by Gaetano Giunta
Wednesday 15 December 2010 9:26:48 pm
To really be a mirror for best practice, then code examples should add phpdoc and use php5 features like __construct and so on, eg:
/** * JACExtensionData does.... */ class JACExtensionData extends eZPersistentObject { /** * Constructor * * @param array $row Hash of attributes for new <span class="Apple-style-span" style="font-size: 13px; " mce_fixed="1">JACExtensionData</span> <span class="Apple-style-span" style="font-size: 13px; " mce_fixed="1"><span>object</span></span> */ function __construct( $row ) { parent::__construct( $row ); } /** * Definition of the data object structure /of the structure of the database table * * @return array Hashed array with table definition of this p<span class="Apple-style-span" style="font-size: 13px; " mce_fixed="1">ersistent object</span> */ static function definition()
Additionally, member variables should probably be protected/private to make sure attribute() function is used outside the class.
Modified on Wednesday 15 December 2010 9:30:56 pm by André R.
Friday 01 July 2011 5:41:36 pm
I thought best practice was to put operators in a separate /operators folder. Is that not the case anymore? Or am I simply mistaken?
Template operators ? Placing them in the 'autoloads' directory, at the root of the given extension directory, is the usual practice.
Cheers,
You must be logged in to post messages in this topic!