ezsystems/ezpublish — pull request #512 by jeromegamez (2012-11-25 16:06:46+00:00)
Title: Set default values in eZPersistentObject for attributes

When creating a custom class extending {{eZPersistentObject}} it is not possible to initialize an object with default values.

Example code:
```php
class eZPersistentObjectTest extends eZPersistentObject
{
static public function definition()
{
static $definition = array(
"fields" => array(
"test" => array(
"name" => "test",
"datatype" => "string",
"default" => "test",
"required" => false,
),
),
"class_name" => "eZPersistentObjectTest",
);

return $definition;
}
}

$test = new eZPersistentObjectTest( false );
var_dump( $test->attribute( "test" ) );
```

This will create the error

```php
Notice: Undefined property: eZPersistentObjectTest::$test in ezpersistentobject.php on line 1298}}
```

and return `NULL`.

This patch enables `eZPersistentObject` to be initialized with default values.

Corresponding JIRA issue: https://jira.ez.no/browse/EZP-20161