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
rinvex/laravel-tenants
src/Traits/Tenantable.php
Tenantable.syncTenants
public function syncTenants($tenants, bool $detaching = true) { // Find tenants $tenants = $this->prepareTenantIds($tenants); // Sync model tenants $this->tenants()->sync($tenants, $detaching); return $this; }
php
public function syncTenants($tenants, bool $detaching = true) { // Find tenants $tenants = $this->prepareTenantIds($tenants); // Sync model tenants $this->tenants()->sync($tenants, $detaching); return $this; }
[ "public", "function", "syncTenants", "(", "$", "tenants", ",", "bool", "$", "detaching", "=", "true", ")", "{", "// Find tenants", "$", "tenants", "=", "$", "this", "->", "prepareTenantIds", "(", "$", "tenants", ")", ";", "// Sync model tenants", "$", "this", "->", "tenants", "(", ")", "->", "sync", "(", "$", "tenants", ",", "$", "detaching", ")", ";", "return", "$", "this", ";", "}" ]
Sync model tenants. @param mixed $tenants @param bool $detaching @return $this
[ "Sync", "model", "tenants", "." ]
a7700cddf4a304ab241025a6ef4bc4eb274983e6
https://github.com/rinvex/laravel-tenants/blob/a7700cddf4a304ab241025a6ef4bc4eb274983e6/src/Traits/Tenantable.php#L268-L277
train
rinvex/laravel-tenants
src/Traits/Tenantable.php
Tenantable.detachTenants
public function detachTenants($tenants = null) { $tenants = ! is_null($tenants) ? $this->prepareTenantIds($tenants) : null; // Sync model tenants $this->tenants()->detach($tenants); return $this; }
php
public function detachTenants($tenants = null) { $tenants = ! is_null($tenants) ? $this->prepareTenantIds($tenants) : null; // Sync model tenants $this->tenants()->detach($tenants); return $this; }
[ "public", "function", "detachTenants", "(", "$", "tenants", "=", "null", ")", "{", "$", "tenants", "=", "!", "is_null", "(", "$", "tenants", ")", "?", "$", "this", "->", "prepareTenantIds", "(", "$", "tenants", ")", ":", "null", ";", "// Sync model tenants", "$", "this", "->", "tenants", "(", ")", "->", "detach", "(", "$", "tenants", ")", ";", "return", "$", "this", ";", "}" ]
Detach model tenants. @param mixed $tenants @return $this
[ "Detach", "model", "tenants", "." ]
a7700cddf4a304ab241025a6ef4bc4eb274983e6
https://github.com/rinvex/laravel-tenants/blob/a7700cddf4a304ab241025a6ef4bc4eb274983e6/src/Traits/Tenantable.php#L298-L306
train
rinvex/laravel-tenants
src/Traits/Tenantable.php
Tenantable.prepareTenantIds
protected function prepareTenantIds($tenants): array { // Convert collection to plain array if ($tenants instanceof BaseCollection && is_string($tenants->first())) { $tenants = $tenants->toArray(); } // Find tenants by slug, and get their IDs if (is_string($tenants) || (is_array($tenants) && is_string(array_first($tenants)))) { $tenants = app('rinvex.tenants.tenant')->whereIn('slug', $tenants)->get()->pluck('id'); } if ($tenants instanceof Model) { return [$tenants->getKey()]; } if ($tenants instanceof Collection) { return $tenants->modelKeys(); } if ($tenants instanceof BaseCollection) { return $tenants->toArray(); } return (array) $tenants; }
php
protected function prepareTenantIds($tenants): array { // Convert collection to plain array if ($tenants instanceof BaseCollection && is_string($tenants->first())) { $tenants = $tenants->toArray(); } // Find tenants by slug, and get their IDs if (is_string($tenants) || (is_array($tenants) && is_string(array_first($tenants)))) { $tenants = app('rinvex.tenants.tenant')->whereIn('slug', $tenants)->get()->pluck('id'); } if ($tenants instanceof Model) { return [$tenants->getKey()]; } if ($tenants instanceof Collection) { return $tenants->modelKeys(); } if ($tenants instanceof BaseCollection) { return $tenants->toArray(); } return (array) $tenants; }
[ "protected", "function", "prepareTenantIds", "(", "$", "tenants", ")", ":", "array", "{", "// Convert collection to plain array", "if", "(", "$", "tenants", "instanceof", "BaseCollection", "&&", "is_string", "(", "$", "tenants", "->", "first", "(", ")", ")", ")", "{", "$", "tenants", "=", "$", "tenants", "->", "toArray", "(", ")", ";", "}", "// Find tenants by slug, and get their IDs", "if", "(", "is_string", "(", "$", "tenants", ")", "||", "(", "is_array", "(", "$", "tenants", ")", "&&", "is_string", "(", "array_first", "(", "$", "tenants", ")", ")", ")", ")", "{", "$", "tenants", "=", "app", "(", "'rinvex.tenants.tenant'", ")", "->", "whereIn", "(", "'slug'", ",", "$", "tenants", ")", "->", "get", "(", ")", "->", "pluck", "(", "'id'", ")", ";", "}", "if", "(", "$", "tenants", "instanceof", "Model", ")", "{", "return", "[", "$", "tenants", "->", "getKey", "(", ")", "]", ";", "}", "if", "(", "$", "tenants", "instanceof", "Collection", ")", "{", "return", "$", "tenants", "->", "modelKeys", "(", ")", ";", "}", "if", "(", "$", "tenants", "instanceof", "BaseCollection", ")", "{", "return", "$", "tenants", "->", "toArray", "(", ")", ";", "}", "return", "(", "array", ")", "$", "tenants", ";", "}" ]
Prepare tenant IDs. @param mixed $tenants @return array
[ "Prepare", "tenant", "IDs", "." ]
a7700cddf4a304ab241025a6ef4bc4eb274983e6
https://github.com/rinvex/laravel-tenants/blob/a7700cddf4a304ab241025a6ef4bc4eb274983e6/src/Traits/Tenantable.php#L315-L340
train
sagebind/slack-client
src/Message/MessageBuilder.php
MessageBuilder.setText
public function setText($text, $markdown = true) { $this->data['text'] = $text; $this->data['mrkdwn'] = $markdown; return $this; }
php
public function setText($text, $markdown = true) { $this->data['text'] = $text; $this->data['mrkdwn'] = $markdown; return $this; }
[ "public", "function", "setText", "(", "$", "text", ",", "$", "markdown", "=", "true", ")", "{", "$", "this", "->", "data", "[", "'text'", "]", "=", "$", "text", ";", "$", "this", "->", "data", "[", "'mrkdwn'", "]", "=", "$", "markdown", ";", "return", "$", "this", ";", "}" ]
Sets the message text. @param string $text The message body text. @param bool $markdown Enable or disable Markdown parsing of the text. @return $this
[ "Sets", "the", "message", "text", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Message/MessageBuilder.php#L50-L55
train
sagebind/slack-client
src/Group.php
Group.rename
public function rename($name) { return $this->client->apiCall('groups.rename', [ 'channel' => $this->getId(), 'name' => $name, ])->then(function () use ($name) { $this->data['name'] = $name; return $name; }); }
php
public function rename($name) { return $this->client->apiCall('groups.rename', [ 'channel' => $this->getId(), 'name' => $name, ])->then(function () use ($name) { $this->data['name'] = $name; return $name; }); }
[ "public", "function", "rename", "(", "$", "name", ")", "{", "return", "$", "this", "->", "client", "->", "apiCall", "(", "'groups.rename'", ",", "[", "'channel'", "=>", "$", "this", "->", "getId", "(", ")", ",", "'name'", "=>", "$", "name", ",", "]", ")", "->", "then", "(", "function", "(", ")", "use", "(", "$", "name", ")", "{", "$", "this", "->", "data", "[", "'name'", "]", "=", "$", "name", ";", "return", "$", "name", ";", "}", ")", ";", "}" ]
Renames the group. @param string $name The name to set to. @return \React\Promise\PromiseInterface
[ "Renames", "the", "group", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Group.php#L16-L25
train
sagebind/slack-client
src/Group.php
Group.setPurpose
public function setPurpose($text) { return $this->client->apiCall('groups.setPurpose', [ 'channel' => $this->getId(), 'purpose' => $text, ])->then(function () use ($text) { $this->data['purpose']['value'] = $text; return $text; }); }
php
public function setPurpose($text) { return $this->client->apiCall('groups.setPurpose', [ 'channel' => $this->getId(), 'purpose' => $text, ])->then(function () use ($text) { $this->data['purpose']['value'] = $text; return $text; }); }
[ "public", "function", "setPurpose", "(", "$", "text", ")", "{", "return", "$", "this", "->", "client", "->", "apiCall", "(", "'groups.setPurpose'", ",", "[", "'channel'", "=>", "$", "this", "->", "getId", "(", ")", ",", "'purpose'", "=>", "$", "text", ",", "]", ")", "->", "then", "(", "function", "(", ")", "use", "(", "$", "text", ")", "{", "$", "this", "->", "data", "[", "'purpose'", "]", "[", "'value'", "]", "=", "$", "text", ";", "return", "$", "text", ";", "}", ")", ";", "}" ]
Sets the group's purpose text. @param string $text The new purpose text to set to. @return \React\Promise\PromiseInterface
[ "Sets", "the", "group", "s", "purpose", "text", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Group.php#L34-L43
train
sagebind/slack-client
src/Group.php
Group.open
public function open() { return $this->client->apiCall('groups.open', [ 'channel' => $this->getId(), ])->then(function ($response) { return !isset($response['no_op']); }); }
php
public function open() { return $this->client->apiCall('groups.open', [ 'channel' => $this->getId(), ])->then(function ($response) { return !isset($response['no_op']); }); }
[ "public", "function", "open", "(", ")", "{", "return", "$", "this", "->", "client", "->", "apiCall", "(", "'groups.open'", ",", "[", "'channel'", "=>", "$", "this", "->", "getId", "(", ")", ",", "]", ")", "->", "then", "(", "function", "(", "$", "response", ")", "{", "return", "!", "isset", "(", "$", "response", "[", "'no_op'", "]", ")", ";", "}", ")", ";", "}" ]
Opens the group. @return \React\Promise\PromiseInterface
[ "Opens", "the", "group", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Group.php#L130-L137
train
sagebind/slack-client
src/Payload.php
Payload.fromJson
public static function fromJson($json) { $data = json_decode((string)$json, true); if (json_last_error() !== JSON_ERROR_NONE || !is_array($data)) { throw new \UnexpectedValueException('Invalid JSON message.'); } return new static($data); }
php
public static function fromJson($json) { $data = json_decode((string)$json, true); if (json_last_error() !== JSON_ERROR_NONE || !is_array($data)) { throw new \UnexpectedValueException('Invalid JSON message.'); } return new static($data); }
[ "public", "static", "function", "fromJson", "(", "$", "json", ")", "{", "$", "data", "=", "json_decode", "(", "(", "string", ")", "$", "json", ",", "true", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", "||", "!", "is_array", "(", "$", "data", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Invalid JSON message.'", ")", ";", "}", "return", "new", "static", "(", "$", "data", ")", ";", "}" ]
Creates a response object from a JSON message. @param string $json A JSON string. @return Response The parsed response.
[ "Creates", "a", "response", "object", "from", "a", "JSON", "message", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Payload.php#L21-L30
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getChannelGroupOrDMByID
public function getChannelGroupOrDMByID($id) { if ($id[0] === 'D') { return $this->getDMById($id); } if ($id[0] === 'G') { return $this->getGroupById($id); } return $this->getChannelById($id); }
php
public function getChannelGroupOrDMByID($id) { if ($id[0] === 'D') { return $this->getDMById($id); } if ($id[0] === 'G') { return $this->getGroupById($id); } return $this->getChannelById($id); }
[ "public", "function", "getChannelGroupOrDMByID", "(", "$", "id", ")", "{", "if", "(", "$", "id", "[", "0", "]", "===", "'D'", ")", "{", "return", "$", "this", "->", "getDMById", "(", "$", "id", ")", ";", "}", "if", "(", "$", "id", "[", "0", "]", "===", "'G'", ")", "{", "return", "$", "this", "->", "getGroupById", "(", "$", "id", ")", ";", "}", "return", "$", "this", "->", "getChannelById", "(", "$", "id", ")", ";", "}" ]
Gets a channel, group, or DM channel by ID. @param string $id The channel ID. @return \React\Promise\PromiseInterface A promise for a channel interface.
[ "Gets", "a", "channel", "group", "or", "DM", "channel", "by", "ID", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L99-L110
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getChannels
public function getChannels() { return $this->apiCall('channels.list')->then(function ($response) { $channels = []; foreach ($response['channels'] as $channel) { $channels[] = new Channel($this, $channel); } return $channels; }); }
php
public function getChannels() { return $this->apiCall('channels.list')->then(function ($response) { $channels = []; foreach ($response['channels'] as $channel) { $channels[] = new Channel($this, $channel); } return $channels; }); }
[ "public", "function", "getChannels", "(", ")", "{", "return", "$", "this", "->", "apiCall", "(", "'channels.list'", ")", "->", "then", "(", "function", "(", "$", "response", ")", "{", "$", "channels", "=", "[", "]", ";", "foreach", "(", "$", "response", "[", "'channels'", "]", "as", "$", "channel", ")", "{", "$", "channels", "[", "]", "=", "new", "Channel", "(", "$", "this", ",", "$", "channel", ")", ";", "}", "return", "$", "channels", ";", "}", ")", ";", "}" ]
Gets all channels in the team. @return \React\Promise\PromiseInterface
[ "Gets", "all", "channels", "in", "the", "team", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L117-L126
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getChannelById
public function getChannelById($id) { return $this->apiCall('channels.info', [ 'channel' => $id, ])->then(function (Payload $response) { return new Channel($this, $response['channel']); }); }
php
public function getChannelById($id) { return $this->apiCall('channels.info', [ 'channel' => $id, ])->then(function (Payload $response) { return new Channel($this, $response['channel']); }); }
[ "public", "function", "getChannelById", "(", "$", "id", ")", "{", "return", "$", "this", "->", "apiCall", "(", "'channels.info'", ",", "[", "'channel'", "=>", "$", "id", ",", "]", ")", "->", "then", "(", "function", "(", "Payload", "$", "response", ")", "{", "return", "new", "Channel", "(", "$", "this", ",", "$", "response", "[", "'channel'", "]", ")", ";", "}", ")", ";", "}" ]
Gets a channel by its ID. @param string $id A channel ID. @return \React\Promise\PromiseInterface A promise for a channel object.
[ "Gets", "a", "channel", "by", "its", "ID", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L135-L142
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getChannelByName
public function getChannelByName($name) { return $this->getChannels()->then(function (array $channels) use ($name) { foreach ($channels as $channel) { if ($channel->getName() === $name) { return $channel; } } throw new ApiException('Channel ' . $name . ' not found.'); }); }
php
public function getChannelByName($name) { return $this->getChannels()->then(function (array $channels) use ($name) { foreach ($channels as $channel) { if ($channel->getName() === $name) { return $channel; } } throw new ApiException('Channel ' . $name . ' not found.'); }); }
[ "public", "function", "getChannelByName", "(", "$", "name", ")", "{", "return", "$", "this", "->", "getChannels", "(", ")", "->", "then", "(", "function", "(", "array", "$", "channels", ")", "use", "(", "$", "name", ")", "{", "foreach", "(", "$", "channels", "as", "$", "channel", ")", "{", "if", "(", "$", "channel", "->", "getName", "(", ")", "===", "$", "name", ")", "{", "return", "$", "channel", ";", "}", "}", "throw", "new", "ApiException", "(", "'Channel '", ".", "$", "name", ".", "' not found.'", ")", ";", "}", ")", ";", "}" ]
Gets a channel by its name. @param string $name The name of the channel. @return \React\Promise\PromiseInterface
[ "Gets", "a", "channel", "by", "its", "name", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L151-L162
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getGroups
public function getGroups() { return $this->apiCall('groups.list')->then(function ($response) { $groups = []; foreach ($response['groups'] as $group) { $groups[] = new Group($this, $group); } return $groups; }); }
php
public function getGroups() { return $this->apiCall('groups.list')->then(function ($response) { $groups = []; foreach ($response['groups'] as $group) { $groups[] = new Group($this, $group); } return $groups; }); }
[ "public", "function", "getGroups", "(", ")", "{", "return", "$", "this", "->", "apiCall", "(", "'groups.list'", ")", "->", "then", "(", "function", "(", "$", "response", ")", "{", "$", "groups", "=", "[", "]", ";", "foreach", "(", "$", "response", "[", "'groups'", "]", "as", "$", "group", ")", "{", "$", "groups", "[", "]", "=", "new", "Group", "(", "$", "this", ",", "$", "group", ")", ";", "}", "return", "$", "groups", ";", "}", ")", ";", "}" ]
Gets all groups the authenticated user is a member of. @return \React\Promise\PromiseInterface
[ "Gets", "all", "groups", "the", "authenticated", "user", "is", "a", "member", "of", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L169-L178
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getGroupById
public function getGroupById($id) { return $this->apiCall('groups.info', [ 'channel' => $id, ])->then(function (Payload $response) { return new Group($this, $response['group']); }); }
php
public function getGroupById($id) { return $this->apiCall('groups.info', [ 'channel' => $id, ])->then(function (Payload $response) { return new Group($this, $response['group']); }); }
[ "public", "function", "getGroupById", "(", "$", "id", ")", "{", "return", "$", "this", "->", "apiCall", "(", "'groups.info'", ",", "[", "'channel'", "=>", "$", "id", ",", "]", ")", "->", "then", "(", "function", "(", "Payload", "$", "response", ")", "{", "return", "new", "Group", "(", "$", "this", ",", "$", "response", "[", "'group'", "]", ")", ";", "}", ")", ";", "}" ]
Gets a group by its ID. @param string $id A group ID. @return \React\Promise\PromiseInterface A promise for a group object.
[ "Gets", "a", "group", "by", "its", "ID", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L187-L194
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getGroupByName
public function getGroupByName($name) { return $this->getGroups()->then(function (array $groups) use ($name) { foreach ($groups as $group) { if ($group->getName() === $name) { return $group; } } throw new ApiException('Group ' . $name . ' not found.'); }); }
php
public function getGroupByName($name) { return $this->getGroups()->then(function (array $groups) use ($name) { foreach ($groups as $group) { if ($group->getName() === $name) { return $group; } } throw new ApiException('Group ' . $name . ' not found.'); }); }
[ "public", "function", "getGroupByName", "(", "$", "name", ")", "{", "return", "$", "this", "->", "getGroups", "(", ")", "->", "then", "(", "function", "(", "array", "$", "groups", ")", "use", "(", "$", "name", ")", "{", "foreach", "(", "$", "groups", "as", "$", "group", ")", "{", "if", "(", "$", "group", "->", "getName", "(", ")", "===", "$", "name", ")", "{", "return", "$", "group", ";", "}", "}", "throw", "new", "ApiException", "(", "'Group '", ".", "$", "name", ".", "' not found.'", ")", ";", "}", ")", ";", "}" ]
Gets a group by its name. @param string $name The name of the group. @return \React\Promise\PromiseInterface
[ "Gets", "a", "group", "by", "its", "name", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L203-L214
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getDMs
public function getDMs() { return $this->apiCall('im.list')->then(function ($response) { $dms = []; foreach ($response['ims'] as $dm) { $dms[] = new DirectMessageChannel($this, $dm); } return $dms; }); }
php
public function getDMs() { return $this->apiCall('im.list')->then(function ($response) { $dms = []; foreach ($response['ims'] as $dm) { $dms[] = new DirectMessageChannel($this, $dm); } return $dms; }); }
[ "public", "function", "getDMs", "(", ")", "{", "return", "$", "this", "->", "apiCall", "(", "'im.list'", ")", "->", "then", "(", "function", "(", "$", "response", ")", "{", "$", "dms", "=", "[", "]", ";", "foreach", "(", "$", "response", "[", "'ims'", "]", "as", "$", "dm", ")", "{", "$", "dms", "[", "]", "=", "new", "DirectMessageChannel", "(", "$", "this", ",", "$", "dm", ")", ";", "}", "return", "$", "dms", ";", "}", ")", ";", "}" ]
Gets all DMs the authenticated user has. @return \React\Promise\PromiseInterface
[ "Gets", "all", "DMs", "the", "authenticated", "user", "has", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L221-L230
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getDMById
public function getDMById($id) { return $this->getDMs()->then(function (array $dms) use ($id) { foreach ($dms as $dm) { if ($dm->getId() === $id) { return $dm; } } throw new ApiException('DM ' . $id . ' not found.'); }); }
php
public function getDMById($id) { return $this->getDMs()->then(function (array $dms) use ($id) { foreach ($dms as $dm) { if ($dm->getId() === $id) { return $dm; } } throw new ApiException('DM ' . $id . ' not found.'); }); }
[ "public", "function", "getDMById", "(", "$", "id", ")", "{", "return", "$", "this", "->", "getDMs", "(", ")", "->", "then", "(", "function", "(", "array", "$", "dms", ")", "use", "(", "$", "id", ")", "{", "foreach", "(", "$", "dms", "as", "$", "dm", ")", "{", "if", "(", "$", "dm", "->", "getId", "(", ")", "===", "$", "id", ")", "{", "return", "$", "dm", ";", "}", "}", "throw", "new", "ApiException", "(", "'DM '", ".", "$", "id", ".", "' not found.'", ")", ";", "}", ")", ";", "}" ]
Gets a direct message channel by its ID. @param string $id A DM channel ID. @return \React\Promise\PromiseInterface A promise for a DM object.
[ "Gets", "a", "direct", "message", "channel", "by", "its", "ID", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L239-L250
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getDMByUserId
public function getDMByUserId($id) { return $this->apiCall('im.open', [ 'user' => $id, ])->then(function (Payload $response) { return $this->getDMById($response['channel']['id']); }); }
php
public function getDMByUserId($id) { return $this->apiCall('im.open', [ 'user' => $id, ])->then(function (Payload $response) { return $this->getDMById($response['channel']['id']); }); }
[ "public", "function", "getDMByUserId", "(", "$", "id", ")", "{", "return", "$", "this", "->", "apiCall", "(", "'im.open'", ",", "[", "'user'", "=>", "$", "id", ",", "]", ")", "->", "then", "(", "function", "(", "Payload", "$", "response", ")", "{", "return", "$", "this", "->", "getDMById", "(", "$", "response", "[", "'channel'", "]", "[", "'id'", "]", ")", ";", "}", ")", ";", "}" ]
Gets a direct message channel by user's ID. @param string $id A user ID. @return \React\Promise\PromiseInterface A promise for a DM object.
[ "Gets", "a", "direct", "message", "channel", "by", "user", "s", "ID", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L271-L278
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getUsers
public function getUsers() { // get the user list return $this->apiCall('users.list')->then(function (Payload $response) { $users = []; foreach ($response['members'] as $member) { $users[] = new User($this, $member); } return $users; }); }
php
public function getUsers() { // get the user list return $this->apiCall('users.list')->then(function (Payload $response) { $users = []; foreach ($response['members'] as $member) { $users[] = new User($this, $member); } return $users; }); }
[ "public", "function", "getUsers", "(", ")", "{", "// get the user list", "return", "$", "this", "->", "apiCall", "(", "'users.list'", ")", "->", "then", "(", "function", "(", "Payload", "$", "response", ")", "{", "$", "users", "=", "[", "]", ";", "foreach", "(", "$", "response", "[", "'members'", "]", "as", "$", "member", ")", "{", "$", "users", "[", "]", "=", "new", "User", "(", "$", "this", ",", "$", "member", ")", ";", "}", "return", "$", "users", ";", "}", ")", ";", "}" ]
Gets all users in the Slack team. @return \React\Promise\PromiseInterface A promise for an array of users.
[ "Gets", "all", "users", "in", "the", "Slack", "team", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L285-L295
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getUserById
public function getUserById($id) { return $this->apiCall('users.info', [ 'user' => $id, ])->then(function (Payload $response) { return new User($this, $response['user']); }); }
php
public function getUserById($id) { return $this->apiCall('users.info', [ 'user' => $id, ])->then(function (Payload $response) { return new User($this, $response['user']); }); }
[ "public", "function", "getUserById", "(", "$", "id", ")", "{", "return", "$", "this", "->", "apiCall", "(", "'users.info'", ",", "[", "'user'", "=>", "$", "id", ",", "]", ")", "->", "then", "(", "function", "(", "Payload", "$", "response", ")", "{", "return", "new", "User", "(", "$", "this", ",", "$", "response", "[", "'user'", "]", ")", ";", "}", ")", ";", "}" ]
Gets a user by its ID. @param string $id A user ID. @return \React\Promise\PromiseInterface A promise for a user object.
[ "Gets", "a", "user", "by", "its", "ID", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L304-L311
train
sagebind/slack-client
src/ApiClient.php
ApiClient.getUserByName
public function getUserByName($username) { return $this->getUsers()->then(function (array $users) use ($username) { foreach ($users as $user) { if ($user->getUsername() === $username) { return $user; } } throw new UserNotFoundException("The user \"$username\" does not exist."); }); }
php
public function getUserByName($username) { return $this->getUsers()->then(function (array $users) use ($username) { foreach ($users as $user) { if ($user->getUsername() === $username) { return $user; } } throw new UserNotFoundException("The user \"$username\" does not exist."); }); }
[ "public", "function", "getUserByName", "(", "$", "username", ")", "{", "return", "$", "this", "->", "getUsers", "(", ")", "->", "then", "(", "function", "(", "array", "$", "users", ")", "use", "(", "$", "username", ")", "{", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "if", "(", "$", "user", "->", "getUsername", "(", ")", "===", "$", "username", ")", "{", "return", "$", "user", ";", "}", "}", "throw", "new", "UserNotFoundException", "(", "\"The user \\\"$username\\\" does not exist.\"", ")", ";", "}", ")", ";", "}" ]
Gets a user by username. If the user could not be found, the returned promise is rejected with a `UserNotFoundException` exception. @return \React\Promise\PromiseInterface A promise for a user object.
[ "Gets", "a", "user", "by", "username", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L321-L332
train
sagebind/slack-client
src/ApiClient.php
ApiClient.send
public function send($text, ChannelInterface $channel) { $message = $this->getMessageBuilder() ->setText($text) ->setChannel($channel) ->create(); return $this->postMessage($message); }
php
public function send($text, ChannelInterface $channel) { $message = $this->getMessageBuilder() ->setText($text) ->setChannel($channel) ->create(); return $this->postMessage($message); }
[ "public", "function", "send", "(", "$", "text", ",", "ChannelInterface", "$", "channel", ")", "{", "$", "message", "=", "$", "this", "->", "getMessageBuilder", "(", ")", "->", "setText", "(", "$", "text", ")", "->", "setChannel", "(", "$", "channel", ")", "->", "create", "(", ")", ";", "return", "$", "this", "->", "postMessage", "(", "$", "message", ")", ";", "}" ]
Sends a regular text message to a given channel. @param string $text The message text. @param ChannelInterface $channel The channel to send the message to. @return \React\Promise\PromiseInterface
[ "Sends", "a", "regular", "text", "message", "to", "a", "given", "channel", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L341-L349
train
sagebind/slack-client
src/ApiClient.php
ApiClient.postMessage
public function postMessage(Message $message) { $options = [ 'text' => $message->getText(), 'channel' => $message->data['channel'], 'as_user' => true, ]; if ($message->hasAttachments()) { $options['attachments'] = json_encode($message->getAttachments()); } return $this->apiCall('chat.postMessage', $options); }
php
public function postMessage(Message $message) { $options = [ 'text' => $message->getText(), 'channel' => $message->data['channel'], 'as_user' => true, ]; if ($message->hasAttachments()) { $options['attachments'] = json_encode($message->getAttachments()); } return $this->apiCall('chat.postMessage', $options); }
[ "public", "function", "postMessage", "(", "Message", "$", "message", ")", "{", "$", "options", "=", "[", "'text'", "=>", "$", "message", "->", "getText", "(", ")", ",", "'channel'", "=>", "$", "message", "->", "data", "[", "'channel'", "]", ",", "'as_user'", "=>", "true", ",", "]", ";", "if", "(", "$", "message", "->", "hasAttachments", "(", ")", ")", "{", "$", "options", "[", "'attachments'", "]", "=", "json_encode", "(", "$", "message", "->", "getAttachments", "(", ")", ")", ";", "}", "return", "$", "this", "->", "apiCall", "(", "'chat.postMessage'", ",", "$", "options", ")", ";", "}" ]
Posts a message. @param \Slack\Message\Message $message The message to post. @return \React\Promise\PromiseInterface
[ "Posts", "a", "message", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/ApiClient.php#L358-L371
train
sagebind/slack-client
src/Message/Attachment.php
Attachment.getTimestamp
public function getTimestamp() { if (!isset($this->data['ts'])) { return null; } $time = new \DateTime(); $time->setTimestamp($this->data['ts']); return $time; }
php
public function getTimestamp() { if (!isset($this->data['ts'])) { return null; } $time = new \DateTime(); $time->setTimestamp($this->data['ts']); return $time; }
[ "public", "function", "getTimestamp", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'ts'", "]", ")", ")", "{", "return", "null", ";", "}", "$", "time", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "time", "->", "setTimestamp", "(", "$", "this", "->", "data", "[", "'ts'", "]", ")", ";", "return", "$", "time", ";", "}" ]
Gets an extra timestamp value in the footer. @return \DateTime The time of the timestamp.
[ "Gets", "an", "extra", "timestamp", "value", "in", "the", "footer", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Message/Attachment.php#L165-L174
train
sagebind/slack-client
src/Channel.php
Channel.getMembers
public function getMembers() { $memberPromises = []; foreach ($this->data['members'] as $memberId) { $memberPromises[] = $this->client->getUserById($memberId); } return Promise\all($memberPromises); }
php
public function getMembers() { $memberPromises = []; foreach ($this->data['members'] as $memberId) { $memberPromises[] = $this->client->getUserById($memberId); } return Promise\all($memberPromises); }
[ "public", "function", "getMembers", "(", ")", "{", "$", "memberPromises", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'members'", "]", "as", "$", "memberId", ")", "{", "$", "memberPromises", "[", "]", "=", "$", "this", "->", "client", "->", "getUserById", "(", "$", "memberId", ")", ";", "}", "return", "Promise", "\\", "all", "(", "$", "memberPromises", ")", ";", "}" ]
Gets an iterator over all users in the channel. @return \React\Promise\PromiseInterface A promise for an array of user objects for each member in the channel.
[ "Gets", "an", "iterator", "over", "all", "users", "in", "the", "channel", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Channel.php#L55-L63
train
sagebind/slack-client
src/Channel.php
Channel.setTopic
public function setTopic($text) { return $this->client->apiCall('channels.setTopic', [ 'channel' => $this->getId(), 'topic' => $text, ])->then(function () use ($text) { $this->data['topic']['value'] = $text; return $text; }); }
php
public function setTopic($text) { return $this->client->apiCall('channels.setTopic', [ 'channel' => $this->getId(), 'topic' => $text, ])->then(function () use ($text) { $this->data['topic']['value'] = $text; return $text; }); }
[ "public", "function", "setTopic", "(", "$", "text", ")", "{", "return", "$", "this", "->", "client", "->", "apiCall", "(", "'channels.setTopic'", ",", "[", "'channel'", "=>", "$", "this", "->", "getId", "(", ")", ",", "'topic'", "=>", "$", "text", ",", "]", ")", "->", "then", "(", "function", "(", ")", "use", "(", "$", "text", ")", "{", "$", "this", "->", "data", "[", "'topic'", "]", "[", "'value'", "]", "=", "$", "text", ";", "return", "$", "text", ";", "}", ")", ";", "}" ]
Sets the channel topic text. @param string $text The new topic text to set to. @return \React\Promise\PromiseInterface
[ "Sets", "the", "channel", "topic", "text", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Channel.php#L150-L159
train
sagebind/slack-client
src/Channel.php
Channel.archive
public function archive() { return $this->client->apiCall('channels.archive', [ 'channel' => $this->getId(), ])->then(function () { $this->data['is_archived'] = true; }); }
php
public function archive() { return $this->client->apiCall('channels.archive', [ 'channel' => $this->getId(), ])->then(function () { $this->data['is_archived'] = true; }); }
[ "public", "function", "archive", "(", ")", "{", "return", "$", "this", "->", "client", "->", "apiCall", "(", "'channels.archive'", ",", "[", "'channel'", "=>", "$", "this", "->", "getId", "(", ")", ",", "]", ")", "->", "then", "(", "function", "(", ")", "{", "$", "this", "->", "data", "[", "'is_archived'", "]", "=", "true", ";", "}", ")", ";", "}" ]
Archives the channel. @return \React\Promise\PromiseInterface
[ "Archives", "the", "channel", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Channel.php#L166-L173
train
sagebind/slack-client
src/Channel.php
Channel.unarchive
public function unarchive() { return $this->client->apiCall('channels.unarchive', [ 'channel' => $this->getId(), ])->then(function () { $this->data['is_archived'] = false; }); }
php
public function unarchive() { return $this->client->apiCall('channels.unarchive', [ 'channel' => $this->getId(), ])->then(function () { $this->data['is_archived'] = false; }); }
[ "public", "function", "unarchive", "(", ")", "{", "return", "$", "this", "->", "client", "->", "apiCall", "(", "'channels.unarchive'", ",", "[", "'channel'", "=>", "$", "this", "->", "getId", "(", ")", ",", "]", ")", "->", "then", "(", "function", "(", ")", "{", "$", "this", "->", "data", "[", "'is_archived'", "]", "=", "false", ";", "}", ")", ";", "}" ]
Un-archives the channel. @return \React\Promise\PromiseInterface
[ "Un", "-", "archives", "the", "channel", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Channel.php#L180-L187
train
sagebind/slack-client
src/Channel.php
Channel.inviteUser
public function inviteUser(User $user) { return $this->client->apiCall('channels.invite', [ 'channel' => $this->getId(), 'user' => $user->getId(), ])->then(function () use ($user) { $this->data['members'][] = $user->getId(); }); }
php
public function inviteUser(User $user) { return $this->client->apiCall('channels.invite', [ 'channel' => $this->getId(), 'user' => $user->getId(), ])->then(function () use ($user) { $this->data['members'][] = $user->getId(); }); }
[ "public", "function", "inviteUser", "(", "User", "$", "user", ")", "{", "return", "$", "this", "->", "client", "->", "apiCall", "(", "'channels.invite'", ",", "[", "'channel'", "=>", "$", "this", "->", "getId", "(", ")", ",", "'user'", "=>", "$", "user", "->", "getId", "(", ")", ",", "]", ")", "->", "then", "(", "function", "(", ")", "use", "(", "$", "user", ")", "{", "$", "this", "->", "data", "[", "'members'", "]", "[", "]", "=", "$", "user", "->", "getId", "(", ")", ";", "}", ")", ";", "}" ]
Invites a user to the channel. @param User The user to invite. @return \React\Promise\PromiseInterface
[ "Invites", "a", "user", "to", "the", "channel", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Channel.php#L196-L204
train
sagebind/slack-client
src/DataObject.php
DataObject.fromData
public static function fromData(array $data) { $reflection = new \ReflectionClass(static::class); $instance = $reflection->newInstanceWithoutConstructor(); $instance->data = $data; $instance->jsonUnserialize($data); return $instance; }
php
public static function fromData(array $data) { $reflection = new \ReflectionClass(static::class); $instance = $reflection->newInstanceWithoutConstructor(); $instance->data = $data; $instance->jsonUnserialize($data); return $instance; }
[ "public", "static", "function", "fromData", "(", "array", "$", "data", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "static", "::", "class", ")", ";", "$", "instance", "=", "$", "reflection", "->", "newInstanceWithoutConstructor", "(", ")", ";", "$", "instance", "->", "data", "=", "$", "data", ";", "$", "instance", "->", "jsonUnserialize", "(", "$", "data", ")", ";", "return", "$", "instance", ";", "}" ]
Creates a data object from an array of data. @param array $data The array containing object data. @return self A new object instance.
[ "Creates", "a", "data", "object", "from", "an", "array", "of", "data", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/DataObject.php#L21-L28
train
sagebind/slack-client
src/Message/AttachmentBuilder.php
AttachmentBuilder.setTitle
public function setTitle($title, $link = null) { $this->data['title'] = $title; if ($link) { $this->data['title_link'] = $link; } return $this; }
php
public function setTitle($title, $link = null) { $this->data['title'] = $title; if ($link) { $this->data['title_link'] = $link; } return $this; }
[ "public", "function", "setTitle", "(", "$", "title", ",", "$", "link", "=", "null", ")", "{", "$", "this", "->", "data", "[", "'title'", "]", "=", "$", "title", ";", "if", "(", "$", "link", ")", "{", "$", "this", "->", "data", "[", "'title_link'", "]", "=", "$", "link", ";", "}", "return", "$", "this", ";", "}" ]
Sets the attachment title with an optional link. @param string $title The attachment title text. @param string $link An optional URL the title should link to. @return $this
[ "Sets", "the", "attachment", "title", "with", "an", "optional", "link", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Message/AttachmentBuilder.php#L24-L32
train
sagebind/slack-client
src/Message/AttachmentBuilder.php
AttachmentBuilder.setText
public function setText($text, $markdown = false) { $this->data['text'] = $text; $this->markdownInText = $markdown; return $this; }
php
public function setText($text, $markdown = false) { $this->data['text'] = $text; $this->markdownInText = $markdown; return $this; }
[ "public", "function", "setText", "(", "$", "text", ",", "$", "markdown", "=", "false", ")", "{", "$", "this", "->", "data", "[", "'text'", "]", "=", "$", "text", ";", "$", "this", "->", "markdownInText", "=", "$", "markdown", ";", "return", "$", "this", ";", "}" ]
Sets the main text of the attachment. @param string $text The attachment text. @param bool $markdown Enables or disables Markdown parsing in the text. @return $this
[ "Sets", "the", "main", "text", "of", "the", "attachment", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Message/AttachmentBuilder.php#L41-L47
train
sagebind/slack-client
src/Message/AttachmentBuilder.php
AttachmentBuilder.setPretext
public function setPretext($pretext, $markdown = false) { $this->data['pretext'] = $pretext; $this->markdownInPretext = $markdown; return $this; }
php
public function setPretext($pretext, $markdown = false) { $this->data['pretext'] = $pretext; $this->markdownInPretext = $markdown; return $this; }
[ "public", "function", "setPretext", "(", "$", "pretext", ",", "$", "markdown", "=", "false", ")", "{", "$", "this", "->", "data", "[", "'pretext'", "]", "=", "$", "pretext", ";", "$", "this", "->", "markdownInPretext", "=", "$", "markdown", ";", "return", "$", "this", ";", "}" ]
Sets the attachment pretext. This is optional text that appears above the message attachment block. @param string $pretext The attachment pretext. @param bool $markdown Enables or disables Markdown parsing in the pretext. @return $this
[ "Sets", "the", "attachment", "pretext", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Message/AttachmentBuilder.php#L73-L79
train
sagebind/slack-client
src/Message/AttachmentBuilder.php
AttachmentBuilder.setAuthor
public function setAuthor($name, $link = null, $icon = null) { $this->data['author_name'] = $name; if ($link) { $this->data['author_link'] = $link; } if ($icon) { $this->data['author_icon'] = $icon; } return $this; }
php
public function setAuthor($name, $link = null, $icon = null) { $this->data['author_name'] = $name; if ($link) { $this->data['author_link'] = $link; } if ($icon) { $this->data['author_icon'] = $icon; } return $this; }
[ "public", "function", "setAuthor", "(", "$", "name", ",", "$", "link", "=", "null", ",", "$", "icon", "=", "null", ")", "{", "$", "this", "->", "data", "[", "'author_name'", "]", "=", "$", "name", ";", "if", "(", "$", "link", ")", "{", "$", "this", "->", "data", "[", "'author_link'", "]", "=", "$", "link", ";", "}", "if", "(", "$", "icon", ")", "{", "$", "this", "->", "data", "[", "'author_icon'", "]", "=", "$", "icon", ";", "}", "return", "$", "this", ";", "}" ]
Sets the message author. @param string $name The author name. @param string $link An optional URL that the author text should link to. @param string $icon An optional URL to an image to show to the left of the author name. @return $this
[ "Sets", "the", "message", "author", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Message/AttachmentBuilder.php#L102-L113
train
sagebind/slack-client
src/Message/AttachmentBuilder.php
AttachmentBuilder.setFooter
public function setFooter($text, $icon = null) { $this->data['footer'] = $text; if ($icon) { $this->data['footer_icon'] = $icon; } return $this; }
php
public function setFooter($text, $icon = null) { $this->data['footer'] = $text; if ($icon) { $this->data['footer_icon'] = $icon; } return $this; }
[ "public", "function", "setFooter", "(", "$", "text", ",", "$", "icon", "=", "null", ")", "{", "$", "this", "->", "data", "[", "'footer'", "]", "=", "$", "text", ";", "if", "(", "$", "icon", ")", "{", "$", "this", "->", "data", "[", "'footer_icon'", "]", "=", "$", "icon", ";", "}", "return", "$", "this", ";", "}" ]
Sets an attachment footer shown beneath the attachment body. @param string $text Brief footer text. @param string $icon An optional URL to an image to show to the left of the footer text. @return $this
[ "Sets", "an", "attachment", "footer", "shown", "beneath", "the", "attachment", "body", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Message/AttachmentBuilder.php#L148-L156
train
sagebind/slack-client
src/Message/AttachmentBuilder.php
AttachmentBuilder.addField
public function addField(AttachmentField $field) { if (!isset($this->data['fields'])) { $this->data['fields'] = []; } $this->data['fields'][] = $field->data; return $this; }
php
public function addField(AttachmentField $field) { if (!isset($this->data['fields'])) { $this->data['fields'] = []; } $this->data['fields'][] = $field->data; return $this; }
[ "public", "function", "addField", "(", "AttachmentField", "$", "field", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", ")", "{", "$", "this", "->", "data", "[", "'fields'", "]", "=", "[", "]", ";", "}", "$", "this", "->", "data", "[", "'fields'", "]", "[", "]", "=", "$", "field", "->", "data", ";", "return", "$", "this", ";", "}" ]
Adds a field to the attachment. @param AttachmentField $field The field to add. @return $this
[ "Adds", "a", "field", "to", "the", "attachment", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Message/AttachmentBuilder.php#L177-L186
train
sagebind/slack-client
src/Message/AttachmentBuilder.php
AttachmentBuilder.create
public function create() { $this->data['mrkdwn_in'] = []; if ($this->markdownInText) { $this->data['mrkdwn_in'][] = 'text'; } if ($this->markdownInPretext) { $this->data['mrkdwn_in'][] = 'pretext'; } if ($this->markdownInFields) { $this->data['mrkdwn_in'][] = 'fields'; } return Attachment::fromData($this->data); }
php
public function create() { $this->data['mrkdwn_in'] = []; if ($this->markdownInText) { $this->data['mrkdwn_in'][] = 'text'; } if ($this->markdownInPretext) { $this->data['mrkdwn_in'][] = 'pretext'; } if ($this->markdownInFields) { $this->data['mrkdwn_in'][] = 'fields'; } return Attachment::fromData($this->data); }
[ "public", "function", "create", "(", ")", "{", "$", "this", "->", "data", "[", "'mrkdwn_in'", "]", "=", "[", "]", ";", "if", "(", "$", "this", "->", "markdownInText", ")", "{", "$", "this", "->", "data", "[", "'mrkdwn_in'", "]", "[", "]", "=", "'text'", ";", "}", "if", "(", "$", "this", "->", "markdownInPretext", ")", "{", "$", "this", "->", "data", "[", "'mrkdwn_in'", "]", "[", "]", "=", "'pretext'", ";", "}", "if", "(", "$", "this", "->", "markdownInFields", ")", "{", "$", "this", "->", "data", "[", "'mrkdwn_in'", "]", "[", "]", "=", "'fields'", ";", "}", "return", "Attachment", "::", "fromData", "(", "$", "this", "->", "data", ")", ";", "}" ]
Creates and returns a new attachment object specified by the builder. @return Attachment A new attachment object.
[ "Creates", "and", "returns", "a", "new", "attachment", "object", "specified", "by", "the", "builder", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/Message/AttachmentBuilder.php#L206-L223
train
sagebind/slack-client
src/RealTimeClient.php
RealTimeClient.connect
public function connect() { $deferred = new Promise\Deferred(); // Request a real-time connection... $this->apiCall('rtm.start') // then connect to the socket... ->then(function (Payload $response) { $responseData = $response->getData(); // get the team info $this->team = new Team($this, $responseData['team']); // Populate self user. $this->users[$responseData['self']['id']] = new User($this, $responseData['self']); // populate list of users foreach ($responseData['users'] as $data) { $this->users[$data['id']] = new User($this, $data); } // populate list of channels foreach ($responseData['channels'] as $data) { $this->channels[$data['id']] = new Channel($this, $data); } // populate list of groups foreach ($responseData['groups'] as $data) { $this->groups[$data['id']] = new Group($this, $data); } // populate list of dms foreach ($responseData['ims'] as $data) { $this->dms[$data['id']] = new DirectMessageChannel($this, $data); } // populate list of bots foreach ($responseData['bots'] as $data) { $this->bots[$data['id']] = new Bot($this, $data); } // Log PHPWS things to stderr $logger = new \Zend\Log\Logger(); $logger->addWriter(new \Zend\Log\Writer\Stream('php://stderr')); // initiate the websocket connection $this->websocket = new WebSocket($responseData['url'], $this->loop, $logger); $this->websocket->on('message', function ($message) { $this->onMessage($message); }); return $this->websocket->open(); }, function($exception) use ($deferred) { // if connection was not succesfull $deferred->reject(new ConnectionException( 'Could not connect to Slack API: '. $exception->getMessage(), $exception->getCode() )); }) // then wait for the connection to be ready. ->then(function () use ($deferred) { $this->once('hello', function () use ($deferred) { $deferred->resolve(); }); $this->once('error', function ($data) use ($deferred) { $deferred->reject(new ConnectionException( 'Could not connect to WebSocket: '.$data['error']['msg'], $data['error']['code'])); }); }); return $deferred->promise(); }
php
public function connect() { $deferred = new Promise\Deferred(); // Request a real-time connection... $this->apiCall('rtm.start') // then connect to the socket... ->then(function (Payload $response) { $responseData = $response->getData(); // get the team info $this->team = new Team($this, $responseData['team']); // Populate self user. $this->users[$responseData['self']['id']] = new User($this, $responseData['self']); // populate list of users foreach ($responseData['users'] as $data) { $this->users[$data['id']] = new User($this, $data); } // populate list of channels foreach ($responseData['channels'] as $data) { $this->channels[$data['id']] = new Channel($this, $data); } // populate list of groups foreach ($responseData['groups'] as $data) { $this->groups[$data['id']] = new Group($this, $data); } // populate list of dms foreach ($responseData['ims'] as $data) { $this->dms[$data['id']] = new DirectMessageChannel($this, $data); } // populate list of bots foreach ($responseData['bots'] as $data) { $this->bots[$data['id']] = new Bot($this, $data); } // Log PHPWS things to stderr $logger = new \Zend\Log\Logger(); $logger->addWriter(new \Zend\Log\Writer\Stream('php://stderr')); // initiate the websocket connection $this->websocket = new WebSocket($responseData['url'], $this->loop, $logger); $this->websocket->on('message', function ($message) { $this->onMessage($message); }); return $this->websocket->open(); }, function($exception) use ($deferred) { // if connection was not succesfull $deferred->reject(new ConnectionException( 'Could not connect to Slack API: '. $exception->getMessage(), $exception->getCode() )); }) // then wait for the connection to be ready. ->then(function () use ($deferred) { $this->once('hello', function () use ($deferred) { $deferred->resolve(); }); $this->once('error', function ($data) use ($deferred) { $deferred->reject(new ConnectionException( 'Could not connect to WebSocket: '.$data['error']['msg'], $data['error']['code'])); }); }); return $deferred->promise(); }
[ "public", "function", "connect", "(", ")", "{", "$", "deferred", "=", "new", "Promise", "\\", "Deferred", "(", ")", ";", "// Request a real-time connection...", "$", "this", "->", "apiCall", "(", "'rtm.start'", ")", "// then connect to the socket...", "->", "then", "(", "function", "(", "Payload", "$", "response", ")", "{", "$", "responseData", "=", "$", "response", "->", "getData", "(", ")", ";", "// get the team info", "$", "this", "->", "team", "=", "new", "Team", "(", "$", "this", ",", "$", "responseData", "[", "'team'", "]", ")", ";", "// Populate self user.", "$", "this", "->", "users", "[", "$", "responseData", "[", "'self'", "]", "[", "'id'", "]", "]", "=", "new", "User", "(", "$", "this", ",", "$", "responseData", "[", "'self'", "]", ")", ";", "// populate list of users", "foreach", "(", "$", "responseData", "[", "'users'", "]", "as", "$", "data", ")", "{", "$", "this", "->", "users", "[", "$", "data", "[", "'id'", "]", "]", "=", "new", "User", "(", "$", "this", ",", "$", "data", ")", ";", "}", "// populate list of channels", "foreach", "(", "$", "responseData", "[", "'channels'", "]", "as", "$", "data", ")", "{", "$", "this", "->", "channels", "[", "$", "data", "[", "'id'", "]", "]", "=", "new", "Channel", "(", "$", "this", ",", "$", "data", ")", ";", "}", "// populate list of groups", "foreach", "(", "$", "responseData", "[", "'groups'", "]", "as", "$", "data", ")", "{", "$", "this", "->", "groups", "[", "$", "data", "[", "'id'", "]", "]", "=", "new", "Group", "(", "$", "this", ",", "$", "data", ")", ";", "}", "// populate list of dms", "foreach", "(", "$", "responseData", "[", "'ims'", "]", "as", "$", "data", ")", "{", "$", "this", "->", "dms", "[", "$", "data", "[", "'id'", "]", "]", "=", "new", "DirectMessageChannel", "(", "$", "this", ",", "$", "data", ")", ";", "}", "// populate list of bots", "foreach", "(", "$", "responseData", "[", "'bots'", "]", "as", "$", "data", ")", "{", "$", "this", "->", "bots", "[", "$", "data", "[", "'id'", "]", "]", "=", "new", "Bot", "(", "$", "this", ",", "$", "data", ")", ";", "}", "// Log PHPWS things to stderr", "$", "logger", "=", "new", "\\", "Zend", "\\", "Log", "\\", "Logger", "(", ")", ";", "$", "logger", "->", "addWriter", "(", "new", "\\", "Zend", "\\", "Log", "\\", "Writer", "\\", "Stream", "(", "'php://stderr'", ")", ")", ";", "// initiate the websocket connection", "$", "this", "->", "websocket", "=", "new", "WebSocket", "(", "$", "responseData", "[", "'url'", "]", ",", "$", "this", "->", "loop", ",", "$", "logger", ")", ";", "$", "this", "->", "websocket", "->", "on", "(", "'message'", ",", "function", "(", "$", "message", ")", "{", "$", "this", "->", "onMessage", "(", "$", "message", ")", ";", "}", ")", ";", "return", "$", "this", "->", "websocket", "->", "open", "(", ")", ";", "}", ",", "function", "(", "$", "exception", ")", "use", "(", "$", "deferred", ")", "{", "// if connection was not succesfull", "$", "deferred", "->", "reject", "(", "new", "ConnectionException", "(", "'Could not connect to Slack API: '", ".", "$", "exception", "->", "getMessage", "(", ")", ",", "$", "exception", "->", "getCode", "(", ")", ")", ")", ";", "}", ")", "// then wait for the connection to be ready.", "->", "then", "(", "function", "(", ")", "use", "(", "$", "deferred", ")", "{", "$", "this", "->", "once", "(", "'hello'", ",", "function", "(", ")", "use", "(", "$", "deferred", ")", "{", "$", "deferred", "->", "resolve", "(", ")", ";", "}", ")", ";", "$", "this", "->", "once", "(", "'error'", ",", "function", "(", "$", "data", ")", "use", "(", "$", "deferred", ")", "{", "$", "deferred", "->", "reject", "(", "new", "ConnectionException", "(", "'Could not connect to WebSocket: '", ".", "$", "data", "[", "'error'", "]", "[", "'msg'", "]", ",", "$", "data", "[", "'error'", "]", "[", "'code'", "]", ")", ")", ";", "}", ")", ";", "}", ")", ";", "return", "$", "deferred", "->", "promise", "(", ")", ";", "}" ]
Connects to the real-time messaging server. @return \React\Promise\PromiseInterface
[ "Connects", "to", "the", "real", "-", "time", "messaging", "server", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/RealTimeClient.php#L73-L147
train
sagebind/slack-client
src/RealTimeClient.php
RealTimeClient.disconnect
public function disconnect() { if (!$this->connected) { return Promise\reject(new ConnectionException('Client not connected. Did you forget to call `connect()`?')); } $this->websocket->close(); $this->connected = false; }
php
public function disconnect() { if (!$this->connected) { return Promise\reject(new ConnectionException('Client not connected. Did you forget to call `connect()`?')); } $this->websocket->close(); $this->connected = false; }
[ "public", "function", "disconnect", "(", ")", "{", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "return", "Promise", "\\", "reject", "(", "new", "ConnectionException", "(", "'Client not connected. Did you forget to call `connect()`?'", ")", ")", ";", "}", "$", "this", "->", "websocket", "->", "close", "(", ")", ";", "$", "this", "->", "connected", "=", "false", ";", "}" ]
Disconnects the client.
[ "Disconnects", "the", "client", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/RealTimeClient.php#L152-L160
train
sagebind/slack-client
src/RealTimeClient.php
RealTimeClient.getBots
public function getBots() { if (!$this->connected) { return Promise\reject(new ConnectionException('Client not connected. Did you forget to call `connect()`?')); } return Promise\resolve(array_values($this->bots)); }
php
public function getBots() { if (!$this->connected) { return Promise\reject(new ConnectionException('Client not connected. Did you forget to call `connect()`?')); } return Promise\resolve(array_values($this->bots)); }
[ "public", "function", "getBots", "(", ")", "{", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "return", "Promise", "\\", "reject", "(", "new", "ConnectionException", "(", "'Client not connected. Did you forget to call `connect()`?'", ")", ")", ";", "}", "return", "Promise", "\\", "resolve", "(", "array_values", "(", "$", "this", "->", "bots", ")", ")", ";", "}" ]
Gets all bots in the Slack team. @return \React\Promise\PromiseInterface A promise for an array of bots.
[ "Gets", "all", "bots", "in", "the", "Slack", "team", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/RealTimeClient.php#L291-L298
train
sagebind/slack-client
src/RealTimeClient.php
RealTimeClient.getBotById
public function getBotById($id) { if (!$this->connected) { return Promise\reject(new ConnectionException('Client not connected. Did you forget to call `connect()`?')); } if (!isset($this->bots[$id])) { return Promise\reject(new ApiException("No bot exists for ID '$id'.")); } return Promise\resolve($this->bots[$id]); }
php
public function getBotById($id) { if (!$this->connected) { return Promise\reject(new ConnectionException('Client not connected. Did you forget to call `connect()`?')); } if (!isset($this->bots[$id])) { return Promise\reject(new ApiException("No bot exists for ID '$id'.")); } return Promise\resolve($this->bots[$id]); }
[ "public", "function", "getBotById", "(", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "return", "Promise", "\\", "reject", "(", "new", "ConnectionException", "(", "'Client not connected. Did you forget to call `connect()`?'", ")", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "bots", "[", "$", "id", "]", ")", ")", "{", "return", "Promise", "\\", "reject", "(", "new", "ApiException", "(", "\"No bot exists for ID '$id'.\"", ")", ")", ";", "}", "return", "Promise", "\\", "resolve", "(", "$", "this", "->", "bots", "[", "$", "id", "]", ")", ";", "}" ]
Gets a bot by its ID. @param string $id A bot ID. @return \React\Promise\PromiseInterface A promise for a bot object.
[ "Gets", "a", "bot", "by", "its", "ID", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/RealTimeClient.php#L307-L318
train
sagebind/slack-client
src/User.php
User.getPresence
public function getPresence() { return $this->client->apiCall('users.getPresence', [ 'user' => $this->getId(), ])->then(function (Payload $response) { return $response['presence']; }); }
php
public function getPresence() { return $this->client->apiCall('users.getPresence', [ 'user' => $this->getId(), ])->then(function (Payload $response) { return $response['presence']; }); }
[ "public", "function", "getPresence", "(", ")", "{", "return", "$", "this", "->", "client", "->", "apiCall", "(", "'users.getPresence'", ",", "[", "'user'", "=>", "$", "this", "->", "getId", "(", ")", ",", "]", ")", "->", "then", "(", "function", "(", "Payload", "$", "response", ")", "{", "return", "$", "response", "[", "'presence'", "]", ";", "}", ")", ";", "}" ]
Gets a user's presence. @return \React\Promise\PromiseInterface The current user's presence, either "active" or "away".
[ "Gets", "a", "user", "s", "presence", "." ]
53e0c2897a5dabf9432e780c9e173872879bc607
https://github.com/sagebind/slack-client/blob/53e0c2897a5dabf9432e780c9e173872879bc607/src/User.php#L136-L143
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Common/Decorator/Base.php
Base.setAimeos
public function setAimeos( \Aimeos\Bootstrap $aimeos ) { parent::setAimeos( $aimeos ); $this->client->setAimeos( $aimeos ); return $this; }
php
public function setAimeos( \Aimeos\Bootstrap $aimeos ) { parent::setAimeos( $aimeos ); $this->client->setAimeos( $aimeos ); return $this; }
[ "public", "function", "setAimeos", "(", "\\", "Aimeos", "\\", "Bootstrap", "$", "aimeos", ")", "{", "parent", "::", "setAimeos", "(", "$", "aimeos", ")", ";", "$", "this", "->", "client", "->", "setAimeos", "(", "$", "aimeos", ")", ";", "return", "$", "this", ";", "}" ]
Sets the Aimeos bootstrap object @param \Aimeos\Bootstrap $aimeos The Aimeos bootstrap object @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls
[ "Sets", "the", "Aimeos", "bootstrap", "object" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Common/Decorator/Base.php#L200-L206
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Customer/Property/Standard.php
Standard.getPropertyTypes
protected function getPropertyTypes() { $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/property/type' ); $search = $manager->createSearch( true )->setSlice( 0, 10000 ); $search->setSortations( [$search->sort( '+', 'customer.property.type.position')] ); return $manager->searchItems( $search ); }
php
protected function getPropertyTypes() { $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/property/type' ); $search = $manager->createSearch( true )->setSlice( 0, 10000 ); $search->setSortations( [$search->sort( '+', 'customer.property.type.position')] ); return $manager->searchItems( $search ); }
[ "protected", "function", "getPropertyTypes", "(", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'customer/property/type'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "search", "->", "setSortations", "(", "[", "$", "search", "->", "sort", "(", "'+'", ",", "'customer.property.type.position'", ")", "]", ")", ";", "return", "$", "manager", "->", "searchItems", "(", "$", "search", ")", ";", "}" ]
Returns the available customer property types @return array Associative list of property type IDs as keys and property type items as values
[ "Returns", "the", "available", "customer", "property", "types" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Customer/Property/Standard.php#L277-L285
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Product/Download/Standard.php
Standard.storeFile
protected function storeFile( \Psr\Http\Message\UploadedFileInterface $file, $path ) { $fs = $this->getContext()->getFilesystemManager()->get( 'fs-secure' ); if( $path == null ) { $ext = pathinfo( $file->getClientFilename(), PATHINFO_EXTENSION ); $hash = md5( $file->getClientFilename() . microtime( true ) ); $path = sprintf( '%s/%s/%s.%s', $hash[0], $hash[1], $hash, $ext ); if( !$fs->isdir( $hash[0] . '/' . $hash[1] ) ) { $fs->mkdir( $hash[0] . '/' . $hash[1] ); } } $fs->writes( $path, $file->getStream()->detach() ); return $path; }
php
protected function storeFile( \Psr\Http\Message\UploadedFileInterface $file, $path ) { $fs = $this->getContext()->getFilesystemManager()->get( 'fs-secure' ); if( $path == null ) { $ext = pathinfo( $file->getClientFilename(), PATHINFO_EXTENSION ); $hash = md5( $file->getClientFilename() . microtime( true ) ); $path = sprintf( '%s/%s/%s.%s', $hash[0], $hash[1], $hash, $ext ); if( !$fs->isdir( $hash[0] . '/' . $hash[1] ) ) { $fs->mkdir( $hash[0] . '/' . $hash[1] ); } } $fs->writes( $path, $file->getStream()->detach() ); return $path; }
[ "protected", "function", "storeFile", "(", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "UploadedFileInterface", "$", "file", ",", "$", "path", ")", "{", "$", "fs", "=", "$", "this", "->", "getContext", "(", ")", "->", "getFilesystemManager", "(", ")", "->", "get", "(", "'fs-secure'", ")", ";", "if", "(", "$", "path", "==", "null", ")", "{", "$", "ext", "=", "pathinfo", "(", "$", "file", "->", "getClientFilename", "(", ")", ",", "PATHINFO_EXTENSION", ")", ";", "$", "hash", "=", "md5", "(", "$", "file", "->", "getClientFilename", "(", ")", ".", "microtime", "(", "true", ")", ")", ";", "$", "path", "=", "sprintf", "(", "'%s/%s/%s.%s'", ",", "$", "hash", "[", "0", "]", ",", "$", "hash", "[", "1", "]", ",", "$", "hash", ",", "$", "ext", ")", ";", "if", "(", "!", "$", "fs", "->", "isdir", "(", "$", "hash", "[", "0", "]", ".", "'/'", ".", "$", "hash", "[", "1", "]", ")", ")", "{", "$", "fs", "->", "mkdir", "(", "$", "hash", "[", "0", "]", ".", "'/'", ".", "$", "hash", "[", "1", "]", ")", ";", "}", "}", "$", "fs", "->", "writes", "(", "$", "path", ",", "$", "file", "->", "getStream", "(", ")", "->", "detach", "(", ")", ")", ";", "return", "$", "path", ";", "}" ]
Stores the uploaded file in the "fs-secure" file system @param \Psr\Http\Message\UploadedFileInterface $file @param string $path Path the file should be stored at @return string Path to the uploaded file
[ "Stores", "the", "uploaded", "file", "in", "the", "fs", "-", "secure", "file", "system" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Product/Download/Standard.php#L295-L313
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Product/Text/Standard.php
Standard.addViewData
protected function addViewData( \Aimeos\MW\View\Iface $view ) { $context = $this->getContext(); $textTypeManager = \Aimeos\MShop::create( $context, 'text/type' ); $listTypeManager = \Aimeos\MShop::create( $context, 'product/lists/type' ); $search = $textTypeManager->createSearch( true )->setSlice( 0, 10000 ); $search->setConditions( $search->compare( '==', 'text.type.domain', 'product' ) ); $search->setSortations( array( $search->sort( '+', 'text.type.position' ) ) ); $listSearch = $listTypeManager->createSearch( true )->setSlice( 0, 10000 ); $listSearch->setConditions( $listSearch->compare( '==', 'product.lists.type.domain', 'text' ) ); $listSearch->setSortations( array( $listSearch->sort( '+', 'product.lists.type.position' ) ) ); $view->textTypes = $this->map( $textTypeManager->searchItems( $search ) ); $view->textListTypes = $this->map( $listTypeManager->searchItems( $listSearch ) ); return $view; }
php
protected function addViewData( \Aimeos\MW\View\Iface $view ) { $context = $this->getContext(); $textTypeManager = \Aimeos\MShop::create( $context, 'text/type' ); $listTypeManager = \Aimeos\MShop::create( $context, 'product/lists/type' ); $search = $textTypeManager->createSearch( true )->setSlice( 0, 10000 ); $search->setConditions( $search->compare( '==', 'text.type.domain', 'product' ) ); $search->setSortations( array( $search->sort( '+', 'text.type.position' ) ) ); $listSearch = $listTypeManager->createSearch( true )->setSlice( 0, 10000 ); $listSearch->setConditions( $listSearch->compare( '==', 'product.lists.type.domain', 'text' ) ); $listSearch->setSortations( array( $listSearch->sort( '+', 'product.lists.type.position' ) ) ); $view->textTypes = $this->map( $textTypeManager->searchItems( $search ) ); $view->textListTypes = $this->map( $listTypeManager->searchItems( $listSearch ) ); return $view; }
[ "protected", "function", "addViewData", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "textTypeManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'text/type'", ")", ";", "$", "listTypeManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'product/lists/type'", ")", ";", "$", "search", "=", "$", "textTypeManager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'text.type.domain'", ",", "'product'", ")", ")", ";", "$", "search", "->", "setSortations", "(", "array", "(", "$", "search", "->", "sort", "(", "'+'", ",", "'text.type.position'", ")", ")", ")", ";", "$", "listSearch", "=", "$", "listTypeManager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "listSearch", "->", "setConditions", "(", "$", "listSearch", "->", "compare", "(", "'=='", ",", "'product.lists.type.domain'", ",", "'text'", ")", ")", ";", "$", "listSearch", "->", "setSortations", "(", "array", "(", "$", "listSearch", "->", "sort", "(", "'+'", ",", "'product.lists.type.position'", ")", ")", ")", ";", "$", "view", "->", "textTypes", "=", "$", "this", "->", "map", "(", "$", "textTypeManager", "->", "searchItems", "(", "$", "search", ")", ")", ";", "$", "view", "->", "textListTypes", "=", "$", "this", "->", "map", "(", "$", "listTypeManager", "->", "searchItems", "(", "$", "listSearch", ")", ")", ";", "return", "$", "view", ";", "}" ]
Adds the required data used in the text template @param \Aimeos\MW\View\Iface $view View object @return \Aimeos\MW\View\Iface View object with assigned parameters
[ "Adds", "the", "required", "data", "used", "in", "the", "text", "template" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Product/Text/Standard.php#L289-L308
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Catalog/Standard.php
Standard.search
public function search() { $view = $this->getView(); $context = $this->getContext(); try { $view->item = \Aimeos\MShop::create( $context, 'catalog' )->createItem(); $view->itemRootId = $this->getRootId(); $view->itemBody = ''; } catch( \Aimeos\MShop\Exception $e ) { $error = array( 'catalog-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); $view->errors = $view->get( 'errors', [] ) + $error; $this->logException( $e ); } catch( \Exception $e ) { $error = array( 'catalog-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); $view->errors = $view->get( 'errors', [] ) + $error; $this->logException( $e ); } return $this->render( $view ); }
php
public function search() { $view = $this->getView(); $context = $this->getContext(); try { $view->item = \Aimeos\MShop::create( $context, 'catalog' )->createItem(); $view->itemRootId = $this->getRootId(); $view->itemBody = ''; } catch( \Aimeos\MShop\Exception $e ) { $error = array( 'catalog-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); $view->errors = $view->get( 'errors', [] ) + $error; $this->logException( $e ); } catch( \Exception $e ) { $error = array( 'catalog-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); $view->errors = $view->get( 'errors', [] ) + $error; $this->logException( $e ); } return $this->render( $view ); }
[ "public", "function", "search", "(", ")", "{", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "try", "{", "$", "view", "->", "item", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'catalog'", ")", "->", "createItem", "(", ")", ";", "$", "view", "->", "itemRootId", "=", "$", "this", "->", "getRootId", "(", ")", ";", "$", "view", "->", "itemBody", "=", "''", ";", "}", "catch", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Exception", "$", "e", ")", "{", "$", "error", "=", "array", "(", "'catalog-item'", "=>", "$", "context", "->", "getI18n", "(", ")", "->", "dt", "(", "'mshop'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "$", "view", "->", "errors", "=", "$", "view", "->", "get", "(", "'errors'", ",", "[", "]", ")", "+", "$", "error", ";", "$", "this", "->", "logException", "(", "$", "e", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "error", "=", "array", "(", "'catalog-item'", "=>", "$", "e", "->", "getMessage", "(", ")", ".", "', '", ".", "$", "e", "->", "getFile", "(", ")", ".", "':'", ".", "$", "e", "->", "getLine", "(", ")", ")", ";", "$", "view", "->", "errors", "=", "$", "view", "->", "get", "(", "'errors'", ",", "[", "]", ")", "+", "$", "error", ";", "$", "this", "->", "logException", "(", "$", "e", ")", ";", "}", "return", "$", "this", "->", "render", "(", "$", "view", ")", ";", "}" ]
Returns the catalog root node @return string HTML output
[ "Returns", "the", "catalog", "root", "node" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Catalog/Standard.php#L277-L302
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Catalog/Standard.php
Standard.getRootId
protected function getRootId() { $manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' ); try { return $manager->getTree( null, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )->getId(); } catch( \Exception $e ) { return null; } }
php
protected function getRootId() { $manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' ); try { return $manager->getTree( null, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )->getId(); } catch( \Exception $e ) { return null; } }
[ "protected", "function", "getRootId", "(", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'catalog'", ")", ";", "try", "{", "return", "$", "manager", "->", "getTree", "(", "null", ",", "[", "]", ",", "\\", "Aimeos", "\\", "MW", "\\", "Tree", "\\", "Manager", "\\", "Base", "::", "LEVEL_ONE", ")", "->", "getId", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "null", ";", "}", "}" ]
Returns the IDs of the root category @return string|null ID of the root category
[ "Returns", "the", "IDs", "of", "the", "root", "category" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Catalog/Standard.php#L420-L429
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Common/Decorator/Index.php
Index.save
public function save() { $result = $this->getClient()->save(); $prodIds = array_unique( $this->getView()->param( 'product/catalog.lists.refid', [] ) ); if( !empty( $prodIds ) ) { $context = $this->getContext(); $manager = \Aimeos\MShop::create( $context, 'product' ); $domains = ['attribute', 'price', 'product', 'supplier', 'text']; $search = $manager->createSearch( true )->setSlice( count( $prodIds ) ); $search->setConditions( $search->compare( '==', 'product.id', $prodIds ) ); $items = $manager->searchItems( $search, $domains ); \Aimeos\MShop::create( $context, 'index' )->rebuildIndex( $items ); } return $result; }
php
public function save() { $result = $this->getClient()->save(); $prodIds = array_unique( $this->getView()->param( 'product/catalog.lists.refid', [] ) ); if( !empty( $prodIds ) ) { $context = $this->getContext(); $manager = \Aimeos\MShop::create( $context, 'product' ); $domains = ['attribute', 'price', 'product', 'supplier', 'text']; $search = $manager->createSearch( true )->setSlice( count( $prodIds ) ); $search->setConditions( $search->compare( '==', 'product.id', $prodIds ) ); $items = $manager->searchItems( $search, $domains ); \Aimeos\MShop::create( $context, 'index' )->rebuildIndex( $items ); } return $result; }
[ "public", "function", "save", "(", ")", "{", "$", "result", "=", "$", "this", "->", "getClient", "(", ")", "->", "save", "(", ")", ";", "$", "prodIds", "=", "array_unique", "(", "$", "this", "->", "getView", "(", ")", "->", "param", "(", "'product/catalog.lists.refid'", ",", "[", "]", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "prodIds", ")", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'product'", ")", ";", "$", "domains", "=", "[", "'attribute'", ",", "'price'", ",", "'product'", ",", "'supplier'", ",", "'text'", "]", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "count", "(", "$", "prodIds", ")", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'product.id'", ",", "$", "prodIds", ")", ")", ";", "$", "items", "=", "$", "manager", "->", "searchItems", "(", "$", "search", ",", "$", "domains", ")", ";", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'index'", ")", "->", "rebuildIndex", "(", "$", "items", ")", ";", "}", "return", "$", "result", ";", "}" ]
Rebuilds the index after saving the item @return string|null admin output to display or null for redirecting to the list
[ "Rebuilds", "the", "index", "after", "saving", "the", "item" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Common/Decorator/Index.php#L27-L46
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Type/Price/Lists/Factory.php
Factory.create
public static function create( \Aimeos\MShop\Context\Item\Iface $context, $name = null ) { /** admin/jqadm/type/price/lists/name * Class name of the used account favorite client implementation * * Each default admin client can be replace by an alternative imlementation. * To use this implementation, you have to set the last part of the class * name as configuration value so the client factory knows which class it * has to instantiate. * * For example, if the name of the default class is * * \Aimeos\Admin\JQAdm\Price\Liststype\Standard * * and you want to replace it with your own version named * * \Aimeos\Admin\JQAdm\Price\Liststype\Myfavorite * * then you have to set the this configuration option: * * admin/jqadm/type/price/lists/name = Myfavorite * * The value is the last part of your own class name and it's case sensitive, * so take care that the configuration value is exactly named like the last * part of the class name. * * The allowed characters of the class name are A-Z, a-z and 0-9. No other * characters are possible! You should always start the last part of the class * name with an upper case character and continue only with lower case characters * or numbers. Avoid chamel case names like "MyFavorite"! * * @param string Last part of the class name * @since 2017.10 * @category Developer */ if( $name === null ) { $name = $context->getConfig()->get( 'admin/jqadm/type/price/lists/name', 'Standard' ); } if( ctype_alnum( $name ) === false ) { $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JQAdm\\Type\\Price\\Lists\\' . $name : '<not a string>'; throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); } $iface = '\\Aimeos\\Admin\\JQAdm\\Iface'; $classname = '\\Aimeos\\Admin\\JQAdm\\Type\\Price\\Lists\\' . $name; $client = self::createAdmin( $context, $classname, $iface ); return self::addClientDecorators( $context, $client, 'type/price/lists' ); }
php
public static function create( \Aimeos\MShop\Context\Item\Iface $context, $name = null ) { /** admin/jqadm/type/price/lists/name * Class name of the used account favorite client implementation * * Each default admin client can be replace by an alternative imlementation. * To use this implementation, you have to set the last part of the class * name as configuration value so the client factory knows which class it * has to instantiate. * * For example, if the name of the default class is * * \Aimeos\Admin\JQAdm\Price\Liststype\Standard * * and you want to replace it with your own version named * * \Aimeos\Admin\JQAdm\Price\Liststype\Myfavorite * * then you have to set the this configuration option: * * admin/jqadm/type/price/lists/name = Myfavorite * * The value is the last part of your own class name and it's case sensitive, * so take care that the configuration value is exactly named like the last * part of the class name. * * The allowed characters of the class name are A-Z, a-z and 0-9. No other * characters are possible! You should always start the last part of the class * name with an upper case character and continue only with lower case characters * or numbers. Avoid chamel case names like "MyFavorite"! * * @param string Last part of the class name * @since 2017.10 * @category Developer */ if( $name === null ) { $name = $context->getConfig()->get( 'admin/jqadm/type/price/lists/name', 'Standard' ); } if( ctype_alnum( $name ) === false ) { $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JQAdm\\Type\\Price\\Lists\\' . $name : '<not a string>'; throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); } $iface = '\\Aimeos\\Admin\\JQAdm\\Iface'; $classname = '\\Aimeos\\Admin\\JQAdm\\Type\\Price\\Lists\\' . $name; $client = self::createAdmin( $context, $classname, $iface ); return self::addClientDecorators( $context, $client, 'type/price/lists' ); }
[ "public", "static", "function", "create", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Context", "\\", "Item", "\\", "Iface", "$", "context", ",", "$", "name", "=", "null", ")", "{", "/** admin/jqadm/type/price/lists/name\n\t\t * Class name of the used account favorite client implementation\n\t\t *\n\t\t * Each default admin client can be replace by an alternative imlementation.\n\t\t * To use this implementation, you have to set the last part of the class\n\t\t * name as configuration value so the client factory knows which class it\n\t\t * has to instantiate.\n\t\t *\n\t\t * For example, if the name of the default class is\n\t\t *\n\t\t * \\Aimeos\\Admin\\JQAdm\\Price\\Liststype\\Standard\n\t\t *\n\t\t * and you want to replace it with your own version named\n\t\t *\n\t\t * \\Aimeos\\Admin\\JQAdm\\Price\\Liststype\\Myfavorite\n\t\t *\n\t\t * then you have to set the this configuration option:\n\t\t *\n\t\t * admin/jqadm/type/price/lists/name = Myfavorite\n\t\t *\n\t\t * The value is the last part of your own class name and it's case sensitive,\n\t\t * so take care that the configuration value is exactly named like the last\n\t\t * part of the class name.\n\t\t *\n\t\t * The allowed characters of the class name are A-Z, a-z and 0-9. No other\n\t\t * characters are possible! You should always start the last part of the class\n\t\t * name with an upper case character and continue only with lower case characters\n\t\t * or numbers. Avoid chamel case names like \"MyFavorite\"!\n\t\t *\n\t\t * @param string Last part of the class name\n\t\t * @since 2017.10\n\t\t * @category Developer\n\t\t */", "if", "(", "$", "name", "===", "null", ")", "{", "$", "name", "=", "$", "context", "->", "getConfig", "(", ")", "->", "get", "(", "'admin/jqadm/type/price/lists/name'", ",", "'Standard'", ")", ";", "}", "if", "(", "ctype_alnum", "(", "$", "name", ")", "===", "false", ")", "{", "$", "classname", "=", "is_string", "(", "$", "name", ")", "?", "'\\\\Aimeos\\\\Admin\\\\JQAdm\\\\Type\\\\Price\\\\Lists\\\\'", ".", "$", "name", ":", "'<not a string>'", ";", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "sprintf", "(", "'Invalid characters in class name \"%1$s\"'", ",", "$", "classname", ")", ")", ";", "}", "$", "iface", "=", "'\\\\Aimeos\\\\Admin\\\\JQAdm\\\\Iface'", ";", "$", "classname", "=", "'\\\\Aimeos\\\\Admin\\\\JQAdm\\\\Type\\\\Price\\\\Lists\\\\'", ".", "$", "name", ";", "$", "client", "=", "self", "::", "createAdmin", "(", "$", "context", ",", "$", "classname", ",", "$", "iface", ")", ";", "return", "self", "::", "addClientDecorators", "(", "$", "context", ",", "$", "client", ",", "'type/price/lists'", ")", ";", "}" ]
Creates a price lists type client object @param \Aimeos\MShop\Context\Item\Iface $context Shop context instance with necessary objects @param string|null $name Admin name (default: "Standard") @return \Aimeos\Admin\JQAdm\Iface Filter part implementing \Aimeos\Admin\JQAdm\Iface @throws \Aimeos\Admin\JQAdm\Exception If requested client implementation couldn't be found or initialisation fails
[ "Creates", "a", "price", "lists", "type", "client", "object" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Type/Price/Lists/Factory.php#L32-L83
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Product/Category/Standard.php
Standard.getCatalogItems
protected function getCatalogItems( array $listItems ) { $ids = []; foreach( $listItems as $listItem ) { $ids[] = $listItem->getParentId(); } $manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' ); $search = $manager->createSearch(); $search->setConditions( $search->compare( '==', 'catalog.id', $ids ) ); return $manager->searchItems( $search ); }
php
protected function getCatalogItems( array $listItems ) { $ids = []; foreach( $listItems as $listItem ) { $ids[] = $listItem->getParentId(); } $manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' ); $search = $manager->createSearch(); $search->setConditions( $search->compare( '==', 'catalog.id', $ids ) ); return $manager->searchItems( $search ); }
[ "protected", "function", "getCatalogItems", "(", "array", "$", "listItems", ")", "{", "$", "ids", "=", "[", "]", ";", "foreach", "(", "$", "listItems", "as", "$", "listItem", ")", "{", "$", "ids", "[", "]", "=", "$", "listItem", "->", "getParentId", "(", ")", ";", "}", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'catalog'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'catalog.id'", ",", "$", "ids", ")", ")", ";", "return", "$", "manager", "->", "searchItems", "(", "$", "search", ")", ";", "}" ]
Returns the category items for the given catalog list items @param array $listItems List of items implementing \Aimeos\Common\Item\Lists\Iface @return array Associative list of catalog IDs as keys and items implementing \Aimeos\Catalog\Item\Iface as values
[ "Returns", "the", "category", "items", "for", "the", "given", "catalog", "list", "items" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Product/Category/Standard.php#L321-L335
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Service/Standard.php
Standard.getConfigAttributes
public function getConfigAttributes( \Aimeos\MShop\Service\Item\Iface $item ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'service' ); try { return $manager->getProvider( $item, $item->getType() )->getConfigBE(); } catch( \Aimeos\MShop\Exception $e ) { return []; } }
php
public function getConfigAttributes( \Aimeos\MShop\Service\Item\Iface $item ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'service' ); try { return $manager->getProvider( $item, $item->getType() )->getConfigBE(); } catch( \Aimeos\MShop\Exception $e ) { return []; } }
[ "public", "function", "getConfigAttributes", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Service", "\\", "Item", "\\", "Iface", "$", "item", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'service'", ")", ";", "try", "{", "return", "$", "manager", "->", "getProvider", "(", "$", "item", ",", "$", "item", "->", "getType", "(", ")", ")", "->", "getConfigBE", "(", ")", ";", "}", "catch", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Exception", "$", "e", ")", "{", "return", "[", "]", ";", "}", "}" ]
Returns the backend configuration attributes of the provider and decorators @param \Aimeos\MShop\Service\Item\Iface $item Service item incl. provider/decorator property @return \Aimeos\MW\Common\Critera\Attribute\Iface[] List of configuration attributes
[ "Returns", "the", "backend", "configuration", "attributes", "of", "the", "provider", "and", "decorators" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Service/Standard.php#L441-L450
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Service/Standard.php
Standard.getProviderNames
protected function getProviderNames() { $ds = DIRECTORY_SEPARATOR; return [ 'delivery' => $this->getClassNames( 'MShop' . $ds . 'Service' . $ds . 'Provider' . $ds . 'Delivery' ), 'payment' => $this->getClassNames( 'MShop' . $ds . 'Service' . $ds . 'Provider' . $ds . 'Payment' ), ]; }
php
protected function getProviderNames() { $ds = DIRECTORY_SEPARATOR; return [ 'delivery' => $this->getClassNames( 'MShop' . $ds . 'Service' . $ds . 'Provider' . $ds . 'Delivery' ), 'payment' => $this->getClassNames( 'MShop' . $ds . 'Service' . $ds . 'Provider' . $ds . 'Payment' ), ]; }
[ "protected", "function", "getProviderNames", "(", ")", "{", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", "return", "[", "'delivery'", "=>", "$", "this", "->", "getClassNames", "(", "'MShop'", ".", "$", "ds", ".", "'Service'", ".", "$", "ds", ".", "'Provider'", ".", "$", "ds", ".", "'Delivery'", ")", ",", "'payment'", "=>", "$", "this", "->", "getClassNames", "(", "'MShop'", ".", "$", "ds", ".", "'Service'", ".", "$", "ds", ".", "'Provider'", ".", "$", "ds", ".", "'Payment'", ")", ",", "]", ";", "}" ]
Returns the names of the available service providers @return string[] List of provider class names
[ "Returns", "the", "names", "of", "the", "available", "service", "providers" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Service/Standard.php#L494-L501
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Service/Standard.php
Standard.getTypeItems
protected function getTypeItems() { $typeManager = \Aimeos\MShop::create( $this->getContext(), 'service/type' ); $search = $typeManager->createSearch( true )->setSlice( 0, 10000 ); $search->setSortations( [$search->sort( '+', 'service.type.position' )] ); return $this->map( $typeManager->searchItems( $search ) ); }
php
protected function getTypeItems() { $typeManager = \Aimeos\MShop::create( $this->getContext(), 'service/type' ); $search = $typeManager->createSearch( true )->setSlice( 0, 10000 ); $search->setSortations( [$search->sort( '+', 'service.type.position' )] ); return $this->map( $typeManager->searchItems( $search ) ); }
[ "protected", "function", "getTypeItems", "(", ")", "{", "$", "typeManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'service/type'", ")", ";", "$", "search", "=", "$", "typeManager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "search", "->", "setSortations", "(", "[", "$", "search", "->", "sort", "(", "'+'", ",", "'service.type.position'", ")", "]", ")", ";", "return", "$", "this", "->", "map", "(", "$", "typeManager", "->", "searchItems", "(", "$", "search", ")", ")", ";", "}" ]
Returns the available service type items @return array List of item implementing \Aimeos\MShop\Common\Type\Iface
[ "Returns", "the", "available", "service", "type", "items" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Service/Standard.php#L553-L561
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Attribute/Media/Standard.php
Standard.addViewData
protected function addViewData( \Aimeos\MW\View\Iface $view ) { $context = $this->getContext(); $typeManager = \Aimeos\MShop::create( $this->getContext(), 'media/type' ); $listTypeManager = \Aimeos\MShop::create( $this->getContext(), 'attribute/lists/type' ); $search = $typeManager->createSearch( true )->setSlice( 0, 10000 ); $search->setConditions( $search->compare( '==', 'media.type.domain', 'attribute' ) ); $search->setSortations( [$search->sort( '+', 'media.type.position' )] ); $listSearch = $listTypeManager->createSearch( true )->setSlice( 0, 10000 ); $listSearch->setConditions( $listSearch->compare( '==', 'attribute.lists.type.domain', 'media' ) ); $listSearch->setSortations( [$listSearch->sort( '+', 'attribute.lists.type.position' )] ); $view->mediaListTypes = $this->map( $listTypeManager->searchItems( $listSearch ) ); $view->mediaTypes = $this->map( $typeManager->searchItems( $search ) ); return $view; }
php
protected function addViewData( \Aimeos\MW\View\Iface $view ) { $context = $this->getContext(); $typeManager = \Aimeos\MShop::create( $this->getContext(), 'media/type' ); $listTypeManager = \Aimeos\MShop::create( $this->getContext(), 'attribute/lists/type' ); $search = $typeManager->createSearch( true )->setSlice( 0, 10000 ); $search->setConditions( $search->compare( '==', 'media.type.domain', 'attribute' ) ); $search->setSortations( [$search->sort( '+', 'media.type.position' )] ); $listSearch = $listTypeManager->createSearch( true )->setSlice( 0, 10000 ); $listSearch->setConditions( $listSearch->compare( '==', 'attribute.lists.type.domain', 'media' ) ); $listSearch->setSortations( [$listSearch->sort( '+', 'attribute.lists.type.position' )] ); $view->mediaListTypes = $this->map( $listTypeManager->searchItems( $listSearch ) ); $view->mediaTypes = $this->map( $typeManager->searchItems( $search ) ); return $view; }
[ "protected", "function", "addViewData", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "typeManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'media/type'", ")", ";", "$", "listTypeManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'attribute/lists/type'", ")", ";", "$", "search", "=", "$", "typeManager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'media.type.domain'", ",", "'attribute'", ")", ")", ";", "$", "search", "->", "setSortations", "(", "[", "$", "search", "->", "sort", "(", "'+'", ",", "'media.type.position'", ")", "]", ")", ";", "$", "listSearch", "=", "$", "listTypeManager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "listSearch", "->", "setConditions", "(", "$", "listSearch", "->", "compare", "(", "'=='", ",", "'attribute.lists.type.domain'", ",", "'media'", ")", ")", ";", "$", "listSearch", "->", "setSortations", "(", "[", "$", "listSearch", "->", "sort", "(", "'+'", ",", "'attribute.lists.type.position'", ")", "]", ")", ";", "$", "view", "->", "mediaListTypes", "=", "$", "this", "->", "map", "(", "$", "listTypeManager", "->", "searchItems", "(", "$", "listSearch", ")", ")", ";", "$", "view", "->", "mediaTypes", "=", "$", "this", "->", "map", "(", "$", "typeManager", "->", "searchItems", "(", "$", "search", ")", ")", ";", "return", "$", "view", ";", "}" ]
Adds the required data used in the attribute template @param \Aimeos\MW\View\Iface $view View object @return \Aimeos\MW\View\Iface View object with assigned parameters
[ "Adds", "the", "required", "data", "used", "in", "the", "attribute", "template" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Attribute/Media/Standard.php#L258-L277
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Attribute/Media/Standard.php
Standard.deleteMediaItems
protected function deleteMediaItems( \Aimeos\MShop\Attribute\Item\Iface $item, array $listItems ) { $context = $this->getContext(); $cntl = \Aimeos\Controller\Common\Media\Factory::create( $context ); $manager = \Aimeos\MShop::create( $context, 'attribute' ); $search = $manager->createSearch(); foreach( $listItems as $listItem ) { $func = $search->createFunction( 'attribute:has', ['media', $listItem->getType(), $listItem->getRefId()] ); $search->setConditions( $search->compare( '!=', $func, null ) ); $items = $manager->searchItems( $search ); $refItem = null; if( count( $items ) === 1 && ( $refItem = $listItem->getRefItem() ) !== null ) { $cntl->delete( $refItem ); } $item->deleteListItem( 'media', $listItem, $refItem ); } return $item; }
php
protected function deleteMediaItems( \Aimeos\MShop\Attribute\Item\Iface $item, array $listItems ) { $context = $this->getContext(); $cntl = \Aimeos\Controller\Common\Media\Factory::create( $context ); $manager = \Aimeos\MShop::create( $context, 'attribute' ); $search = $manager->createSearch(); foreach( $listItems as $listItem ) { $func = $search->createFunction( 'attribute:has', ['media', $listItem->getType(), $listItem->getRefId()] ); $search->setConditions( $search->compare( '!=', $func, null ) ); $items = $manager->searchItems( $search ); $refItem = null; if( count( $items ) === 1 && ( $refItem = $listItem->getRefItem() ) !== null ) { $cntl->delete( $refItem ); } $item->deleteListItem( 'media', $listItem, $refItem ); } return $item; }
[ "protected", "function", "deleteMediaItems", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Attribute", "\\", "Item", "\\", "Iface", "$", "item", ",", "array", "$", "listItems", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "cntl", "=", "\\", "Aimeos", "\\", "Controller", "\\", "Common", "\\", "Media", "\\", "Factory", "::", "create", "(", "$", "context", ")", ";", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'attribute'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", ")", ";", "foreach", "(", "$", "listItems", "as", "$", "listItem", ")", "{", "$", "func", "=", "$", "search", "->", "createFunction", "(", "'attribute:has'", ",", "[", "'media'", ",", "$", "listItem", "->", "getType", "(", ")", ",", "$", "listItem", "->", "getRefId", "(", ")", "]", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'!='", ",", "$", "func", ",", "null", ")", ")", ";", "$", "items", "=", "$", "manager", "->", "searchItems", "(", "$", "search", ")", ";", "$", "refItem", "=", "null", ";", "if", "(", "count", "(", "$", "items", ")", "===", "1", "&&", "(", "$", "refItem", "=", "$", "listItem", "->", "getRefItem", "(", ")", ")", "!==", "null", ")", "{", "$", "cntl", "->", "delete", "(", "$", "refItem", ")", ";", "}", "$", "item", "->", "deleteListItem", "(", "'media'", ",", "$", "listItem", ",", "$", "refItem", ")", ";", "}", "return", "$", "item", ";", "}" ]
Removes the media reference and the media item if not shared @param \Aimeos\MShop\Attribute\Item\Iface $item Attribute item including media reference @param array $listItems Media list items to be removed @return \Aimeos\MShop\Attribute\Item\Iface Modified attribute item
[ "Removes", "the", "media", "reference", "and", "the", "media", "item", "if", "not", "shared" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Attribute/Media/Standard.php#L287-L309
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Base.php
Base.getView
public function getView() { if( !isset( $this->view ) ) { throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'No view available' ) ); } return $this->view; }
php
public function getView() { if( !isset( $this->view ) ) { throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'No view available' ) ); } return $this->view; }
[ "public", "function", "getView", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "view", ")", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "sprintf", "(", "'No view available'", ")", ")", ";", "}", "return", "$", "this", "->", "view", ";", "}" ]
Returns the view object that will generate the admin output. @return \Aimeos\MW\View\Iface The view object which generates the admin output
[ "Returns", "the", "view", "object", "that", "will", "generate", "the", "admin", "output", "." ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Base.php#L88-L95
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Base.php
Base.addDecorators
protected function addDecorators( \Aimeos\Admin\JQAdm\Iface $client, array $decorators, $classprefix ) { foreach( $decorators as $name ) { if( ctype_alnum( $name ) === false ) { $classname = is_string( $name ) ? $classprefix . $name : '<not a string>'; throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); } $classname = $classprefix . $name; if( class_exists( $classname ) === false ) { throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); } $client = new $classname( $client, $this->context ); \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\Iface', $client ); } return $client; }
php
protected function addDecorators( \Aimeos\Admin\JQAdm\Iface $client, array $decorators, $classprefix ) { foreach( $decorators as $name ) { if( ctype_alnum( $name ) === false ) { $classname = is_string( $name ) ? $classprefix . $name : '<not a string>'; throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); } $classname = $classprefix . $name; if( class_exists( $classname ) === false ) { throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); } $client = new $classname( $client, $this->context ); \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\Iface', $client ); } return $client; }
[ "protected", "function", "addDecorators", "(", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Iface", "$", "client", ",", "array", "$", "decorators", ",", "$", "classprefix", ")", "{", "foreach", "(", "$", "decorators", "as", "$", "name", ")", "{", "if", "(", "ctype_alnum", "(", "$", "name", ")", "===", "false", ")", "{", "$", "classname", "=", "is_string", "(", "$", "name", ")", "?", "$", "classprefix", ".", "$", "name", ":", "'<not a string>'", ";", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "sprintf", "(", "'Invalid class name \"%1$s\"'", ",", "$", "classname", ")", ")", ";", "}", "$", "classname", "=", "$", "classprefix", ".", "$", "name", ";", "if", "(", "class_exists", "(", "$", "classname", ")", "===", "false", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "sprintf", "(", "'Class \"%1$s\" not found'", ",", "$", "classname", ")", ")", ";", "}", "$", "client", "=", "new", "$", "classname", "(", "$", "client", ",", "$", "this", "->", "context", ")", ";", "\\", "Aimeos", "\\", "MW", "\\", "Common", "\\", "Base", "::", "checkClass", "(", "'\\\\Aimeos\\\\Admin\\\\JQAdm\\\\Common\\\\Decorator\\\\Iface'", ",", "$", "client", ")", ";", "}", "return", "$", "client", ";", "}" ]
Adds the decorators to the client object @param \Aimeos\Admin\JQAdm\Iface $client Admin object @param array $decorators List of decorator name that should be wrapped around the client @param string $classprefix Decorator class prefix, e.g. "\Aimeos\Admin\JQAdm\Catalog\Decorator\" @return \Aimeos\Admin\JQAdm\Iface Admin object
[ "Adds", "the", "decorators", "to", "the", "client", "object" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Base.php#L223-L245
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Base.php
Base.getValue
protected function getValue( array $values, $key, $default = null ) { foreach( explode( '/', trim( $key, '/' ) ) as $part ) { if( isset( $values[$part] ) ) { $values = $values[$part]; } else { return $default; } } return $values; }
php
protected function getValue( array $values, $key, $default = null ) { foreach( explode( '/', trim( $key, '/' ) ) as $part ) { if( isset( $values[$part] ) ) { $values = $values[$part]; } else { return $default; } } return $values; }
[ "protected", "function", "getValue", "(", "array", "$", "values", ",", "$", "key", ",", "$", "default", "=", "null", ")", "{", "foreach", "(", "explode", "(", "'/'", ",", "trim", "(", "$", "key", ",", "'/'", ")", ")", "as", "$", "part", ")", "{", "if", "(", "isset", "(", "$", "values", "[", "$", "part", "]", ")", ")", "{", "$", "values", "=", "$", "values", "[", "$", "part", "]", ";", "}", "else", "{", "return", "$", "default", ";", "}", "}", "return", "$", "values", ";", "}" ]
Returns the value for the given key in the array @param array $values Multi-dimensional associative list of key/value pairs @param string $key Parameter key like "name" or "list/test" for associative arrays @param mixed $default Returned value if no one for key is available @return mixed Value from the array or default value if not present in array
[ "Returns", "the", "value", "for", "the", "given", "key", "in", "the", "array" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Base.php#L336-L348
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Base.php
Base.getClientParams
protected function getClientParams( $names = array( 'id', 'resource', 'site', 'lang' ) ) { $list = []; foreach( $names as $name ) { if( ( $val = $this->view->param( $name ) ) !== null ) { $list[$name] = $val; } } return $list; }
php
protected function getClientParams( $names = array( 'id', 'resource', 'site', 'lang' ) ) { $list = []; foreach( $names as $name ) { if( ( $val = $this->view->param( $name ) ) !== null ) { $list[$name] = $val; } } return $list; }
[ "protected", "function", "getClientParams", "(", "$", "names", "=", "array", "(", "'id'", ",", "'resource'", ",", "'site'", ",", "'lang'", ")", ")", "{", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "if", "(", "(", "$", "val", "=", "$", "this", "->", "view", "->", "param", "(", "$", "name", ")", ")", "!==", "null", ")", "{", "$", "list", "[", "$", "name", "]", "=", "$", "val", ";", "}", "}", "return", "$", "list", ";", "}" ]
Returns the known client parameters and their values @param array $names List of parameter names @return array Associative list of parameters names as key and their values
[ "Returns", "the", "known", "client", "parameters", "and", "their", "values" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Base.php#L357-L369
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Base.php
Base.getClassNames
protected function getClassNames( $relpath, array $excludes = ['Base.php', 'Iface.php', 'Example.php', 'None.php'] ) { $list = []; foreach( $this->getAimeos()->getIncludePaths() as $path ) { $path .= DIRECTORY_SEPARATOR . $relpath; if( is_dir( $path ) ) { foreach( new \DirectoryIterator( $path ) as $entry ) { if( $entry->isFile() && !in_array( $entry->getFileName(), $excludes ) ) { $list[] = pathinfo( $entry->getFileName(), PATHINFO_FILENAME ); } } } } sort( $list ); return $list; }
php
protected function getClassNames( $relpath, array $excludes = ['Base.php', 'Iface.php', 'Example.php', 'None.php'] ) { $list = []; foreach( $this->getAimeos()->getIncludePaths() as $path ) { $path .= DIRECTORY_SEPARATOR . $relpath; if( is_dir( $path ) ) { foreach( new \DirectoryIterator( $path ) as $entry ) { if( $entry->isFile() && !in_array( $entry->getFileName(), $excludes ) ) { $list[] = pathinfo( $entry->getFileName(), PATHINFO_FILENAME ); } } } } sort( $list ); return $list; }
[ "protected", "function", "getClassNames", "(", "$", "relpath", ",", "array", "$", "excludes", "=", "[", "'Base.php'", ",", "'Iface.php'", ",", "'Example.php'", ",", "'None.php'", "]", ")", "{", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getAimeos", "(", ")", "->", "getIncludePaths", "(", ")", "as", "$", "path", ")", "{", "$", "path", ".=", "DIRECTORY_SEPARATOR", ".", "$", "relpath", ";", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "foreach", "(", "new", "\\", "DirectoryIterator", "(", "$", "path", ")", "as", "$", "entry", ")", "{", "if", "(", "$", "entry", "->", "isFile", "(", ")", "&&", "!", "in_array", "(", "$", "entry", "->", "getFileName", "(", ")", ",", "$", "excludes", ")", ")", "{", "$", "list", "[", "]", "=", "pathinfo", "(", "$", "entry", "->", "getFileName", "(", ")", ",", "PATHINFO_FILENAME", ")", ";", "}", "}", "}", "}", "sort", "(", "$", "list", ")", ";", "return", "$", "list", ";", "}" ]
Returns the available class names without namespace that are stored in the given path @param string $relpath Path relative to the include paths @param string[] $excludes List of file names to execlude @return string[] List of available class names
[ "Returns", "the", "available", "class", "names", "without", "namespace", "that", "are", "stored", "in", "the", "given", "path" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Base.php#L398-L419
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Base.php
Base.getCriteriaConditions
protected function getCriteriaConditions( array $params ) { $expr = []; if( isset( $params['key'] ) ) { foreach( (array) $params['key'] as $idx => $key ) { if( $key != '' && isset( $params['op'][$idx] ) && $params['op'][$idx] != '' && isset( $params['val'][$idx] ) && $params['val'][$idx] != '' ) { $expr[] = [$params['op'][$idx] => [$key => $params['val'][$idx]]]; } } if( !empty( $expr ) ) { $expr = ['&&' => $expr]; } } return $expr; }
php
protected function getCriteriaConditions( array $params ) { $expr = []; if( isset( $params['key'] ) ) { foreach( (array) $params['key'] as $idx => $key ) { if( $key != '' && isset( $params['op'][$idx] ) && $params['op'][$idx] != '' && isset( $params['val'][$idx] ) && $params['val'][$idx] != '' ) { $expr[] = [$params['op'][$idx] => [$key => $params['val'][$idx]]]; } } if( !empty( $expr ) ) { $expr = ['&&' => $expr]; } } return $expr; }
[ "protected", "function", "getCriteriaConditions", "(", "array", "$", "params", ")", "{", "$", "expr", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "params", "[", "'key'", "]", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "params", "[", "'key'", "]", "as", "$", "idx", "=>", "$", "key", ")", "{", "if", "(", "$", "key", "!=", "''", "&&", "isset", "(", "$", "params", "[", "'op'", "]", "[", "$", "idx", "]", ")", "&&", "$", "params", "[", "'op'", "]", "[", "$", "idx", "]", "!=", "''", "&&", "isset", "(", "$", "params", "[", "'val'", "]", "[", "$", "idx", "]", ")", "&&", "$", "params", "[", "'val'", "]", "[", "$", "idx", "]", "!=", "''", ")", "{", "$", "expr", "[", "]", "=", "[", "$", "params", "[", "'op'", "]", "[", "$", "idx", "]", "=>", "[", "$", "key", "=>", "$", "params", "[", "'val'", "]", "[", "$", "idx", "]", "]", "]", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "expr", ")", ")", "{", "$", "expr", "=", "[", "'&&'", "=>", "$", "expr", "]", ";", "}", "}", "return", "$", "expr", ";", "}" ]
Returns the array of criteria conditions based on the given parameters @param array $params List of criteria data with condition, sorting and paging @return array Multi-dimensional associative list of criteria conditions
[ "Returns", "the", "array", "of", "criteria", "conditions", "based", "on", "the", "given", "parameters" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Base.php#L428-L449
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Base.php
Base.getCriteriaSortations
protected function getCriteriaSortations( array $params ) { $sortation = []; foreach( $params as $sort ) { if( $sort[0] === '-' ) { $sortation[substr( $sort, 1 )] = '-'; } else { $sortation[$sort] = '+'; } } return $sortation; }
php
protected function getCriteriaSortations( array $params ) { $sortation = []; foreach( $params as $sort ) { if( $sort[0] === '-' ) { $sortation[substr( $sort, 1 )] = '-'; } else { $sortation[$sort] = '+'; } } return $sortation; }
[ "protected", "function", "getCriteriaSortations", "(", "array", "$", "params", ")", "{", "$", "sortation", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "sort", ")", "{", "if", "(", "$", "sort", "[", "0", "]", "===", "'-'", ")", "{", "$", "sortation", "[", "substr", "(", "$", "sort", ",", "1", ")", "]", "=", "'-'", ";", "}", "else", "{", "$", "sortation", "[", "$", "sort", "]", "=", "'+'", ";", "}", "}", "return", "$", "sortation", ";", "}" ]
Returns the array of criteria sortations based on the given parameters @param array $params List of criteria data with condition, sorting and paging @return array Associative list of criteria sortations
[ "Returns", "the", "array", "of", "criteria", "sortations", "based", "on", "the", "given", "parameters" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Base.php#L458-L472
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Base.php
Base.initCriteria
protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) { if( isset( $params['filter'] ) ) { $criteria = $this->initCriteriaConditions( $criteria, (array) $params['filter'] ); } if( isset( $params['sort'] ) ) { $criteria = $this->initCriteriaSortations( $criteria, (array) $params['sort'] ); } $page = []; if( isset( $params['page'] ) ) { $page = (array) $params['page']; } return $this->initCriteriaSlice( $criteria, $page ); }
php
protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) { if( isset( $params['filter'] ) ) { $criteria = $this->initCriteriaConditions( $criteria, (array) $params['filter'] ); } if( isset( $params['sort'] ) ) { $criteria = $this->initCriteriaSortations( $criteria, (array) $params['sort'] ); } $page = []; if( isset( $params['page'] ) ) { $page = (array) $params['page']; } return $this->initCriteriaSlice( $criteria, $page ); }
[ "protected", "function", "initCriteria", "(", "\\", "Aimeos", "\\", "MW", "\\", "Criteria", "\\", "Iface", "$", "criteria", ",", "array", "$", "params", ")", "{", "if", "(", "isset", "(", "$", "params", "[", "'filter'", "]", ")", ")", "{", "$", "criteria", "=", "$", "this", "->", "initCriteriaConditions", "(", "$", "criteria", ",", "(", "array", ")", "$", "params", "[", "'filter'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'sort'", "]", ")", ")", "{", "$", "criteria", "=", "$", "this", "->", "initCriteriaSortations", "(", "$", "criteria", ",", "(", "array", ")", "$", "params", "[", "'sort'", "]", ")", ";", "}", "$", "page", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "params", "[", "'page'", "]", ")", ")", "{", "$", "page", "=", "(", "array", ")", "$", "params", "[", "'page'", "]", ";", "}", "return", "$", "this", "->", "initCriteriaSlice", "(", "$", "criteria", ",", "$", "page", ")", ";", "}" ]
Initializes the criteria object based on the given parameter @param \Aimeos\MW\Criteria\Iface $criteria Criteria object @param array $params List of criteria data with condition, sorting and paging @return \Aimeos\MW\Criteria\Iface Initialized criteria object
[ "Initializes", "the", "criteria", "object", "based", "on", "the", "given", "parameter" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Base.php#L502-L518
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Base.php
Base.nextAction
protected function nextAction( \Aimeos\MW\View\Iface $view, $action, $resource, $id = null, $act = null ) { $params = $this->getClientParams(); $params['resource'] = $resource; unset( $params['id'] ); if( $act ) { $params['act'] = $act; } switch( $action ) { case 'search': $target = $view->config( 'admin/jqadm/url/search/target' ); $cntl = $view->config( 'admin/jqadm/url/search/controller', 'Jqadm' ); $action = $view->config( 'admin/jqadm/url/search/action', 'search' ); $conf = $view->config( 'admin/jqadm/url/search/config', [] ); $url = $view->url( $target, $cntl, $action, $params, [], $conf ); break; case 'create': $target = $view->config( 'admin/jqadm/url/create/target' ); $cntl = $view->config( 'admin/jqadm/url/create/controller', 'Jqadm' ); $action = $view->config( 'admin/jqadm/url/create/action', 'create' ); $conf = $view->config( 'admin/jqadm/url/create/config', [] ); $url = $view->url( $target, $cntl, $action, $params, [], $conf ); break; case 'copy': $target = $view->config( 'admin/jqadm/url/copy/target' ); $cntl = $view->config( 'admin/jqadm/url/copy/controller', 'Jqadm' ); $action = $view->config( 'admin/jqadm/url/copy/action', 'copy' ); $conf = $view->config( 'admin/jqadm/url/copy/config', [] ); $url = $view->url( $target, $cntl, $action, ['id' => $id] + $params, [], $conf ); break; default: $target = $view->config( 'admin/jqadm/url/get/target' ); $cntl = $view->config( 'admin/jqadm/url/get/controller', 'Jqadm' ); $action = $view->config( 'admin/jqadm/url/get/action', 'get' ); $conf = $view->config( 'admin/jqadm/url/get/config', [] ); $url = $view->url( $target, $cntl, $action, ['id' => $id] + $params, [], $conf ); } $view->response()->withStatus( 302 ); $view->response()->withHeader( 'Location', $url ); $view->response()->withHeader( 'Cache-Control', 'no-store' ); return $view; }
php
protected function nextAction( \Aimeos\MW\View\Iface $view, $action, $resource, $id = null, $act = null ) { $params = $this->getClientParams(); $params['resource'] = $resource; unset( $params['id'] ); if( $act ) { $params['act'] = $act; } switch( $action ) { case 'search': $target = $view->config( 'admin/jqadm/url/search/target' ); $cntl = $view->config( 'admin/jqadm/url/search/controller', 'Jqadm' ); $action = $view->config( 'admin/jqadm/url/search/action', 'search' ); $conf = $view->config( 'admin/jqadm/url/search/config', [] ); $url = $view->url( $target, $cntl, $action, $params, [], $conf ); break; case 'create': $target = $view->config( 'admin/jqadm/url/create/target' ); $cntl = $view->config( 'admin/jqadm/url/create/controller', 'Jqadm' ); $action = $view->config( 'admin/jqadm/url/create/action', 'create' ); $conf = $view->config( 'admin/jqadm/url/create/config', [] ); $url = $view->url( $target, $cntl, $action, $params, [], $conf ); break; case 'copy': $target = $view->config( 'admin/jqadm/url/copy/target' ); $cntl = $view->config( 'admin/jqadm/url/copy/controller', 'Jqadm' ); $action = $view->config( 'admin/jqadm/url/copy/action', 'copy' ); $conf = $view->config( 'admin/jqadm/url/copy/config', [] ); $url = $view->url( $target, $cntl, $action, ['id' => $id] + $params, [], $conf ); break; default: $target = $view->config( 'admin/jqadm/url/get/target' ); $cntl = $view->config( 'admin/jqadm/url/get/controller', 'Jqadm' ); $action = $view->config( 'admin/jqadm/url/get/action', 'get' ); $conf = $view->config( 'admin/jqadm/url/get/config', [] ); $url = $view->url( $target, $cntl, $action, ['id' => $id] + $params, [], $conf ); } $view->response()->withStatus( 302 ); $view->response()->withHeader( 'Location', $url ); $view->response()->withHeader( 'Cache-Control', 'no-store' ); return $view; }
[ "protected", "function", "nextAction", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ",", "$", "action", ",", "$", "resource", ",", "$", "id", "=", "null", ",", "$", "act", "=", "null", ")", "{", "$", "params", "=", "$", "this", "->", "getClientParams", "(", ")", ";", "$", "params", "[", "'resource'", "]", "=", "$", "resource", ";", "unset", "(", "$", "params", "[", "'id'", "]", ")", ";", "if", "(", "$", "act", ")", "{", "$", "params", "[", "'act'", "]", "=", "$", "act", ";", "}", "switch", "(", "$", "action", ")", "{", "case", "'search'", ":", "$", "target", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/search/target'", ")", ";", "$", "cntl", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/search/controller'", ",", "'Jqadm'", ")", ";", "$", "action", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/search/action'", ",", "'search'", ")", ";", "$", "conf", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/search/config'", ",", "[", "]", ")", ";", "$", "url", "=", "$", "view", "->", "url", "(", "$", "target", ",", "$", "cntl", ",", "$", "action", ",", "$", "params", ",", "[", "]", ",", "$", "conf", ")", ";", "break", ";", "case", "'create'", ":", "$", "target", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/create/target'", ")", ";", "$", "cntl", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/create/controller'", ",", "'Jqadm'", ")", ";", "$", "action", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/create/action'", ",", "'create'", ")", ";", "$", "conf", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/create/config'", ",", "[", "]", ")", ";", "$", "url", "=", "$", "view", "->", "url", "(", "$", "target", ",", "$", "cntl", ",", "$", "action", ",", "$", "params", ",", "[", "]", ",", "$", "conf", ")", ";", "break", ";", "case", "'copy'", ":", "$", "target", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/copy/target'", ")", ";", "$", "cntl", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/copy/controller'", ",", "'Jqadm'", ")", ";", "$", "action", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/copy/action'", ",", "'copy'", ")", ";", "$", "conf", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/copy/config'", ",", "[", "]", ")", ";", "$", "url", "=", "$", "view", "->", "url", "(", "$", "target", ",", "$", "cntl", ",", "$", "action", ",", "[", "'id'", "=>", "$", "id", "]", "+", "$", "params", ",", "[", "]", ",", "$", "conf", ")", ";", "break", ";", "default", ":", "$", "target", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/get/target'", ")", ";", "$", "cntl", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/get/controller'", ",", "'Jqadm'", ")", ";", "$", "action", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/get/action'", ",", "'get'", ")", ";", "$", "conf", "=", "$", "view", "->", "config", "(", "'admin/jqadm/url/get/config'", ",", "[", "]", ")", ";", "$", "url", "=", "$", "view", "->", "url", "(", "$", "target", ",", "$", "cntl", ",", "$", "action", ",", "[", "'id'", "=>", "$", "id", "]", "+", "$", "params", ",", "[", "]", ",", "$", "conf", ")", ";", "}", "$", "view", "->", "response", "(", ")", "->", "withStatus", "(", "302", ")", ";", "$", "view", "->", "response", "(", ")", "->", "withHeader", "(", "'Location'", ",", "$", "url", ")", ";", "$", "view", "->", "response", "(", ")", "->", "withHeader", "(", "'Cache-Control'", ",", "'no-store'", ")", ";", "return", "$", "view", ";", "}" ]
Adds a redirect to the response for the next action @param \Aimeos\MW\View\Iface $view View object @param string $action Next action @param string $resource Resource name @param string $id ID of the next resource item @return \Aimeos\MW\View\Iface Modified view object
[ "Adds", "a", "redirect", "to", "the", "response", "for", "the", "next", "action" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Base.php#L562-L608
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Base.php
Base.storeSearchParams
protected function storeSearchParams( array $params, $name ) { $key = 'aimeos/admin/jqadm/' . $name; $session = $this->getContext()->getSession(); if( isset( $params['filter'] ) ) { $session->set( $key . '/filter', $params['filter'] ); } if( isset( $params['sort'] ) ) { $session->set( $key . '/sort', $params['sort'] ); } if( isset( $params['page'] ) ) { $session->set( $key . '/page', $params['page'] ); } if( isset( $params['fields'] ) ) { $session->set( $key . '/fields', $params['fields'] ); } return [ 'fields' => $session->get( $key . '/fields' ), 'filter' => $session->get( $key . '/filter' ), 'page' => $session->get( $key . '/page' ), 'sort' => $session->get( $key . '/sort' ), ]; }
php
protected function storeSearchParams( array $params, $name ) { $key = 'aimeos/admin/jqadm/' . $name; $session = $this->getContext()->getSession(); if( isset( $params['filter'] ) ) { $session->set( $key . '/filter', $params['filter'] ); } if( isset( $params['sort'] ) ) { $session->set( $key . '/sort', $params['sort'] ); } if( isset( $params['page'] ) ) { $session->set( $key . '/page', $params['page'] ); } if( isset( $params['fields'] ) ) { $session->set( $key . '/fields', $params['fields'] ); } return [ 'fields' => $session->get( $key . '/fields' ), 'filter' => $session->get( $key . '/filter' ), 'page' => $session->get( $key . '/page' ), 'sort' => $session->get( $key . '/sort' ), ]; }
[ "protected", "function", "storeSearchParams", "(", "array", "$", "params", ",", "$", "name", ")", "{", "$", "key", "=", "'aimeos/admin/jqadm/'", ".", "$", "name", ";", "$", "session", "=", "$", "this", "->", "getContext", "(", ")", "->", "getSession", "(", ")", ";", "if", "(", "isset", "(", "$", "params", "[", "'filter'", "]", ")", ")", "{", "$", "session", "->", "set", "(", "$", "key", ".", "'/filter'", ",", "$", "params", "[", "'filter'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'sort'", "]", ")", ")", "{", "$", "session", "->", "set", "(", "$", "key", ".", "'/sort'", ",", "$", "params", "[", "'sort'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'page'", "]", ")", ")", "{", "$", "session", "->", "set", "(", "$", "key", ".", "'/page'", ",", "$", "params", "[", "'page'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'fields'", "]", ")", ")", "{", "$", "session", "->", "set", "(", "$", "key", ".", "'/fields'", ",", "$", "params", "[", "'fields'", "]", ")", ";", "}", "return", "[", "'fields'", "=>", "$", "session", "->", "get", "(", "$", "key", ".", "'/fields'", ")", ",", "'filter'", "=>", "$", "session", "->", "get", "(", "$", "key", ".", "'/filter'", ")", ",", "'page'", "=>", "$", "session", "->", "get", "(", "$", "key", ".", "'/page'", ")", ",", "'sort'", "=>", "$", "session", "->", "get", "(", "$", "key", ".", "'/sort'", ")", ",", "]", ";", "}" ]
Stores and returns the parameters used for searching items @param array $params GET/POST parameter set @param string $name Name of the panel/subpanel @return array Associative list of parameters for searching items
[ "Stores", "and", "returns", "the", "parameters", "used", "for", "searching", "items" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Base.php#L618-L645
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Service/Price/Standard.php
Standard.addViewData
protected function addViewData( \Aimeos\MW\View\Iface $view ) { $context = $this->getContext(); $priceTypeManager = \Aimeos\MShop::create( $context, 'price/type' ); $listTypeManager = \Aimeos\MShop::create( $context, 'service/lists/type' ); $currencyManager = \Aimeos\MShop::create( $context, 'locale/currency' ); $search = $priceTypeManager->createSearch( true )->setSlice( 0, 10000 ); $search->setConditions( $search->compare( '==', 'price.type.domain', 'service' ) ); $search->setSortations( [$search->sort( '+', 'price.type.position' )] ); $listSearch = $listTypeManager->createSearch( true )->setSlice( 0, 10000 ); $listSearch->setConditions( $listSearch->compare( '==', 'service.lists.type.domain', 'price' ) ); $listSearch->setSortations( [$listSearch->sort( '+', 'service.lists.type.position' )] ); $view->priceTypes = $this->map( $priceTypeManager->searchItems( $search ) ); $view->priceListTypes = $this->map( $listTypeManager->searchItems( $listSearch ) ); $view->priceCurrencies = $currencyManager->searchItems( $currencyManager->createSearch( true )->setSlice( 0, 10000 ) ); if( $view->priceCurrencies === [] ) { throw new \Aimeos\Admin\JQAdm\Exception( 'No currencies available. Please enable at least one currency' ); } return $view; }
php
protected function addViewData( \Aimeos\MW\View\Iface $view ) { $context = $this->getContext(); $priceTypeManager = \Aimeos\MShop::create( $context, 'price/type' ); $listTypeManager = \Aimeos\MShop::create( $context, 'service/lists/type' ); $currencyManager = \Aimeos\MShop::create( $context, 'locale/currency' ); $search = $priceTypeManager->createSearch( true )->setSlice( 0, 10000 ); $search->setConditions( $search->compare( '==', 'price.type.domain', 'service' ) ); $search->setSortations( [$search->sort( '+', 'price.type.position' )] ); $listSearch = $listTypeManager->createSearch( true )->setSlice( 0, 10000 ); $listSearch->setConditions( $listSearch->compare( '==', 'service.lists.type.domain', 'price' ) ); $listSearch->setSortations( [$listSearch->sort( '+', 'service.lists.type.position' )] ); $view->priceTypes = $this->map( $priceTypeManager->searchItems( $search ) ); $view->priceListTypes = $this->map( $listTypeManager->searchItems( $listSearch ) ); $view->priceCurrencies = $currencyManager->searchItems( $currencyManager->createSearch( true )->setSlice( 0, 10000 ) ); if( $view->priceCurrencies === [] ) { throw new \Aimeos\Admin\JQAdm\Exception( 'No currencies available. Please enable at least one currency' ); } return $view; }
[ "protected", "function", "addViewData", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "priceTypeManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'price/type'", ")", ";", "$", "listTypeManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'service/lists/type'", ")", ";", "$", "currencyManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'locale/currency'", ")", ";", "$", "search", "=", "$", "priceTypeManager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'price.type.domain'", ",", "'service'", ")", ")", ";", "$", "search", "->", "setSortations", "(", "[", "$", "search", "->", "sort", "(", "'+'", ",", "'price.type.position'", ")", "]", ")", ";", "$", "listSearch", "=", "$", "listTypeManager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "listSearch", "->", "setConditions", "(", "$", "listSearch", "->", "compare", "(", "'=='", ",", "'service.lists.type.domain'", ",", "'price'", ")", ")", ";", "$", "listSearch", "->", "setSortations", "(", "[", "$", "listSearch", "->", "sort", "(", "'+'", ",", "'service.lists.type.position'", ")", "]", ")", ";", "$", "view", "->", "priceTypes", "=", "$", "this", "->", "map", "(", "$", "priceTypeManager", "->", "searchItems", "(", "$", "search", ")", ")", ";", "$", "view", "->", "priceListTypes", "=", "$", "this", "->", "map", "(", "$", "listTypeManager", "->", "searchItems", "(", "$", "listSearch", ")", ")", ";", "$", "view", "->", "priceCurrencies", "=", "$", "currencyManager", "->", "searchItems", "(", "$", "currencyManager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ")", ";", "if", "(", "$", "view", "->", "priceCurrencies", "===", "[", "]", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "'No currencies available. Please enable at least one currency'", ")", ";", "}", "return", "$", "view", ";", "}" ]
Adds the required data used in the price template @param \Aimeos\MW\View\Iface $view View object @return \Aimeos\MW\View\Iface View object with assigned parameters
[ "Adds", "the", "required", "data", "used", "in", "the", "price", "template" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Service/Price/Standard.php#L289-L314
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Locale/Site/Standard.php
Standard.checkSite
protected function checkSite( $super, $id = null ) { if( $super === true || (string) $this->getUserSiteId() === (string) $id ) { return; } throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Permission denied' ) ); }
php
protected function checkSite( $super, $id = null ) { if( $super === true || (string) $this->getUserSiteId() === (string) $id ) { return; } throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Permission denied' ) ); }
[ "protected", "function", "checkSite", "(", "$", "super", ",", "$", "id", "=", "null", ")", "{", "if", "(", "$", "super", "===", "true", "||", "(", "string", ")", "$", "this", "->", "getUserSiteId", "(", ")", "===", "(", "string", ")", "$", "id", ")", "{", "return", ";", "}", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "sprintf", "(", "'Permission denied'", ")", ")", ";", "}" ]
Checks if the user is allowed to access the site item @param boolean $super True if user is a super user @param string $id ID of the site to access @throws \Aimeos\Admin\JQAdm\Exception If user isn't allowed to access the site
[ "Checks", "if", "the", "user", "is", "allowed", "to", "access", "the", "site", "item" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Locale/Site/Standard.php#L466-L473
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Locale/Site/Standard.php
Standard.getUserSiteId
protected function getUserSiteId() { $context = $this->getContext(); $manager = \Aimeos\MShop::create( $context, 'customer' ); return $manager->getItem( $context->getUserId() )->getSiteId(); }
php
protected function getUserSiteId() { $context = $this->getContext(); $manager = \Aimeos\MShop::create( $context, 'customer' ); return $manager->getItem( $context->getUserId() )->getSiteId(); }
[ "protected", "function", "getUserSiteId", "(", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'customer'", ")", ";", "return", "$", "manager", "->", "getItem", "(", "$", "context", "->", "getUserId", "(", ")", ")", "->", "getSiteId", "(", ")", ";", "}" ]
Returns the site ID of the current user @return string|null Site ID of the current user
[ "Returns", "the", "site", "ID", "of", "the", "current", "user" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Locale/Site/Standard.php#L481-L487
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Locale/Site/Standard.php
Standard.render
protected function render( \Aimeos\MW\View\Iface $view ) { /** admin/jqadm/locale/site/template-item * Relative path to the HTML body template for the locale item. * * The template file contains the HTML code and processing instructions * to generate the result shown in the body of the frontend. The * configuration string is the path to the template file relative * to the templates directory (usually in admin/jqadm/templates). * * You can overwrite the template file configuration in extensions and * provide alternative templates. These alternative templates should be * named like the default one but with the string "default" replaced by * an unique name. You may use the name of your project for this. If * you've implemented an alternative client class as well, "default" * should be replaced by the name of the new class. * * @param string Relative path to the template creating the HTML code * @since 2017.10 * @category Developer */ $tplconf = 'admin/jqadm/locale/site/template-item'; $default = 'locale/site/item-standard'; return $view->render( $view->config( $tplconf, $default ) ); }
php
protected function render( \Aimeos\MW\View\Iface $view ) { /** admin/jqadm/locale/site/template-item * Relative path to the HTML body template for the locale item. * * The template file contains the HTML code and processing instructions * to generate the result shown in the body of the frontend. The * configuration string is the path to the template file relative * to the templates directory (usually in admin/jqadm/templates). * * You can overwrite the template file configuration in extensions and * provide alternative templates. These alternative templates should be * named like the default one but with the string "default" replaced by * an unique name. You may use the name of your project for this. If * you've implemented an alternative client class as well, "default" * should be replaced by the name of the new class. * * @param string Relative path to the template creating the HTML code * @since 2017.10 * @category Developer */ $tplconf = 'admin/jqadm/locale/site/template-item'; $default = 'locale/site/item-standard'; return $view->render( $view->config( $tplconf, $default ) ); }
[ "protected", "function", "render", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ")", "{", "/** admin/jqadm/locale/site/template-item\n\t\t * Relative path to the HTML body template for the locale item.\n\t\t *\n\t\t * The template file contains the HTML code and processing instructions\n\t\t * to generate the result shown in the body of the frontend. The\n\t\t * configuration string is the path to the template file relative\n\t\t * to the templates directory (usually in admin/jqadm/templates).\n\t\t *\n\t\t * You can overwrite the template file configuration in extensions and\n\t\t * provide alternative templates. These alternative templates should be\n\t\t * named like the default one but with the string \"default\" replaced by\n\t\t * an unique name. You may use the name of your project for this. If\n\t\t * you've implemented an alternative client class as well, \"default\"\n\t\t * should be replaced by the name of the new class.\n\t\t *\n\t\t * @param string Relative path to the template creating the HTML code\n\t\t * @since 2017.10\n\t\t * @category Developer\n\t\t */", "$", "tplconf", "=", "'admin/jqadm/locale/site/template-item'", ";", "$", "default", "=", "'locale/site/item-standard'", ";", "return", "$", "view", "->", "render", "(", "$", "view", "->", "config", "(", "$", "tplconf", ",", "$", "default", ")", ")", ";", "}" ]
Returns the rendered template including the view data @return string HTML output
[ "Returns", "the", "rendered", "template", "including", "the", "view", "data" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Locale/Site/Standard.php#L611-L636
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Supplier/Product/Standard.php
Standard.getProductItems
protected function getProductItems( array $listItems ) { $list = []; foreach( $listItems as $listItem ) { $list[] = $listItem->getRefId(); } $manager = \Aimeos\MShop::create( $this->getContext(), 'product' ); $search = $manager->createSearch()->setSlice( 0, count( $list ) ); $search->setConditions( $search->compare( '==', 'product.id', $list ) ); return $manager->searchItems( $search ); }
php
protected function getProductItems( array $listItems ) { $list = []; foreach( $listItems as $listItem ) { $list[] = $listItem->getRefId(); } $manager = \Aimeos\MShop::create( $this->getContext(), 'product' ); $search = $manager->createSearch()->setSlice( 0, count( $list ) ); $search->setConditions( $search->compare( '==', 'product.id', $list ) ); return $manager->searchItems( $search ); }
[ "protected", "function", "getProductItems", "(", "array", "$", "listItems", ")", "{", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "listItems", "as", "$", "listItem", ")", "{", "$", "list", "[", "]", "=", "$", "listItem", "->", "getRefId", "(", ")", ";", "}", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'product'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", ")", "->", "setSlice", "(", "0", ",", "count", "(", "$", "list", ")", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'product.id'", ",", "$", "list", ")", ")", ";", "return", "$", "manager", "->", "searchItems", "(", "$", "search", ")", ";", "}" ]
Returns the product items referenced by the given list items @param \Aimeos\MShop\Common\Item\List\Iface[] $listItems Supplier list items referencing the products @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and items as values
[ "Returns", "the", "product", "items", "referenced", "by", "the", "given", "list", "items" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Supplier/Product/Standard.php#L330-L344
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Customer/Product/Standard.php
Standard.getListItems
protected function getListItems( \Aimeos\MShop\Customer\Item\Iface $item, array $params = [], &$total = null ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/lists' ); $search = $manager->createSearch(); $search->setSortations( [$search->sort( '-', 'customer.lists.ctime' )] ); $search = $this->initCriteria( $search, $params ); $expr = [ $search->getConditions(), $search->compare( '==', 'customer.lists.parentid', $item->getId() ), $search->compare( '==', 'customer.lists.domain', 'product' ), ]; $search->setConditions( $search->combine( '&&', $expr ) ); return $manager->searchItems( $search, [], $total ); }
php
protected function getListItems( \Aimeos\MShop\Customer\Item\Iface $item, array $params = [], &$total = null ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/lists' ); $search = $manager->createSearch(); $search->setSortations( [$search->sort( '-', 'customer.lists.ctime' )] ); $search = $this->initCriteria( $search, $params ); $expr = [ $search->getConditions(), $search->compare( '==', 'customer.lists.parentid', $item->getId() ), $search->compare( '==', 'customer.lists.domain', 'product' ), ]; $search->setConditions( $search->combine( '&&', $expr ) ); return $manager->searchItems( $search, [], $total ); }
[ "protected", "function", "getListItems", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Customer", "\\", "Item", "\\", "Iface", "$", "item", ",", "array", "$", "params", "=", "[", "]", ",", "&", "$", "total", "=", "null", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'customer/lists'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", ")", ";", "$", "search", "->", "setSortations", "(", "[", "$", "search", "->", "sort", "(", "'-'", ",", "'customer.lists.ctime'", ")", "]", ")", ";", "$", "search", "=", "$", "this", "->", "initCriteria", "(", "$", "search", ",", "$", "params", ")", ";", "$", "expr", "=", "[", "$", "search", "->", "getConditions", "(", ")", ",", "$", "search", "->", "compare", "(", "'=='", ",", "'customer.lists.parentid'", ",", "$", "item", "->", "getId", "(", ")", ")", ",", "$", "search", "->", "compare", "(", "'=='", ",", "'customer.lists.domain'", ",", "'product'", ")", ",", "]", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "combine", "(", "'&&'", ",", "$", "expr", ")", ")", ";", "return", "$", "manager", "->", "searchItems", "(", "$", "search", ",", "[", "]", ",", "$", "total", ")", ";", "}" ]
Returns the customer list items referencing the products @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object @param array $params Associative list of GET/POST parameters @param integer $total Value/result parameter that will contain the item total afterwards @return \Aimeos\MShop\Common\Item\List\Iface[] Customer list items referencing the products
[ "Returns", "the", "customer", "list", "items", "referencing", "the", "products" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Customer/Product/Standard.php#L288-L304
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Customer/Product/Standard.php
Standard.getListTypes
protected function getListTypes() { $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/lists/type' ); $search = $manager->createSearch( true )->setSlice( 0, 10000 ); $search->setConditions( $search->compare( '==', 'customer.lists.type.domain', 'product' ) ); $search->setSortations( [$search->sort( '+', 'customer.lists.type.position' )] ); return $this->map( $manager->searchItems( $search ) ); }
php
protected function getListTypes() { $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/lists/type' ); $search = $manager->createSearch( true )->setSlice( 0, 10000 ); $search->setConditions( $search->compare( '==', 'customer.lists.type.domain', 'product' ) ); $search->setSortations( [$search->sort( '+', 'customer.lists.type.position' )] ); return $this->map( $manager->searchItems( $search ) ); }
[ "protected", "function", "getListTypes", "(", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'customer/lists/type'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'customer.lists.type.domain'", ",", "'product'", ")", ")", ";", "$", "search", "->", "setSortations", "(", "[", "$", "search", "->", "sort", "(", "'+'", ",", "'customer.lists.type.position'", ")", "]", ")", ";", "return", "$", "this", "->", "map", "(", "$", "manager", "->", "searchItems", "(", "$", "search", ")", ")", ";", "}" ]
Returns the available product list types @return \Aimeos\MShop\Common\Item\Type\Iface[] Associative list of type IDs as keys and type codes as values
[ "Returns", "the", "available", "product", "list", "types" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Customer/Product/Standard.php#L312-L321
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Product/Subscription/Standard.php
Standard.getIntervalItems
protected function getIntervalItems() { $manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' ); $search = $manager->createSearch(); $expr = [ $search->compare( '==', 'attribute.type', 'interval' ), $search->compare( '==', 'attribute.domain', 'product' ), ]; $search->setConditions( $search->combine( '&&', $expr ) ); $search->setSortations( [$search->sort( '+', 'attribute.code' )] ); return $manager->searchItems( $search ); }
php
protected function getIntervalItems() { $manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' ); $search = $manager->createSearch(); $expr = [ $search->compare( '==', 'attribute.type', 'interval' ), $search->compare( '==', 'attribute.domain', 'product' ), ]; $search->setConditions( $search->combine( '&&', $expr ) ); $search->setSortations( [$search->sort( '+', 'attribute.code' )] ); return $manager->searchItems( $search ); }
[ "protected", "function", "getIntervalItems", "(", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'attribute'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", ")", ";", "$", "expr", "=", "[", "$", "search", "->", "compare", "(", "'=='", ",", "'attribute.type'", ",", "'interval'", ")", ",", "$", "search", "->", "compare", "(", "'=='", ",", "'attribute.domain'", ",", "'product'", ")", ",", "]", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "combine", "(", "'&&'", ",", "$", "expr", ")", ")", ";", "$", "search", "->", "setSortations", "(", "[", "$", "search", "->", "sort", "(", "'+'", ",", "'attribute.code'", ")", "]", ")", ";", "return", "$", "manager", "->", "searchItems", "(", "$", "search", ")", ";", "}" ]
Returns the available attribute items of type "interval" @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as keys and items as values
[ "Returns", "the", "available", "attribute", "items", "of", "type", "interval" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Product/Subscription/Standard.php#L230-L243
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Common/Decorator/Page.php
Page.setView
public function setView( \Aimeos\MW\View\Iface $view ) { parent::setView( $view ); // set first to be able to show errors occuring afterwards $view->pageParams = $this->getClientParams(); $context = $this->getContext(); $siteManager = \Aimeos\MShop::create( $context, 'locale/site' ); $langManager = \Aimeos\MShop::create( $context, 'locale/language' ); $customerManager = \Aimeos\MShop::create( $context, 'customer' ); $siteItem = $siteManager->findItem( $view->param( 'site', 'default' ) ); try { $siteid = $customerManager->getItem( $context->getUserId() )->getSiteId() ?: $siteItem->getSiteId(); } catch( \Exception $e ) { $siteid = $siteItem->getSiteId(); } if( $view->access( ['admin', 'super'] ) ) { $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE; } else { $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE; } $sitePath = $siteManager->getPath( $siteid ); $view->pageI18nList = $this->getAimeos()->getI18nList( 'admin' ); $view->pageLangItems = $langManager->searchItems( $langManager->createSearch( true ) ); $view->pageSiteTree = $siteManager->getTree( $siteid, [], $level ); $view->pageSitePath = $sitePath; $view->pageSiteItem = $siteItem; if( $view->access( ['super'] ) ) { $search = $siteManager->createSearch()->setSlice( 0, 1000 ); $search->setSortations( [$search->sort( '+', 'locale.site.label')] ); $search->setConditions( $search->compare( '==', 'locale.site.level', 0 ) ); $view->pageSiteList = $siteManager->searchItems( $search ); if( ( $rootItem = reset( $sitePath ) ) !== false ) { $view->pageSiteTree = $siteManager->getTree( $rootItem->getId(), [], $level ); } } else { $view->pageSiteList = [$view->pageSiteTree]; } $this->getClient()->setView( $view ); return $this; }
php
public function setView( \Aimeos\MW\View\Iface $view ) { parent::setView( $view ); // set first to be able to show errors occuring afterwards $view->pageParams = $this->getClientParams(); $context = $this->getContext(); $siteManager = \Aimeos\MShop::create( $context, 'locale/site' ); $langManager = \Aimeos\MShop::create( $context, 'locale/language' ); $customerManager = \Aimeos\MShop::create( $context, 'customer' ); $siteItem = $siteManager->findItem( $view->param( 'site', 'default' ) ); try { $siteid = $customerManager->getItem( $context->getUserId() )->getSiteId() ?: $siteItem->getSiteId(); } catch( \Exception $e ) { $siteid = $siteItem->getSiteId(); } if( $view->access( ['admin', 'super'] ) ) { $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE; } else { $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE; } $sitePath = $siteManager->getPath( $siteid ); $view->pageI18nList = $this->getAimeos()->getI18nList( 'admin' ); $view->pageLangItems = $langManager->searchItems( $langManager->createSearch( true ) ); $view->pageSiteTree = $siteManager->getTree( $siteid, [], $level ); $view->pageSitePath = $sitePath; $view->pageSiteItem = $siteItem; if( $view->access( ['super'] ) ) { $search = $siteManager->createSearch()->setSlice( 0, 1000 ); $search->setSortations( [$search->sort( '+', 'locale.site.label')] ); $search->setConditions( $search->compare( '==', 'locale.site.level', 0 ) ); $view->pageSiteList = $siteManager->searchItems( $search ); if( ( $rootItem = reset( $sitePath ) ) !== false ) { $view->pageSiteTree = $siteManager->getTree( $rootItem->getId(), [], $level ); } } else { $view->pageSiteList = [$view->pageSiteTree]; } $this->getClient()->setView( $view ); return $this; }
[ "public", "function", "setView", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ")", "{", "parent", "::", "setView", "(", "$", "view", ")", ";", "// set first to be able to show errors occuring afterwards", "$", "view", "->", "pageParams", "=", "$", "this", "->", "getClientParams", "(", ")", ";", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "siteManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'locale/site'", ")", ";", "$", "langManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'locale/language'", ")", ";", "$", "customerManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'customer'", ")", ";", "$", "siteItem", "=", "$", "siteManager", "->", "findItem", "(", "$", "view", "->", "param", "(", "'site'", ",", "'default'", ")", ")", ";", "try", "{", "$", "siteid", "=", "$", "customerManager", "->", "getItem", "(", "$", "context", "->", "getUserId", "(", ")", ")", "->", "getSiteId", "(", ")", "?", ":", "$", "siteItem", "->", "getSiteId", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "siteid", "=", "$", "siteItem", "->", "getSiteId", "(", ")", ";", "}", "if", "(", "$", "view", "->", "access", "(", "[", "'admin'", ",", "'super'", "]", ")", ")", "{", "$", "level", "=", "\\", "Aimeos", "\\", "MW", "\\", "Tree", "\\", "Manager", "\\", "Base", "::", "LEVEL_TREE", ";", "}", "else", "{", "$", "level", "=", "\\", "Aimeos", "\\", "MW", "\\", "Tree", "\\", "Manager", "\\", "Base", "::", "LEVEL_ONE", ";", "}", "$", "sitePath", "=", "$", "siteManager", "->", "getPath", "(", "$", "siteid", ")", ";", "$", "view", "->", "pageI18nList", "=", "$", "this", "->", "getAimeos", "(", ")", "->", "getI18nList", "(", "'admin'", ")", ";", "$", "view", "->", "pageLangItems", "=", "$", "langManager", "->", "searchItems", "(", "$", "langManager", "->", "createSearch", "(", "true", ")", ")", ";", "$", "view", "->", "pageSiteTree", "=", "$", "siteManager", "->", "getTree", "(", "$", "siteid", ",", "[", "]", ",", "$", "level", ")", ";", "$", "view", "->", "pageSitePath", "=", "$", "sitePath", ";", "$", "view", "->", "pageSiteItem", "=", "$", "siteItem", ";", "if", "(", "$", "view", "->", "access", "(", "[", "'super'", "]", ")", ")", "{", "$", "search", "=", "$", "siteManager", "->", "createSearch", "(", ")", "->", "setSlice", "(", "0", ",", "1000", ")", ";", "$", "search", "->", "setSortations", "(", "[", "$", "search", "->", "sort", "(", "'+'", ",", "'locale.site.label'", ")", "]", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'locale.site.level'", ",", "0", ")", ")", ";", "$", "view", "->", "pageSiteList", "=", "$", "siteManager", "->", "searchItems", "(", "$", "search", ")", ";", "if", "(", "(", "$", "rootItem", "=", "reset", "(", "$", "sitePath", ")", ")", "!==", "false", ")", "{", "$", "view", "->", "pageSiteTree", "=", "$", "siteManager", "->", "getTree", "(", "$", "rootItem", "->", "getId", "(", ")", ",", "[", "]", ",", "$", "level", ")", ";", "}", "}", "else", "{", "$", "view", "->", "pageSiteList", "=", "[", "$", "view", "->", "pageSiteTree", "]", ";", "}", "$", "this", "->", "getClient", "(", ")", "->", "setView", "(", "$", "view", ")", ";", "return", "$", "this", ";", "}" ]
Sets the view object and adds the required page data to the view @param \Aimeos\MW\View\Iface $view The view object which generates the admin output @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls
[ "Sets", "the", "view", "object", "and", "adds", "the", "required", "page", "data", "to", "the", "view" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Common/Decorator/Page.php#L28-L81
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Product/Media/Standard.php
Standard.addMediaAttributes
protected function addMediaAttributes( \Aimeos\MShop\Media\Item\Iface $mediaItem, array $attrListItems ) { $listManager = \Aimeos\MShop::create( $this->getContext(), 'media/lists' ); $listItems = $mediaItem->getListItems( 'attribute', 'variant', null, false ); foreach( $attrListItems as $listItem ) { if( ( $litem = $mediaItem->getListItem( 'attribute', 'variant', $listItem->getRefId(), false ) ) !== null ) { unset( $listItems[$litem->getId()] ); continue; } $litem = $listManager->createItem()->setType( 'variant' )->setRefId( $listItem->getRefId() ); $mediaItem->addListItem( 'attribute', $litem ); } return $mediaItem->deleteListItems( $listItems ); }
php
protected function addMediaAttributes( \Aimeos\MShop\Media\Item\Iface $mediaItem, array $attrListItems ) { $listManager = \Aimeos\MShop::create( $this->getContext(), 'media/lists' ); $listItems = $mediaItem->getListItems( 'attribute', 'variant', null, false ); foreach( $attrListItems as $listItem ) { if( ( $litem = $mediaItem->getListItem( 'attribute', 'variant', $listItem->getRefId(), false ) ) !== null ) { unset( $listItems[$litem->getId()] ); continue; } $litem = $listManager->createItem()->setType( 'variant' )->setRefId( $listItem->getRefId() ); $mediaItem->addListItem( 'attribute', $litem ); } return $mediaItem->deleteListItems( $listItems ); }
[ "protected", "function", "addMediaAttributes", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Media", "\\", "Item", "\\", "Iface", "$", "mediaItem", ",", "array", "$", "attrListItems", ")", "{", "$", "listManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'media/lists'", ")", ";", "$", "listItems", "=", "$", "mediaItem", "->", "getListItems", "(", "'attribute'", ",", "'variant'", ",", "null", ",", "false", ")", ";", "foreach", "(", "$", "attrListItems", "as", "$", "listItem", ")", "{", "if", "(", "(", "$", "litem", "=", "$", "mediaItem", "->", "getListItem", "(", "'attribute'", ",", "'variant'", ",", "$", "listItem", "->", "getRefId", "(", ")", ",", "false", ")", ")", "!==", "null", ")", "{", "unset", "(", "$", "listItems", "[", "$", "litem", "->", "getId", "(", ")", "]", ")", ";", "continue", ";", "}", "$", "litem", "=", "$", "listManager", "->", "createItem", "(", ")", "->", "setType", "(", "'variant'", ")", "->", "setRefId", "(", "$", "listItem", "->", "getRefId", "(", ")", ")", ";", "$", "mediaItem", "->", "addListItem", "(", "'attribute'", ",", "$", "litem", ")", ";", "}", "return", "$", "mediaItem", "->", "deleteListItems", "(", "$", "listItems", ")", ";", "}" ]
Adds the product variant attributes to the media item Then, the images will only be shown if the customer selected the product variant @param \Aimeos\MShop\Media\Item\Iface $mediaItem Media item, maybe with referenced attribute items @param \Aimeos\MShop\Common\Item\Lists\Iface[] $attrListItems Product list items referencing variant attributes @return \Aimeos\MShop\Media\Item\Iface Modified media item
[ "Adds", "the", "product", "variant", "attributes", "to", "the", "media", "item", "Then", "the", "images", "will", "only", "be", "shown", "if", "the", "customer", "selected", "the", "product", "variant" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Product/Media/Standard.php#L260-L278
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Customer/Order/Standard.php
Standard.getOrderBaseItems
protected function getOrderBaseItems( array $items ) { $ids = []; foreach( $items as $item ) { $ids[] = $item->getBaseId(); } $manager = \Aimeos\MShop::create( $this->getContext(), 'order/base' ); $search = $manager->createSearch()->setSlice( 0, count( $ids ) ); $search->setConditions( $search->compare( '==', 'order.base.id', $ids ) ); return $manager->searchItems( $search ); }
php
protected function getOrderBaseItems( array $items ) { $ids = []; foreach( $items as $item ) { $ids[] = $item->getBaseId(); } $manager = \Aimeos\MShop::create( $this->getContext(), 'order/base' ); $search = $manager->createSearch()->setSlice( 0, count( $ids ) ); $search->setConditions( $search->compare( '==', 'order.base.id', $ids ) ); return $manager->searchItems( $search ); }
[ "protected", "function", "getOrderBaseItems", "(", "array", "$", "items", ")", "{", "$", "ids", "=", "[", "]", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "ids", "[", "]", "=", "$", "item", "->", "getBaseId", "(", ")", ";", "}", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'order/base'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", ")", "->", "setSlice", "(", "0", ",", "count", "(", "$", "ids", ")", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'order.base.id'", ",", "$", "ids", ")", ")", ";", "return", "$", "manager", "->", "searchItems", "(", "$", "search", ")", ";", "}" ]
Returns the basket items for the given orders @param \Aimeos\MShop\Order\Item\Iface[] $items Order item objects @return \Aimeos\MShop\Order\Item\Base\Iface[] Basket items
[ "Returns", "the", "basket", "items", "for", "the", "given", "orders" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Customer/Order/Standard.php#L203-L217
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Coupon/Code/Standard.php
Standard.checkFileUpload
protected function checkFileUpload( \Psr\Http\Message\UploadedFileInterface $file ) { if( $file->getError() !== UPLOAD_ERR_OK ) { switch( $file->getError() ) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: throw new \Aimeos\Admin\JQAdm\Exception( 'The uploaded file exceeds the max. allowed filesize' ); case UPLOAD_ERR_PARTIAL: throw new \Aimeos\Admin\JQAdm\Exception( 'The uploaded file was only partially uploaded' ); case UPLOAD_ERR_NO_FILE: throw new \Aimeos\Admin\JQAdm\Exception( 'No file was uploaded' ); case UPLOAD_ERR_NO_TMP_DIR: throw new \Aimeos\Admin\JQAdm\Exception( 'Temporary folder is missing' ); case UPLOAD_ERR_CANT_WRITE: throw new \Aimeos\Admin\JQAdm\Exception( 'Failed to write file to disk' ); case UPLOAD_ERR_EXTENSION: throw new \Aimeos\Admin\JQAdm\Exception( 'File upload stopped by extension' ); default: throw new \Aimeos\Admin\JQAdm\Exception( 'Unknown upload error' ); } } }
php
protected function checkFileUpload( \Psr\Http\Message\UploadedFileInterface $file ) { if( $file->getError() !== UPLOAD_ERR_OK ) { switch( $file->getError() ) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: throw new \Aimeos\Admin\JQAdm\Exception( 'The uploaded file exceeds the max. allowed filesize' ); case UPLOAD_ERR_PARTIAL: throw new \Aimeos\Admin\JQAdm\Exception( 'The uploaded file was only partially uploaded' ); case UPLOAD_ERR_NO_FILE: throw new \Aimeos\Admin\JQAdm\Exception( 'No file was uploaded' ); case UPLOAD_ERR_NO_TMP_DIR: throw new \Aimeos\Admin\JQAdm\Exception( 'Temporary folder is missing' ); case UPLOAD_ERR_CANT_WRITE: throw new \Aimeos\Admin\JQAdm\Exception( 'Failed to write file to disk' ); case UPLOAD_ERR_EXTENSION: throw new \Aimeos\Admin\JQAdm\Exception( 'File upload stopped by extension' ); default: throw new \Aimeos\Admin\JQAdm\Exception( 'Unknown upload error' ); } } }
[ "protected", "function", "checkFileUpload", "(", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "UploadedFileInterface", "$", "file", ")", "{", "if", "(", "$", "file", "->", "getError", "(", ")", "!==", "UPLOAD_ERR_OK", ")", "{", "switch", "(", "$", "file", "->", "getError", "(", ")", ")", "{", "case", "UPLOAD_ERR_INI_SIZE", ":", "case", "UPLOAD_ERR_FORM_SIZE", ":", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "'The uploaded file exceeds the max. allowed filesize'", ")", ";", "case", "UPLOAD_ERR_PARTIAL", ":", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "'The uploaded file was only partially uploaded'", ")", ";", "case", "UPLOAD_ERR_NO_FILE", ":", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "'No file was uploaded'", ")", ";", "case", "UPLOAD_ERR_NO_TMP_DIR", ":", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "'Temporary folder is missing'", ")", ";", "case", "UPLOAD_ERR_CANT_WRITE", ":", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "'Failed to write file to disk'", ")", ";", "case", "UPLOAD_ERR_EXTENSION", ":", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "'File upload stopped by extension'", ")", ";", "default", ":", "throw", "new", "\\", "Aimeos", "\\", "Admin", "\\", "JQAdm", "\\", "Exception", "(", "'Unknown upload error'", ")", ";", "}", "}", "}" ]
Checks if an error during upload occured @param \Psr\Http\Message\UploadedFileInterface $file Uploaded file @throws \Aimeos\Admin\JQAdm\Exception If an error occured during upload
[ "Checks", "if", "an", "error", "during", "upload", "occured" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Coupon/Code/Standard.php#L236-L259
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Coupon/Code/Standard.php
Standard.storeFile
protected function storeFile( \Aimeos\MShop\Coupon\Item\Iface $item, array $files ) { $file = $this->getValue( $files, 'code/file' ); if( $file == null || $file->getError() === UPLOAD_ERR_NO_FILE ) { return; } $this->checkFileUpload( $file ); $context = $this->getContext(); $fs = $context->getFilesystemManager()->get( 'fs-import' ); $dir = 'couponcode/' . $context->getLocale()->getSite()->getCode(); if( $fs->isdir( $dir ) === false ) { $fs->mkdir( $dir ); } $fs->writes( $dir . '/' . $item->getId() . '.csv', $file->getStream()->detach() ); }
php
protected function storeFile( \Aimeos\MShop\Coupon\Item\Iface $item, array $files ) { $file = $this->getValue( $files, 'code/file' ); if( $file == null || $file->getError() === UPLOAD_ERR_NO_FILE ) { return; } $this->checkFileUpload( $file ); $context = $this->getContext(); $fs = $context->getFilesystemManager()->get( 'fs-import' ); $dir = 'couponcode/' . $context->getLocale()->getSite()->getCode(); if( $fs->isdir( $dir ) === false ) { $fs->mkdir( $dir ); } $fs->writes( $dir . '/' . $item->getId() . '.csv', $file->getStream()->detach() ); }
[ "protected", "function", "storeFile", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Coupon", "\\", "Item", "\\", "Iface", "$", "item", ",", "array", "$", "files", ")", "{", "$", "file", "=", "$", "this", "->", "getValue", "(", "$", "files", ",", "'code/file'", ")", ";", "if", "(", "$", "file", "==", "null", "||", "$", "file", "->", "getError", "(", ")", "===", "UPLOAD_ERR_NO_FILE", ")", "{", "return", ";", "}", "$", "this", "->", "checkFileUpload", "(", "$", "file", ")", ";", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "fs", "=", "$", "context", "->", "getFilesystemManager", "(", ")", "->", "get", "(", "'fs-import'", ")", ";", "$", "dir", "=", "'couponcode/'", ".", "$", "context", "->", "getLocale", "(", ")", "->", "getSite", "(", ")", "->", "getCode", "(", ")", ";", "if", "(", "$", "fs", "->", "isdir", "(", "$", "dir", ")", "===", "false", ")", "{", "$", "fs", "->", "mkdir", "(", "$", "dir", ")", ";", "}", "$", "fs", "->", "writes", "(", "$", "dir", ".", "'/'", ".", "$", "item", "->", "getId", "(", ")", ".", "'.csv'", ",", "$", "file", "->", "getStream", "(", ")", "->", "detach", "(", ")", ")", ";", "}" ]
Stores the uploaded CSV file containing the coupon codes @param \Aimeos\MShop\Coupon\Item\Iface $item Coupon item object @param array $files File upload array including the PSR-7 file upload objects
[ "Stores", "the", "uploaded", "CSV", "file", "containing", "the", "coupon", "codes" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Coupon/Code/Standard.php#L364-L383
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Order/Standard.php
Standard.export
public function export() { $view = $this->getView(); $context = $this->getContext(); try { $params = $this->storeSearchParams( $view->param(), 'order' ); $msg = ['sitecode' => $context->getLocale()->getSite()->getCode()]; if( isset( $params['filter'] ) ) { $msg['filter'] = $this->getCriteriaConditions( $params['filter'] ); } if( isset( $params['sort'] ) ) { $msg['sort'] = $this->getCriteriaSortations( $params['sort'] ); } $mq = $context->getMessageQueueManager()->get( 'mq-admin' )->getQueue( 'order-export' ); $mq->add( json_encode( $msg ) ); $msg = $context->getI18n()->dt( 'admin', 'Your export will be available in a few minutes for download' ); $view->info = $view->get( 'info', [] ) + ['order-item' => $msg]; } catch( \Aimeos\MShop\Exception $e ) { $error = array( 'order-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); $view->errors = $view->get( 'errors', [] ) + $error; $this->logException( $e ); } catch( \Exception $e ) { $error = array( 'order-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); $view->errors = $view->get( 'errors', [] ) + $error; $this->logException( $e ); } return $this->search(); }
php
public function export() { $view = $this->getView(); $context = $this->getContext(); try { $params = $this->storeSearchParams( $view->param(), 'order' ); $msg = ['sitecode' => $context->getLocale()->getSite()->getCode()]; if( isset( $params['filter'] ) ) { $msg['filter'] = $this->getCriteriaConditions( $params['filter'] ); } if( isset( $params['sort'] ) ) { $msg['sort'] = $this->getCriteriaSortations( $params['sort'] ); } $mq = $context->getMessageQueueManager()->get( 'mq-admin' )->getQueue( 'order-export' ); $mq->add( json_encode( $msg ) ); $msg = $context->getI18n()->dt( 'admin', 'Your export will be available in a few minutes for download' ); $view->info = $view->get( 'info', [] ) + ['order-item' => $msg]; } catch( \Aimeos\MShop\Exception $e ) { $error = array( 'order-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); $view->errors = $view->get( 'errors', [] ) + $error; $this->logException( $e ); } catch( \Exception $e ) { $error = array( 'order-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); $view->errors = $view->get( 'errors', [] ) + $error; $this->logException( $e ); } return $this->search(); }
[ "public", "function", "export", "(", ")", "{", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "try", "{", "$", "params", "=", "$", "this", "->", "storeSearchParams", "(", "$", "view", "->", "param", "(", ")", ",", "'order'", ")", ";", "$", "msg", "=", "[", "'sitecode'", "=>", "$", "context", "->", "getLocale", "(", ")", "->", "getSite", "(", ")", "->", "getCode", "(", ")", "]", ";", "if", "(", "isset", "(", "$", "params", "[", "'filter'", "]", ")", ")", "{", "$", "msg", "[", "'filter'", "]", "=", "$", "this", "->", "getCriteriaConditions", "(", "$", "params", "[", "'filter'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'sort'", "]", ")", ")", "{", "$", "msg", "[", "'sort'", "]", "=", "$", "this", "->", "getCriteriaSortations", "(", "$", "params", "[", "'sort'", "]", ")", ";", "}", "$", "mq", "=", "$", "context", "->", "getMessageQueueManager", "(", ")", "->", "get", "(", "'mq-admin'", ")", "->", "getQueue", "(", "'order-export'", ")", ";", "$", "mq", "->", "add", "(", "json_encode", "(", "$", "msg", ")", ")", ";", "$", "msg", "=", "$", "context", "->", "getI18n", "(", ")", "->", "dt", "(", "'admin'", ",", "'Your export will be available in a few minutes for download'", ")", ";", "$", "view", "->", "info", "=", "$", "view", "->", "get", "(", "'info'", ",", "[", "]", ")", "+", "[", "'order-item'", "=>", "$", "msg", "]", ";", "}", "catch", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Exception", "$", "e", ")", "{", "$", "error", "=", "array", "(", "'order-item'", "=>", "$", "context", "->", "getI18n", "(", ")", "->", "dt", "(", "'mshop'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "$", "view", "->", "errors", "=", "$", "view", "->", "get", "(", "'errors'", ",", "[", "]", ")", "+", "$", "error", ";", "$", "this", "->", "logException", "(", "$", "e", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "error", "=", "array", "(", "'order-item'", "=>", "$", "e", "->", "getMessage", "(", ")", ".", "', '", ".", "$", "e", "->", "getFile", "(", ")", ".", "':'", ".", "$", "e", "->", "getLine", "(", ")", ")", ";", "$", "view", "->", "errors", "=", "$", "view", "->", "get", "(", "'errors'", ",", "[", "]", ")", "+", "$", "error", ";", "$", "this", "->", "logException", "(", "$", "e", ")", ";", "}", "return", "$", "this", "->", "search", "(", ")", ";", "}" ]
Exports a resource @return string Admin output to display
[ "Exports", "a", "resource" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Order/Standard.php#L124-L162
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Common/Decorator/Cache.php
Cache.delete
public function delete() { $result = $this->getClient()->delete(); $ids = (array) $this->getView()->param( 'id' ); $tags = array( 'product' ); foreach( $ids as $id ) { $tags[] = 'product-' . $id; } $this->getContext()->getCache()->deleteByTags( $tags ); return $result; }
php
public function delete() { $result = $this->getClient()->delete(); $ids = (array) $this->getView()->param( 'id' ); $tags = array( 'product' ); foreach( $ids as $id ) { $tags[] = 'product-' . $id; } $this->getContext()->getCache()->deleteByTags( $tags ); return $result; }
[ "public", "function", "delete", "(", ")", "{", "$", "result", "=", "$", "this", "->", "getClient", "(", ")", "->", "delete", "(", ")", ";", "$", "ids", "=", "(", "array", ")", "$", "this", "->", "getView", "(", ")", "->", "param", "(", "'id'", ")", ";", "$", "tags", "=", "array", "(", "'product'", ")", ";", "foreach", "(", "$", "ids", "as", "$", "id", ")", "{", "$", "tags", "[", "]", "=", "'product-'", ".", "$", "id", ";", "}", "$", "this", "->", "getContext", "(", ")", "->", "getCache", "(", ")", "->", "deleteByTags", "(", "$", "tags", ")", ";", "return", "$", "result", ";", "}" ]
Clears the cache after deleting the item @return string|null admin output to display or null for redirecting to the list
[ "Clears", "the", "cache", "after", "deleting", "the", "item" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Common/Decorator/Cache.php#L27-L41
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Service/Media/Property/Standard.php
Standard.addViewData
protected function addViewData( \Aimeos\MW\View\Iface $view ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'media/property/type' ); $search = $manager->createSearch( true )->setSlice( 0, 10000 ); $search->setConditions( $search->compare( '==', 'media.property.type.domain', 'service' ) ); $search->setSortations( [$search->sort( '+', 'media.property.type.position')] ); $view->propertyTypes = $this->map( $manager->searchItems( $search ) ); return $view; }
php
protected function addViewData( \Aimeos\MW\View\Iface $view ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'media/property/type' ); $search = $manager->createSearch( true )->setSlice( 0, 10000 ); $search->setConditions( $search->compare( '==', 'media.property.type.domain', 'service' ) ); $search->setSortations( [$search->sort( '+', 'media.property.type.position')] ); $view->propertyTypes = $this->map( $manager->searchItems( $search ) ); return $view; }
[ "protected", "function", "addViewData", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'media/property/type'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", "true", ")", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'media.property.type.domain'", ",", "'service'", ")", ")", ";", "$", "search", "->", "setSortations", "(", "[", "$", "search", "->", "sort", "(", "'+'", ",", "'media.property.type.position'", ")", "]", ")", ";", "$", "view", "->", "propertyTypes", "=", "$", "this", "->", "map", "(", "$", "manager", "->", "searchItems", "(", "$", "search", ")", ")", ";", "return", "$", "view", ";", "}" ]
Adds the required data used in the service template @param \Aimeos\MW\View\Iface $view View object @return \Aimeos\MW\View\Iface View object with assigned parameters
[ "Adds", "the", "required", "data", "used", "in", "the", "service", "template" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Service/Media/Property/Standard.php#L215-L226
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Customer/Standard.php
Standard.getGroupItems
protected function getGroupItems() { $list = []; $isSuper = $this->getView()->access( ['super'] ); $isAdmin = $this->getView()->access( ['admin'] ); $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/group' ); $search = $manager->createSearch(); $search->setSortations( [$search->sort( '+', 'customer.group.label' )] ); foreach( $manager->searchItems( $search ) as $groupId => $groupItem ) { if( !$isSuper && in_array( $groupItem->getCode(), ['super'] ) ) { continue; } if( !$isSuper && !$isAdmin && in_array( $groupItem->getCode(), ['super', 'admin', 'editor'] ) ) { continue; } $list[$groupId] = $groupItem; } return $list; }
php
protected function getGroupItems() { $list = []; $isSuper = $this->getView()->access( ['super'] ); $isAdmin = $this->getView()->access( ['admin'] ); $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/group' ); $search = $manager->createSearch(); $search->setSortations( [$search->sort( '+', 'customer.group.label' )] ); foreach( $manager->searchItems( $search ) as $groupId => $groupItem ) { if( !$isSuper && in_array( $groupItem->getCode(), ['super'] ) ) { continue; } if( !$isSuper && !$isAdmin && in_array( $groupItem->getCode(), ['super', 'admin', 'editor'] ) ) { continue; } $list[$groupId] = $groupItem; } return $list; }
[ "protected", "function", "getGroupItems", "(", ")", "{", "$", "list", "=", "[", "]", ";", "$", "isSuper", "=", "$", "this", "->", "getView", "(", ")", "->", "access", "(", "[", "'super'", "]", ")", ";", "$", "isAdmin", "=", "$", "this", "->", "getView", "(", ")", "->", "access", "(", "[", "'admin'", "]", ")", ";", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'customer/group'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", ")", ";", "$", "search", "->", "setSortations", "(", "[", "$", "search", "->", "sort", "(", "'+'", ",", "'customer.group.label'", ")", "]", ")", ";", "foreach", "(", "$", "manager", "->", "searchItems", "(", "$", "search", ")", "as", "$", "groupId", "=>", "$", "groupItem", ")", "{", "if", "(", "!", "$", "isSuper", "&&", "in_array", "(", "$", "groupItem", "->", "getCode", "(", ")", ",", "[", "'super'", "]", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "$", "isSuper", "&&", "!", "$", "isAdmin", "&&", "in_array", "(", "$", "groupItem", "->", "getCode", "(", ")", ",", "[", "'super'", ",", "'admin'", ",", "'editor'", "]", ")", ")", "{", "continue", ";", "}", "$", "list", "[", "$", "groupId", "]", "=", "$", "groupItem", ";", "}", "return", "$", "list", ";", "}" ]
Returns the available group items @return \Aimeos\MShop\Customer\Item\Group\Iface[] Associative list of group IDs as keys and group items as values
[ "Returns", "the", "available", "group", "items" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Customer/Standard.php#L452-L476
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Product/Selection/Standard.php
Standard.fromArrayAttributes
protected function fromArrayAttributes( \Aimeos\MShop\Product\Item\Iface $refItem, array $entry ) { $listManager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' ); $listItem = $listManager->createItem()->setType( 'variant' ); $litems = $refItem->getListItems( 'attribute', 'variant', null, false ); foreach( $entry as $pos => $attr ) { if( !isset( $attr['product.lists.refid'] ) || $attr['product.lists.refid'] == '' ) { continue; } if( ( $litem = $refItem->getListItem( 'attribute', 'variant', $attr['product.lists.refid'], false ) ) === null ) { $litem = clone $listItem; } $litem->fromArray( $attr, true ); $litem->setPosition( $pos ); $refItem->addListItem( 'attribute', $litem, $litem->getRefItem() ); unset( $litems[$litem->getId()] ); } return $refItem->deleteListItems( $litems ); }
php
protected function fromArrayAttributes( \Aimeos\MShop\Product\Item\Iface $refItem, array $entry ) { $listManager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' ); $listItem = $listManager->createItem()->setType( 'variant' ); $litems = $refItem->getListItems( 'attribute', 'variant', null, false ); foreach( $entry as $pos => $attr ) { if( !isset( $attr['product.lists.refid'] ) || $attr['product.lists.refid'] == '' ) { continue; } if( ( $litem = $refItem->getListItem( 'attribute', 'variant', $attr['product.lists.refid'], false ) ) === null ) { $litem = clone $listItem; } $litem->fromArray( $attr, true ); $litem->setPosition( $pos ); $refItem->addListItem( 'attribute', $litem, $litem->getRefItem() ); unset( $litems[$litem->getId()] ); } return $refItem->deleteListItems( $litems ); }
[ "protected", "function", "fromArrayAttributes", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Product", "\\", "Item", "\\", "Iface", "$", "refItem", ",", "array", "$", "entry", ")", "{", "$", "listManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'product/lists'", ")", ";", "$", "listItem", "=", "$", "listManager", "->", "createItem", "(", ")", "->", "setType", "(", "'variant'", ")", ";", "$", "litems", "=", "$", "refItem", "->", "getListItems", "(", "'attribute'", ",", "'variant'", ",", "null", ",", "false", ")", ";", "foreach", "(", "$", "entry", "as", "$", "pos", "=>", "$", "attr", ")", "{", "if", "(", "!", "isset", "(", "$", "attr", "[", "'product.lists.refid'", "]", ")", "||", "$", "attr", "[", "'product.lists.refid'", "]", "==", "''", ")", "{", "continue", ";", "}", "if", "(", "(", "$", "litem", "=", "$", "refItem", "->", "getListItem", "(", "'attribute'", ",", "'variant'", ",", "$", "attr", "[", "'product.lists.refid'", "]", ",", "false", ")", ")", "===", "null", ")", "{", "$", "litem", "=", "clone", "$", "listItem", ";", "}", "$", "litem", "->", "fromArray", "(", "$", "attr", ",", "true", ")", ";", "$", "litem", "->", "setPosition", "(", "$", "pos", ")", ";", "$", "refItem", "->", "addListItem", "(", "'attribute'", ",", "$", "litem", ",", "$", "litem", "->", "getRefItem", "(", ")", ")", ";", "unset", "(", "$", "litems", "[", "$", "litem", "->", "getId", "(", ")", "]", ")", ";", "}", "return", "$", "refItem", "->", "deleteListItems", "(", "$", "litems", ")", ";", "}" ]
Updates the variant attributes of the given product item @param \Aimeos\MShop\Product\Item\Iface $refItem Article item object @param array $entry Associative list of key/values for product attribute references @return \Aimeos\MShop\Product\Item\Iface Updated artice item object
[ "Updates", "the", "variant", "attributes", "of", "the", "given", "product", "item" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Product/Selection/Standard.php#L339-L364
train
aimeos/ai-admin-jqadm
admin/jqadm/src/Admin/JQAdm/Product/Characteristic/Property/Standard.php
Standard.excludeItems
protected function excludeItems( array $propItems ) { $excludes = array( 'package-length', 'package-height', 'package-width', 'package-weight' ); foreach( $propItems as $key => $propItem ) { if( in_array( $propItem->getType(), $excludes ) ) { unset( $propItems[$key] ); } } return $propItems; }
php
protected function excludeItems( array $propItems ) { $excludes = array( 'package-length', 'package-height', 'package-width', 'package-weight' ); foreach( $propItems as $key => $propItem ) { if( in_array( $propItem->getType(), $excludes ) ) { unset( $propItems[$key] ); } } return $propItems; }
[ "protected", "function", "excludeItems", "(", "array", "$", "propItems", ")", "{", "$", "excludes", "=", "array", "(", "'package-length'", ",", "'package-height'", ",", "'package-width'", ",", "'package-weight'", ")", ";", "foreach", "(", "$", "propItems", "as", "$", "key", "=>", "$", "propItem", ")", "{", "if", "(", "in_array", "(", "$", "propItem", "->", "getType", "(", ")", ",", "$", "excludes", ")", ")", "{", "unset", "(", "$", "propItems", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "propItems", ";", "}" ]
Filter the list of property items and remove items with excluded types @param \Aimeos\MShop\Common\Item\Property\Iface[] $propItems List of property items @return \Aimeos\MShop\Common\Item\Property\Iface[] Filtered list of property items
[ "Filter", "the", "list", "of", "property", "items", "and", "remove", "items", "with", "excluded", "types" ]
e7f118f38a1cdf156baba26f2ad398307955a528
https://github.com/aimeos/ai-admin-jqadm/blob/e7f118f38a1cdf156baba26f2ad398307955a528/admin/jqadm/src/Admin/JQAdm/Product/Characteristic/Property/Standard.php#L213-L225
train
hiqdev/yii2-thememanager
attic/View.php
View.__isset
public function __isset($name) { return ($name && parent::__isset($name)) || isset($this->params[$name]); }
php
public function __isset($name) { return ($name && parent::__isset($name)) || isset($this->params[$name]); }
[ "public", "function", "__isset", "(", "$", "name", ")", "{", "return", "(", "$", "name", "&&", "parent", "::", "__isset", "(", "$", "name", ")", ")", "||", "isset", "(", "$", "this", "->", "params", "[", "$", "name", "]", ")", ";", "}" ]
Magic is set checker. @param string $name the property or param name to check @return bool whether the value is set
[ "Magic", "is", "set", "checker", "." ]
0817fddba78492d0cfa094ad9126eff4313029e7
https://github.com/hiqdev/yii2-thememanager/blob/0817fddba78492d0cfa094ad9126eff4313029e7/attic/View.php#L63-L66
train
hiqdev/yii2-thememanager
src/ThemeManager.php
ThemeManager.getDefaultTheme
public function getDefaultTheme() { if (!$this->_defaultTheme) { $keys = $this->keys(); /// shame to PHP it can't be done in single line :( $this->_defaultTheme = reset($keys); } return $this->_defaultTheme; }
php
public function getDefaultTheme() { if (!$this->_defaultTheme) { $keys = $this->keys(); /// shame to PHP it can't be done in single line :( $this->_defaultTheme = reset($keys); } return $this->_defaultTheme; }
[ "public", "function", "getDefaultTheme", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_defaultTheme", ")", "{", "$", "keys", "=", "$", "this", "->", "keys", "(", ")", ";", "/// shame to PHP it can't be done in single line :(", "$", "this", "->", "_defaultTheme", "=", "reset", "(", "$", "keys", ")", ";", "}", "return", "$", "this", "->", "_defaultTheme", ";", "}" ]
Returns the default theme. Returns the first of available themes by default. @return string default theme name
[ "Returns", "the", "default", "theme", ".", "Returns", "the", "first", "of", "available", "themes", "by", "default", "." ]
0817fddba78492d0cfa094ad9126eff4313029e7
https://github.com/hiqdev/yii2-thememanager/blob/0817fddba78492d0cfa094ad9126eff4313029e7/src/ThemeManager.php#L71-L79
train
hiqdev/yii2-thememanager
src/ThemeManager.php
ThemeManager.registerAssets
public function registerAssets() { foreach (array_merge($this->assets, $this->getTheme()->assets) as $asset) { /** @var AssetBundle $asset */ $asset::register($this->getView()); } }
php
public function registerAssets() { foreach (array_merge($this->assets, $this->getTheme()->assets) as $asset) { /** @var AssetBundle $asset */ $asset::register($this->getView()); } }
[ "public", "function", "registerAssets", "(", ")", "{", "foreach", "(", "array_merge", "(", "$", "this", "->", "assets", ",", "$", "this", "->", "getTheme", "(", ")", "->", "assets", ")", "as", "$", "asset", ")", "{", "/** @var AssetBundle $asset */", "$", "asset", "::", "register", "(", "$", "this", "->", "getView", "(", ")", ")", ";", "}", "}" ]
Register all the assets.
[ "Register", "all", "the", "assets", "." ]
0817fddba78492d0cfa094ad9126eff4313029e7
https://github.com/hiqdev/yii2-thememanager/blob/0817fddba78492d0cfa094ad9126eff4313029e7/src/ThemeManager.php#L171-L177
train
hiqdev/yii2-thememanager
src/GetManagerTrait.php
GetManagerTrait.getManager
public function getManager() { if (!is_object($this->_manager)) { $this->_manager = Yii::$app->get($this->_manager); } return $this->_manager; }
php
public function getManager() { if (!is_object($this->_manager)) { $this->_manager = Yii::$app->get($this->_manager); } return $this->_manager; }
[ "public", "function", "getManager", "(", ")", "{", "if", "(", "!", "is_object", "(", "$", "this", "->", "_manager", ")", ")", "{", "$", "this", "->", "_manager", "=", "Yii", "::", "$", "app", "->", "get", "(", "$", "this", "->", "_manager", ")", ";", "}", "return", "$", "this", "->", "_manager", ";", "}" ]
Getter for manager. @return ThemeManager
[ "Getter", "for", "manager", "." ]
0817fddba78492d0cfa094ad9126eff4313029e7
https://github.com/hiqdev/yii2-thememanager/blob/0817fddba78492d0cfa094ad9126eff4313029e7/src/GetManagerTrait.php#L35-L42
train
hiqdev/yii2-thememanager
src/controllers/SettingsController.php
SettingsController.actionIndex
public function actionIndex() { $model = $this->getModel(); $data = Yii::$app->request->post($model->formName()); if (empty($data)) { $data = $this->getThemeSettingsStorage()->get(); } if (Yii::$app->request->getIsPost() && $model->load($data) && $model->validate()) { $this->getThemeSettingsStorage()->set($model); $this->setGlobalOrientation($model->filterOrientation); Yii::$app->session->setFlash('success', Yii::t('hiqdev.thememanager', 'Layout settings saved.')); } if (Yii::$app->request->isAjax) { return $this->renderAjax('//settings/_form', compact('model')); } return $this->render('index', compact('model')); }
php
public function actionIndex() { $model = $this->getModel(); $data = Yii::$app->request->post($model->formName()); if (empty($data)) { $data = $this->getThemeSettingsStorage()->get(); } if (Yii::$app->request->getIsPost() && $model->load($data) && $model->validate()) { $this->getThemeSettingsStorage()->set($model); $this->setGlobalOrientation($model->filterOrientation); Yii::$app->session->setFlash('success', Yii::t('hiqdev.thememanager', 'Layout settings saved.')); } if (Yii::$app->request->isAjax) { return $this->renderAjax('//settings/_form', compact('model')); } return $this->render('index', compact('model')); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "model", "=", "$", "this", "->", "getModel", "(", ")", ";", "$", "data", "=", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "$", "model", "->", "formName", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "getThemeSettingsStorage", "(", ")", "->", "get", "(", ")", ";", "}", "if", "(", "Yii", "::", "$", "app", "->", "request", "->", "getIsPost", "(", ")", "&&", "$", "model", "->", "load", "(", "$", "data", ")", "&&", "$", "model", "->", "validate", "(", ")", ")", "{", "$", "this", "->", "getThemeSettingsStorage", "(", ")", "->", "set", "(", "$", "model", ")", ";", "$", "this", "->", "setGlobalOrientation", "(", "$", "model", "->", "filterOrientation", ")", ";", "Yii", "::", "$", "app", "->", "session", "->", "setFlash", "(", "'success'", ",", "Yii", "::", "t", "(", "'hiqdev.thememanager'", ",", "'Layout settings saved.'", ")", ")", ";", "}", "if", "(", "Yii", "::", "$", "app", "->", "request", "->", "isAjax", ")", "{", "return", "$", "this", "->", "renderAjax", "(", "'//settings/_form'", ",", "compact", "(", "'model'", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'index'", ",", "compact", "(", "'model'", ")", ")", ";", "}" ]
Settings form. @return string|Response
[ "Settings", "form", "." ]
0817fddba78492d0cfa094ad9126eff4313029e7
https://github.com/hiqdev/yii2-thememanager/blob/0817fddba78492d0cfa094ad9126eff4313029e7/src/controllers/SettingsController.php#L53-L73
train
hiqdev/yii2-thememanager
src/Theme.php
Theme.init
public function init() { parent::init(); if (!is_array($this->pathMap)) { $this->pathMap = []; } $this->pathMap = $this->compilePathMap(ArrayHelper::merge([ '$themedViewPaths' => $this->buildThemedViewPaths(), '$themedWidgetPaths' => '$themedViewPaths/widgets', Yii::$app->viewPath => '$themedViewPaths', __DIR__ . '/widgets/views' => '$themedWidgetPaths', ], $this->getManager()->pathMap, $this->pathMap)); }
php
public function init() { parent::init(); if (!is_array($this->pathMap)) { $this->pathMap = []; } $this->pathMap = $this->compilePathMap(ArrayHelper::merge([ '$themedViewPaths' => $this->buildThemedViewPaths(), '$themedWidgetPaths' => '$themedViewPaths/widgets', Yii::$app->viewPath => '$themedViewPaths', __DIR__ . '/widgets/views' => '$themedWidgetPaths', ], $this->getManager()->pathMap, $this->pathMap)); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "this", "->", "pathMap", ")", ")", "{", "$", "this", "->", "pathMap", "=", "[", "]", ";", "}", "$", "this", "->", "pathMap", "=", "$", "this", "->", "compilePathMap", "(", "ArrayHelper", "::", "merge", "(", "[", "'$themedViewPaths'", "=>", "$", "this", "->", "buildThemedViewPaths", "(", ")", ",", "'$themedWidgetPaths'", "=>", "'$themedViewPaths/widgets'", ",", "Yii", "::", "$", "app", "->", "viewPath", "=>", "'$themedViewPaths'", ",", "__DIR__", ".", "'/widgets/views'", "=>", "'$themedWidgetPaths'", ",", "]", ",", "$", "this", "->", "getManager", "(", ")", "->", "pathMap", ",", "$", "this", "->", "pathMap", ")", ")", ";", "}" ]
Getter for pathMap.
[ "Getter", "for", "pathMap", "." ]
0817fddba78492d0cfa094ad9126eff4313029e7
https://github.com/hiqdev/yii2-thememanager/blob/0817fddba78492d0cfa094ad9126eff4313029e7/src/Theme.php#L73-L86
train
LaravelParse/Laravel-Parse
src/ParseServiceProvider.php
ParseServiceProvider.setupParse
protected function setupParse() { $config = $this->app->config->get('parse'); ParseClient::initialize($config['app_id'], $config['rest_key'], $config['master_key']); if (isset($config['server_url']) && isset($config['mount_path'])) { $serverURL = rtrim($config['server_url'], '/'); $mountPath = trim($config['mount_path'], '/').'/'; ParseClient::setServerURL($serverURL, $mountPath); } if (isset($config['session']) && $config['session'] === 'laravel') { ParseClient::setStorage(new ParseSessionStorage($this->app->session)); } }
php
protected function setupParse() { $config = $this->app->config->get('parse'); ParseClient::initialize($config['app_id'], $config['rest_key'], $config['master_key']); if (isset($config['server_url']) && isset($config['mount_path'])) { $serverURL = rtrim($config['server_url'], '/'); $mountPath = trim($config['mount_path'], '/').'/'; ParseClient::setServerURL($serverURL, $mountPath); } if (isset($config['session']) && $config['session'] === 'laravel') { ParseClient::setStorage(new ParseSessionStorage($this->app->session)); } }
[ "protected", "function", "setupParse", "(", ")", "{", "$", "config", "=", "$", "this", "->", "app", "->", "config", "->", "get", "(", "'parse'", ")", ";", "ParseClient", "::", "initialize", "(", "$", "config", "[", "'app_id'", "]", ",", "$", "config", "[", "'rest_key'", "]", ",", "$", "config", "[", "'master_key'", "]", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "'server_url'", "]", ")", "&&", "isset", "(", "$", "config", "[", "'mount_path'", "]", ")", ")", "{", "$", "serverURL", "=", "rtrim", "(", "$", "config", "[", "'server_url'", "]", ",", "'/'", ")", ";", "$", "mountPath", "=", "trim", "(", "$", "config", "[", "'mount_path'", "]", ",", "'/'", ")", ".", "'/'", ";", "ParseClient", "::", "setServerURL", "(", "$", "serverURL", ",", "$", "mountPath", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'session'", "]", ")", "&&", "$", "config", "[", "'session'", "]", "===", "'laravel'", ")", "{", "ParseClient", "::", "setStorage", "(", "new", "ParseSessionStorage", "(", "$", "this", "->", "app", "->", "session", ")", ")", ";", "}", "}" ]
Setup parse. @return void
[ "Setup", "parse", "." ]
59d8b44581dab0d8f79125b28ca12411c8cdc7f3
https://github.com/LaravelParse/Laravel-Parse/blob/59d8b44581dab0d8f79125b28ca12411c8cdc7f3/src/ParseServiceProvider.php#L62-L78
train
LaravelParse/Laravel-Parse
src/ParseSessionStorage.php
ParseSessionStorage.get
public function get($key) { if ($this->session->has($key)) { return $this->session->get($key); } }
php
public function get($key) { if ($this->session->has($key)) { return $this->session->get($key); } }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "session", "->", "has", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "session", "->", "get", "(", "$", "key", ")", ";", "}", "}" ]
Gets the value for a key from storage. @param string $key The key to get the value for @return mixed
[ "Gets", "the", "value", "for", "a", "key", "from", "storage", "." ]
59d8b44581dab0d8f79125b28ca12411c8cdc7f3
https://github.com/LaravelParse/Laravel-Parse/blob/59d8b44581dab0d8f79125b28ca12411c8cdc7f3/src/ParseSessionStorage.php#L65-L70
train
alxlit/coffeescript-php
src/CoffeeScript/Init.php
Init.load
static function load($root = NULL) { if ($root === NULL) { $root = realpath(dirname(__FILE__)); } $files = array( 'Compiler', 'Error', 'Helpers', 'Lexer', 'Nodes', 'Parser', 'Rewriter', 'Scope', 'SyntaxError', 'Value', 'yy/Base', // load the base class first 'yy/While', // For extends While 'yy/Access', 'yy/Arr', 'yy/Assign', 'yy/Block', 'yy/Call', 'yy/Class', 'yy/Closure', 'yy/Code', 'yy/Comment', 'yy/Existence', 'yy/Extends', 'yy/For', 'yy/If', 'yy/In', 'yy/Index', 'yy/Literal', 'yy/Obj', 'yy/Op', 'yy/Param', 'yy/Parens', 'yy/Range', 'yy/Return', 'yy/Slice', 'yy/Splat', 'yy/Switch', 'yy/Throw', 'yy/Try', 'yy/Value', ); foreach ($files as $file) { require_once "$root/$file.php"; } }
php
static function load($root = NULL) { if ($root === NULL) { $root = realpath(dirname(__FILE__)); } $files = array( 'Compiler', 'Error', 'Helpers', 'Lexer', 'Nodes', 'Parser', 'Rewriter', 'Scope', 'SyntaxError', 'Value', 'yy/Base', // load the base class first 'yy/While', // For extends While 'yy/Access', 'yy/Arr', 'yy/Assign', 'yy/Block', 'yy/Call', 'yy/Class', 'yy/Closure', 'yy/Code', 'yy/Comment', 'yy/Existence', 'yy/Extends', 'yy/For', 'yy/If', 'yy/In', 'yy/Index', 'yy/Literal', 'yy/Obj', 'yy/Op', 'yy/Param', 'yy/Parens', 'yy/Range', 'yy/Return', 'yy/Slice', 'yy/Splat', 'yy/Switch', 'yy/Throw', 'yy/Try', 'yy/Value', ); foreach ($files as $file) { require_once "$root/$file.php"; } }
[ "static", "function", "load", "(", "$", "root", "=", "NULL", ")", "{", "if", "(", "$", "root", "===", "NULL", ")", "{", "$", "root", "=", "realpath", "(", "dirname", "(", "__FILE__", ")", ")", ";", "}", "$", "files", "=", "array", "(", "'Compiler'", ",", "'Error'", ",", "'Helpers'", ",", "'Lexer'", ",", "'Nodes'", ",", "'Parser'", ",", "'Rewriter'", ",", "'Scope'", ",", "'SyntaxError'", ",", "'Value'", ",", "'yy/Base'", ",", "// load the base class first", "'yy/While'", ",", "// For extends While", "'yy/Access'", ",", "'yy/Arr'", ",", "'yy/Assign'", ",", "'yy/Block'", ",", "'yy/Call'", ",", "'yy/Class'", ",", "'yy/Closure'", ",", "'yy/Code'", ",", "'yy/Comment'", ",", "'yy/Existence'", ",", "'yy/Extends'", ",", "'yy/For'", ",", "'yy/If'", ",", "'yy/In'", ",", "'yy/Index'", ",", "'yy/Literal'", ",", "'yy/Obj'", ",", "'yy/Op'", ",", "'yy/Param'", ",", "'yy/Parens'", ",", "'yy/Range'", ",", "'yy/Return'", ",", "'yy/Slice'", ",", "'yy/Splat'", ",", "'yy/Switch'", ",", "'yy/Throw'", ",", "'yy/Try'", ",", "'yy/Value'", ",", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "require_once", "\"$root/$file.php\"", ";", "}", "}" ]
This function may be used in lieu of an autoloader.
[ "This", "function", "may", "be", "used", "in", "lieu", "of", "an", "autoloader", "." ]
0dd272746cb16a420dfba8073e54312b0a7ccb1b
https://github.com/alxlit/coffeescript-php/blob/0dd272746cb16a420dfba8073e54312b0a7ccb1b/src/CoffeeScript/Init.php#L18-L74
train
alxlit/coffeescript-php
src/CoffeeScript/Helpers.php
Helpers.args
static function args(array $args, $required, array $optional = NULL) { if (count($args) < $required) { throw new Error("Function requires at least $required arguments."); } return array_merge($args, (array) $optional); }
php
static function args(array $args, $required, array $optional = NULL) { if (count($args) < $required) { throw new Error("Function requires at least $required arguments."); } return array_merge($args, (array) $optional); }
[ "static", "function", "args", "(", "array", "$", "args", ",", "$", "required", ",", "array", "$", "optional", "=", "NULL", ")", "{", "if", "(", "count", "(", "$", "args", ")", "<", "$", "required", ")", "{", "throw", "new", "Error", "(", "\"Function requires at least $required arguments.\"", ")", ";", "}", "return", "array_merge", "(", "$", "args", ",", "(", "array", ")", "$", "optional", ")", ";", "}" ]
In some cases it seems to be unavoidable that method parameters conflict with their parent class's. This workaround is used to silence E_STRICT errors. @param $args `func_get_args()` @param $required The number of required arguments. @param $optional An array of defaults for optional arguments.
[ "In", "some", "cases", "it", "seems", "to", "be", "unavoidable", "that", "method", "parameters", "conflict", "with", "their", "parent", "class", "s", ".", "This", "workaround", "is", "used", "to", "silence", "E_STRICT", "errors", "." ]
0dd272746cb16a420dfba8073e54312b0a7ccb1b
https://github.com/alxlit/coffeescript-php/blob/0dd272746cb16a420dfba8073e54312b0a7ccb1b/src/CoffeeScript/Helpers.php#L18-L26
train
alxlit/coffeescript-php
src/CoffeeScript/Parser.php
Parser.Trace
static function Trace($TraceFILE, $zTracePrompt) { if (!$TraceFILE) { $zTracePrompt = 0; } elseif (!$zTracePrompt) { $TraceFILE = 0; } self::$yyTraceFILE = $TraceFILE; self::$yyTracePrompt = $zTracePrompt; }
php
static function Trace($TraceFILE, $zTracePrompt) { if (!$TraceFILE) { $zTracePrompt = 0; } elseif (!$zTracePrompt) { $TraceFILE = 0; } self::$yyTraceFILE = $TraceFILE; self::$yyTracePrompt = $zTracePrompt; }
[ "static", "function", "Trace", "(", "$", "TraceFILE", ",", "$", "zTracePrompt", ")", "{", "if", "(", "!", "$", "TraceFILE", ")", "{", "$", "zTracePrompt", "=", "0", ";", "}", "elseif", "(", "!", "$", "zTracePrompt", ")", "{", "$", "TraceFILE", "=", "0", ";", "}", "self", "::", "$", "yyTraceFILE", "=", "$", "TraceFILE", ";", "self", "::", "$", "yyTracePrompt", "=", "$", "zTracePrompt", ";", "}" ]
Turn parser tracing on by giving a stream to which to write the trace and a prompt to preface each trace message. Tracing is turned off by making either argument NULL Inputs: - A stream resource to which trace output should be written. If NULL, then tracing is turned off. - A prefix string written at the beginning of every line of trace output. If NULL, then tracing is turned off. Outputs: - None. @param resource @param string
[ "Turn", "parser", "tracing", "on", "by", "giving", "a", "stream", "to", "which", "to", "write", "the", "trace", "and", "a", "prompt", "to", "preface", "each", "trace", "message", ".", "Tracing", "is", "turned", "off", "by", "making", "either", "argument", "NULL" ]
0dd272746cb16a420dfba8073e54312b0a7ccb1b
https://github.com/alxlit/coffeescript-php/blob/0dd272746cb16a420dfba8073e54312b0a7ccb1b/src/CoffeeScript/Parser.php#L1613-L1622
train
alxlit/coffeescript-php
src/CoffeeScript/Parser.php
Parser.yy_shift
function yy_shift($yyNewState, $yyMajor, $yypMinor) { $this->yyidx++; if ($this->yyidx >= self::YYSTACKDEPTH) { $this->yyidx--; if (self::$yyTraceFILE) { fprintf(self::$yyTraceFILE, "%sStack Overflow!\n", self::$yyTracePrompt); } while ($this->yyidx >= 0) { $this->yy_pop_parser_stack(); } /* Here code is inserted which will execute if the parser ** stack ever overflows */ return; } $yytos = new yyStackEntry; $yytos->stateno = $yyNewState; $yytos->major = $yyMajor; $yytos->minor = $yypMinor; array_push($this->yystack, $yytos); if (self::$yyTraceFILE && $this->yyidx > 0) { fprintf(self::$yyTraceFILE, "%sShift %d\n", self::$yyTracePrompt, $yyNewState); fprintf(self::$yyTraceFILE, "%sStack:", self::$yyTracePrompt); for ($i = 1; $i <= $this->yyidx; $i++) { fprintf(self::$yyTraceFILE, " %s", self::tokenName($this->yystack[$i]->major)); } fwrite(self::$yyTraceFILE,"\n"); } }
php
function yy_shift($yyNewState, $yyMajor, $yypMinor) { $this->yyidx++; if ($this->yyidx >= self::YYSTACKDEPTH) { $this->yyidx--; if (self::$yyTraceFILE) { fprintf(self::$yyTraceFILE, "%sStack Overflow!\n", self::$yyTracePrompt); } while ($this->yyidx >= 0) { $this->yy_pop_parser_stack(); } /* Here code is inserted which will execute if the parser ** stack ever overflows */ return; } $yytos = new yyStackEntry; $yytos->stateno = $yyNewState; $yytos->major = $yyMajor; $yytos->minor = $yypMinor; array_push($this->yystack, $yytos); if (self::$yyTraceFILE && $this->yyidx > 0) { fprintf(self::$yyTraceFILE, "%sShift %d\n", self::$yyTracePrompt, $yyNewState); fprintf(self::$yyTraceFILE, "%sStack:", self::$yyTracePrompt); for ($i = 1; $i <= $this->yyidx; $i++) { fprintf(self::$yyTraceFILE, " %s", self::tokenName($this->yystack[$i]->major)); } fwrite(self::$yyTraceFILE,"\n"); } }
[ "function", "yy_shift", "(", "$", "yyNewState", ",", "$", "yyMajor", ",", "$", "yypMinor", ")", "{", "$", "this", "->", "yyidx", "++", ";", "if", "(", "$", "this", "->", "yyidx", ">=", "self", "::", "YYSTACKDEPTH", ")", "{", "$", "this", "->", "yyidx", "--", ";", "if", "(", "self", "::", "$", "yyTraceFILE", ")", "{", "fprintf", "(", "self", "::", "$", "yyTraceFILE", ",", "\"%sStack Overflow!\\n\"", ",", "self", "::", "$", "yyTracePrompt", ")", ";", "}", "while", "(", "$", "this", "->", "yyidx", ">=", "0", ")", "{", "$", "this", "->", "yy_pop_parser_stack", "(", ")", ";", "}", "/* Here code is inserted which will execute if the parser\n ** stack ever overflows */", "return", ";", "}", "$", "yytos", "=", "new", "yyStackEntry", ";", "$", "yytos", "->", "stateno", "=", "$", "yyNewState", ";", "$", "yytos", "->", "major", "=", "$", "yyMajor", ";", "$", "yytos", "->", "minor", "=", "$", "yypMinor", ";", "array_push", "(", "$", "this", "->", "yystack", ",", "$", "yytos", ")", ";", "if", "(", "self", "::", "$", "yyTraceFILE", "&&", "$", "this", "->", "yyidx", ">", "0", ")", "{", "fprintf", "(", "self", "::", "$", "yyTraceFILE", ",", "\"%sShift %d\\n\"", ",", "self", "::", "$", "yyTracePrompt", ",", "$", "yyNewState", ")", ";", "fprintf", "(", "self", "::", "$", "yyTraceFILE", ",", "\"%sStack:\"", ",", "self", "::", "$", "yyTracePrompt", ")", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "this", "->", "yyidx", ";", "$", "i", "++", ")", "{", "fprintf", "(", "self", "::", "$", "yyTraceFILE", ",", "\" %s\"", ",", "self", "::", "tokenName", "(", "$", "this", "->", "yystack", "[", "$", "i", "]", "->", "major", ")", ")", ";", "}", "fwrite", "(", "self", "::", "$", "yyTraceFILE", ",", "\"\\n\"", ")", ";", "}", "}" ]
Perform a shift action. @param int The new state to shift in @param int The major token to shift in @param mixed the minor token to shift in
[ "Perform", "a", "shift", "action", "." ]
0dd272746cb16a420dfba8073e54312b0a7ccb1b
https://github.com/alxlit/coffeescript-php/blob/0dd272746cb16a420dfba8073e54312b0a7ccb1b/src/CoffeeScript/Parser.php#L2216-L2246
train
alxlit/coffeescript-php
src/CoffeeScript/Compiler.php
Compiler.compile
static function compile($code, $options = array()) { $lexer = new Lexer($code, $options); if (isset($options['filename'])) { Parser::$FILE = $options['filename']; } if (isset($options['tokens'])) { $tokens = & $options['tokens']; } if (isset($options['trace'])) { Parser::Trace(fopen($options['trace'], 'w', TRUE), '> '); } try { $parser = new Parser(); foreach (($tokens = $lexer->tokenize()) as $token) { $parser->parse($token); } $js = $parser->parse(NULL)->compile($options); } catch (\Exception $e) { throw new Error("In {$options['filename']}, ".$e->getMessage()); } if ( ! isset($options['header']) || $options['header']) { $js = '// Generated by CoffeeScript PHP ' . COFFEESCRIPT_VERSION . "\n" . $js; } return $js; }
php
static function compile($code, $options = array()) { $lexer = new Lexer($code, $options); if (isset($options['filename'])) { Parser::$FILE = $options['filename']; } if (isset($options['tokens'])) { $tokens = & $options['tokens']; } if (isset($options['trace'])) { Parser::Trace(fopen($options['trace'], 'w', TRUE), '> '); } try { $parser = new Parser(); foreach (($tokens = $lexer->tokenize()) as $token) { $parser->parse($token); } $js = $parser->parse(NULL)->compile($options); } catch (\Exception $e) { throw new Error("In {$options['filename']}, ".$e->getMessage()); } if ( ! isset($options['header']) || $options['header']) { $js = '// Generated by CoffeeScript PHP ' . COFFEESCRIPT_VERSION . "\n" . $js; } return $js; }
[ "static", "function", "compile", "(", "$", "code", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "lexer", "=", "new", "Lexer", "(", "$", "code", ",", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'filename'", "]", ")", ")", "{", "Parser", "::", "$", "FILE", "=", "$", "options", "[", "'filename'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'tokens'", "]", ")", ")", "{", "$", "tokens", "=", "&", "$", "options", "[", "'tokens'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'trace'", "]", ")", ")", "{", "Parser", "::", "Trace", "(", "fopen", "(", "$", "options", "[", "'trace'", "]", ",", "'w'", ",", "TRUE", ")", ",", "'> '", ")", ";", "}", "try", "{", "$", "parser", "=", "new", "Parser", "(", ")", ";", "foreach", "(", "(", "$", "tokens", "=", "$", "lexer", "->", "tokenize", "(", ")", ")", "as", "$", "token", ")", "{", "$", "parser", "->", "parse", "(", "$", "token", ")", ";", "}", "$", "js", "=", "$", "parser", "->", "parse", "(", "NULL", ")", "->", "compile", "(", "$", "options", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Error", "(", "\"In {$options['filename']}, \"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "'header'", "]", ")", "||", "$", "options", "[", "'header'", "]", ")", "{", "$", "js", "=", "'// Generated by CoffeeScript PHP '", ".", "COFFEESCRIPT_VERSION", ".", "\"\\n\"", ".", "$", "js", ";", "}", "return", "$", "js", ";", "}" ]
Compile some CoffeeScript. Available options: 'filename' => The source file, for debugging (formatted into error messages) 'header' => Add a header to the generated source (default: TRUE) 'rewrite' => Enable rewriting token stream (debugging) 'tokens' => Reference to token stream (debugging) 'trace' => File to write parser trace to (debugging) @param string The source CoffeeScript code @param array Options (see above) @return string The resulting JavaScript (if there were no errors)
[ "Compile", "some", "CoffeeScript", "." ]
0dd272746cb16a420dfba8073e54312b0a7ccb1b
https://github.com/alxlit/coffeescript-php/blob/0dd272746cb16a420dfba8073e54312b0a7ccb1b/src/CoffeeScript/Compiler.php#L31-L72
train
bakaphp/http
src/QueryParser.php
QueryParser.parseSubquery
protected function parseSubquery(string $unparsed): array { // Strip parens that come with the request string $tableName = explode("(", $unparsed, 2); //print_r($tableName);die(); $tableName = strtolower($tableName[0]); $modelName = str_replace('_', ' ', $tableName); $modelName = str_replace(' ', '', ucwords($modelName)); //Add the namespace to the model name $model = $this->config['namespace']['models'] . '\\' . $modelName; $unparsed = str_replace($tableName, '', $unparsed); $unparsed = trim($unparsed, '()'); // Now we have an array of "key:value" strings. $splitFields = explode(',', $unparsed); if (strpos($splitFields[0], '!::') !== false) { $action = 'not in'; $fieldsToRelate = explode('!::', $splitFields[0]); } elseif (strpos($splitFields[0], '::') !== false) { $action = 'in'; $fieldsToRelate = explode('::', $splitFields[0]); } else { throw new \Exception("Error Processing Subquery", 1); } $subquery = [ 'action' => $action, 'firstField' => $fieldsToRelate[0], 'secondField' => $fieldsToRelate[1], 'model' => $model, ]; return $subquery; }
php
protected function parseSubquery(string $unparsed): array { // Strip parens that come with the request string $tableName = explode("(", $unparsed, 2); //print_r($tableName);die(); $tableName = strtolower($tableName[0]); $modelName = str_replace('_', ' ', $tableName); $modelName = str_replace(' ', '', ucwords($modelName)); //Add the namespace to the model name $model = $this->config['namespace']['models'] . '\\' . $modelName; $unparsed = str_replace($tableName, '', $unparsed); $unparsed = trim($unparsed, '()'); // Now we have an array of "key:value" strings. $splitFields = explode(',', $unparsed); if (strpos($splitFields[0], '!::') !== false) { $action = 'not in'; $fieldsToRelate = explode('!::', $splitFields[0]); } elseif (strpos($splitFields[0], '::') !== false) { $action = 'in'; $fieldsToRelate = explode('::', $splitFields[0]); } else { throw new \Exception("Error Processing Subquery", 1); } $subquery = [ 'action' => $action, 'firstField' => $fieldsToRelate[0], 'secondField' => $fieldsToRelate[1], 'model' => $model, ]; return $subquery; }
[ "protected", "function", "parseSubquery", "(", "string", "$", "unparsed", ")", ":", "array", "{", "// Strip parens that come with the request string", "$", "tableName", "=", "explode", "(", "\"(\"", ",", "$", "unparsed", ",", "2", ")", ";", "//print_r($tableName);die();", "$", "tableName", "=", "strtolower", "(", "$", "tableName", "[", "0", "]", ")", ";", "$", "modelName", "=", "str_replace", "(", "'_'", ",", "' '", ",", "$", "tableName", ")", ";", "$", "modelName", "=", "str_replace", "(", "' '", ",", "''", ",", "ucwords", "(", "$", "modelName", ")", ")", ";", "//Add the namespace to the model name", "$", "model", "=", "$", "this", "->", "config", "[", "'namespace'", "]", "[", "'models'", "]", ".", "'\\\\'", ".", "$", "modelName", ";", "$", "unparsed", "=", "str_replace", "(", "$", "tableName", ",", "''", ",", "$", "unparsed", ")", ";", "$", "unparsed", "=", "trim", "(", "$", "unparsed", ",", "'()'", ")", ";", "// Now we have an array of \"key:value\" strings.", "$", "splitFields", "=", "explode", "(", "','", ",", "$", "unparsed", ")", ";", "if", "(", "strpos", "(", "$", "splitFields", "[", "0", "]", ",", "'!::'", ")", "!==", "false", ")", "{", "$", "action", "=", "'not in'", ";", "$", "fieldsToRelate", "=", "explode", "(", "'!::'", ",", "$", "splitFields", "[", "0", "]", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "splitFields", "[", "0", "]", ",", "'::'", ")", "!==", "false", ")", "{", "$", "action", "=", "'in'", ";", "$", "fieldsToRelate", "=", "explode", "(", "'::'", ",", "$", "splitFields", "[", "0", "]", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "\"Error Processing Subquery\"", ",", "1", ")", ";", "}", "$", "subquery", "=", "[", "'action'", "=>", "$", "action", ",", "'firstField'", "=>", "$", "fieldsToRelate", "[", "0", "]", ",", "'secondField'", "=>", "$", "fieldsToRelate", "[", "1", "]", ",", "'model'", "=>", "$", "model", ",", "]", ";", "return", "$", "subquery", ";", "}" ]
Parses out the subquery parameters from a request. in = ::, not in = !:: Unparsed, they will look like this: internet_special(id::vehicles_id) Parsed: Array('action' => in, 'firstField' => id, 'secondField' => vehicles_id,'model' => MyDealer\Models\InternetSpecial) * @param string $unparsed Unparsed search string @return array An array of fieldname=>value search parameters
[ "Parses", "out", "the", "subquery", "parameters", "from", "a", "request", "." ]
e99d7e1408066c4b30450455c32adb810ce41e49
https://github.com/bakaphp/http/blob/e99d7e1408066c4b30450455c32adb810ce41e49/src/QueryParser.php#L145-L182
train
bakaphp/http
src/QueryParser.php
QueryParser.prepareSearch
protected function prepareSearch(array $unparsed, bool $isSearch = false, $hasSubquery = false): array { $statement = [ 'conditions' => "1 = 1", 'bind' => [], ]; if ($isSearch) { $mapped = $this->parseSearchParameters($unparsed['params']); $conditions = '1 = 1'; $tmpMapped = $mapped; foreach ($tmpMapped as $key => $value) { if (strpos($value, '~') !== false) { unset($tmpMapped[$key]); $betweenMap[$key] = explode('~', $value); } } $keys = array_keys($tmpMapped); $values = array_values($tmpMapped); $di = Di::getDefault(); foreach ($keys as $key => $field) { if ($di->get('config')->database->adapter == 'Postgresql') { $conditions .= " AND CAST({$field} AS TEXT) LIKE ?{$key}"; } else { $conditions .= " AND {$field} LIKE ?{$key}"; } } if (isset($betweenMap)) { foreach ($betweenMap as $key => $fields) { $binds = count($values); $conditions .= ' AND ' . $key . ' BETWEEN ?' . $binds . ' AND ?' . ($binds + 1); $values = array_merge($values, $fields); } } if ($hasSubquery) { $subquery = $this->parseSubquery($unparsed['subquery']); $conditions .= ' AND ' . $subquery['firstField'] . ' ' . $subquery['action'] . ' (select ' . $subquery['secondField'] . ' FROM ' . $subquery['model'] . ')'; } $statement = [ 'conditions' => $conditions, 'bind' => $values, ]; } return $statement; }
php
protected function prepareSearch(array $unparsed, bool $isSearch = false, $hasSubquery = false): array { $statement = [ 'conditions' => "1 = 1", 'bind' => [], ]; if ($isSearch) { $mapped = $this->parseSearchParameters($unparsed['params']); $conditions = '1 = 1'; $tmpMapped = $mapped; foreach ($tmpMapped as $key => $value) { if (strpos($value, '~') !== false) { unset($tmpMapped[$key]); $betweenMap[$key] = explode('~', $value); } } $keys = array_keys($tmpMapped); $values = array_values($tmpMapped); $di = Di::getDefault(); foreach ($keys as $key => $field) { if ($di->get('config')->database->adapter == 'Postgresql') { $conditions .= " AND CAST({$field} AS TEXT) LIKE ?{$key}"; } else { $conditions .= " AND {$field} LIKE ?{$key}"; } } if (isset($betweenMap)) { foreach ($betweenMap as $key => $fields) { $binds = count($values); $conditions .= ' AND ' . $key . ' BETWEEN ?' . $binds . ' AND ?' . ($binds + 1); $values = array_merge($values, $fields); } } if ($hasSubquery) { $subquery = $this->parseSubquery($unparsed['subquery']); $conditions .= ' AND ' . $subquery['firstField'] . ' ' . $subquery['action'] . ' (select ' . $subquery['secondField'] . ' FROM ' . $subquery['model'] . ')'; } $statement = [ 'conditions' => $conditions, 'bind' => $values, ]; } return $statement; }
[ "protected", "function", "prepareSearch", "(", "array", "$", "unparsed", ",", "bool", "$", "isSearch", "=", "false", ",", "$", "hasSubquery", "=", "false", ")", ":", "array", "{", "$", "statement", "=", "[", "'conditions'", "=>", "\"1 = 1\"", ",", "'bind'", "=>", "[", "]", ",", "]", ";", "if", "(", "$", "isSearch", ")", "{", "$", "mapped", "=", "$", "this", "->", "parseSearchParameters", "(", "$", "unparsed", "[", "'params'", "]", ")", ";", "$", "conditions", "=", "'1 = 1'", ";", "$", "tmpMapped", "=", "$", "mapped", ";", "foreach", "(", "$", "tmpMapped", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "value", ",", "'~'", ")", "!==", "false", ")", "{", "unset", "(", "$", "tmpMapped", "[", "$", "key", "]", ")", ";", "$", "betweenMap", "[", "$", "key", "]", "=", "explode", "(", "'~'", ",", "$", "value", ")", ";", "}", "}", "$", "keys", "=", "array_keys", "(", "$", "tmpMapped", ")", ";", "$", "values", "=", "array_values", "(", "$", "tmpMapped", ")", ";", "$", "di", "=", "Di", "::", "getDefault", "(", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", "=>", "$", "field", ")", "{", "if", "(", "$", "di", "->", "get", "(", "'config'", ")", "->", "database", "->", "adapter", "==", "'Postgresql'", ")", "{", "$", "conditions", ".=", "\" AND CAST({$field} AS TEXT) LIKE ?{$key}\"", ";", "}", "else", "{", "$", "conditions", ".=", "\" AND {$field} LIKE ?{$key}\"", ";", "}", "}", "if", "(", "isset", "(", "$", "betweenMap", ")", ")", "{", "foreach", "(", "$", "betweenMap", "as", "$", "key", "=>", "$", "fields", ")", "{", "$", "binds", "=", "count", "(", "$", "values", ")", ";", "$", "conditions", ".=", "' AND '", ".", "$", "key", ".", "' BETWEEN ?'", ".", "$", "binds", ".", "' AND ?'", ".", "(", "$", "binds", "+", "1", ")", ";", "$", "values", "=", "array_merge", "(", "$", "values", ",", "$", "fields", ")", ";", "}", "}", "if", "(", "$", "hasSubquery", ")", "{", "$", "subquery", "=", "$", "this", "->", "parseSubquery", "(", "$", "unparsed", "[", "'subquery'", "]", ")", ";", "$", "conditions", ".=", "' AND '", ".", "$", "subquery", "[", "'firstField'", "]", ".", "' '", ".", "$", "subquery", "[", "'action'", "]", ".", "' (select '", ".", "$", "subquery", "[", "'secondField'", "]", ".", "' FROM '", ".", "$", "subquery", "[", "'model'", "]", ".", "')'", ";", "}", "$", "statement", "=", "[", "'conditions'", "=>", "$", "conditions", ",", "'bind'", "=>", "$", "values", ",", "]", ";", "}", "return", "$", "statement", ";", "}" ]
Prepare conditions to search in record @param string $unparsed @return array
[ "Prepare", "conditions", "to", "search", "in", "record" ]
e99d7e1408066c4b30450455c32adb810ce41e49
https://github.com/bakaphp/http/blob/e99d7e1408066c4b30450455c32adb810ce41e49/src/QueryParser.php#L190-L244
train