Last active
August 29, 2015 14:25
-
-
Save PifyZ/6f1de8589d67f5088129 to your computer and use it in GitHub Desktop.
API BMC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Vocabulaire des méthodes : | |
- get = obtenir | |
- set = définir | |
- add = ajouter | |
- remove = supprimer | |
- is = booléen | |
*/ | |
class Manager { | |
private $_pk = 'id'; | |
private $_tablename = false; | |
} | |
class Site extends Manager { | |
private $forumCategories = []; // List<ForumCategory> | |
private $articleCategories = []; // List<ArticleCategory> | |
private $users = []; // List<User> | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getForumCategories() { | |
return $this->forumCategories; | |
} | |
public function getArticleCategories() { | |
return $this->articleCategories; | |
} | |
public function getUsers() { | |
return $this->users; | |
} | |
/// Méthodes | |
public function addUser(User $user) { | |
$this->users[] = $user; | |
} | |
public function addForumCategory(ForumCategory $category) { | |
$this->forumCategories[] = $category; | |
} | |
public function addArticleCategory(ArticleCategory $category) { | |
$this->articleCategories[] = $category; | |
} | |
public function getById() { | |
return false; | |
} | |
public function all() { | |
return false; | |
} | |
public function filter() { | |
return $this; | |
} | |
} | |
class User extends Manager { | |
private $name = ''; // String | |
private $password = ''; // String | |
private $signature = ''; // String | |
private $permissions = []; // List<UserPermission> | |
private $dateRegister = null; // DateTime | |
private $dateLastActivity = null; // DateTime | |
private $banishments = []; // List<UserBanishment> | |
private $contacts = []; // List<User> | |
private $forumReadings = []; // Dict<ForumTopic, DateTime> | |
private $mailReadings = []; // Dict<ForumTopic, DateTime> | |
// à faire, trouver un meilleur fonctionnement pour les *Readings | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getName() { | |
return $this->name; | |
} | |
public function getPassword() { | |
return $this->password; | |
} | |
public function getSignature() { | |
return $this->signature; | |
} | |
public function getPermissions() { | |
return $this->permissions; | |
} | |
public function getDateRegister() { | |
return $this->dateRegister; | |
} | |
public function getDateLastActivity() { | |
return $this->dateLastActivity; | |
} | |
public function getBanishments() { | |
return $this->banishments; | |
} | |
public function getContacts() { | |
return $this->contacts; | |
} | |
public function getForumReadings() { | |
return $this->forumReadings; | |
} | |
public function getMailReadings() { | |
return $this->mailReadings; | |
} | |
/// Mutateurs | |
public function setName($name) { | |
$this->name = $name; | |
} | |
public function setPassword($password) { | |
$this->password = $password; // à faire : hasher le mdp | |
} | |
public function setSignature($signature) { | |
$this->signature = $signature; | |
} | |
public function setPermissions(array $permissions) { | |
$this->removePermissions(); // à faire : renommer clean ? autre ? | |
foreach ($permissions as $permission) | |
$this->addPermission($permission); | |
} | |
public function setDateLastActivity(DateTime $dateLastActivity) { | |
$this->dateLastActivity = $dateLastActivity; | |
} | |
/// Méthodes | |
public function addBanishment(UserBanishment $banishment) { | |
$this->banishments[] = $banishment; | |
} | |
public function removeBanishment(UserBanishment $banishment) { | |
// à faire | |
} | |
public function removeBanishments() { | |
// à faire : préférer faire $this->banishments = [] ? | |
foreach ($this->banishments as $banishment) | |
$this->removeBanishment($banishment); | |
} | |
public function addPermission(UserPermission $permission) { | |
$this->permissions[] = $permission; | |
} | |
public function removePermission(UserPermission $permission) { | |
// à faire | |
} | |
public function removePermissions() { | |
// à faire : préférer faire $this->permissions = [] ? | |
foreach ($this->permissions as $permission) | |
$this->removePermission($permission); | |
} | |
public function addContact(User $contact) { | |
$this->contacts[] = $contact; | |
} | |
public function removeContact(User $contact) { | |
// à faire | |
} | |
public function addForumReading(array $forumReading) { | |
$this->forumReadings[] = $forumReading; | |
} | |
public function removeForumReading(array $forumReading) { | |
// à faire | |
} | |
public function addMailReading(array $mailReading) { | |
$this->mailReadings[] = $mailReading; | |
} | |
public function removeMailReading(array $mailReading) { | |
// à faire | |
} | |
public function getCurrentBanishment() { | |
// à faire : récupérer le bannissement le plus contraignant (permissions minimales) | |
$now = new DateTime(); | |
foreach ($this->banishments as $banishment) | |
if ($now >= $banishment->getDateBegin() && $now <= $banishment->getDateEnd()) | |
return $banishment; // le premier bannissement qui respecte la condition | |
return null; | |
} | |
public function isBanished() { | |
return (bool) $this->getCurrentBanishment(); | |
} | |
} | |
// à faire : les permissions doivent être des listes ou un entier ? | |
abstract class UserPermission { | |
const POST_FLUX = 1; | |
const POST_FORUM = 2; | |
const POST_CHAT = 4; | |
const POST_TUTORIAL = 8; | |
const POST_MAIL = 16; | |
const MODERATOR = 32; | |
const ADMINISTRATOR = 64; | |
const SUPER_ADMINISTRATOR = 128; | |
} | |
class UserBanishment extends Manager { | |
private $user = null; // User | |
private $dateBegin = null; // DateTime | |
private $dateEnd = null; // DateTime | |
private $reason = ''; // String | |
private $permissions = []; // List<UserPermission> | |
private $banisher = null; // User | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getUser() { | |
return $this->user; | |
} | |
public function getDateBegin() { | |
return $this->dateBegin; | |
} | |
public function getDateEnd() { | |
return $this->dateEnd; | |
} | |
public function getReason() { | |
return $this->dateEnd; | |
} | |
public function getPermissions() { | |
return $this->permissions; | |
} | |
public function getBanisher() { | |
return $this->banisher; | |
} | |
/// Mutateurs | |
public function setUser(User $user) { | |
$this->user = $user; | |
} | |
public function setDateBegin(DateTime $date) { | |
$this->dateBegin = $date; | |
} | |
public function setDateEnd(DateTime $date) { | |
$this->dateEnd = $date; | |
} | |
public function setReason($reason) { | |
$this->reason = $reason; | |
} | |
public function setPermissions(array $permissions) { | |
$this->removePermissions(); | |
foreach ($permissions as $permission) | |
$this->addPermission($permission); | |
} | |
public function setBanisher(User $banisher) { | |
$this->banisher = $banisher; | |
} | |
/// Méthodes | |
public function addPermission(UserPermission $permission) { | |
$this->permissions[] = $permission; | |
} | |
public function removePermission(UserPermission $permission) { | |
// à faire | |
} | |
public function removePermissions() { | |
foreach ($this->permissions as $permission) | |
$this->removePermission($permission); | |
} | |
} | |
class ForumTopic extends Manager { | |
private $title = ''; // String | |
private $slug = ''; // String | |
private $locked = false; // Bool | |
private $pinned = false; // Bool | |
private $archived = false; // Bool | |
private $messages = []; // List<ForumMessage> | |
private $category = null; // ForumCategory | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getTitle() { | |
return $this->title; | |
} | |
public function getSlug() { | |
return $this->slug; | |
} | |
public function getMessages() { | |
return $this->messages; | |
} | |
public function getCategory() { | |
return $this->category; | |
} | |
/// Mutateurs | |
public function setTitle($title, $updateSlug = false) { | |
$this->title = $title; | |
if ($updateSlug) | |
$this->slug = 'à faire'; // à faire | |
} | |
public function setLocked($locked) { | |
$this->locked = (bool) $locked; | |
} | |
public function setPinned($pinned) { | |
$this->pinned = (bool) $pinned; | |
} | |
public function setArchived($archived) { | |
$this->archived = (bool) $archived; | |
} | |
public function setCategory($category) { | |
$this->category = $category; | |
} | |
/// Méthodes | |
public function addMessage(ForumMessage $message) { | |
$this->messages[] = $message; | |
} | |
public function removeMessage(ForumMessage $message) { | |
// à faire | |
} | |
public function removeMessages() { | |
foreach ($this->messages as $message) | |
$this->removeMessage($message); | |
} | |
public function isLocked() { | |
return $this->locked; | |
} | |
public function isPinned() { | |
return $this->pinned; | |
} | |
public function isArchived() { | |
return $this->archived; | |
} | |
} | |
class ForumMessage extends Manager { | |
private $author = null; // User | |
private $content = ''; // String | |
private $dateAdd = null; // DateTime | |
private $dateUpd = null; // DateTime | |
private $topic = null; // ForumTopic | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getAuthor() { | |
return $this->author; | |
} | |
public function getContent() { | |
return $this->content; | |
} | |
public function getDateAdd() { | |
return $this->dateAdd; | |
} | |
public function getDateUpd() { | |
return $this->dateUpd; | |
} | |
public function getTopic() { | |
return $this->topic; | |
} | |
/// Mutateurs | |
public function setAuthor(User $author) { | |
$this->author = $author; | |
$this->updateDateUpd(); | |
} | |
public function setContent($content) { | |
$this->content = $author; | |
$this->updateDateUpd(); | |
} | |
public function setTopic(ForumTopic $topic) { | |
$this->topic = $topic; | |
$this->updateDateUpd(); | |
} | |
/// Méthodes | |
private function updateDateUpd() { | |
$this->dateUpd = new DateTime(); | |
} | |
} | |
class ForumCategory extends Manager { | |
private $title = ''; // String | |
private $slug = ''; // String | |
private $topics = []; // List<ForumTopic> | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getTitle() { | |
return $this->title; | |
} | |
public function getSlug() { | |
return $this->slug; | |
} | |
public function getTopics() { | |
return $this->topics; | |
} | |
/// Mutateurs | |
public function setTitle($title, $updateSlug = false) { | |
$this->title = $title; | |
if ($updateSlug) | |
$this->slug = 'à faire'; // à faire | |
} | |
/// Méthodes | |
public function addTopic(ForumTopic $topic) { | |
$this->topics[] = $topic; | |
} | |
public function removeTopic(ForumTopic $topic) { | |
// à faire | |
} | |
public function removeTopics() { | |
foreach ($this->topics as $topic) | |
$this->removeTopic($topic); | |
} | |
} | |
class MailTopic extends Manager { | |
private $title = ''; // String | |
private $slug = ''; // String | |
private $messages = []; // List<MailMessage> | |
private $participants = []; // List<User> | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getTitle() { | |
return $this->title; | |
} | |
public function getSlug() { | |
return $this->slug; | |
} | |
public function getMessages() { | |
return $this->messages; | |
} | |
public function getParticipants() { | |
return $this->participants; | |
} | |
/// Mutateurs | |
public function setTitle($title, $updateSlug = false) { | |
$this->title = $title; | |
if ($updateSlug) | |
$this->slug = 'à faire'; // à faire | |
} | |
public function setParticipants(array $participants) { | |
$this->participants = $participants; | |
} | |
/// Méthodes | |
public function addMessage(ForumMessage $message) { | |
$this->messages[] = $message; | |
} | |
public function removeMessage(ForumMessage $message) { | |
// à faire | |
} | |
public function removeMessages() { | |
foreach ($this->messages as $message) | |
$this->addMessage($message); | |
} | |
public function addParticipant(User $user) { | |
$this->participants[] = $user; | |
} | |
public function removeParticipant(User $user) { | |
// à faire | |
} | |
public function removeParticipants() { | |
foreach ($this->participants as $participant) | |
$this->addParticipant($participant); | |
} | |
} | |
class MailMessage extends Manager { | |
private $content = ''; // String | |
private $dateAdd = null; // DateTime | |
private $author = null; // User | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getContent() { | |
return $this->content; | |
} | |
public function getDateAdd() { | |
return $this->dateAdd; | |
} | |
public function getAuthor() { | |
return $this->author; | |
} | |
/// Mutateurs | |
public function setContent($content) { | |
$this->content = $content; | |
} | |
public function setDateAdd(DateTime $date) { | |
$this->dateAdd = $date; | |
} | |
public function setAuthor(User $author) { | |
$this->author = $author; | |
} | |
} | |
class ChatMessage extends Manager { | |
private $author = null; // User | |
private $content = ''; // String | |
private $dateAdd = null; // DateTime | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getAuthor() { | |
return $this->author; | |
} | |
public function getContent() { | |
return $this->content; | |
} | |
public function getDateAdd() { | |
return $this->dateAdd; | |
} | |
/// Mutateurs | |
public function setAuthor(User $author) { | |
$this->author = $author; | |
} | |
public function setContent($content) { | |
$this->content = $content; | |
} | |
} | |
class Tutorial extends Manager { | |
private $title = ''; // String | |
private $slug = ''; // String | |
private $progression = 0; // Int [0..100] | |
private $visibility = TutorialVisibility::VISIBILITY_CLOSED; // TutorialVisibility | |
private $tags = []; // List<String> | |
private $content = ''; // String | |
private $dateAdd = null; // DateTime | |
private $dateUpd = null; // DateTime | |
private $contributors = []; // List<TutorialContributor> | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getTitle() { | |
return $this->title; | |
} | |
public function getSlug() { | |
return $this->slug; | |
} | |
public function getProgression() { | |
return $this->progression; | |
} | |
public function getVisibility() { | |
return $this->visibility; | |
} | |
public function getTags() { | |
return $this->tags; | |
} | |
public function getContent() { | |
return $this->content; | |
} | |
public function getDateAdd() { | |
return $this->dateAdd; | |
} | |
public function getDateUpd() { | |
return $this->dateUpd; | |
} | |
public function getContributors() { | |
return $this->contributors; | |
} | |
/// Mutateurs | |
public function setTitle($title, $updateSlug = false) { | |
$this->title = $title; | |
if ($updateSlug) | |
$this->slug = 'à faire'; // à faire | |
} | |
public function setProgression() { | |
$this->progression = $progression; | |
} | |
public function setVisibility($visibility) { | |
$this->visibility = $visibility; | |
} | |
public function setTags(array $tags) { | |
$this->removeTags(); | |
foreach ($tags as $tag) | |
$this->addTag($tag); | |
} | |
public function setContent($content) { | |
$this->content = $content; | |
} | |
public function setContributors(array $contributors) { | |
// à faire : à compléter | |
foreach ($contributors as $contributor) | |
$this->addContributor($contributor); | |
} | |
/// Méthodes | |
public function addContributor(TutorialContributor $contributor) { | |
$this->contributors[] = $contributor; | |
} | |
public function removeContributor(TutorialContributor $contributor) { | |
// à faire | |
} | |
public function removeContributors() { | |
foreach ($this->contributors as $contributor) | |
$this->removeContributor($contributor); | |
} | |
public function addTag($tag) { | |
$this->tags[] = $tag; | |
} | |
public function removeTag($tag) { | |
// à faire | |
} | |
public function removeTags() { | |
foreach ($this->tags as $tag) | |
$this->removeTag($tag); | |
} | |
} | |
abstract class TutorialVisibility { | |
const VISIBILITY_CLOSED = 0; | |
const VISIBILITY_SHARED = 1; | |
const VISIBILITY_BETA = 2; | |
const VISIBILITY_PUBLIC = 3; | |
} | |
class TutorialContributor extends Manager { | |
private $user = null; // User | |
private $permissions = []; // List<TutorialContributorPermission> | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getUser() { | |
return $this->user; | |
} | |
public function getPermissions() { | |
return $this->permissions; | |
} | |
/// Mutateurs | |
public function setUser(User $user) { | |
$this->user = $user; | |
} | |
public function setPermissions(array $permissions) { | |
$this->removePermissions(); | |
foreach ($this->permissions as $permission) | |
$this->addPermission($permission); | |
} | |
/// Méthodes | |
public function addPermission(TutorialContributorPermission $permission) { | |
$this->permissions[] = $permission; | |
} | |
public function removePermission(TutorialContributorPermission $permission) { | |
// à faire | |
} | |
public function removePermissions() { | |
foreach ($this->permissions as $permission) | |
$this->removePermission($permission); | |
} | |
} | |
abstract class TutorialContributorPermission { | |
const CAN_CHANGE_INFORMATIONS = 1; | |
const CAN_CHANGE_VISIBILITY = 2; | |
const CAN_MANAGE_CONTRIBUTORS = 4; | |
const IS_CREATOR = 8; | |
} | |
class ArticleCategory extends Manager { | |
private $title = ''; // String | |
private $slug = ''; // String | |
private $description = ''; // String | |
private $articles = []; // List<Article> | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getTitle() { | |
return $this->title; | |
} | |
public function getSlug() { | |
return $this->slug; | |
} | |
public function getDescription() { | |
return $this->description; | |
} | |
public function getArticles() { | |
return $this->articles; | |
} | |
/// Mutateurs | |
public function setTitle($title, $updateSlug = false) { | |
$this->title = $title; | |
if ($updateSlug) | |
$this->slug = 'à faire'; // à faire | |
} | |
public function setDescription($description) { | |
$this->description = $description; | |
} | |
/// Méthodes | |
public function addArticle(Article $article) { | |
$this->articles[] = $article; | |
} | |
public function removeArticle(Article $article) { | |
// à faire | |
} | |
} | |
class Article extends Manager { | |
private $author = null; // User | |
private $title = ''; // String | |
private $slug = ''; // String | |
private $content = ''; // String | |
private $dateAdd = null; // DateTime | |
private $tags = []; // List<String> | |
private $status = ArticleStatus::STATUS_DRAFT; // ArticleStatus | |
private $categories = []; // List<ArticleCategory> | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getAuthor() { | |
return $this->author; | |
} | |
public function getTitle() { | |
return $this->title; | |
} | |
public function getSlug() { | |
return $this->slug; | |
} | |
public function getContent() { | |
return $this->content; | |
} | |
public function getDateAdd() { | |
return $this->dateAdd; | |
} | |
public function getTags() { | |
return $this->tags; | |
} | |
public function getStatus() { | |
return $this->status; | |
} | |
public function getCategories() { | |
return $this->categories; | |
} | |
/// Mutateurs | |
public function setAuthor(User $author) { | |
$this->author = $author; | |
} | |
public function setTitle($title, $updateSlug = false) { | |
$this->title = $title; | |
if ($updateSlug) | |
$this->slug = 'à faire'; // à faire | |
} | |
public function setContent($content) { | |
$this->content = $content; | |
} | |
public function setTags(array $tags) { | |
$this->tags = $tags; | |
} | |
public function setStatus(ArticleStatus $status) { | |
$this->status = $status; | |
} | |
public function setCategories(array $categories) { | |
$this->categories = $categories; | |
} | |
/// Méthodes | |
public function addCategory(ArticleCategory $category) { | |
$this->categories[] = $category; | |
} | |
public function removeCategory(ArticleCategory $category) { | |
// à faire | |
} | |
} | |
abstract class ArticleStatus { | |
const STATUS_PRIVATE = 0; | |
const STATUS_UNPUBLISHED = 1; | |
const STATUS_PULISHED = 2; | |
} | |
class Notification extends Manager { | |
private $users = []; // List<User> | |
private $content = ''; // String | |
private $dateAdd = null; // DateTime | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getUsers() { | |
return $this->users; | |
} | |
public function getContent() { | |
return $this->content; | |
} | |
public function getDateAdd() { | |
return $this->dateAdd; | |
} | |
/// Mutateurs | |
public function setUsers($users) { | |
$this->users = $users; | |
} | |
public function setContent($content) { | |
$this->content = $content; | |
} | |
/// Méthodes | |
public function addUser(User $user) { | |
$this->users[] = $user; | |
} | |
public function removeUser(User $user) { | |
// à faire | |
} | |
} | |
class FluxMessage extends Manager { | |
private $author = null; // User | |
private $content = ''; // String | |
private $dateAdd = null; // DateTime | |
private $visibility = FluxMessageVisibility::VISIBILITY_PUBLIC; // FluxMessageVisibility | |
private $comments = []; // List<FluxMessageComment> | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getAuthor() { | |
return $this->author; | |
} | |
public function getContent() { | |
return $this->content; | |
} | |
public function getDateAdd() { | |
return $this->dateAdd; | |
} | |
public function getVisibility() { | |
return $this->visibility; | |
} | |
public function getComments() { | |
return $this->comments; | |
} | |
/// Mutateurs | |
public function setAuthor(User $author) { | |
$this->author = $author; | |
} | |
public function setContent($content) { | |
$this->content = $content; | |
} | |
public function setVisibility(FluxMessageVisibility $visibility) { | |
$this->visibility = $visibility; | |
} | |
public function setComments(array $comments) { | |
$this->comments = $comments; | |
} | |
/// Méthodes | |
public function addComment(FluxMessageComment $comment) { | |
$this->comments[] = $comment; | |
} | |
public function removeComment(FluxMessageComment $comment) { | |
// à faire | |
} | |
} | |
abstract class FluxMessageVisibility { | |
const VISIBILITY_FRIENDS = 0; | |
const VISIBILITY_PUBLIC = 1; | |
} | |
class FluxMessageComment extends Manager { | |
private $author = null; // User | |
private $content = ''; // String | |
private $dateAdd = null; // DateTime | |
private $message = null; // FluxMessage | |
public function __construct(array $values = []) { | |
foreach ($values as $key => $value) | |
if (property_exists($this, $key)) | |
$this->$key = $value; | |
} | |
/// Accesseurs | |
public function getAuthor() { | |
return $this->author; | |
} | |
public function getContent() { | |
return $this->content; | |
} | |
public function getDateAdd() { | |
return $this->dateAdd; | |
} | |
public function getMessage() { | |
return $this->message; | |
} | |
/// Mutateurs | |
public function setAuthor(User $author) { | |
$this->author = $author; | |
} | |
public function setContent($content) { | |
$this->content = $content; | |
} | |
public function setMessage(ForumMessage $message) { | |
$this->message = $message; | |
} | |
} | |
/// | |
/// Test | |
/// | |
$site = new Site(); | |
$user1 = new User([ 'name' => 'naemie' ]); | |
$site->addUser($user1); | |
$banishment1 = new UserBanishment([ | |
'dateBegin' => new DateTime('-1 week'), | |
'dateEnd' => new DateTime('+2 weeks') | |
]); | |
$user1->addBanishment($banishment1); | |
$category1 = new ForumCategory([ 'title' => 'Blabla' ]); | |
$site->addForumCategory($category1); | |
$topic1 = new ForumTopic([ 'title' => 'Bonjour à tous' ]); | |
$category1->addTopic($topic1); | |
$message1 = new ForumMessage([ 'author' => $user1, 'content' => 'Bonjour' ]); | |
$topic1->addMessage($message1); | |
$user2 = new User([ 'name' => 'booti' ]); | |
$site->addUser($user2); | |
var_dump($site->getUsers()[0]->isBanished()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment