示例#1
0
文件: Handler.php 项目: visapi/amun
 public function update(RecordInterface $record)
 {
     if ($record->hasFields('id')) {
         if (isset($record->url)) {
             // request host meta
             $template = $this->getLrddTemplate($record->getUrl());
             $record->template = (string) $template;
         }
         $con = new Condition(array('id', '=', $record->id));
         $this->table->update($record->getData(), $con);
         $this->notify(RecordAbstract::UPDATE, $record);
         return $record;
     } else {
         throw new Exception('Missing field in record');
     }
 }
示例#2
0
文件: Entity.php 项目: uqiauto/fusio
 /**
  * Returns the PUT response
  *
  * @param \PSX\Data\RecordInterface $record
  * @param \PSX\Api\Version $version
  * @return array|\PSX\Data\RecordInterface
  */
 protected function doUpdate(RecordInterface $record, Version $version)
 {
     $appId = (int) $this->getUriFragment('app_id');
     $app = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\App')->get($appId);
     if (!empty($app)) {
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\App')->update(array('id' => $app->getId(), 'status' => $record->getStatus(), 'name' => $record->getName(), 'url' => $record->getUrl()));
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\App\\Scope')->deleteAllFromApp($appId);
         $scopes = $record->getScopes();
         if (!empty($scopes) && is_array($scopes)) {
             $this->insertScopes($appId, $scopes);
         }
         return array('success' => true, 'message' => 'App successful updated');
     } else {
         throw new StatusCode\NotFoundException('Could not find app');
     }
 }
示例#3
0
 protected function assertRecord(RecordInterface $record)
 {
     // check available fields
     $this->assertTrue($record->getRecordInfo()->hasField('id'));
     $this->assertTrue($record->getRecordInfo()->hasField('title'));
     $this->assertTrue($record->getRecordInfo()->hasField('active'));
     $this->assertTrue($record->getRecordInfo()->hasField('disabled'));
     $this->assertTrue($record->getRecordInfo()->hasField('count'));
     $this->assertTrue($record->getRecordInfo()->hasField('rating'));
     $this->assertFalse($record->getRecordInfo()->hasField('foobar'));
     $this->assertFalse($record->getRecordInfo()->hasField('foo'));
     if ($this->canDetermineType()) {
         $this->assertEquals(1, $record->getId());
         $this->assertEquals('foobar', $record->getTitle());
         $this->assertTrue($record->getActive());
         $this->assertFalse($record->getDisabled());
         $this->assertEquals(12, $record->getCount());
         $this->assertEquals(12.45, $record->getRating());
         $this->assertInternalType('integer', $record->getId());
         $this->assertInternalType('string', $record->getTitle());
         $this->assertInternalType('boolean', $record->getActive());
         $this->assertInternalType('boolean', $record->getDisabled());
         $this->assertInternalType('integer', $record->getCount());
         $this->assertInternalType('float', $record->getRating());
         $this->assertInstanceOf('DateTime', $record->getDate());
     } else {
         $this->assertEquals('1', $record->getId());
         $this->assertEquals('foobar', $record->getTitle());
         // the json reader returns the real php type the xml reader returns
         // the string true or false
         $this->assertTrue($record->getActive() === true || $record->getActive() === 'true');
         $this->assertTrue($record->getDisabled() === false || $record->getDisabled() === 'false');
         $this->assertEquals('12', $record->getCount());
         $this->assertEquals('12.45', $record->getRating());
         $this->assertEquals('2014-01-01T12:34:47+01:00', $record->getDate());
     }
     if ($this->canImportComplexRecord()) {
         $this->assertInstanceOf('PSX\\Data\\Record\\Importer\\Test\\Person', $record->getPerson());
         $this->assertEquals('Foo', $record->getPerson()->getTitle());
         $this->assertEquals(true, is_array($record->getTags()));
         $this->assertEquals(3, count($record->getTags()));
         $this->assertEquals('bar', $record->getTags()[0]);
         $this->assertEquals('foo', $record->getTags()[1]);
         $this->assertEquals('test', $record->getTags()[2]);
         $this->assertEquals(true, is_array($record->getEntry()));
         $this->assertEquals(3, count($record->getEntry()));
         $this->assertEquals('bar', $record->getEntry()[0]->getTitle());
         $this->assertEquals('foo', $record->getEntry()[1]->getTitle());
         $this->assertEquals('test', $record->getEntry()[2]->getTitle());
         foreach ($record->getEntry() as $entry) {
             $this->assertInstanceOf('PSX\\Data\\Record\\Importer\\Test\\Entry', $entry);
         }
         $this->assertInstanceOf('stdClass', $record->getToken());
         $this->assertEquals('bar', $record->getToken()->value);
         $this->assertInstanceOf('PSX\\Url', $record->getUrl());
         $this->assertEquals('http://google.com', $record->getUrl()->__toString());
     }
 }
示例#4
0
 /**
  * Returns the POST response
  *
  * @param \PSX\Data\RecordInterface $record
  * @param \PSX\Api\Version $version
  * @return array|\PSX\Data\RecordInterface
  */
 protected function doCreate(RecordInterface $record, Version $version)
 {
     $appKey = TokenGenerator::generateAppKey();
     $appSecret = TokenGenerator::generateAppSecret();
     $table = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\App');
     $table->create(array('userId' => $record->getUserId(), 'status' => $record->getStatus(), 'name' => $record->getName(), 'url' => $record->getUrl(), 'appKey' => $appKey, 'appSecret' => $appSecret, 'date' => new DateTime()));
     $appId = $table->getLastInsertId();
     // insert scopes to the app which are assigned to the user
     $this->insertDefaultScopes($appId, $record->getUserId());
     return array('success' => true, 'message' => 'App successful created');
 }