本文整理汇总了PHP中Article::setAuthor方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::setAuthor方法的具体用法?PHP Article::setAuthor怎么用?PHP Article::setAuthor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::setAuthor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadOne
protected function loadOne($file)
{
$xml = new SimpleXMLElement($file, 0, true);
if ((string) $xml->head->title == null) {
return null;
}
$article = new Article();
foreach ($xml->head->meta as $meta) {
$name = (string) $meta['name'];
$content = (string) $meta['content'];
switch ($name) {
case 'date':
$article->setPublicationDate(new DateTime($content));
break;
case 'author':
$article->setAuthor($content);
break;
}
}
$article->setTitle((string) $xml->head->title);
$article->setHash($this->getHash($article->getTitle()));
$content = "";
foreach ($xml->body->children() as $child) {
$content .= $child->asXml();
}
$article->setContent($content);
return $article;
}
示例2: article
function article(array $langs = array())
{
$article = new Article();
$article->setAuthor(author('henry'));
foreach ($langs as $lang) {
$article->Translation[$lang]->fromArray(array('title' => 'Title in ' . $lang, 'slug' => $lang . '-slug'));
}
return $article;
}
开发者ID:n1k0,项目名称:akDoctrineTemplateCacheInvaliderPlugin,代码行数:9,代码来源:akDoctrineCacheUriResolverTest.php
示例3: CamelCase
$t->is($article->getAuthor_id(), $article->author_id);
$t->is($article->getAuthorId(), $article->author_id);
$t->is($article->getauthorId(), $article->author_id);
$t->is($article->getAuthorID(), $article->author_id);
$t->is($article->getauthor_id(), $article->author_id);
// Camel case columns
$camelCase = new CamelCase();
$camelCase->testCamelCase = 'camel';
$camelCase->setTestCamelCase('camel');
$t->is($camelCase->getTestCamelCase(), 'camel');
$t->is($camelCase->gettestCamelCase(), 'camel');
$t->is($camelCase->gettestcamelcase(), 'camel');
$t->is($camelCase->gettest_camel_case(), 'camel');
$t->is($camelCase->getTest_camel_case(), 'camel');
// Propel style accessors work with relationships
$article->setAuthor($author);
$t->is($article->Author, $author);
$t->is($article->getAuthor(), $author);
// Camel case with relationships
$t->is($article->getCamelCase()->getTable()->getOption('name'), 'CamelCase');
// Test getDateTimeObject()
$dateTime = $article->getDateTimeObject('created_at');
$t->is($dateTime instanceof DateTime, true);
$t->is($dateTime->format('m/d/Y'), date('m/d/Y'));
try {
$article->getDateTimeObject('author_id');
$t->fail();
} catch (Exception $e) {
$t->pass();
}
$article->setDateTimeObject('created_at', new DateTime('1985-09-01'));
示例4: setArticleAuthorsLegacy
/**
* Set authors for an article, uses legacy classes
*
* @param Article $article
* @param \Newscoop\IngestPluginBundle\Entity\Entry $entry
*/
protected function setArticleAuthorsLegacy(\Article $article, \Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry)
{
$authors = $entry->getAuthors();
$order = 0;
if (count($authors) > 0) {
foreach ($authors as $author) {
$name = trim($author['firstname'] . ' ' . $author['lastname']);
$author = new \Author($name);
if (!$author->exists()) {
$author->create();
}
$article->setAuthor($author, $order++);
}
} else {
$name = $entry->getProduct() ?: $entry->getFeed()->getName();
$author = new \Author($name);
if (!$author->exists()) {
$author->create();
}
$article->setAuthor($author);
}
}
示例5: Author
if (isset($article->author) && !empty($article->author)) {
$authorName = (string) $article->author;
} else {
$authorName = (string) $g_user->getRealName();
$isAuthorFromCreator = TRUE;
}
$authorObj = new Author($authorName);
if (!$authorObj->exists()) {
$authorData = Author::ReadName($authorName);
if ($isAuthorFromCreator) {
$authorData['email'] = $g_user->getEmail();
}
$authorObj->create($authorData);
}
if ($authorObj->exists()) {
$articleObj->setAuthor($authorObj);
$articleFields['author'] = true;
}
// Updates the publish date
$articlePublishDate = (string) $article->publish_date;
$articleObj->setPublishDate($articlePublishDate);
// Updates the article
if (isset($article->keywords) && !empty($article->keywords)) {
$articleObj->setKeywords((string) $article->keywords);
}
$articleFields['keywords'] = true;
foreach ($xmlArticle as $articleFieldName => $articleFieldValue) {
if (!array_key_exists($articleFieldName, $articleFields)) {
$errorMessages[$articleCount][] = '"' . $articleFieldName . '" field in XML file ' . 'was not loaded into database as there is not any ' . 'article type field matching it.<br />';
}
}
示例6: serialize
$serialized = serialize($before);
$after = unserialize($serialized);
$t->is($after->title, 'test', '->unserialize() maintains field values on I18n records');
$conn = Doctrine_Manager::getInstance()->getConnectionForComponent('Article');
$before = new Article();
$before->title = 'test';
$serialized = serialize($before);
$conn->clear();
$conn->evictTables();
$after = unserialize($serialized);
$t->is($after->title, 'test', '->unserialize() maintains field values on I18n records upon reset');
$article = new Article();
try {
$article->setAuthor(new stdClass());
} catch (Exception $e) {
$t->is($e->getMessage(), 'Couldn\'t call Doctrine_Core::set(), second argument should be an instance of Doctrine_Record or Doctrine_Null when setting one-to-one references.', 'Making sure proper exception message is thrown');
}
$article = new Article();
$article->title = 'testing this out';
$serialized = serialize($article);
$article = unserialize($serialized);
$t->is($article->getTitle(), 'testing this out', 'Making sure getTitle() is still accessible after unserializing');
try {
$test = new ModelWithNumberInColumn();
$test->getColumn_1();
$test->getColumn_2();
示例7: setArticleAuthors
/**
* Set article authors
*
* @param Article $article
* @param Newscoop\Entity\Ingest\Feed\Entry $entry
* @return void
*/
private function setArticleAuthors(\Article $article, Entry $entry)
{
$name = $entry->getFeed()->getTitle();
$author = new \Author($name);
if (!$author->exists()) {
$author->create();
}
$article->setAuthor($author);
}
示例8: CategoryDao
<?php
include_once 'data/CategoryDAO.php';
include_once 'control/ArticleControls.php';
include_once 'business/Article.php';
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$categoryDao = new CategoryDao();
$articleController = new ArticleControls();
var_dump($_POST['category']);
$categoryId = $categoryDao->getIdForName($_POST['category']);
$article = new Article();
$article->setName($_POST['title']);
$article->setContent($_POST['editor']);
$article->setSumup($_POST['sumup_editor']);
$article->setCategory($categoryId);
$article->setAuthor($_SESSION['USR']);
$article->setTags($_POST['tags']);
$ret = $articleController->submitNewArticle($article);
if ($ret) {
header("location:../adminConsole.php");
} else {
echo "Unexpected exception";
}