本文整理匯總了PHP中app\Item::getId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::getId方法的具體用法?PHP Item::getId怎麽用?PHP Item::getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Item
的用法示例。
在下文中一共展示了Item::getId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: files
/**
* @testdox An item can have a single file attached.
* @test
*/
public function files()
{
$item = new Item(null, $this->testUser);
// First version.
$item->save([], null, null, 'Test file contents.');
$this->assertSame(1, $item->getId());
$this->assertSame('c4/ca/1/v1', $item->getFilePath());
$this->assertFileExists(__DIR__ . '/data/storage/c4/ca/1/v1');
$this->assertSame('Test file contents.', $item->getFileContents());
$this->assertSame(1, $item->getVersionCount());
// Second version.
$item->save(['id' => 1], null, null, 'New file contents.');
$this->assertSame(1, $item->getId());
$this->assertSame(2, $item->getVersionCount());
$this->assertSame('c4/ca/1/v2', $item->getFilePath());
$this->assertFileExists(__DIR__ . '/data/storage/c4/ca/1/v1');
$this->assertFileExists(__DIR__ . '/data/storage/c4/ca/1/v2');
$this->assertSame('New file contents.', $item->getFileContents());
$this->assertSame('Test file contents.', $item->getFileContents(1));
// Upload a different file.
$item2 = new Item(null, $this->testUser);
$item2->save(['title' => 'Second test'], null, null, 'Second test.');
$this->assertSame(2, $item2->getId());
$this->assertSame('c8/1e/2/v1', $item2->getFilePath());
$this->assertTrue($item2->isText());
}
示例2: save
public function save(Request $request, Response $response, array $args)
{
$_POST = array_filter($_POST, 'trim');
$metadata = array('id' => filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT), 'title' => filter_input(INPUT_POST, 'title'), 'description' => filter_input(INPUT_POST, 'description'), 'date' => filter_input(INPUT_POST, 'date'), 'date_granularity' => filter_input(INPUT_POST, 'date_granularity', FILTER_SANITIZE_NUMBER_INT), 'edit_group' => filter_input(INPUT_POST, 'edit_group', FILTER_SANITIZE_NUMBER_INT), 'read_group' => filter_input(INPUT_POST, 'read_group', FILTER_SANITIZE_NUMBER_INT));
$tags = filter_input(INPUT_POST, 'tags');
$item = new Item(null, $this->user);
$item->save($metadata, $tags, $_FILES['file']['tmp_name'], filter_input(INPUT_POST, 'file_contents'));
$config = new Config();
return new RedirectResponse($config->baseUrl() . '/' . $item->getId());
}