Skip to content

Instantly share code, notes, and snippets.

@dpobel
Created December 23, 2011 12:47
Show Gist options
  • Select an option

  • Save dpobel/1514107 to your computer and use it in GitHub Desktop.

Select an option

Save dpobel/1514107 to your computer and use it in GitHub Desktop.
Test skeleton
<?php
// the API should be in extension/api
// change the login and the password of the databse below
require_once 'extension/api/bootstrap.php';
try
{
$handler = new \ezp\Persistence\Storage\Legacy\Handler( array( 'dsn' => 'mysql://muser:mpasswd@localhost/mdatabase' ) );
$converter = $handler->getFieldValueConverterRegistry();
// converters need to be manually registered
// add the converter(s) needed for the fields you want to use
$converter->register( 'ezstring', new \ezp\Persistence\Storage\Legacy\Content\FieldValue\Converter\TextLine() );
$converter->register( 'ezxmltext', new \ezp\Persistence\Storage\Legacy\Content\FieldValue\Converter\XmlText() );
$converter->register( 'ezboolean', new \ezp\Persistence\Storage\Legacy\Content\FieldValue\Converter\Checkbox() );
$sc = new ezp\Base\ServiceContainer( \ezp\Base\Configuration::getInstance( 'service' )->getAll(), array( '@persistence_handler' => $handler ) );
$repository = $sc->getRepository();
$userService = $repository->getUserService();
$repository->setUser( $userService->load( 14 ) );
$contentService = $repository->getContentService();
$typeService = $repository->getContentTypeService();
$repository->beginTransaction();
// CODE GOES HERE
$repository->commit();
}
catch( Exception $e )
{
$cli->error( 'Exception: ' . get_class( $e ) );
$cli->error( $e->getMessage() );
$cli->error();
$cli->error( $e->getTraceAsString() );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment