Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Persistent Manager avec prise en charge de XML
<?php
class ezcPersistentXmlManager extends ezcPersistentDefinitionManager
{
private $file;
public function __construct( $file )
{
if( file_exists($file) )
$this->file = $file;
}
public function fetchDefinition( $class )
{
$dom = new DOMDocument();
$dom->load( $this->file );
$xpath = new DOMXpath($dom);
$elements = $xpath->query("//definition[@class_name='$class']");
$def = new ezcPersistentObjectDefinition();
$def->table = "comptes";
$def->class = $class;
$def->idProperty = new ezcPersistentObjectIdProperty;
$def->idProperty->columnName = 'code';
$def->idProperty->propertyName = 'code';
$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentSequenceGenerator' );
$definition = null;
$path = $this->dir . strtolower( $class ) . '.php';
if ( file_exists( $path ) )
{
$definition = require $path;
}
if ( !( $definition instanceof ezcPersistentObjectDefinition ) )
{
throw new ezcPersistentDefinitionNotFoundException( $class,
"Searched for '" . realpath( dirname( $path ) ) . "/" . basename( $path ) . "'." );
}
if ( $definition->idProperty === null )
{
throw new ezcPersistentDefinitionMissingIdPropertyException( $class );
}
$definition = $this->setupReversePropertyDefinition( $definition );
return $definition;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment