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
QoboLtd/cakephp-search
src/Utility/Search.php
Search.byAssociations
protected function byAssociations(array $data): array { $result = []; foreach ($this->getAssociationsBySearchData($data) as $association) { // skip non-supported associations if (!in_array($association->type(), Options::getSearchableAssociations())) { continue; } $targetTable = $association->getTarget(); // skip associations with itself if ($targetTable->getTable() === $this->table->getTable()) { continue; } $primaryKeys = []; foreach ((array)$targetTable->getPrimaryKey() as $primaryKey) { $primaryKeys[] = $targetTable->aliasField($primaryKey); } // instantiate Search on related table $search = new Search($targetTable, $this->user); $select = array_diff($search->getSelectClause($data), $primaryKeys); if (!empty($select)) { $result[$association->getName()]['select'] = $select; } $where = $search->getWhereClause($data); if (!empty($where)) { $result[$association->getName()]['where'] = $where; } } return $result; }
php
protected function byAssociations(array $data): array { $result = []; foreach ($this->getAssociationsBySearchData($data) as $association) { // skip non-supported associations if (!in_array($association->type(), Options::getSearchableAssociations())) { continue; } $targetTable = $association->getTarget(); // skip associations with itself if ($targetTable->getTable() === $this->table->getTable()) { continue; } $primaryKeys = []; foreach ((array)$targetTable->getPrimaryKey() as $primaryKey) { $primaryKeys[] = $targetTable->aliasField($primaryKey); } // instantiate Search on related table $search = new Search($targetTable, $this->user); $select = array_diff($search->getSelectClause($data), $primaryKeys); if (!empty($select)) { $result[$association->getName()]['select'] = $select; } $where = $search->getWhereClause($data); if (!empty($where)) { $result[$association->getName()]['where'] = $where; } } return $result; }
[ "protected", "function", "byAssociations", "(", "array", "$", "data", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getAssociationsBySearchData", "(", "$", "data", ")", "as", "$", "association", ")", "{", ...
Search by current Table associations. @param mixed[] $data Search data @return mixed[]
[ "Search", "by", "current", "Table", "associations", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L240-L276
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.getAssociationsBySearchData
private function getAssociationsBySearchData(array $data) : array { $fields = []; if (array_key_exists('criteria', $data)) { foreach (array_keys($data['criteria']) as $field) { $field = $this->table->aliasField((string)$field); if (! in_array($field, $fields)) { $fields[] = $field; } } } if (array_key_exists('display_columns', $data)) { foreach ($data['display_columns'] as $field) { if (is_string($field) && ! in_array($field, $fields)) { $fields[] = $field; } } } $result = []; foreach ($fields as $field) { list($name) = explode('.', $this->table->aliasField($field), 2); if ($name === $this->table->getAlias()) { continue; } if (! $this->table->hasAssociation($name)) { throw new \RuntimeException(sprintf('Table "%s" does not have association "%s"', $this->table->getAlias(), $name)); } $association = $this->table->getAssociation($name); if (array_key_exists($association->getName(), $result)) { continue; } $result[$association->getName()] = $association; } return $result; }
php
private function getAssociationsBySearchData(array $data) : array { $fields = []; if (array_key_exists('criteria', $data)) { foreach (array_keys($data['criteria']) as $field) { $field = $this->table->aliasField((string)$field); if (! in_array($field, $fields)) { $fields[] = $field; } } } if (array_key_exists('display_columns', $data)) { foreach ($data['display_columns'] as $field) { if (is_string($field) && ! in_array($field, $fields)) { $fields[] = $field; } } } $result = []; foreach ($fields as $field) { list($name) = explode('.', $this->table->aliasField($field), 2); if ($name === $this->table->getAlias()) { continue; } if (! $this->table->hasAssociation($name)) { throw new \RuntimeException(sprintf('Table "%s" does not have association "%s"', $this->table->getAlias(), $name)); } $association = $this->table->getAssociation($name); if (array_key_exists($association->getName(), $result)) { continue; } $result[$association->getName()] = $association; } return $result; }
[ "private", "function", "getAssociationsBySearchData", "(", "array", "$", "data", ")", ":", "array", "{", "$", "fields", "=", "[", "]", ";", "if", "(", "array_key_exists", "(", "'criteria'", ",", "$", "data", ")", ")", "{", "foreach", "(", "array_keys", "...
Retrieves search-required associations based on the provided search data. @param mixed[] $data Search data @return mixed[]
[ "Retrieves", "search", "-", "required", "associations", "based", "on", "the", "provided", "search", "data", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L284-L326
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.getWhereClause
protected function getWhereClause(array $data): array { $result = []; if (empty($data['criteria'])) { return $result; } // get current module searchable fields. $moduleFields = $this->filterFields(array_keys($this->searchFields)); foreach ($data['criteria'] as $fieldName => $criterias) { if (empty($criterias)) { continue; } $fieldName = $this->table->aliasField($fieldName); if (!in_array($fieldName, $moduleFields)) { continue; } foreach ($criterias as $criteria) { $condition = $this->getWhereCondition($fieldName, $criteria); if (empty($condition)) { continue; } $result[] = $condition; } } return $result; }
php
protected function getWhereClause(array $data): array { $result = []; if (empty($data['criteria'])) { return $result; } // get current module searchable fields. $moduleFields = $this->filterFields(array_keys($this->searchFields)); foreach ($data['criteria'] as $fieldName => $criterias) { if (empty($criterias)) { continue; } $fieldName = $this->table->aliasField($fieldName); if (!in_array($fieldName, $moduleFields)) { continue; } foreach ($criterias as $criteria) { $condition = $this->getWhereCondition($fieldName, $criteria); if (empty($condition)) { continue; } $result[] = $condition; } } return $result; }
[ "protected", "function", "getWhereClause", "(", "array", "$", "data", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "data", "[", "'criteria'", "]", ")", ")", "{", "return", "$", "result", ";", "}", "// get...
Prepare search query's where statement @param mixed[] $data request data @return mixed[]
[ "Prepare", "search", "query", "s", "where", "statement" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L334-L366
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.filterFields
protected function filterFields(array $fields): array { if (empty($fields)) { return []; } foreach ($fields as $k => $v) { if (false !== strpos($v, $this->table->getAlias() . '.')) { continue; } unset($fields[$k]); } return $fields; }
php
protected function filterFields(array $fields): array { if (empty($fields)) { return []; } foreach ($fields as $k => $v) { if (false !== strpos($v, $this->table->getAlias() . '.')) { continue; } unset($fields[$k]); } return $fields; }
[ "protected", "function", "filterFields", "(", "array", "$", "fields", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "fields", ")", ")", "{", "return", "[", "]", ";", "}", "foreach", "(", "$", "fields", "as", "$", "k", "=>", "$", "v", ")",...
Filter only current module fields. @param mixed[] $fields Search fields @return mixed[]
[ "Filter", "only", "current", "module", "fields", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L374-L389
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.getWhereCondition
protected function getWhereCondition(string $field, array $criteria): array { $value = is_array($criteria['value']) ? $criteria['value'] : trim($criteria['value']); if ('' === $value) { return $this->getEmptyWhereCondition($field, $criteria); } $value = $this->handleMagicValue($value); $operator = $this->searchFields[$field]['operators'][$criteria['operator']]; if (isset($operator['pattern'])) { $pattern = $operator['pattern']; $value = str_replace('{{value}}', $value, $pattern); } $type = 'string'; if (! empty($this->searchFields[$field]['type']) && array_key_exists($this->searchFields[$field]['type'], (array)Type::getMap()) ) { $type = $this->searchFields[$field]['type']; } if (in_array($operator['operator'], ['IN', 'NOT IN'])) { $type .= '[]'; $value = (array)$value; } if ($operator['operator'] === 'NOT IN') { return [ 'OR' => [ $field . ' IS NULL', new Comparison(new IdentifierExpression($field), $value, $type, $operator['operator']) ]]; } return [ new Comparison(new IdentifierExpression($field), $value, $type, $operator['operator']) ]; }
php
protected function getWhereCondition(string $field, array $criteria): array { $value = is_array($criteria['value']) ? $criteria['value'] : trim($criteria['value']); if ('' === $value) { return $this->getEmptyWhereCondition($field, $criteria); } $value = $this->handleMagicValue($value); $operator = $this->searchFields[$field]['operators'][$criteria['operator']]; if (isset($operator['pattern'])) { $pattern = $operator['pattern']; $value = str_replace('{{value}}', $value, $pattern); } $type = 'string'; if (! empty($this->searchFields[$field]['type']) && array_key_exists($this->searchFields[$field]['type'], (array)Type::getMap()) ) { $type = $this->searchFields[$field]['type']; } if (in_array($operator['operator'], ['IN', 'NOT IN'])) { $type .= '[]'; $value = (array)$value; } if ($operator['operator'] === 'NOT IN') { return [ 'OR' => [ $field . ' IS NULL', new Comparison(new IdentifierExpression($field), $value, $type, $operator['operator']) ]]; } return [ new Comparison(new IdentifierExpression($field), $value, $type, $operator['operator']) ]; }
[ "protected", "function", "getWhereCondition", "(", "string", "$", "field", ",", "array", "$", "criteria", ")", ":", "array", "{", "$", "value", "=", "is_array", "(", "$", "criteria", "[", "'value'", "]", ")", "?", "$", "criteria", "[", "'value'", "]", ...
Prepare and return where statement condition. @param string $field Field name @param mixed[] $criteria Criteria properties @return mixed[]
[ "Prepare", "and", "return", "where", "statement", "condition", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L398-L431
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.handleMagicValue
protected function handleMagicValue($value) { switch (gettype($value)) { case 'string': $value = (new MagicValue($value, $this->user))->get(); break; case 'array': foreach ($value as $key => $val) { $value[$key] = (new MagicValue($val, $this->user))->get(); } break; } return $value; }
php
protected function handleMagicValue($value) { switch (gettype($value)) { case 'string': $value = (new MagicValue($value, $this->user))->get(); break; case 'array': foreach ($value as $key => $val) { $value[$key] = (new MagicValue($val, $this->user))->get(); } break; } return $value; }
[ "protected", "function", "handleMagicValue", "(", "$", "value", ")", "{", "switch", "(", "gettype", "(", "$", "value", ")", ")", "{", "case", "'string'", ":", "$", "value", "=", "(", "new", "MagicValue", "(", "$", "value", ",", "$", "this", "->", "us...
Magic value handler. @param mixed $value Field value @return mixed
[ "Magic", "value", "handler", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L439-L454
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.getEmptyWhereCondition
protected function getEmptyWhereCondition(string $field, array $criteria): array { $emptyCriteria = $this->searchFields[$field]['operators'][$criteria['operator']]['emptyCriteria']; $result = []; foreach ($emptyCriteria['values'] as $value) { $result[$emptyCriteria['aggregator']][] = $field . ' ' . trim($value); } return $result; }
php
protected function getEmptyWhereCondition(string $field, array $criteria): array { $emptyCriteria = $this->searchFields[$field]['operators'][$criteria['operator']]['emptyCriteria']; $result = []; foreach ($emptyCriteria['values'] as $value) { $result[$emptyCriteria['aggregator']][] = $field . ' ' . trim($value); } return $result; }
[ "protected", "function", "getEmptyWhereCondition", "(", "string", "$", "field", ",", "array", "$", "criteria", ")", ":", "array", "{", "$", "emptyCriteria", "=", "$", "this", "->", "searchFields", "[", "$", "field", "]", "[", "'operators'", "]", "[", "$", ...
Prepare and return where statement condition for empty value. @param string $field Field name @param mixed[] $criteria Criteria properties @return mixed[]
[ "Prepare", "and", "return", "where", "statement", "condition", "for", "empty", "value", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L463-L473
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.getSelectClause
public function getSelectClause(array $data): array { if (empty($data['display_columns'])) { return []; } $result = (array)$data['display_columns']; foreach ((array)$this->table->getPrimaryKey() as $primaryKey) { $primaryKey = $this->table->aliasField($primaryKey); if (! in_array($primaryKey, $result)) { array_unshift($result, $primaryKey); } } $result = $this->filterFields($result); return $result; }
php
public function getSelectClause(array $data): array { if (empty($data['display_columns'])) { return []; } $result = (array)$data['display_columns']; foreach ((array)$this->table->getPrimaryKey() as $primaryKey) { $primaryKey = $this->table->aliasField($primaryKey); if (! in_array($primaryKey, $result)) { array_unshift($result, $primaryKey); } } $result = $this->filterFields($result); return $result; }
[ "public", "function", "getSelectClause", "(", "array", "$", "data", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "data", "[", "'display_columns'", "]", ")", ")", "{", "return", "[", "]", ";", "}", "$", "result", "=", "(", "array", ")", "$"...
Get fields for Query's select statement. @param mixed[] $data request data @return string[]
[ "Get", "fields", "for", "Query", "s", "select", "statement", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L481-L498
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.preSave
protected function preSave(array $data): string { /** * @var \Search\Model\Entity\SavedSearch */ $entity = $this->searchTable->newEntity(); $entity = $this->normalize($entity, $data, $data); $this->searchTable->save($entity); return $entity->id; }
php
protected function preSave(array $data): string { /** * @var \Search\Model\Entity\SavedSearch */ $entity = $this->searchTable->newEntity(); $entity = $this->normalize($entity, $data, $data); $this->searchTable->save($entity); return $entity->id; }
[ "protected", "function", "preSave", "(", "array", "$", "data", ")", ":", "string", "{", "/**\n * @var \\Search\\Model\\Entity\\SavedSearch\n */", "$", "entity", "=", "$", "this", "->", "searchTable", "->", "newEntity", "(", ")", ";", "$", "entity", ...
Method that pre-saves search and returns saved record id. @param mixed[] $data Search data @return string
[ "Method", "that", "pre", "-", "saves", "search", "and", "returns", "saved", "record", "id", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L517-L528
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.normalize
protected function normalize(SavedSearch $entity, array $saved, array $latest) : SavedSearch { // Backward compatibility: search content must always contain 'saved' and 'latest' keys. $saved = isset($saved['saved']) ? $saved['saved'] : $saved; $latest = isset($latest['latest']) ? $latest['latest'] : (isset($latest['saved']) ? $latest['saved'] : $latest); // Backward compatibility: always prefix search criteria, display columns and sort by fields with table name. $filterFunc = function ($data) { if (array_key_exists('criteria', $data)) { foreach ($data['criteria'] as $field => $option) { unset($data['criteria'][$field]); $data['criteria'][$this->table->aliasField($field)] = $option; } } if (array_key_exists('display_columns', $data)) { $data['display_columns'] = array_values($data['display_columns']); foreach ($data['display_columns'] as &$field) { $field = $this->table->aliasField($field); } } if (array_key_exists('sort_by_field', $data)) { $data['sort_by_field'] = $this->table->aliasField($data['sort_by_field']); } return $data; }; $saved = $filterFunc($saved); $latest = $filterFunc($latest); $entity->set('user_id', $this->user['id']); $entity->set('model', $this->table->getRegistryAlias()); $entity->set('content', ['saved' => $saved, 'latest' => $latest]); return $entity; }
php
protected function normalize(SavedSearch $entity, array $saved, array $latest) : SavedSearch { // Backward compatibility: search content must always contain 'saved' and 'latest' keys. $saved = isset($saved['saved']) ? $saved['saved'] : $saved; $latest = isset($latest['latest']) ? $latest['latest'] : (isset($latest['saved']) ? $latest['saved'] : $latest); // Backward compatibility: always prefix search criteria, display columns and sort by fields with table name. $filterFunc = function ($data) { if (array_key_exists('criteria', $data)) { foreach ($data['criteria'] as $field => $option) { unset($data['criteria'][$field]); $data['criteria'][$this->table->aliasField($field)] = $option; } } if (array_key_exists('display_columns', $data)) { $data['display_columns'] = array_values($data['display_columns']); foreach ($data['display_columns'] as &$field) { $field = $this->table->aliasField($field); } } if (array_key_exists('sort_by_field', $data)) { $data['sort_by_field'] = $this->table->aliasField($data['sort_by_field']); } return $data; }; $saved = $filterFunc($saved); $latest = $filterFunc($latest); $entity->set('user_id', $this->user['id']); $entity->set('model', $this->table->getRegistryAlias()); $entity->set('content', ['saved' => $saved, 'latest' => $latest]); return $entity; }
[ "protected", "function", "normalize", "(", "SavedSearch", "$", "entity", ",", "array", "$", "saved", ",", "array", "$", "latest", ")", ":", "SavedSearch", "{", "// Backward compatibility: search content must always contain 'saved' and 'latest' keys.", "$", "saved", "=", ...
Normalize search. @param \Search\Model\Entity\SavedSearch $entity Search entity @param mixed[] $saved Saved search data @param mixed[] $latest Latest search data @return \Search\Model\Entity\SavedSearch
[ "Normalize", "search", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L538-L577
train
TYPO3-CMS/redirects
Classes/Hooks/DataHandlerCacheFlushingHook.php
DataHandlerCacheFlushingHook.rebuildRedirectCacheIfNecessary
public function rebuildRedirectCacheIfNecessary(array $parameters, DataHandler $dataHandler) { if (isset($dataHandler->datamap['sys_redirect']) || isset($dataHandler->cmdmap['sys_redirect'])) { GeneralUtility::makeInstance(RedirectCacheService::class)->rebuild(); } }
php
public function rebuildRedirectCacheIfNecessary(array $parameters, DataHandler $dataHandler) { if (isset($dataHandler->datamap['sys_redirect']) || isset($dataHandler->cmdmap['sys_redirect'])) { GeneralUtility::makeInstance(RedirectCacheService::class)->rebuild(); } }
[ "public", "function", "rebuildRedirectCacheIfNecessary", "(", "array", "$", "parameters", ",", "DataHandler", "$", "dataHandler", ")", "{", "if", "(", "isset", "(", "$", "dataHandler", "->", "datamap", "[", "'sys_redirect'", "]", ")", "||", "isset", "(", "$", ...
Check if the data handler processed a sys_redirect record, if so, rebuild the redirect index cache @param array $parameters unused @param DataHandler $dataHandler the data handler object
[ "Check", "if", "the", "data", "handler", "processed", "a", "sys_redirect", "record", "if", "so", "rebuild", "the", "redirect", "index", "cache" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Hooks/DataHandlerCacheFlushingHook.php#L34-L39
train
mitchdav/st-george-ipg
src/Request.php
Request.createFromClient
public static function createFromClient(Client $client, $includeTerminalType = TRUE) { $request = new Request(); $request->setInterface($client->getInterface()); if ($includeTerminalType) { $request->setTerminalType($client->getTerminalType()); } return $request; }
php
public static function createFromClient(Client $client, $includeTerminalType = TRUE) { $request = new Request(); $request->setInterface($client->getInterface()); if ($includeTerminalType) { $request->setTerminalType($client->getTerminalType()); } return $request; }
[ "public", "static", "function", "createFromClient", "(", "Client", "$", "client", ",", "$", "includeTerminalType", "=", "TRUE", ")", "{", "$", "request", "=", "new", "Request", "(", ")", ";", "$", "request", "->", "setInterface", "(", "$", "client", "->", ...
Creates the request using information from the client. @param \StGeorgeIPG\Client $client @param boolean $includeTerminalType @return \StGeorgeIPG\Request
[ "Creates", "the", "request", "using", "information", "from", "the", "client", "." ]
2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc
https://github.com/mitchdav/st-george-ipg/blob/2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc/src/Request.php#L195-L206
train
mitchdav/st-george-ipg
src/Request.php
Request.validate
public function validate() { $this->validateAttributes([ Request::ATTRIBUTE_INTERFACE, Request::ATTRIBUTE_TRANSACTION_TYPE, ]); $transactionType = $this->getTransactionType(); switch ($transactionType) { case Request::TRANSACTION_TYPE_PURCHASE: case Request::TRANSACTION_TYPE_PRE_AUTH: { $this->validateAttributes([ Request::ATTRIBUTE_TOTAL_AMOUNT, Request::ATTRIBUTE_CARD_DATA, Request::ATTRIBUTE_CARD_EXPIRY_DATE, ], [ Request::ATTRIBUTE_TRANSACTION_REFERENCE, Request::ATTRIBUTE_ORIGINAL_TRANSACTION_REFERENCE, Request::ATTRIBUTE_PRE_AUTH_NUMBER, Request::ATTRIBUTE_AUTH_NUMBER, Request::ATTRIBUTE_AUTHORISATION_CODE, Request::ATTRIBUTE_AUTHORISATION_NUMBER, ]); break; } case Request::TRANSACTION_TYPE_REFUND: { $this->validateAttributes([ Request::ATTRIBUTE_TOTAL_AMOUNT, Request::ATTRIBUTE_ORIGINAL_TRANSACTION_REFERENCE, ], [ Request::ATTRIBUTE_CARD_DATA, Request::ATTRIBUTE_CARD_EXPIRY_DATE, Request::ATTRIBUTE_TRANSACTION_REFERENCE, Request::ATTRIBUTE_PRE_AUTH_NUMBER, Request::ATTRIBUTE_AUTH_NUMBER, Request::ATTRIBUTE_AUTHORISATION_CODE, Request::ATTRIBUTE_AUTHORISATION_NUMBER, ]); break; } case Request::TRANSACTION_TYPE_COMPLETION: { $this->validateAttributes([ Request::ATTRIBUTE_TOTAL_AMOUNT, [ Request::ATTRIBUTE_ORIGINAL_TRANSACTION_REFERENCE, Request::ATTRIBUTE_PRE_AUTH_NUMBER, ], [ Request::ATTRIBUTE_AUTH_CODE, Request::ATTRIBUTE_AUTH_NUMBER, Request::ATTRIBUTE_AUTHORISATION_CODE, Request::ATTRIBUTE_AUTHORISATION_NUMBER, ], ], [ Request::ATTRIBUTE_CARD_DATA, Request::ATTRIBUTE_CARD_EXPIRY_DATE, Request::ATTRIBUTE_TRANSACTION_REFERENCE, ]); break; } case Request::TRANSACTION_TYPE_STATUS: { $this->validateAttributes([ Request::ATTRIBUTE_TRANSACTION_REFERENCE, ], [ Request::ATTRIBUTE_TOTAL_AMOUNT, Request::ATTRIBUTE_TAX_AMOUNT, Request::ATTRIBUTE_CARD_DATA, Request::ATTRIBUTE_CARD_EXPIRY_DATE, Request::ATTRIBUTE_ORIGINAL_TRANSACTION_REFERENCE, Request::ATTRIBUTE_PRE_AUTH_NUMBER, Request::ATTRIBUTE_AUTH_CODE, Request::ATTRIBUTE_AUTH_NUMBER, Request::ATTRIBUTE_AUTHORISATION_CODE, Request::ATTRIBUTE_AUTHORISATION_NUMBER, Request::ATTRIBUTE_CLIENT_REFERENCE, Request::ATTRIBUTE_COMMENT, Request::ATTRIBUTE_MERCHANT_CARD_HOLDER_NAME, Request::ATTRIBUTE_MERCHANT_DESCRIPTION, Request::ATTRIBUTE_TERMINAL_TYPE, Request::ATTRIBUTE_CVC2, ]); break; } } return TRUE; }
php
public function validate() { $this->validateAttributes([ Request::ATTRIBUTE_INTERFACE, Request::ATTRIBUTE_TRANSACTION_TYPE, ]); $transactionType = $this->getTransactionType(); switch ($transactionType) { case Request::TRANSACTION_TYPE_PURCHASE: case Request::TRANSACTION_TYPE_PRE_AUTH: { $this->validateAttributes([ Request::ATTRIBUTE_TOTAL_AMOUNT, Request::ATTRIBUTE_CARD_DATA, Request::ATTRIBUTE_CARD_EXPIRY_DATE, ], [ Request::ATTRIBUTE_TRANSACTION_REFERENCE, Request::ATTRIBUTE_ORIGINAL_TRANSACTION_REFERENCE, Request::ATTRIBUTE_PRE_AUTH_NUMBER, Request::ATTRIBUTE_AUTH_NUMBER, Request::ATTRIBUTE_AUTHORISATION_CODE, Request::ATTRIBUTE_AUTHORISATION_NUMBER, ]); break; } case Request::TRANSACTION_TYPE_REFUND: { $this->validateAttributes([ Request::ATTRIBUTE_TOTAL_AMOUNT, Request::ATTRIBUTE_ORIGINAL_TRANSACTION_REFERENCE, ], [ Request::ATTRIBUTE_CARD_DATA, Request::ATTRIBUTE_CARD_EXPIRY_DATE, Request::ATTRIBUTE_TRANSACTION_REFERENCE, Request::ATTRIBUTE_PRE_AUTH_NUMBER, Request::ATTRIBUTE_AUTH_NUMBER, Request::ATTRIBUTE_AUTHORISATION_CODE, Request::ATTRIBUTE_AUTHORISATION_NUMBER, ]); break; } case Request::TRANSACTION_TYPE_COMPLETION: { $this->validateAttributes([ Request::ATTRIBUTE_TOTAL_AMOUNT, [ Request::ATTRIBUTE_ORIGINAL_TRANSACTION_REFERENCE, Request::ATTRIBUTE_PRE_AUTH_NUMBER, ], [ Request::ATTRIBUTE_AUTH_CODE, Request::ATTRIBUTE_AUTH_NUMBER, Request::ATTRIBUTE_AUTHORISATION_CODE, Request::ATTRIBUTE_AUTHORISATION_NUMBER, ], ], [ Request::ATTRIBUTE_CARD_DATA, Request::ATTRIBUTE_CARD_EXPIRY_DATE, Request::ATTRIBUTE_TRANSACTION_REFERENCE, ]); break; } case Request::TRANSACTION_TYPE_STATUS: { $this->validateAttributes([ Request::ATTRIBUTE_TRANSACTION_REFERENCE, ], [ Request::ATTRIBUTE_TOTAL_AMOUNT, Request::ATTRIBUTE_TAX_AMOUNT, Request::ATTRIBUTE_CARD_DATA, Request::ATTRIBUTE_CARD_EXPIRY_DATE, Request::ATTRIBUTE_ORIGINAL_TRANSACTION_REFERENCE, Request::ATTRIBUTE_PRE_AUTH_NUMBER, Request::ATTRIBUTE_AUTH_CODE, Request::ATTRIBUTE_AUTH_NUMBER, Request::ATTRIBUTE_AUTHORISATION_CODE, Request::ATTRIBUTE_AUTHORISATION_NUMBER, Request::ATTRIBUTE_CLIENT_REFERENCE, Request::ATTRIBUTE_COMMENT, Request::ATTRIBUTE_MERCHANT_CARD_HOLDER_NAME, Request::ATTRIBUTE_MERCHANT_DESCRIPTION, Request::ATTRIBUTE_TERMINAL_TYPE, Request::ATTRIBUTE_CVC2, ]); break; } } return TRUE; }
[ "public", "function", "validate", "(", ")", "{", "$", "this", "->", "validateAttributes", "(", "[", "Request", "::", "ATTRIBUTE_INTERFACE", ",", "Request", "::", "ATTRIBUTE_TRANSACTION_TYPE", ",", "]", ")", ";", "$", "transactionType", "=", "$", "this", "->", ...
Validates the request attributes based on the transaction type, and the rules specified by St.George. @return boolean @throws \StGeorgeIPG\Exceptions\InvalidAttributeValueException
[ "Validates", "the", "request", "attributes", "based", "on", "the", "transaction", "type", "and", "the", "rules", "specified", "by", "St", ".", "George", "." ]
2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc
https://github.com/mitchdav/st-george-ipg/blob/2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc/src/Request.php#L502-L596
train
TYPO3-CMS/redirects
Classes/Repository/RedirectRepository.php
RedirectRepository.findRedirectsByDemand
public function findRedirectsByDemand(): array { return $this->getQueryBuilderForDemand() ->setMaxResults($this->demand->getLimit()) ->setFirstResult($this->demand->getOffset()) ->execute() ->fetchAll(); }
php
public function findRedirectsByDemand(): array { return $this->getQueryBuilderForDemand() ->setMaxResults($this->demand->getLimit()) ->setFirstResult($this->demand->getOffset()) ->execute() ->fetchAll(); }
[ "public", "function", "findRedirectsByDemand", "(", ")", ":", "array", "{", "return", "$", "this", "->", "getQueryBuilderForDemand", "(", ")", "->", "setMaxResults", "(", "$", "this", "->", "demand", "->", "getLimit", "(", ")", ")", "->", "setFirstResult", "...
Used within the backend module, which also includes the hidden records, but never deleted records. @return array
[ "Used", "within", "the", "backend", "module", "which", "also", "includes", "the", "hidden", "records", "but", "never", "deleted", "records", "." ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Repository/RedirectRepository.php#L49-L56
train
TYPO3-CMS/redirects
Classes/Repository/RedirectRepository.php
RedirectRepository.getQueryBuilderForDemand
protected function getQueryBuilderForDemand(): QueryBuilder { $queryBuilder = $this->getQueryBuilder(); $queryBuilder ->select('*') ->from('sys_redirect') ->orderBy('source_host') ->addOrderBy('source_path'); $constraints = []; if ($this->demand->hasSourceHost()) { $constraints[] =$queryBuilder->expr()->eq( 'source_host', $queryBuilder->createNamedParameter($this->demand->getSourceHost(), \PDO::PARAM_STR) ); } if ($this->demand->hasSourcePath()) { $escapedLikeString = '%' . $queryBuilder->escapeLikeWildcards($this->demand->getSourcePath()) . '%'; $constraints[] = $queryBuilder->expr()->like( 'source_path', $queryBuilder->createNamedParameter($escapedLikeString, \PDO::PARAM_STR) ); } if ($this->demand->hasTarget()) { $escapedLikeString = '%' . $queryBuilder->escapeLikeWildcards($this->demand->getTarget()) . '%'; $constraints[] = $queryBuilder->expr()->like( 'target', $queryBuilder->createNamedParameter($escapedLikeString, \PDO::PARAM_STR) ); } if ($this->demand->hasStatusCode()) { $constraints[] =$queryBuilder->expr()->eq( 'target_statuscode', $queryBuilder->createNamedParameter($this->demand->getStatusCode(), \PDO::PARAM_INT) ); } if (!empty($constraints)) { $queryBuilder->where(...$constraints); } return $queryBuilder; }
php
protected function getQueryBuilderForDemand(): QueryBuilder { $queryBuilder = $this->getQueryBuilder(); $queryBuilder ->select('*') ->from('sys_redirect') ->orderBy('source_host') ->addOrderBy('source_path'); $constraints = []; if ($this->demand->hasSourceHost()) { $constraints[] =$queryBuilder->expr()->eq( 'source_host', $queryBuilder->createNamedParameter($this->demand->getSourceHost(), \PDO::PARAM_STR) ); } if ($this->demand->hasSourcePath()) { $escapedLikeString = '%' . $queryBuilder->escapeLikeWildcards($this->demand->getSourcePath()) . '%'; $constraints[] = $queryBuilder->expr()->like( 'source_path', $queryBuilder->createNamedParameter($escapedLikeString, \PDO::PARAM_STR) ); } if ($this->demand->hasTarget()) { $escapedLikeString = '%' . $queryBuilder->escapeLikeWildcards($this->demand->getTarget()) . '%'; $constraints[] = $queryBuilder->expr()->like( 'target', $queryBuilder->createNamedParameter($escapedLikeString, \PDO::PARAM_STR) ); } if ($this->demand->hasStatusCode()) { $constraints[] =$queryBuilder->expr()->eq( 'target_statuscode', $queryBuilder->createNamedParameter($this->demand->getStatusCode(), \PDO::PARAM_INT) ); } if (!empty($constraints)) { $queryBuilder->where(...$constraints); } return $queryBuilder; }
[ "protected", "function", "getQueryBuilderForDemand", "(", ")", ":", "QueryBuilder", "{", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "select", "(", "'*'", ")", "->", "from", "(", "'sys_redirect'", ...
Prepares the QueryBuilder with Constraints from the Demand @return QueryBuilder
[ "Prepares", "the", "QueryBuilder", "with", "Constraints", "from", "the", "Demand" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Repository/RedirectRepository.php#L71-L115
train
gocom/rah_sitemap
src/Rah/Sitemap.php
Rah_Sitemap.cleanUrlHandler
public function cleanUrlHandler(): void { global $pretext; $basename = explode('?', (string) $pretext['request_uri']); $basename = basename(array_shift($basename)); if ($basename === 'robots.txt') { $this->sendRobots(); } if ($basename === 'sitemap.xml' || $basename === 'sitemap.xml.gz') { $this->populateArticleFields()->sendSitemap(); } }
php
public function cleanUrlHandler(): void { global $pretext; $basename = explode('?', (string) $pretext['request_uri']); $basename = basename(array_shift($basename)); if ($basename === 'robots.txt') { $this->sendRobots(); } if ($basename === 'sitemap.xml' || $basename === 'sitemap.xml.gz') { $this->populateArticleFields()->sendSitemap(); } }
[ "public", "function", "cleanUrlHandler", "(", ")", ":", "void", "{", "global", "$", "pretext", ";", "$", "basename", "=", "explode", "(", "'?'", ",", "(", "string", ")", "$", "pretext", "[", "'request_uri'", "]", ")", ";", "$", "basename", "=", "basena...
Handles routing clean URLs.
[ "Handles", "routing", "clean", "URLs", "." ]
a01e380b6695ad283fbdf402fb2ea1a640c607f9
https://github.com/gocom/rah_sitemap/blob/a01e380b6695ad283fbdf402fb2ea1a640c607f9/src/Rah/Sitemap.php#L122-L136
train
gocom/rah_sitemap
src/Rah/Sitemap.php
Rah_Sitemap.addUrl
private function addUrl($url, $lastmod = null): self { if (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) { $url = hu.ltrim($url, '/'); } if (preg_match('/[\'"<>]/', $url)) { $url = htmlspecialchars($url, ENT_QUOTES); } if (isset($this->addUrlset[$url])) { return $this; } if ($lastmod !== null) { if (!is_int($lastmod)) { $lastmod = strtotime($lastmod); } if ($lastmod !== false) { $lastmod = safe_strftime('iso8601', $lastmod); } } $this->addUrlset[$url] = '<url>'. '<loc>'.$url.'</loc>'. ($lastmod ? '<lastmod>'.$lastmod.'</lastmod>' : ''). '</url>'; return $this; }
php
private function addUrl($url, $lastmod = null): self { if (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) { $url = hu.ltrim($url, '/'); } if (preg_match('/[\'"<>]/', $url)) { $url = htmlspecialchars($url, ENT_QUOTES); } if (isset($this->addUrlset[$url])) { return $this; } if ($lastmod !== null) { if (!is_int($lastmod)) { $lastmod = strtotime($lastmod); } if ($lastmod !== false) { $lastmod = safe_strftime('iso8601', $lastmod); } } $this->addUrlset[$url] = '<url>'. '<loc>'.$url.'</loc>'. ($lastmod ? '<lastmod>'.$lastmod.'</lastmod>' : ''). '</url>'; return $this; }
[ "private", "function", "addUrl", "(", "$", "url", ",", "$", "lastmod", "=", "null", ")", ":", "self", "{", "if", "(", "strpos", "(", "$", "url", ",", "'http://'", ")", "!==", "0", "&&", "strpos", "(", "$", "url", ",", "'https://'", ")", "!==", "0...
Renders a &lt;url&gt; element to the XML document. @param string $url The URL @param int|string $lastmod The modification date @return $this
[ "Renders", "a", "&lt", ";", "url&gt", ";", "element", "to", "the", "XML", "document", "." ]
a01e380b6695ad283fbdf402fb2ea1a640c607f9
https://github.com/gocom/rah_sitemap/blob/a01e380b6695ad283fbdf402fb2ea1a640c607f9/src/Rah/Sitemap.php#L268-L299
train
gocom/rah_sitemap
src/Rah/Sitemap.php
Rah_Sitemap.populateArticleFields
private function populateArticleFields(): self { $columns = (array) @getThings('describe '.safe_pfx('textpattern')); foreach ($columns as $name) { $this->articleFields[strtolower($name)] = $name; } foreach (getCustomFields() as $id => $name) { $this->articleFields[$name] = 'custom_'.intval($id); } return $this; }
php
private function populateArticleFields(): self { $columns = (array) @getThings('describe '.safe_pfx('textpattern')); foreach ($columns as $name) { $this->articleFields[strtolower($name)] = $name; } foreach (getCustomFields() as $id => $name) { $this->articleFields[$name] = 'custom_'.intval($id); } return $this; }
[ "private", "function", "populateArticleFields", "(", ")", ":", "self", "{", "$", "columns", "=", "(", "array", ")", "@", "getThings", "(", "'describe '", ".", "safe_pfx", "(", "'textpattern'", ")", ")", ";", "foreach", "(", "$", "columns", "as", "$", "na...
Picks up names of article fields. @return $this
[ "Picks", "up", "names", "of", "article", "fields", "." ]
a01e380b6695ad283fbdf402fb2ea1a640c607f9
https://github.com/gocom/rah_sitemap/blob/a01e380b6695ad283fbdf402fb2ea1a640c607f9/src/Rah/Sitemap.php#L306-L319
train
gocom/rah_sitemap
src/Rah/Sitemap.php
Rah_Sitemap.prefs
public function prefs(): void { pagetop(gTxt('rah_sitemap')); echo graf( href(gTxt('rah_sitemap_view_prefs'), ['event' => 'prefs']) . br . href(gTxt('rah_sitemap_view_sitemap'), hu . '?rah_sitemap=sitemap') ); }
php
public function prefs(): void { pagetop(gTxt('rah_sitemap')); echo graf( href(gTxt('rah_sitemap_view_prefs'), ['event' => 'prefs']) . br . href(gTxt('rah_sitemap_view_sitemap'), hu . '?rah_sitemap=sitemap') ); }
[ "public", "function", "prefs", "(", ")", ":", "void", "{", "pagetop", "(", "gTxt", "(", "'rah_sitemap'", ")", ")", ";", "echo", "graf", "(", "href", "(", "gTxt", "(", "'rah_sitemap_view_prefs'", ")", ",", "[", "'event'", "=>", "'prefs'", "]", ")", ".",...
Options panel.
[ "Options", "panel", "." ]
a01e380b6695ad283fbdf402fb2ea1a640c607f9
https://github.com/gocom/rah_sitemap/blob/a01e380b6695ad283fbdf402fb2ea1a640c607f9/src/Rah/Sitemap.php#L324-L332
train
gocom/rah_sitemap
src/Rah/Sitemap.php
Rah_Sitemap.renderSectionOptions
public function renderSectionOptions($event, $step, $void, $r): string { if ($r['name'] !== 'default') { return inputLabel( 'rah_sitemap_include_in', yesnoradio('rah_sitemap_include_in', !empty($r['rah_sitemap_include_in']), '', ''), '', 'rah_sitemap_include_in' ); } }
php
public function renderSectionOptions($event, $step, $void, $r): string { if ($r['name'] !== 'default') { return inputLabel( 'rah_sitemap_include_in', yesnoradio('rah_sitemap_include_in', !empty($r['rah_sitemap_include_in']), '', ''), '', 'rah_sitemap_include_in' ); } }
[ "public", "function", "renderSectionOptions", "(", "$", "event", ",", "$", "step", ",", "$", "void", ",", "$", "r", ")", ":", "string", "{", "if", "(", "$", "r", "[", "'name'", "]", "!==", "'default'", ")", "{", "return", "inputLabel", "(", "'rah_sit...
Shows settings at the Sections panel. @param string $event The event @param string $step The step @param bool $void Not used @param array $r The section data as an array @return string HTML
[ "Shows", "settings", "at", "the", "Sections", "panel", "." ]
a01e380b6695ad283fbdf402fb2ea1a640c607f9
https://github.com/gocom/rah_sitemap/blob/a01e380b6695ad283fbdf402fb2ea1a640c607f9/src/Rah/Sitemap.php#L343-L353
train
QoboLtd/cakephp-search
src/Controller/SearchTrait.php
SearchTrait.getAjaxViewVars
protected function getAjaxViewVars(array $searchData, RepositoryInterface $table, Search $search): array { /** @var \Cake\ORM\Table */ $table = $table; $searchData['sort_by_field'] = Hash::get($this->request->getQueryParams(), 'sort', ''); $searchData['sort_by_order'] = Hash::get( $this->request->getQueryParams(), 'direction', SearchOptions::DEFAULT_SORT_BY_ORDER ); /** @var \Cake\ORM\Query */ $query = $search->execute($searchData); $resultSet = $this->paginate($query); $event = new Event( (string)SearchEventName::MODEL_SEARCH_AFTER_FIND(), $this, ['entities' => $resultSet, 'table' => $table] ); $this->getEventManager()->dispatch($event); $resultSet = $event->getResult() instanceof ResultSetInterface ? $event->getResult() : $resultSet; $primaryKeys = []; foreach ((array)$table->getPrimaryKey() as $primaryKey) { $primaryKeys[] = $table->aliasField($primaryKey); } $displayColumns = empty($searchData['group_by']) ? $searchData['display_columns'] : [$searchData['group_by'], pluginSplit($searchData['group_by'])[0] . '.' . Search::GROUP_BY_FIELD]; $displayColumns = array_merge($primaryKeys, $displayColumns); return [ 'success' => true, 'data' => Utility::instance()->formatter($resultSet, $displayColumns, $table, $this->Auth->user()), 'pagination' => ['count' => $query->count()], '_serialize' => ['success', 'data', 'pagination'] ]; }
php
protected function getAjaxViewVars(array $searchData, RepositoryInterface $table, Search $search): array { /** @var \Cake\ORM\Table */ $table = $table; $searchData['sort_by_field'] = Hash::get($this->request->getQueryParams(), 'sort', ''); $searchData['sort_by_order'] = Hash::get( $this->request->getQueryParams(), 'direction', SearchOptions::DEFAULT_SORT_BY_ORDER ); /** @var \Cake\ORM\Query */ $query = $search->execute($searchData); $resultSet = $this->paginate($query); $event = new Event( (string)SearchEventName::MODEL_SEARCH_AFTER_FIND(), $this, ['entities' => $resultSet, 'table' => $table] ); $this->getEventManager()->dispatch($event); $resultSet = $event->getResult() instanceof ResultSetInterface ? $event->getResult() : $resultSet; $primaryKeys = []; foreach ((array)$table->getPrimaryKey() as $primaryKey) { $primaryKeys[] = $table->aliasField($primaryKey); } $displayColumns = empty($searchData['group_by']) ? $searchData['display_columns'] : [$searchData['group_by'], pluginSplit($searchData['group_by'])[0] . '.' . Search::GROUP_BY_FIELD]; $displayColumns = array_merge($primaryKeys, $displayColumns); return [ 'success' => true, 'data' => Utility::instance()->formatter($resultSet, $displayColumns, $table, $this->Auth->user()), 'pagination' => ['count' => $query->count()], '_serialize' => ['success', 'data', 'pagination'] ]; }
[ "protected", "function", "getAjaxViewVars", "(", "array", "$", "searchData", ",", "RepositoryInterface", "$", "table", ",", "Search", "$", "search", ")", ":", "array", "{", "/** @var \\Cake\\ORM\\Table */", "$", "table", "=", "$", "table", ";", "$", "searchData"...
Get AJAX response view variables @param mixed[] $searchData Search data @param \Cake\Datasource\RepositoryInterface $table Table instance @param \Search\Utility\Search $search Search instance @return mixed[] Variables and values for AJAX response
[ "Get", "AJAX", "response", "view", "variables" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Controller/SearchTrait.php#L137-L177
train
QoboLtd/cakephp-search
src/Controller/SearchTrait.php
SearchTrait.exportSearch
public function exportSearch(string $id, string $filename) { $filename = '' === trim($filename) ? $this->name : $filename; $export = new Export($id, $filename, $this->Auth->user()); if ($this->request->is('ajax') && $this->request->accepts('application/json')) { $page = (int)Hash::get($this->request->getQueryParams(), 'page', 1); $limit = (int)Hash::get($this->request->getQueryParams(), 'limit', Configure::read('Search.export.limit')); $export->execute($page, $limit); $result = [ 'success' => true, 'data' => ['path' => $export->getUrl()], '_serialize' => ['success', 'data'] ]; $this->set($result); return; } $this->set('count', $export->count()); $this->set('filename', $filename); $this->render('Search.Search/export'); }
php
public function exportSearch(string $id, string $filename) { $filename = '' === trim($filename) ? $this->name : $filename; $export = new Export($id, $filename, $this->Auth->user()); if ($this->request->is('ajax') && $this->request->accepts('application/json')) { $page = (int)Hash::get($this->request->getQueryParams(), 'page', 1); $limit = (int)Hash::get($this->request->getQueryParams(), 'limit', Configure::read('Search.export.limit')); $export->execute($page, $limit); $result = [ 'success' => true, 'data' => ['path' => $export->getUrl()], '_serialize' => ['success', 'data'] ]; $this->set($result); return; } $this->set('count', $export->count()); $this->set('filename', $filename); $this->render('Search.Search/export'); }
[ "public", "function", "exportSearch", "(", "string", "$", "id", ",", "string", "$", "filename", ")", "{", "$", "filename", "=", "''", "===", "trim", "(", "$", "filename", ")", "?", "$", "this", "->", "name", ":", "$", "filename", ";", "$", "export", ...
Export Search results Method responsible for exporting search results into a CSV file and forcing file download. @param string $id Pre-saved search id @param string $filename Export filename @return \Cake\Http\Response|void
[ "Export", "Search", "results" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Controller/SearchTrait.php#L288-L313
train
BabDev/Transifex-API
src/Connector/Resources.php
Resources.deleteResource
public function deleteResource(string $project, string $resource): ResponseInterface { return $this->client->sendRequest($this->createRequest('DELETE', $this->createUri("/api/2/project/$project/resource/$resource"))); }
php
public function deleteResource(string $project, string $resource): ResponseInterface { return $this->client->sendRequest($this->createRequest('DELETE', $this->createUri("/api/2/project/$project/resource/$resource"))); }
[ "public", "function", "deleteResource", "(", "string", "$", "project", ",", "string", "$", "resource", ")", ":", "ResponseInterface", "{", "return", "$", "this", "->", "client", "->", "sendRequest", "(", "$", "this", "->", "createRequest", "(", "'DELETE'", "...
Delete a resource within a project. @param string $project The slug for the project the resource is part of @param string $resource The resource slug within the project @return ResponseInterface
[ "Delete", "a", "resource", "within", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Resources.php#L84-L87
train
BabDev/Transifex-API
src/Connector/Resources.php
Resources.getResource
public function getResource(string $project, string $resource, bool $details = false): ResponseInterface { $uri = $this->createUri("/api/2/project/$project/resource/$resource/"); if ($details) { $uri = $uri->withQuery('details'); } return $this->client->sendRequest($this->createRequest('GET', $uri)); }
php
public function getResource(string $project, string $resource, bool $details = false): ResponseInterface { $uri = $this->createUri("/api/2/project/$project/resource/$resource/"); if ($details) { $uri = $uri->withQuery('details'); } return $this->client->sendRequest($this->createRequest('GET', $uri)); }
[ "public", "function", "getResource", "(", "string", "$", "project", ",", "string", "$", "resource", ",", "bool", "$", "details", "=", "false", ")", ":", "ResponseInterface", "{", "$", "uri", "=", "$", "this", "->", "createUri", "(", "\"/api/2/project/$projec...
Get information about a resource within a project. @param string $project The slug for the project the resource is part of @param string $resource The resource slug within the project @param bool $details True to retrieve additional project details @return ResponseInterface
[ "Get", "information", "about", "a", "resource", "within", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Resources.php#L98-L107
train
BabDev/Transifex-API
src/Connector/Resources.php
Resources.updateResourceContent
public function updateResourceContent( string $project, string $resource, string $content, string $type = 'string' ): ResponseInterface { return $this->updateResource($this->createUri("/api/2/project/$project/resource/$resource/content/"), $content, $type); }
php
public function updateResourceContent( string $project, string $resource, string $content, string $type = 'string' ): ResponseInterface { return $this->updateResource($this->createUri("/api/2/project/$project/resource/$resource/content/"), $content, $type); }
[ "public", "function", "updateResourceContent", "(", "string", "$", "project", ",", "string", "$", "resource", ",", "string", "$", "content", ",", "string", "$", "type", "=", "'string'", ")", ":", "ResponseInterface", "{", "return", "$", "this", "->", "update...
Update the content of a resource within a project. @param string $project The slug for the project the resource is part of @param string $resource The resource slug within the project @param string $content The content of the resource, this can either be a string of data or a file path @param string $type The type of content in the $content variable, this should be either string or file @return ResponseInterface
[ "Update", "the", "content", "of", "a", "resource", "within", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Resources.php#L144-L151
train
QoboLtd/cakephp-search
src/Utility/MagicValue.php
MagicValue.get
public function get() { $value = str_replace(static::WRAPPER, '', $this->value); if (! method_exists($this, $value)) { return $this->value; } return $this->{$value}(); }
php
public function get() { $value = str_replace(static::WRAPPER, '', $this->value); if (! method_exists($this, $value)) { return $this->value; } return $this->{$value}(); }
[ "public", "function", "get", "(", ")", "{", "$", "value", "=", "str_replace", "(", "static", "::", "WRAPPER", ",", "''", ",", "$", "this", "->", "value", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "value", ")", ")", "{...
Magic value getter. @return mixed
[ "Magic", "value", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/MagicValue.php#L68-L77
train
QoboLtd/cakephp-search
src/Model/Table/DashboardsTable.php
DashboardsTable.getUserDashboards
public function getUserDashboards(array $user): QueryInterface { // get all dashboards $query = $this->find('all')->order('name'); // return all dashboards if current user is superuser if (isset($user['is_superuser']) && $user['is_superuser']) { return $query; } $roles = []; /** @var \Groups\Model\Table\GroupsTable */ $table = $this->Roles->Groups->getTarget(); $groups = $table->getUserGroups($user['id']); // get group(s) roles if (!empty($groups)) { $roles = $this->Roles->Capabilities->getGroupsRoles($groups); } if (empty($roles)) { // get all dashboards not assigned to any role $query->where(['Dashboards.role_id IS NULL']); return $query; } // return all dashboards for Admins if (in_array(Configure::read('RolesCapabilities.Roles.Admin.name'), $roles)) { return $query; } // get role(s) dashboards $query->where(['OR' => [ ['Dashboards.role_id IN' => array_keys($roles)], ['Dashboards.role_id IS NULL'] ]]); return $query; }
php
public function getUserDashboards(array $user): QueryInterface { // get all dashboards $query = $this->find('all')->order('name'); // return all dashboards if current user is superuser if (isset($user['is_superuser']) && $user['is_superuser']) { return $query; } $roles = []; /** @var \Groups\Model\Table\GroupsTable */ $table = $this->Roles->Groups->getTarget(); $groups = $table->getUserGroups($user['id']); // get group(s) roles if (!empty($groups)) { $roles = $this->Roles->Capabilities->getGroupsRoles($groups); } if (empty($roles)) { // get all dashboards not assigned to any role $query->where(['Dashboards.role_id IS NULL']); return $query; } // return all dashboards for Admins if (in_array(Configure::read('RolesCapabilities.Roles.Admin.name'), $roles)) { return $query; } // get role(s) dashboards $query->where(['OR' => [ ['Dashboards.role_id IN' => array_keys($roles)], ['Dashboards.role_id IS NULL'] ]]); return $query; }
[ "public", "function", "getUserDashboards", "(", "array", "$", "user", ")", ":", "QueryInterface", "{", "// get all dashboards", "$", "query", "=", "$", "this", "->", "find", "(", "'all'", ")", "->", "order", "(", "'name'", ")", ";", "// return all dashboards i...
Get specified user accessible dashboards. @param mixed[] $user user details @return \Cake\Datasource\QueryInterface
[ "Get", "specified", "user", "accessible", "dashboards", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Model/Table/DashboardsTable.php#L95-L133
train
mmoreram/ControllerExtraBundle
Resolver/LogAnnotationResolver.php
LogAnnotationResolver.logMessage
private function logMessage( LoggerInterface $logger, string $level, string $value ) { /** * Logs content, using specified level. */ $logger->$level($value); }
php
private function logMessage( LoggerInterface $logger, string $level, string $value ) { /** * Logs content, using specified level. */ $logger->$level($value); }
[ "private", "function", "logMessage", "(", "LoggerInterface", "$", "logger", ",", "string", "$", "level", ",", "string", "$", "value", ")", "{", "/**\n * Logs content, using specified level.\n */", "$", "logger", "->", "$", "level", "(", "$", "value",...
Send value to log. @param LoggerInterface $logger @param string $level @param string $value
[ "Send", "value", "to", "log", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/LogAnnotationResolver.php#L166-L175
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Order/Standard.php
Standard.createOrder
protected function createOrder( $baseId ) { $context = $this->getContext(); $cntl = \Aimeos\Controller\Frontend::create( $context, 'order' ); $item = $cntl->add( $baseId, ['order.type' => 'jsonapi'] )->store(); $context->getSession()->set( 'aimeos/orderid', $item->getId() ); return $item; }
php
protected function createOrder( $baseId ) { $context = $this->getContext(); $cntl = \Aimeos\Controller\Frontend::create( $context, 'order' ); $item = $cntl->add( $baseId, ['order.type' => 'jsonapi'] )->store(); $context->getSession()->set( 'aimeos/orderid', $item->getId() ); return $item; }
[ "protected", "function", "createOrder", "(", "$", "baseId", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "cntl", "=", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "::", "create", "(", "$", "context", ",",...
Adds and returns a new order item for the given order base ID @param string $baseId Unique order base ID @return \Aimeos\MShop\Order\Item\Iface New order item
[ "Adds", "and", "returns", "a", "new", "order", "item", "for", "the", "given", "order", "base", "ID" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Order/Standard.php#L175-L184
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Order/Standard.php
Standard.getBasket
protected function getBasket( $basketId ) { $context = $this->getContext(); $baseId = $context->getSession()->get( 'aimeos/order.baseid' ); if( $baseId != $basketId ) { $msg = sprintf( 'No basket for the "order.baseid" ("%1$s") found', $basketId ); throw new \Aimeos\Client\JsonApi\Exception( $msg, 403 ); } $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_SERVICE; $cntl = \Aimeos\Controller\Frontend::create( $context, 'basket' ); return $cntl->load( $baseId, $parts, false ); }
php
protected function getBasket( $basketId ) { $context = $this->getContext(); $baseId = $context->getSession()->get( 'aimeos/order.baseid' ); if( $baseId != $basketId ) { $msg = sprintf( 'No basket for the "order.baseid" ("%1$s") found', $basketId ); throw new \Aimeos\Client\JsonApi\Exception( $msg, 403 ); } $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_SERVICE; $cntl = \Aimeos\Controller\Frontend::create( $context, 'basket' ); return $cntl->load( $baseId, $parts, false ); }
[ "protected", "function", "getBasket", "(", "$", "basketId", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "baseId", "=", "$", "context", "->", "getSession", "(", ")", "->", "get", "(", "'aimeos/order.baseid'", ")", ...
Returns the basket object for the given ID @param string $basketId Unique order base ID @return \Aimeos\MShop\Order\Item\Base\Iface Basket object including only the services @throws \Aimeos\Client\JsonApi\Exception If basket ID is not the same as stored before in the current session
[ "Returns", "the", "basket", "object", "for", "the", "given", "ID" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Order/Standard.php#L194-L209
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Order/Standard.php
Standard.render
protected function render( ResponseInterface $response, \Aimeos\MW\View\Iface $view, $status ) { /** client/jsonapi/order/standard/template * Relative path to the order JSON API template * * The template file contains the code and processing instructions * to generate the result shown in the JSON API body. The * configuration string is the path to the template file relative * to the templates directory (usually in client/jsonapi/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 "standard" 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, "standard" * should be replaced by the name of the new class. * * @param string Relative path to the template creating the body of the JSON API * @since 2017.03 * @category Developer */ $tplconf = 'client/jsonapi/order/standard/template'; $default = 'order/standard'; $body = $view->render( $view->config( $tplconf, $default ) ); return $response->withHeader( 'Allow', 'GET,OPTIONS,POST' ) ->withHeader( 'Cache-Control', 'no-cache, private' ) ->withHeader( 'Content-Type', 'application/vnd.api+json' ) ->withBody( $view->response()->createStreamFromString( $body ) ) ->withStatus( $status ); }
php
protected function render( ResponseInterface $response, \Aimeos\MW\View\Iface $view, $status ) { /** client/jsonapi/order/standard/template * Relative path to the order JSON API template * * The template file contains the code and processing instructions * to generate the result shown in the JSON API body. The * configuration string is the path to the template file relative * to the templates directory (usually in client/jsonapi/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 "standard" 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, "standard" * should be replaced by the name of the new class. * * @param string Relative path to the template creating the body of the JSON API * @since 2017.03 * @category Developer */ $tplconf = 'client/jsonapi/order/standard/template'; $default = 'order/standard'; $body = $view->render( $view->config( $tplconf, $default ) ); return $response->withHeader( 'Allow', 'GET,OPTIONS,POST' ) ->withHeader( 'Cache-Control', 'no-cache, private' ) ->withHeader( 'Content-Type', 'application/vnd.api+json' ) ->withBody( $view->response()->createStreamFromString( $body ) ) ->withStatus( $status ); }
[ "protected", "function", "render", "(", "ResponseInterface", "$", "response", ",", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ",", "$", "status", ")", "{", "/** client/jsonapi/order/standard/template\n\t\t * Relative path to the order JSON API...
Returns the response object with the rendered header and body @param \Psr\Http\Message\ResponseInterface $response Response object @param \Aimeos\MW\View\Iface $view View instance @param integer $status HTTP status code @return \Psr\Http\Message\ResponseInterface Modified response object
[ "Returns", "the", "response", "object", "with", "the", "rendered", "header", "and", "body" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Order/Standard.php#L322-L353
train
QoboLtd/cakephp-search
src/Event/Model/WidgetsListener.php
WidgetsListener.getWidgets
public function getWidgets(Event $event): void { $result = array_merge( (array)$event->result, $this->getSavedSearchWidgets(), $this->getReportWidgets(), $this->getAppWidgets() ); $event->result = array_filter($result); }
php
public function getWidgets(Event $event): void { $result = array_merge( (array)$event->result, $this->getSavedSearchWidgets(), $this->getReportWidgets(), $this->getAppWidgets() ); $event->result = array_filter($result); }
[ "public", "function", "getWidgets", "(", "Event", "$", "event", ")", ":", "void", "{", "$", "result", "=", "array_merge", "(", "(", "array", ")", "$", "event", "->", "result", ",", "$", "this", "->", "getSavedSearchWidgets", "(", ")", ",", "$", "this",...
Add widgets for Search plugin's Dashboards. @param \Cake\Event\Event $event Event instance @return void
[ "Add", "widgets", "for", "Search", "plugin", "s", "Dashboards", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Event/Model/WidgetsListener.php#L41-L51
train
QoboLtd/cakephp-search
src/Event/Model/WidgetsListener.php
WidgetsListener.getSavedSearchWidgets
private function getSavedSearchWidgets(): array { $table = TableRegistry::get('Search.SavedSearches'); $query = $table->find('all') ->where([ 'SavedSearches.name IS NOT' => null, 'SavedSearches.name !=' => '', 'SavedSearches.system' => false ]) ->enableHydration(false) ->indexBy('id'); if ($query->isEmpty()) { return []; } return [ ['type' => 'saved_search', 'data' => $query->toArray()] ]; }
php
private function getSavedSearchWidgets(): array { $table = TableRegistry::get('Search.SavedSearches'); $query = $table->find('all') ->where([ 'SavedSearches.name IS NOT' => null, 'SavedSearches.name !=' => '', 'SavedSearches.system' => false ]) ->enableHydration(false) ->indexBy('id'); if ($query->isEmpty()) { return []; } return [ ['type' => 'saved_search', 'data' => $query->toArray()] ]; }
[ "private", "function", "getSavedSearchWidgets", "(", ")", ":", "array", "{", "$", "table", "=", "TableRegistry", "::", "get", "(", "'Search.SavedSearches'", ")", ";", "$", "query", "=", "$", "table", "->", "find", "(", "'all'", ")", "->", "where", "(", "...
Fetch all saved searches from the database. @return mixed[]
[ "Fetch", "all", "saved", "searches", "from", "the", "database", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Event/Model/WidgetsListener.php#L58-L78
train
QoboLtd/cakephp-search
src/Event/Model/WidgetsListener.php
WidgetsListener.getReportWidgets
private function getReportWidgets(): array { $event = new Event((string)EventName::MODEL_DASHBOARDS_GET_REPORTS(), $this); EventManager::instance()->dispatch($event); if (empty($event->result)) { return []; } $result = []; foreach ($event->result as $reports) { foreach ($reports as $report) { if (! isset($result[$report['widget_type']])) { $result[$report['widget_type']] = ['type' => $report['widget_type'], 'data' => []]; } $result[$report['widget_type']]['data'][$report['id']] = $report; } } return array_values($result); }
php
private function getReportWidgets(): array { $event = new Event((string)EventName::MODEL_DASHBOARDS_GET_REPORTS(), $this); EventManager::instance()->dispatch($event); if (empty($event->result)) { return []; } $result = []; foreach ($event->result as $reports) { foreach ($reports as $report) { if (! isset($result[$report['widget_type']])) { $result[$report['widget_type']] = ['type' => $report['widget_type'], 'data' => []]; } $result[$report['widget_type']]['data'][$report['id']] = $report; } } return array_values($result); }
[ "private", "function", "getReportWidgets", "(", ")", ":", "array", "{", "$", "event", "=", "new", "Event", "(", "(", "string", ")", "EventName", "::", "MODEL_DASHBOARDS_GET_REPORTS", "(", ")", ",", "$", "this", ")", ";", "EventManager", "::", "instance", "...
Fetch all reports through Event broadcast. @return mixed[]
[ "Fetch", "all", "reports", "through", "Event", "broadcast", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Event/Model/WidgetsListener.php#L85-L105
train
QoboLtd/cakephp-search
src/Event/Model/WidgetsListener.php
WidgetsListener.getAppWidgets
private function getAppWidgets(): array { $table = TableRegistry::get('Search.AppWidgets'); $query = $table->find('all') ->select(['id', 'name', 'content']); if ($query->isEmpty()) { return []; } $data = []; // normalize app widget data foreach ($query->all() as $entity) { $data[] = [ 'id' => $entity->get('id'), 'model' => $entity->get('content')['model'], 'name' => $entity->get('name'), 'path' => $entity->get('content')['path'] ]; } return [ ['type' => 'app', 'data' => $data] ]; }
php
private function getAppWidgets(): array { $table = TableRegistry::get('Search.AppWidgets'); $query = $table->find('all') ->select(['id', 'name', 'content']); if ($query->isEmpty()) { return []; } $data = []; // normalize app widget data foreach ($query->all() as $entity) { $data[] = [ 'id' => $entity->get('id'), 'model' => $entity->get('content')['model'], 'name' => $entity->get('name'), 'path' => $entity->get('content')['path'] ]; } return [ ['type' => 'app', 'data' => $data] ]; }
[ "private", "function", "getAppWidgets", "(", ")", ":", "array", "{", "$", "table", "=", "TableRegistry", "::", "get", "(", "'Search.AppWidgets'", ")", ";", "$", "query", "=", "$", "table", "->", "find", "(", "'all'", ")", "->", "select", "(", "[", "'id...
Returns list of widgets defined in the application scope. @return mixed[]
[ "Returns", "list", "of", "widgets", "defined", "in", "the", "application", "scope", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Event/Model/WidgetsListener.php#L112-L137
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi.php
JsonApi.create
public static function create( \Aimeos\MShop\Context\Item\Iface $context, $path, $name = null ) { $path = trim( $path, '/' ); if( empty( $path ) ) { return self::createRoot( $context, $path, $name ); } $parts = explode( '/', $path ); foreach( $parts as $key => $part ) { if( ctype_alnum( $part ) === false ) { $msg = sprintf( 'Invalid client "%1$s"', $path ); throw new \Aimeos\Client\JsonApi\Exception( $msg, 400 ); } $parts[$key] = ucfirst( $part ); } $factory = '\\Aimeos\\Client\\JsonApi\\' . join( '\\', $parts ) . '\\Factory'; if( class_exists( $factory ) === true ) { if( ( $client = @call_user_func_array( [$factory, 'create'], [$context, $path, $name] ) ) === false ) { throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); } } else { $client = self::createRoot( $context, $path, $name ); } return $client; }
php
public static function create( \Aimeos\MShop\Context\Item\Iface $context, $path, $name = null ) { $path = trim( $path, '/' ); if( empty( $path ) ) { return self::createRoot( $context, $path, $name ); } $parts = explode( '/', $path ); foreach( $parts as $key => $part ) { if( ctype_alnum( $part ) === false ) { $msg = sprintf( 'Invalid client "%1$s"', $path ); throw new \Aimeos\Client\JsonApi\Exception( $msg, 400 ); } $parts[$key] = ucfirst( $part ); } $factory = '\\Aimeos\\Client\\JsonApi\\' . join( '\\', $parts ) . '\\Factory'; if( class_exists( $factory ) === true ) { if( ( $client = @call_user_func_array( [$factory, 'create'], [$context, $path, $name] ) ) === false ) { throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); } } else { $client = self::createRoot( $context, $path, $name ); } return $client; }
[ "public", "static", "function", "create", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Context", "\\", "Item", "\\", "Iface", "$", "context", ",", "$", "path", ",", "$", "name", "=", "null", ")", "{", "$", "path", "=", "trim", "(", "$", "path", ",", ...
Creates the required client specified by the given path of client names Clients are created by providing only the domain name, e.g. "product" for the \Aimeos\Client\JsonApi\Product\Standard or a path of names to retrieve a specific sub-client, e.g. "product/type" for the \Aimeos\Client\JsonApi\Product\Type\Standard client. @param \Aimeos\MShop\Context\Item\Iface $context Context object required by clients @param string $path Name of the client separated by slashes, e.g "order/base" @param string|null $name Name of the client implementation ("Standard" if null) @return \Aimeos\Client\JsonApi\Iface JSON client instance @throws \Aimeos\Client\JsonApi\Exception If the given path is invalid
[ "Creates", "the", "required", "client", "specified", "by", "the", "given", "path", "of", "client", "names" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi.php#L36-L71
train
BabDev/Transifex-API
src/Connector/Languageinfo.php
Languageinfo.getLanguage
public function getLanguage(string $lang): ResponseInterface { return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/language/$lang/"))); }
php
public function getLanguage(string $lang): ResponseInterface { return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/language/$lang/"))); }
[ "public", "function", "getLanguage", "(", "string", "$", "lang", ")", ":", "ResponseInterface", "{", "return", "$", "this", "->", "client", "->", "sendRequest", "(", "$", "this", "->", "createRequest", "(", "'GET'", ",", "$", "this", "->", "createUri", "("...
Get data on the specified language. @param string $lang The language code to retrieve @return ResponseInterface
[ "Get", "data", "on", "the", "specified", "language", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languageinfo.php#L22-L25
train
BabDev/Transifex-API
src/Connector/Translationstrings.php
Translationstrings.getStrings
public function getStrings( string $project, string $resource, string $lang, bool $details = false, array $options = [] ): ResponseInterface { $uri = $this->createUri("/api/2/project/$project/resource/$resource/translation/$lang/strings/"); $query = []; if ($details) { // Add details now because `http_build_query()` can't handle something that isn't a key/value pair $uri = $uri->withQuery('details'); } if (isset($options['key'])) { $query['key'] = $options['key']; } if (isset($options['context'])) { $query['context'] = $options['context']; } if (!empty($query)) { if ($uri->getQuery() === '') { $uri = $uri->withQuery(\http_build_query($query)); } else { $uri = $uri->withQuery($uri->getQuery() . '&' . \http_build_query($query)); } } return $this->client->sendRequest($this->createRequest('GET', $uri)); }
php
public function getStrings( string $project, string $resource, string $lang, bool $details = false, array $options = [] ): ResponseInterface { $uri = $this->createUri("/api/2/project/$project/resource/$resource/translation/$lang/strings/"); $query = []; if ($details) { // Add details now because `http_build_query()` can't handle something that isn't a key/value pair $uri = $uri->withQuery('details'); } if (isset($options['key'])) { $query['key'] = $options['key']; } if (isset($options['context'])) { $query['context'] = $options['context']; } if (!empty($query)) { if ($uri->getQuery() === '') { $uri = $uri->withQuery(\http_build_query($query)); } else { $uri = $uri->withQuery($uri->getQuery() . '&' . \http_build_query($query)); } } return $this->client->sendRequest($this->createRequest('GET', $uri)); }
[ "public", "function", "getStrings", "(", "string", "$", "project", ",", "string", "$", "resource", ",", "string", "$", "lang", ",", "bool", "$", "details", "=", "false", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ResponseInterface", "{", "...
Method to get the translation strings on a specified resource. @param string $project The slug for the project to pull from @param string $resource The slug for the resource to pull from @param string $lang The language to return the translation for @param bool $details Flag to retrieve additional details on the strings @param array $options An array of additional options for the request @return ResponseInterface
[ "Method", "to", "get", "the", "translation", "strings", "on", "a", "specified", "resource", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Translationstrings.php#L39-L71
train
techdivision/import-category
src/Subjects/BunchSubject.php
BunchSubject.getDisplayModeByValue
public function getDisplayModeByValue($displayMode) { // query whether or not, the requested display mode is available if (isset($this->availableDisplayModes[$displayMode])) { return $this->availableDisplayModes[$displayMode]; } // throw an exception, if not throw new \Exception(sprintf('Found invalid display mode %s', $displayMode)); }
php
public function getDisplayModeByValue($displayMode) { // query whether or not, the requested display mode is available if (isset($this->availableDisplayModes[$displayMode])) { return $this->availableDisplayModes[$displayMode]; } // throw an exception, if not throw new \Exception(sprintf('Found invalid display mode %s', $displayMode)); }
[ "public", "function", "getDisplayModeByValue", "(", "$", "displayMode", ")", "{", "// query whether or not, the requested display mode is available", "if", "(", "isset", "(", "$", "this", "->", "availableDisplayModes", "[", "$", "displayMode", "]", ")", ")", "{", "ret...
Return's the display mode for the passed display mode string. @param string $displayMode The display mode string to return the key for @return integer The requested display mode @throws \Exception Is thrown, if the requested display mode is not available
[ "Return", "s", "the", "display", "mode", "for", "the", "passed", "display", "mode", "string", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Subjects/BunchSubject.php#L146-L156
train
techdivision/import-category
src/Subjects/BunchSubject.php
BunchSubject.getPageLayoutByValue
public function getPageLayoutByValue($pageLayout) { // query whether or not, the requested display mode is available if (isset($this->availablePageLayouts[$pageLayout])) { return $this->availablePageLayouts[$pageLayout]; } // throw an exception, if not throw new \Exception(printf('Found invalid page layout %s', $pageLayout)); }
php
public function getPageLayoutByValue($pageLayout) { // query whether or not, the requested display mode is available if (isset($this->availablePageLayouts[$pageLayout])) { return $this->availablePageLayouts[$pageLayout]; } // throw an exception, if not throw new \Exception(printf('Found invalid page layout %s', $pageLayout)); }
[ "public", "function", "getPageLayoutByValue", "(", "$", "pageLayout", ")", "{", "// query whether or not, the requested display mode is available", "if", "(", "isset", "(", "$", "this", "->", "availablePageLayouts", "[", "$", "pageLayout", "]", ")", ")", "{", "return"...
Return's the page layout for the passed page layout string. @param string $pageLayout The page layout string to return the key for @return integer The requested page layout @throws \Exception Is thrown, if the requested page layout is not available
[ "Return", "s", "the", "page", "layout", "for", "the", "passed", "page", "layout", "string", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Subjects/BunchSubject.php#L166-L176
train
techdivision/import-category
src/Subjects/BunchSubject.php
BunchSubject.getRootCategoryStoreViewCodes
public function getRootCategoryStoreViewCodes($path) { // explode the path of the root category list ($rootCategoryPath, ) = explode('/', $path); // query whether or not a root category with the given path exists if ($rootCategory = $this->getCategoryByPath($rootCategoryPath)) { // initialize the array with the store view codes $storeViewCodes = array(); // try to assemble the store view codes by iterating over the available root categories foreach ($this->rootCategories as $storeViewCode => $category) { // query whether or not the entity ID of the root category matches if ((integer) $category[$this->getPrimaryKeyMemberName()] === (integer) $rootCategory[$this->getPrimaryKeyMemberName()]) { $storeViewCodes[] = $storeViewCode; } } // return the array with the store view codes return $storeViewCodes; } // throw an exception, if the root category is NOT available throw new \Exception(printf('Can\'t load root category "%s" for path "%s"', $rootCategoryPath, $path)); }
php
public function getRootCategoryStoreViewCodes($path) { // explode the path of the root category list ($rootCategoryPath, ) = explode('/', $path); // query whether or not a root category with the given path exists if ($rootCategory = $this->getCategoryByPath($rootCategoryPath)) { // initialize the array with the store view codes $storeViewCodes = array(); // try to assemble the store view codes by iterating over the available root categories foreach ($this->rootCategories as $storeViewCode => $category) { // query whether or not the entity ID of the root category matches if ((integer) $category[$this->getPrimaryKeyMemberName()] === (integer) $rootCategory[$this->getPrimaryKeyMemberName()]) { $storeViewCodes[] = $storeViewCode; } } // return the array with the store view codes return $storeViewCodes; } // throw an exception, if the root category is NOT available throw new \Exception(printf('Can\'t load root category "%s" for path "%s"', $rootCategoryPath, $path)); }
[ "public", "function", "getRootCategoryStoreViewCodes", "(", "$", "path", ")", "{", "// explode the path of the root category", "list", "(", "$", "rootCategoryPath", ",", ")", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";", "// query whether or not a root categ...
Returns the store view codes relevant to the category represented by the current row. @param string $path The path to return the root category's store view codes for @return array The store view codes for the given root category @throws \Exception Is thrown, if the root category of the passed path is NOT available
[ "Returns", "the", "store", "view", "codes", "relevant", "to", "the", "category", "represented", "by", "the", "current", "row", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Subjects/BunchSubject.php#L196-L221
train
hiqdev/hipanel-module-finance
src/cart/AbstractCartPosition.php
AbstractCartPosition.serializationMap
protected function serializationMap() { return [ 'attributes' => $this->getAttributes(), '_quantity' => $this->_quantity, '_price' => $this->_price, '_value' => $this->_value, '_id' => $this->_id, ]; }
php
protected function serializationMap() { return [ 'attributes' => $this->getAttributes(), '_quantity' => $this->_quantity, '_price' => $this->_price, '_value' => $this->_value, '_id' => $this->_id, ]; }
[ "protected", "function", "serializationMap", "(", ")", "{", "return", "[", "'attributes'", "=>", "$", "this", "->", "getAttributes", "(", ")", ",", "'_quantity'", "=>", "$", "this", "->", "_quantity", ",", "'_price'", "=>", "$", "this", "->", "_price", ","...
Method stores map of attributes that must be serialized. @return array key is the attribute name where the value should be extracted In case when the value shoule be assigned in a special way, use [[unserializationMap]] to map key to a closure, that will set the value @see unserializationMap
[ "Method", "stores", "map", "of", "attributes", "that", "must", "be", "serialized", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/cart/AbstractCartPosition.php#L188-L197
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Product/Standard.php
Standard.aggregate
protected function aggregate( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) { $view->data = $this->getController( $view )->sort() ->slice( $view->param( 'page/offset', 0 ), $view->param( 'page/limit', 10000 ) ) ->aggregate( $view->param( 'aggregate' ) ); return $response; }
php
protected function aggregate( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) { $view->data = $this->getController( $view )->sort() ->slice( $view->param( 'page/offset', 0 ), $view->param( 'page/limit', 10000 ) ) ->aggregate( $view->param( 'aggregate' ) ); return $response; }
[ "protected", "function", "aggregate", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ",", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "$", "view", "->", "data", "=", "$", "this"...
Counts the number of products for the requested key @param \Aimeos\MW\View\Iface $view View instance @param \Psr\Http\Message\ServerRequestInterface $request Request object @param \Psr\Http\Message\ResponseInterface $response Response object @return \Psr\Http\Message\ResponseInterface Modified response object
[ "Counts", "the", "number", "of", "products", "for", "the", "requested", "key" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Product/Standard.php#L202-L209
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Product/Standard.php
Standard.getController
protected function getController( \Aimeos\MW\View\Iface $view ) { $context = $this->getContext(); $cntl = \Aimeos\Controller\Frontend::create( $context, 'product' ); /** client/jsonapi/product/levels * Include products of sub-categories in the product list of the current category * * Sometimes it may be useful to show products of sub-categories in the * current category product list, e.g. if the current category contains * no products at all or if there are only a few products in all categories. * * Possible constant values for this setting are: * * 1 : Only products from the current category * * 2 : Products from the current category and the direct child categories * * 3 : Products from the current category and the whole category sub-tree * * Caution: Please keep in mind that displaying products of sub-categories * can slow down your shop, especially if it contains more than a few * products! You have no real control over the positions of the products * in the result list too because all products from different categories * with the same position value are placed randomly. * * Usually, a better way is to associate products to all categories they * should be listed in. This can be done manually if there are only a few * ones or during the product import automatically. * * @param integer Tree level constant * @since 2017.03 * @category Developer */ $level = $context->getConfig()->get( 'client/jsonapi/product/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); foreach( (array) $view->param( 'filter/f_oneid', [] ) as $list ) { $cntl->oneOf( $list ); } $cntl->allOf( $view->param( 'filter/f_attrid', [] ) ) ->oneOf( $view->param( 'filter/f_optid', [] ) ) ->text( $view->param( 'filter/f_search' ) ) ->supplier( $view->param( 'filter/f_supid', [] ), $view->param( 'filter/f_listtype', 'default' ) ) ->category( $view->param( 'filter/f_catid' ), $view->param( 'filter/f_listtype', 'default' ), $level ); $params = (array) $view->param( 'filter', [] ); unset( $params['f_supid'], $params['f_search'] ); unset( $params['f_catid'], $params['f_listtype'] ); unset( $params['f_attrid'], $params['f_optid'], $params['f_oneid'] ); return $cntl->parse( $params ) ->sort( $view->param( 'sort', 'relevance' ) ) ->slice( $view->param( 'page/offset', 0 ), $view->param( 'page/limit', 48 ) ); }
php
protected function getController( \Aimeos\MW\View\Iface $view ) { $context = $this->getContext(); $cntl = \Aimeos\Controller\Frontend::create( $context, 'product' ); /** client/jsonapi/product/levels * Include products of sub-categories in the product list of the current category * * Sometimes it may be useful to show products of sub-categories in the * current category product list, e.g. if the current category contains * no products at all or if there are only a few products in all categories. * * Possible constant values for this setting are: * * 1 : Only products from the current category * * 2 : Products from the current category and the direct child categories * * 3 : Products from the current category and the whole category sub-tree * * Caution: Please keep in mind that displaying products of sub-categories * can slow down your shop, especially if it contains more than a few * products! You have no real control over the positions of the products * in the result list too because all products from different categories * with the same position value are placed randomly. * * Usually, a better way is to associate products to all categories they * should be listed in. This can be done manually if there are only a few * ones or during the product import automatically. * * @param integer Tree level constant * @since 2017.03 * @category Developer */ $level = $context->getConfig()->get( 'client/jsonapi/product/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); foreach( (array) $view->param( 'filter/f_oneid', [] ) as $list ) { $cntl->oneOf( $list ); } $cntl->allOf( $view->param( 'filter/f_attrid', [] ) ) ->oneOf( $view->param( 'filter/f_optid', [] ) ) ->text( $view->param( 'filter/f_search' ) ) ->supplier( $view->param( 'filter/f_supid', [] ), $view->param( 'filter/f_listtype', 'default' ) ) ->category( $view->param( 'filter/f_catid' ), $view->param( 'filter/f_listtype', 'default' ), $level ); $params = (array) $view->param( 'filter', [] ); unset( $params['f_supid'], $params['f_search'] ); unset( $params['f_catid'], $params['f_listtype'] ); unset( $params['f_attrid'], $params['f_optid'], $params['f_oneid'] ); return $cntl->parse( $params ) ->sort( $view->param( 'sort', 'relevance' ) ) ->slice( $view->param( 'page/offset', 0 ), $view->param( 'page/limit', 48 ) ); }
[ "protected", "function", "getController", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "cntl", "=", "\\", "Aimeos", "\\", "Controller", ...
Returns the initialized product controller @param \Aimeos\MW\View\Iface $view View instance @return \Aimeos\Controller\Frontend\Product\Iface Initialized product controller
[ "Returns", "the", "initialized", "product", "controller" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Product/Standard.php#L218-L270
train
mmoreram/ControllerExtraBundle
Resolver/AnnotationResolver.php
AnnotationResolver.getParameterType
public function getParameterType( ReflectionMethod $method, string $parameterName, ? string $default = null ) : ? string { $parameters = $method->getParameters(); foreach ($parameters as $parameter) { if ($parameter->getName() === $parameterName) { $class = $parameter->getClass(); return $class ? $class->getName() : $default; } } return $default; }
php
public function getParameterType( ReflectionMethod $method, string $parameterName, ? string $default = null ) : ? string { $parameters = $method->getParameters(); foreach ($parameters as $parameter) { if ($parameter->getName() === $parameterName) { $class = $parameter->getClass(); return $class ? $class->getName() : $default; } } return $default; }
[ "public", "function", "getParameterType", "(", "ReflectionMethod", "$", "method", ",", "string", "$", "parameterName", ",", "?", "string", "$", "default", "=", "null", ")", ":", "?", "string", "{", "$", "parameters", "=", "$", "method", "->", "getParameters"...
Return parameter type. @param ReflectionMethod $method @param string $parameterName @param string|null $default @return string|null
[ "Return", "parameter", "type", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/AnnotationResolver.php#L37-L55
train
MetaModels/filter_perimetersearch
src/FilterHelper/ProviderInterface.php
ProviderInterface.getFullCountryName
public function getFullCountryName($shortTag) { $countries = $this->getCountries(); if (\array_key_exists($shortTag, $countries)) { return $countries[$shortTag]; } return null; }
php
public function getFullCountryName($shortTag) { $countries = $this->getCountries(); if (\array_key_exists($shortTag, $countries)) { return $countries[$shortTag]; } return null; }
[ "public", "function", "getFullCountryName", "(", "$", "shortTag", ")", "{", "$", "countries", "=", "$", "this", "->", "getCountries", "(", ")", ";", "if", "(", "\\", "array_key_exists", "(", "$", "shortTag", ",", "$", "countries", ")", ")", "{", "return"...
Search the full name of a country. @param string $shortTag The short tag for the country. @return null|string Null on error or the full name as string.
[ "Search", "the", "full", "name", "of", "a", "country", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterHelper/ProviderInterface.php#L51-L59
train
MetaModels/filter_perimetersearch
src/FilterHelper/ProviderInterface.php
ProviderInterface.getQueryString
public function getQueryString( $street = null, $postal = null, $city = null, $country = null, $fullAddress = null ) { // If we have a full address use it. if ($fullAddress) { // If there is a country try to use the long form. if ((null !== $country) && (null !== ($fullCountryName = $this->getFullCountryName($country)))) { return \sprintf('%s, %s', $fullAddress, $fullCountryName); } if (null !== $country) { // If there is no long form use it as is it. return \sprintf('%s, %s', $fullAddress, $country); } // Or just the full one. return $fullAddress; } // Try to solve the country. if ((null !== $country) && (null !== ($fullCountryName = $this->getFullCountryName($country)))) { $country = $fullCountryName; } return \sprintf( '%s, %s %s, %s', $street, $postal, $city, $country ); }
php
public function getQueryString( $street = null, $postal = null, $city = null, $country = null, $fullAddress = null ) { // If we have a full address use it. if ($fullAddress) { // If there is a country try to use the long form. if ((null !== $country) && (null !== ($fullCountryName = $this->getFullCountryName($country)))) { return \sprintf('%s, %s', $fullAddress, $fullCountryName); } if (null !== $country) { // If there is no long form use it as is it. return \sprintf('%s, %s', $fullAddress, $country); } // Or just the full one. return $fullAddress; } // Try to solve the country. if ((null !== $country) && (null !== ($fullCountryName = $this->getFullCountryName($country)))) { $country = $fullCountryName; } return \sprintf( '%s, %s %s, %s', $street, $postal, $city, $country ); }
[ "public", "function", "getQueryString", "(", "$", "street", "=", "null", ",", "$", "postal", "=", "null", ",", "$", "city", "=", "null", ",", "$", "country", "=", "null", ",", "$", "fullAddress", "=", "null", ")", "{", "// If we have a full address use it....
Build the query string. @param string $street The street. @param string $postal The postal code. @param string $city Name of city. @param string $country A 2-letter country code. @param string $fullAddress Address string without specific format. @return string
[ "Build", "the", "query", "string", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterHelper/ProviderInterface.php#L72-L107
train
mmoreram/ControllerExtraBundle
Provider/RequestParameterProvider.php
RequestParameterProvider.resolveValueFromParameterBag
protected function resolveValueFromParameterBag( ParameterBag $parameterBag, string $delimiter, string $value ) { $trimmedValue = trim($value, $delimiter); if ( ($delimiter . $trimmedValue . $delimiter === $value) && $parameterBag->has($trimmedValue) ) { $value = $parameterBag->get($trimmedValue); } return $value; }
php
protected function resolveValueFromParameterBag( ParameterBag $parameterBag, string $delimiter, string $value ) { $trimmedValue = trim($value, $delimiter); if ( ($delimiter . $trimmedValue . $delimiter === $value) && $parameterBag->has($trimmedValue) ) { $value = $parameterBag->get($trimmedValue); } return $value; }
[ "protected", "function", "resolveValueFromParameterBag", "(", "ParameterBag", "$", "parameterBag", ",", "string", "$", "delimiter", ",", "string", "$", "value", ")", "{", "$", "trimmedValue", "=", "trim", "(", "$", "value", ",", "$", "delimiter", ")", ";", "...
Given a bag and a delimiter, return the resolved value. @param ParameterBag $parameterBag @param string $delimiter @param string $value @return mixed
[ "Given", "a", "bag", "and", "a", "delimiter", "return", "the", "resolved", "value", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Provider/RequestParameterProvider.php#L124-L139
train
techdivision/import-category
src/Subjects/AbstractCategorySubject.php
AbstractCategorySubject.getRowStoreId
public function getRowStoreId($default = null) { // initialize the default store view code, if not passed if ($default == null) { $defaultStore = $this->getDefaultStore(); $default = $defaultStore[MemberNames::CODE]; } // load the store view code the create the product/attributes for $storeViewCode = $this->getStoreViewCode($default); // query whether or not, the requested store is available if (isset($this->stores[$storeViewCode])) { return (integer) $this->stores[$storeViewCode][MemberNames::STORE_ID]; } // throw an exception, if not throw new \Exception(sprintf('Found invalid store view code "%s"', $storeViewCode)); }
php
public function getRowStoreId($default = null) { // initialize the default store view code, if not passed if ($default == null) { $defaultStore = $this->getDefaultStore(); $default = $defaultStore[MemberNames::CODE]; } // load the store view code the create the product/attributes for $storeViewCode = $this->getStoreViewCode($default); // query whether or not, the requested store is available if (isset($this->stores[$storeViewCode])) { return (integer) $this->stores[$storeViewCode][MemberNames::STORE_ID]; } // throw an exception, if not throw new \Exception(sprintf('Found invalid store view code "%s"', $storeViewCode)); }
[ "public", "function", "getRowStoreId", "(", "$", "default", "=", "null", ")", "{", "// initialize the default store view code, if not passed", "if", "(", "$", "default", "==", "null", ")", "{", "$", "defaultStore", "=", "$", "this", "->", "getDefaultStore", "(", ...
Return's the store ID of the actual row, or of the default store if no store view code is set in the CSV file. @param string|null $default The default store view code to use, if no store view code is set in the CSV file @return integer The ID of the actual store @throws \Exception Is thrown, if the store with the actual code is not available
[ "Return", "s", "the", "store", "ID", "of", "the", "actual", "row", "or", "of", "the", "default", "store", "if", "no", "store", "view", "code", "is", "set", "in", "the", "CSV", "file", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Subjects/AbstractCategorySubject.php#L349-L368
train
techdivision/import-category
src/Subjects/AbstractCategorySubject.php
AbstractCategorySubject.getStoreWebsiteIdByCode
public function getStoreWebsiteIdByCode($code) { // query whether or not, the requested store website is available if (isset($this->storeWebsites[$code])) { return (integer) $this->storeWebsites[$code][MemberNames::WEBSITE_ID]; } // throw an exception, if not throw new \Exception(sprintf('Found invalid website code "%s"', $code)); }
php
public function getStoreWebsiteIdByCode($code) { // query whether or not, the requested store website is available if (isset($this->storeWebsites[$code])) { return (integer) $this->storeWebsites[$code][MemberNames::WEBSITE_ID]; } // throw an exception, if not throw new \Exception(sprintf('Found invalid website code "%s"', $code)); }
[ "public", "function", "getStoreWebsiteIdByCode", "(", "$", "code", ")", "{", "// query whether or not, the requested store website is available", "if", "(", "isset", "(", "$", "this", "->", "storeWebsites", "[", "$", "code", "]", ")", ")", "{", "return", "(", "int...
Return's the store website for the passed code. @param string $code The code of the store website to return the ID for @return integer The store website ID @throws \Exception Is thrown, if the store website with the requested code is not available
[ "Return", "s", "the", "store", "website", "for", "the", "passed", "code", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Subjects/AbstractCategorySubject.php#L378-L388
train
techdivision/import-category
src/Subjects/AbstractCategorySubject.php
AbstractCategorySubject.updateCategory
public function updateCategory($path, $category) { $this->categories[$path] = array_merge($this->categories[$path], $category); }
php
public function updateCategory($path, $category) { $this->categories[$path] = array_merge($this->categories[$path], $category); }
[ "public", "function", "updateCategory", "(", "$", "path", ",", "$", "category", ")", "{", "$", "this", "->", "categories", "[", "$", "path", "]", "=", "array_merge", "(", "$", "this", "->", "categories", "[", "$", "path", "]", ",", "$", "category", "...
Updates the category with the passed path. @param string $path The path of the category to update @param array $category The category data to update @return void @deprecated Since 7.0.0
[ "Updates", "the", "category", "with", "the", "passed", "path", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Subjects/AbstractCategorySubject.php#L435-L438
train
techdivision/import-category
src/Plugins/ChildrenCountPlugin.php
ChildrenCountPlugin.process
public function process() { // load all available categories $categories = $this->getImportProcessor()->getCategories(); // update the categories children count foreach ($categories as $category) { // load the category itself $this->category = $this->loadCategory($pk = $this->getPrimaryKey($category)); // update the category's children count $this->persistCategory($this->initializeCategory($this->prepareAttributes())); // write a log message $this->getSystemLogger()->debug( sprintf('Successfully updated category with primary key %d', $pk) ); } }
php
public function process() { // load all available categories $categories = $this->getImportProcessor()->getCategories(); // update the categories children count foreach ($categories as $category) { // load the category itself $this->category = $this->loadCategory($pk = $this->getPrimaryKey($category)); // update the category's children count $this->persistCategory($this->initializeCategory($this->prepareAttributes())); // write a log message $this->getSystemLogger()->debug( sprintf('Successfully updated category with primary key %d', $pk) ); } }
[ "public", "function", "process", "(", ")", "{", "// load all available categories", "$", "categories", "=", "$", "this", "->", "getImportProcessor", "(", ")", "->", "getCategories", "(", ")", ";", "// update the categories children count", "foreach", "(", "$", "cate...
Process the plugin functionality. @return void @throws \Exception Is thrown, if the plugin can not be processed
[ "Process", "the", "plugin", "functionality", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Plugins/ChildrenCountPlugin.php#L70-L89
train
mmoreram/ControllerExtraBundle
Resolver/PaginatorAnnotationResolver.php
PaginatorAnnotationResolver.createQueryBuilder
private function createQueryBuilder(string $entityNamespace) : QueryBuilder { return $this ->doctrine ->getManagerForClass($entityNamespace) ->createQueryBuilder() ->select(['x']) ->from($entityNamespace, 'x'); }
php
private function createQueryBuilder(string $entityNamespace) : QueryBuilder { return $this ->doctrine ->getManagerForClass($entityNamespace) ->createQueryBuilder() ->select(['x']) ->from($entityNamespace, 'x'); }
[ "private", "function", "createQueryBuilder", "(", "string", "$", "entityNamespace", ")", ":", "QueryBuilder", "{", "return", "$", "this", "->", "doctrine", "->", "getManagerForClass", "(", "$", "entityNamespace", ")", "->", "createQueryBuilder", "(", ")", "->", ...
Generate QueryBuilder. @param string $entityNamespace @return QueryBuilder
[ "Generate", "QueryBuilder", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/PaginatorAnnotationResolver.php#L250-L258
train
mmoreram/ControllerExtraBundle
Resolver/PaginatorAnnotationResolver.php
PaginatorAnnotationResolver.evaluateAttributes
private function evaluateAttributes( Request $request, CreatePaginator $annotation, DoctrinePaginator $paginator, int $limitPerPage, int $page ) { if ($annotation->getAttributes()) { $total = $paginator->count(); $paginatorAttributes = new PaginatorAttributes( (int) ceil($total / $limitPerPage), $total, $page, $limitPerPage ); $request->attributes->set( trim($annotation->getAttributes()), $paginatorAttributes ); } }
php
private function evaluateAttributes( Request $request, CreatePaginator $annotation, DoctrinePaginator $paginator, int $limitPerPage, int $page ) { if ($annotation->getAttributes()) { $total = $paginator->count(); $paginatorAttributes = new PaginatorAttributes( (int) ceil($total / $limitPerPage), $total, $page, $limitPerPage ); $request->attributes->set( trim($annotation->getAttributes()), $paginatorAttributes ); } }
[ "private", "function", "evaluateAttributes", "(", "Request", "$", "request", ",", "CreatePaginator", "$", "annotation", ",", "DoctrinePaginator", "$", "paginator", ",", "int", "$", "limitPerPage", ",", "int", "$", "page", ")", "{", "if", "(", "$", "annotation"...
Evaluates Paginator attributes. @param Request $request @param CreatePaginator $annotation @param DoctrinePaginator $paginator @param int $limitPerPage @param int $page
[ "Evaluates", "Paginator", "attributes", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/PaginatorAnnotationResolver.php#L269-L290
train
mmoreram/ControllerExtraBundle
Resolver/PaginatorAnnotationResolver.php
PaginatorAnnotationResolver.decidePaginatorFormat
private function decidePaginatorFormat( DoctrinePaginator $paginator, string $parameterType, int $limitPerPage, int $page ) { if (Pagerfanta::class === $parameterType) { $paginator = new Pagerfanta(new DoctrineORMAdapter($paginator->getQuery())); $paginator->setMaxPerPage($limitPerPage); $paginator->setCurrentPage($page); } if (PaginationInterface::class === $parameterType) { $knp = new KnpPaginator(); $paginator = $knp->paginate($paginator->getQuery(), $page, $limitPerPage); } return $paginator; }
php
private function decidePaginatorFormat( DoctrinePaginator $paginator, string $parameterType, int $limitPerPage, int $page ) { if (Pagerfanta::class === $parameterType) { $paginator = new Pagerfanta(new DoctrineORMAdapter($paginator->getQuery())); $paginator->setMaxPerPage($limitPerPage); $paginator->setCurrentPage($page); } if (PaginationInterface::class === $parameterType) { $knp = new KnpPaginator(); $paginator = $knp->paginate($paginator->getQuery(), $page, $limitPerPage); } return $paginator; }
[ "private", "function", "decidePaginatorFormat", "(", "DoctrinePaginator", "$", "paginator", ",", "string", "$", "parameterType", ",", "int", "$", "limitPerPage", ",", "int", "$", "page", ")", "{", "if", "(", "Pagerfanta", "::", "class", "===", "$", "parameterT...
Return real usable Paginator instance given the definition type. @param DoctrinePaginator $paginator @param string $parameterType @param int $limitPerPage @param int $page @return mixed
[ "Return", "real", "usable", "Paginator", "instance", "given", "the", "definition", "type", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/PaginatorAnnotationResolver.php#L302-L319
train
techdivision/import-category
src/Repositories/CategoryRepository.php
CategoryRepository.countChildren
public function countChildren($path) { // load and return the category with the passed path $this->categoryCountChildrenStmt->execute(array(MemberNames::PATH => $path)); return $this->categoryCountChildrenStmt->fetchColumn(); }
php
public function countChildren($path) { // load and return the category with the passed path $this->categoryCountChildrenStmt->execute(array(MemberNames::PATH => $path)); return $this->categoryCountChildrenStmt->fetchColumn(); }
[ "public", "function", "countChildren", "(", "$", "path", ")", "{", "// load and return the category with the passed path", "$", "this", "->", "categoryCountChildrenStmt", "->", "execute", "(", "array", "(", "MemberNames", "::", "PATH", "=>", "$", "path", ")", ")", ...
Return's the children count of the category with the passed path. @param string $path The path of the category to count the children for @return integer The children count of the category with the passed path
[ "Return", "s", "the", "children", "count", "of", "the", "category", "with", "the", "passed", "path", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Repositories/CategoryRepository.php#L114-L119
train
QoboLtd/cakephp-search
src/Utility/Validator.php
Validator.validateData
public static function validateData(RepositoryInterface $table, array $data, array $user): array { $fields = Utility::instance()->getSearchableFields($table, $user); $fields = array_keys($fields); // merge default options $data += Options::getDefaults($table); if (!empty($data['criteria'])) { $data['criteria'] = static::validateCriteria($data['criteria'], $fields); } $data['display_columns'] = static::validateDisplayColumns($data['display_columns'], $fields); $data['sort_by_field'] = static::validateSortByField( $data['sort_by_field'], $fields, $data['display_columns'], $table ); $data['sort_by_order'] = static::validateSortByOrder($data['sort_by_order']); $data['aggregator'] = static::validateAggregator($data['aggregator']); return $data; }
php
public static function validateData(RepositoryInterface $table, array $data, array $user): array { $fields = Utility::instance()->getSearchableFields($table, $user); $fields = array_keys($fields); // merge default options $data += Options::getDefaults($table); if (!empty($data['criteria'])) { $data['criteria'] = static::validateCriteria($data['criteria'], $fields); } $data['display_columns'] = static::validateDisplayColumns($data['display_columns'], $fields); $data['sort_by_field'] = static::validateSortByField( $data['sort_by_field'], $fields, $data['display_columns'], $table ); $data['sort_by_order'] = static::validateSortByOrder($data['sort_by_order']); $data['aggregator'] = static::validateAggregator($data['aggregator']); return $data; }
[ "public", "static", "function", "validateData", "(", "RepositoryInterface", "$", "table", ",", "array", "$", "data", ",", "array", "$", "user", ")", ":", "array", "{", "$", "fields", "=", "Utility", "::", "instance", "(", ")", "->", "getSearchableFields", ...
Base search data validation method. Retrieves current searchable table columns, validates and filters criteria, display columns and sort by field against them. Then validates sort by order againt available options and sets it to the default option if they fail validation. @param \Cake\Datasource\RepositoryInterface $table Table instace @param mixed[] $data Search data @param mixed[] $user User info @return mixed[]
[ "Base", "search", "data", "validation", "method", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Validator.php#L40-L63
train
QoboLtd/cakephp-search
src/Utility/Validator.php
Validator.validateCriteria
protected static function validateCriteria(array $data, array $fields): array { foreach (array_keys($data) as $key) { if (in_array($key, $fields)) { continue; } unset($data[$key]); } return $data; }
php
protected static function validateCriteria(array $data, array $fields): array { foreach (array_keys($data) as $key) { if (in_array($key, $fields)) { continue; } unset($data[$key]); } return $data; }
[ "protected", "static", "function", "validateCriteria", "(", "array", "$", "data", ",", "array", "$", "fields", ")", ":", "array", "{", "foreach", "(", "array_keys", "(", "$", "data", ")", "as", "$", "key", ")", "{", "if", "(", "in_array", "(", "$", "...
Validate search criteria. @param mixed[] $data Criteria values @param mixed[] $fields Searchable fields @return mixed[]
[ "Validate", "search", "criteria", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Validator.php#L72-L82
train
QoboLtd/cakephp-search
src/Utility/Validator.php
Validator.validateSortByField
protected static function validateSortByField(string $data, array $fields, array $displayColumns, RepositoryInterface $table): string { /** @var \Cake\ORM\Table */ $table = $table; // use sort field if is searchable if (in_array($data, $fields)) { return $data; } // set display field as sort field $data = $table->getDisplayField(); // check if display field exists in the database table if ($table->getSchema()->getColumn($data)) { return $table->aliasField($data); } // use first display column which exists in the database table foreach ($displayColumns as $displayColumn) { // remove table prefix list(, $displayColumn) = explode('.', $displayColumn); if (!$table->getSchema()->getColumn($displayColumn)) { continue; } return $table->aliasField($displayColumn); } // use primary key as a last resort return $table->aliasField(current((array)$table->getPrimaryKey())); }
php
protected static function validateSortByField(string $data, array $fields, array $displayColumns, RepositoryInterface $table): string { /** @var \Cake\ORM\Table */ $table = $table; // use sort field if is searchable if (in_array($data, $fields)) { return $data; } // set display field as sort field $data = $table->getDisplayField(); // check if display field exists in the database table if ($table->getSchema()->getColumn($data)) { return $table->aliasField($data); } // use first display column which exists in the database table foreach ($displayColumns as $displayColumn) { // remove table prefix list(, $displayColumn) = explode('.', $displayColumn); if (!$table->getSchema()->getColumn($displayColumn)) { continue; } return $table->aliasField($displayColumn); } // use primary key as a last resort return $table->aliasField(current((array)$table->getPrimaryKey())); }
[ "protected", "static", "function", "validateSortByField", "(", "string", "$", "data", ",", "array", "$", "fields", ",", "array", "$", "displayColumns", ",", "RepositoryInterface", "$", "table", ")", ":", "string", "{", "/** @var \\Cake\\ORM\\Table */", "$", "table...
Validate search sort by field. @param string $data Sort by field value @param mixed[] $fields Searchable fields @param mixed[] $displayColumns Display columns @param \Cake\Datasource\RepositoryInterface $table Table instance @return string
[ "Validate", "search", "sort", "by", "field", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Validator.php#L112-L142
train
QoboLtd/cakephp-search
src/Utility/Validator.php
Validator.validateSortByOrder
protected static function validateSortByOrder(string $data): string { $options = array_keys(Options::getSortByOrders()); if (!in_array($data, $options)) { $data = Options::DEFAULT_SORT_BY_ORDER; } return $data; }
php
protected static function validateSortByOrder(string $data): string { $options = array_keys(Options::getSortByOrders()); if (!in_array($data, $options)) { $data = Options::DEFAULT_SORT_BY_ORDER; } return $data; }
[ "protected", "static", "function", "validateSortByOrder", "(", "string", "$", "data", ")", ":", "string", "{", "$", "options", "=", "array_keys", "(", "Options", "::", "getSortByOrders", "(", ")", ")", ";", "if", "(", "!", "in_array", "(", "$", "data", "...
Validate search sort by order. @param string $data Sort by order value @return string
[ "Validate", "search", "sort", "by", "order", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Validator.php#L150-L158
train
QoboLtd/cakephp-search
src/Utility/Validator.php
Validator.validateAggregator
protected static function validateAggregator(string $data): string { $options = array_keys(Options::getAggregators()); if (!in_array($data, $options)) { $data = Options::DEFAULT_AGGREGATOR; } return $data; }
php
protected static function validateAggregator(string $data): string { $options = array_keys(Options::getAggregators()); if (!in_array($data, $options)) { $data = Options::DEFAULT_AGGREGATOR; } return $data; }
[ "protected", "static", "function", "validateAggregator", "(", "string", "$", "data", ")", ":", "string", "{", "$", "options", "=", "array_keys", "(", "Options", "::", "getAggregators", "(", ")", ")", ";", "if", "(", "!", "in_array", "(", "$", "data", ","...
Validate search aggregator. @param string $data Aggregator value @return string
[ "Validate", "search", "aggregator", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Validator.php#L166-L174
train
BabDev/Transifex-API
src/ApiFactory.php
ApiFactory.createApiConnector
public function createApiConnector(string $name, array $options = []): ApiConnector { $namespace = __NAMESPACE__ . '\\Connector'; $class = $namespace . '\\' . \ucfirst(\strtolower($name)); if (\class_exists($class)) { return new $class($this->client, $this->requestFactory, $this->streamFactory, $this->uriFactory, $options); } // No class found, sorry! throw new Exception\UnknownApiConnectorException("Could not find an API object for '$name'."); }
php
public function createApiConnector(string $name, array $options = []): ApiConnector { $namespace = __NAMESPACE__ . '\\Connector'; $class = $namespace . '\\' . \ucfirst(\strtolower($name)); if (\class_exists($class)) { return new $class($this->client, $this->requestFactory, $this->streamFactory, $this->uriFactory, $options); } // No class found, sorry! throw new Exception\UnknownApiConnectorException("Could not find an API object for '$name'."); }
[ "public", "function", "createApiConnector", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ApiConnector", "{", "$", "namespace", "=", "__NAMESPACE__", ".", "'\\\\Connector'", ";", "$", "class", "=", "$", "namespace", "....
Factory method to create API connectors. @param string $name Name of the API connector to retrieve @param array $options API connector options @return ApiConnector @throws Exception\UnknownApiConnectorException
[ "Factory", "method", "to", "create", "API", "connectors", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/ApiFactory.php#L71-L82
train
QoboLtd/cakephp-search
src/Widgets/SavedSearchWidget.php
SavedSearchWidget.getResults
public function getResults(array $options = []) : ?SavedSearch { $this->setContainerId($options['entity']); $table = TableRegistry::get('Search.SavedSearches'); /** @var \Search\Model\Entity\SavedSearch|null */ $savedSearch = $table->find() ->where(['id' => $this->widget->get('widget_id')]) ->enableHydration(true) ->first(); if (null === $savedSearch) { $this->errors[] = 'No data found for this entity'; return null; } /** @var \Cake\Datasource\RepositoryInterface */ $table = TableRegistry::get($savedSearch->get('model')); $search = new Search($table, $options['user']); // keeps backward compatibility $entity = $search->reset($savedSearch); if (null === $entity) { $this->errors[] = 'Failed to reset entity'; return null; } $content = $entity->get('content'); $content['saved'] = Validator::validateData($table, $content['saved'], $options['user']); $entity->set('content', $content); $this->options['fields'] = Utility::instance()->getSearchableFields($table, $options['user']); $this->options['associationLabels'] = Utility::instance()->getAssociationLabels($table); $this->data = $entity; return $this->data; }
php
public function getResults(array $options = []) : ?SavedSearch { $this->setContainerId($options['entity']); $table = TableRegistry::get('Search.SavedSearches'); /** @var \Search\Model\Entity\SavedSearch|null */ $savedSearch = $table->find() ->where(['id' => $this->widget->get('widget_id')]) ->enableHydration(true) ->first(); if (null === $savedSearch) { $this->errors[] = 'No data found for this entity'; return null; } /** @var \Cake\Datasource\RepositoryInterface */ $table = TableRegistry::get($savedSearch->get('model')); $search = new Search($table, $options['user']); // keeps backward compatibility $entity = $search->reset($savedSearch); if (null === $entity) { $this->errors[] = 'Failed to reset entity'; return null; } $content = $entity->get('content'); $content['saved'] = Validator::validateData($table, $content['saved'], $options['user']); $entity->set('content', $content); $this->options['fields'] = Utility::instance()->getSearchableFields($table, $options['user']); $this->options['associationLabels'] = Utility::instance()->getAssociationLabels($table); $this->data = $entity; return $this->data; }
[ "public", "function", "getResults", "(", "array", "$", "options", "=", "[", "]", ")", ":", "?", "SavedSearch", "{", "$", "this", "->", "setContainerId", "(", "$", "options", "[", "'entity'", "]", ")", ";", "$", "table", "=", "TableRegistry", "::", "get...
Retrieve SavedSearch results for the widget @param array $options containing entity and view params. @return \Search\Model\Entity\SavedSearch|null
[ "Retrieve", "SavedSearch", "results", "for", "the", "widget" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Widgets/SavedSearchWidget.php#L87-L126
train
QoboLtd/cakephp-search
src/Widgets/SavedSearchWidget.php
SavedSearchWidget.setContainerId
public function setContainerId(EntityInterface $entity) : void { $this->containerId = self::TABLE_PREFIX . md5($entity->id); }
php
public function setContainerId(EntityInterface $entity) : void { $this->containerId = self::TABLE_PREFIX . md5($entity->id); }
[ "public", "function", "setContainerId", "(", "EntityInterface", "$", "entity", ")", ":", "void", "{", "$", "this", "->", "containerId", "=", "self", "::", "TABLE_PREFIX", ".", "md5", "(", "$", "entity", "->", "id", ")", ";", "}" ]
setContainerId method. Setting unique identifier of the widget. @param \Cake\Datasource\EntityInterface $entity used for setting id of widget. @return void
[ "setContainerId", "method", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Widgets/SavedSearchWidget.php#L136-L139
train
hiqdev/hipanel-module-finance
src/providers/BillTypesProvider.php
BillTypesProvider.getTypes
public function getTypes() { $options = ['select' => 'full', 'orderby' => 'name_asc', 'with_hierarchy' => true]; $types = Ref::findCached('type,bill', 'hipanel:finance', $options); if (!$this->app->user->can('support')) { $types = $this->removeUnusedTypes($types); } return $types; }
php
public function getTypes() { $options = ['select' => 'full', 'orderby' => 'name_asc', 'with_hierarchy' => true]; $types = Ref::findCached('type,bill', 'hipanel:finance', $options); if (!$this->app->user->can('support')) { $types = $this->removeUnusedTypes($types); } return $types; }
[ "public", "function", "getTypes", "(", ")", "{", "$", "options", "=", "[", "'select'", "=>", "'full'", ",", "'orderby'", "=>", "'name_asc'", ",", "'with_hierarchy'", "=>", "true", "]", ";", "$", "types", "=", "Ref", "::", "findCached", "(", "'type,bill'", ...
Returns array of types. When user can not support, filters out unused types. @return Ref[]
[ "Returns", "array", "of", "types", ".", "When", "user", "can", "not", "support", "filters", "out", "unused", "types", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/providers/BillTypesProvider.php#L49-L59
train
mmoreram/ControllerExtraBundle
Resolver/Paginator/PaginatorWheresEvaluator.php
PaginatorWheresEvaluator.addWildcards
private function addWildcards( string $annotationWhereParameter, string $whereValue ) : string { if (substr($annotationWhereParameter, 0, 1) === '%') { $whereValue = '%' . $whereValue; } if (substr($annotationWhereParameter, -1, 1) === '%') { $whereValue = $whereValue . '%'; } return $whereValue; }
php
private function addWildcards( string $annotationWhereParameter, string $whereValue ) : string { if (substr($annotationWhereParameter, 0, 1) === '%') { $whereValue = '%' . $whereValue; } if (substr($annotationWhereParameter, -1, 1) === '%') { $whereValue = $whereValue . '%'; } return $whereValue; }
[ "private", "function", "addWildcards", "(", "string", "$", "annotationWhereParameter", ",", "string", "$", "whereValue", ")", ":", "string", "{", "if", "(", "substr", "(", "$", "annotationWhereParameter", ",", "0", ",", "1", ")", "===", "'%'", ")", "{", "$...
Add wildcards to query if necessary. @param string $annotationWhereParameter @param string $whereValue @return string
[ "Add", "wildcards", "to", "query", "if", "necessary", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/Paginator/PaginatorWheresEvaluator.php#L111-L124
train
techdivision/import-category
src/Assembler/CategoryAttributeAssembler.php
CategoryAttributeAssembler.getCategoryAttributesByPrimaryKeyAndStoreIdExtendedWithAttributeCode
public function getCategoryAttributesByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) { // initialize the array for the attributes $attributes = array(); // load the datetime attributes foreach ($this->categoryDatetimeRepository->findAllByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) as $attribute) { $attributes[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute; } // load the decimal attributes foreach ($this->categoryDecimalRepository->findAllByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) as $attribute) { $attributes[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute; } // load the integer attributes foreach ($this->categoryIntRepository->findAllByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) as $attribute) { $attributes[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute; } // load the text attributes foreach ($this->categoryTextRepository->findAllByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) as $attribute) { $attributes[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute; } // load the varchar attributes foreach ($this->categoryVarcharRepository->findAllByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) as $attribute) { $attributes[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute; } // return the array with the attributes return $attributes; }
php
public function getCategoryAttributesByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) { // initialize the array for the attributes $attributes = array(); // load the datetime attributes foreach ($this->categoryDatetimeRepository->findAllByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) as $attribute) { $attributes[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute; } // load the decimal attributes foreach ($this->categoryDecimalRepository->findAllByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) as $attribute) { $attributes[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute; } // load the integer attributes foreach ($this->categoryIntRepository->findAllByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) as $attribute) { $attributes[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute; } // load the text attributes foreach ($this->categoryTextRepository->findAllByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) as $attribute) { $attributes[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute; } // load the varchar attributes foreach ($this->categoryVarcharRepository->findAllByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId) as $attribute) { $attributes[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute; } // return the array with the attributes return $attributes; }
[ "public", "function", "getCategoryAttributesByPrimaryKeyAndStoreIdExtendedWithAttributeCode", "(", "$", "pk", ",", "$", "storeId", ")", "{", "// initialize the array for the attributes", "$", "attributes", "=", "array", "(", ")", ";", "// load the datetime attributes", "forea...
Intializes the existing attributes for the entity with the passed primary key, extended with their attribute code. @param string $pk The primary key of the entity to load the attributes for @param integer $storeId The ID of the store view to load the attributes for @return array The entity attributes
[ "Intializes", "the", "existing", "attributes", "for", "the", "entity", "with", "the", "passed", "primary", "key", "extended", "with", "their", "attribute", "code", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Assembler/CategoryAttributeAssembler.php#L151-L184
train
techdivision/import-category
src/Assembler/CategoryAssembler.php
CategoryAssembler.getCategoryByPkAndStoreId
public function getCategoryByPkAndStoreId($pk, $storeId) { // load the category with the passed path if ($category = $this->categoryRepository->load($pk)) { // load the category's attribute values for the passed PK and store ID $attributes = $this->categoryAttributeAssembler->getCategoryAttributesByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId); // assemble the category withe the attributes foreach ($attributes as $attribute) { $category[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute[MemberNames::VALUE]; } // return the category assembled with the values for the given store ID return $category; } }
php
public function getCategoryByPkAndStoreId($pk, $storeId) { // load the category with the passed path if ($category = $this->categoryRepository->load($pk)) { // load the category's attribute values for the passed PK and store ID $attributes = $this->categoryAttributeAssembler->getCategoryAttributesByPrimaryKeyAndStoreIdExtendedWithAttributeCode($pk, $storeId); // assemble the category withe the attributes foreach ($attributes as $attribute) { $category[$attribute[MemberNames::ATTRIBUTE_CODE]] = $attribute[MemberNames::VALUE]; } // return the category assembled with the values for the given store ID return $category; } }
[ "public", "function", "getCategoryByPkAndStoreId", "(", "$", "pk", ",", "$", "storeId", ")", "{", "// load the category with the passed path", "if", "(", "$", "category", "=", "$", "this", "->", "categoryRepository", "->", "load", "(", "$", "pk", ")", ")", "{"...
Returns the category with the passed primary key and the attribute values for the passed store ID. @param string $pk The primary key of the category to return @param integer $storeId The store ID of the category values @return array|null The category data
[ "Returns", "the", "category", "with", "the", "passed", "primary", "key", "and", "the", "attribute", "values", "for", "the", "passed", "store", "ID", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Assembler/CategoryAssembler.php#L74-L90
train
QoboLtd/cakephp-search
src/Widgets/ReportWidget.php
ReportWidget.getReports
public function getReports() : array { $event = new Event((string)EventName::MODEL_DASHBOARDS_GET_REPORTS()); EventManager::instance()->dispatch($event); return (array)$event->getResult(); }
php
public function getReports() : array { $event = new Event((string)EventName::MODEL_DASHBOARDS_GET_REPORTS()); EventManager::instance()->dispatch($event); return (array)$event->getResult(); }
[ "public", "function", "getReports", "(", ")", ":", "array", "{", "$", "event", "=", "new", "Event", "(", "(", "string", ")", "EventName", "::", "MODEL_DASHBOARDS_GET_REPORTS", "(", ")", ")", ";", "EventManager", "::", "instance", "(", ")", "->", "dispatch"...
Method retrieves all reports from ini files Basic reports getter that uses Events to get reports application-wise. @return mixed[] $result with reports array.
[ "Method", "retrieves", "all", "reports", "from", "ini", "files" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Widgets/ReportWidget.php#L120-L126
train
QoboLtd/cakephp-search
src/Widgets/ReportWidget.php
ReportWidget.getReport
public function getReport(array $options = []) : array { if (empty($options['entity'])) { return []; } if (empty($options['reports'])) { $options['reports'] = $this->getReports(); } $widgetId = $options['entity']->widget_id; if (empty($options['reports'])) { return []; } $result = []; foreach ($options['reports'] as $modelName => $reports) { foreach ($reports as $slug => $reportInfo) { if ($reportInfo['id'] !== $widgetId) { continue; } $result = ['modelName' => $modelName, 'slug' => $slug, 'info' => $reportInfo]; } } return $result; }
php
public function getReport(array $options = []) : array { if (empty($options['entity'])) { return []; } if (empty($options['reports'])) { $options['reports'] = $this->getReports(); } $widgetId = $options['entity']->widget_id; if (empty($options['reports'])) { return []; } $result = []; foreach ($options['reports'] as $modelName => $reports) { foreach ($reports as $slug => $reportInfo) { if ($reportInfo['id'] !== $widgetId) { continue; } $result = ['modelName' => $modelName, 'slug' => $slug, 'info' => $reportInfo]; } } return $result; }
[ "public", "function", "getReport", "(", "array", "$", "options", "=", "[", "]", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "options", "[", "'entity'", "]", ")", ")", "{", "return", "[", "]", ";", "}", "if", "(", "empty", "(", "$", "o...
Parses the config of the report for widgetHandler @param mixed[] $options with entity data. @return mixed[]
[ "Parses", "the", "config", "of", "the", "report", "for", "widgetHandler" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Widgets/ReportWidget.php#L134-L162
train
QoboLtd/cakephp-search
src/Widgets/ReportWidget.php
ReportWidget.getReportInstance
public function getReportInstance(array $options = []) : ?ReportGraphsInterface { if (empty($options['config'])) { $options['config'] = $this->getReport($options); } if (empty($options['config'])) { return null; } $renderAs = $options['config']['info']['renderAs']; if (empty($renderAs)) { return null; } $className = __NAMESPACE__ . '\\Reports\\' . Inflector::camelize($renderAs) . self::WIDGET_REPORT_SUFFIX; if (! class_exists($className)) { return null; } if (! in_array(__NAMESPACE__ . '\\Reports\\' . 'ReportGraphsInterface', class_implements($className))) { return null; } return new $className($options); }
php
public function getReportInstance(array $options = []) : ?ReportGraphsInterface { if (empty($options['config'])) { $options['config'] = $this->getReport($options); } if (empty($options['config'])) { return null; } $renderAs = $options['config']['info']['renderAs']; if (empty($renderAs)) { return null; } $className = __NAMESPACE__ . '\\Reports\\' . Inflector::camelize($renderAs) . self::WIDGET_REPORT_SUFFIX; if (! class_exists($className)) { return null; } if (! in_array(__NAMESPACE__ . '\\Reports\\' . 'ReportGraphsInterface', class_implements($className))) { return null; } return new $className($options); }
[ "public", "function", "getReportInstance", "(", "array", "$", "options", "=", "[", "]", ")", ":", "?", "ReportGraphsInterface", "{", "if", "(", "empty", "(", "$", "options", "[", "'config'", "]", ")", ")", "{", "$", "options", "[", "'config'", "]", "="...
Initialize Report instance ReportWidgetHandler operates via $_instance variable that we set based on the renderAs parameter of the report. @param mixed[] $options containing reports @return \Search\Widgets\Reports\ReportGraphsInterface|null
[ "Initialize", "Report", "instance" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Widgets/ReportWidget.php#L173-L198
train
QoboLtd/cakephp-search
src/Widgets/ReportWidget.php
ReportWidget.getResults
public function getResults(array $options = []) : array { $this->_instance = $this->getReportInstance($options); if (null === $this->_instance) { return []; } $config = $this->getReport($options); if (empty($config)) { return []; } $this->setConfig($config); $this->setContainerId($config); $validated = $this->validate($config); if (! $validated['status']) { throw new RuntimeException("Report validation failed"); } $result = $this->getQueryData($config); if (!empty($result)) { $this->_instance->getChartData($result); $this->setOptions(['scripts' => $this->_instance->getScripts()]); } return $result; }
php
public function getResults(array $options = []) : array { $this->_instance = $this->getReportInstance($options); if (null === $this->_instance) { return []; } $config = $this->getReport($options); if (empty($config)) { return []; } $this->setConfig($config); $this->setContainerId($config); $validated = $this->validate($config); if (! $validated['status']) { throw new RuntimeException("Report validation failed"); } $result = $this->getQueryData($config); if (!empty($result)) { $this->_instance->getChartData($result); $this->setOptions(['scripts' => $this->_instance->getScripts()]); } return $result; }
[ "public", "function", "getResults", "(", "array", "$", "options", "=", "[", "]", ")", ":", "array", "{", "$", "this", "->", "_instance", "=", "$", "this", "->", "getReportInstance", "(", "$", "options", ")", ";", "if", "(", "null", "===", "$", "this"...
Assembles results data for the report Establish report data for the widgetHandler. @param mixed[] $options with entity and view data. @throws \RuntimeException @return mixed[] $result containing $_data.
[ "Assembles", "results", "data", "for", "the", "report" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Widgets/ReportWidget.php#L209-L238
train
QoboLtd/cakephp-search
src/Widgets/ReportWidget.php
ReportWidget.getQueryData
public function getQueryData(array $config = []) : array { if (empty($config)) { return []; } $resultSet = []; if (!empty($config['info']['finder'])) { $table = $config['info']['model']; $finder = $config['info']['finder']['name']; $options = Hash::get($config, 'info.finder.options', []); $resultSet = TableRegistry::get($table)->find($finder, $options); } if (empty($config['info']['finder']) && !empty($config['info']['query'])) { $resultSet = ConnectionManager::get('default') ->execute($config['info']['query']) ->fetchAll('assoc'); } $columns = explode(',', $config['info']['columns']); $result = []; foreach ($resultSet as $item) { $row = []; foreach ($item as $column => $value) { if (in_array($column, $columns)) { $row[$column] = $value; } } array_push($result, $row); } return $result; }
php
public function getQueryData(array $config = []) : array { if (empty($config)) { return []; } $resultSet = []; if (!empty($config['info']['finder'])) { $table = $config['info']['model']; $finder = $config['info']['finder']['name']; $options = Hash::get($config, 'info.finder.options', []); $resultSet = TableRegistry::get($table)->find($finder, $options); } if (empty($config['info']['finder']) && !empty($config['info']['query'])) { $resultSet = ConnectionManager::get('default') ->execute($config['info']['query']) ->fetchAll('assoc'); } $columns = explode(',', $config['info']['columns']); $result = []; foreach ($resultSet as $item) { $row = []; foreach ($item as $column => $value) { if (in_array($column, $columns)) { $row[$column] = $value; } } array_push($result, $row); } return $result; }
[ "public", "function", "getQueryData", "(", "array", "$", "config", "=", "[", "]", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "config", ")", ")", "{", "return", "[", "]", ";", "}", "$", "resultSet", "=", "[", "]", ";", "if", "(", "!",...
Retrieve Query data for the report Executes Query statement from the report.ini to retrieve actual report resultSet. @param mixed[] $config of the report.ini @return mixed[] $result containing required resultset fields.
[ "Retrieve", "Query", "data", "for", "the", "report" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Widgets/ReportWidget.php#L249-L286
train
TYPO3-CMS/redirects
Classes/Service/RedirectService.php
RedirectService.resolveLinkDetailsFromLinkTarget
protected function resolveLinkDetailsFromLinkTarget(string $redirectTarget): array { // build the target URL, take force SSL into account etc. $linkService = GeneralUtility::makeInstance(LinkService::class); try { $linkDetails = $linkService->resolve($redirectTarget); switch ($linkDetails['type']) { case LinkService::TYPE_URL: // all set up, nothing to do break; case LinkService::TYPE_FILE: /** @var File $file */ $file = $linkDetails['file']; if ($file instanceof File) { $linkDetails['url'] = $file->getPublicUrl(); } break; case LinkService::TYPE_FOLDER: /** @var Folder $folder */ $folder = $linkDetails['folder']; if ($folder instanceof Folder) { $linkDetails['url'] = $folder->getPublicUrl(); } break; default: // we have to return the link details without having a "URL" parameter } } catch (InvalidPathException $e) { return []; } return $linkDetails; }
php
protected function resolveLinkDetailsFromLinkTarget(string $redirectTarget): array { // build the target URL, take force SSL into account etc. $linkService = GeneralUtility::makeInstance(LinkService::class); try { $linkDetails = $linkService->resolve($redirectTarget); switch ($linkDetails['type']) { case LinkService::TYPE_URL: // all set up, nothing to do break; case LinkService::TYPE_FILE: /** @var File $file */ $file = $linkDetails['file']; if ($file instanceof File) { $linkDetails['url'] = $file->getPublicUrl(); } break; case LinkService::TYPE_FOLDER: /** @var Folder $folder */ $folder = $linkDetails['folder']; if ($folder instanceof Folder) { $linkDetails['url'] = $folder->getPublicUrl(); } break; default: // we have to return the link details without having a "URL" parameter } } catch (InvalidPathException $e) { return []; } return $linkDetails; }
[ "protected", "function", "resolveLinkDetailsFromLinkTarget", "(", "string", "$", "redirectTarget", ")", ":", "array", "{", "// build the target URL, take force SSL into account etc.", "$", "linkService", "=", "GeneralUtility", "::", "makeInstance", "(", "LinkService", "::", ...
Check if the current request is actually a redirect, and then process the redirect. @param string $redirectTarget @return array the link details from the linkService
[ "Check", "if", "the", "current", "request", "is", "actually", "a", "redirect", "and", "then", "process", "the", "redirect", "." ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Service/RedirectService.php#L131-L163
train
TYPO3-CMS/redirects
Classes/Service/RedirectService.php
RedirectService.addQueryParams
protected function addQueryParams(array $queryParams, Uri $url): Uri { // New query parameters overrule the ones that should be kept $newQueryParamString = $url->getQuery(); if (!empty($newQueryParamString)) { $newQueryParams = []; parse_str($newQueryParamString, $newQueryParams); $queryParams = array_replace_recursive($queryParams, $newQueryParams); } $query = http_build_query($queryParams, '', '&', PHP_QUERY_RFC3986); if ($query) { $url = $url->withQuery($query); } return $url; }
php
protected function addQueryParams(array $queryParams, Uri $url): Uri { // New query parameters overrule the ones that should be kept $newQueryParamString = $url->getQuery(); if (!empty($newQueryParamString)) { $newQueryParams = []; parse_str($newQueryParamString, $newQueryParams); $queryParams = array_replace_recursive($queryParams, $newQueryParams); } $query = http_build_query($queryParams, '', '&', PHP_QUERY_RFC3986); if ($query) { $url = $url->withQuery($query); } return $url; }
[ "protected", "function", "addQueryParams", "(", "array", "$", "queryParams", ",", "Uri", "$", "url", ")", ":", "Uri", "{", "// New query parameters overrule the ones that should be kept", "$", "newQueryParamString", "=", "$", "url", "->", "getQuery", "(", ")", ";", ...
Adds query parameters to a Uri object @param array $queryParams @param Uri $url @return Uri
[ "Adds", "query", "parameters", "to", "a", "Uri", "object" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Service/RedirectService.php#L200-L214
train
TYPO3-CMS/redirects
Classes/Service/RedirectService.php
RedirectService.bootFrontendController
protected function bootFrontendController(?SiteInterface $site, array $queryParams): TypoScriptFrontendController { // disable page errors $GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling'] = false; $controller = GeneralUtility::makeInstance( TypoScriptFrontendController::class, null, $site ? $site->getRootPageId() : $GLOBALS['TSFE']->id, 0 ); $controller->fe_user = $GLOBALS['TSFE']->fe_user ?? null; $controller->fetch_the_id(); $controller->calculateLinkVars($queryParams); $controller->getConfigArray(); $controller->settingLanguage(); $controller->settingLocale(); $controller->newCObj(); return $controller; }
php
protected function bootFrontendController(?SiteInterface $site, array $queryParams): TypoScriptFrontendController { // disable page errors $GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling'] = false; $controller = GeneralUtility::makeInstance( TypoScriptFrontendController::class, null, $site ? $site->getRootPageId() : $GLOBALS['TSFE']->id, 0 ); $controller->fe_user = $GLOBALS['TSFE']->fe_user ?? null; $controller->fetch_the_id(); $controller->calculateLinkVars($queryParams); $controller->getConfigArray(); $controller->settingLanguage(); $controller->settingLocale(); $controller->newCObj(); return $controller; }
[ "protected", "function", "bootFrontendController", "(", "?", "SiteInterface", "$", "site", ",", "array", "$", "queryParams", ")", ":", "TypoScriptFrontendController", "{", "// disable page errors", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'FE'", "]", "["...
Finishing booting up TSFE, after that the following properties are available. Instantiating is done by the middleware stack (see Configuration/RequestMiddlewares.php) - TSFE->fe_user - TSFE->sys_page - TSFE->tmpl - TSFE->config - TSFE->cObj So a link to a page can be generated. @param SiteInterface|null $site @param array $queryParams @return TypoScriptFrontendController
[ "Finishing", "booting", "up", "TSFE", "after", "that", "the", "following", "properties", "are", "available", "." ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Service/RedirectService.php#L272-L290
train
hiqdev/hipanel-module-finance
src/forms/AbstractTariffForm.php
AbstractTariffForm.setDefaultTariff
protected function setDefaultTariff() { if (!$this->setTariff($this->parentTariff)) { return false; } // Default tariff's id and name are useless on create $this->id = null; $this->name = null; return true; }
php
protected function setDefaultTariff() { if (!$this->setTariff($this->parentTariff)) { return false; } // Default tariff's id and name are useless on create $this->id = null; $this->name = null; return true; }
[ "protected", "function", "setDefaultTariff", "(", ")", "{", "if", "(", "!", "$", "this", "->", "setTariff", "(", "$", "this", "->", "parentTariff", ")", ")", "{", "return", "false", ";", "}", "// Default tariff's id and name are useless on create", "$", "this", ...
Sets default tariff. @return bool success
[ "Sets", "default", "tariff", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/forms/AbstractTariffForm.php#L96-L107
train
QoboLtd/cakephp-search
src/Shell/SearchShell.php
SearchShell.cleanup
public function cleanup(string $time = self::DEFAULT_MAX_LENGTH) : void { $table = $this->loadModel('Search.SavedSearches'); $date = strtotime($time); if (false === $date) { $this->err(sprintf('Failed to remove pre-saved searches, unsupported time value provided: %s', $time)); return; } $count = $table->deleteAll([ 'modified <' => $date, 'OR' => ['name' => '', 'name IS' => null] ]); $this->info($count . ' outdated pre-saved searches removed.'); }
php
public function cleanup(string $time = self::DEFAULT_MAX_LENGTH) : void { $table = $this->loadModel('Search.SavedSearches'); $date = strtotime($time); if (false === $date) { $this->err(sprintf('Failed to remove pre-saved searches, unsupported time value provided: %s', $time)); return; } $count = $table->deleteAll([ 'modified <' => $date, 'OR' => ['name' => '', 'name IS' => null] ]); $this->info($count . ' outdated pre-saved searches removed.'); }
[ "public", "function", "cleanup", "(", "string", "$", "time", "=", "self", "::", "DEFAULT_MAX_LENGTH", ")", ":", "void", "{", "$", "table", "=", "$", "this", "->", "loadModel", "(", "'Search.SavedSearches'", ")", ";", "$", "date", "=", "strtotime", "(", "...
Method responsible for outdated pre-saved searches cleanup. @param string $time A date/time string. Valid formats are explained in http://php.net/manual/en/datetime.formats.php @return void
[ "Method", "responsible", "for", "outdated", "pre", "-", "saved", "searches", "cleanup", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Shell/SearchShell.php#L43-L61
train
hiqdev/hipanel-module-finance
src/models/Price.php
Price.getUnitOptions
public function getUnitOptions() { $unitGroup = [ 'speed' => ['bps', 'kbps', 'mbps', 'gbps', 'tbps'], 'size' => ['mb', 'mb10', 'mb100', 'gb', 'tb'], ]; $availableUnitsByPriceType = [ 'overuse,ip_num' => ['items'], 'overuse,support_time' => ['hour'], 'overuse,backup_du' => $unitGroup['size'], 'overuse,server_traf_max' => $unitGroup['size'], 'overuse,server_traf95_max' => $unitGroup['speed'], 'overuse,server_du' => $unitGroup['size'], 'overuse,server_ssd' => $unitGroup['size'], 'overuse,server_sata' => $unitGroup['size'], 'overuse,backup_traf' => $unitGroup['size'], 'overuse,domain_traf' => $unitGroup['size'], 'overuse,domain_num' => ['items'], 'overuse,ip_traf_max' => $unitGroup['size'], 'overuse,account_traf' => $unitGroup['size'], 'overuse,account_du' => $unitGroup['size'], 'overuse,mail_num' => ['items'], 'overuse,mail_du' => $unitGroup['size'], 'overuse,db_num' => ['items'], ]; $units = Ref::getList('type,unit', 'hipanel.finance.units', [ 'with_recursive' => 1, 'select' => 'oname_label', 'mapOptions' => ['from' => 'oname'], ]); $possibleTypes = $availableUnitsByPriceType[$this->type] ?? []; return array_intersect_key($units, array_combine($possibleTypes, $possibleTypes)); }
php
public function getUnitOptions() { $unitGroup = [ 'speed' => ['bps', 'kbps', 'mbps', 'gbps', 'tbps'], 'size' => ['mb', 'mb10', 'mb100', 'gb', 'tb'], ]; $availableUnitsByPriceType = [ 'overuse,ip_num' => ['items'], 'overuse,support_time' => ['hour'], 'overuse,backup_du' => $unitGroup['size'], 'overuse,server_traf_max' => $unitGroup['size'], 'overuse,server_traf95_max' => $unitGroup['speed'], 'overuse,server_du' => $unitGroup['size'], 'overuse,server_ssd' => $unitGroup['size'], 'overuse,server_sata' => $unitGroup['size'], 'overuse,backup_traf' => $unitGroup['size'], 'overuse,domain_traf' => $unitGroup['size'], 'overuse,domain_num' => ['items'], 'overuse,ip_traf_max' => $unitGroup['size'], 'overuse,account_traf' => $unitGroup['size'], 'overuse,account_du' => $unitGroup['size'], 'overuse,mail_num' => ['items'], 'overuse,mail_du' => $unitGroup['size'], 'overuse,db_num' => ['items'], ]; $units = Ref::getList('type,unit', 'hipanel.finance.units', [ 'with_recursive' => 1, 'select' => 'oname_label', 'mapOptions' => ['from' => 'oname'], ]); $possibleTypes = $availableUnitsByPriceType[$this->type] ?? []; return array_intersect_key($units, array_combine($possibleTypes, $possibleTypes)); }
[ "public", "function", "getUnitOptions", "(", ")", "{", "$", "unitGroup", "=", "[", "'speed'", "=>", "[", "'bps'", ",", "'kbps'", ",", "'mbps'", ",", "'gbps'", ",", "'tbps'", "]", ",", "'size'", "=>", "[", "'mb'", ",", "'mb10'", ",", "'mb100'", ",", "...
Returns array of unit option, that are available for this price depending on price type. @return array
[ "Returns", "array", "of", "unit", "option", "that", "are", "available", "for", "this", "price", "depending", "on", "price", "type", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/models/Price.php#L94-L130
train
hiqdev/hipanel-module-finance
src/models/Price.php
Price.isQuantityPredefined
public function isQuantityPredefined(): bool { if (!$this->isOveruse() && ($this->isShared() || $this->getSubtype() === 'rack_unit') ) { return false; } return true; }
php
public function isQuantityPredefined(): bool { if (!$this->isOveruse() && ($this->isShared() || $this->getSubtype() === 'rack_unit') ) { return false; } return true; }
[ "public", "function", "isQuantityPredefined", "(", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "isOveruse", "(", ")", "&&", "(", "$", "this", "->", "isShared", "(", ")", "||", "$", "this", "->", "getSubtype", "(", ")", "===", "'rack_uni...
Method checks, whether current price quantity is predefined and is not a result of sophisticated calculation on server side. @return bool
[ "Method", "checks", "whether", "current", "price", "quantity", "is", "predefined", "and", "is", "not", "a", "result", "of", "sophisticated", "calculation", "on", "server", "side", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/models/Price.php#L137-L146
train
techdivision/import-category
src/Observers/UrlRewriteUpdateObserver.php
UrlRewriteUpdateObserver.initializeUrlRewrite
protected function initializeUrlRewrite(array $attr) { // load store ID and request path $categoryId = $attr[MemberNames::ENTITY_ID]; $requestPath = $attr[MemberNames::REQUEST_PATH]; // iterate over the available URL rewrites to find the one that matches the category ID foreach ($this->existingUrlRewrites as $urlRewrite) { // compare the category IDs AND the request path if ($categoryId === $urlRewrite[MemberNames::ENTITY_ID] && $requestPath === $urlRewrite[MemberNames::REQUEST_PATH] ) { // if a URL rewrite has been found, do NOT create a redirect $this->removeExistingUrlRewrite($urlRewrite); // if the found URL rewrite has been created manually if ((integer) $urlRewrite[MemberNames::IS_AUTOGENERATED] === 0 && (integer) $urlRewrite[MemberNames::REDIRECT_TYPE] === 0) { // do NOT update it nor create a another redirect return false; } // if the found URL rewrite has been autogenerated, then update it return $this->mergeEntity($urlRewrite, $attr); } } // simple return the attributes return $attr; }
php
protected function initializeUrlRewrite(array $attr) { // load store ID and request path $categoryId = $attr[MemberNames::ENTITY_ID]; $requestPath = $attr[MemberNames::REQUEST_PATH]; // iterate over the available URL rewrites to find the one that matches the category ID foreach ($this->existingUrlRewrites as $urlRewrite) { // compare the category IDs AND the request path if ($categoryId === $urlRewrite[MemberNames::ENTITY_ID] && $requestPath === $urlRewrite[MemberNames::REQUEST_PATH] ) { // if a URL rewrite has been found, do NOT create a redirect $this->removeExistingUrlRewrite($urlRewrite); // if the found URL rewrite has been created manually if ((integer) $urlRewrite[MemberNames::IS_AUTOGENERATED] === 0 && (integer) $urlRewrite[MemberNames::REDIRECT_TYPE] === 0) { // do NOT update it nor create a another redirect return false; } // if the found URL rewrite has been autogenerated, then update it return $this->mergeEntity($urlRewrite, $attr); } } // simple return the attributes return $attr; }
[ "protected", "function", "initializeUrlRewrite", "(", "array", "$", "attr", ")", "{", "// load store ID and request path", "$", "categoryId", "=", "$", "attr", "[", "MemberNames", "::", "ENTITY_ID", "]", ";", "$", "requestPath", "=", "$", "attr", "[", "MemberNam...
Initialize the URL rewrite with the passed attributes and returns an instance. @param array $attr The URL rewrite attributes @return array The initialized URL rewrite
[ "Initialize", "the", "URL", "rewrite", "with", "the", "passed", "attributes", "and", "returns", "an", "instance", "." ]
6e4dfba08c69fd051587cbdeb92c9a9606d956ee
https://github.com/techdivision/import-category/blob/6e4dfba08c69fd051587cbdeb92c9a9606d956ee/src/Observers/UrlRewriteUpdateObserver.php#L183-L212
train
hiqdev/hipanel-module-finance
src/widgets/PayButtonComment.php
PayButtonComment.renderComment
protected function renderComment() { $merchant = $this->getMerchantName(); if (($view = $this->getCommentView($merchant)) === null) { return ''; } return $this->render($view, [ 'merchant' => $merchant, 'widget' => $this, 'event' => $this->event, ]); }
php
protected function renderComment() { $merchant = $this->getMerchantName(); if (($view = $this->getCommentView($merchant)) === null) { return ''; } return $this->render($view, [ 'merchant' => $merchant, 'widget' => $this, 'event' => $this->event, ]); }
[ "protected", "function", "renderComment", "(", ")", "{", "$", "merchant", "=", "$", "this", "->", "getMerchantName", "(", ")", ";", "if", "(", "(", "$", "view", "=", "$", "this", "->", "getCommentView", "(", "$", "merchant", ")", ")", "===", "null", ...
Method renders comment from the view, specified in. @return string
[ "Method", "renders", "comment", "from", "the", "view", "specified", "in", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/widgets/PayButtonComment.php#L92-L105
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.display
public function display(array $options, View $view): void { $this->validateOptions($options); $this->set('cakeView', $view); $this->set('isBatch', $this->batch); $this->set('isGroup', (bool)$this->getGroupByField()); $this->set('isSystem', (bool)$this->entity->get('system')); $this->set('isExport', $this->getExport()); $this->set('viewOptions', $this->getViewOptions()); $this->set('tableOptions', [ 'id' => $this->getTableId(), 'headers' => $this->getTableHeaders() ]); $this->set('dtOptions', $this->getDatatableOptions()); $this->set('chartOptions', $this->getChartOptions()); }
php
public function display(array $options, View $view): void { $this->validateOptions($options); $this->set('cakeView', $view); $this->set('isBatch', $this->batch); $this->set('isGroup', (bool)$this->getGroupByField()); $this->set('isSystem', (bool)$this->entity->get('system')); $this->set('isExport', $this->getExport()); $this->set('viewOptions', $this->getViewOptions()); $this->set('tableOptions', [ 'id' => $this->getTableId(), 'headers' => $this->getTableHeaders() ]); $this->set('dtOptions', $this->getDatatableOptions()); $this->set('chartOptions', $this->getChartOptions()); }
[ "public", "function", "display", "(", "array", "$", "options", ",", "View", "$", "view", ")", ":", "void", "{", "$", "this", "->", "validateOptions", "(", "$", "options", ")", ";", "$", "this", "->", "set", "(", "'cakeView'", ",", "$", "view", ")", ...
Cell display method. @param mixed[] $options Search options @param \Cake\View\View $view View instance @return void
[ "Cell", "display", "method", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L107-L123
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.validateOptions
private function validateOptions(array $options): void { foreach ($this->requiredOptions as $name) { if (!array_key_exists($name, $options)) { throw new InvalidArgumentException(sprintf('Required parameter "%s" is missing.', $name)); } $this->{$name} = $options[$name]; } }
php
private function validateOptions(array $options): void { foreach ($this->requiredOptions as $name) { if (!array_key_exists($name, $options)) { throw new InvalidArgumentException(sprintf('Required parameter "%s" is missing.', $name)); } $this->{$name} = $options[$name]; } }
[ "private", "function", "validateOptions", "(", "array", "$", "options", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "requiredOptions", "as", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "options", ...
Validates required options and sets them as class properties. @param mixed[] $options Search options @return void
[ "Validates", "required", "options", "and", "sets", "them", "as", "class", "properties", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L131-L140
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.getTableId
private function getTableId(): string { if ('' === $this->tableId) { $this->tableId = 'table-datatable-' . md5($this->preSaveId); } return $this->tableId; }
php
private function getTableId(): string { if ('' === $this->tableId) { $this->tableId = 'table-datatable-' . md5($this->preSaveId); } return $this->tableId; }
[ "private", "function", "getTableId", "(", ")", ":", "string", "{", "if", "(", "''", "===", "$", "this", "->", "tableId", ")", "{", "$", "this", "->", "tableId", "=", "'table-datatable-'", ".", "md5", "(", "$", "this", "->", "preSaveId", ")", ";", "}"...
Html table id getter. @return string
[ "Html", "table", "id", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L147-L154
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.getGroupByField
private function getGroupByField(): string { if ('' === $this->groupByField) { $this->groupByField = ! empty($this->searchData['group_by']) ? $this->searchData['group_by'] : ''; } return $this->groupByField; }
php
private function getGroupByField(): string { if ('' === $this->groupByField) { $this->groupByField = ! empty($this->searchData['group_by']) ? $this->searchData['group_by'] : ''; } return $this->groupByField; }
[ "private", "function", "getGroupByField", "(", ")", ":", "string", "{", "if", "(", "''", "===", "$", "this", "->", "groupByField", ")", "{", "$", "this", "->", "groupByField", "=", "!", "empty", "(", "$", "this", "->", "searchData", "[", "'group_by'", ...
Group field getter. @return string
[ "Group", "field", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L161-L168
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.getExport
private function getExport(): bool { if (false === $this->export) { $this->export = (bool)Configure::read('Search.dashboardExport'); } return $this->export; }
php
private function getExport(): bool { if (false === $this->export) { $this->export = (bool)Configure::read('Search.dashboardExport'); } return $this->export; }
[ "private", "function", "getExport", "(", ")", ":", "bool", "{", "if", "(", "false", "===", "$", "this", "->", "export", ")", "{", "$", "this", "->", "export", "=", "(", "bool", ")", "Configure", "::", "read", "(", "'Search.dashboardExport'", ")", ";", ...
Export status getter. @return bool
[ "Export", "status", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L175-L182
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.getViewOptions
private function getViewOptions(): array { // search url if is a saved one list($plugin, $controller) = pluginSplit($this->entity->get('model')); $title = $this->entity->has('name') ? $this->entity->get('name') : $controller; $url = ['plugin' => $plugin, 'controller' => $controller, 'action' => 'search', $this->entity->get('id')]; $result = ['title' => $title, 'url' => $url]; if ($this->getExport()) { $result['exportUrl'] = Router::url([ 'plugin' => $plugin, 'controller' => $controller, 'action' => 'export-search', $this->entity->get('id'), $this->entity->get('name') ]); } return $result; }
php
private function getViewOptions(): array { // search url if is a saved one list($plugin, $controller) = pluginSplit($this->entity->get('model')); $title = $this->entity->has('name') ? $this->entity->get('name') : $controller; $url = ['plugin' => $plugin, 'controller' => $controller, 'action' => 'search', $this->entity->get('id')]; $result = ['title' => $title, 'url' => $url]; if ($this->getExport()) { $result['exportUrl'] = Router::url([ 'plugin' => $plugin, 'controller' => $controller, 'action' => 'export-search', $this->entity->get('id'), $this->entity->get('name') ]); } return $result; }
[ "private", "function", "getViewOptions", "(", ")", ":", "array", "{", "// search url if is a saved one", "list", "(", "$", "plugin", ",", "$", "controller", ")", "=", "pluginSplit", "(", "$", "this", "->", "entity", "->", "get", "(", "'model'", ")", ")", "...
View options getter. @return mixed[]
[ "View", "options", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L189-L210
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.getTableHeaders
private function getTableHeaders(): array { $result = []; foreach ($this->getDisplayColumns() as $column) { $label = $column; if (array_key_exists($label, $this->searchableFields)) { $label = $this->searchableFields[$label]['label']; } list($fieldModel, ) = pluginSplit($column); if (array_key_exists($fieldModel, $this->associationLabels)) { $label .= ' (' . $this->associationLabels[$fieldModel] . ')'; } $result[] = $label; } return $result; }
php
private function getTableHeaders(): array { $result = []; foreach ($this->getDisplayColumns() as $column) { $label = $column; if (array_key_exists($label, $this->searchableFields)) { $label = $this->searchableFields[$label]['label']; } list($fieldModel, ) = pluginSplit($column); if (array_key_exists($fieldModel, $this->associationLabels)) { $label .= ' (' . $this->associationLabels[$fieldModel] . ')'; } $result[] = $label; } return $result; }
[ "private", "function", "getTableHeaders", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getDisplayColumns", "(", ")", "as", "$", "column", ")", "{", "$", "label", "=", "$", "column", ";", "if", ...
Html table headers getter. @return mixed[]
[ "Html", "table", "headers", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L217-L235
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.getDatatableOptions
private function getDatatableOptions(): array { list($plugin, $controller) = pluginSplit($this->entity->get('model')); $result = [ 'table_id' => '#' . $this->getTableId(), 'order' => [$this->getOrderField(), $this->getOrderDirection()], 'ajax' => [ 'url' => Router::url([ 'plugin' => $plugin, 'controller' => $controller, 'action' => $this->action, $this->preSaveId ]), 'columns' => $this->getDatatableColumns(), 'extras' => ['format' => 'pretty'] ], ]; if (! $this->getGroupByField() && $this->batch) { $result['batch'] = ['id' => Configure::read('Search.batch.button_id')]; } return $result; }
php
private function getDatatableOptions(): array { list($plugin, $controller) = pluginSplit($this->entity->get('model')); $result = [ 'table_id' => '#' . $this->getTableId(), 'order' => [$this->getOrderField(), $this->getOrderDirection()], 'ajax' => [ 'url' => Router::url([ 'plugin' => $plugin, 'controller' => $controller, 'action' => $this->action, $this->preSaveId ]), 'columns' => $this->getDatatableColumns(), 'extras' => ['format' => 'pretty'] ], ]; if (! $this->getGroupByField() && $this->batch) { $result['batch'] = ['id' => Configure::read('Search.batch.button_id')]; } return $result; }
[ "private", "function", "getDatatableOptions", "(", ")", ":", "array", "{", "list", "(", "$", "plugin", ",", "$", "controller", ")", "=", "pluginSplit", "(", "$", "this", "->", "entity", "->", "get", "(", "'model'", ")", ")", ";", "$", "result", "=", ...
DataTable options getter. @return mixed[]
[ "DataTable", "options", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L242-L266
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.getChartOptions
private function getChartOptions(): array { $groupByField = $this->getGroupByField(); if (!$groupByField) { return []; } list($plugin, $controller) = pluginSplit($this->entity->get('model')); list($prefix, $fieldName) = pluginSplit($groupByField); $result = []; foreach ($this->charts as $chart) { $result[] = [ 'chart' => $chart['type'], 'icon' => $chart['icon'], 'id' => Inflector::delimit($chart['type']) . '_' . $this->getTableId(), 'ajax' => [ 'url' => Router::url([ 'plugin' => $plugin, 'controller' => $controller, 'action' => 'search', $this->entity->get('id') ]), 'format' => 'pretty', ], 'options' => [ 'resize' => true, 'hideHover' => true, 'labels' => [Inflector::humanize(Search::GROUP_BY_FIELD), Inflector::humanize($fieldName)], 'xkey' => [$groupByField], 'ykeys' => [$prefix . '.' . Search::GROUP_BY_FIELD] ] ]; } return $result; }
php
private function getChartOptions(): array { $groupByField = $this->getGroupByField(); if (!$groupByField) { return []; } list($plugin, $controller) = pluginSplit($this->entity->get('model')); list($prefix, $fieldName) = pluginSplit($groupByField); $result = []; foreach ($this->charts as $chart) { $result[] = [ 'chart' => $chart['type'], 'icon' => $chart['icon'], 'id' => Inflector::delimit($chart['type']) . '_' . $this->getTableId(), 'ajax' => [ 'url' => Router::url([ 'plugin' => $plugin, 'controller' => $controller, 'action' => 'search', $this->entity->get('id') ]), 'format' => 'pretty', ], 'options' => [ 'resize' => true, 'hideHover' => true, 'labels' => [Inflector::humanize(Search::GROUP_BY_FIELD), Inflector::humanize($fieldName)], 'xkey' => [$groupByField], 'ykeys' => [$prefix . '.' . Search::GROUP_BY_FIELD] ] ]; } return $result; }
[ "private", "function", "getChartOptions", "(", ")", ":", "array", "{", "$", "groupByField", "=", "$", "this", "->", "getGroupByField", "(", ")", ";", "if", "(", "!", "$", "groupByField", ")", "{", "return", "[", "]", ";", "}", "list", "(", "$", "plug...
Chart options getter. @return mixed[]
[ "Chart", "options", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L273-L309
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.getOrderField
private function getOrderField(): int { $result = (int)array_search($this->searchData['sort_by_field'], $this->getDisplayColumns()); if ($this->batch && !$this->getGroupByField()) { $result += 1; } return $result; }
php
private function getOrderField(): int { $result = (int)array_search($this->searchData['sort_by_field'], $this->getDisplayColumns()); if ($this->batch && !$this->getGroupByField()) { $result += 1; } return $result; }
[ "private", "function", "getOrderField", "(", ")", ":", "int", "{", "$", "result", "=", "(", "int", ")", "array_search", "(", "$", "this", "->", "searchData", "[", "'sort_by_field'", "]", ",", "$", "this", "->", "getDisplayColumns", "(", ")", ")", ";", ...
Sort column getter. @return int
[ "Sort", "column", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L316-L325
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.getOrderDirection
private function getOrderDirection(): string { $result = !empty($this->searchData['sort_by_order']) ? $this->searchData['sort_by_order'] : Options::DEFAULT_SORT_BY_ORDER; return $result; }
php
private function getOrderDirection(): string { $result = !empty($this->searchData['sort_by_order']) ? $this->searchData['sort_by_order'] : Options::DEFAULT_SORT_BY_ORDER; return $result; }
[ "private", "function", "getOrderDirection", "(", ")", ":", "string", "{", "$", "result", "=", "!", "empty", "(", "$", "this", "->", "searchData", "[", "'sort_by_order'", "]", ")", "?", "$", "this", "->", "searchData", "[", "'sort_by_order'", "]", ":", "O...
Sort direction getter. @return string
[ "Sort", "direction", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L332-L339
train
QoboLtd/cakephp-search
src/View/Cell/ResultCell.php
ResultCell.getDatatableColumns
private function getDatatableColumns(): array { $result = $this->getDisplayColumns(); if (!$this->getGroupByField()) { $result[] = Utility::MENU_PROPERTY_NAME; } if (!$this->getGroupByField() && $this->batch) { $table = TableRegistry::get($this->entity->get('model')); // add primary key in FIRST position foreach ((array)$table->getPrimaryKey() as $primaryKey) { array_unshift($result, $table->aliasField($primaryKey)); } } return $result; }
php
private function getDatatableColumns(): array { $result = $this->getDisplayColumns(); if (!$this->getGroupByField()) { $result[] = Utility::MENU_PROPERTY_NAME; } if (!$this->getGroupByField() && $this->batch) { $table = TableRegistry::get($this->entity->get('model')); // add primary key in FIRST position foreach ((array)$table->getPrimaryKey() as $primaryKey) { array_unshift($result, $table->aliasField($primaryKey)); } } return $result; }
[ "private", "function", "getDatatableColumns", "(", ")", ":", "array", "{", "$", "result", "=", "$", "this", "->", "getDisplayColumns", "(", ")", ";", "if", "(", "!", "$", "this", "->", "getGroupByField", "(", ")", ")", "{", "$", "result", "[", "]", "...
DataTable columns getter. @return mixed[]
[ "DataTable", "columns", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L346-L363
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Base.php
Base.defaultAction
protected function defaultAction( ServerRequestInterface $request, ResponseInterface $response ) { $status = 403; $view = $this->getView(); $view->errors = array( array( 'title' => $this->getContext()->getI18n()->dt( 'client/jsonapi', 'Not allowed for this resource' ), ) ); /** client/jsonapi/standard/template-error * Relative path to the default JSON API template * * The template file contains the code and processing instructions * to generate the result shown in the JSON API body. The * configuration string is the path to the template file relative * to the templates directory (usually in client/jsonapi/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 "standard" 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, "standard" * should be replaced by the name of the new class. * * @param string Relative path to the template creating the body for the JSON API response * @since 2017.02 * @category Developer * @see client/jsonapi/standard/template-delete * @see client/jsonapi/standard/template-patch * @see client/jsonapi/standard/template-post * @see client/jsonapi/standard/template-get * @see client/jsonapi/standard/template-options */ $tplconf = 'client/jsonapi/standard/template-error'; $default = 'error-standard'; $body = $view->render( $view->config( $tplconf, $default ) ); return $response->withHeader( 'Content-Type', 'application/vnd.api+json' ) ->withBody( $view->response()->createStreamFromString( $body ) ) ->withStatus( $status ); }
php
protected function defaultAction( ServerRequestInterface $request, ResponseInterface $response ) { $status = 403; $view = $this->getView(); $view->errors = array( array( 'title' => $this->getContext()->getI18n()->dt( 'client/jsonapi', 'Not allowed for this resource' ), ) ); /** client/jsonapi/standard/template-error * Relative path to the default JSON API template * * The template file contains the code and processing instructions * to generate the result shown in the JSON API body. The * configuration string is the path to the template file relative * to the templates directory (usually in client/jsonapi/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 "standard" 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, "standard" * should be replaced by the name of the new class. * * @param string Relative path to the template creating the body for the JSON API response * @since 2017.02 * @category Developer * @see client/jsonapi/standard/template-delete * @see client/jsonapi/standard/template-patch * @see client/jsonapi/standard/template-post * @see client/jsonapi/standard/template-get * @see client/jsonapi/standard/template-options */ $tplconf = 'client/jsonapi/standard/template-error'; $default = 'error-standard'; $body = $view->render( $view->config( $tplconf, $default ) ); return $response->withHeader( 'Content-Type', 'application/vnd.api+json' ) ->withBody( $view->response()->createStreamFromString( $body ) ) ->withStatus( $status ); }
[ "protected", "function", "defaultAction", "(", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "$", "status", "=", "403", ";", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "$", "view", "->", ...
Returns the default response for the resource @param \Psr\Http\Message\ServerRequestInterface $request Request object @param \Psr\Http\Message\ResponseInterface $response Response object @return \Psr\Http\Message\ResponseInterface Modified response object
[ "Returns", "the", "default", "response", "for", "the", "resource" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Base.php#L169-L210
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Base.php
Base.getErrorDetails
protected function getErrorDetails( \Exception $e, $domain = null ) { $details = []; if( $domain !== null ) { $details['title'] = $this->context->getI18n()->dt( $domain, $e->getMessage() ); } else { $details['title'] = $e->getMessage(); } /** client/jsonapi/debug * Send debug information withing responses to clients if an error occurrs * * By default, the Aimeos client JSON REST API won't send any details * besides the error message to the client if an error occurred. This * prevents leaking sensitive information to attackers. For debugging * your requests it's helpful to see the stack strace. If you set this * configuration option to true, the stack trace will be returned too. * * @param boolean True to return the stack trace in JSON response, false for error message only * @since 2017.07 * @category Developer */ if( $this->context->getConfig()->get( 'client/jsonapi/debug', false ) == true ) { $details['detail'] = $e->getTraceAsString(); } return [$details]; // jsonapi.org requires a list of error objects }
php
protected function getErrorDetails( \Exception $e, $domain = null ) { $details = []; if( $domain !== null ) { $details['title'] = $this->context->getI18n()->dt( $domain, $e->getMessage() ); } else { $details['title'] = $e->getMessage(); } /** client/jsonapi/debug * Send debug information withing responses to clients if an error occurrs * * By default, the Aimeos client JSON REST API won't send any details * besides the error message to the client if an error occurred. This * prevents leaking sensitive information to attackers. For debugging * your requests it's helpful to see the stack strace. If you set this * configuration option to true, the stack trace will be returned too. * * @param boolean True to return the stack trace in JSON response, false for error message only * @since 2017.07 * @category Developer */ if( $this->context->getConfig()->get( 'client/jsonapi/debug', false ) == true ) { $details['detail'] = $e->getTraceAsString(); } return [$details]; // jsonapi.org requires a list of error objects }
[ "protected", "function", "getErrorDetails", "(", "\\", "Exception", "$", "e", ",", "$", "domain", "=", "null", ")", "{", "$", "details", "=", "[", "]", ";", "if", "(", "$", "domain", "!==", "null", ")", "{", "$", "details", "[", "'title'", "]", "="...
Returns the translated title and the details of the error @param \Exception $e Thrown exception @param string|null $domain Translation domain @return array Associative list with "title" and "detail" key (if debug config is enabled)
[ "Returns", "the", "translated", "title", "and", "the", "details", "of", "the", "error" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Base.php#L231-L259
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Base.php
Base.getOptionsResponse
public function getOptionsResponse( ServerRequestInterface $request, ResponseInterface $response, $allow ) { $view = $this->getView(); $tplconf = 'client/jsonapi/standard/template-options'; $default = 'options-standard'; $body = $view->render( $view->config( $tplconf, $default ) ); return $response->withHeader( 'Allow', $allow ) ->withHeader( 'Cache-Control', 'max-age=300' ) ->withHeader( 'Content-Type', 'application/vnd.api+json' ) ->withBody( $view->response()->createStreamFromString( $body ) ) ->withStatus( 200 ); }
php
public function getOptionsResponse( ServerRequestInterface $request, ResponseInterface $response, $allow ) { $view = $this->getView(); $tplconf = 'client/jsonapi/standard/template-options'; $default = 'options-standard'; $body = $view->render( $view->config( $tplconf, $default ) ); return $response->withHeader( 'Allow', $allow ) ->withHeader( 'Cache-Control', 'max-age=300' ) ->withHeader( 'Content-Type', 'application/vnd.api+json' ) ->withBody( $view->response()->createStreamFromString( $body ) ) ->withStatus( 200 ); }
[ "public", "function", "getOptionsResponse", "(", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ",", "$", "allow", ")", "{", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "$", "tplconf", "=", "'client/js...
Returns the available REST verbs and the available parameters @param \Psr\Http\Message\ServerRequestInterface $request Request object @param \Psr\Http\Message\ResponseInterface $response Response object @param string $allow Allowed HTTP methods @return \Psr\Http\Message\ResponseInterface Modified response object
[ "Returns", "the", "available", "REST", "verbs", "and", "the", "available", "parameters" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Base.php#L363-L377
train
hiqdev/hipanel-module-finance
src/cart/storage/CartStorageFactory.php
CartStorageFactory.forUser
public static function forUser(User $user) { if ($user->getIsGuest()) { return Yii::$app->session; } return Yii::createObject(['class' => RemoteCartStorage::class, 'sessionCartId' => 'yz\shoppingcart\ShoppingCart']); }
php
public static function forUser(User $user) { if ($user->getIsGuest()) { return Yii::$app->session; } return Yii::createObject(['class' => RemoteCartStorage::class, 'sessionCartId' => 'yz\shoppingcart\ShoppingCart']); }
[ "public", "static", "function", "forUser", "(", "User", "$", "user", ")", "{", "if", "(", "$", "user", "->", "getIsGuest", "(", ")", ")", "{", "return", "Yii", "::", "$", "app", "->", "session", ";", "}", "return", "Yii", "::", "createObject", "(", ...
CartStorageFactory constructor. @param User $user @return \yii\web\Session
[ "CartStorageFactory", "constructor", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/cart/storage/CartStorageFactory.php#L29-L36
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Basket/Standard.php
Standard.getParts
protected function getParts( \Aimeos\MW\View\Iface $view ) { $available = array( 'basket/address' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_ADDRESS, 'basket/coupon' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_COUPON, 'basket/product' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT, 'basket/service' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_SERVICE, ); $included = explode( ',', $view->param( 'included', 'basket/address,basket/coupon,basket/product,basket/service' ) ); $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_NONE; foreach( $included as $type ) { if( isset( $available[$type] ) ) { $parts |= $available[$type]; } } return $parts; }
php
protected function getParts( \Aimeos\MW\View\Iface $view ) { $available = array( 'basket/address' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_ADDRESS, 'basket/coupon' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_COUPON, 'basket/product' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT, 'basket/service' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_SERVICE, ); $included = explode( ',', $view->param( 'included', 'basket/address,basket/coupon,basket/product,basket/service' ) ); $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_NONE; foreach( $included as $type ) { if( isset( $available[$type] ) ) { $parts |= $available[$type]; } } return $parts; }
[ "protected", "function", "getParts", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ")", "{", "$", "available", "=", "array", "(", "'basket/address'", "=>", "\\", "Aimeos", "\\", "MShop", "\\", "Order", "\\", "Item", "\\", "...
Returns the integer constant for the basket parts that should be included @param \Aimeos\MW\View\Iface $view View instance @return integer Constant from Aimeos\MShop\Order\Item\Base\Base
[ "Returns", "the", "integer", "constant", "for", "the", "basket", "parts", "that", "should", "be", "included" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Basket/Standard.php#L256-L276
train
TYPO3-CMS/redirects
Classes/ViewHelpers/TargetPageIdViewHelper.php
TargetPageIdViewHelper.renderStatic
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { if (!strpos($arguments['target'], 't3://page', 0) === 0) { return ''; } try { $linkService = GeneralUtility::makeInstance(LinkService::class); $resolvedLink = $linkService->resolveByStringRepresentation($arguments['target']); return $resolvedLink['pageuid'] ?? ''; } catch (UnknownUrnException $e) { return ''; } }
php
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { if (!strpos($arguments['target'], 't3://page', 0) === 0) { return ''; } try { $linkService = GeneralUtility::makeInstance(LinkService::class); $resolvedLink = $linkService->resolveByStringRepresentation($arguments['target']); return $resolvedLink['pageuid'] ?? ''; } catch (UnknownUrnException $e) { return ''; } }
[ "public", "static", "function", "renderStatic", "(", "array", "$", "arguments", ",", "\\", "Closure", "$", "renderChildrenClosure", ",", "RenderingContextInterface", "$", "renderingContext", ")", ":", "string", "{", "if", "(", "!", "strpos", "(", "$", "arguments...
Renders the page ID @param array $arguments @param \Closure $renderChildrenClosure @param RenderingContextInterface $renderingContext @return string
[ "Renders", "the", "page", "ID" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/ViewHelpers/TargetPageIdViewHelper.php#L51-L64
train