Beispiel #1
0
 public function setUp()
 {
     $this->client = new TestClient();
     $manager = new Manager($this->client);
     $manager->registerEntity('Doctrine\\Tests\\REST\\ClientArticleTest');
     $manager->registerEntity('Doctrine\\Tests\\REST\\Status');
     Entity::setManager($manager);
 }
Beispiel #2
0
 public function setUpRest($type)
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir('/tmp');
     $config->setProxyNamespace('Proxies');
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
     $connectionOptions = array('driver' => 'pdo_sqlite', 'memory' => true);
     $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
     $classes = array($em->getMetadataFactory()->getMetadataFor('Doctrine\\Tests\\REST\\DoctrineUser'));
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $schemaTool->dropSchema($classes);
     $schemaTool->createSchema($classes);
     if ($type === 'orm') {
         $this->_client = new TestFunctionalClient('user', $em);
     } else {
         $this->_client = new TestFunctionalClient('user', $em->getConnection());
     }
     $this->_manager = new Manager($this->_client);
     $this->_manager->registerEntity('Doctrine\\Tests\\REST\\User');
     Entity::setManager($this->_manager);
 }
Beispiel #3
0
<?php

require '/Users/jwage/Sites/doctrine2git/lib/Doctrine/Common/ClassLoader.php';
use Doctrine\REST\Client\Client, Doctrine\REST\Client\EntityConfiguration, Doctrine\REST\Client\Manager, Doctrine\REST\Client\Entity, Doctrine\Common\ClassLoader;
$classLoader = new ClassLoader('Doctrine\\REST', __DIR__ . '/lib');
$classLoader->register();
$client = new Client();
$manager = new Manager($client);
$manager->registerEntity('User');
Entity::setManager($manager);
class User extends Entity
{
    public $id;
    public $username;
    public $password;
    public static function configure(EntityConfiguration $entityConfiguration)
    {
        $entityConfiguration->setUrl('http://localhost/rest/server.php');
        $entityConfiguration->setName('user');
    }
}
$user = User::find(9);
$user->username = '******';
$user->password = '******';
$user->save();
print_r($user);