repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
flarum/core | src/Group/Group.php | Group.hasPermission | public function hasPermission($permission)
{
if ($this->id == self::ADMINISTRATOR_ID) {
return true;
}
return $this->permissions->contains('permission', $permission);
} | php | public function hasPermission($permission)
{
if ($this->id == self::ADMINISTRATOR_ID) {
return true;
}
return $this->permissions->contains('permission', $permission);
} | [
"public",
"function",
"hasPermission",
"(",
"$",
"permission",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"id",
"==",
"self",
"::",
"ADMINISTRATOR_ID",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"permissions",
"->",
"contains",
"(",
... | Check whether the group has a certain permission.
@param string $permission
@return bool | [
"Check",
"whether",
"the",
"group",
"has",
"a",
"certain",
"permission",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Group/Group.php#L136-L143 | train |
flarum/core | src/User/RegistrationToken.php | RegistrationToken.generate | public static function generate(string $provider, string $identifier, array $attributes, array $payload)
{
$token = new static;
$token->token = str_random(40);
$token->provider = $provider;
$token->identifier = $identifier;
$token->user_attributes = $attributes;
$tok... | php | public static function generate(string $provider, string $identifier, array $attributes, array $payload)
{
$token = new static;
$token->token = str_random(40);
$token->provider = $provider;
$token->identifier = $identifier;
$token->user_attributes = $attributes;
$tok... | [
"public",
"static",
"function",
"generate",
"(",
"string",
"$",
"provider",
",",
"string",
"$",
"identifier",
",",
"array",
"$",
"attributes",
",",
"array",
"$",
"payload",
")",
"{",
"$",
"token",
"=",
"new",
"static",
";",
"$",
"token",
"->",
"token",
... | Generate an auth token for the specified user.
@param string $provider
@param string $identifier
@param array $attributes
@param array $payload
@return static | [
"Generate",
"an",
"auth",
"token",
"for",
"the",
"specified",
"user",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/User/RegistrationToken.php#L61-L73 | train |
flarum/core | src/Http/Middleware/DispatchRoute.php | DispatchRoute.process | public function process(Request $request, Handler $handler): Response
{
$method = $request->getMethod();
$uri = $request->getUri()->getPath() ?: '/';
$routeInfo = $this->getDispatcher()->dispatch($method, $uri);
switch ($routeInfo[0]) {
case Dispatcher::NOT_FOUND:
... | php | public function process(Request $request, Handler $handler): Response
{
$method = $request->getMethod();
$uri = $request->getUri()->getPath() ?: '/';
$routeInfo = $this->getDispatcher()->dispatch($method, $uri);
switch ($routeInfo[0]) {
case Dispatcher::NOT_FOUND:
... | [
"public",
"function",
"process",
"(",
"Request",
"$",
"request",
",",
"Handler",
"$",
"handler",
")",
":",
"Response",
"{",
"$",
"method",
"=",
"$",
"request",
"->",
"getMethod",
"(",
")",
";",
"$",
"uri",
"=",
"$",
"request",
"->",
"getUri",
"(",
")... | Dispatch the given request to our route collection.
@throws MethodNotAllowedException
@throws RouteNotFoundException | [
"Dispatch",
"the",
"given",
"request",
"to",
"our",
"route",
"collection",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Http/Middleware/DispatchRoute.php#L51-L69 | train |
flarum/core | src/Post/PostRepository.php | PostRepository.findOrFail | public function findOrFail($id, User $actor = null)
{
return $this->queryVisibleTo($actor)->findOrFail($id);
} | php | public function findOrFail($id, User $actor = null)
{
return $this->queryVisibleTo($actor)->findOrFail($id);
} | [
"public",
"function",
"findOrFail",
"(",
"$",
"id",
",",
"User",
"$",
"actor",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"queryVisibleTo",
"(",
"$",
"actor",
")",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"}"
] | Find a post by ID, optionally making sure it is visible to a certain
user, or throw an exception.
@param int $id
@param \Flarum\User\User $actor
@return \Flarum\Post\Post
@throws \Illuminate\Database\Eloquent\ModelNotFoundException | [
"Find",
"a",
"post",
"by",
"ID",
"optionally",
"making",
"sure",
"it",
"is",
"visible",
"to",
"a",
"certain",
"user",
"or",
"throw",
"an",
"exception",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Post/PostRepository.php#L55-L58 | train |
flarum/core | src/Post/PostRepository.php | PostRepository.findByIds | public function findByIds(array $ids, User $actor = null)
{
$posts = $this->queryIds($ids, $actor)->get();
$posts = $posts->sort(function ($a, $b) use ($ids) {
$aPos = array_search($a->id, $ids);
$bPos = array_search($b->id, $ids);
if ($aPos === $bPos) {
... | php | public function findByIds(array $ids, User $actor = null)
{
$posts = $this->queryIds($ids, $actor)->get();
$posts = $posts->sort(function ($a, $b) use ($ids) {
$aPos = array_search($a->id, $ids);
$bPos = array_search($b->id, $ids);
if ($aPos === $bPos) {
... | [
"public",
"function",
"findByIds",
"(",
"array",
"$",
"ids",
",",
"User",
"$",
"actor",
"=",
"null",
")",
"{",
"$",
"posts",
"=",
"$",
"this",
"->",
"queryIds",
"(",
"$",
"ids",
",",
"$",
"actor",
")",
"->",
"get",
"(",
")",
";",
"$",
"posts",
... | Find posts by their IDs, optionally making sure they are visible to a
certain user.
@param array $ids
@param \Flarum\User\User|null $actor
@return \Illuminate\Database\Eloquent\Collection | [
"Find",
"posts",
"by",
"their",
"IDs",
"optionally",
"making",
"sure",
"they",
"are",
"visible",
"to",
"a",
"certain",
"user",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Post/PostRepository.php#L93-L109 | train |
flarum/core | src/Post/PostRepository.php | PostRepository.filterVisibleIds | public function filterVisibleIds(array $ids, User $actor)
{
return $this->queryIds($ids, $actor)->pluck('posts.id')->all();
} | php | public function filterVisibleIds(array $ids, User $actor)
{
return $this->queryIds($ids, $actor)->pluck('posts.id')->all();
} | [
"public",
"function",
"filterVisibleIds",
"(",
"array",
"$",
"ids",
",",
"User",
"$",
"actor",
")",
"{",
"return",
"$",
"this",
"->",
"queryIds",
"(",
"$",
"ids",
",",
"$",
"actor",
")",
"->",
"pluck",
"(",
"'posts.id'",
")",
"->",
"all",
"(",
")",
... | Filter a list of post IDs to only include posts that are visible to a
certain user.
@param array $ids
@param User $actor
@return array | [
"Filter",
"a",
"list",
"of",
"post",
"IDs",
"to",
"only",
"include",
"posts",
"that",
"are",
"visible",
"to",
"a",
"certain",
"user",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Post/PostRepository.php#L119-L122 | train |
flarum/core | src/Post/PostRepository.php | PostRepository.getIndexForNumber | public function getIndexForNumber($discussionId, $number, User $actor = null)
{
$query = Discussion::find($discussionId)
->posts()
->whereVisibleTo($actor)
->where('created_at', '<', function ($query) use ($discussionId, $number) {
$query->select('created_... | php | public function getIndexForNumber($discussionId, $number, User $actor = null)
{
$query = Discussion::find($discussionId)
->posts()
->whereVisibleTo($actor)
->where('created_at', '<', function ($query) use ($discussionId, $number) {
$query->select('created_... | [
"public",
"function",
"getIndexForNumber",
"(",
"$",
"discussionId",
",",
"$",
"number",
",",
"User",
"$",
"actor",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"Discussion",
"::",
"find",
"(",
"$",
"discussionId",
")",
"->",
"posts",
"(",
")",
"->",
"whe... | Get the position within a discussion where a post with a certain number
is. If the post with that number does not exist, the index of the
closest post to it will be returned.
@param int $discussionId
@param int $number
@param \Flarum\User\User|null $actor
@return int | [
"Get",
"the",
"position",
"within",
"a",
"discussion",
"where",
"a",
"post",
"with",
"a",
"certain",
"number",
"is",
".",
"If",
"the",
"post",
"with",
"that",
"number",
"does",
"not",
"exist",
"the",
"index",
"of",
"the",
"closest",
"post",
"to",
"it",
... | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Post/PostRepository.php#L134-L152 | train |
flarum/core | src/User/SelfDemotionGuard.php | SelfDemotionGuard.handle | public function handle(Saving $event)
{
// Non-admin users pose no problem
if (! $event->actor->isAdmin()) {
return;
}
// Only admins can demote users, which means demoting other users is
// fine, because we still have at least one admin (the actor) left
... | php | public function handle(Saving $event)
{
// Non-admin users pose no problem
if (! $event->actor->isAdmin()) {
return;
}
// Only admins can demote users, which means demoting other users is
// fine, because we still have at least one admin (the actor) left
... | [
"public",
"function",
"handle",
"(",
"Saving",
"$",
"event",
")",
"{",
"// Non-admin users pose no problem",
"if",
"(",
"!",
"$",
"event",
"->",
"actor",
"->",
"isAdmin",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Only admins can demote users, which means demotin... | Prevent an admin from removing their admin permission via the API.
@param Saving $event
@throws PermissionDeniedException | [
"Prevent",
"an",
"admin",
"from",
"removing",
"their",
"admin",
"permission",
"via",
"the",
"API",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/User/SelfDemotionGuard.php#L25-L57 | train |
flarum/core | src/Search/GambitManager.php | GambitManager.apply | public function apply(AbstractSearch $search, $query)
{
$query = $this->applyGambits($search, $query);
if ($query) {
$this->applyFulltext($search, $query);
}
} | php | public function apply(AbstractSearch $search, $query)
{
$query = $this->applyGambits($search, $query);
if ($query) {
$this->applyFulltext($search, $query);
}
} | [
"public",
"function",
"apply",
"(",
"AbstractSearch",
"$",
"search",
",",
"$",
"query",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"applyGambits",
"(",
"$",
"search",
",",
"$",
"query",
")",
";",
"if",
"(",
"$",
"query",
")",
"{",
"$",
"this",... | Apply gambits to a search, given a search query.
@param AbstractSearch $search
@param string $query | [
"Apply",
"gambits",
"to",
"a",
"search",
"given",
"a",
"search",
"query",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Search/GambitManager.php#L61-L68 | train |
flarum/core | src/User/Guest.php | Guest.getGroupsAttribute | public function getGroupsAttribute()
{
if (! isset($this->attributes['groups'])) {
$this->attributes['groups'] = $this->relations['groups'] = Group::where('id', Group::GUEST_ID)->get();
}
return $this->attributes['groups'];
} | php | public function getGroupsAttribute()
{
if (! isset($this->attributes['groups'])) {
$this->attributes['groups'] = $this->relations['groups'] = Group::where('id', Group::GUEST_ID)->get();
}
return $this->attributes['groups'];
} | [
"public",
"function",
"getGroupsAttribute",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'groups'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'groups'",
"]",
"=",
"$",
"this",
"->",
"relations",
... | Get the guest's group, containing only the 'guests' group model.
@return \Flarum\Group\Group | [
"Get",
"the",
"guest",
"s",
"group",
"containing",
"only",
"the",
"guests",
"group",
"model",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/User/Guest.php#L30-L37 | train |
flarum/core | src/Foundation/Console/InfoCommand.php | InfoCommand.findPackageVersion | private function findPackageVersion($path, $fallback = null)
{
if (file_exists("$path/.git")) {
$cwd = getcwd();
chdir($path);
$output = [];
$status = null;
exec('git rev-parse HEAD 2>&1', $output, $status);
chdir($cwd);
... | php | private function findPackageVersion($path, $fallback = null)
{
if (file_exists("$path/.git")) {
$cwd = getcwd();
chdir($path);
$output = [];
$status = null;
exec('git rev-parse HEAD 2>&1', $output, $status);
chdir($cwd);
... | [
"private",
"function",
"findPackageVersion",
"(",
"$",
"path",
",",
"$",
"fallback",
"=",
"null",
")",
"{",
"if",
"(",
"file_exists",
"(",
"\"$path/.git\"",
")",
")",
"{",
"$",
"cwd",
"=",
"getcwd",
"(",
")",
";",
"chdir",
"(",
"$",
"path",
")",
";",... | Try to detect a package's exact version.
If the package seems to be a Git version, we extract the currently
checked out commit using the command line.
@param string $path
@param string $fallback
@return string | [
"Try",
"to",
"detect",
"a",
"package",
"s",
"exact",
"version",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Foundation/Console/InfoCommand.php#L111-L129 | train |
flarum/core | src/Discussion/UserState.php | UserState.read | public function read($number)
{
if ($number > $this->last_read_post_number) {
$this->last_read_post_number = $number;
$this->last_read_at = Carbon::now();
$this->raise(new UserRead($this));
}
return $this;
} | php | public function read($number)
{
if ($number > $this->last_read_post_number) {
$this->last_read_post_number = $number;
$this->last_read_at = Carbon::now();
$this->raise(new UserRead($this));
}
return $this;
} | [
"public",
"function",
"read",
"(",
"$",
"number",
")",
"{",
"if",
"(",
"$",
"number",
">",
"$",
"this",
"->",
"last_read_post_number",
")",
"{",
"$",
"this",
"->",
"last_read_post_number",
"=",
"$",
"number",
";",
"$",
"this",
"->",
"last_read_at",
"=",
... | Mark the discussion as being read up to a certain point. Raises the
DiscussionWasRead event.
@param int $number
@return $this | [
"Mark",
"the",
"discussion",
"as",
"being",
"read",
"up",
"to",
"a",
"certain",
"point",
".",
"Raises",
"the",
"DiscussionWasRead",
"event",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/UserState.php#L58-L68 | train |
flarum/core | src/Discussion/DiscussionRepository.php | DiscussionRepository.findOrFail | public function findOrFail($id, User $user = null)
{
$query = Discussion::where('id', $id);
return $this->scopeVisibleTo($query, $user)->firstOrFail();
} | php | public function findOrFail($id, User $user = null)
{
$query = Discussion::where('id', $id);
return $this->scopeVisibleTo($query, $user)->firstOrFail();
} | [
"public",
"function",
"findOrFail",
"(",
"$",
"id",
",",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"Discussion",
"::",
"where",
"(",
"'id'",
",",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"scopeVisibleTo",
"(",
"$",
"qu... | Find a discussion by ID, optionally making sure it is visible to a
certain user, or throw an exception.
@param int $id
@param User $user
@return \Flarum\Discussion\Discussion | [
"Find",
"a",
"discussion",
"by",
"ID",
"optionally",
"making",
"sure",
"it",
"is",
"visible",
"to",
"a",
"certain",
"user",
"or",
"throw",
"an",
"exception",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/DiscussionRepository.php#L37-L42 | train |
flarum/core | src/Discussion/DiscussionRepository.php | DiscussionRepository.getReadIds | public function getReadIds(User $user)
{
return Discussion::leftJoin('discussion_user', 'discussion_user.discussion_id', '=', 'discussions.id')
->where('discussion_user.user_id', $user->id)
->whereColumn('last_read_post_number', '>=', 'last_post_number')
->pluck('id')
... | php | public function getReadIds(User $user)
{
return Discussion::leftJoin('discussion_user', 'discussion_user.discussion_id', '=', 'discussions.id')
->where('discussion_user.user_id', $user->id)
->whereColumn('last_read_post_number', '>=', 'last_post_number')
->pluck('id')
... | [
"public",
"function",
"getReadIds",
"(",
"User",
"$",
"user",
")",
"{",
"return",
"Discussion",
"::",
"leftJoin",
"(",
"'discussion_user'",
",",
"'discussion_user.discussion_id'",
",",
"'='",
",",
"'discussions.id'",
")",
"->",
"where",
"(",
"'discussion_user.user_i... | Get the IDs of discussions which a user has read completely.
@param User $user
@return array | [
"Get",
"the",
"IDs",
"of",
"discussions",
"which",
"a",
"user",
"has",
"read",
"completely",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/DiscussionRepository.php#L50-L57 | train |
flarum/core | src/Http/UrlGenerator.php | UrlGenerator.addCollection | public function addCollection($key, RouteCollection $routes, $prefix = null)
{
$this->routes[$key] = new RouteCollectionUrlGenerator(
$this->app->url($prefix),
$routes
);
return $this;
} | php | public function addCollection($key, RouteCollection $routes, $prefix = null)
{
$this->routes[$key] = new RouteCollectionUrlGenerator(
$this->app->url($prefix),
$routes
);
return $this;
} | [
"public",
"function",
"addCollection",
"(",
"$",
"key",
",",
"RouteCollection",
"$",
"routes",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"$",
"key",
"]",
"=",
"new",
"RouteCollectionUrlGenerator",
"(",
"$",
"this",
"->"... | Register a named route collection for URL generation.
@param string $key
@param RouteCollection $routes
@param string $prefix
@return static | [
"Register",
"a",
"named",
"route",
"collection",
"for",
"URL",
"generation",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Http/UrlGenerator.php#L39-L47 | train |
flarum/core | src/Foundation/DispatchEventsTrait.php | DispatchEventsTrait.dispatchEventsFor | public function dispatchEventsFor($entity, User $actor = null)
{
foreach ($entity->releaseEvents() as $event) {
$event->actor = $actor;
$this->events->dispatch($event);
}
} | php | public function dispatchEventsFor($entity, User $actor = null)
{
foreach ($entity->releaseEvents() as $event) {
$event->actor = $actor;
$this->events->dispatch($event);
}
} | [
"public",
"function",
"dispatchEventsFor",
"(",
"$",
"entity",
",",
"User",
"$",
"actor",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"entity",
"->",
"releaseEvents",
"(",
")",
"as",
"$",
"event",
")",
"{",
"$",
"event",
"->",
"actor",
"=",
"$",
"act... | Dispatch all events for an entity.
@param object $entity
@param User $actor | [
"Dispatch",
"all",
"events",
"for",
"an",
"entity",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Foundation/DispatchEventsTrait.php#L30-L37 | train |
flarum/core | src/Notification/NotificationSyncer.php | NotificationSyncer.sync | public function sync(Blueprint\BlueprintInterface $blueprint, array $users)
{
$attributes = $this->getAttributes($blueprint);
// Find all existing notification records in the database matching this
// blueprint. We will begin by assuming that they all need to be
// deleted in order ... | php | public function sync(Blueprint\BlueprintInterface $blueprint, array $users)
{
$attributes = $this->getAttributes($blueprint);
// Find all existing notification records in the database matching this
// blueprint. We will begin by assuming that they all need to be
// deleted in order ... | [
"public",
"function",
"sync",
"(",
"Blueprint",
"\\",
"BlueprintInterface",
"$",
"blueprint",
",",
"array",
"$",
"users",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
"$",
"blueprint",
")",
";",
"// Find all existing notification re... | Sync a notification so that it is visible to the specified users, and not
visible to anyone else. If it is being made visible for the first time,
attempt to send the user an email.
@param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint
@param User[] $users
@return void | [
"Sync",
"a",
"notification",
"so",
"that",
"it",
"is",
"visible",
"to",
"the",
"specified",
"users",
"and",
"not",
"visible",
"to",
"anyone",
"else",
".",
"If",
"it",
"is",
"being",
"made",
"visible",
"for",
"the",
"first",
"time",
"attempt",
"to",
"send... | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Notification/NotificationSyncer.php#L72-L122 | train |
flarum/core | src/Notification/NotificationSyncer.php | NotificationSyncer.delete | public function delete(BlueprintInterface $blueprint)
{
Notification::where($this->getAttributes($blueprint))->update(['is_deleted' => true]);
} | php | public function delete(BlueprintInterface $blueprint)
{
Notification::where($this->getAttributes($blueprint))->update(['is_deleted' => true]);
} | [
"public",
"function",
"delete",
"(",
"BlueprintInterface",
"$",
"blueprint",
")",
"{",
"Notification",
"::",
"where",
"(",
"$",
"this",
"->",
"getAttributes",
"(",
"$",
"blueprint",
")",
")",
"->",
"update",
"(",
"[",
"'is_deleted'",
"=>",
"true",
"]",
")"... | Delete a notification for all users.
@param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint
@return void | [
"Delete",
"a",
"notification",
"for",
"all",
"users",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Notification/NotificationSyncer.php#L130-L133 | train |
flarum/core | src/Notification/NotificationSyncer.php | NotificationSyncer.restore | public function restore(BlueprintInterface $blueprint)
{
Notification::where($this->getAttributes($blueprint))->update(['is_deleted' => false]);
} | php | public function restore(BlueprintInterface $blueprint)
{
Notification::where($this->getAttributes($blueprint))->update(['is_deleted' => false]);
} | [
"public",
"function",
"restore",
"(",
"BlueprintInterface",
"$",
"blueprint",
")",
"{",
"Notification",
"::",
"where",
"(",
"$",
"this",
"->",
"getAttributes",
"(",
"$",
"blueprint",
")",
")",
"->",
"update",
"(",
"[",
"'is_deleted'",
"=>",
"false",
"]",
"... | Restore a notification for all users.
@param BlueprintInterface $blueprint
@return void | [
"Restore",
"a",
"notification",
"for",
"all",
"users",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Notification/NotificationSyncer.php#L141-L144 | train |
flarum/core | src/Notification/NotificationSyncer.php | NotificationSyncer.mailNotifications | protected function mailNotifications(MailableInterface $blueprint, array $recipients)
{
foreach ($recipients as $user) {
if ($user->shouldEmail($blueprint::getType())) {
$this->mailer->send($blueprint, $user);
}
}
} | php | protected function mailNotifications(MailableInterface $blueprint, array $recipients)
{
foreach ($recipients as $user) {
if ($user->shouldEmail($blueprint::getType())) {
$this->mailer->send($blueprint, $user);
}
}
} | [
"protected",
"function",
"mailNotifications",
"(",
"MailableInterface",
"$",
"blueprint",
",",
"array",
"$",
"recipients",
")",
"{",
"foreach",
"(",
"$",
"recipients",
"as",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"shouldEmail",
"(",
"$",
"blu... | Mail a notification to a list of users.
@param MailableInterface $blueprint
@param User[] $recipients | [
"Mail",
"a",
"notification",
"to",
"a",
"list",
"of",
"users",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Notification/NotificationSyncer.php#L198-L205 | train |
flarum/core | src/Notification/NotificationSyncer.php | NotificationSyncer.getAttributes | protected function getAttributes(Blueprint\BlueprintInterface $blueprint)
{
return [
'type' => $blueprint::getType(),
'from_user_id' => ($fromUser = $blueprint->getFromUser()) ? $fromUser->id : null,
'subject_id' => ($subject = $blueprint->getSubject()) ? $subject->id : n... | php | protected function getAttributes(Blueprint\BlueprintInterface $blueprint)
{
return [
'type' => $blueprint::getType(),
'from_user_id' => ($fromUser = $blueprint->getFromUser()) ? $fromUser->id : null,
'subject_id' => ($subject = $blueprint->getSubject()) ? $subject->id : n... | [
"protected",
"function",
"getAttributes",
"(",
"Blueprint",
"\\",
"BlueprintInterface",
"$",
"blueprint",
")",
"{",
"return",
"[",
"'type'",
"=>",
"$",
"blueprint",
"::",
"getType",
"(",
")",
",",
"'from_user_id'",
"=>",
"(",
"$",
"fromUser",
"=",
"$",
"blue... | Construct an array of attributes to be stored in a notification record in
the database, given a notification blueprint.
@param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint
@return array | [
"Construct",
"an",
"array",
"of",
"attributes",
"to",
"be",
"stored",
"in",
"a",
"notification",
"record",
"in",
"the",
"database",
"given",
"a",
"notification",
"blueprint",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Notification/NotificationSyncer.php#L225-L233 | train |
flarum/core | src/Extension/ExtensionManager.php | ExtensionManager.enable | public function enable($name)
{
if ($this->isEnabled($name)) {
return;
}
$extension = $this->getExtension($name);
$this->dispatcher->dispatch(new Enabling($extension));
$enabled = $this->getEnabled();
$enabled[] = $name;
$this->migrate($extens... | php | public function enable($name)
{
if ($this->isEnabled($name)) {
return;
}
$extension = $this->getExtension($name);
$this->dispatcher->dispatch(new Enabling($extension));
$enabled = $this->getEnabled();
$enabled[] = $name;
$this->migrate($extens... | [
"public",
"function",
"enable",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
"(",
"$",
"name",
")",
")",
"{",
"return",
";",
"}",
"$",
"extension",
"=",
"$",
"this",
"->",
"getExtension",
"(",
"$",
"name",
")",
";",
"$",... | Enables the extension.
@param string $name | [
"Enables",
"the",
"extension",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/ExtensionManager.php#L113-L136 | train |
flarum/core | src/Extension/ExtensionManager.php | ExtensionManager.disable | public function disable($name)
{
$enabled = $this->getEnabled();
if (($k = array_search($name, $enabled)) === false) {
return;
}
$extension = $this->getExtension($name);
$this->dispatcher->dispatch(new Disabling($extension));
unset($enabled[$k]);
... | php | public function disable($name)
{
$enabled = $this->getEnabled();
if (($k = array_search($name, $enabled)) === false) {
return;
}
$extension = $this->getExtension($name);
$this->dispatcher->dispatch(new Disabling($extension));
unset($enabled[$k]);
... | [
"public",
"function",
"disable",
"(",
"$",
"name",
")",
"{",
"$",
"enabled",
"=",
"$",
"this",
"->",
"getEnabled",
"(",
")",
";",
"if",
"(",
"(",
"$",
"k",
"=",
"array_search",
"(",
"$",
"name",
",",
"$",
"enabled",
")",
")",
"===",
"false",
")",... | Disables an extension.
@param string $name | [
"Disables",
"an",
"extension",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/ExtensionManager.php#L143-L162 | train |
flarum/core | src/Extension/ExtensionManager.php | ExtensionManager.uninstall | public function uninstall($name)
{
$extension = $this->getExtension($name);
$this->disable($name);
$this->migrateDown($extension);
$this->unpublishAssets($extension);
$extension->setInstalled(false);
$this->dispatcher->dispatch(new Uninstalled($extension));
} | php | public function uninstall($name)
{
$extension = $this->getExtension($name);
$this->disable($name);
$this->migrateDown($extension);
$this->unpublishAssets($extension);
$extension->setInstalled(false);
$this->dispatcher->dispatch(new Uninstalled($extension));
} | [
"public",
"function",
"uninstall",
"(",
"$",
"name",
")",
"{",
"$",
"extension",
"=",
"$",
"this",
"->",
"getExtension",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"disable",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"migrateDown",
"(",
"$... | Uninstalls an extension.
@param string $name | [
"Uninstalls",
"an",
"extension",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/ExtensionManager.php#L169-L182 | train |
flarum/core | src/Extension/ExtensionManager.php | ExtensionManager.publishAssets | protected function publishAssets(Extension $extension)
{
if ($extension->hasAssets()) {
$this->filesystem->copyDirectory(
$extension->getPath().'/assets',
$this->app->publicPath().'/assets/extensions/'.$extension->getId()
);
}
} | php | protected function publishAssets(Extension $extension)
{
if ($extension->hasAssets()) {
$this->filesystem->copyDirectory(
$extension->getPath().'/assets',
$this->app->publicPath().'/assets/extensions/'.$extension->getId()
);
}
} | [
"protected",
"function",
"publishAssets",
"(",
"Extension",
"$",
"extension",
")",
"{",
"if",
"(",
"$",
"extension",
"->",
"hasAssets",
"(",
")",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"copyDirectory",
"(",
"$",
"extension",
"->",
"getPath",
"(",... | Copy the assets from an extension's assets directory into public view.
@param Extension $extension | [
"Copy",
"the",
"assets",
"from",
"an",
"extension",
"s",
"assets",
"directory",
"into",
"public",
"view",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/ExtensionManager.php#L189-L197 | train |
flarum/core | src/Extension/ExtensionManager.php | ExtensionManager.unpublishAssets | protected function unpublishAssets(Extension $extension)
{
$this->filesystem->deleteDirectory($this->app->publicPath().'/assets/extensions/'.$extension->getId());
} | php | protected function unpublishAssets(Extension $extension)
{
$this->filesystem->deleteDirectory($this->app->publicPath().'/assets/extensions/'.$extension->getId());
} | [
"protected",
"function",
"unpublishAssets",
"(",
"Extension",
"$",
"extension",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"deleteDirectory",
"(",
"$",
"this",
"->",
"app",
"->",
"publicPath",
"(",
")",
".",
"'/assets/extensions/'",
".",
"$",
"extension"... | Delete an extension's assets from public view.
@param Extension $extension | [
"Delete",
"an",
"extension",
"s",
"assets",
"from",
"public",
"view",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/ExtensionManager.php#L204-L207 | train |
flarum/core | src/Extension/ExtensionManager.php | ExtensionManager.getAsset | public function getAsset(Extension $extension, $path)
{
return $this->app->publicPath().'/assets/extensions/'.$extension->getId().$path;
} | php | public function getAsset(Extension $extension, $path)
{
return $this->app->publicPath().'/assets/extensions/'.$extension->getId().$path;
} | [
"public",
"function",
"getAsset",
"(",
"Extension",
"$",
"extension",
",",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"->",
"publicPath",
"(",
")",
".",
"'/assets/extensions/'",
".",
"$",
"extension",
"->",
"getId",
"(",
")",
".",
"$",
... | Get the path to an extension's published asset.
@param Extension $extension
@param string $path
@return string | [
"Get",
"the",
"path",
"to",
"an",
"extension",
"s",
"published",
"asset",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/ExtensionManager.php#L216-L219 | train |
flarum/core | src/Extension/ExtensionManager.php | ExtensionManager.migrate | public function migrate(Extension $extension, $direction = 'up')
{
$this->app->bind('Illuminate\Database\Schema\Builder', function ($container) {
return $container->make('Illuminate\Database\ConnectionInterface')->getSchemaBuilder();
});
$extension->migrate($this->migrator, $dir... | php | public function migrate(Extension $extension, $direction = 'up')
{
$this->app->bind('Illuminate\Database\Schema\Builder', function ($container) {
return $container->make('Illuminate\Database\ConnectionInterface')->getSchemaBuilder();
});
$extension->migrate($this->migrator, $dir... | [
"public",
"function",
"migrate",
"(",
"Extension",
"$",
"extension",
",",
"$",
"direction",
"=",
"'up'",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'Illuminate\\Database\\Schema\\Builder'",
",",
"function",
"(",
"$",
"container",
")",
"{",
"retu... | Runs the database migrations for the extension.
@param Extension $extension
@param string $direction
@return void | [
"Runs",
"the",
"database",
"migrations",
"for",
"the",
"extension",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/ExtensionManager.php#L228-L235 | train |
flarum/core | src/Extension/ExtensionManager.php | ExtensionManager.getEnabledExtensions | public function getEnabledExtensions()
{
$enabled = [];
$extensions = $this->getExtensions();
foreach ($this->getEnabled() as $id) {
if (isset($extensions[$id])) {
$enabled[$id] = $extensions[$id];
}
}
return $enabled;
} | php | public function getEnabledExtensions()
{
$enabled = [];
$extensions = $this->getExtensions();
foreach ($this->getEnabled() as $id) {
if (isset($extensions[$id])) {
$enabled[$id] = $extensions[$id];
}
}
return $enabled;
} | [
"public",
"function",
"getEnabledExtensions",
"(",
")",
"{",
"$",
"enabled",
"=",
"[",
"]",
";",
"$",
"extensions",
"=",
"$",
"this",
"->",
"getExtensions",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getEnabled",
"(",
")",
"as",
"$",
"id",
")... | Get only enabled extensions.
@return array | [
"Get",
"only",
"enabled",
"extensions",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/ExtensionManager.php#L263-L275 | train |
flarum/core | src/Extension/ExtensionManager.php | ExtensionManager.extend | public function extend(Container $app)
{
foreach ($this->getEnabledExtensions() as $extension) {
$extension->extend($app);
}
} | php | public function extend(Container $app)
{
foreach ($this->getEnabledExtensions() as $extension) {
$extension->extend($app);
}
} | [
"public",
"function",
"extend",
"(",
"Container",
"$",
"app",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getEnabledExtensions",
"(",
")",
"as",
"$",
"extension",
")",
"{",
"$",
"extension",
"->",
"extend",
"(",
"$",
"app",
")",
";",
"}",
"}"
] | Call on all enabled extensions to extend the Flarum application.
@param Container $app | [
"Call",
"on",
"all",
"enabled",
"extensions",
"to",
"extend",
"the",
"Flarum",
"application",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/ExtensionManager.php#L282-L287 | train |
flarum/core | src/Extension/ExtensionManager.php | ExtensionManager.setEnabled | protected function setEnabled(array $enabled)
{
$enabled = array_values(array_unique($enabled));
$this->config->set('extensions_enabled', json_encode($enabled));
} | php | protected function setEnabled(array $enabled)
{
$enabled = array_values(array_unique($enabled));
$this->config->set('extensions_enabled', json_encode($enabled));
} | [
"protected",
"function",
"setEnabled",
"(",
"array",
"$",
"enabled",
")",
"{",
"$",
"enabled",
"=",
"array_values",
"(",
"array_unique",
"(",
"$",
"enabled",
")",
")",
";",
"$",
"this",
"->",
"config",
"->",
"set",
"(",
"'extensions_enabled'",
",",
"json_e... | Persist the currently enabled extensions.
@param array $enabled | [
"Persist",
"the",
"currently",
"enabled",
"extensions",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/ExtensionManager.php#L304-L309 | train |
flarum/core | src/Event/ConfigureLocales.php | ConfigureLocales.loadLanguagePackFrom | public function loadLanguagePackFrom($directory)
{
$name = $title = basename($directory);
if (file_exists($manifest = $directory.'/composer.json')) {
$json = json_decode(file_get_contents($manifest), true);
if (empty($json)) {
throw new RuntimeException("Err... | php | public function loadLanguagePackFrom($directory)
{
$name = $title = basename($directory);
if (file_exists($manifest = $directory.'/composer.json')) {
$json = json_decode(file_get_contents($manifest), true);
if (empty($json)) {
throw new RuntimeException("Err... | [
"public",
"function",
"loadLanguagePackFrom",
"(",
"$",
"directory",
")",
"{",
"$",
"name",
"=",
"$",
"title",
"=",
"basename",
"(",
"$",
"directory",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"manifest",
"=",
"$",
"directory",
".",
"'/composer.json'",... | Load language pack resources from the given directory.
@param string $directory | [
"Load",
"language",
"pack",
"resources",
"from",
"the",
"given",
"directory",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Event/ConfigureLocales.php#L41-L79 | train |
flarum/core | src/Console/Event/Configuring.php | Configuring.addCommand | public function addCommand($command)
{
if (is_string($command)) {
$command = $this->app->make($command);
}
if ($command instanceof Command) {
$command->setLaravel($this->app);
}
$this->console->add($command);
} | php | public function addCommand($command)
{
if (is_string($command)) {
$command = $this->app->make($command);
}
if ($command instanceof Command) {
$command->setLaravel($this->app);
}
$this->console->add($command);
} | [
"public",
"function",
"addCommand",
"(",
"$",
"command",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"command",
")",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"$",
"command",
")",
";",
"}",
"if",
"(",
"$",
"comma... | Add a console command to the flarum binary.
@param Command|string $command | [
"Add",
"a",
"console",
"command",
"to",
"the",
"flarum",
"binary",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Console/Event/Configuring.php#L50-L61 | train |
flarum/core | src/Discussion/Discussion.php | Discussion.start | public static function start($title, User $user)
{
$discussion = new static;
$discussion->title = $title;
$discussion->created_at = Carbon::now();
$discussion->user_id = $user->id;
$discussion->setRelation('user', $user);
$discussion->raise(new Started($discussion)... | php | public static function start($title, User $user)
{
$discussion = new static;
$discussion->title = $title;
$discussion->created_at = Carbon::now();
$discussion->user_id = $user->id;
$discussion->setRelation('user', $user);
$discussion->raise(new Started($discussion)... | [
"public",
"static",
"function",
"start",
"(",
"$",
"title",
",",
"User",
"$",
"user",
")",
"{",
"$",
"discussion",
"=",
"new",
"static",
";",
"$",
"discussion",
"->",
"title",
"=",
"$",
"title",
";",
"$",
"discussion",
"->",
"created_at",
"=",
"Carbon"... | Start a new discussion. Raises the DiscussionWasStarted event.
@param string $title
@param User $user
@return static | [
"Start",
"a",
"new",
"discussion",
".",
"Raises",
"the",
"DiscussionWasStarted",
"event",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/Discussion.php#L129-L142 | train |
flarum/core | src/Discussion/Discussion.php | Discussion.rename | public function rename($title)
{
if ($this->title !== $title) {
$oldTitle = $this->title;
$this->title = $title;
$this->raise(new Renamed($this, $oldTitle));
}
return $this;
} | php | public function rename($title)
{
if ($this->title !== $title) {
$oldTitle = $this->title;
$this->title = $title;
$this->raise(new Renamed($this, $oldTitle));
}
return $this;
} | [
"public",
"function",
"rename",
"(",
"$",
"title",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"title",
"!==",
"$",
"title",
")",
"{",
"$",
"oldTitle",
"=",
"$",
"this",
"->",
"title",
";",
"$",
"this",
"->",
"title",
"=",
"$",
"title",
";",
"$",
"... | Rename the discussion. Raises the DiscussionWasRenamed event.
@param string $title
@return $this | [
"Rename",
"the",
"discussion",
".",
"Raises",
"the",
"DiscussionWasRenamed",
"event",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/Discussion.php#L150-L160 | train |
flarum/core | src/Discussion/Discussion.php | Discussion.hide | public function hide(User $actor = null)
{
if (! $this->hidden_at) {
$this->hidden_at = Carbon::now();
$this->hidden_user_id = $actor ? $actor->id : null;
$this->raise(new Hidden($this));
}
return $this;
} | php | public function hide(User $actor = null)
{
if (! $this->hidden_at) {
$this->hidden_at = Carbon::now();
$this->hidden_user_id = $actor ? $actor->id : null;
$this->raise(new Hidden($this));
}
return $this;
} | [
"public",
"function",
"hide",
"(",
"User",
"$",
"actor",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hidden_at",
")",
"{",
"$",
"this",
"->",
"hidden_at",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"$",
"this",
"->",
"hidden_user_id"... | Hide the discussion.
@param User $actor
@return $this | [
"Hide",
"the",
"discussion",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/Discussion.php#L168-L178 | train |
flarum/core | src/Discussion/Discussion.php | Discussion.restore | public function restore()
{
if ($this->hidden_at !== null) {
$this->hidden_at = null;
$this->hidden_user_id = null;
$this->raise(new Restored($this));
}
return $this;
} | php | public function restore()
{
if ($this->hidden_at !== null) {
$this->hidden_at = null;
$this->hidden_user_id = null;
$this->raise(new Restored($this));
}
return $this;
} | [
"public",
"function",
"restore",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hidden_at",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"hidden_at",
"=",
"null",
";",
"$",
"this",
"->",
"hidden_user_id",
"=",
"null",
";",
"$",
"this",
"->",
"raise",
... | Restore the discussion.
@return $this | [
"Restore",
"the",
"discussion",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/Discussion.php#L185-L195 | train |
flarum/core | src/Discussion/Discussion.php | Discussion.setFirstPost | public function setFirstPost(Post $post)
{
$this->created_at = $post->created_at;
$this->user_id = $post->user_id;
$this->first_post_id = $post->id;
return $this;
} | php | public function setFirstPost(Post $post)
{
$this->created_at = $post->created_at;
$this->user_id = $post->user_id;
$this->first_post_id = $post->id;
return $this;
} | [
"public",
"function",
"setFirstPost",
"(",
"Post",
"$",
"post",
")",
"{",
"$",
"this",
"->",
"created_at",
"=",
"$",
"post",
"->",
"created_at",
";",
"$",
"this",
"->",
"user_id",
"=",
"$",
"post",
"->",
"user_id",
";",
"$",
"this",
"->",
"first_post_i... | Set the discussion's first post details.
@param Post $post
@return $this | [
"Set",
"the",
"discussion",
"s",
"first",
"post",
"details",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/Discussion.php#L203-L210 | train |
flarum/core | src/Discussion/Discussion.php | Discussion.setLastPost | public function setLastPost(Post $post)
{
$this->last_posted_at = $post->created_at;
$this->last_posted_user_id = $post->user_id;
$this->last_post_id = $post->id;
$this->last_post_number = $post->number;
return $this;
} | php | public function setLastPost(Post $post)
{
$this->last_posted_at = $post->created_at;
$this->last_posted_user_id = $post->user_id;
$this->last_post_id = $post->id;
$this->last_post_number = $post->number;
return $this;
} | [
"public",
"function",
"setLastPost",
"(",
"Post",
"$",
"post",
")",
"{",
"$",
"this",
"->",
"last_posted_at",
"=",
"$",
"post",
"->",
"created_at",
";",
"$",
"this",
"->",
"last_posted_user_id",
"=",
"$",
"post",
"->",
"user_id",
";",
"$",
"this",
"->",
... | Set the discussion's last post details.
@param Post $post
@return $this | [
"Set",
"the",
"discussion",
"s",
"last",
"post",
"details",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/Discussion.php#L218-L226 | train |
flarum/core | src/Discussion/Discussion.php | Discussion.refreshLastPost | public function refreshLastPost()
{
/** @var Post $lastPost */
if ($lastPost = $this->comments()->latest()->first()) {
$this->setLastPost($lastPost);
}
return $this;
} | php | public function refreshLastPost()
{
/** @var Post $lastPost */
if ($lastPost = $this->comments()->latest()->first()) {
$this->setLastPost($lastPost);
}
return $this;
} | [
"public",
"function",
"refreshLastPost",
"(",
")",
"{",
"/** @var Post $lastPost */",
"if",
"(",
"$",
"lastPost",
"=",
"$",
"this",
"->",
"comments",
"(",
")",
"->",
"latest",
"(",
")",
"->",
"first",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setLastPost",... | Refresh a discussion's last post details.
@return $this | [
"Refresh",
"a",
"discussion",
"s",
"last",
"post",
"details",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/Discussion.php#L233-L241 | train |
flarum/core | src/Discussion/Discussion.php | Discussion.mergePost | public function mergePost(MergeableInterface $post)
{
$lastPost = $this->posts()->latest()->first();
$post = $post->saveAfter($lastPost);
return $this->modifiedPosts[] = $post;
} | php | public function mergePost(MergeableInterface $post)
{
$lastPost = $this->posts()->latest()->first();
$post = $post->saveAfter($lastPost);
return $this->modifiedPosts[] = $post;
} | [
"public",
"function",
"mergePost",
"(",
"MergeableInterface",
"$",
"post",
")",
"{",
"$",
"lastPost",
"=",
"$",
"this",
"->",
"posts",
"(",
")",
"->",
"latest",
"(",
")",
"->",
"first",
"(",
")",
";",
"$",
"post",
"=",
"$",
"post",
"->",
"saveAfter",... | Save a post, attempting to merge it with the discussion's last post.
The merge logic is delegated to the new post. (As an example, a
DiscussionRenamedPost will merge if adjacent to another
DiscussionRenamedPost, and delete if the title has been reverted
completely.)
@param \Flarum\Post\MergeableInterface $post The po... | [
"Save",
"a",
"post",
"attempting",
"to",
"merge",
"it",
"with",
"the",
"discussion",
"s",
"last",
"post",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/Discussion.php#L280-L287 | train |
flarum/core | src/Discussion/Discussion.php | Discussion.state | public function state(User $user = null)
{
$user = $user ?: static::$stateUser;
return $this->hasOne(UserState::class)->where('user_id', $user ? $user->id : null);
} | php | public function state(User $user = null)
{
$user = $user ?: static::$stateUser;
return $this->hasOne(UserState::class)->where('user_id', $user ? $user->id : null);
} | [
"public",
"function",
"state",
"(",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"user",
"=",
"$",
"user",
"?",
":",
"static",
"::",
"$",
"stateUser",
";",
"return",
"$",
"this",
"->",
"hasOne",
"(",
"UserState",
"::",
"class",
")",
"->",
"wher... | Define the relationship with the discussion's state for a particular
user.
If no user is passed (i.e. in the case of eager loading the 'state'
relation), then the static `$stateUser` property is used.
@see Discussion::setStateUser()
@param User|null $user
@return \Illuminate\Database\Eloquent\Relations\HasOne | [
"Define",
"the",
"relationship",
"with",
"the",
"discussion",
"s",
"state",
"for",
"a",
"particular",
"user",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/Discussion.php#L410-L415 | train |
flarum/core | src/Discussion/Discussion.php | Discussion.setTitleAttribute | protected function setTitleAttribute($title)
{
$this->attributes['title'] = $title;
$this->slug = Str::slug($title);
} | php | protected function setTitleAttribute($title)
{
$this->attributes['title'] = $title;
$this->slug = Str::slug($title);
} | [
"protected",
"function",
"setTitleAttribute",
"(",
"$",
"title",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'title'",
"]",
"=",
"$",
"title",
";",
"$",
"this",
"->",
"slug",
"=",
"Str",
"::",
"slug",
"(",
"$",
"title",
")",
";",
"}"
] | Set the discussion title.
This automatically creates a matching slug for the discussion.
@param string $title | [
"Set",
"the",
"discussion",
"title",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Discussion/Discussion.php#L454-L458 | train |
flarum/core | src/Database/AbstractModel.php | AbstractModel.getAttribute | public function getAttribute($key)
{
if (! is_null($value = parent::getAttribute($key))) {
return $value;
}
// If a custom relation with this key has been set up, then we will load
// and return results from the query and hydrate the relationship's
// value on th... | php | public function getAttribute($key)
{
if (! is_null($value = parent::getAttribute($key))) {
return $value;
}
// If a custom relation with this key has been set up, then we will load
// and return results from the query and hydrate the relationship's
// value on th... | [
"public",
"function",
"getAttribute",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"value",
"=",
"parent",
"::",
"getAttribute",
"(",
"$",
"key",
")",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"// If a custom relation with this ... | Get an attribute from the model. If nothing is found, attempt to load
a custom relation method with this key.
@param string $key
@return mixed | [
"Get",
"an",
"attribute",
"from",
"the",
"model",
".",
"If",
"nothing",
"is",
"found",
"attempt",
"to",
"load",
"a",
"custom",
"relation",
"method",
"with",
"this",
"key",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Database/AbstractModel.php#L116-L134 | train |
flarum/core | src/Database/MigrationCreator.php | MigrationCreator.create | public function create($name, $extension = null, $table = null, $create = false)
{
$migrationPath = $this->getMigrationPath($extension);
$path = $this->getPath($name, $migrationPath);
$stub = $this->getStub($table, $create);
$this->files->put($path, $this->populateStub($stub, $tab... | php | public function create($name, $extension = null, $table = null, $create = false)
{
$migrationPath = $this->getMigrationPath($extension);
$path = $this->getPath($name, $migrationPath);
$stub = $this->getStub($table, $create);
$this->files->put($path, $this->populateStub($stub, $tab... | [
"public",
"function",
"create",
"(",
"$",
"name",
",",
"$",
"extension",
"=",
"null",
",",
"$",
"table",
"=",
"null",
",",
"$",
"create",
"=",
"false",
")",
"{",
"$",
"migrationPath",
"=",
"$",
"this",
"->",
"getMigrationPath",
"(",
"$",
"extension",
... | Create a new migration for the given extension.
@param string $name
@param Extension $extension
@param string $table
@param bool $create
@return string | [
"Create",
"a",
"new",
"migration",
"for",
"the",
"given",
"extension",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Database/MigrationCreator.php#L52-L63 | train |
flarum/core | src/Console/AbstractCommand.php | AbstractCommand.error | protected function error($message)
{
if ($this->output instanceof ConsoleOutputInterface) {
$this->output->getErrorOutput()->writeln("<error>$message</error>");
} else {
$this->output->writeln("<error>$message</error>");
}
} | php | protected function error($message)
{
if ($this->output instanceof ConsoleOutputInterface) {
$this->output->getErrorOutput()->writeln("<error>$message</error>");
} else {
$this->output->writeln("<error>$message</error>");
}
} | [
"protected",
"function",
"error",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"output",
"instanceof",
"ConsoleOutputInterface",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"getErrorOutput",
"(",
")",
"->",
"writeln",
"(",
"\"<error>$message... | Send an error or warning message to the user.
If possible, this will send the message via STDERR.
@param string $message | [
"Send",
"an",
"error",
"or",
"warning",
"message",
"to",
"the",
"user",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Console/AbstractCommand.php#L75-L82 | train |
flarum/core | src/Post/Post.php | Post.isVisibleTo | public function isVisibleTo(User $user)
{
return (bool) $this->newQuery()->whereVisibleTo($user)->find($this->id);
} | php | public function isVisibleTo(User $user)
{
return (bool) $this->newQuery()->whereVisibleTo($user)->find($this->id);
} | [
"public",
"function",
"isVisibleTo",
"(",
"User",
"$",
"user",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"newQuery",
"(",
")",
"->",
"whereVisibleTo",
"(",
"$",
"user",
")",
"->",
"find",
"(",
"$",
"this",
"->",
"id",
")",
";",
"}"
] | Determine whether or not this post is visible to the given user.
@param User $user
@return bool | [
"Determine",
"whether",
"or",
"not",
"this",
"post",
"is",
"visible",
"to",
"the",
"given",
"user",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Post/Post.php#L122-L125 | train |
flarum/core | src/Post/Post.php | Post.newFromBuilder | public function newFromBuilder($attributes = [], $connection = null)
{
$attributes = (array) $attributes;
if (! empty($attributes['type'])
&& isset(static::$models[$attributes['type']])
&& class_exists($class = static::$models[$attributes['type']])
) {
/*... | php | public function newFromBuilder($attributes = [], $connection = null)
{
$attributes = (array) $attributes;
if (! empty($attributes['type'])
&& isset(static::$models[$attributes['type']])
&& class_exists($class = static::$models[$attributes['type']])
) {
/*... | [
"public",
"function",
"newFromBuilder",
"(",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"connection",
"=",
"null",
")",
"{",
"$",
"attributes",
"=",
"(",
"array",
")",
"$",
"attributes",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"attributes",
"[",
"'t... | Create a new model instance according to the post's type.
@param array $attributes
@param string|null $connection
@return static|object | [
"Create",
"a",
"new",
"model",
"instance",
"according",
"to",
"the",
"post",
"s",
"type",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Post/Post.php#L186-L204 | train |
flarum/core | src/Extension/Extension.php | Extension.assignId | protected function assignId()
{
list($vendor, $package) = explode('/', $this->name);
$package = str_replace(['flarum-ext-', 'flarum-'], '', $package);
$this->id = "$vendor-$package";
} | php | protected function assignId()
{
list($vendor, $package) = explode('/', $this->name);
$package = str_replace(['flarum-ext-', 'flarum-'], '', $package);
$this->id = "$vendor-$package";
} | [
"protected",
"function",
"assignId",
"(",
")",
"{",
"list",
"(",
"$",
"vendor",
",",
"$",
"package",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"name",
")",
";",
"$",
"package",
"=",
"str_replace",
"(",
"[",
"'flarum-ext-'",
",",
"'flar... | Assigns the id for the extension used globally. | [
"Assigns",
"the",
"id",
"for",
"the",
"extension",
"used",
"globally",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/Extension.php#L107-L112 | train |
flarum/core | src/Extension/Extension.php | Extension.getIcon | public function getIcon()
{
$icon = $this->composerJsonAttribute('extra.flarum-extension.icon');
$file = Arr::get($icon, 'image');
if (is_null($icon) || is_null($file)) {
return $icon;
}
$file = $this->path.'/'.$file;
if (file_exists($file)) {
... | php | public function getIcon()
{
$icon = $this->composerJsonAttribute('extra.flarum-extension.icon');
$file = Arr::get($icon, 'image');
if (is_null($icon) || is_null($file)) {
return $icon;
}
$file = $this->path.'/'.$file;
if (file_exists($file)) {
... | [
"public",
"function",
"getIcon",
"(",
")",
"{",
"$",
"icon",
"=",
"$",
"this",
"->",
"composerJsonAttribute",
"(",
"'extra.flarum-extension.icon'",
")",
";",
"$",
"file",
"=",
"Arr",
"::",
"get",
"(",
"$",
"icon",
",",
"'image'",
")",
";",
"if",
"(",
"... | Loads the icon information from the composer.json.
@return array|null | [
"Loads",
"the",
"icon",
"information",
"from",
"the",
"composer",
".",
"json",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/Extension.php#L200-L224 | train |
flarum/core | src/Extension/Extension.php | Extension.toArray | public function toArray()
{
return (array) array_merge([
'id' => $this->getId(),
'version' => $this->getVersion(),
'path' => $this->path,
'icon' => $this->getIcon(),
'hasAssets' => $this->hasAssets(),
... | php | public function toArray()
{
return (array) array_merge([
'id' => $this->getId(),
'version' => $this->getVersion(),
'path' => $this->path,
'icon' => $this->getIcon(),
'hasAssets' => $this->hasAssets(),
... | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"(",
"array",
")",
"array_merge",
"(",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"'version'",
"=>",
"$",
"this",
"->",
"getVersion",
"(",
")",
",",
"'path'",
"=>",
"$",
"... | Generates an array result for the object.
@return array | [
"Generates",
"an",
"array",
"result",
"for",
"the",
"object",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Extension/Extension.php#L363-L373 | train |
flarum/core | src/User/EmailConfirmationMailer.php | EmailConfirmationMailer.getEmailData | protected function getEmailData(User $user, $email)
{
$token = $this->generateToken($user, $email);
return [
'{username}' => $user->display_name,
'{url}' => $this->url->to('forum')->route('confirmEmail', ['token' => $token->token]),
'{forum}' => $this->settings->... | php | protected function getEmailData(User $user, $email)
{
$token = $this->generateToken($user, $email);
return [
'{username}' => $user->display_name,
'{url}' => $this->url->to('forum')->route('confirmEmail', ['token' => $token->token]),
'{forum}' => $this->settings->... | [
"protected",
"function",
"getEmailData",
"(",
"User",
"$",
"user",
",",
"$",
"email",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"generateToken",
"(",
"$",
"user",
",",
"$",
"email",
")",
";",
"return",
"[",
"'{username}'",
"=>",
"$",
"user",
"-... | Get the data that should be made available to email templates.
@param User $user
@param string $email
@return array | [
"Get",
"the",
"data",
"that",
"should",
"be",
"made",
"available",
"to",
"email",
"templates",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/User/EmailConfirmationMailer.php#L84-L93 | train |
flarum/core | src/Group/Permission.php | Permission.map | public static function map()
{
$permissions = [];
foreach (static::get() as $permission) {
$permissions[$permission->permission][] = (string) $permission->group_id;
}
return $permissions;
} | php | public static function map()
{
$permissions = [];
foreach (static::get() as $permission) {
$permissions[$permission->permission][] = (string) $permission->group_id;
}
return $permissions;
} | [
"public",
"static",
"function",
"map",
"(",
")",
"{",
"$",
"permissions",
"=",
"[",
"]",
";",
"foreach",
"(",
"static",
"::",
"get",
"(",
")",
"as",
"$",
"permission",
")",
"{",
"$",
"permissions",
"[",
"$",
"permission",
"->",
"permission",
"]",
"["... | Get a map of permissions to the group IDs that have them.
@return array[] | [
"Get",
"a",
"map",
"of",
"permissions",
"to",
"the",
"group",
"IDs",
"that",
"have",
"them",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Group/Permission.php#L57-L66 | train |
flarum/core | src/Forum/ForumServiceProvider.php | ForumServiceProvider.populateRoutes | protected function populateRoutes(RouteCollection $routes)
{
$factory = $this->app->make(RouteHandlerFactory::class);
$callback = include __DIR__.'/routes.php';
$callback($routes, $factory);
$this->app->make('events')->fire(
new ConfigureForumRoutes($routes, $factory)
... | php | protected function populateRoutes(RouteCollection $routes)
{
$factory = $this->app->make(RouteHandlerFactory::class);
$callback = include __DIR__.'/routes.php';
$callback($routes, $factory);
$this->app->make('events')->fire(
new ConfigureForumRoutes($routes, $factory)
... | [
"protected",
"function",
"populateRoutes",
"(",
"RouteCollection",
"$",
"routes",
")",
"{",
"$",
"factory",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"RouteHandlerFactory",
"::",
"class",
")",
";",
"$",
"callback",
"=",
"include",
"__DIR__",
".",
"... | Populate the forum client routes.
@param RouteCollection $routes | [
"Populate",
"the",
"forum",
"client",
"routes",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Forum/ForumServiceProvider.php#L173-L197 | train |
flarum/core | src/Notification/Notification.php | Notification.scopeWhereSubjectVisibleTo | public function scopeWhereSubjectVisibleTo(Builder $query, User $actor)
{
$query->where(function ($query) use ($actor) {
$classes = [];
foreach (static::$subjectModels as $type => $class) {
$classes[$class][] = $type;
}
foreach ($classes as $... | php | public function scopeWhereSubjectVisibleTo(Builder $query, User $actor)
{
$query->where(function ($query) use ($actor) {
$classes = [];
foreach (static::$subjectModels as $type => $class) {
$classes[$class][] = $type;
}
foreach ($classes as $... | [
"public",
"function",
"scopeWhereSubjectVisibleTo",
"(",
"Builder",
"$",
"query",
",",
"User",
"$",
"actor",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"actor",
")",
"{",
"$",
"classes",
"=",
"[",
... | Scope the query to include only notifications whose subjects are visible
to the given user.
@param Builder $query | [
"Scope",
"the",
"query",
"to",
"include",
"only",
"notifications",
"whose",
"subjects",
"are",
"visible",
"to",
"the",
"given",
"user",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Notification/Notification.php#L146-L170 | train |
flarum/core | src/Notification/Notification.php | Notification.scopeWhereSubject | public function scopeWhereSubject(Builder $query, $model)
{
$query->whereSubjectModel(get_class($model))
->where('subject_id', $model->id);
} | php | public function scopeWhereSubject(Builder $query, $model)
{
$query->whereSubjectModel(get_class($model))
->where('subject_id', $model->id);
} | [
"public",
"function",
"scopeWhereSubject",
"(",
"Builder",
"$",
"query",
",",
"$",
"model",
")",
"{",
"$",
"query",
"->",
"whereSubjectModel",
"(",
"get_class",
"(",
"$",
"model",
")",
")",
"->",
"where",
"(",
"'subject_id'",
",",
"$",
"model",
"->",
"id... | Scope the query to include only notifications that have the given
subject.
@param Builder $query
@param object $model | [
"Scope",
"the",
"query",
"to",
"include",
"only",
"notifications",
"that",
"have",
"the",
"given",
"subject",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Notification/Notification.php#L179-L183 | train |
flarum/core | src/Notification/Notification.php | Notification.scopeWhereSubjectModel | public function scopeWhereSubjectModel(Builder $query, string $class)
{
$notificationTypes = array_filter(self::getSubjectModels(), function ($modelClass) use ($class) {
return $modelClass === $class or is_subclass_of($class, $modelClass);
});
$query->whereIn('type', array_keys(... | php | public function scopeWhereSubjectModel(Builder $query, string $class)
{
$notificationTypes = array_filter(self::getSubjectModels(), function ($modelClass) use ($class) {
return $modelClass === $class or is_subclass_of($class, $modelClass);
});
$query->whereIn('type', array_keys(... | [
"public",
"function",
"scopeWhereSubjectModel",
"(",
"Builder",
"$",
"query",
",",
"string",
"$",
"class",
")",
"{",
"$",
"notificationTypes",
"=",
"array_filter",
"(",
"self",
"::",
"getSubjectModels",
"(",
")",
",",
"function",
"(",
"$",
"modelClass",
")",
... | Scope the query to include only notification types that use the given
subject model.
@param Builder $query
@param string $class | [
"Scope",
"the",
"query",
"to",
"include",
"only",
"notification",
"types",
"that",
"use",
"the",
"given",
"subject",
"model",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Notification/Notification.php#L192-L199 | train |
flarum/core | src/User/EmailToken.php | EmailToken.generate | public static function generate($email, $userId)
{
$token = new static;
$token->token = str_random(40);
$token->user_id = $userId;
$token->email = $email;
$token->created_at = Carbon::now();
return $token;
} | php | public static function generate($email, $userId)
{
$token = new static;
$token->token = str_random(40);
$token->user_id = $userId;
$token->email = $email;
$token->created_at = Carbon::now();
return $token;
} | [
"public",
"static",
"function",
"generate",
"(",
"$",
"email",
",",
"$",
"userId",
")",
"{",
"$",
"token",
"=",
"new",
"static",
";",
"$",
"token",
"->",
"token",
"=",
"str_random",
"(",
"40",
")",
";",
"$",
"token",
"->",
"user_id",
"=",
"$",
"use... | Generate an email token for the specified user.
@param string $email
@param int $userId
@return static | [
"Generate",
"an",
"email",
"token",
"for",
"the",
"specified",
"user",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/User/EmailToken.php#L53-L63 | train |
flarum/core | src/Database/Migration.php | Migration.addColumns | public static function addColumns($tableName, array $columnDefinitions)
{
return [
'up' => function (Builder $schema) use ($tableName, $columnDefinitions) {
$schema->table($tableName, function (Blueprint $table) use ($schema, $columnDefinitions) {
foreach ($co... | php | public static function addColumns($tableName, array $columnDefinitions)
{
return [
'up' => function (Builder $schema) use ($tableName, $columnDefinitions) {
$schema->table($tableName, function (Blueprint $table) use ($schema, $columnDefinitions) {
foreach ($co... | [
"public",
"static",
"function",
"addColumns",
"(",
"$",
"tableName",
",",
"array",
"$",
"columnDefinitions",
")",
"{",
"return",
"[",
"'up'",
"=>",
"function",
"(",
"Builder",
"$",
"schema",
")",
"use",
"(",
"$",
"tableName",
",",
"$",
"columnDefinitions",
... | Add columns to a table. | [
"Add",
"columns",
"to",
"a",
"table",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Database/Migration.php#L60-L77 | train |
flarum/core | src/Database/Migration.php | Migration.renameColumns | public static function renameColumns($tableName, array $columnNames)
{
return [
'up' => function (Builder $schema) use ($tableName, $columnNames) {
$schema->table($tableName, function (Blueprint $table) use ($columnNames) {
foreach ($columnNames as $from => $t... | php | public static function renameColumns($tableName, array $columnNames)
{
return [
'up' => function (Builder $schema) use ($tableName, $columnNames) {
$schema->table($tableName, function (Blueprint $table) use ($columnNames) {
foreach ($columnNames as $from => $t... | [
"public",
"static",
"function",
"renameColumns",
"(",
"$",
"tableName",
",",
"array",
"$",
"columnNames",
")",
"{",
"return",
"[",
"'up'",
"=>",
"function",
"(",
"Builder",
"$",
"schema",
")",
"use",
"(",
"$",
"tableName",
",",
"$",
"columnNames",
")",
"... | Rename multiple columns. | [
"Rename",
"multiple",
"columns",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Database/Migration.php#L103-L121 | train |
flarum/core | src/Database/Migration.php | Migration.addSettings | public static function addSettings(array $defaults)
{
return [
'up' => function (Builder $schema) use ($defaults) {
$settings = new DatabaseSettingsRepository(
$schema->getConnection()
);
foreach ($defaults as $key => $value) {... | php | public static function addSettings(array $defaults)
{
return [
'up' => function (Builder $schema) use ($defaults) {
$settings = new DatabaseSettingsRepository(
$schema->getConnection()
);
foreach ($defaults as $key => $value) {... | [
"public",
"static",
"function",
"addSettings",
"(",
"array",
"$",
"defaults",
")",
"{",
"return",
"[",
"'up'",
"=>",
"function",
"(",
"Builder",
"$",
"schema",
")",
"use",
"(",
"$",
"defaults",
")",
"{",
"$",
"settings",
"=",
"new",
"DatabaseSettingsReposi... | Add default values for config values. | [
"Add",
"default",
"values",
"for",
"config",
"values",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Database/Migration.php#L126-L148 | train |
flarum/core | src/Database/Migration.php | Migration.addPermissions | public static function addPermissions(array $permissions)
{
$rows = [];
foreach ($permissions as $permission => $groups) {
foreach ((array) $groups as $group) {
$rows[] = [
'group_id' => $group,
'permission' => $permission,
... | php | public static function addPermissions(array $permissions)
{
$rows = [];
foreach ($permissions as $permission => $groups) {
foreach ((array) $groups as $group) {
$rows[] = [
'group_id' => $group,
'permission' => $permission,
... | [
"public",
"static",
"function",
"addPermissions",
"(",
"array",
"$",
"permissions",
")",
"{",
"$",
"rows",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"permission",
"=>",
"$",
"groups",
")",
"{",
"foreach",
"(",
"(",
"array",
")"... | Add default permissions. | [
"Add",
"default",
"permissions",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Database/Migration.php#L153-L191 | train |
flarum/core | src/Formatter/Formatter.php | Formatter.parse | public function parse($text, $context = null)
{
$parser = $this->getParser($context);
$this->events->dispatch(new Parsing($parser, $context, $text));
return $parser->parse($text);
} | php | public function parse($text, $context = null)
{
$parser = $this->getParser($context);
$this->events->dispatch(new Parsing($parser, $context, $text));
return $parser->parse($text);
} | [
"public",
"function",
"parse",
"(",
"$",
"text",
",",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"parser",
"=",
"$",
"this",
"->",
"getParser",
"(",
"$",
"context",
")",
";",
"$",
"this",
"->",
"events",
"->",
"dispatch",
"(",
"new",
"Parsing",
"(... | Parse text.
@param string $text
@param mixed $context
@return string | [
"Parse",
"text",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Formatter/Formatter.php#L59-L66 | train |
flarum/core | src/Formatter/Formatter.php | Formatter.render | public function render($xml, $context = null, ServerRequestInterface $request = null)
{
$renderer = $this->getRenderer();
$this->events->dispatch(new Rendering($renderer, $context, $xml, $request));
return $renderer->render($xml);
} | php | public function render($xml, $context = null, ServerRequestInterface $request = null)
{
$renderer = $this->getRenderer();
$this->events->dispatch(new Rendering($renderer, $context, $xml, $request));
return $renderer->render($xml);
} | [
"public",
"function",
"render",
"(",
"$",
"xml",
",",
"$",
"context",
"=",
"null",
",",
"ServerRequestInterface",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"renderer",
"=",
"$",
"this",
"->",
"getRenderer",
"(",
")",
";",
"$",
"this",
"->",
"events",... | Render parsed XML.
@param string $xml
@param mixed $context
@param ServerRequestInterface|null $request
@return string | [
"Render",
"parsed",
"XML",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Formatter/Formatter.php#L76-L83 | train |
flarum/core | src/Formatter/Formatter.php | Formatter.getComponent | protected function getComponent($name)
{
$formatter = $this->cache->rememberForever('flarum.formatter', function () {
return $this->getConfigurator()->finalize();
});
return $formatter[$name];
} | php | protected function getComponent($name)
{
$formatter = $this->cache->rememberForever('flarum.formatter', function () {
return $this->getConfigurator()->finalize();
});
return $formatter[$name];
} | [
"protected",
"function",
"getComponent",
"(",
"$",
"name",
")",
"{",
"$",
"formatter",
"=",
"$",
"this",
"->",
"cache",
"->",
"rememberForever",
"(",
"'flarum.formatter'",
",",
"function",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getConfigurator",
"(",
... | Get a TextFormatter component.
@param string $name "renderer" or "parser" or "js"
@return mixed | [
"Get",
"a",
"TextFormatter",
"component",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Formatter/Formatter.php#L155-L162 | train |
flarum/core | src/Api/Serializer/AbstractSerializer.php | AbstractSerializer.getCustomRelationship | protected function getCustomRelationship($model, $name)
{
$relationship = static::$dispatcher->until(
new GetApiRelationship($this, $name, $model)
);
if ($relationship && ! ($relationship instanceof Relationship)) {
throw new LogicException(
'GetApiRe... | php | protected function getCustomRelationship($model, $name)
{
$relationship = static::$dispatcher->until(
new GetApiRelationship($this, $name, $model)
);
if ($relationship && ! ($relationship instanceof Relationship)) {
throw new LogicException(
'GetApiRe... | [
"protected",
"function",
"getCustomRelationship",
"(",
"$",
"model",
",",
"$",
"name",
")",
"{",
"$",
"relationship",
"=",
"static",
"::",
"$",
"dispatcher",
"->",
"until",
"(",
"new",
"GetApiRelationship",
"(",
"$",
"this",
",",
"$",
"name",
",",
"$",
"... | Get a custom relationship.
@param mixed $model
@param string $name
@return Relationship|null | [
"Get",
"a",
"custom",
"relationship",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Api/Serializer/AbstractSerializer.php#L133-L146 | train |
flarum/core | src/Api/Serializer/AbstractSerializer.php | AbstractSerializer.hasOne | public function hasOne($model, $serializer, $relation = null)
{
return $this->buildRelationship($model, $serializer, $relation);
} | php | public function hasOne($model, $serializer, $relation = null)
{
return $this->buildRelationship($model, $serializer, $relation);
} | [
"public",
"function",
"hasOne",
"(",
"$",
"model",
",",
"$",
"serializer",
",",
"$",
"relation",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"buildRelationship",
"(",
"$",
"model",
",",
"$",
"serializer",
",",
"$",
"relation",
")",
";",
"}"
] | Get a relationship builder for a has-one relationship.
@param mixed $model
@param string|Closure|\Tobscure\JsonApi\SerializerInterface $serializer
@param string|Closure|null $relation
@return Relationship | [
"Get",
"a",
"relationship",
"builder",
"for",
"a",
"has",
"-",
"one",
"relationship",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Api/Serializer/AbstractSerializer.php#L156-L159 | train |
flarum/core | src/Api/Serializer/AbstractSerializer.php | AbstractSerializer.hasMany | public function hasMany($model, $serializer, $relation = null)
{
return $this->buildRelationship($model, $serializer, $relation, true);
} | php | public function hasMany($model, $serializer, $relation = null)
{
return $this->buildRelationship($model, $serializer, $relation, true);
} | [
"public",
"function",
"hasMany",
"(",
"$",
"model",
",",
"$",
"serializer",
",",
"$",
"relation",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"buildRelationship",
"(",
"$",
"model",
",",
"$",
"serializer",
",",
"$",
"relation",
",",
"true",
")"... | Get a relationship builder for a has-many relationship.
@param mixed $model
@param string|Closure|\Tobscure\JsonApi\SerializerInterface $serializer
@param string|null $relation
@return Relationship | [
"Get",
"a",
"relationship",
"builder",
"for",
"a",
"has",
"-",
"many",
"relationship",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Api/Serializer/AbstractSerializer.php#L169-L172 | train |
flarum/core | src/Search/ApplySearchParametersTrait.php | ApplySearchParametersTrait.applySort | protected function applySort(AbstractSearch $search, array $sort = null)
{
$sort = $sort ?: $search->getDefaultSort();
if (is_callable($sort)) {
$sort($search->getQuery());
} else {
foreach ($sort as $field => $order) {
if (is_array($order)) {
... | php | protected function applySort(AbstractSearch $search, array $sort = null)
{
$sort = $sort ?: $search->getDefaultSort();
if (is_callable($sort)) {
$sort($search->getQuery());
} else {
foreach ($sort as $field => $order) {
if (is_array($order)) {
... | [
"protected",
"function",
"applySort",
"(",
"AbstractSearch",
"$",
"search",
",",
"array",
"$",
"sort",
"=",
"null",
")",
"{",
"$",
"sort",
"=",
"$",
"sort",
"?",
":",
"$",
"search",
"->",
"getDefaultSort",
"(",
")",
";",
"if",
"(",
"is_callable",
"(",
... | Apply sort criteria to a discussion search.
@param AbstractSearch $search
@param array $sort | [
"Apply",
"sort",
"criteria",
"to",
"a",
"discussion",
"search",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Search/ApplySearchParametersTrait.php#L22-L39 | train |
flarum/core | src/Post/CommentPost.php | CommentPost.revise | public function revise($content, User $actor)
{
if ($this->content !== $content) {
$this->content = $content;
$this->edited_at = Carbon::now();
$this->edited_user_id = $actor->id;
$this->raise(new Revised($this));
}
return $this;
} | php | public function revise($content, User $actor)
{
if ($this->content !== $content) {
$this->content = $content;
$this->edited_at = Carbon::now();
$this->edited_user_id = $actor->id;
$this->raise(new Revised($this));
}
return $this;
} | [
"public",
"function",
"revise",
"(",
"$",
"content",
",",
"User",
"$",
"actor",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"content",
"!==",
"$",
"content",
")",
"{",
"$",
"this",
"->",
"content",
"=",
"$",
"content",
";",
"$",
"this",
"->",
"edited_a... | Revise the post's content.
@param string $content
@param User $actor
@return $this | [
"Revise",
"the",
"post",
"s",
"content",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Post/CommentPost.php#L76-L88 | train |
flarum/core | src/Post/CommentPost.php | CommentPost.setContentAttribute | public function setContentAttribute($value)
{
$this->attributes['content'] = $value ? static::$formatter->parse($value, $this) : null;
} | php | public function setContentAttribute($value)
{
$this->attributes['content'] = $value ? static::$formatter->parse($value, $this) : null;
} | [
"public",
"function",
"setContentAttribute",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'content'",
"]",
"=",
"$",
"value",
"?",
"static",
"::",
"$",
"formatter",
"->",
"parse",
"(",
"$",
"value",
",",
"$",
"this",
")",
":",
... | Parse the content before it is saved to the database.
@param string $value | [
"Parse",
"the",
"content",
"before",
"it",
"is",
"saved",
"to",
"the",
"database",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Post/CommentPost.php#L151-L154 | train |
flarum/core | src/Database/Migrator.php | Migrator.runClosureMigration | protected function runClosureMigration($migration, $direction = 'up')
{
if (is_array($migration) && array_key_exists($direction, $migration)) {
call_user_func($migration[$direction], $this->schemaBuilder);
} else {
throw new Exception('Migration file should contain an array w... | php | protected function runClosureMigration($migration, $direction = 'up')
{
if (is_array($migration) && array_key_exists($direction, $migration)) {
call_user_func($migration[$direction], $this->schemaBuilder);
} else {
throw new Exception('Migration file should contain an array w... | [
"protected",
"function",
"runClosureMigration",
"(",
"$",
"migration",
",",
"$",
"direction",
"=",
"'up'",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"migration",
")",
"&&",
"array_key_exists",
"(",
"$",
"direction",
",",
"$",
"migration",
")",
")",
"{",
... | Runs a closure migration based on the migrate direction.
@param $migration
@param string $direction
@throws Exception | [
"Runs",
"a",
"closure",
"migration",
"based",
"on",
"the",
"migrate",
"direction",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Database/Migrator.php#L196-L203 | train |
flarum/core | src/User/LoginProvider.php | LoginProvider.logIn | public static function logIn(string $provider, string $identifier): ?User
{
if ($provider = static::where(compact('provider', 'identifier'))->first()) {
$provider->touch();
return $provider->user;
}
return null;
} | php | public static function logIn(string $provider, string $identifier): ?User
{
if ($provider = static::where(compact('provider', 'identifier'))->first()) {
$provider->touch();
return $provider->user;
}
return null;
} | [
"public",
"static",
"function",
"logIn",
"(",
"string",
"$",
"provider",
",",
"string",
"$",
"identifier",
")",
":",
"?",
"User",
"{",
"if",
"(",
"$",
"provider",
"=",
"static",
"::",
"where",
"(",
"compact",
"(",
"'provider'",
",",
"'identifier'",
")",
... | Get the user associated with the provider so that they can be logged in.
@param string $provider
@param string $identifier
@return User|null | [
"Get",
"the",
"user",
"associated",
"with",
"the",
"provider",
"so",
"that",
"they",
"can",
"be",
"logged",
"in",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/User/LoginProvider.php#L50-L59 | train |
flarum/core | src/Api/Client.php | Client.send | public function send($controller, User $actor = null, array $queryParams = [], array $body = []): ResponseInterface
{
$request = ServerRequestFactory::fromGlobals(null, $queryParams, $body);
$request = $request->withAttribute('actor', $actor);
if (is_string($controller)) {
$con... | php | public function send($controller, User $actor = null, array $queryParams = [], array $body = []): ResponseInterface
{
$request = ServerRequestFactory::fromGlobals(null, $queryParams, $body);
$request = $request->withAttribute('actor', $actor);
if (is_string($controller)) {
$con... | [
"public",
"function",
"send",
"(",
"$",
"controller",
",",
"User",
"$",
"actor",
"=",
"null",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
",",
"array",
"$",
"body",
"=",
"[",
"]",
")",
":",
"ResponseInterface",
"{",
"$",
"request",
"=",
"ServerR... | Execute the given API action class, pass the input and return its response.
@param string|RequestHandlerInterface $controller
@param User|null $actor
@param array $queryParams
@param array $body
@return ResponseInterface
@throws Exception | [
"Execute",
"the",
"given",
"API",
"action",
"class",
"pass",
"the",
"input",
"and",
"return",
"its",
"response",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Api/Client.php#L54-L79 | train |
flarum/core | src/Group/GroupRepository.php | GroupRepository.findOrFail | public function findOrFail($id, User $actor = null)
{
$query = Group::where('id', $id);
return $this->scopeVisibleTo($query, $actor)->firstOrFail();
} | php | public function findOrFail($id, User $actor = null)
{
$query = Group::where('id', $id);
return $this->scopeVisibleTo($query, $actor)->firstOrFail();
} | [
"public",
"function",
"findOrFail",
"(",
"$",
"id",
",",
"User",
"$",
"actor",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"Group",
"::",
"where",
"(",
"'id'",
",",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"scopeVisibleTo",
"(",
"$",
"query"... | Find a user by ID, optionally making sure it is visible to a certain
user, or throw an exception.
@param int $id
@param User $actor
@return \Flarum\Group\Group
@throws \Illuminate\Database\Eloquent\ModelNotFoundException | [
"Find",
"a",
"user",
"by",
"ID",
"optionally",
"making",
"sure",
"it",
"is",
"visible",
"to",
"a",
"certain",
"user",
"or",
"throw",
"an",
"exception",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Group/GroupRepository.php#L39-L44 | train |
flarum/core | src/Group/GroupRepository.php | GroupRepository.findByName | public function findByName($name, User $actor = null)
{
$query = Group::where('name_singular', $name)->orWhere('name_plural', $name);
return $this->scopeVisibleTo($query, $actor)->first();
} | php | public function findByName($name, User $actor = null)
{
$query = Group::where('name_singular', $name)->orWhere('name_plural', $name);
return $this->scopeVisibleTo($query, $actor)->first();
} | [
"public",
"function",
"findByName",
"(",
"$",
"name",
",",
"User",
"$",
"actor",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"Group",
"::",
"where",
"(",
"'name_singular'",
",",
"$",
"name",
")",
"->",
"orWhere",
"(",
"'name_plural'",
",",
"$",
"name",
... | Find a group by name.
@param string $name
@return User|null | [
"Find",
"a",
"group",
"by",
"name",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Group/GroupRepository.php#L52-L57 | train |
flarum/core | src/Util/Str.php | Str.slug | public static function slug($str)
{
$str = strtolower($str);
$str = preg_replace('/[^a-z0-9]/i', '-', $str);
$str = preg_replace('/-+/', '-', $str);
$str = preg_replace('/-$|^-/', '', $str);
return $str;
} | php | public static function slug($str)
{
$str = strtolower($str);
$str = preg_replace('/[^a-z0-9]/i', '-', $str);
$str = preg_replace('/-+/', '-', $str);
$str = preg_replace('/-$|^-/', '', $str);
return $str;
} | [
"public",
"static",
"function",
"slug",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"strtolower",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"preg_replace",
"(",
"'/[^a-z0-9]/i'",
",",
"'-'",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"preg_repla... | Create a slug out of the given string.
Non-alphanumeric characters are converted to hyphens.
@param string $str
@return string | [
"Create",
"a",
"slug",
"out",
"of",
"the",
"given",
"string",
"."
] | 99a6066f96899c15145eff80bb3ad3e97ff24c29 | https://github.com/flarum/core/blob/99a6066f96899c15145eff80bb3ad3e97ff24c29/src/Util/Str.php#L24-L32 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.autoDetectTimeZone | protected function autoDetectTimeZone($object, $originalObject = null)
{
/** @var CarbonTimeZone $timezone */
$timezone = CarbonTimeZone::instance($object);
if ($timezone && is_int($originalObject ?: $object)) {
$timezone = $timezone->toRegionTimeZone($this);
}
r... | php | protected function autoDetectTimeZone($object, $originalObject = null)
{
/** @var CarbonTimeZone $timezone */
$timezone = CarbonTimeZone::instance($object);
if ($timezone && is_int($originalObject ?: $object)) {
$timezone = $timezone->toRegionTimeZone($this);
}
r... | [
"protected",
"function",
"autoDetectTimeZone",
"(",
"$",
"object",
",",
"$",
"originalObject",
"=",
"null",
")",
"{",
"/** @var CarbonTimeZone $timezone */",
"$",
"timezone",
"=",
"CarbonTimeZone",
"::",
"instance",
"(",
"$",
"object",
")",
";",
"if",
"(",
"$",
... | Creates a DateTimeZone from a string, DateTimeZone or integer offset then convert it as region timezone
if integer.
@param \DateTimeZone|string|int|null $object
@param \DateTimeZone|string|int|null $originalObject if different
@throws \InvalidArgumentException
@return CarbonTimeZone|false | [
"Creates",
"a",
"DateTimeZone",
"from",
"a",
"string",
"DateTimeZone",
"or",
"integer",
"offset",
"then",
"convert",
"it",
"as",
"region",
"timezone",
"if",
"integer",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L608-L617 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.resolveCarbon | protected function resolveCarbon($date = null)
{
if (!$date) {
return $this->nowWithSameTz();
}
if (is_string($date)) {
return static::parse($date, $this->getTimezone());
}
static::expectDateTime($date, ['null', 'string']);
return $date inst... | php | protected function resolveCarbon($date = null)
{
if (!$date) {
return $this->nowWithSameTz();
}
if (is_string($date)) {
return static::parse($date, $this->getTimezone());
}
static::expectDateTime($date, ['null', 'string']);
return $date inst... | [
"protected",
"function",
"resolveCarbon",
"(",
"$",
"date",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"date",
")",
"{",
"return",
"$",
"this",
"->",
"nowWithSameTz",
"(",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"date",
")",
")",
"{",
"... | Return the Carbon instance passed through, a now instance in the same timezone
if null given or parse the input if string given.
@param \Carbon\Carbon|\DateTimeInterface|string|null $date
@return static|CarbonInterface | [
"Return",
"the",
"Carbon",
"instance",
"passed",
"through",
"a",
"now",
"instance",
"in",
"the",
"same",
"timezone",
"if",
"null",
"given",
"or",
"parse",
"the",
"input",
"if",
"string",
"given",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L717-L730 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.addUnitNoOverflow | public function addUnitNoOverflow($valueUnit, $value, $overflowUnit)
{
return $this->setUnitNoOverflow($valueUnit, $this->$valueUnit + $value, $overflowUnit);
} | php | public function addUnitNoOverflow($valueUnit, $value, $overflowUnit)
{
return $this->setUnitNoOverflow($valueUnit, $this->$valueUnit + $value, $overflowUnit);
} | [
"public",
"function",
"addUnitNoOverflow",
"(",
"$",
"valueUnit",
",",
"$",
"value",
",",
"$",
"overflowUnit",
")",
"{",
"return",
"$",
"this",
"->",
"setUnitNoOverflow",
"(",
"$",
"valueUnit",
",",
"$",
"this",
"->",
"$",
"valueUnit",
"+",
"$",
"value",
... | Add any unit to a new value without overflowing current other unit given.
@param string $valueUnit unit name to modify
@param int $value amount to add to the input unit
@param string $overflowUnit unit name to not overflow
@return static|CarbonInterface | [
"Add",
"any",
"unit",
"to",
"a",
"new",
"value",
"without",
"overflowing",
"current",
"other",
"unit",
"given",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1299-L1302 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.subUnitNoOverflow | public function subUnitNoOverflow($valueUnit, $value, $overflowUnit)
{
return $this->setUnitNoOverflow($valueUnit, $this->$valueUnit - $value, $overflowUnit);
} | php | public function subUnitNoOverflow($valueUnit, $value, $overflowUnit)
{
return $this->setUnitNoOverflow($valueUnit, $this->$valueUnit - $value, $overflowUnit);
} | [
"public",
"function",
"subUnitNoOverflow",
"(",
"$",
"valueUnit",
",",
"$",
"value",
",",
"$",
"overflowUnit",
")",
"{",
"return",
"$",
"this",
"->",
"setUnitNoOverflow",
"(",
"$",
"valueUnit",
",",
"$",
"this",
"->",
"$",
"valueUnit",
"-",
"$",
"value",
... | Subtract any unit to a new value without overflowing current other unit given.
@param string $valueUnit unit name to modify
@param int $value amount to subtract to the input unit
@param string $overflowUnit unit name to not overflow
@return static|CarbonInterface | [
"Subtract",
"any",
"unit",
"to",
"a",
"new",
"value",
"without",
"overflowing",
"current",
"other",
"unit",
"given",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1313-L1316 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.utcOffset | public function utcOffset(int $offset = null)
{
if (func_num_args() < 1) {
return $this->offsetMinutes;
}
return $this->setTimezone(static::safeCreateDateTimeZone($offset / static::MINUTES_PER_HOUR));
} | php | public function utcOffset(int $offset = null)
{
if (func_num_args() < 1) {
return $this->offsetMinutes;
}
return $this->setTimezone(static::safeCreateDateTimeZone($offset / static::MINUTES_PER_HOUR));
} | [
"public",
"function",
"utcOffset",
"(",
"int",
"$",
"offset",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"<",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"offsetMinutes",
";",
"}",
"return",
"$",
"this",
"->",
"setTimezone",
"(",
"s... | Returns the minutes offset to UTC if no arguments passed, else set the timezone with given minutes shift passed.
@param int|null $offset
@return int|static|CarbonInterface | [
"Returns",
"the",
"minutes",
"offset",
"to",
"UTC",
"if",
"no",
"arguments",
"passed",
"else",
"set",
"the",
"timezone",
"with",
"given",
"minutes",
"shift",
"passed",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1325-L1332 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.setTimezone | public function setTimezone($value)
{
/** @var static $date */
$date = parent::setTimezone(static::safeCreateDateTimeZone($value));
// https://bugs.php.net/bug.php?id=72338
// just workaround on this bug
$date->getTimestamp();
return $date;
} | php | public function setTimezone($value)
{
/** @var static $date */
$date = parent::setTimezone(static::safeCreateDateTimeZone($value));
// https://bugs.php.net/bug.php?id=72338
// just workaround on this bug
$date->getTimestamp();
return $date;
} | [
"public",
"function",
"setTimezone",
"(",
"$",
"value",
")",
"{",
"/** @var static $date */",
"$",
"date",
"=",
"parent",
"::",
"setTimezone",
"(",
"static",
"::",
"safeCreateDateTimeZone",
"(",
"$",
"value",
")",
")",
";",
"// https://bugs.php.net/bug.php?id=72338"... | Set the instance's timezone from a string or object.
@param \DateTimeZone|string $value
@return static|CarbonInterface | [
"Set",
"the",
"instance",
"s",
"timezone",
"from",
"a",
"string",
"or",
"object",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1403-L1412 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.setTimeFrom | public function setTimeFrom($date = null)
{
$date = $this->resolveCarbon($date);
return $this->setTime($date->hour, $date->minute, $date->second, $date->microsecond);
} | php | public function setTimeFrom($date = null)
{
$date = $this->resolveCarbon($date);
return $this->setTime($date->hour, $date->minute, $date->second, $date->microsecond);
} | [
"public",
"function",
"setTimeFrom",
"(",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"date",
"=",
"$",
"this",
"->",
"resolveCarbon",
"(",
"$",
"date",
")",
";",
"return",
"$",
"this",
"->",
"setTime",
"(",
"$",
"date",
"->",
"hour",
",",
"$",
"date"... | Set the hour, minute, second and microseconds for this instance to that of the passed instance.
@param \Carbon\Carbon|\DateTimeInterface $date now if null
@return static | [
"Set",
"the",
"hour",
"minute",
"second",
"and",
"microseconds",
"for",
"this",
"instance",
"to",
"that",
"of",
"the",
"passed",
"instance",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1460-L1465 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.setDateTimeFrom | public function setDateTimeFrom($date = null)
{
$date = $this->resolveCarbon($date);
return $this->modify($date->rawFormat('Y-m-d H:i:s.u'));
} | php | public function setDateTimeFrom($date = null)
{
$date = $this->resolveCarbon($date);
return $this->modify($date->rawFormat('Y-m-d H:i:s.u'));
} | [
"public",
"function",
"setDateTimeFrom",
"(",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"date",
"=",
"$",
"this",
"->",
"resolveCarbon",
"(",
"$",
"date",
")",
";",
"return",
"$",
"this",
"->",
"modify",
"(",
"$",
"date",
"->",
"rawFormat",
"(",
"'Y-m... | Set the date and time for this instance to that of the passed instance.
@param \Carbon\Carbon|\DateTimeInterface $date
@return static | [
"Set",
"the",
"date",
"and",
"time",
"for",
"this",
"instance",
"to",
"that",
"of",
"the",
"passed",
"instance",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1474-L1479 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.hasRelativeKeywords | public static function hasRelativeKeywords($time)
{
if (strtotime($time) === false) {
return false;
}
$date1 = new DateTime('2000-01-01T00:00:00Z');
$date1->modify($time);
$date2 = new DateTime('2001-12-25T00:00:00Z');
$date2->modify($time);
retu... | php | public static function hasRelativeKeywords($time)
{
if (strtotime($time) === false) {
return false;
}
$date1 = new DateTime('2000-01-01T00:00:00Z');
$date1->modify($time);
$date2 = new DateTime('2001-12-25T00:00:00Z');
$date2->modify($time);
retu... | [
"public",
"static",
"function",
"hasRelativeKeywords",
"(",
"$",
"time",
")",
"{",
"if",
"(",
"strtotime",
"(",
"$",
"time",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"date1",
"=",
"new",
"DateTime",
"(",
"'2000-01-01T00:00:00Z'",
... | Determine if a time string will produce a relative date.
@param string $time
@return bool true if time match a relative date, false if absolute or invalid time string | [
"Determine",
"if",
"a",
"time",
"string",
"will",
"produce",
"a",
"relative",
"date",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1598-L1610 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.getIsoFormats | public function getIsoFormats($locale = null)
{
return [
'LT' => $this->getTranslationMessage('formats.LT', $locale, 'h:mm A'),
'LTS' => $this->getTranslationMessage('formats.LTS', $locale, 'h:mm:ss A'),
'L' => $this->getTranslationMessage('formats.L', $locale, 'MM/DD/YYY... | php | public function getIsoFormats($locale = null)
{
return [
'LT' => $this->getTranslationMessage('formats.LT', $locale, 'h:mm A'),
'LTS' => $this->getTranslationMessage('formats.LTS', $locale, 'h:mm:ss A'),
'L' => $this->getTranslationMessage('formats.L', $locale, 'MM/DD/YYY... | [
"public",
"function",
"getIsoFormats",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"return",
"[",
"'LT'",
"=>",
"$",
"this",
"->",
"getTranslationMessage",
"(",
"'formats.LT'",
",",
"$",
"locale",
",",
"'h:mm A'",
")",
",",
"'LTS'",
"=>",
"$",
"this",
"->... | Returns list of locale formats for ISO formatting.
@param string|null $locale current locale used if null
@return array | [
"Returns",
"list",
"of",
"locale",
"formats",
"for",
"ISO",
"formatting",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1656-L1666 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.getCalendarFormats | public function getCalendarFormats($locale = null)
{
return [
'sameDay' => $this->getTranslationMessage('calendar.sameDay', $locale, '[Today at] LT'),
'nextDay' => $this->getTranslationMessage('calendar.nextDay', $locale, '[Tomorrow at] LT'),
'nextWeek' => $this->getTrans... | php | public function getCalendarFormats($locale = null)
{
return [
'sameDay' => $this->getTranslationMessage('calendar.sameDay', $locale, '[Today at] LT'),
'nextDay' => $this->getTranslationMessage('calendar.nextDay', $locale, '[Tomorrow at] LT'),
'nextWeek' => $this->getTrans... | [
"public",
"function",
"getCalendarFormats",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"return",
"[",
"'sameDay'",
"=>",
"$",
"this",
"->",
"getTranslationMessage",
"(",
"'calendar.sameDay'",
",",
"$",
"locale",
",",
"'[Today at] LT'",
")",
",",
"'nextDay'",
"... | Returns list of calendar formats for ISO formatting.
@param string|null $locale current locale used if null
@return array | [
"Returns",
"list",
"of",
"calendar",
"formats",
"for",
"ISO",
"formatting",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1675-L1685 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.getPaddedUnit | public function getPaddedUnit($unit, $length = 2, $padString = '0', $padType = STR_PAD_LEFT)
{
return ($this->$unit < 0 ? '-' : '').str_pad(abs($this->$unit), $length, $padString, $padType);
} | php | public function getPaddedUnit($unit, $length = 2, $padString = '0', $padType = STR_PAD_LEFT)
{
return ($this->$unit < 0 ? '-' : '').str_pad(abs($this->$unit), $length, $padString, $padType);
} | [
"public",
"function",
"getPaddedUnit",
"(",
"$",
"unit",
",",
"$",
"length",
"=",
"2",
",",
"$",
"padString",
"=",
"'0'",
",",
"$",
"padType",
"=",
"STR_PAD_LEFT",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"$",
"unit",
"<",
"0",
"?",
"'-'",
":",
... | Returns a unit of the instance padded with 0 by default or any other string if specified.
@param string $unit Carbon unit name
@param int $length Length of the output (2 by default)
@param string $padString String to use for padding ("0" by default)
@param int $padType Side(s) to pad (STR_PAD_LEFT by d... | [
"Returns",
"a",
"unit",
"of",
"the",
"instance",
"padded",
"with",
"0",
"by",
"default",
"or",
"any",
"other",
"string",
"if",
"specified",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1826-L1829 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.ordinal | public function ordinal(string $key, string $period = null): string
{
$number = $this->$key;
$result = $this->translate('ordinal', [
':number' => $number,
':period' => $period,
]);
return strval($result === 'ordinal' ? $number : $result);
} | php | public function ordinal(string $key, string $period = null): string
{
$number = $this->$key;
$result = $this->translate('ordinal', [
':number' => $number,
':period' => $period,
]);
return strval($result === 'ordinal' ? $number : $result);
} | [
"public",
"function",
"ordinal",
"(",
"string",
"$",
"key",
",",
"string",
"$",
"period",
"=",
"null",
")",
":",
"string",
"{",
"$",
"number",
"=",
"$",
"this",
"->",
"$",
"key",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"translate",
"(",
"'ordin... | Return a property with its ordinal.
@param string $key
@param string|null $period
@return string | [
"Return",
"a",
"property",
"with",
"its",
"ordinal",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1839-L1848 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.meridiem | public function meridiem(bool $isLower = false): string
{
$hour = $this->hour;
$index = $hour < 12 ? 0 : 1;
if ($isLower) {
$key = 'meridiem.'.($index + 2);
$result = $this->translate($key);
if ($result !== $key) {
return $result;
... | php | public function meridiem(bool $isLower = false): string
{
$hour = $this->hour;
$index = $hour < 12 ? 0 : 1;
if ($isLower) {
$key = 'meridiem.'.($index + 2);
$result = $this->translate($key);
if ($result !== $key) {
return $result;
... | [
"public",
"function",
"meridiem",
"(",
"bool",
"$",
"isLower",
"=",
"false",
")",
":",
"string",
"{",
"$",
"hour",
"=",
"$",
"this",
"->",
"hour",
";",
"$",
"index",
"=",
"$",
"hour",
"<",
"12",
"?",
"0",
":",
"1",
";",
"if",
"(",
"$",
"isLower... | Return the meridiem of the current time in the current locale.
@param bool $isLower if true, returns lowercase variant if available in the current locale.
@return string | [
"Return",
"the",
"meridiem",
"of",
"the",
"current",
"time",
"in",
"the",
"current",
"locale",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1857-L1888 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.getAltNumber | public function getAltNumber(string $key): string
{
$number = strlen($key) > 1 ? $this->$key : $this->rawFormat('h');
$translateKey = "alt_numbers.$number";
$symbol = $this->translate($translateKey);
if ($symbol !== $translateKey) {
return $symbol;
}
if ... | php | public function getAltNumber(string $key): string
{
$number = strlen($key) > 1 ? $this->$key : $this->rawFormat('h');
$translateKey = "alt_numbers.$number";
$symbol = $this->translate($translateKey);
if ($symbol !== $translateKey) {
return $symbol;
}
if ... | [
"public",
"function",
"getAltNumber",
"(",
"string",
"$",
"key",
")",
":",
"string",
"{",
"$",
"number",
"=",
"strlen",
"(",
"$",
"key",
")",
">",
"1",
"?",
"$",
"this",
"->",
"$",
"key",
":",
"$",
"this",
"->",
"rawFormat",
"(",
"'h'",
")",
";",... | Returns the alternative number if available in the current locale.
@param string $key date property
@return string | [
"Returns",
"the",
"alternative",
"number",
"if",
"available",
"in",
"the",
"current",
"locale",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L1897-L1939 | train |
briannesbitt/Carbon | src/Carbon/Traits/Date.php | Date.setUnit | public function setUnit($unit, $value = null)
{
$unit = static::singularUnit($unit);
$dateUnits = ['year', 'month', 'day'];
if (in_array($unit, $dateUnits)) {
return $this->setDate(...array_map(function ($name) use ($unit, $value) {
return $name === $unit ? $value... | php | public function setUnit($unit, $value = null)
{
$unit = static::singularUnit($unit);
$dateUnits = ['year', 'month', 'day'];
if (in_array($unit, $dateUnits)) {
return $this->setDate(...array_map(function ($name) use ($unit, $value) {
return $name === $unit ? $value... | [
"public",
"function",
"setUnit",
"(",
"$",
"unit",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"unit",
"=",
"static",
"::",
"singularUnit",
"(",
"$",
"unit",
")",
";",
"$",
"dateUnits",
"=",
"[",
"'year'",
",",
"'month'",
",",
"'day'",
"]",
";",... | Set specified unit to new given value.
@param string $unit year, month, day, hour, minute, second or microsecond
@param int $value new value for given unit
@return static | [
"Set",
"specified",
"unit",
"to",
"new",
"given",
"value",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Date.php#L2248-L2269 | train |
briannesbitt/Carbon | src/Carbon/Traits/Localization.php | Localization.setFallbackLocale | public static function setFallbackLocale($locale)
{
$translator = static::getTranslator();
if (method_exists($translator, 'setFallbackLocales')) {
$translator->setFallbackLocales([$locale]);
if ($translator instanceof Translator) {
$preferredLocale = $transl... | php | public static function setFallbackLocale($locale)
{
$translator = static::getTranslator();
if (method_exists($translator, 'setFallbackLocales')) {
$translator->setFallbackLocales([$locale]);
if ($translator instanceof Translator) {
$preferredLocale = $transl... | [
"public",
"static",
"function",
"setFallbackLocale",
"(",
"$",
"locale",
")",
"{",
"$",
"translator",
"=",
"static",
"::",
"getTranslator",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"translator",
",",
"'setFallbackLocales'",
")",
")",
"{",
"$",
... | Set the fallback locale.
@see https://symfony.com/doc/current/components/translation.html#fallback-locales
@param string $locale | [
"Set",
"the",
"fallback",
"locale",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Localization.php#L418-L434 | train |
briannesbitt/Carbon | src/Carbon/Traits/Localization.php | Localization.localeHasShortUnits | public static function localeHasShortUnits($locale)
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
return $newLocale &&
(
($y = static::translateWith($translator, 'y')) !== 'y' &&
$y !==... | php | public static function localeHasShortUnits($locale)
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
return $newLocale &&
(
($y = static::translateWith($translator, 'y')) !== 'y' &&
$y !==... | [
"public",
"static",
"function",
"localeHasShortUnits",
"(",
"$",
"locale",
")",
"{",
"return",
"static",
"::",
"executeWithLocale",
"(",
"$",
"locale",
",",
"function",
"(",
"$",
"newLocale",
",",
"TranslatorInterface",
"$",
"translator",
")",
"{",
"return",
"... | Returns true if the given locale is internally supported and has short-units support.
Support is considered enabled if either year, day or hour has a short variant translated.
@param string $locale locale ex. en
@return bool | [
"Returns",
"true",
"if",
"the",
"given",
"locale",
"is",
"internally",
"supported",
"and",
"has",
"short",
"-",
"units",
"support",
".",
"Support",
"is",
"considered",
"enabled",
"if",
"either",
"year",
"day",
"or",
"hour",
"has",
"a",
"short",
"variant",
... | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Localization.php#L480-L495 | train |
briannesbitt/Carbon | src/Carbon/Traits/Localization.php | Localization.getAvailableLocalesInfo | public static function getAvailableLocalesInfo()
{
$languages = [];
foreach (static::getAvailableLocales() as $id) {
$languages[$id] = new Language($id);
}
return $languages;
} | php | public static function getAvailableLocalesInfo()
{
$languages = [];
foreach (static::getAvailableLocales() as $id) {
$languages[$id] = new Language($id);
}
return $languages;
} | [
"public",
"static",
"function",
"getAvailableLocalesInfo",
"(",
")",
"{",
"$",
"languages",
"=",
"[",
"]",
";",
"foreach",
"(",
"static",
"::",
"getAvailableLocales",
"(",
")",
"as",
"$",
"id",
")",
"{",
"$",
"languages",
"[",
"$",
"id",
"]",
"=",
"new... | Returns list of Language object for each available locale. This object allow you to get the ISO name, native
name, region and variant of the locale.
@return Language[] | [
"Returns",
"list",
"of",
"Language",
"object",
"for",
"each",
"available",
"locale",
".",
"This",
"object",
"allow",
"you",
"to",
"get",
"the",
"ISO",
"name",
"native",
"name",
"region",
"and",
"variant",
"of",
"the",
"locale",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Localization.php#L601-L609 | train |
briannesbitt/Carbon | src/Carbon/Traits/Creator.php | Creator.createFromDate | public static function createFromDate($year = null, $month = null, $day = null, $tz = null)
{
return static::create($year, $month, $day, null, null, null, $tz);
} | php | public static function createFromDate($year = null, $month = null, $day = null, $tz = null)
{
return static::create($year, $month, $day, null, null, null, $tz);
} | [
"public",
"static",
"function",
"createFromDate",
"(",
"$",
"year",
"=",
"null",
",",
"$",
"month",
"=",
"null",
",",
"$",
"day",
"=",
"null",
",",
"$",
"tz",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"create",
"(",
"$",
"year",
",",
"$",
... | Create a Carbon instance from just a date. The time portion is set to now.
@param int|null $year
@param int|null $month
@param int|null $day
@param \DateTimeZone|string|null $tz
@throws \InvalidArgumentException
@return static|CarbonInterface | [
"Create",
"a",
"Carbon",
"instance",
"from",
"just",
"a",
"date",
".",
"The",
"time",
"portion",
"is",
"set",
"to",
"now",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Creator.php#L393-L396 | train |
briannesbitt/Carbon | src/Carbon/Traits/Creator.php | Creator.createMidnightDate | public static function createMidnightDate($year = null, $month = null, $day = null, $tz = null)
{
return static::create($year, $month, $day, 0, 0, 0, $tz);
} | php | public static function createMidnightDate($year = null, $month = null, $day = null, $tz = null)
{
return static::create($year, $month, $day, 0, 0, 0, $tz);
} | [
"public",
"static",
"function",
"createMidnightDate",
"(",
"$",
"year",
"=",
"null",
",",
"$",
"month",
"=",
"null",
",",
"$",
"day",
"=",
"null",
",",
"$",
"tz",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"create",
"(",
"$",
"year",
",",
"$"... | Create a Carbon instance from just a date. The time portion is set to midnight.
@param int|null $year
@param int|null $month
@param int|null $day
@param \DateTimeZone|string|null $tz
@return static|CarbonInterface | [
"Create",
"a",
"Carbon",
"instance",
"from",
"just",
"a",
"date",
".",
"The",
"time",
"portion",
"is",
"set",
"to",
"midnight",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Creator.php#L408-L411 | train |
briannesbitt/Carbon | src/Carbon/Traits/Creator.php | Creator.createFromLocaleFormat | public static function createFromLocaleFormat($format, $locale, $time, $tz = null)
{
return static::rawCreateFromFormat($format, static::translateTimeString($time, $locale, 'en'), $tz);
} | php | public static function createFromLocaleFormat($format, $locale, $time, $tz = null)
{
return static::rawCreateFromFormat($format, static::translateTimeString($time, $locale, 'en'), $tz);
} | [
"public",
"static",
"function",
"createFromLocaleFormat",
"(",
"$",
"format",
",",
"$",
"locale",
",",
"$",
"time",
",",
"$",
"tz",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"rawCreateFromFormat",
"(",
"$",
"format",
",",
"static",
"::",
"translateT... | Create a Carbon instance from a specific format and a string in a given language.
@param string $format Datetime format
@param string $locale
@param string $time
@param \DateTimeZone|string|false|null $tz
@throws InvalidArgumentException
@ret... | [
"Create",
"a",
"Carbon",
"instance",
"from",
"a",
"specific",
"format",
"and",
"a",
"string",
"in",
"a",
"given",
"language",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Creator.php#L723-L726 | train |
briannesbitt/Carbon | src/Carbon/Traits/Creator.php | Creator.createFromLocaleIsoFormat | public static function createFromLocaleIsoFormat($format, $locale, $time, $tz = null)
{
$time = static::translateTimeString($time, $locale, 'en', CarbonInterface::TRANSLATE_MONTHS | CarbonInterface::TRANSLATE_DAYS | CarbonInterface::TRANSLATE_MERIDIEM);
return static::createFromIsoFormat($format, $... | php | public static function createFromLocaleIsoFormat($format, $locale, $time, $tz = null)
{
$time = static::translateTimeString($time, $locale, 'en', CarbonInterface::TRANSLATE_MONTHS | CarbonInterface::TRANSLATE_DAYS | CarbonInterface::TRANSLATE_MERIDIEM);
return static::createFromIsoFormat($format, $... | [
"public",
"static",
"function",
"createFromLocaleIsoFormat",
"(",
"$",
"format",
",",
"$",
"locale",
",",
"$",
"time",
",",
"$",
"tz",
"=",
"null",
")",
"{",
"$",
"time",
"=",
"static",
"::",
"translateTimeString",
"(",
"$",
"time",
",",
"$",
"locale",
... | Create a Carbon instance from a specific ISO format and a string in a given language.
@param string $format Datetime ISO format
@param string $locale
@param string $time
@param \DateTimeZone|string|false|null $tz
@throws InvalidArgumentExcepti... | [
"Create",
"a",
"Carbon",
"instance",
"from",
"a",
"specific",
"ISO",
"format",
"and",
"a",
"string",
"in",
"a",
"given",
"language",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Creator.php#L740-L745 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.