本文整理汇总了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());
}