本文整理汇总了PHP中Table::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::factory方法的具体用法?PHP Table::factory怎么用?PHP Table::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEmailOnNewIsTrueWhenPreferenceSet
public function testEmailOnNewIsTrueWhenPreferenceSet()
{
$comment = Table::factory('Comments')->read(3);
$this->assertTrue($comment->emailOnNew());
$comment = Table::factory('Comments')->read(4);
$this->assertTrue($comment->emailOnNew());
}
示例2: index
public function index()
{
if ($this->request->isGet()) {
$this->assign("columns", Table::factory('Contacts')->getColumns());
}
if ($this->request->isPost()) {
$contact = Table::factory('Contacts')->newObject();
if ($contact->setValues($this->request->getPost())) {
// all good. add, and stuff
$contact->save();
$address = Settings::getValue("contact.address");
$subject = "Enquiry via paynedigital.com";
$from = $contact->name . " <" . $contact->email . ">";
$email = Email::factory();
$email->setFrom($from);
$email->setTo($address);
$email->setSubject($subject);
$email->setBody($this->fetchTemplate("emails/contact", array("query" => $contact->content, "name" => $contact->name)));
$email->send();
if (!$this->request->isAjax()) {
$this->setFlash("contact_thanks");
return $this->redirectAction("thanks");
}
} else {
$this->setErrors($contact->getErrors());
}
}
}
示例3: index
public function index()
{
$articles = Table::factory('Posts')->findRecent(10);
$this->assign('articles', $articles);
$this->response->addHeader('Content-Type', 'text/xml; charset=utf-8');
return $this->render("index");
}
示例4: setUp
public function setUp()
{
parent::setUp();
Utils::reset();
Utils::setCurrentDate("2011-09-19 00:00:00");
$this->table = Table::factory("Posts");
}
示例5: generateUniqueIdentifier
public function generateUniqueIdentifier()
{
do {
$identifier = $this->generateIdentifier();
} while (Table::factory("Previews")->findByIdentifier($identifier) !== false);
return $identifier;
}
示例6: do_redirect
public function do_redirect()
{
$link = Table::factory('Shortlinks')->findByUrl($this->getMatch('url'));
if ($link == null) {
throw new CoreException('Redirect URL not found', CoreException::PATH_REJECTED);
}
return $this->redirect($link->redirect_url);
}
示例7: index
public function index()
{
$posts = Table::factory('Posts')->findAllForTagOrTitle($this->request->getVar('q'));
$query = $this->request->getVar('q');
if ($query !== null && trim($query) != "") {
$this->assign('search_query', $this->request->getVar('q'));
}
$this->assign('posts', $posts);
}
示例8: getRelatedPosts
public function getRelatedPosts()
{
return Table::factory('RelatedPosts')->findAll(array("post_id" => $this->getId()));
}
示例9: content
/**
* Get pages contents
*
* @return string
*/
public static function content($slug = '')
{
if (!empty($slug)) {
$page = Table::factory('pages')->select('[slug="' . $slug . '"]', null);
if (!empty($page)) {
$content = Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . $page['id'] . '.page.txt'));
$content = Filter::apply('content', $content);
return $content;
} else {
return '';
}
} else {
return Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . Pages::$page['id'] . '.page.txt'));
}
}
示例10: delete_related_post
public function delete_related_post()
{
$related = Table::factory('RelatedPosts')->read($this->getMatch('related_post_id'));
if ($related == false || $related->post_id != $this->post->getId()) {
return $this->redirectAction("index", "You cannot perform this action");
}
$related->delete();
return $this->redirectAction("index", "Relation Deleted");
}
示例11: getAllPosts
/**
* NB this INCLUDES posts which have been deleted or not yet published
*/
public function getAllPosts()
{
return Table::factory('Posts')->findAll(array("user_id" => $this->getId()));
}
示例12: assignArchive
protected function assignArchive()
{
$archive = Table::factory('Posts')->findMonthsWithPublishedPosts();
$this->assign('archive', $archive);
}
示例13: testGetTweetUrlWithRecentArticle
public function testGetTweetUrlWithRecentArticle()
{
$post = Table::factory('Posts')->newObject();
$post->setValues(array("published" => "01/03/2013 00:00:00", "url" => "test-article"));
$this->assertEquals("articles/2013/03/test-article", $post->getTweetUrl());
}
示例14: setUp
public function setUp()
{
parent::setUp();
$this->table = Table::factory("Users");
}
示例15: testScriptBlockAddsContentWhenProvided
public function testScriptBlockAddsContentWhenProvided()
{
$this->request->dispatch("/articles/2011/09/this-is-a-test-post");
$this->assertBodyHasContents("<script type=\"text/javascript\" src=\"/foo/bar.js\"></script>", Table::factory('Posts')->read(3)->script_block);
}