Continued work on getter/setters: entity IDs
This commit is contained in:
parent
878f09ad0d
commit
7df8a6fa3b
36 changed files with 125 additions and 113 deletions
|
@ -105,7 +105,7 @@ class Access
|
|||
{
|
||||
if (!$user)
|
||||
return 'all';
|
||||
return $user->id == Auth::getCurrentUser()->id ? 'own' : 'all';
|
||||
return $user->getId() == Auth::getCurrentUser()->getId() ? 'own' : 'all';
|
||||
}
|
||||
|
||||
public static function getAllowedSafety()
|
||||
|
|
|
@ -16,7 +16,7 @@ class AddCommentJob extends AbstractJob
|
|||
CommentModel::save($comment);
|
||||
Logger::log('{user} commented on {post}', [
|
||||
'user' => TextHelper::reprUser($user),
|
||||
'post' => TextHelper::reprPost($comment->getPost()->id)]);
|
||||
'post' => TextHelper::reprPost($comment->getPost())]);
|
||||
|
||||
return $comment;
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ class EditPostRelationsJob extends AbstractPostEditJob
|
|||
$post = $this->post;
|
||||
$relations = $this->getArgument(self::RELATED_POST_IDS);
|
||||
|
||||
$oldRelatedIds = array_map(function($post) { return $post->id; }, $post->getRelations());
|
||||
$oldRelatedIds = array_map(function($post) { return $post->getId(); }, $post->getRelations());
|
||||
$post->setRelationsFromText($relations);
|
||||
$newRelatedIds = array_map(function($post) { return $post->id; }, $post->getRelations());
|
||||
$newRelatedIds = array_map(function($post) { return $post->getId(); }, $post->getRelations());
|
||||
|
||||
if (!$this->skipSaving)
|
||||
PostModel::save($post);
|
||||
|
|
|
@ -19,7 +19,7 @@ class EditUserEmailJob extends AbstractUserEditJob
|
|||
$user->emailUnconfirmed = $newEmail;
|
||||
$user->emailConfirmed = null;
|
||||
|
||||
if (Auth::getCurrentUser()->id == $user->id)
|
||||
if (Auth::getCurrentUser()->getId() == $user->getId())
|
||||
{
|
||||
if (!empty($newEmail))
|
||||
ActivateUserEmailJob::sendEmail($user);
|
||||
|
|
|
@ -5,7 +5,7 @@ class FeaturePostJob extends AbstractPostJob
|
|||
{
|
||||
$post = $this->post;
|
||||
|
||||
PropertyModel::set(PropertyModel::FeaturedPostId, $post->id);
|
||||
PropertyModel::set(PropertyModel::FeaturedPostId, $post->getId());
|
||||
PropertyModel::set(PropertyModel::FeaturedPostDate, time());
|
||||
PropertyModel::set(PropertyModel::FeaturedPostUserName, Auth::getCurrentUser()->getName());
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class GetPostContentJob extends AbstractJob
|
|||
|
||||
$fileName = sprintf('%s_%s_%s.%s',
|
||||
$config->main->title,
|
||||
$post->id,
|
||||
$post->getId(),
|
||||
join(',', array_map(function($tag) { return $tag->getName(); }, $post->getTags())),
|
||||
TextHelper::resolveMimeType($post->mimeType) ?: 'dat');
|
||||
$fileName = preg_replace('/[[:^print:]]/', '', $fileName);
|
||||
|
|
|
@ -85,7 +85,7 @@ class Auth
|
|||
private static function getAnonymousUser()
|
||||
{
|
||||
$dummy = UserModel::spawn();
|
||||
$dummy->id = null;
|
||||
$dummy->setId(null);
|
||||
$dummy->setName(UserModel::getAnonymousName());
|
||||
$dummy->setAccessRank(new AccessRank(AccessRank::Anonymous));
|
||||
return $dummy;
|
||||
|
|
|
@ -83,7 +83,7 @@ class UserController
|
|||
|
||||
if ($user->getAccessRank()->toInteger() != AccessRank::Anonymous)
|
||||
UserModel::save($user);
|
||||
if ($user->id == Auth::getCurrentUser()->id)
|
||||
if ($user->getId() == Auth::getCurrentUser()->getId())
|
||||
Auth::setCurrentUser($user);
|
||||
|
||||
Messenger::message('Browsing settings updated!');
|
||||
|
@ -109,7 +109,7 @@ class UserController
|
|||
$args = array_filter($args);
|
||||
$user = Api::run(new EditUserJob(), $args);
|
||||
|
||||
if (Auth::getCurrentUser()->id == $user->id)
|
||||
if (Auth::getCurrentUser()->getId() == $user->getId())
|
||||
Auth::setCurrentUser($user);
|
||||
|
||||
$message = 'Account settings updated!';
|
||||
|
@ -127,7 +127,7 @@ class UserController
|
|||
Api::run(new DeleteUserJob(), [
|
||||
DeleteUserJob::USER_NAME => $name]);
|
||||
|
||||
$user = UserModel::findById(Auth::getCurrentUser()->id, false);
|
||||
$user = UserModel::findById(Auth::getCurrentUser()->getId(), false);
|
||||
if (!$user)
|
||||
Auth::logOut();
|
||||
|
||||
|
@ -292,7 +292,7 @@ class UserController
|
|||
private function requirePasswordConfirmation()
|
||||
{
|
||||
$user = getContext()->transport->user;
|
||||
if (Auth::getCurrentUser()->id == $user->id)
|
||||
if (Auth::getCurrentUser()->getId() == $user->getId())
|
||||
{
|
||||
$suppliedPassword = InputHelper::get('current-password');
|
||||
$suppliedPasswordHash = UserModel::hashPassword($suppliedPassword, $user->passSalt);
|
||||
|
|
|
@ -150,7 +150,7 @@ class TextHelper
|
|||
{
|
||||
if (!is_object($post))
|
||||
return '@' . $post;
|
||||
return '@' . $post->id;
|
||||
return '@' . $post->getId();
|
||||
}
|
||||
|
||||
public static function reprUser($user)
|
||||
|
|
|
@ -126,7 +126,7 @@ abstract class AbstractCrudModel implements IModel
|
|||
$table = static::getTableName();
|
||||
if (!Database::inTransaction())
|
||||
throw new Exception('Can be run only within transaction');
|
||||
if (!$entity->id)
|
||||
if (!$entity->getId())
|
||||
{
|
||||
$stmt = new Sql\InsertStatement();
|
||||
$stmt->setTable($table);
|
||||
|
@ -139,7 +139,7 @@ abstract class AbstractCrudModel implements IModel
|
|||
$stmt->setColumn($key, new Sql\Binding($val));
|
||||
}
|
||||
Database::exec($stmt);
|
||||
$entity->id = (int) Database::lastInsertId();
|
||||
$entity->setId((int) Database::lastInsertId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class CommentModel extends AbstractCrudModel
|
|||
|
||||
$stmt = new Sql\UpdateStatement();
|
||||
$stmt->setTable('comment');
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($comment->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($comment->getId())));
|
||||
|
||||
foreach ($bindings as $key => $val)
|
||||
$stmt->setColumn($key, new Sql\Binding($val));
|
||||
|
@ -49,7 +49,7 @@ class CommentModel extends AbstractCrudModel
|
|||
{
|
||||
$stmt = new Sql\DeleteStatement();
|
||||
$stmt->setTable('comment');
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($comment->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($comment->getId())));
|
||||
Database::exec($stmt);
|
||||
});
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class CommentModel extends AbstractCrudModel
|
|||
{
|
||||
self::preloadOneToMany($comments,
|
||||
function($comment) { return $comment->commenterId; },
|
||||
function($user) { return $user->id; },
|
||||
function($user) { return $user->getId(); },
|
||||
function($userIds) { return UserModel::findByIds($userIds); },
|
||||
function($comment, $user) { return $comment->setCache('commenter', $user); });
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class CommentModel extends AbstractCrudModel
|
|||
{
|
||||
self::preloadOneToMany($comments,
|
||||
function($comment) { return $comment->postId; },
|
||||
function($post) { return $post->id; },
|
||||
function($post) { return $post->getId(); },
|
||||
function($postIds) { return PostModel::findByIds($postIds); },
|
||||
function($comment, $post) { $comment->setCache('post', $post); });
|
||||
}
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
<?php
|
||||
abstract class AbstractEntity implements IValidatable
|
||||
{
|
||||
public $id;
|
||||
protected $id;
|
||||
protected $__cache = [];
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function resetCache()
|
||||
{
|
||||
$this->__cache = [];
|
||||
|
|
|
@ -39,7 +39,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
|||
|
||||
public function setUploader($user)
|
||||
{
|
||||
$this->uploaderId = $user->id;
|
||||
$this->uploaderId = $user->getId();
|
||||
$this->setCache('uploader', $user);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
|||
{
|
||||
if ($this->hasCache('comments'))
|
||||
return $this->getCache('comments');
|
||||
$comments = CommentModel::findAllByPostId($this->id);
|
||||
$comments = CommentModel::findAllByPostId($this->getId());
|
||||
$this->setCache('comments', $comments);
|
||||
return $comments;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
|||
$stmt->setColumn('user.*');
|
||||
$stmt->setTable('user');
|
||||
$stmt->addInnerJoin('favoritee', new Sql\EqualsFunctor('favoritee.user_id', 'user.id'));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('favoritee.post_id', new Sql\Binding($this->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('favoritee.post_id', new Sql\Binding($this->getId())));
|
||||
$rows = Database::fetchAll($stmt);
|
||||
$favorites = UserModel::convertRows($rows);
|
||||
$this->setCache('favoritee', $favorites);
|
||||
|
@ -75,7 +75,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
|||
$stmt = new Sql\SelectStatement();
|
||||
$stmt->setColumn('post.*');
|
||||
$stmt->setTable('post');
|
||||
$binding = new Sql\Binding($this->id);
|
||||
$binding = new Sql\Binding($this->getId());
|
||||
$stmt->addInnerJoin('crossref', (new Sql\DisjunctionFunctor)
|
||||
->add(
|
||||
(new Sql\ConjunctionFunctor)
|
||||
|
@ -94,11 +94,11 @@ class PostEntity extends AbstractEntity implements IValidatable
|
|||
public function setRelations(array $relations)
|
||||
{
|
||||
foreach ($relations as $relatedPost)
|
||||
if (!$relatedPost->id)
|
||||
if (!$relatedPost->getId())
|
||||
throw new Exception('All related posts must be saved');
|
||||
$uniqueRelations = [];
|
||||
foreach ($relations as $relatedPost)
|
||||
$uniqueRelations[$relatedPost->id] = $relatedPost;
|
||||
$uniqueRelations[$relatedPost->getId()] = $relatedPost;
|
||||
$relations = array_values($uniqueRelations);
|
||||
$this->setCache('relations', $relations);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
|||
$relatedPosts = [];
|
||||
foreach ($relatedIds as $relatedId)
|
||||
{
|
||||
if ($relatedId == $this->id)
|
||||
if ($relatedId == $this->getId())
|
||||
continue;
|
||||
|
||||
if (count($relatedPosts) > $config->browsing->maxRelatedPosts)
|
||||
|
@ -131,7 +131,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
|||
{
|
||||
if ($this->hasCache('tags'))
|
||||
return $this->getCache('tags');
|
||||
$tags = TagModel::findAllByPostId($this->id);
|
||||
$tags = TagModel::findAllByPostId($this->getId());
|
||||
$this->setCache('tags', $tags);
|
||||
return $tags;
|
||||
}
|
||||
|
@ -139,11 +139,11 @@ class PostEntity extends AbstractEntity implements IValidatable
|
|||
public function setTags(array $tags)
|
||||
{
|
||||
foreach ($tags as $tag)
|
||||
if (!$tag->id)
|
||||
if (!$tag->getId())
|
||||
throw new Exception('All tags must be saved');
|
||||
$uniqueTags = [];
|
||||
foreach ($tags as $tag)
|
||||
$uniqueTags[$tag->id] = $tag;
|
||||
$uniqueTags[$tag->getId()] = $tag;
|
||||
$tags = array_values($uniqueTags);
|
||||
$this->setCache('tags', $tags);
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
|||
}
|
||||
|
||||
$duplicatedPost = PostModel::findByHash($this->fileHash, false);
|
||||
if ($duplicatedPost !== null and (!$this->id or $this->id != $duplicatedPost->id))
|
||||
if ($duplicatedPost !== null and (!$this->getId() or $this->getId() != $duplicatedPost->getId()))
|
||||
{
|
||||
throw new SimpleException(
|
||||
'Duplicate upload: %s',
|
||||
|
@ -361,7 +361,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
|||
unlink($thumbPath);
|
||||
|
||||
$duplicatedPost = PostModel::findByHash($youtubeId, false);
|
||||
if ($duplicatedPost !== null and (!$this->id or $this->id != $duplicatedPost->id))
|
||||
if ($duplicatedPost !== null and (!$this->getId() or $this->getId() != $duplicatedPost->getId()))
|
||||
{
|
||||
throw new SimpleException(
|
||||
'Duplicate upload: %s',
|
||||
|
|
|
@ -29,7 +29,7 @@ class TagEntity extends AbstractEntity implements IValidatable
|
|||
$stmt = new Sql\SelectStatement();
|
||||
$stmt->setColumn(new Sql\AliasFunctor(new Sql\CountFunctor('1'), 'count'));
|
||||
$stmt->setTable('post_tag');
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('tag_id', new Sql\Binding($this->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('tag_id', new Sql\Binding($this->getId())));
|
||||
return Database::fetchOne($stmt)['count'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ class TokenEntity extends AbstractEntity implements IValidatable
|
|||
|
||||
public function setUser($user)
|
||||
{
|
||||
$this->userId = $user ? $user->id : null;
|
||||
$this->userId = $user ? $user->getId() : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,8 +172,8 @@ class UserEntity extends AbstractEntity implements IValidatable
|
|||
$stmt->setColumn(new Sql\AliasFunctor(new Sql\CountFunctor('1'), 'count'));
|
||||
$stmt->setTable('favoritee');
|
||||
$stmt->setCriterion((new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('user_id', new Sql\Binding($this->id)))
|
||||
->add(new Sql\EqualsFunctor('post_id', new Sql\Binding($post->id))));
|
||||
->add(new Sql\EqualsFunctor('user_id', new Sql\Binding($this->getId())))
|
||||
->add(new Sql\EqualsFunctor('post_id', new Sql\Binding($post->getId()))));
|
||||
return Database::fetchOne($stmt)['count'] == 1;
|
||||
}
|
||||
|
||||
|
@ -183,8 +183,8 @@ class UserEntity extends AbstractEntity implements IValidatable
|
|||
$stmt->setColumn('score');
|
||||
$stmt->setTable('post_score');
|
||||
$stmt->setCriterion((new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('user_id', new Sql\Binding($this->id)))
|
||||
->add(new Sql\EqualsFunctor('post_id', new Sql\Binding($post->id))));
|
||||
->add(new Sql\EqualsFunctor('user_id', new Sql\Binding($this->getId())))
|
||||
->add(new Sql\EqualsFunctor('post_id', new Sql\Binding($post->getId()))));
|
||||
$row = Database::fetchOne($stmt);
|
||||
if ($row)
|
||||
return intval($row['score']);
|
||||
|
@ -196,7 +196,7 @@ class UserEntity extends AbstractEntity implements IValidatable
|
|||
$stmt = new Sql\SelectStatement();
|
||||
$stmt->setColumn(new Sql\AliasFunctor(new Sql\CountFunctor('1'), 'count'));
|
||||
$stmt->setTable('favoritee');
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('user_id', new Sql\Binding($this->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('user_id', new Sql\Binding($this->getId())));
|
||||
return Database::fetchOne($stmt)['count'];
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ class UserEntity extends AbstractEntity implements IValidatable
|
|||
$stmt = new Sql\SelectStatement();
|
||||
$stmt->setColumn(new Sql\AliasFunctor(new Sql\CountFunctor('1'), 'count'));
|
||||
$stmt->setTable('comment');
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('commenter_id', new Sql\Binding($this->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('commenter_id', new Sql\Binding($this->getId())));
|
||||
return Database::fetchOne($stmt)['count'];
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ class UserEntity extends AbstractEntity implements IValidatable
|
|||
$stmt = new Sql\SelectStatement();
|
||||
$stmt->setColumn(new Sql\AliasFunctor(new Sql\CountFunctor('1'), 'count'));
|
||||
$stmt->setTable('post');
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('uploader_id', new Sql\Binding($this->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('uploader_id', new Sql\Binding($this->getId())));
|
||||
return Database::fetchOne($stmt)['count'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class PostModel extends AbstractCrudModel
|
|||
foreach ($bindings as $key => $value)
|
||||
$stmt->setColumn($key, new Sql\Binding($value));
|
||||
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($post->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($post->getId())));
|
||||
Database::exec($stmt);
|
||||
|
||||
//tags
|
||||
|
@ -81,15 +81,15 @@ class PostModel extends AbstractCrudModel
|
|||
|
||||
$stmt = new Sql\DeleteStatement();
|
||||
$stmt->setTable('post_tag');
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('post_id', new Sql\Binding($post->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('post_id', new Sql\Binding($post->getId())));
|
||||
Database::exec($stmt);
|
||||
|
||||
foreach ($tags as $postTag)
|
||||
{
|
||||
$stmt = new Sql\InsertStatement();
|
||||
$stmt->setTable('post_tag');
|
||||
$stmt->setColumn('post_id', new Sql\Binding($post->id));
|
||||
$stmt->setColumn('tag_id', new Sql\Binding($postTag->id));
|
||||
$stmt->setColumn('post_id', new Sql\Binding($post->getId()));
|
||||
$stmt->setColumn('tag_id', new Sql\Binding($postTag->getId()));
|
||||
Database::exec($stmt);
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ class PostModel extends AbstractCrudModel
|
|||
|
||||
$stmt = new Sql\DeleteStatement();
|
||||
$stmt->setTable('crossref');
|
||||
$binding = new Sql\Binding($post->id);
|
||||
$binding = new Sql\Binding($post->getId());
|
||||
$stmt->setCriterion((new Sql\DisjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('post_id', $binding))
|
||||
->add(new Sql\EqualsFunctor('post2_id', $binding)));
|
||||
|
@ -108,8 +108,8 @@ class PostModel extends AbstractCrudModel
|
|||
{
|
||||
$stmt = new Sql\InsertStatement();
|
||||
$stmt->setTable('crossref');
|
||||
$stmt->setColumn('post_id', new Sql\Binding($post->id));
|
||||
$stmt->setColumn('post2_id', new Sql\Binding($relatedPost->id));
|
||||
$stmt->setColumn('post_id', new Sql\Binding($post->getId()));
|
||||
$stmt->setColumn('post2_id', new Sql\Binding($relatedPost->getId()));
|
||||
Database::exec($stmt);
|
||||
}
|
||||
});
|
||||
|
@ -121,7 +121,7 @@ class PostModel extends AbstractCrudModel
|
|||
{
|
||||
Database::transaction(function() use ($post)
|
||||
{
|
||||
$binding = new Sql\Binding($post->id);
|
||||
$binding = new Sql\Binding($post->getId());
|
||||
|
||||
$stmt = new Sql\DeleteStatement();
|
||||
$stmt->setTable('post_score');
|
||||
|
@ -204,7 +204,7 @@ class PostModel extends AbstractCrudModel
|
|||
$tagsMap = [];
|
||||
foreach ($posts as $post)
|
||||
{
|
||||
$postId = $post->id;
|
||||
$postId = $post->getId();
|
||||
$postMap[$postId] = $post;
|
||||
$commentMap[$postId] = [];
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ class PostModel extends AbstractCrudModel
|
|||
$tagsMap = [];
|
||||
foreach ($posts as $post)
|
||||
{
|
||||
$postId = $post->id;
|
||||
$postId = $post->getId();
|
||||
$postMap[$postId] = $post;
|
||||
$tagsMap[$postId] = [];
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class PostSearchParser extends AbstractSearchParser
|
|||
$innerStmt->setTable('post_tag');
|
||||
$innerStmt->setCriterion((new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('post_tag.post_id', 'post.id'))
|
||||
->add(new Sql\EqualsFunctor('post_tag.tag_id', new Sql\Binding($tag->id))));
|
||||
->add(new Sql\EqualsFunctor('post_tag.tag_id', new Sql\Binding($tag->getId()))));
|
||||
$operator = new Sql\ExistsFunctor($innerStmt);
|
||||
if ($neg)
|
||||
$operator = new Sql\NegationFunctor($operator);
|
||||
|
@ -78,7 +78,7 @@ class PostSearchParser extends AbstractSearchParser
|
|||
->setTable('favoritee')
|
||||
->setCriterion((new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('favoritee.post_id', 'post.id'))
|
||||
->add(new Sql\EqualsFunctor('favoritee.user_id', new Sql\Binding($user->id))));
|
||||
->add(new Sql\EqualsFunctor('favoritee.user_id', new Sql\Binding($user->getId()))));
|
||||
return new Sql\ExistsFunctor($innerStmt);
|
||||
}
|
||||
|
||||
|
@ -89,14 +89,14 @@ class PostSearchParser extends AbstractSearchParser
|
|||
->setTable('comment')
|
||||
->setCriterion((new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('comment.post_id', 'post.id'))
|
||||
->add(new Sql\EqualsFunctor('comment.commenter_id', new Sql\Binding($user->id))));
|
||||
->add(new Sql\EqualsFunctor('comment.commenter_id', new Sql\Binding($user->getId()))));
|
||||
return new Sql\ExistsFunctor($innerStmt);
|
||||
}
|
||||
|
||||
elseif (in_array($key, ['submit', 'upload', 'uploads', 'uploader', 'uploaded']))
|
||||
{
|
||||
$user = UserModel::findByNameOrEmail($value);
|
||||
return new Sql\EqualsFunctor('post.uploader_id', new Sql\Binding($user->id));
|
||||
return new Sql\EqualsFunctor('post.uploader_id', new Sql\Binding($user->getId()));
|
||||
}
|
||||
|
||||
elseif (in_array($key, ['idmin', 'id_min']))
|
||||
|
@ -165,7 +165,7 @@ class PostSearchParser extends AbstractSearchParser
|
|||
{
|
||||
$this->statement->addLeftOuterJoin('post_score', (new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('post_score.post_id', 'post.id'))
|
||||
->add(new Sql\EqualsFunctor('post_score.user_id', new Sql\Binding($activeUser->id))));
|
||||
->add(new Sql\EqualsFunctor('post_score.user_id', new Sql\Binding($activeUser->getId()))));
|
||||
}
|
||||
return new Sql\EqualsFunctor(new Sql\IfNullFunctor('post_score.score', '0'), '1');
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ class PostSearchParser extends AbstractSearchParser
|
|||
{
|
||||
$this->statement->addLeftOuterJoin('post_score', (new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('post_score.post_id', 'post.id'))
|
||||
->add(new Sql\EqualsFunctor('post_score.user_id', new Sql\Binding($activeUser->id))));
|
||||
->add(new Sql\EqualsFunctor('post_score.user_id', new Sql\Binding($activeUser->getId()))));
|
||||
}
|
||||
return new Sql\EqualsFunctor(new Sql\IfNullFunctor('post_score.score', '0'), '-1');
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class TagSearchService extends AbstractSearchService
|
|||
$parentTagEntity = TagModel::findByName($parentTagName, false);
|
||||
if (empty($parentTagEntity))
|
||||
return [];
|
||||
$parentTagId = $parentTagEntity->id;
|
||||
$parentTagId = $parentTagEntity->getId();
|
||||
|
||||
//get tags that appear with selected tag along with their occurence frequency
|
||||
$stmt = (new Sql\SelectStatement)
|
||||
|
|
|
@ -28,7 +28,7 @@ class TagModel extends AbstractCrudModel
|
|||
$stmt = new Sql\UpdateStatement();
|
||||
$stmt->setTable('tag');
|
||||
$stmt->setColumn('name', new Sql\Binding($tag->getName()));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($tag->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($tag->getId())));
|
||||
|
||||
Database::exec($stmt);
|
||||
});
|
||||
|
@ -38,7 +38,7 @@ class TagModel extends AbstractCrudModel
|
|||
|
||||
public static function remove($tag)
|
||||
{
|
||||
$binding = new Sql\Binding($tag->id);
|
||||
$binding = new Sql\Binding($tag->getId());
|
||||
|
||||
$stmt = new Sql\DeleteStatement();
|
||||
$stmt->setTable('post_tag');
|
||||
|
@ -58,7 +58,7 @@ class TagModel extends AbstractCrudModel
|
|||
$sourceTag = TagModel::findByName($sourceName);
|
||||
$targetTag = TagModel::findByName($targetName, false);
|
||||
|
||||
if ($targetTag and $targetTag->id != $sourceTag->id)
|
||||
if ($targetTag and $targetTag->getId() != $sourceTag->getId())
|
||||
throw new SimpleException('Target tag already exists');
|
||||
|
||||
$sourceTag->setName($targetName);
|
||||
|
@ -74,7 +74,7 @@ class TagModel extends AbstractCrudModel
|
|||
$sourceTag = TagModel::findByName($sourceName);
|
||||
$targetTag = TagModel::findByName($targetName);
|
||||
|
||||
if ($sourceTag->id == $targetTag->id)
|
||||
if ($sourceTag->getId() == $targetTag->getId())
|
||||
throw new SimpleException('Source and target tag are the same');
|
||||
|
||||
$stmt = new Sql\SelectStatement();
|
||||
|
@ -89,7 +89,7 @@ class TagModel extends AbstractCrudModel
|
|||
->setCriterion(
|
||||
(new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('post_tag.post_id', 'post.id'))
|
||||
->add(new Sql\EqualsFunctor('post_tag.tag_id', new Sql\Binding($sourceTag->id))))))
|
||||
->add(new Sql\EqualsFunctor('post_tag.tag_id', new Sql\Binding($sourceTag->getId()))))))
|
||||
->add(
|
||||
new Sql\NegationFunctor(
|
||||
new Sql\ExistsFunctor(
|
||||
|
@ -98,7 +98,7 @@ class TagModel extends AbstractCrudModel
|
|||
->setCriterion(
|
||||
(new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('post_tag.post_id', 'post.id'))
|
||||
->add(new Sql\EqualsFunctor('post_tag.tag_id', new Sql\Binding($targetTag->id))))))));
|
||||
->add(new Sql\EqualsFunctor('post_tag.tag_id', new Sql\Binding($targetTag->getId()))))))));
|
||||
$rows = Database::fetchAll($stmt);
|
||||
$postIds = array_map(function($row) { return $row['id']; }, $rows);
|
||||
|
||||
|
@ -109,7 +109,7 @@ class TagModel extends AbstractCrudModel
|
|||
$stmt = new Sql\InsertStatement();
|
||||
$stmt->setTable('post_tag');
|
||||
$stmt->setColumn('post_id', new Sql\Binding($postId));
|
||||
$stmt->setColumn('tag_id', new Sql\Binding($targetTag->id));
|
||||
$stmt->setColumn('tag_id', new Sql\Binding($targetTag->getId()));
|
||||
Database::exec($stmt);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@ class TokenModel extends AbstractCrudModel
|
|||
|
||||
$stmt = new Sql\UpdateStatement();
|
||||
$stmt->setTable('user_token');
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($token->id)));
|
||||
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($token->getId())));
|
||||
|
||||
foreach ($bindings as $key => $val)
|
||||
$stmt->setColumn($key, new Sql\Binding($val));
|
||||
|
|
|
@ -56,7 +56,7 @@ class UserModel extends AbstractCrudModel
|
|||
|
||||
$stmt = (new Sql\UpdateStatement)
|
||||
->setTable('user')
|
||||
->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($user->id)));
|
||||
->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($user->getId())));
|
||||
|
||||
foreach ($bindings as $key => $val)
|
||||
$stmt->setColumn($key, new Sql\Binding($val));
|
||||
|
@ -71,7 +71,7 @@ class UserModel extends AbstractCrudModel
|
|||
{
|
||||
Database::transaction(function() use ($user)
|
||||
{
|
||||
$binding = new Sql\Binding($user->id);
|
||||
$binding = new Sql\Binding($user->getId());
|
||||
|
||||
$stmt = new Sql\DeleteStatement();
|
||||
$stmt->setTable('post_score');
|
||||
|
@ -144,16 +144,16 @@ class UserModel extends AbstractCrudModel
|
|||
$stmt = new Sql\DeleteStatement();
|
||||
$stmt->setTable('post_score');
|
||||
$stmt->setCriterion((new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('post_id', new Sql\Binding($post->id)))
|
||||
->add(new Sql\EqualsFunctor('user_id', new Sql\Binding($user->id))));
|
||||
->add(new Sql\EqualsFunctor('post_id', new Sql\Binding($post->getId())))
|
||||
->add(new Sql\EqualsFunctor('user_id', new Sql\Binding($user->getId()))));
|
||||
Database::exec($stmt);
|
||||
$score = intval($score);
|
||||
if ($score != 0)
|
||||
{
|
||||
$stmt = new Sql\InsertStatement();
|
||||
$stmt->setTable('post_score');
|
||||
$stmt->setColumn('post_id', new Sql\Binding($post->id));
|
||||
$stmt->setColumn('user_id', new Sql\Binding($user->id));
|
||||
$stmt->setColumn('post_id', new Sql\Binding($post->getId()));
|
||||
$stmt->setColumn('user_id', new Sql\Binding($user->getId()));
|
||||
$stmt->setColumn('score', new Sql\Binding($score));
|
||||
Database::exec($stmt);
|
||||
}
|
||||
|
@ -167,8 +167,8 @@ class UserModel extends AbstractCrudModel
|
|||
self::removeFromUserFavorites($user, $post);
|
||||
$stmt = new Sql\InsertStatement();
|
||||
$stmt->setTable('favoritee');
|
||||
$stmt->setColumn('post_id', new Sql\Binding($post->id));
|
||||
$stmt->setColumn('user_id', new Sql\Binding($user->id));
|
||||
$stmt->setColumn('post_id', new Sql\Binding($post->getId()));
|
||||
$stmt->setColumn('user_id', new Sql\Binding($user->getId()));
|
||||
$stmt->setColumn('fav_date', time());
|
||||
Database::exec($stmt);
|
||||
});
|
||||
|
@ -181,8 +181,8 @@ class UserModel extends AbstractCrudModel
|
|||
$stmt = new Sql\DeleteStatement();
|
||||
$stmt->setTable('favoritee');
|
||||
$stmt->setCriterion((new Sql\ConjunctionFunctor)
|
||||
->add(new Sql\EqualsFunctor('post_id', new Sql\Binding($post->id)))
|
||||
->add(new Sql\EqualsFunctor('user_id', new Sql\Binding($user->id))));
|
||||
->add(new Sql\EqualsFunctor('post_id', new Sql\Binding($post->getId())))
|
||||
->add(new Sql\EqualsFunctor('user_id', new Sql\Binding($user->getId()))));
|
||||
Database::exec($stmt);
|
||||
});
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ class UserModel extends AbstractCrudModel
|
|||
$config = getConfig();
|
||||
|
||||
$otherUser = self::findByName($userName, false);
|
||||
if ($otherUser !== null and $otherUser->id != $user->id)
|
||||
if ($otherUser !== null and $otherUser->getId() != $user->getId())
|
||||
{
|
||||
if (!$otherUser->emailConfirmed and $config->registration->needEmailForRegistering)
|
||||
throw new SimpleException('User with this name is already registered and awaits e-mail confirmation');
|
||||
|
|
|
@ -16,7 +16,7 @@ Assets::addScript('comment-edit.js');
|
|||
<div class="input-wrapper"><textarea name="text" cols="50" rows="3"></textarea></div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="post-id" value="<?= $this->context->transport->post->id ?>">
|
||||
<input type="hidden" name="post-id" value="<?= $this->context->transport->post->getId() ?>">
|
||||
|
||||
<div class="form-row">
|
||||
<button name="sender" class="submit" type="submit" value="preview">Preview</button>
|
||||
|
|
|
@ -7,7 +7,7 @@ Assets::addScript('comment-edit.js');
|
|||
method="post"
|
||||
action="<?= \Chibi\Router::linkTo(
|
||||
['CommentController', 'editAction'],
|
||||
['id' => $this->context->transport->comment->id]) ?>"
|
||||
['id' => $this->context->transport->comment->getId()]) ?>"
|
||||
class="edit-comment">
|
||||
|
||||
<h1>edit comment</h1>
|
||||
|
|
|
@ -33,7 +33,7 @@ Assets::setSubTitle('comments');
|
|||
<?php if (count($comments) > count($commentsToDisplay)): ?>
|
||||
<a href="<?= \Chibi\Router::linkTo(
|
||||
['PostController', 'genericView'],
|
||||
['id' => $this->context->post->id]) ?>">
|
||||
['id' => $this->context->post->getId()]) ?>">
|
||||
<span class="hellip">(more…)</span>
|
||||
</a>
|
||||
<?php endif ?>
|
||||
|
|
|
@ -42,7 +42,7 @@ Assets::addScript('comment-edit.js');
|
|||
<span class="edit">
|
||||
<a href="<?= \Chibi\Router::linkTo(
|
||||
['CommentController', 'editView'],
|
||||
['id' => $this->context->comment->id]) ?>">
|
||||
['id' => $this->context->comment->getId()]) ?>">
|
||||
edit
|
||||
</a>
|
||||
</span>
|
||||
|
@ -56,7 +56,7 @@ Assets::addScript('comment-edit.js');
|
|||
data-confirm-text="Are you sure you want to delete this comment?"
|
||||
href="<?= \Chibi\Router::linkTo(
|
||||
['CommentController', 'deleteAction'],
|
||||
['id' => $this->context->comment->id]) ?>">
|
||||
['id' => $this->context->comment->getId()]) ?>">
|
||||
delete
|
||||
</a>
|
||||
</span>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<form method="post"
|
||||
action="<?= \Chibi\Router::linkTo(
|
||||
['PostController', 'editAction'],
|
||||
['id' => $this->context->transport->post->id]) ?>"
|
||||
['id' => $this->context->transport->post->getId()]) ?>"
|
||||
enctype="multipart/form-data"
|
||||
class="edit-post">
|
||||
|
||||
|
@ -79,7 +79,7 @@
|
|||
id="relations"
|
||||
placeholder="id1,id2,…"
|
||||
value="<?= join(',', array_map(function($post) {
|
||||
return $post->id;
|
||||
return $post->getId();
|
||||
}, $this->context->transport->post->getRelations())) ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -29,7 +29,7 @@ if ($masstag)
|
|||
<?php if ($masstag): ?>
|
||||
<a class="toggle-tag"
|
||||
href="<?= \Chibi\Router::linkTo(['PostController', 'toggleTagAction'], [
|
||||
'id' => $this->context->post->id,
|
||||
'id' => $this->context->post->getId(),
|
||||
'tag' => $this->context->additionalInfo,
|
||||
'enable' => '_enable_']) ?>"
|
||||
data-text-tagged="Tagged"
|
||||
|
@ -44,12 +44,12 @@ if ($masstag)
|
|||
<?php if (Auth::getCurrentUser()->hasEnabledPostTagTitles()): ?>
|
||||
title="<?= TextHelper::reprTags($this->context->post->getTags()) ?>"
|
||||
<?php endif ?>
|
||||
href="<?= \Chibi\Router::linkTo(['PostController', 'genericView'], ['id' => $this->context->post->id]) ?>">
|
||||
href="<?= \Chibi\Router::linkTo(['PostController', 'genericView'], ['id' => $this->context->post->getId()]) ?>">
|
||||
|
||||
<img
|
||||
class="thumb"
|
||||
src="<?= \Chibi\Router::linkTo(['PostController', 'thumbView'], ['name' => $this->context->post->getName()]) ?>"
|
||||
alt="@<?= $this->context->post->id ?>"/>
|
||||
alt="@<?= $this->context->post->getId() ?>"/>
|
||||
|
||||
<?php
|
||||
$x =
|
||||
|
|
|
@ -155,7 +155,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
{
|
||||
return \Chibi\Router::linkTo(
|
||||
['PostController', 'scoreAction'],
|
||||
['id' => $this->context->transport->post->id, 'score' => $score]);
|
||||
['id' => $this->context->transport->post->getId(), 'score' => $score]);
|
||||
}
|
||||
?>
|
||||
<?php if (Access::check(new Privilege(
|
||||
|
@ -210,7 +210,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<a class="add-fav icon simple-action"
|
||||
href="<?= \Chibi\Router::linkTo(
|
||||
['PostController', 'addFavoriteAction'],
|
||||
['id' => $this->context->transport->post->id]) ?>">
|
||||
['id' => $this->context->transport->post->getId()]) ?>">
|
||||
<i class="icon-fav"></i>
|
||||
<span>Add to favorites</span>
|
||||
</a>
|
||||
|
@ -218,7 +218,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<a class="rem-fav icon simple-action"
|
||||
href="<?= \Chibi\Router::linkTo(
|
||||
['PostController', 'removeFavoriteAction'],
|
||||
['id' => $this->context->transport->post->id]) ?>">
|
||||
['id' => $this->context->transport->post->getId()]) ?>">
|
||||
<i class="icon-fav"></i>
|
||||
<span>Remove from favorites</span>
|
||||
</a>
|
||||
|
@ -259,8 +259,10 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<ul>
|
||||
<?php foreach ($this->context->transport->post->getRelations() as $relatedPost): ?>
|
||||
<li>
|
||||
<a href="<?= \Chibi\Router::linkTo(['PostController', 'genericView'], ['id' => $relatedPost->id]) ?>">
|
||||
@<?= $relatedPost->id ?>
|
||||
<a href="<?= \Chibi\Router::linkTo(
|
||||
['PostController', 'genericView'],
|
||||
['id' => $relatedPost->getId()]) ?>">
|
||||
@<?= $relatedPost->getId() ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
|
@ -281,7 +283,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
'text' => 'Feature on main page',
|
||||
'simple-action' => \Chibi\Router::linkTo(
|
||||
['PostController', 'featureAction'],
|
||||
['id' => $this->context->transport->post->id]),
|
||||
['id' => $this->context->transport->post->getId()]),
|
||||
'data-confirm-text' => 'Are you sure you want to feature this post on the main page?',
|
||||
'data-redirect-url' => \Chibi\Router::linkTo(['StaticPagesController', 'mainPageView']),
|
||||
];
|
||||
|
@ -308,7 +310,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
'text' => 'Flag for moderator attention',
|
||||
'simple-action' => \Chibi\Router::linkTo(
|
||||
['PostController', 'flagAction'],
|
||||
['id' => $this->context->transport->post->id]),
|
||||
['id' => $this->context->transport->post->getId()]),
|
||||
'data-confirm-text' => 'Are you sure you want to flag this post?',
|
||||
];
|
||||
}
|
||||
|
@ -326,7 +328,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
'text' => 'Unhide',
|
||||
'simple-action' => \Chibi\Router::linkTo(
|
||||
['PostController', 'unhideAction'],
|
||||
['id' => $this->context->transport->post->id]),
|
||||
['id' => $this->context->transport->post->getId()]),
|
||||
];
|
||||
}
|
||||
else
|
||||
|
@ -337,7 +339,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
'text' => 'Hide',
|
||||
'simple-action' => \Chibi\Router::linkTo(
|
||||
['PostController', 'hideAction'],
|
||||
['id' => $this->context->transport->post->id]),
|
||||
['id' => $this->context->transport->post->getId()]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +354,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
'text' => 'Delete',
|
||||
'simple-action' => \Chibi\Router::linkTo(
|
||||
['PostController', 'deleteAction'],
|
||||
['id' => $this->context->transport->post->id]),
|
||||
['id' => $this->context->transport->post->getId()]),
|
||||
'data-confirm-text' => 'Are you sure you want to delete this post?',
|
||||
'data-redirect-url' => \Chibi\Router::linkTo(['PostController', 'listView']),
|
||||
];
|
||||
|
|
|
@ -15,7 +15,7 @@ Assets::addStylesheet('static-main.css');
|
|||
<?php
|
||||
$this->context->transport->post = $this->context->featuredPost;
|
||||
$this->context->imageLink = \Chibi\Router::linkTo(['PostController', 'genericView'], [
|
||||
'id' => $this->context->featuredPost->id]);
|
||||
'id' => $this->context->featuredPost->getId()]);
|
||||
?>
|
||||
|
||||
<?php \Chibi\View::render('post-file-render', $this->context) ?>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
autocomplete="off"
|
||||
data-confirm-text="Are you sure you want to delete your account?">
|
||||
|
||||
<?php if (Auth::getCurrentUser()->id == $this->context->transport->user->id): ?>
|
||||
<?php if (Auth::getCurrentUser()->getId() == $this->context->transport->user->getId()): ?>
|
||||
<div class="form-row current-password">
|
||||
<label for="current-password">Current password:</label>
|
||||
<div class="input-wrapper">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
class="edit"
|
||||
autocomplete="off">
|
||||
|
||||
<?php if (Auth::getCurrentUser()->id == $this->context->transport->user->id): ?>
|
||||
<?php if (Auth::getCurrentUser()->getId() == $this->context->transport->user->getId()): ?>
|
||||
<div class="form-row current-password">
|
||||
<label for="current-password">Current password:</label>
|
||||
<div class="input-wrapper">
|
||||
|
|
|
@ -15,12 +15,12 @@ class CommentAddTest extends AbstractTest
|
|||
|
||||
$this->assert->areEqual(1, CommentModel::getCount());
|
||||
$this->assert->areEqual($text, $comment->text);
|
||||
$this->assert->areEqual(Auth::getCurrentUser()->id, $comment->getCommenter()->id);
|
||||
$this->assert->areEqual(1, $comment->getPost()->id);
|
||||
$this->assert->areEqual(Auth::getCurrentUser()->getId(), $comment->getCommenter()->getId());
|
||||
$this->assert->areEqual(1, $comment->getPost()->getId());
|
||||
$this->assert->isNotNull($comment->commentDate);
|
||||
$this->assert->doesNotThrow(function() use ($comment)
|
||||
{
|
||||
UserModel::findById($comment->id);
|
||||
UserModel::findById($comment->getId());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ class CommentAddTest extends AbstractTest
|
|||
});
|
||||
|
||||
$this->assert->areEqual($text, $comment->text);
|
||||
$this->assert->areEqual(Auth::getCurrentUser()->id, $comment->getCommenter()->id);
|
||||
$this->assert->areEqual(Auth::getCurrentUser()->getId(), $comment->getCommenter()->getId());
|
||||
$this->assert->areEqual(UserModel::getAnonymousName(), $comment->getCommenter()->getName());
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ class CommentAddTest extends AbstractTest
|
|||
return Api::run(
|
||||
new AddCommentJob(),
|
||||
[
|
||||
AddCommentJob::POST_ID => $post->id,
|
||||
AddCommentJob::POST_ID => $post->getId(),
|
||||
AddCommentJob::TEXT => $text,
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class CommentDeleteTest extends AbstractTest
|
|||
Api::run(
|
||||
new DeleteCommentJob(),
|
||||
[
|
||||
DeleteCommentJob::COMMENT_ID => $comment->id,
|
||||
DeleteCommentJob::COMMENT_ID => $comment->getId(),
|
||||
]);
|
||||
}, 'Insufficient privileges');
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class CommentDeleteTest extends AbstractTest
|
|||
return Api::run(
|
||||
new DeleteCommentJob(),
|
||||
[
|
||||
DeleteCommentJob::COMMENT_ID => $comment->id,
|
||||
DeleteCommentJob::COMMENT_ID => $comment->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@ class CommentEditTest extends AbstractTest
|
|||
});
|
||||
|
||||
$this->assert->areEqual($text, $comment->text);
|
||||
$this->assert->areEqual(Auth::getCurrentUser()->id, $comment->getCommenter()->id);
|
||||
$this->assert->areEqual(1, $comment->getPost()->id);
|
||||
$this->assert->areEqual(Auth::getCurrentUser()->getId(), $comment->getCommenter()->getId());
|
||||
$this->assert->areEqual(1, $comment->getPost()->getId());
|
||||
$this->assert->isNotNull($comment->commentDate);
|
||||
$this->assert->doesNotThrow(function() use ($comment)
|
||||
{
|
||||
UserModel::findById($comment->id);
|
||||
UserModel::findById($comment->getId());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ class CommentEditTest extends AbstractTest
|
|||
Api::run(
|
||||
new EditCommentJob(),
|
||||
[
|
||||
EditCommentJob::COMMENT_ID => $comment->id,
|
||||
EditCommentJob::COMMENT_ID => $comment->getId(),
|
||||
EditCommentJob::TEXT => 'alohaa',
|
||||
]);
|
||||
}, 'Insufficient privileges');
|
||||
|
@ -145,7 +145,7 @@ class CommentEditTest extends AbstractTest
|
|||
return Api::run(
|
||||
new EditCommentJob(),
|
||||
[
|
||||
EditCommentJob::COMMENT_ID => $comment->id,
|
||||
EditCommentJob::COMMENT_ID => $comment->getId(),
|
||||
EditCommentJob::TEXT => $text,
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class CommentListTest extends AbstractTest
|
|||
$post = $ret->entities[0];
|
||||
$samePost = $this->assert->doesNotThrow(function() use ($post)
|
||||
{
|
||||
return PostModel::findById($post->id);
|
||||
return PostModel::findById($post->getId());
|
||||
});
|
||||
//posts retrieved via ListCommentsJob should already have cached its comments
|
||||
$this->assert->areNotEquivalent($post, $samePost);
|
||||
|
|
Loading…
Reference in a new issue