Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@charlycoste
Created March 10, 2014 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charlycoste/9469809 to your computer and use it in GitHub Desktop.
Save charlycoste/9469809 to your computer and use it in GitHub Desktop.
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