id int32 0 241k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,500 | 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",
",",
"$",
"options",
")",
")",
"{",
"$",
"data",
"=",
"Options",
"::",
"DEFAULT_AGGREGATOR",
";",
"}",
"return",
"$",
"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 |
28,501 | 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",
".",
"'\\\\'",
".",
"\\",
"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'.\"",
")",
";",
"}"
] | 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 |
28,502 | 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",
"(",
"'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",
";",
"}"
] | 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 |
28,503 | 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 |
28,504 | 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'",
",",
"'hipanel:finance'",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"user",
"->",
"can",
"(",
"'support'",
")",
")",
"{",
"$",
"types",
"=",
"$",
"this",
"->",
"removeUnusedTypes",
"(",
"$",
"types",
")",
";",
"}",
"return",
"$",
"types",
";",
"}"
] | 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 |
28,505 | 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",
")",
"===",
"'%'",
")",
"{",
"$",
"whereValue",
"=",
"'%'",
".",
"$",
"whereValue",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"annotationWhereParameter",
",",
"-",
"1",
",",
"1",
")",
"===",
"'%'",
")",
"{",
"$",
"whereValue",
"=",
"$",
"whereValue",
".",
"'%'",
";",
"}",
"return",
"$",
"whereValue",
";",
"}"
] | 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 |
28,506 | 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",
"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",
";",
"}"
] | 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 |
28,507 | 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",
")",
")",
"{",
"// 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",
";",
"}",
"}"
] | 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 |
28,508 | 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",
"(",
"$",
"event",
")",
";",
"return",
"(",
"array",
")",
"$",
"event",
"->",
"getResult",
"(",
")",
";",
"}"
] | 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 |
28,509 | 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",
"(",
"$",
"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",
";",
"}"
] | 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 |
28,510 | 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'",
"]",
"=",
"$",
"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",
")",
";",
"}"
] | 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 |
28,511 | 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",
"->",
"_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",
";",
"}"
] | 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 |
28,512 | 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",
"(",
"!",
"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",
";",
"}"
] | 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 |
28,513 | 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",
"::",
"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",
";",
"}"
] | 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 |
28,514 | 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",
"(",
")",
";",
"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",
";",
"}"
] | 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 |
28,515 | 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'",
"]",
"[",
"'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",
";",
"}"
] | 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 |
28,516 | 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",
"->",
"id",
"=",
"null",
";",
"$",
"this",
"->",
"name",
"=",
"null",
";",
"return",
"true",
";",
"}"
] | 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 |
28,517 | 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",
"(",
"$",
"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.'",
")",
";",
"}"
] | 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 |
28,518 | 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'",
",",
"'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",
")",
")",
";",
"}"
] | 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 |
28,519 | 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_unit'",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | 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 |
28,520 | 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",
"[",
"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",
";",
"}"
] | 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 |
28,521 | 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",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"view",
",",
"[",
"'merchant'",
"=>",
"$",
"merchant",
",",
"'widget'",
"=>",
"$",
"this",
",",
"'event'",
"=>",
"$",
"this",
"->",
"event",
",",
"]",
")",
";",
"}"
] | 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 |
28,522 | 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",
")",
";",
"$",
"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",
"(",
")",
")",
";",
"}"
] | 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 |
28,523 | 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",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Required parameter \"%s\" is missing.'",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"this",
"->",
"{",
"$",
"name",
"}",
"=",
"$",
"options",
"[",
"$",
"name",
"]",
";",
"}",
"}"
] | 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 |
28,524 | 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",
")",
";",
"}",
"return",
"$",
"this",
"->",
"tableId",
";",
"}"
] | 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 |
28,525 | 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'",
"]",
")",
"?",
"$",
"this",
"->",
"searchData",
"[",
"'group_by'",
"]",
":",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"groupByField",
";",
"}"
] | Group field getter.
@return string | [
"Group",
"field",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L161-L168 |
28,526 | 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'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"export",
";",
"}"
] | Export status getter.
@return bool | [
"Export",
"status",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L175-L182 |
28,527 | 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'",
")",
")",
";",
"$",
"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",
";",
"}"
] | View options getter.
@return mixed[] | [
"View",
"options",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L189-L210 |
28,528 | 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",
"(",
"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",
";",
"}"
] | 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 |
28,529 | 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",
"=",
"[",
"'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",
";",
"}"
] | DataTable options getter.
@return mixed[] | [
"DataTable",
"options",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L242-L266 |
28,530 | 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",
"(",
"$",
"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",
";",
"}"
] | Chart options getter.
@return mixed[] | [
"Chart",
"options",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L273-L309 |
28,531 | 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",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"batch",
"&&",
"!",
"$",
"this",
"->",
"getGroupByField",
"(",
")",
")",
"{",
"$",
"result",
"+=",
"1",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Sort column getter.
@return int | [
"Sort",
"column",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L316-L325 |
28,532 | 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'",
"]",
":",
"Options",
"::",
"DEFAULT_SORT_BY_ORDER",
";",
"return",
"$",
"result",
";",
"}"
] | Sort direction getter.
@return string | [
"Sort",
"direction",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L332-L339 |
28,533 | 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",
"[",
"]",
"=",
"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",
";",
"}"
] | DataTable columns getter.
@return mixed[] | [
"DataTable",
"columns",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/View/Cell/ResultCell.php#L346-L363 |
28,534 | 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",
"->",
"errors",
"=",
"array",
"(",
"array",
"(",
"'title'",
"=>",
"$",
"this",
"->",
"getContext",
"(",
")",
"->",
"getI18n",
"(",
")",
"->",
"dt",
"(",
"'client/jsonapi'",
",",
"'Not allowed for this resource'",
")",
",",
")",
")",
";",
"/** client/jsonapi/standard/template-error\n\t\t * Relative path to the default JSON API template\n\t\t *\n\t\t * The template file contains the code and processing instructions\n\t\t * to generate the result shown in the JSON API body. The\n\t\t * configuration string is the path to the template file relative\n\t\t * to the templates directory (usually in client/jsonapi/templates).\n\t\t *\n\t\t * You can overwrite the template file configuration in extensions and\n\t\t * provide alternative templates. These alternative templates should be\n\t\t * named like the default one but with the string \"standard\" replaced by\n\t\t * an unique name. You may use the name of your project for this. If\n\t\t * you've implemented an alternative client class as well, \"standard\"\n\t\t * should be replaced by the name of the new class.\n\t\t *\n\t\t * @param string Relative path to the template creating the body for the JSON API response\n\t\t * @since 2017.02\n\t\t * @category Developer\n\t\t * @see client/jsonapi/standard/template-delete\n\t\t * @see client/jsonapi/standard/template-patch\n\t\t * @see client/jsonapi/standard/template-post\n\t\t * @see client/jsonapi/standard/template-get\n\t\t * @see client/jsonapi/standard/template-options\n\t\t */",
"$",
"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",
")",
";",
"}"
] | 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 |
28,535 | 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'",
"]",
"=",
"$",
"this",
"->",
"context",
"->",
"getI18n",
"(",
")",
"->",
"dt",
"(",
"$",
"domain",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"details",
"[",
"'title'",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"/** client/jsonapi/debug\n\t\t * Send debug information withing responses to clients if an error occurrs\n\t\t *\n\t\t * By default, the Aimeos client JSON REST API won't send any details\n\t\t * besides the error message to the client if an error occurred. This\n\t\t * prevents leaking sensitive information to attackers. For debugging\n\t\t * your requests it's helpful to see the stack strace. If you set this\n\t\t * configuration option to true, the stack trace will be returned too.\n\t\t *\n\t\t * @param boolean True to return the stack trace in JSON response, false for error message only\n\t\t * @since 2017.07\n\t\t * @category Developer\n\t\t */",
"if",
"(",
"$",
"this",
"->",
"context",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'client/jsonapi/debug'",
",",
"false",
")",
"==",
"true",
")",
"{",
"$",
"details",
"[",
"'detail'",
"]",
"=",
"$",
"e",
"->",
"getTraceAsString",
"(",
")",
";",
"}",
"return",
"[",
"$",
"details",
"]",
";",
"// jsonapi.org requires a list of error objects",
"}"
] | 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 |
28,536 | 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/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",
")",
";",
"}"
] | 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 |
28,537 | 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",
"(",
"[",
"'class'",
"=>",
"RemoteCartStorage",
"::",
"class",
",",
"'sessionCartId'",
"=>",
"'yz\\shoppingcart\\ShoppingCart'",
"]",
")",
";",
"}"
] | 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 |
28,538 | 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",
"\\",
"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",
";",
"}"
] | 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 |
28,539 | 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",
"[",
"'target'",
"]",
",",
"'t3://page'",
",",
"0",
")",
"===",
"0",
")",
"{",
"return",
"''",
";",
"}",
"try",
"{",
"$",
"linkService",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"LinkService",
"::",
"class",
")",
";",
"$",
"resolvedLink",
"=",
"$",
"linkService",
"->",
"resolveByStringRepresentation",
"(",
"$",
"arguments",
"[",
"'target'",
"]",
")",
";",
"return",
"$",
"resolvedLink",
"[",
"'pageuid'",
"]",
"??",
"''",
";",
"}",
"catch",
"(",
"UnknownUrnException",
"$",
"e",
")",
"{",
"return",
"''",
";",
"}",
"}"
] | 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 |
28,540 | BabDev/Transifex-API | src/Transifex.php | Transifex.get | public function get(string $name): ApiConnector
{
return $this->apiFactory->createApiConnector($name, $this->options);
} | php | public function get(string $name): ApiConnector
{
return $this->apiFactory->createApiConnector($name, $this->options);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"name",
")",
":",
"ApiConnector",
"{",
"return",
"$",
"this",
"->",
"apiFactory",
"->",
"createApiConnector",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"options",
")",
";",
"}"
] | Factory method to fetch API objects.
@param string $name Name of the API object to retrieve
@return ApiConnector
@throws Exception\UnknownApiConnectorException | [
"Factory",
"method",
"to",
"fetch",
"API",
"objects",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Transifex.php#L48-L51 |
28,541 | hiqdev/hipanel-module-finance | src/models/DomainService.php | DomainService.tryResourceAssignation | public function tryResourceAssignation(DomainResource $resource)
{
if ($type = $this->matchType($resource)) {
$this->resources[$type] = $resource;
return true;
}
return false;
} | php | public function tryResourceAssignation(DomainResource $resource)
{
if ($type = $this->matchType($resource)) {
$this->resources[$type] = $resource;
return true;
}
return false;
} | [
"public",
"function",
"tryResourceAssignation",
"(",
"DomainResource",
"$",
"resource",
")",
"{",
"if",
"(",
"$",
"type",
"=",
"$",
"this",
"->",
"matchType",
"(",
"$",
"resource",
")",
")",
"{",
"$",
"this",
"->",
"resources",
"[",
"$",
"type",
"]",
"=",
"$",
"resource",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Tries to assign a resource in this service, if the type is correct.
@param DomainResource $resource
@return bool | [
"Tries",
"to",
"assign",
"a",
"resource",
"in",
"this",
"service",
"if",
"the",
"type",
"is",
"correct",
"."
] | fa027420ddc1d6de22a6d830e14dde587c837220 | https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/models/DomainService.php#L51-L60 |
28,542 | mmoreram/ControllerExtraBundle | DependencyInjection/ControllerExtraExtension.php | ControllerExtraExtension.getConfigFiles | protected function getConfigFiles(array $config) : array
{
return [
'providers',
'annotations_resolver',
['resolver_form', $config['form']['active']],
['resolver_flush', $config['flush']['active']],
['resolver_entity', $config['entity']['active']],
['resolver_log', $config['log']['active']],
['resolver_json_response', $config['json_response']['active']],
['resolver_paginator', $config['paginator']['active']],
['resolver_get', $config['get']['active']],
['resolver_post', $config['post']['active']],
];
} | php | protected function getConfigFiles(array $config) : array
{
return [
'providers',
'annotations_resolver',
['resolver_form', $config['form']['active']],
['resolver_flush', $config['flush']['active']],
['resolver_entity', $config['entity']['active']],
['resolver_log', $config['log']['active']],
['resolver_json_response', $config['json_response']['active']],
['resolver_paginator', $config['paginator']['active']],
['resolver_get', $config['get']['active']],
['resolver_post', $config['post']['active']],
];
} | [
"protected",
"function",
"getConfigFiles",
"(",
"array",
"$",
"config",
")",
":",
"array",
"{",
"return",
"[",
"'providers'",
",",
"'annotations_resolver'",
",",
"[",
"'resolver_form'",
",",
"$",
"config",
"[",
"'form'",
"]",
"[",
"'active'",
"]",
"]",
",",
"[",
"'resolver_flush'",
",",
"$",
"config",
"[",
"'flush'",
"]",
"[",
"'active'",
"]",
"]",
",",
"[",
"'resolver_entity'",
",",
"$",
"config",
"[",
"'entity'",
"]",
"[",
"'active'",
"]",
"]",
",",
"[",
"'resolver_log'",
",",
"$",
"config",
"[",
"'log'",
"]",
"[",
"'active'",
"]",
"]",
",",
"[",
"'resolver_json_response'",
",",
"$",
"config",
"[",
"'json_response'",
"]",
"[",
"'active'",
"]",
"]",
",",
"[",
"'resolver_paginator'",
",",
"$",
"config",
"[",
"'paginator'",
"]",
"[",
"'active'",
"]",
"]",
",",
"[",
"'resolver_get'",
",",
"$",
"config",
"[",
"'get'",
"]",
"[",
"'active'",
"]",
"]",
",",
"[",
"'resolver_post'",
",",
"$",
"config",
"[",
"'post'",
"]",
"[",
"'active'",
"]",
"]",
",",
"]",
";",
"}"
] | Config files to load.
Each array position can be a simple file name if must be loaded always,
or an array, with the filename in the first position, and a boolean in
the second one.
As a parameter, this method receives all loaded configuration, to allow
setting this boolean value from a configuration value.
return array(
'file1.yml',
'file2.yml',
['file3.yml', $config['my_boolean'],
...
);
@param array $config Config definitions
@return array Config files | [
"Config",
"files",
"to",
"load",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/DependencyInjection/ControllerExtraExtension.php#L72-L86 |
28,543 | MetaModels/filter_perimetersearch | src/Helper/SphericalDistance.php | SphericalDistance.validateCoordinate | public static function validateCoordinate($coordinate): bool
{
if (!(is_numeric($coordinate)
&& (3 >= \strlen((int) \abs($coordinate)))
&& (6 >= (\strlen($coordinate) - \strlen((int) $coordinate) - 1)))
) {
return false;
}
return true;
} | php | public static function validateCoordinate($coordinate): bool
{
if (!(is_numeric($coordinate)
&& (3 >= \strlen((int) \abs($coordinate)))
&& (6 >= (\strlen($coordinate) - \strlen((int) $coordinate) - 1)))
) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"validateCoordinate",
"(",
"$",
"coordinate",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"(",
"is_numeric",
"(",
"$",
"coordinate",
")",
"&&",
"(",
"3",
">=",
"\\",
"strlen",
"(",
"(",
"int",
")",
"\\",
"abs",
"(",
"$",
"coordinate",
")",
")",
")",
"&&",
"(",
"6",
">=",
"(",
"\\",
"strlen",
"(",
"$",
"coordinate",
")",
"-",
"\\",
"strlen",
"(",
"(",
"int",
")",
"$",
"coordinate",
")",
"-",
"1",
")",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Validate the coordinate.
@param string|float $coordinate The latitude or longitude coordinate.
@return bool | [
"Validate",
"the",
"coordinate",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/Helper/SphericalDistance.php#L154-L164 |
28,544 | TYPO3-CMS/redirects | Classes/Service/UrlService.php | UrlService.getDefaultUrl | public function getDefaultUrl(): string
{
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
$firstPageInTree = $connection->select(['uid'], 'pages', ['pid' => 0], [], ['sorting' => 'ASC'], 1)->fetchColumn(0);
$url = BackendUtility::getViewDomain($firstPageInTree);
return $url;
} | php | public function getDefaultUrl(): string
{
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
$firstPageInTree = $connection->select(['uid'], 'pages', ['pid' => 0], [], ['sorting' => 'ASC'], 1)->fetchColumn(0);
$url = BackendUtility::getViewDomain($firstPageInTree);
return $url;
} | [
"public",
"function",
"getDefaultUrl",
"(",
")",
":",
"string",
"{",
"$",
"connection",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ConnectionPool",
"::",
"class",
")",
"->",
"getConnectionForTable",
"(",
"'pages'",
")",
";",
"$",
"firstPageInTree",
"=",
"$",
"connection",
"->",
"select",
"(",
"[",
"'uid'",
"]",
",",
"'pages'",
",",
"[",
"'pid'",
"=>",
"0",
"]",
",",
"[",
"]",
",",
"[",
"'sorting'",
"=>",
"'ASC'",
"]",
",",
"1",
")",
"->",
"fetchColumn",
"(",
"0",
")",
";",
"$",
"url",
"=",
"BackendUtility",
"::",
"getViewDomain",
"(",
"$",
"firstPageInTree",
")",
";",
"return",
"$",
"url",
";",
"}"
] | Retrieves the first valid URL
@return string a URL like "http://example.org" | [
"Retrieves",
"the",
"first",
"valid",
"URL"
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Service/UrlService.php#L34-L41 |
28,545 | aimeos/ai-client-jsonapi | client/jsonapi/src/Client/JsonApi/Common/Decorator/Base.php | Base.setView | public function setView( \Aimeos\MW\View\Iface $view )
{
$this->client->setView( $view );
parent::setView( $view );
return $this;
} | php | public function setView( \Aimeos\MW\View\Iface $view )
{
$this->client->setView( $view );
parent::setView( $view );
return $this;
} | [
"public",
"function",
"setView",
"(",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"View",
"\\",
"Iface",
"$",
"view",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"setView",
"(",
"$",
"view",
")",
";",
"parent",
"::",
"setView",
"(",
"$",
"view",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the view object that will generate the admin output.
@param \Aimeos\MW\View\Iface $view The view object which generates the admin output
@return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls | [
"Sets",
"the",
"view",
"object",
"that",
"will",
"generate",
"the",
"admin",
"output",
"."
] | b0dfb018ae0a1f7196b18322e28a1b3224aa9045 | https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Common/Decorator/Base.php#L159-L165 |
28,546 | QoboLtd/cakephp-search | src/Utility.php | Utility.instance | public static function instance(Utility $utility = null)
{
if ($utility instanceof Utility) {
static::$instance = $utility;
}
if (empty(static::$instance)) {
static::$instance = new static();
}
return static::$instance;
} | php | public static function instance(Utility $utility = null)
{
if ($utility instanceof Utility) {
static::$instance = $utility;
}
if (empty(static::$instance)) {
static::$instance = new static();
}
return static::$instance;
} | [
"public",
"static",
"function",
"instance",
"(",
"Utility",
"$",
"utility",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"utility",
"instanceof",
"Utility",
")",
"{",
"static",
"::",
"$",
"instance",
"=",
"$",
"utility",
";",
"}",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"instance",
")",
")",
"{",
"static",
"::",
"$",
"instance",
"=",
"new",
"static",
"(",
")",
";",
"}",
"return",
"static",
"::",
"$",
"instance",
";",
"}"
] | Returns the globally available instance of a Search\Utility.
@param \Search\Utility|null $utility Utility instance
@return static The global search utility | [
"Returns",
"the",
"globally",
"available",
"instance",
"of",
"a",
"Search",
"\\",
"Utility",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility.php#L62-L73 |
28,547 | QoboLtd/cakephp-search | src/Utility.php | Utility.getSearchableFields | public function getSearchableFields(RepositoryInterface $table, array $user) : array
{
$alias = $table->getAlias();
if (!empty($this->searchableFields[$alias])) {
return $this->searchableFields[$alias];
}
$event = new Event((string)EventName::MODEL_SEARCH_SEARCHABLE_FIELDS(), $this, [
'table' => $table,
'user' => $user
]);
EventManager::instance()->dispatch($event);
$this->searchableFields[$alias] = $event->result ? $event->result : [];
return $this->searchableFields[$alias];
} | php | public function getSearchableFields(RepositoryInterface $table, array $user) : array
{
$alias = $table->getAlias();
if (!empty($this->searchableFields[$alias])) {
return $this->searchableFields[$alias];
}
$event = new Event((string)EventName::MODEL_SEARCH_SEARCHABLE_FIELDS(), $this, [
'table' => $table,
'user' => $user
]);
EventManager::instance()->dispatch($event);
$this->searchableFields[$alias] = $event->result ? $event->result : [];
return $this->searchableFields[$alias];
} | [
"public",
"function",
"getSearchableFields",
"(",
"RepositoryInterface",
"$",
"table",
",",
"array",
"$",
"user",
")",
":",
"array",
"{",
"$",
"alias",
"=",
"$",
"table",
"->",
"getAlias",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"searchableFields",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"searchableFields",
"[",
"$",
"alias",
"]",
";",
"}",
"$",
"event",
"=",
"new",
"Event",
"(",
"(",
"string",
")",
"EventName",
"::",
"MODEL_SEARCH_SEARCHABLE_FIELDS",
"(",
")",
",",
"$",
"this",
",",
"[",
"'table'",
"=>",
"$",
"table",
",",
"'user'",
"=>",
"$",
"user",
"]",
")",
";",
"EventManager",
"::",
"instance",
"(",
")",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"searchableFields",
"[",
"$",
"alias",
"]",
"=",
"$",
"event",
"->",
"result",
"?",
"$",
"event",
"->",
"result",
":",
"[",
"]",
";",
"return",
"$",
"this",
"->",
"searchableFields",
"[",
"$",
"alias",
"]",
";",
"}"
] | Return Table's searchable fields.
@param \Cake\Datasource\RepositoryInterface $table Table object
@param mixed[] $user User info
@return mixed[] | [
"Return",
"Table",
"s",
"searchable",
"fields",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility.php#L82-L99 |
28,548 | QoboLtd/cakephp-search | src/Utility.php | Utility.formatter | public function formatter(ResultSetInterface $resultSet, array $fields, RepositoryInterface $table, array $user) : array
{
$result = [];
if ($resultSet->isEmpty()) {
return $result;
}
$cakeView = new View();
$registryAlias = $table->getRegistryAlias();
$alias = $table->getAlias();
foreach ($resultSet as $key => $entity) {
foreach ($fields as $field) {
list($tableName, $fieldName) = explode('.', $field);
// current table field
if ($alias === $tableName) {
$result[$key][$field] = $entity->get($fieldName);
continue;
}
if (!$entity->get('_matchingData')) {
continue;
}
if (!isset($entity->_matchingData[$tableName])) {
continue;
}
// associated table field
$result[$key][$field] = $entity->_matchingData[$tableName]->get($fieldName);
}
$result[$key][static::MENU_PROPERTY_NAME] = $cakeView->element('Search.Menu/search-view-actions', [
'entity' => $entity,
'model' => $registryAlias,
'user' => $user
]);
}
return $result;
} | php | public function formatter(ResultSetInterface $resultSet, array $fields, RepositoryInterface $table, array $user) : array
{
$result = [];
if ($resultSet->isEmpty()) {
return $result;
}
$cakeView = new View();
$registryAlias = $table->getRegistryAlias();
$alias = $table->getAlias();
foreach ($resultSet as $key => $entity) {
foreach ($fields as $field) {
list($tableName, $fieldName) = explode('.', $field);
// current table field
if ($alias === $tableName) {
$result[$key][$field] = $entity->get($fieldName);
continue;
}
if (!$entity->get('_matchingData')) {
continue;
}
if (!isset($entity->_matchingData[$tableName])) {
continue;
}
// associated table field
$result[$key][$field] = $entity->_matchingData[$tableName]->get($fieldName);
}
$result[$key][static::MENU_PROPERTY_NAME] = $cakeView->element('Search.Menu/search-view-actions', [
'entity' => $entity,
'model' => $registryAlias,
'user' => $user
]);
}
return $result;
} | [
"public",
"function",
"formatter",
"(",
"ResultSetInterface",
"$",
"resultSet",
",",
"array",
"$",
"fields",
",",
"RepositoryInterface",
"$",
"table",
",",
"array",
"$",
"user",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"resultSet",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"cakeView",
"=",
"new",
"View",
"(",
")",
";",
"$",
"registryAlias",
"=",
"$",
"table",
"->",
"getRegistryAlias",
"(",
")",
";",
"$",
"alias",
"=",
"$",
"table",
"->",
"getAlias",
"(",
")",
";",
"foreach",
"(",
"$",
"resultSet",
"as",
"$",
"key",
"=>",
"$",
"entity",
")",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"list",
"(",
"$",
"tableName",
",",
"$",
"fieldName",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"field",
")",
";",
"// current table field",
"if",
"(",
"$",
"alias",
"===",
"$",
"tableName",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"[",
"$",
"field",
"]",
"=",
"$",
"entity",
"->",
"get",
"(",
"$",
"fieldName",
")",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"entity",
"->",
"get",
"(",
"'_matchingData'",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"entity",
"->",
"_matchingData",
"[",
"$",
"tableName",
"]",
")",
")",
"{",
"continue",
";",
"}",
"// associated table field",
"$",
"result",
"[",
"$",
"key",
"]",
"[",
"$",
"field",
"]",
"=",
"$",
"entity",
"->",
"_matchingData",
"[",
"$",
"tableName",
"]",
"->",
"get",
"(",
"$",
"fieldName",
")",
";",
"}",
"$",
"result",
"[",
"$",
"key",
"]",
"[",
"static",
"::",
"MENU_PROPERTY_NAME",
"]",
"=",
"$",
"cakeView",
"->",
"element",
"(",
"'Search.Menu/search-view-actions'",
",",
"[",
"'entity'",
"=>",
"$",
"entity",
",",
"'model'",
"=>",
"$",
"registryAlias",
",",
"'user'",
"=>",
"$",
"user",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Method that formats resultset.
@param \Cake\Datasource\ResultSetInterface $resultSet ResultSet
@param string[] $fields Display fields
@param \Cake\Datasource\RepositoryInterface $table Table instance
@param mixed[] $user User info
@return mixed[] | [
"Method",
"that",
"formats",
"resultset",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility.php#L110-L150 |
28,549 | QoboLtd/cakephp-search | src/Utility.php | Utility.getAssociationLabels | public function getAssociationLabels(RepositoryInterface $table) : array
{
/** @var \Cake\ORM\Table */
$table = $table;
$result = [];
foreach ($table->associations() as $association) {
if (!in_array($association->type(), $this->searchableAssociations)) {
continue;
}
$result[$association->getName()] = Inflector::humanize(current((array)$association->getForeignKey()));
}
return $result;
} | php | public function getAssociationLabels(RepositoryInterface $table) : array
{
/** @var \Cake\ORM\Table */
$table = $table;
$result = [];
foreach ($table->associations() as $association) {
if (!in_array($association->type(), $this->searchableAssociations)) {
continue;
}
$result[$association->getName()] = Inflector::humanize(current((array)$association->getForeignKey()));
}
return $result;
} | [
"public",
"function",
"getAssociationLabels",
"(",
"RepositoryInterface",
"$",
"table",
")",
":",
"array",
"{",
"/** @var \\Cake\\ORM\\Table */",
"$",
"table",
"=",
"$",
"table",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"table",
"->",
"associations",
"(",
")",
"as",
"$",
"association",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"association",
"->",
"type",
"(",
")",
",",
"$",
"this",
"->",
"searchableAssociations",
")",
")",
"{",
"continue",
";",
"}",
"$",
"result",
"[",
"$",
"association",
"->",
"getName",
"(",
")",
"]",
"=",
"Inflector",
"::",
"humanize",
"(",
"current",
"(",
"(",
"array",
")",
"$",
"association",
"->",
"getForeignKey",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Associations labels getter.
@param \Cake\Datasource\RepositoryInterface $table Table instance
@return mixed[] | [
"Associations",
"labels",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility.php#L199-L214 |
28,550 | mmoreram/ControllerExtraBundle | Resolver/AnnotationResolverCollector.php | AnnotationResolverCollector.analyzeRequest | public function analyzeRequest(
Request $request,
Reader $reader,
ReflectionMethod $method
) {
/**
* Annotations load.
*/
$methodAnnotations = $reader->getMethodAnnotations($method);
/**
* Every annotation found is parsed.
*/
foreach ($methodAnnotations as $annotation) {
if ($annotation instanceof Annotation) {
$this->analyzeAnnotation(
$request,
$method,
$annotation,
$this->resolverStack
);
}
}
} | php | public function analyzeRequest(
Request $request,
Reader $reader,
ReflectionMethod $method
) {
/**
* Annotations load.
*/
$methodAnnotations = $reader->getMethodAnnotations($method);
/**
* Every annotation found is parsed.
*/
foreach ($methodAnnotations as $annotation) {
if ($annotation instanceof Annotation) {
$this->analyzeAnnotation(
$request,
$method,
$annotation,
$this->resolverStack
);
}
}
} | [
"public",
"function",
"analyzeRequest",
"(",
"Request",
"$",
"request",
",",
"Reader",
"$",
"reader",
",",
"ReflectionMethod",
"$",
"method",
")",
"{",
"/**\n * Annotations load.\n */",
"$",
"methodAnnotations",
"=",
"$",
"reader",
"->",
"getMethodAnnotations",
"(",
"$",
"method",
")",
";",
"/**\n * Every annotation found is parsed.\n */",
"foreach",
"(",
"$",
"methodAnnotations",
"as",
"$",
"annotation",
")",
"{",
"if",
"(",
"$",
"annotation",
"instanceof",
"Annotation",
")",
"{",
"$",
"this",
"->",
"analyzeAnnotation",
"(",
"$",
"request",
",",
"$",
"method",
",",
"$",
"annotation",
",",
"$",
"this",
"->",
"resolverStack",
")",
";",
"}",
"}",
"}"
] | Evaluate request.
@param Request $request
@param Reader $reader
@param ReflectionMethod $method | [
"Evaluate",
"request",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/AnnotationResolverCollector.php#L121-L144 |
28,551 | mmoreram/ControllerExtraBundle | Resolver/AnnotationResolverCollector.php | AnnotationResolverCollector.analyzeAnnotation | public function analyzeAnnotation(
Request $request,
ReflectionMethod $method,
Annotation $annotation,
array $resolverStack
) {
/**
* Every resolver must evaluate its logic.
*/
foreach ($resolverStack as $resolver) {
$resolver->evaluateAnnotation($request, $annotation, $method);
}
} | php | public function analyzeAnnotation(
Request $request,
ReflectionMethod $method,
Annotation $annotation,
array $resolverStack
) {
/**
* Every resolver must evaluate its logic.
*/
foreach ($resolverStack as $resolver) {
$resolver->evaluateAnnotation($request, $annotation, $method);
}
} | [
"public",
"function",
"analyzeAnnotation",
"(",
"Request",
"$",
"request",
",",
"ReflectionMethod",
"$",
"method",
",",
"Annotation",
"$",
"annotation",
",",
"array",
"$",
"resolverStack",
")",
"{",
"/**\n * Every resolver must evaluate its logic.\n */",
"foreach",
"(",
"$",
"resolverStack",
"as",
"$",
"resolver",
")",
"{",
"$",
"resolver",
"->",
"evaluateAnnotation",
"(",
"$",
"request",
",",
"$",
"annotation",
",",
"$",
"method",
")",
";",
"}",
"}"
] | Allow every available resolver to solve its own logic.
@param Request $request
@param ReflectionMethod $method
@param Annotation $annotation
@param array $resolverStack | [
"Allow",
"every",
"available",
"resolver",
"to",
"solve",
"its",
"own",
"logic",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/AnnotationResolverCollector.php#L154-L167 |
28,552 | MetaModels/filter_perimetersearch | src/Helper/HaversineSphericalDistance.php | HaversineSphericalDistance.getFormulaAsQueryPart | public static function getFormulaAsQueryPart(
$firstLatitude,
$firstLongitude,
$secondLatitude,
$secondLongitude,
$digits = 0,
$earthRadius = self::EARTH_RADIUS_IN_KM
): string {
return \sprintf(
'ROUND(
SQRT(
POWER(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) - CAST(%3$s AS DECIMAL(9,6))) * %6$s, 2)
+ POWER(2 * PI() / 360 * (CAST(%2$s AS DECIMAL(9,6)) - CAST(%4$s AS DECIMAL(9,6))) * %6$s
* COS(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) + CAST(%3$s AS DECIMAL(9,6))) * 0.5), 2)
), %5$s
)',
$firstLatitude,
$firstLongitude,
$secondLatitude,
$secondLongitude,
$digits,
$earthRadius
);
} | php | public static function getFormulaAsQueryPart(
$firstLatitude,
$firstLongitude,
$secondLatitude,
$secondLongitude,
$digits = 0,
$earthRadius = self::EARTH_RADIUS_IN_KM
): string {
return \sprintf(
'ROUND(
SQRT(
POWER(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) - CAST(%3$s AS DECIMAL(9,6))) * %6$s, 2)
+ POWER(2 * PI() / 360 * (CAST(%2$s AS DECIMAL(9,6)) - CAST(%4$s AS DECIMAL(9,6))) * %6$s
* COS(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) + CAST(%3$s AS DECIMAL(9,6))) * 0.5), 2)
), %5$s
)',
$firstLatitude,
$firstLongitude,
$secondLatitude,
$secondLongitude,
$digits,
$earthRadius
);
} | [
"public",
"static",
"function",
"getFormulaAsQueryPart",
"(",
"$",
"firstLatitude",
",",
"$",
"firstLongitude",
",",
"$",
"secondLatitude",
",",
"$",
"secondLongitude",
",",
"$",
"digits",
"=",
"0",
",",
"$",
"earthRadius",
"=",
"self",
"::",
"EARTH_RADIUS_IN_KM",
")",
":",
"string",
"{",
"return",
"\\",
"sprintf",
"(",
"'ROUND(\n SQRT(\n POWER(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) - CAST(%3$s AS DECIMAL(9,6))) * %6$s, 2) \n + POWER(2 * PI() / 360 * (CAST(%2$s AS DECIMAL(9,6)) - CAST(%4$s AS DECIMAL(9,6))) * %6$s \n * COS(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) + CAST(%3$s AS DECIMAL(9,6))) * 0.5), 2)\n ), %5$s\n )'",
",",
"$",
"firstLatitude",
",",
"$",
"firstLongitude",
",",
"$",
"secondLatitude",
",",
"$",
"secondLongitude",
",",
"$",
"digits",
",",
"$",
"earthRadius",
")",
";",
"}"
] | Get the spherical distance haversine formula for the database query part.
@param string|float $firstLatitude The first latitude coordinate. You can a coordinate or a database field.
@param string|float $firstLongitude The first longitude coordinate. You can a coordinate or a database field.
@param string|float $secondLatitude The second latitude coordinate. You can a coordinate or a database field.
@param string|float $secondLongitude The second longitude coordinate. You can a coordinate or a database field.
@param int $digits The number of digits after the decimal point.
@param int $earthRadius The earth radius.
@return string | [
"Get",
"the",
"spherical",
"distance",
"haversine",
"formula",
"for",
"the",
"database",
"query",
"part",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/Helper/HaversineSphericalDistance.php#L42-L65 |
28,553 | MetaModels/filter_perimetersearch | src/Helper/HaversineSphericalDistance.php | HaversineSphericalDistance.calculate | public static function calculate(
float $firstLatitude,
float $firstLongitude,
float $secondLatitude,
float $secondLongitude,
int $digits = 0,
int $earthRadius = self::EARTH_RADIUS_IN_KM
): float {
$oneRad = ((2 * M_PI) / 360);
return \round(
\sqrt(
(($oneRad * ($firstLatitude - $secondLatitude) * $earthRadius) ** 2)
+ (($oneRad * ($firstLongitude - $secondLongitude) * $earthRadius
* \cos($oneRad * ($firstLatitude + $secondLatitude) * .5)) ** 2)
),
$digits
);
} | php | public static function calculate(
float $firstLatitude,
float $firstLongitude,
float $secondLatitude,
float $secondLongitude,
int $digits = 0,
int $earthRadius = self::EARTH_RADIUS_IN_KM
): float {
$oneRad = ((2 * M_PI) / 360);
return \round(
\sqrt(
(($oneRad * ($firstLatitude - $secondLatitude) * $earthRadius) ** 2)
+ (($oneRad * ($firstLongitude - $secondLongitude) * $earthRadius
* \cos($oneRad * ($firstLatitude + $secondLatitude) * .5)) ** 2)
),
$digits
);
} | [
"public",
"static",
"function",
"calculate",
"(",
"float",
"$",
"firstLatitude",
",",
"float",
"$",
"firstLongitude",
",",
"float",
"$",
"secondLatitude",
",",
"float",
"$",
"secondLongitude",
",",
"int",
"$",
"digits",
"=",
"0",
",",
"int",
"$",
"earthRadius",
"=",
"self",
"::",
"EARTH_RADIUS_IN_KM",
")",
":",
"float",
"{",
"$",
"oneRad",
"=",
"(",
"(",
"2",
"*",
"M_PI",
")",
"/",
"360",
")",
";",
"return",
"\\",
"round",
"(",
"\\",
"sqrt",
"(",
"(",
"(",
"$",
"oneRad",
"*",
"(",
"$",
"firstLatitude",
"-",
"$",
"secondLatitude",
")",
"*",
"$",
"earthRadius",
")",
"**",
"2",
")",
"+",
"(",
"(",
"$",
"oneRad",
"*",
"(",
"$",
"firstLongitude",
"-",
"$",
"secondLongitude",
")",
"*",
"$",
"earthRadius",
"*",
"\\",
"cos",
"(",
"$",
"oneRad",
"*",
"(",
"$",
"firstLatitude",
"+",
"$",
"secondLatitude",
")",
"*",
".5",
")",
")",
"**",
"2",
")",
")",
",",
"$",
"digits",
")",
";",
"}"
] | Calculate the spherical distance with the haversine formula.
@param float $firstLatitude The first latitude coordinate.
@param float $firstLongitude The first longitude coordinate.
@param float $secondLatitude The second latitude coordinate.
@param float $secondLongitude The second longitude coordinate.
@param int $digits The number of digits after the decimal point.
@param int $earthRadius The earth radius.
@return float | [
"Calculate",
"the",
"spherical",
"distance",
"with",
"the",
"haversine",
"formula",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/Helper/HaversineSphericalDistance.php#L79-L97 |
28,554 | QoboLtd/cakephp-search | src/Model/Table/AppWidgetsTable.php | AppWidgetsTable._saveAppWidgets | protected function _saveAppWidgets(): void
{
$widgets = $this->_getAppWidgets();
$found = [];
foreach ($widgets as $widget) {
$found[] = $widget['name'];
// skip adding existing app widgets
if ($this->exists(['AppWidgets.name' => $widget['name']])) {
continue;
}
$entity = $this->newEntity();
$entity = $this->patchEntity($entity, $widget);
$this->save($entity);
}
// soft delete non-existing app widgets
$this->trashAll(! empty($found) ? ['AppWidgets.name NOT IN' => $found] : []);
} | php | protected function _saveAppWidgets(): void
{
$widgets = $this->_getAppWidgets();
$found = [];
foreach ($widgets as $widget) {
$found[] = $widget['name'];
// skip adding existing app widgets
if ($this->exists(['AppWidgets.name' => $widget['name']])) {
continue;
}
$entity = $this->newEntity();
$entity = $this->patchEntity($entity, $widget);
$this->save($entity);
}
// soft delete non-existing app widgets
$this->trashAll(! empty($found) ? ['AppWidgets.name NOT IN' => $found] : []);
} | [
"protected",
"function",
"_saveAppWidgets",
"(",
")",
":",
"void",
"{",
"$",
"widgets",
"=",
"$",
"this",
"->",
"_getAppWidgets",
"(",
")",
";",
"$",
"found",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"widgets",
"as",
"$",
"widget",
")",
"{",
"$",
"found",
"[",
"]",
"=",
"$",
"widget",
"[",
"'name'",
"]",
";",
"// skip adding existing app widgets",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"[",
"'AppWidgets.name'",
"=>",
"$",
"widget",
"[",
"'name'",
"]",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"entity",
"=",
"$",
"this",
"->",
"newEntity",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"patchEntity",
"(",
"$",
"entity",
",",
"$",
"widget",
")",
";",
"$",
"this",
"->",
"save",
"(",
"$",
"entity",
")",
";",
"}",
"// soft delete non-existing app widgets",
"$",
"this",
"->",
"trashAll",
"(",
"!",
"empty",
"(",
"$",
"found",
")",
"?",
"[",
"'AppWidgets.name NOT IN'",
"=>",
"$",
"found",
"]",
":",
"[",
"]",
")",
";",
"}"
] | Store application scope widgets into the database.
@return void | [
"Store",
"application",
"scope",
"widgets",
"into",
"the",
"database",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Model/Table/AppWidgetsTable.php#L127-L147 |
28,555 | MetaModels/filter_perimetersearch | src/FilterSetting/Perimetersearch.php | Perimetersearch.getCountryInformation | protected function getCountryInformation()
{
// Get the country for the lookup.
$country = null;
if (('get' === $this->get('countrymode')) && $this->get('country_get')) {
$getValue = Input::get($this->get('country_get')) ?: Input::post($this->get('country_get'));
$getValue = \trim($getValue);
if (!empty($getValue)) {
$country = $getValue;
}
} elseif ('preset' === $this->get('countrymode')) {
$country = $this->get('country_preset');
}
return $country;
} | php | protected function getCountryInformation()
{
// Get the country for the lookup.
$country = null;
if (('get' === $this->get('countrymode')) && $this->get('country_get')) {
$getValue = Input::get($this->get('country_get')) ?: Input::post($this->get('country_get'));
$getValue = \trim($getValue);
if (!empty($getValue)) {
$country = $getValue;
}
} elseif ('preset' === $this->get('countrymode')) {
$country = $this->get('country_preset');
}
return $country;
} | [
"protected",
"function",
"getCountryInformation",
"(",
")",
"{",
"// Get the country for the lookup.",
"$",
"country",
"=",
"null",
";",
"if",
"(",
"(",
"'get'",
"===",
"$",
"this",
"->",
"get",
"(",
"'countrymode'",
")",
")",
"&&",
"$",
"this",
"->",
"get",
"(",
"'country_get'",
")",
")",
"{",
"$",
"getValue",
"=",
"Input",
"::",
"get",
"(",
"$",
"this",
"->",
"get",
"(",
"'country_get'",
")",
")",
"?",
":",
"Input",
"::",
"post",
"(",
"$",
"this",
"->",
"get",
"(",
"'country_get'",
")",
")",
";",
"$",
"getValue",
"=",
"\\",
"trim",
"(",
"$",
"getValue",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"getValue",
")",
")",
"{",
"$",
"country",
"=",
"$",
"getValue",
";",
"}",
"}",
"elseif",
"(",
"'preset'",
"===",
"$",
"this",
"->",
"get",
"(",
"'countrymode'",
")",
")",
"{",
"$",
"country",
"=",
"$",
"this",
"->",
"get",
"(",
"'country_preset'",
")",
";",
"}",
"return",
"$",
"country",
";",
"}"
] | Try to get a valid country information.
@return string|null The country short tag (2-letters) or null. | [
"Try",
"to",
"get",
"a",
"valid",
"country",
"information",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L200-L216 |
28,556 | MetaModels/filter_perimetersearch | src/FilterSetting/Perimetersearch.php | Perimetersearch.getSearchWidget | private function getSearchWidget(FrontendFilterOptions $frontendFilterOptions)
{
$widget = [
'label' => [
($this->get('label') ?: $this->getAttributeName()),
'GET: ' . $this->getParamName(),
],
'inputType' => 'text',
'count' => [],
'showCount' => $frontendFilterOptions->isShowCountValues(),
'eval' => [
'colname' => $this->getColname(),
'urlparam' => $this->getParamName(),
'template' => $this->get('template'),
'placeholder' => $this->get('placeholder')
]
];
return $widget;
} | php | private function getSearchWidget(FrontendFilterOptions $frontendFilterOptions)
{
$widget = [
'label' => [
($this->get('label') ?: $this->getAttributeName()),
'GET: ' . $this->getParamName(),
],
'inputType' => 'text',
'count' => [],
'showCount' => $frontendFilterOptions->isShowCountValues(),
'eval' => [
'colname' => $this->getColname(),
'urlparam' => $this->getParamName(),
'template' => $this->get('template'),
'placeholder' => $this->get('placeholder')
]
];
return $widget;
} | [
"private",
"function",
"getSearchWidget",
"(",
"FrontendFilterOptions",
"$",
"frontendFilterOptions",
")",
"{",
"$",
"widget",
"=",
"[",
"'label'",
"=>",
"[",
"(",
"$",
"this",
"->",
"get",
"(",
"'label'",
")",
"?",
":",
"$",
"this",
"->",
"getAttributeName",
"(",
")",
")",
",",
"'GET: '",
".",
"$",
"this",
"->",
"getParamName",
"(",
")",
",",
"]",
",",
"'inputType'",
"=>",
"'text'",
",",
"'count'",
"=>",
"[",
"]",
",",
"'showCount'",
"=>",
"$",
"frontendFilterOptions",
"->",
"isShowCountValues",
"(",
")",
",",
"'eval'",
"=>",
"[",
"'colname'",
"=>",
"$",
"this",
"->",
"getColname",
"(",
")",
",",
"'urlparam'",
"=>",
"$",
"this",
"->",
"getParamName",
"(",
")",
",",
"'template'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'template'",
")",
",",
"'placeholder'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'placeholder'",
")",
"]",
"]",
";",
"return",
"$",
"widget",
";",
"}"
] | Get the widget information for the search field.
@param FrontendFilterOptions $frontendFilterOptions The FE options.
@return array | [
"Get",
"the",
"widget",
"information",
"for",
"the",
"search",
"field",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L302-L321 |
28,557 | MetaModels/filter_perimetersearch | src/FilterSetting/Perimetersearch.php | Perimetersearch.getRangeWidget | private function getRangeWidget()
{
if ('selection' === $this->get('rangemode')) {
// Get all range options.
$rangeOptions = [];
foreach (StringUtil::deserialize($this->get('range_selection'), true) as $rangeItem) {
$rangeOptions[$rangeItem['range']] = $rangeItem['range'] . 'km';
}
$rangeWidget = [
'label' => [
($this->get('range_label') ?: $this->getAttributeName() . ' Range '),
'GET: ' . $this->getParamNameRange()
],
'inputType' => 'select',
'options' => $rangeOptions,
'eval' => [
'colname' => $this->getColname(),
'urlparam' => $this->getParamNameRange(),
'template' => $this->get('range_template')
]
];
return $rangeWidget;
}
if ('free' === $this->get('rangemode')) {
$rangeWidget = [
'label' => [
($this->get('range_label') ?: $this->getAttributeName() . ' Range '),
'GET: ' . $this->getParamNameRange()
],
'inputType' => 'text',
'eval' => [
'colname' => $this->getColname(),
'urlparam' => $this->getParamNameRange(),
'template' => $this->get('range_template'),
'placeholder' => $this->get('range_placeholder')
]
];
return $rangeWidget;
}
return null;
} | php | private function getRangeWidget()
{
if ('selection' === $this->get('rangemode')) {
// Get all range options.
$rangeOptions = [];
foreach (StringUtil::deserialize($this->get('range_selection'), true) as $rangeItem) {
$rangeOptions[$rangeItem['range']] = $rangeItem['range'] . 'km';
}
$rangeWidget = [
'label' => [
($this->get('range_label') ?: $this->getAttributeName() . ' Range '),
'GET: ' . $this->getParamNameRange()
],
'inputType' => 'select',
'options' => $rangeOptions,
'eval' => [
'colname' => $this->getColname(),
'urlparam' => $this->getParamNameRange(),
'template' => $this->get('range_template')
]
];
return $rangeWidget;
}
if ('free' === $this->get('rangemode')) {
$rangeWidget = [
'label' => [
($this->get('range_label') ?: $this->getAttributeName() . ' Range '),
'GET: ' . $this->getParamNameRange()
],
'inputType' => 'text',
'eval' => [
'colname' => $this->getColname(),
'urlparam' => $this->getParamNameRange(),
'template' => $this->get('range_template'),
'placeholder' => $this->get('range_placeholder')
]
];
return $rangeWidget;
}
return null;
} | [
"private",
"function",
"getRangeWidget",
"(",
")",
"{",
"if",
"(",
"'selection'",
"===",
"$",
"this",
"->",
"get",
"(",
"'rangemode'",
")",
")",
"{",
"// Get all range options.",
"$",
"rangeOptions",
"=",
"[",
"]",
";",
"foreach",
"(",
"StringUtil",
"::",
"deserialize",
"(",
"$",
"this",
"->",
"get",
"(",
"'range_selection'",
")",
",",
"true",
")",
"as",
"$",
"rangeItem",
")",
"{",
"$",
"rangeOptions",
"[",
"$",
"rangeItem",
"[",
"'range'",
"]",
"]",
"=",
"$",
"rangeItem",
"[",
"'range'",
"]",
".",
"'km'",
";",
"}",
"$",
"rangeWidget",
"=",
"[",
"'label'",
"=>",
"[",
"(",
"$",
"this",
"->",
"get",
"(",
"'range_label'",
")",
"?",
":",
"$",
"this",
"->",
"getAttributeName",
"(",
")",
".",
"' Range '",
")",
",",
"'GET: '",
".",
"$",
"this",
"->",
"getParamNameRange",
"(",
")",
"]",
",",
"'inputType'",
"=>",
"'select'",
",",
"'options'",
"=>",
"$",
"rangeOptions",
",",
"'eval'",
"=>",
"[",
"'colname'",
"=>",
"$",
"this",
"->",
"getColname",
"(",
")",
",",
"'urlparam'",
"=>",
"$",
"this",
"->",
"getParamNameRange",
"(",
")",
",",
"'template'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'range_template'",
")",
"]",
"]",
";",
"return",
"$",
"rangeWidget",
";",
"}",
"if",
"(",
"'free'",
"===",
"$",
"this",
"->",
"get",
"(",
"'rangemode'",
")",
")",
"{",
"$",
"rangeWidget",
"=",
"[",
"'label'",
"=>",
"[",
"(",
"$",
"this",
"->",
"get",
"(",
"'range_label'",
")",
"?",
":",
"$",
"this",
"->",
"getAttributeName",
"(",
")",
".",
"' Range '",
")",
",",
"'GET: '",
".",
"$",
"this",
"->",
"getParamNameRange",
"(",
")",
"]",
",",
"'inputType'",
"=>",
"'text'",
",",
"'eval'",
"=>",
"[",
"'colname'",
"=>",
"$",
"this",
"->",
"getColname",
"(",
")",
",",
"'urlparam'",
"=>",
"$",
"this",
"->",
"getParamNameRange",
"(",
")",
",",
"'template'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'range_template'",
")",
",",
"'placeholder'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'range_placeholder'",
")",
"]",
"]",
";",
"return",
"$",
"rangeWidget",
";",
"}",
"return",
"null",
";",
"}"
] | Get the widget for the distance.
@return array|null | [
"Get",
"the",
"widget",
"for",
"the",
"distance",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L329-L375 |
28,558 | MetaModels/filter_perimetersearch | src/FilterSetting/Perimetersearch.php | Perimetersearch.lookupGeo | protected function lookupGeo($address, $country)
{
// Trim the data. Better!
$address = \trim($address);
$country = \trim($country);
// First check cache.
$cacheResult = $this->getFromCache($address, $country);
if (null !== $cacheResult) {
return $cacheResult;
}
// If there is no data from the cache ask google.
$lookupServices = (array) StringUtil::deserialize($this->get('lookupservice'), true);
if (!\count($lookupServices)) {
return null;
}
foreach ($lookupServices as $lookupService) {
try {
$callback = $this->getObjectFromName($lookupService['lookupservice']);
// Call the main function.
if (null !== $callback) {
/** @var Container $result */
$result = $callback
->getCoordinates(
null,
null,
null,
$country,
$address,
$lookupService['apiToken'] ?: null
);
// Check if we have a result.
if (!$result->hasError()) {
$this->addToCache($address, $country, $result);
return $result;
}
}
} catch (\RuntimeException $exc) {
// Okay, we have an error try next one.
continue;
}
}
// When we reach this point, we have no result, so return false.
return null;
} | php | protected function lookupGeo($address, $country)
{
// Trim the data. Better!
$address = \trim($address);
$country = \trim($country);
// First check cache.
$cacheResult = $this->getFromCache($address, $country);
if (null !== $cacheResult) {
return $cacheResult;
}
// If there is no data from the cache ask google.
$lookupServices = (array) StringUtil::deserialize($this->get('lookupservice'), true);
if (!\count($lookupServices)) {
return null;
}
foreach ($lookupServices as $lookupService) {
try {
$callback = $this->getObjectFromName($lookupService['lookupservice']);
// Call the main function.
if (null !== $callback) {
/** @var Container $result */
$result = $callback
->getCoordinates(
null,
null,
null,
$country,
$address,
$lookupService['apiToken'] ?: null
);
// Check if we have a result.
if (!$result->hasError()) {
$this->addToCache($address, $country, $result);
return $result;
}
}
} catch (\RuntimeException $exc) {
// Okay, we have an error try next one.
continue;
}
}
// When we reach this point, we have no result, so return false.
return null;
} | [
"protected",
"function",
"lookupGeo",
"(",
"$",
"address",
",",
"$",
"country",
")",
"{",
"// Trim the data. Better!",
"$",
"address",
"=",
"\\",
"trim",
"(",
"$",
"address",
")",
";",
"$",
"country",
"=",
"\\",
"trim",
"(",
"$",
"country",
")",
";",
"// First check cache.",
"$",
"cacheResult",
"=",
"$",
"this",
"->",
"getFromCache",
"(",
"$",
"address",
",",
"$",
"country",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"cacheResult",
")",
"{",
"return",
"$",
"cacheResult",
";",
"}",
"// If there is no data from the cache ask google.",
"$",
"lookupServices",
"=",
"(",
"array",
")",
"StringUtil",
"::",
"deserialize",
"(",
"$",
"this",
"->",
"get",
"(",
"'lookupservice'",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"\\",
"count",
"(",
"$",
"lookupServices",
")",
")",
"{",
"return",
"null",
";",
"}",
"foreach",
"(",
"$",
"lookupServices",
"as",
"$",
"lookupService",
")",
"{",
"try",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"getObjectFromName",
"(",
"$",
"lookupService",
"[",
"'lookupservice'",
"]",
")",
";",
"// Call the main function.",
"if",
"(",
"null",
"!==",
"$",
"callback",
")",
"{",
"/** @var Container $result */",
"$",
"result",
"=",
"$",
"callback",
"->",
"getCoordinates",
"(",
"null",
",",
"null",
",",
"null",
",",
"$",
"country",
",",
"$",
"address",
",",
"$",
"lookupService",
"[",
"'apiToken'",
"]",
"?",
":",
"null",
")",
";",
"// Check if we have a result.",
"if",
"(",
"!",
"$",
"result",
"->",
"hasError",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addToCache",
"(",
"$",
"address",
",",
"$",
"country",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}",
"}",
"}",
"catch",
"(",
"\\",
"RuntimeException",
"$",
"exc",
")",
"{",
"// Okay, we have an error try next one.",
"continue",
";",
"}",
"}",
"// When we reach this point, we have no result, so return false.",
"return",
"null",
";",
"}"
] | User the provider classes to make a look up.
@param string $address The full address to search for.
@param string $country The country as 2-letters form.
@return Container|null Return the container with all information or null on error. | [
"User",
"the",
"provider",
"classes",
"to",
"make",
"a",
"look",
"up",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L505-L555 |
28,559 | MetaModels/filter_perimetersearch | src/FilterSetting/Perimetersearch.php | Perimetersearch.getObjectFromName | protected function getObjectFromName($lookupClassName)
{
// Check if we know this class.
if (!isset($GLOBALS['METAMODELS']['filters']['perimetersearch']['resolve_class'][$lookupClassName])) {
return null;
}
$reflectionName = $GLOBALS['METAMODELS']['filters']['perimetersearch']['resolve_class'][$lookupClassName];
$reflection = new \ReflectionClass($reflectionName);
// Fetch singleton instance.
if ($reflection->hasMethod('getInstance')) {
$getInstanceMethod = $reflection->getMethod('getInstance');
// Create a new instance.
if ($getInstanceMethod->isStatic()) {
return $getInstanceMethod->invoke(null);
}
return $reflection->newInstance();
}
// Create a normal object.
return $reflection->newInstance();
} | php | protected function getObjectFromName($lookupClassName)
{
// Check if we know this class.
if (!isset($GLOBALS['METAMODELS']['filters']['perimetersearch']['resolve_class'][$lookupClassName])) {
return null;
}
$reflectionName = $GLOBALS['METAMODELS']['filters']['perimetersearch']['resolve_class'][$lookupClassName];
$reflection = new \ReflectionClass($reflectionName);
// Fetch singleton instance.
if ($reflection->hasMethod('getInstance')) {
$getInstanceMethod = $reflection->getMethod('getInstance');
// Create a new instance.
if ($getInstanceMethod->isStatic()) {
return $getInstanceMethod->invoke(null);
}
return $reflection->newInstance();
}
// Create a normal object.
return $reflection->newInstance();
} | [
"protected",
"function",
"getObjectFromName",
"(",
"$",
"lookupClassName",
")",
"{",
"// Check if we know this class.",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'METAMODELS'",
"]",
"[",
"'filters'",
"]",
"[",
"'perimetersearch'",
"]",
"[",
"'resolve_class'",
"]",
"[",
"$",
"lookupClassName",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"reflectionName",
"=",
"$",
"GLOBALS",
"[",
"'METAMODELS'",
"]",
"[",
"'filters'",
"]",
"[",
"'perimetersearch'",
"]",
"[",
"'resolve_class'",
"]",
"[",
"$",
"lookupClassName",
"]",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"reflectionName",
")",
";",
"// Fetch singleton instance.",
"if",
"(",
"$",
"reflection",
"->",
"hasMethod",
"(",
"'getInstance'",
")",
")",
"{",
"$",
"getInstanceMethod",
"=",
"$",
"reflection",
"->",
"getMethod",
"(",
"'getInstance'",
")",
";",
"// Create a new instance.",
"if",
"(",
"$",
"getInstanceMethod",
"->",
"isStatic",
"(",
")",
")",
"{",
"return",
"$",
"getInstanceMethod",
"->",
"invoke",
"(",
"null",
")",
";",
"}",
"return",
"$",
"reflection",
"->",
"newInstance",
"(",
")",
";",
"}",
"// Create a normal object.",
"return",
"$",
"reflection",
"->",
"newInstance",
"(",
")",
";",
"}"
] | Try to get a object from the given class.
@param string $lookupClassName The name of the class.
@return null|object
@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName) | [
"Try",
"to",
"get",
"a",
"object",
"from",
"the",
"given",
"class",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L567-L592 |
28,560 | MetaModels/filter_perimetersearch | src/FilterSetting/Perimetersearch.php | Perimetersearch.addToCache | protected function addToCache($address, $country, $result)
{
$this->connection->insert(
'tl_metamodel_perimetersearch',
[
$this->connection->quoteIdentifier('search') => $address,
$this->connection->quoteIdentifier('country') => $country,
$this->connection->quoteIdentifier('geo_lat') => $result->getLatitude(),
$this->connection->quoteIdentifier('geo_long') => $result->getLongitude()
]
);
} | php | protected function addToCache($address, $country, $result)
{
$this->connection->insert(
'tl_metamodel_perimetersearch',
[
$this->connection->quoteIdentifier('search') => $address,
$this->connection->quoteIdentifier('country') => $country,
$this->connection->quoteIdentifier('geo_lat') => $result->getLatitude(),
$this->connection->quoteIdentifier('geo_long') => $result->getLongitude()
]
);
} | [
"protected",
"function",
"addToCache",
"(",
"$",
"address",
",",
"$",
"country",
",",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"insert",
"(",
"'tl_metamodel_perimetersearch'",
",",
"[",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"'search'",
")",
"=>",
"$",
"address",
",",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"'country'",
")",
"=>",
"$",
"country",
",",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"'geo_lat'",
")",
"=>",
"$",
"result",
"->",
"getLatitude",
"(",
")",
",",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"'geo_long'",
")",
"=>",
"$",
"result",
"->",
"getLongitude",
"(",
")",
"]",
")",
";",
"}"
] | Add data to the cache.
@param string $address The address which where use for the search.
@param string $country The country.
@param Container $result The container with all information.
@return void
@throws \Doctrine\DBAL\DBALException When insert fails. | [
"Add",
"data",
"to",
"the",
"cache",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L605-L616 |
28,561 | MetaModels/filter_perimetersearch | src/FilterSetting/Perimetersearch.php | Perimetersearch.getFromCache | protected function getFromCache($address, $country)
{
$builder = $this->connection->createQueryBuilder();
$builder
->select('*')
->from($this->connection->quoteIdentifier('tl_metamodel_perimetersearch'))
->where($builder->expr()->eq($this->connection->quoteIdentifier('search'), ':search'))
->andWhere($builder->expr()->eq($this->connection->quoteIdentifier('country'), ':country'))
->setParameter('search', $address)
->setParameter('country', $country);
$statement = $builder->execute();
// If we have no data just return null.
if (!$statement->rowCount()) {
return null;
}
$result = $statement->fetch(\PDO::FETCH_OBJ);
// Build a new container.
$container = new Container();
$container->setLatitude($result->geo_lat);
$container->setLongitude($result->geo_long);
$container->setSearchParam(
\strtr(
$builder->getSQL(),
[
':search' => $this->connection->quote($address),
':country' => $this->connection->quote($country)
]
)
);
return $container;
} | php | protected function getFromCache($address, $country)
{
$builder = $this->connection->createQueryBuilder();
$builder
->select('*')
->from($this->connection->quoteIdentifier('tl_metamodel_perimetersearch'))
->where($builder->expr()->eq($this->connection->quoteIdentifier('search'), ':search'))
->andWhere($builder->expr()->eq($this->connection->quoteIdentifier('country'), ':country'))
->setParameter('search', $address)
->setParameter('country', $country);
$statement = $builder->execute();
// If we have no data just return null.
if (!$statement->rowCount()) {
return null;
}
$result = $statement->fetch(\PDO::FETCH_OBJ);
// Build a new container.
$container = new Container();
$container->setLatitude($result->geo_lat);
$container->setLongitude($result->geo_long);
$container->setSearchParam(
\strtr(
$builder->getSQL(),
[
':search' => $this->connection->quote($address),
':country' => $this->connection->quote($country)
]
)
);
return $container;
} | [
"protected",
"function",
"getFromCache",
"(",
"$",
"address",
",",
"$",
"country",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"builder",
"->",
"select",
"(",
"'*'",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"'tl_metamodel_perimetersearch'",
")",
")",
"->",
"where",
"(",
"$",
"builder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"'search'",
")",
",",
"':search'",
")",
")",
"->",
"andWhere",
"(",
"$",
"builder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"'country'",
")",
",",
"':country'",
")",
")",
"->",
"setParameter",
"(",
"'search'",
",",
"$",
"address",
")",
"->",
"setParameter",
"(",
"'country'",
",",
"$",
"country",
")",
";",
"$",
"statement",
"=",
"$",
"builder",
"->",
"execute",
"(",
")",
";",
"// If we have no data just return null.",
"if",
"(",
"!",
"$",
"statement",
"->",
"rowCount",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"result",
"=",
"$",
"statement",
"->",
"fetch",
"(",
"\\",
"PDO",
"::",
"FETCH_OBJ",
")",
";",
"// Build a new container.",
"$",
"container",
"=",
"new",
"Container",
"(",
")",
";",
"$",
"container",
"->",
"setLatitude",
"(",
"$",
"result",
"->",
"geo_lat",
")",
";",
"$",
"container",
"->",
"setLongitude",
"(",
"$",
"result",
"->",
"geo_long",
")",
";",
"$",
"container",
"->",
"setSearchParam",
"(",
"\\",
"strtr",
"(",
"$",
"builder",
"->",
"getSQL",
"(",
")",
",",
"[",
"':search'",
"=>",
"$",
"this",
"->",
"connection",
"->",
"quote",
"(",
"$",
"address",
")",
",",
"':country'",
"=>",
"$",
"this",
"->",
"connection",
"->",
"quote",
"(",
"$",
"country",
")",
"]",
")",
")",
";",
"return",
"$",
"container",
";",
"}"
] | Get data from cache.
@param string $address The address which where use for the search.
@param string $country The country.
@return Container|null | [
"Get",
"data",
"from",
"cache",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L626-L661 |
28,562 | MetaModels/filter_perimetersearch | src/FilterRules/Perimetersearch.php | Perimetersearch.getMetaModelTableName | private function getMetaModelTableName()
{
$attribute = ((int) $this->mode === self::MODE_SINGLE) ? $this->singleAttribute : $this->latitudeAttribute;
return $attribute
->getMetaModel()
->getTableName();
} | php | private function getMetaModelTableName()
{
$attribute = ((int) $this->mode === self::MODE_SINGLE) ? $this->singleAttribute : $this->latitudeAttribute;
return $attribute
->getMetaModel()
->getTableName();
} | [
"private",
"function",
"getMetaModelTableName",
"(",
")",
"{",
"$",
"attribute",
"=",
"(",
"(",
"int",
")",
"$",
"this",
"->",
"mode",
"===",
"self",
"::",
"MODE_SINGLE",
")",
"?",
"$",
"this",
"->",
"singleAttribute",
":",
"$",
"this",
"->",
"latitudeAttribute",
";",
"return",
"$",
"attribute",
"->",
"getMetaModel",
"(",
")",
"->",
"getTableName",
"(",
")",
";",
"}"
] | Get the table name from the MetaModel.
@return string | [
"Get",
"the",
"table",
"name",
"from",
"the",
"MetaModel",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterRules/Perimetersearch.php#L160-L167 |
28,563 | MetaModels/filter_perimetersearch | src/FilterRules/Perimetersearch.php | Perimetersearch.checkAttributeTypes | private function checkAttributeTypes($latitudeAttribute, $longitudeAttribute, $singleAttribute)
{
if (null !== $singleAttribute) {
$this->checkMultiAttribute($singleAttribute);
$this->mode = self::MODE_SINGLE;
return;
}
if ((null !== $latitudeAttribute) && (null !== $longitudeAttribute)) {
$this->checkSingleAttributes($latitudeAttribute, $longitudeAttribute);
$this->mode = self::MODE_MULTI;
return;
}
// If we have no hit throw an exception.
throw new \InvalidArgumentException(
'Need a pair of valid latitude and longitude attributes or a valid geolocation attribute.'
);
} | php | private function checkAttributeTypes($latitudeAttribute, $longitudeAttribute, $singleAttribute)
{
if (null !== $singleAttribute) {
$this->checkMultiAttribute($singleAttribute);
$this->mode = self::MODE_SINGLE;
return;
}
if ((null !== $latitudeAttribute) && (null !== $longitudeAttribute)) {
$this->checkSingleAttributes($latitudeAttribute, $longitudeAttribute);
$this->mode = self::MODE_MULTI;
return;
}
// If we have no hit throw an exception.
throw new \InvalidArgumentException(
'Need a pair of valid latitude and longitude attributes or a valid geolocation attribute.'
);
} | [
"private",
"function",
"checkAttributeTypes",
"(",
"$",
"latitudeAttribute",
",",
"$",
"longitudeAttribute",
",",
"$",
"singleAttribute",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"singleAttribute",
")",
"{",
"$",
"this",
"->",
"checkMultiAttribute",
"(",
"$",
"singleAttribute",
")",
";",
"$",
"this",
"->",
"mode",
"=",
"self",
"::",
"MODE_SINGLE",
";",
"return",
";",
"}",
"if",
"(",
"(",
"null",
"!==",
"$",
"latitudeAttribute",
")",
"&&",
"(",
"null",
"!==",
"$",
"longitudeAttribute",
")",
")",
"{",
"$",
"this",
"->",
"checkSingleAttributes",
"(",
"$",
"latitudeAttribute",
",",
"$",
"longitudeAttribute",
")",
";",
"$",
"this",
"->",
"mode",
"=",
"self",
"::",
"MODE_MULTI",
";",
"return",
";",
"}",
"// If we have no hit throw an exception.",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Need a pair of valid latitude and longitude attributes or a valid geolocation attribute.'",
")",
";",
"}"
] | Check the attribute.
@param IAttribute $latitudeAttribute The attribute to be checked.
@param IAttribute $longitudeAttribute The attribute to be checked.
@param IAttribute $singleAttribute The attribute to be checked.
@return void
@throws \InvalidArgumentException If we have no single attribute or the lang/lot attribute is missing. | [
"Check",
"the",
"attribute",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterRules/Perimetersearch.php#L197-L215 |
28,564 | MetaModels/filter_perimetersearch | src/FilterRules/Perimetersearch.php | Perimetersearch.checkSingleAttributes | private function checkSingleAttributes($latitudeAttribute, $longitudeAttribute)
{
// Check if both of the are simple
if (!($latitudeAttribute instanceof ISimple) || !($longitudeAttribute instanceof ISimple)) {
throw new \InvalidArgumentException('Only simple attributes are allowed.');
}
if ($latitudeAttribute->getMetaModel() !== $longitudeAttribute->getMetaModel()) {
throw new \InvalidArgumentException('The first and second attribute have to be from the same MetaModel.');
}
} | php | private function checkSingleAttributes($latitudeAttribute, $longitudeAttribute)
{
// Check if both of the are simple
if (!($latitudeAttribute instanceof ISimple) || !($longitudeAttribute instanceof ISimple)) {
throw new \InvalidArgumentException('Only simple attributes are allowed.');
}
if ($latitudeAttribute->getMetaModel() !== $longitudeAttribute->getMetaModel()) {
throw new \InvalidArgumentException('The first and second attribute have to be from the same MetaModel.');
}
} | [
"private",
"function",
"checkSingleAttributes",
"(",
"$",
"latitudeAttribute",
",",
"$",
"longitudeAttribute",
")",
"{",
"// Check if both of the are simple",
"if",
"(",
"!",
"(",
"$",
"latitudeAttribute",
"instanceof",
"ISimple",
")",
"||",
"!",
"(",
"$",
"longitudeAttribute",
"instanceof",
"ISimple",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Only simple attributes are allowed.'",
")",
";",
"}",
"if",
"(",
"$",
"latitudeAttribute",
"->",
"getMetaModel",
"(",
")",
"!==",
"$",
"longitudeAttribute",
"->",
"getMetaModel",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The first and second attribute have to be from the same MetaModel.'",
")",
";",
"}",
"}"
] | Check the single attributes.
@param IAttribute $latitudeAttribute The attribute to be checked.
@param IAttribute $longitudeAttribute The attribute to be checked.
@return void
@throws \InvalidArgumentException If one of the attribute is not from type ISimple. | [
"Check",
"the",
"single",
"attributes",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterRules/Perimetersearch.php#L244-L254 |
28,565 | MetaModels/filter_perimetersearch | src/FilterRules/Perimetersearch.php | Perimetersearch.runSimpleQuery | protected function runSimpleQuery($idField, $tableName, $latitudeField, $longitudeField, $additionalWhere)
{
$distanceCalculation = HaversineSphericalDistance::getFormulaAsQueryPart(
$this->latitude,
$this->longitude,
$this->connection->quoteIdentifier($latitudeField),
$this->connection->quoteIdentifier($longitudeField),
2
);
$builder = $this->connection->createQueryBuilder();
$builder
->select($this->connection->quoteIdentifier($idField))
->from($tableName)
->where($builder->expr()->lte($distanceCalculation, ':distance'))
->orderBy($distanceCalculation)
->setParameter('distance', $this->dist);
if ($additionalWhere) {
foreach ($additionalWhere as $index => $where) {
if (0 === $index) {
$builder->where($where);
}
$builder->andWhere($where);
}
$builder->andWhere($builder->expr()->lte($distanceCalculation, ':distance'));
} else {
$builder->where($builder->expr()->lte($distanceCalculation, ':distance'));
}
$statement = $builder->execute();
if (!$statement->rowCount()) {
return [];
}
return $statement->fetchAll(\PDO::FETCH_COLUMN);
} | php | protected function runSimpleQuery($idField, $tableName, $latitudeField, $longitudeField, $additionalWhere)
{
$distanceCalculation = HaversineSphericalDistance::getFormulaAsQueryPart(
$this->latitude,
$this->longitude,
$this->connection->quoteIdentifier($latitudeField),
$this->connection->quoteIdentifier($longitudeField),
2
);
$builder = $this->connection->createQueryBuilder();
$builder
->select($this->connection->quoteIdentifier($idField))
->from($tableName)
->where($builder->expr()->lte($distanceCalculation, ':distance'))
->orderBy($distanceCalculation)
->setParameter('distance', $this->dist);
if ($additionalWhere) {
foreach ($additionalWhere as $index => $where) {
if (0 === $index) {
$builder->where($where);
}
$builder->andWhere($where);
}
$builder->andWhere($builder->expr()->lte($distanceCalculation, ':distance'));
} else {
$builder->where($builder->expr()->lte($distanceCalculation, ':distance'));
}
$statement = $builder->execute();
if (!$statement->rowCount()) {
return [];
}
return $statement->fetchAll(\PDO::FETCH_COLUMN);
} | [
"protected",
"function",
"runSimpleQuery",
"(",
"$",
"idField",
",",
"$",
"tableName",
",",
"$",
"latitudeField",
",",
"$",
"longitudeField",
",",
"$",
"additionalWhere",
")",
"{",
"$",
"distanceCalculation",
"=",
"HaversineSphericalDistance",
"::",
"getFormulaAsQueryPart",
"(",
"$",
"this",
"->",
"latitude",
",",
"$",
"this",
"->",
"longitude",
",",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"$",
"latitudeField",
")",
",",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"$",
"longitudeField",
")",
",",
"2",
")",
";",
"$",
"builder",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"builder",
"->",
"select",
"(",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"$",
"idField",
")",
")",
"->",
"from",
"(",
"$",
"tableName",
")",
"->",
"where",
"(",
"$",
"builder",
"->",
"expr",
"(",
")",
"->",
"lte",
"(",
"$",
"distanceCalculation",
",",
"':distance'",
")",
")",
"->",
"orderBy",
"(",
"$",
"distanceCalculation",
")",
"->",
"setParameter",
"(",
"'distance'",
",",
"$",
"this",
"->",
"dist",
")",
";",
"if",
"(",
"$",
"additionalWhere",
")",
"{",
"foreach",
"(",
"$",
"additionalWhere",
"as",
"$",
"index",
"=>",
"$",
"where",
")",
"{",
"if",
"(",
"0",
"===",
"$",
"index",
")",
"{",
"$",
"builder",
"->",
"where",
"(",
"$",
"where",
")",
";",
"}",
"$",
"builder",
"->",
"andWhere",
"(",
"$",
"where",
")",
";",
"}",
"$",
"builder",
"->",
"andWhere",
"(",
"$",
"builder",
"->",
"expr",
"(",
")",
"->",
"lte",
"(",
"$",
"distanceCalculation",
",",
"':distance'",
")",
")",
";",
"}",
"else",
"{",
"$",
"builder",
"->",
"where",
"(",
"$",
"builder",
"->",
"expr",
"(",
")",
"->",
"lte",
"(",
"$",
"distanceCalculation",
",",
"':distance'",
")",
")",
";",
"}",
"$",
"statement",
"=",
"$",
"builder",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"!",
"$",
"statement",
"->",
"rowCount",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"statement",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_COLUMN",
")",
";",
"}"
] | Build the SQL and execute it.
@param string $idField Name of the id field.
@param string $tableName The name of the table.
@param string $latitudeField The name of the latitude field.
@param string $longitudeField The name of the longitude field.
@param array|null $additionalWhere A list with additional where information.
@return array A list with ID's or an empty array. | [
"Build",
"the",
"SQL",
"and",
"execute",
"it",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterRules/Perimetersearch.php#L291-L329 |
28,566 | MetaModels/filter_perimetersearch | src/FilterRules/Perimetersearch.php | Perimetersearch.buildAdditionalWhere | protected function buildAdditionalWhere($additionalWhere)
{
if (null === $additionalWhere) {
return null;
}
$sql = \implode(' AND ', \array_keys((array) $additionalWhere));
return ('' !== $sql) ? $sql . ' AND ' : null;
} | php | protected function buildAdditionalWhere($additionalWhere)
{
if (null === $additionalWhere) {
return null;
}
$sql = \implode(' AND ', \array_keys((array) $additionalWhere));
return ('' !== $sql) ? $sql . ' AND ' : null;
} | [
"protected",
"function",
"buildAdditionalWhere",
"(",
"$",
"additionalWhere",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"additionalWhere",
")",
"{",
"return",
"null",
";",
"}",
"$",
"sql",
"=",
"\\",
"implode",
"(",
"' AND '",
",",
"\\",
"array_keys",
"(",
"(",
"array",
")",
"$",
"additionalWhere",
")",
")",
";",
"return",
"(",
"''",
"!==",
"$",
"sql",
")",
"?",
"$",
"sql",
".",
"' AND '",
":",
"null",
";",
"}"
] | Build a where ...
@param array $additionalWhere A list with additional where information.
@return null|string
@deprecated This is deprecated since 2.1 and where remove in 3.0. | [
"Build",
"a",
"where",
"..."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterRules/Perimetersearch.php#L340-L349 |
28,567 | hiqdev/hipanel-module-finance | src/logic/AbstractTariffManager.php | AbstractTariffManager.determineParentTariff | protected function determineParentTariff()
{
if ($this->tariff === null) {
if (!empty($this->parent_id)) {
return $this->parent_id;
}
return null;
}
if ($this->tariff->parent_id !== null) {
return $this->tariff->parent_id;
}
return $this->tariff->id;
} | php | protected function determineParentTariff()
{
if ($this->tariff === null) {
if (!empty($this->parent_id)) {
return $this->parent_id;
}
return null;
}
if ($this->tariff->parent_id !== null) {
return $this->tariff->parent_id;
}
return $this->tariff->id;
} | [
"protected",
"function",
"determineParentTariff",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tariff",
"===",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"parent_id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parent_id",
";",
"}",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"tariff",
"->",
"parent_id",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"tariff",
"->",
"parent_id",
";",
"}",
"return",
"$",
"this",
"->",
"tariff",
"->",
"id",
";",
"}"
] | Finds parent tariff ID.
@return int | [
"Finds",
"parent",
"tariff",
"ID",
"."
] | fa027420ddc1d6de22a6d830e14dde587c837220 | https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/logic/AbstractTariffManager.php#L112-L127 |
28,568 | TYPO3-CMS/redirects | Classes/Http/Middleware/RedirectHandler.php | RedirectHandler.process | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$redirectService = GeneralUtility::makeInstance(RedirectService::class);
$port = $request->getUri()->getPort();
$matchedRedirect = $redirectService->matchRedirect(
$request->getUri()->getHost() . ($port ? ':' . $port : ''),
$request->getUri()->getPath(),
$request->getUri()->getQuery() ?? ''
);
// If the matched redirect is found, resolve it, and check further
if (is_array($matchedRedirect)) {
$url = $redirectService->getTargetUrl($matchedRedirect, $request->getQueryParams(), $request->getAttribute('site', null));
if ($url instanceof UriInterface) {
$this->logger->debug('Redirecting', ['record' => $matchedRedirect, 'uri' => $url]);
$response = $this->buildRedirectResponse($url, $matchedRedirect);
$this->incrementHitCount($matchedRedirect);
return $response;
}
}
return $handler->handle($request);
} | php | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$redirectService = GeneralUtility::makeInstance(RedirectService::class);
$port = $request->getUri()->getPort();
$matchedRedirect = $redirectService->matchRedirect(
$request->getUri()->getHost() . ($port ? ':' . $port : ''),
$request->getUri()->getPath(),
$request->getUri()->getQuery() ?? ''
);
// If the matched redirect is found, resolve it, and check further
if (is_array($matchedRedirect)) {
$url = $redirectService->getTargetUrl($matchedRedirect, $request->getQueryParams(), $request->getAttribute('site', null));
if ($url instanceof UriInterface) {
$this->logger->debug('Redirecting', ['record' => $matchedRedirect, 'uri' => $url]);
$response = $this->buildRedirectResponse($url, $matchedRedirect);
$this->incrementHitCount($matchedRedirect);
return $response;
}
}
return $handler->handle($request);
} | [
"public",
"function",
"process",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"RequestHandlerInterface",
"$",
"handler",
")",
":",
"ResponseInterface",
"{",
"$",
"redirectService",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"RedirectService",
"::",
"class",
")",
";",
"$",
"port",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getPort",
"(",
")",
";",
"$",
"matchedRedirect",
"=",
"$",
"redirectService",
"->",
"matchRedirect",
"(",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getHost",
"(",
")",
".",
"(",
"$",
"port",
"?",
"':'",
".",
"$",
"port",
":",
"''",
")",
",",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
",",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getQuery",
"(",
")",
"??",
"''",
")",
";",
"// If the matched redirect is found, resolve it, and check further",
"if",
"(",
"is_array",
"(",
"$",
"matchedRedirect",
")",
")",
"{",
"$",
"url",
"=",
"$",
"redirectService",
"->",
"getTargetUrl",
"(",
"$",
"matchedRedirect",
",",
"$",
"request",
"->",
"getQueryParams",
"(",
")",
",",
"$",
"request",
"->",
"getAttribute",
"(",
"'site'",
",",
"null",
")",
")",
";",
"if",
"(",
"$",
"url",
"instanceof",
"UriInterface",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'Redirecting'",
",",
"[",
"'record'",
"=>",
"$",
"matchedRedirect",
",",
"'uri'",
"=>",
"$",
"url",
"]",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"buildRedirectResponse",
"(",
"$",
"url",
",",
"$",
"matchedRedirect",
")",
";",
"$",
"this",
"->",
"incrementHitCount",
"(",
"$",
"matchedRedirect",
")",
";",
"return",
"$",
"response",
";",
"}",
"}",
"return",
"$",
"handler",
"->",
"handle",
"(",
"$",
"request",
")",
";",
"}"
] | First hook within the Frontend Request handling
@param ServerRequestInterface $request
@param RequestHandlerInterface $handler
@return ResponseInterface | [
"First",
"hook",
"within",
"the",
"Frontend",
"Request",
"handling"
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Http/Middleware/RedirectHandler.php#L48-L71 |
28,569 | TYPO3-CMS/redirects | Classes/Http/Middleware/RedirectHandler.php | RedirectHandler.buildRedirectResponse | protected function buildRedirectResponse(UriInterface $uri, array $redirectRecord): ResponseInterface
{
return new RedirectResponse(
$uri,
(int)$redirectRecord['target_statuscode'],
['X-Redirect-By' => 'TYPO3 Redirect ' . $redirectRecord['uid']]
);
} | php | protected function buildRedirectResponse(UriInterface $uri, array $redirectRecord): ResponseInterface
{
return new RedirectResponse(
$uri,
(int)$redirectRecord['target_statuscode'],
['X-Redirect-By' => 'TYPO3 Redirect ' . $redirectRecord['uid']]
);
} | [
"protected",
"function",
"buildRedirectResponse",
"(",
"UriInterface",
"$",
"uri",
",",
"array",
"$",
"redirectRecord",
")",
":",
"ResponseInterface",
"{",
"return",
"new",
"RedirectResponse",
"(",
"$",
"uri",
",",
"(",
"int",
")",
"$",
"redirectRecord",
"[",
"'target_statuscode'",
"]",
",",
"[",
"'X-Redirect-By'",
"=>",
"'TYPO3 Redirect '",
".",
"$",
"redirectRecord",
"[",
"'uid'",
"]",
"]",
")",
";",
"}"
] | Creates a PSR-7 compatible Response object
@param UriInterface $uri
@param array $redirectRecord
@return ResponseInterface | [
"Creates",
"a",
"PSR",
"-",
"7",
"compatible",
"Response",
"object"
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Http/Middleware/RedirectHandler.php#L80-L87 |
28,570 | TYPO3-CMS/redirects | Classes/Http/Middleware/RedirectHandler.php | RedirectHandler.incrementHitCount | protected function incrementHitCount(array $redirectRecord)
{
// Track the hit if not disabled
if (!GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount') || $redirectRecord['disable_hitcount']) {
return;
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('sys_redirect');
$queryBuilder
->update('sys_redirect')
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($redirectRecord['uid'], \PDO::PARAM_INT))
)
->set('hitcount', $queryBuilder->quoteIdentifier('hitcount') . '+1', false)
->set('lasthiton', $GLOBALS['EXEC_TIME'])
->execute();
} | php | protected function incrementHitCount(array $redirectRecord)
{
// Track the hit if not disabled
if (!GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount') || $redirectRecord['disable_hitcount']) {
return;
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('sys_redirect');
$queryBuilder
->update('sys_redirect')
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($redirectRecord['uid'], \PDO::PARAM_INT))
)
->set('hitcount', $queryBuilder->quoteIdentifier('hitcount') . '+1', false)
->set('lasthiton', $GLOBALS['EXEC_TIME'])
->execute();
} | [
"protected",
"function",
"incrementHitCount",
"(",
"array",
"$",
"redirectRecord",
")",
"{",
"// Track the hit if not disabled",
"if",
"(",
"!",
"GeneralUtility",
"::",
"makeInstance",
"(",
"Features",
"::",
"class",
")",
"->",
"isFeatureEnabled",
"(",
"'redirects.hitCount'",
")",
"||",
"$",
"redirectRecord",
"[",
"'disable_hitcount'",
"]",
")",
"{",
"return",
";",
"}",
"$",
"queryBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ConnectionPool",
"::",
"class",
")",
"->",
"getQueryBuilderForTable",
"(",
"'sys_redirect'",
")",
";",
"$",
"queryBuilder",
"->",
"update",
"(",
"'sys_redirect'",
")",
"->",
"where",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'uid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"$",
"redirectRecord",
"[",
"'uid'",
"]",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
")",
"->",
"set",
"(",
"'hitcount'",
",",
"$",
"queryBuilder",
"->",
"quoteIdentifier",
"(",
"'hitcount'",
")",
".",
"'+1'",
",",
"false",
")",
"->",
"set",
"(",
"'lasthiton'",
",",
"$",
"GLOBALS",
"[",
"'EXEC_TIME'",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}"
] | Updates the sys_record's hit counter by one
@param array $redirectRecord | [
"Updates",
"the",
"sys_record",
"s",
"hit",
"counter",
"by",
"one"
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Http/Middleware/RedirectHandler.php#L94-L110 |
28,571 | hiqdev/hipanel-module-finance | src/grid/BillGridView.php | BillGridView.objectLink | public function objectLink(Bill $model): string
{
return $model->class === 'device'
? Html::a($model->object, ['@server/view', 'id' => $model->object_id])
: Html::tag('b', $model->object);
} | php | public function objectLink(Bill $model): string
{
return $model->class === 'device'
? Html::a($model->object, ['@server/view', 'id' => $model->object_id])
: Html::tag('b', $model->object);
} | [
"public",
"function",
"objectLink",
"(",
"Bill",
"$",
"model",
")",
":",
"string",
"{",
"return",
"$",
"model",
"->",
"class",
"===",
"'device'",
"?",
"Html",
"::",
"a",
"(",
"$",
"model",
"->",
"object",
",",
"[",
"'@server/view'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"object_id",
"]",
")",
":",
"Html",
"::",
"tag",
"(",
"'b'",
",",
"$",
"model",
"->",
"object",
")",
";",
"}"
] | Creates link to object details page.
@param Bill $model
@return string | [
"Creates",
"link",
"to",
"object",
"details",
"page",
"."
] | fa027420ddc1d6de22a6d830e14dde587c837220 | https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/grid/BillGridView.php#L227-L232 |
28,572 | TYPO3-CMS/redirects | Classes/FormDataProvider/ValuePickerItemDataProvider.php | ValuePickerItemDataProvider.getHosts | protected function getHosts(): array
{
$domains = [];
foreach ($this->siteFinder->getAllSites() as $site) {
foreach ($site->getAllLanguages() as $language) {
$domains[] = $language->getBase()->getHost();
}
}
$domains = array_unique($domains);
sort($domains, SORT_NATURAL);
return $domains;
} | php | protected function getHosts(): array
{
$domains = [];
foreach ($this->siteFinder->getAllSites() as $site) {
foreach ($site->getAllLanguages() as $language) {
$domains[] = $language->getBase()->getHost();
}
}
$domains = array_unique($domains);
sort($domains, SORT_NATURAL);
return $domains;
} | [
"protected",
"function",
"getHosts",
"(",
")",
":",
"array",
"{",
"$",
"domains",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"siteFinder",
"->",
"getAllSites",
"(",
")",
"as",
"$",
"site",
")",
"{",
"foreach",
"(",
"$",
"site",
"->",
"getAllLanguages",
"(",
")",
"as",
"$",
"language",
")",
"{",
"$",
"domains",
"[",
"]",
"=",
"$",
"language",
"->",
"getBase",
"(",
")",
"->",
"getHost",
"(",
")",
";",
"}",
"}",
"$",
"domains",
"=",
"array_unique",
"(",
"$",
"domains",
")",
";",
"sort",
"(",
"$",
"domains",
",",
"SORT_NATURAL",
")",
";",
"return",
"$",
"domains",
";",
"}"
] | Get all hosts from sites
@return array domain records | [
"Get",
"all",
"hosts",
"from",
"sites"
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/FormDataProvider/ValuePickerItemDataProvider.php#L68-L79 |
28,573 | BabDev/Transifex-API | src/Connector/Translations.php | Translations.getTranslation | public function getTranslation(
string $project,
string $resource,
string $lang,
string $mode = ''
): ResponseInterface {
$uri = $this->createUri("/api/2/project/$project/resource/$resource/translation/$lang");
if (!empty($mode)) {
$uri = $uri->withQuery("mode=$mode&file");
}
return $this->client->sendRequest($this->createRequest('GET', $uri));
} | php | public function getTranslation(
string $project,
string $resource,
string $lang,
string $mode = ''
): ResponseInterface {
$uri = $this->createUri("/api/2/project/$project/resource/$resource/translation/$lang");
if (!empty($mode)) {
$uri = $uri->withQuery("mode=$mode&file");
}
return $this->client->sendRequest($this->createRequest('GET', $uri));
} | [
"public",
"function",
"getTranslation",
"(",
"string",
"$",
"project",
",",
"string",
"$",
"resource",
",",
"string",
"$",
"lang",
",",
"string",
"$",
"mode",
"=",
"''",
")",
":",
"ResponseInterface",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"createUri",
"(",
"\"/api/2/project/$project/resource/$resource/translation/$lang\"",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"mode",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withQuery",
"(",
"\"mode=$mode&file\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"client",
"->",
"sendRequest",
"(",
"$",
"this",
"->",
"createRequest",
"(",
"'GET'",
",",
"$",
"uri",
")",
")",
";",
"}"
] | Get translations 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 string $mode The mode of the downloaded file
@return ResponseInterface | [
"Get",
"translations",
"on",
"a",
"specified",
"resource",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Translations.php#L25-L38 |
28,574 | BabDev/Transifex-API | src/Connector/Translations.php | Translations.updateTranslation | public function updateTranslation(
string $project,
string $resource,
string $lang,
string $content,
string $type = 'string'
): ResponseInterface {
return $this->updateResource(
$this->createUri("/api/2/project/$project/resource/$resource/translation/$lang"),
$content,
$type
);
} | php | public function updateTranslation(
string $project,
string $resource,
string $lang,
string $content,
string $type = 'string'
): ResponseInterface {
return $this->updateResource(
$this->createUri("/api/2/project/$project/resource/$resource/translation/$lang"),
$content,
$type
);
} | [
"public",
"function",
"updateTranslation",
"(",
"string",
"$",
"project",
",",
"string",
"$",
"resource",
",",
"string",
"$",
"lang",
",",
"string",
"$",
"content",
",",
"string",
"$",
"type",
"=",
"'string'",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"updateResource",
"(",
"$",
"this",
"->",
"createUri",
"(",
"\"/api/2/project/$project/resource/$resource/translation/$lang\"",
")",
",",
"$",
"content",
",",
"$",
"type",
")",
";",
"}"
] | Update the content of a translation within a project.
@param string $project The project the resource is part of
@param string $resource The resource slug within the project
@param string $lang The language to return the translation for
@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",
"translation",
"within",
"a",
"project",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Translations.php#L51-L63 |
28,575 | QoboLtd/cakephp-search | src/Utility/BasicSearch.php | BasicSearch.getCriteria | public function getCriteria(string $value): array
{
if ('' === trim($value)) {
return [];
}
$fields = $this->getFields();
if (empty($fields)) {
return [];
}
$result = [];
foreach ($fields as $field) {
$criteria = $this->getFieldCriteria($field, $value);
if (empty($criteria)) {
continue;
}
$result[$field][] = $criteria;
}
return $result;
} | php | public function getCriteria(string $value): array
{
if ('' === trim($value)) {
return [];
}
$fields = $this->getFields();
if (empty($fields)) {
return [];
}
$result = [];
foreach ($fields as $field) {
$criteria = $this->getFieldCriteria($field, $value);
if (empty($criteria)) {
continue;
}
$result[$field][] = $criteria;
}
return $result;
} | [
"public",
"function",
"getCriteria",
"(",
"string",
"$",
"value",
")",
":",
"array",
"{",
"if",
"(",
"''",
"===",
"trim",
"(",
"$",
"value",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"fields",
"=",
"$",
"this",
"->",
"getFields",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"criteria",
"=",
"$",
"this",
"->",
"getFieldCriteria",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"criteria",
")",
")",
"{",
"continue",
";",
"}",
"$",
"result",
"[",
"$",
"field",
"]",
"[",
"]",
"=",
"$",
"criteria",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Prepare basic search query's where statement
@param string $value Search query value
@return mixed[] | [
"Prepare",
"basic",
"search",
"query",
"s",
"where",
"statement"
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L76-L98 |
28,576 | QoboLtd/cakephp-search | src/Utility/BasicSearch.php | BasicSearch.getFields | protected function getFields(): array
{
if (empty($this->searchFields)) {
return [];
}
$event = new Event((string)EventName::MODEL_SEARCH_BASIC_SEARCH_FIELDS(), $this, [
'table' => $this->table
]);
EventManager::instance()->dispatch($event);
$result = (array)$event->result;
if (empty($result)) {
$result = (array)$this->table->aliasField($this->table->getDisplayField());
}
$result = $this->filterFields($result);
if (!empty($result)) {
return $result;
}
$result = $this->getDefaultFields();
return $result;
} | php | protected function getFields(): array
{
if (empty($this->searchFields)) {
return [];
}
$event = new Event((string)EventName::MODEL_SEARCH_BASIC_SEARCH_FIELDS(), $this, [
'table' => $this->table
]);
EventManager::instance()->dispatch($event);
$result = (array)$event->result;
if (empty($result)) {
$result = (array)$this->table->aliasField($this->table->getDisplayField());
}
$result = $this->filterFields($result);
if (!empty($result)) {
return $result;
}
$result = $this->getDefaultFields();
return $result;
} | [
"protected",
"function",
"getFields",
"(",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"searchFields",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"event",
"=",
"new",
"Event",
"(",
"(",
"string",
")",
"EventName",
"::",
"MODEL_SEARCH_BASIC_SEARCH_FIELDS",
"(",
")",
",",
"$",
"this",
",",
"[",
"'table'",
"=>",
"$",
"this",
"->",
"table",
"]",
")",
";",
"EventManager",
"::",
"instance",
"(",
")",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"$",
"result",
"=",
"(",
"array",
")",
"$",
"event",
"->",
"result",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"result",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"table",
"->",
"aliasField",
"(",
"$",
"this",
"->",
"table",
"->",
"getDisplayField",
"(",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"filterFields",
"(",
"$",
"result",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"getDefaultFields",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Method that broadcasts an Event to generate the basic search fields.
If the Event result is empty then it falls back to using the display field.
If the display field is a virtual one then if falls back to searchable fields,
using the ones that their type matches the basicSearchFieldTypes list.
@return mixed[] | [
"Method",
"that",
"broadcasts",
"an",
"Event",
"to",
"generate",
"the",
"basic",
"search",
"fields",
".",
"If",
"the",
"Event",
"result",
"is",
"empty",
"then",
"it",
"falls",
"back",
"to",
"using",
"the",
"display",
"field",
".",
"If",
"the",
"display",
"field",
"is",
"a",
"virtual",
"one",
"then",
"if",
"falls",
"back",
"to",
"searchable",
"fields",
"using",
"the",
"ones",
"that",
"their",
"type",
"matches",
"the",
"basicSearchFieldTypes",
"list",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L108-L134 |
28,577 | QoboLtd/cakephp-search | src/Utility/BasicSearch.php | BasicSearch.filterFields | protected function filterFields(array $fields): array
{
// get table columns, aliased
$columns = $this->table->getSchema()->columns();
foreach ($columns as $index => $column) {
$columns[$index] = $this->table->aliasField($column);
}
// filter out virtual fields
foreach ($fields as $index => $field) {
if (!in_array($field, $columns)) {
unset($fields[$index]);
}
}
return $fields;
} | php | protected function filterFields(array $fields): array
{
// get table columns, aliased
$columns = $this->table->getSchema()->columns();
foreach ($columns as $index => $column) {
$columns[$index] = $this->table->aliasField($column);
}
// filter out virtual fields
foreach ($fields as $index => $field) {
if (!in_array($field, $columns)) {
unset($fields[$index]);
}
}
return $fields;
} | [
"protected",
"function",
"filterFields",
"(",
"array",
"$",
"fields",
")",
":",
"array",
"{",
"// get table columns, aliased",
"$",
"columns",
"=",
"$",
"this",
"->",
"table",
"->",
"getSchema",
"(",
")",
"->",
"columns",
"(",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"index",
"=>",
"$",
"column",
")",
"{",
"$",
"columns",
"[",
"$",
"index",
"]",
"=",
"$",
"this",
"->",
"table",
"->",
"aliasField",
"(",
"$",
"column",
")",
";",
"}",
"// filter out virtual fields",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"index",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"field",
",",
"$",
"columns",
")",
")",
"{",
"unset",
"(",
"$",
"fields",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}",
"return",
"$",
"fields",
";",
"}"
] | Filters basic search fields by removing virtual ones.
@param mixed[] $fields Basic search fields
@return mixed[] | [
"Filters",
"basic",
"search",
"fields",
"by",
"removing",
"virtual",
"ones",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L142-L158 |
28,578 | QoboLtd/cakephp-search | src/Utility/BasicSearch.php | BasicSearch.getDefaultFields | protected function getDefaultFields(): array
{
$result = [];
$types = Options::getBasicSearchFieldTypes();
foreach ($this->searchFields as $field => $properties) {
if (in_array($properties['type'], $types)) {
$result[] = $field;
}
}
return $result;
} | php | protected function getDefaultFields(): array
{
$result = [];
$types = Options::getBasicSearchFieldTypes();
foreach ($this->searchFields as $field => $properties) {
if (in_array($properties['type'], $types)) {
$result[] = $field;
}
}
return $result;
} | [
"protected",
"function",
"getDefaultFields",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"types",
"=",
"Options",
"::",
"getBasicSearchFieldTypes",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"searchFields",
"as",
"$",
"field",
"=>",
"$",
"properties",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"properties",
"[",
"'type'",
"]",
",",
"$",
"types",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"field",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Default basic search fields getter.
@return mixed[] | [
"Default",
"basic",
"search",
"fields",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L165-L177 |
28,579 | QoboLtd/cakephp-search | src/Utility/BasicSearch.php | BasicSearch.getFieldCriteria | protected function getFieldCriteria(string $field, string $value): array
{
// not a searchable field
if (!array_key_exists($field, $this->searchFields)) {
return [];
}
// unsupported field type for basic search
$type = $this->searchFields[$field]['type'];
if (!in_array($type, Options::getBasicSearchFieldTypes())) {
return [];
}
$result = [];
switch ($type) {
case 'related':
$result = $this->getRelatedFieldValue($field, $value);
break;
default:
$result = $this->getFieldValue($field, $value);
break;
}
return $result;
} | php | protected function getFieldCriteria(string $field, string $value): array
{
// not a searchable field
if (!array_key_exists($field, $this->searchFields)) {
return [];
}
// unsupported field type for basic search
$type = $this->searchFields[$field]['type'];
if (!in_array($type, Options::getBasicSearchFieldTypes())) {
return [];
}
$result = [];
switch ($type) {
case 'related':
$result = $this->getRelatedFieldValue($field, $value);
break;
default:
$result = $this->getFieldValue($field, $value);
break;
}
return $result;
} | [
"protected",
"function",
"getFieldCriteria",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"value",
")",
":",
"array",
"{",
"// not a searchable field",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"searchFields",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"// unsupported field type for basic search",
"$",
"type",
"=",
"$",
"this",
"->",
"searchFields",
"[",
"$",
"field",
"]",
"[",
"'type'",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"Options",
"::",
"getBasicSearchFieldTypes",
"(",
")",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'related'",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"getRelatedFieldValue",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"break",
";",
"default",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"break",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Field criteria getter for basic search field.
@param string $field Field name
@param string $value Search query value
@return mixed[] | [
"Field",
"criteria",
"getter",
"for",
"basic",
"search",
"field",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L186-L211 |
28,580 | QoboLtd/cakephp-search | src/Utility/BasicSearch.php | BasicSearch.getFieldValue | protected function getFieldValue(string $field, string $value): array
{
return [
'type' => $this->searchFields[$field]['type'],
'operator' => key($this->searchFields[$field]['operators']),
'value' => $value
];
} | php | protected function getFieldValue(string $field, string $value): array
{
return [
'type' => $this->searchFields[$field]['type'],
'operator' => key($this->searchFields[$field]['operators']),
'value' => $value
];
} | [
"protected",
"function",
"getFieldValue",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"value",
")",
":",
"array",
"{",
"return",
"[",
"'type'",
"=>",
"$",
"this",
"->",
"searchFields",
"[",
"$",
"field",
"]",
"[",
"'type'",
"]",
",",
"'operator'",
"=>",
"key",
"(",
"$",
"this",
"->",
"searchFields",
"[",
"$",
"field",
"]",
"[",
"'operators'",
"]",
")",
",",
"'value'",
"=>",
"$",
"value",
"]",
";",
"}"
] | Field value getter for basic search criteria.
@param string $field Field name
@param string $value Search query value
@return mixed[] | [
"Field",
"value",
"getter",
"for",
"basic",
"search",
"criteria",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L220-L227 |
28,581 | QoboLtd/cakephp-search | src/Utility/BasicSearch.php | BasicSearch.getRelatedFieldValue | protected function getRelatedFieldValue(string $field, string $value): array
{
$table = TableRegistry::get($this->searchFields[$field]['source']);
// avoid infinite recursion
if ($this->table->getAlias() === $table->getAlias()) {
return [];
}
$search = new Search($table, $this->user);
$basicSearch = new BasicSearch($table, $this->user);
$criteria = $basicSearch->getCriteria($value);
if (empty($criteria)) {
return [];
}
$data = [
'aggregator' => 'OR',
'criteria' => $criteria
];
$resultSet = $search->execute($data)->all();
if ($resultSet->isEmpty()) {
return [];
}
$result = [];
foreach ($resultSet as $entity) {
$result[] = $entity->id;
}
return [
'type' => $this->searchFields[$field]['type'],
'operator' => key($this->searchFields[$field]['operators']),
'value' => $result
];
} | php | protected function getRelatedFieldValue(string $field, string $value): array
{
$table = TableRegistry::get($this->searchFields[$field]['source']);
// avoid infinite recursion
if ($this->table->getAlias() === $table->getAlias()) {
return [];
}
$search = new Search($table, $this->user);
$basicSearch = new BasicSearch($table, $this->user);
$criteria = $basicSearch->getCriteria($value);
if (empty($criteria)) {
return [];
}
$data = [
'aggregator' => 'OR',
'criteria' => $criteria
];
$resultSet = $search->execute($data)->all();
if ($resultSet->isEmpty()) {
return [];
}
$result = [];
foreach ($resultSet as $entity) {
$result[] = $entity->id;
}
return [
'type' => $this->searchFields[$field]['type'],
'operator' => key($this->searchFields[$field]['operators']),
'value' => $result
];
} | [
"protected",
"function",
"getRelatedFieldValue",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"value",
")",
":",
"array",
"{",
"$",
"table",
"=",
"TableRegistry",
"::",
"get",
"(",
"$",
"this",
"->",
"searchFields",
"[",
"$",
"field",
"]",
"[",
"'source'",
"]",
")",
";",
"// avoid infinite recursion",
"if",
"(",
"$",
"this",
"->",
"table",
"->",
"getAlias",
"(",
")",
"===",
"$",
"table",
"->",
"getAlias",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"search",
"=",
"new",
"Search",
"(",
"$",
"table",
",",
"$",
"this",
"->",
"user",
")",
";",
"$",
"basicSearch",
"=",
"new",
"BasicSearch",
"(",
"$",
"table",
",",
"$",
"this",
"->",
"user",
")",
";",
"$",
"criteria",
"=",
"$",
"basicSearch",
"->",
"getCriteria",
"(",
"$",
"value",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"criteria",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"data",
"=",
"[",
"'aggregator'",
"=>",
"'OR'",
",",
"'criteria'",
"=>",
"$",
"criteria",
"]",
";",
"$",
"resultSet",
"=",
"$",
"search",
"->",
"execute",
"(",
"$",
"data",
")",
"->",
"all",
"(",
")",
";",
"if",
"(",
"$",
"resultSet",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"resultSet",
"as",
"$",
"entity",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"entity",
"->",
"id",
";",
"}",
"return",
"[",
"'type'",
"=>",
"$",
"this",
"->",
"searchFields",
"[",
"$",
"field",
"]",
"[",
"'type'",
"]",
",",
"'operator'",
"=>",
"key",
"(",
"$",
"this",
"->",
"searchFields",
"[",
"$",
"field",
"]",
"[",
"'operators'",
"]",
")",
",",
"'value'",
"=>",
"$",
"result",
"]",
";",
"}"
] | Gets basic search values from Related module.
This method is useful when you do a basic search on a related field,
in which the values are always uuid's. What this method will do is
run a search in the related module (recursively) to fetch and
return the entities IDs matching the search string.
@param string $field Field name
@param string $value Search query value
@return mixed[] | [
"Gets",
"basic",
"search",
"values",
"from",
"Related",
"module",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L241-L278 |
28,582 | QoboLtd/cakephp-search | src/Service/Search.php | Search.addCriteria | public function addCriteria(Criteria $criteria) : void
{
if (! $this->isValidFilter($criteria->getOperator())) {
throw new \RuntimeException(sprintf('Invalid filter provided: %s', $criteria->getOperator()));
}
$this->criteria[] = $criteria;
} | php | public function addCriteria(Criteria $criteria) : void
{
if (! $this->isValidFilter($criteria->getOperator())) {
throw new \RuntimeException(sprintf('Invalid filter provided: %s', $criteria->getOperator()));
}
$this->criteria[] = $criteria;
} | [
"public",
"function",
"addCriteria",
"(",
"Criteria",
"$",
"criteria",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidFilter",
"(",
"$",
"criteria",
"->",
"getOperator",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Invalid filter provided: %s'",
",",
"$",
"criteria",
"->",
"getOperator",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"criteria",
"[",
"]",
"=",
"$",
"criteria",
";",
"}"
] | Add criteria to Search.
@param \Search\Service\Criteria $criteria Criteria object
@return void
@throws \RuntimeException When invalid filter class is provided | [
"Add",
"criteria",
"to",
"Search",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L103-L110 |
28,583 | QoboLtd/cakephp-search | src/Service/Search.php | Search.setConjunction | public function setConjunction(string $conjunction = self::DEFAULT_CONJUNCTION) : void
{
if (! in_array($conjunction, self::CONJUNCTIONS)) {
throw new \RuntimeException(sprintf('Invalid conjunction provided: %s', $conjunction));
}
$this->conjunction = $conjunction;
} | php | public function setConjunction(string $conjunction = self::DEFAULT_CONJUNCTION) : void
{
if (! in_array($conjunction, self::CONJUNCTIONS)) {
throw new \RuntimeException(sprintf('Invalid conjunction provided: %s', $conjunction));
}
$this->conjunction = $conjunction;
} | [
"public",
"function",
"setConjunction",
"(",
"string",
"$",
"conjunction",
"=",
"self",
"::",
"DEFAULT_CONJUNCTION",
")",
":",
"void",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"conjunction",
",",
"self",
"::",
"CONJUNCTIONS",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Invalid conjunction provided: %s'",
",",
"$",
"conjunction",
")",
")",
";",
"}",
"$",
"this",
"->",
"conjunction",
"=",
"$",
"conjunction",
";",
"}"
] | Add conjunction to Search.
@param string $conjunction Search conjunction
@return void
@throws \RuntimeException When invalid filter class is provided | [
"Add",
"conjunction",
"to",
"Search",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L119-L126 |
28,584 | QoboLtd/cakephp-search | src/Service/Search.php | Search.execute | public function execute() : Query
{
$this->applyFilters();
$this->applySelect();
$this->applyJoins();
$clause = $this->query->clause('where');
// adjust where clause conjunction
if (null !== $clause) {
$this->query->where($clause->setConjunction($this->conjunction), [], true);
}
return $this->query;
} | php | public function execute() : Query
{
$this->applyFilters();
$this->applySelect();
$this->applyJoins();
$clause = $this->query->clause('where');
// adjust where clause conjunction
if (null !== $clause) {
$this->query->where($clause->setConjunction($this->conjunction), [], true);
}
return $this->query;
} | [
"public",
"function",
"execute",
"(",
")",
":",
"Query",
"{",
"$",
"this",
"->",
"applyFilters",
"(",
")",
";",
"$",
"this",
"->",
"applySelect",
"(",
")",
";",
"$",
"this",
"->",
"applyJoins",
"(",
")",
";",
"$",
"clause",
"=",
"$",
"this",
"->",
"query",
"->",
"clause",
"(",
"'where'",
")",
";",
"// adjust where clause conjunction",
"if",
"(",
"null",
"!==",
"$",
"clause",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"where",
"(",
"$",
"clause",
"->",
"setConjunction",
"(",
"$",
"this",
"->",
"conjunction",
")",
",",
"[",
"]",
",",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"query",
";",
"}"
] | Executes search logic.
@return \Cake\ORM\Query | [
"Executes",
"search",
"logic",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L133-L146 |
28,585 | QoboLtd/cakephp-search | src/Service/Search.php | Search.applyFilters | private function applyFilters() : void
{
foreach ($this->criteria as $criteria) {
$filterClass = $criteria->getOperator();
$filter = new $filterClass(
$this->table->aliasField($criteria->getField()),
$criteria->getValue()
);
$filter->apply($this->query);
}
} | php | private function applyFilters() : void
{
foreach ($this->criteria as $criteria) {
$filterClass = $criteria->getOperator();
$filter = new $filterClass(
$this->table->aliasField($criteria->getField()),
$criteria->getValue()
);
$filter->apply($this->query);
}
} | [
"private",
"function",
"applyFilters",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"criteria",
"as",
"$",
"criteria",
")",
"{",
"$",
"filterClass",
"=",
"$",
"criteria",
"->",
"getOperator",
"(",
")",
";",
"$",
"filter",
"=",
"new",
"$",
"filterClass",
"(",
"$",
"this",
"->",
"table",
"->",
"aliasField",
"(",
"$",
"criteria",
"->",
"getField",
"(",
")",
")",
",",
"$",
"criteria",
"->",
"getValue",
"(",
")",
")",
";",
"$",
"filter",
"->",
"apply",
"(",
"$",
"this",
"->",
"query",
")",
";",
"}",
"}"
] | Applies filters to the Query.
@return void | [
"Applies",
"filters",
"to",
"the",
"Query",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L164-L176 |
28,586 | QoboLtd/cakephp-search | src/Service/Search.php | Search.applySelect | private function applySelect() : void
{
$group = $this->query->clause('group');
$group = array_filter($group);
if (empty($group)) {
return;
}
$this->query->select($group, true);
$this->query->select([self::GROUP_BY_FIELD => $this->query->func()->count($group[0])]);
} | php | private function applySelect() : void
{
$group = $this->query->clause('group');
$group = array_filter($group);
if (empty($group)) {
return;
}
$this->query->select($group, true);
$this->query->select([self::GROUP_BY_FIELD => $this->query->func()->count($group[0])]);
} | [
"private",
"function",
"applySelect",
"(",
")",
":",
"void",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"query",
"->",
"clause",
"(",
"'group'",
")",
";",
"$",
"group",
"=",
"array_filter",
"(",
"$",
"group",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"group",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"query",
"->",
"select",
"(",
"$",
"group",
",",
"true",
")",
";",
"$",
"this",
"->",
"query",
"->",
"select",
"(",
"[",
"self",
"::",
"GROUP_BY_FIELD",
"=>",
"$",
"this",
"->",
"query",
"->",
"func",
"(",
")",
"->",
"count",
"(",
"$",
"group",
"[",
"0",
"]",
")",
"]",
")",
";",
"}"
] | Adjusts select clause in case a group_by clause is defined.
@return void | [
"Adjusts",
"select",
"clause",
"in",
"case",
"a",
"group_by",
"clause",
"is",
"defined",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L183-L193 |
28,587 | QoboLtd/cakephp-search | src/Service/Search.php | Search.applyJoins | private function applyJoins() : void
{
foreach ($this->getAssociations() as $association) {
switch ($association->type()) {
case Association::MANY_TO_ONE:
$this->query->leftJoinWith($association->getName());
break;
case Association::ONE_TO_ONE:
case Association::ONE_TO_MANY:
case Association::MANY_TO_MANY:
default:
break;
}
}
} | php | private function applyJoins() : void
{
foreach ($this->getAssociations() as $association) {
switch ($association->type()) {
case Association::MANY_TO_ONE:
$this->query->leftJoinWith($association->getName());
break;
case Association::ONE_TO_ONE:
case Association::ONE_TO_MANY:
case Association::MANY_TO_MANY:
default:
break;
}
}
} | [
"private",
"function",
"applyJoins",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getAssociations",
"(",
")",
"as",
"$",
"association",
")",
"{",
"switch",
"(",
"$",
"association",
"->",
"type",
"(",
")",
")",
"{",
"case",
"Association",
"::",
"MANY_TO_ONE",
":",
"$",
"this",
"->",
"query",
"->",
"leftJoinWith",
"(",
"$",
"association",
"->",
"getName",
"(",
")",
")",
";",
"break",
";",
"case",
"Association",
"::",
"ONE_TO_ONE",
":",
"case",
"Association",
"::",
"ONE_TO_MANY",
":",
"case",
"Association",
"::",
"MANY_TO_MANY",
":",
"default",
":",
"break",
";",
"}",
"}",
"}"
] | Applies association joins to the Query.
@return void | [
"Applies",
"association",
"joins",
"to",
"the",
"Query",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L200-L215 |
28,588 | QoboLtd/cakephp-search | src/Service/Search.php | Search.getAssociations | private function getAssociations() : array
{
$result = [];
foreach ($this->getQueryFields() as $field) {
$association = $this->getAssociationByField($field);
if (null === $association) {
continue;
}
if (array_key_exists($association->getName(), $result)) {
continue;
}
$result[$association->getName()] = $association;
}
return $result;
} | php | private function getAssociations() : array
{
$result = [];
foreach ($this->getQueryFields() as $field) {
$association = $this->getAssociationByField($field);
if (null === $association) {
continue;
}
if (array_key_exists($association->getName(), $result)) {
continue;
}
$result[$association->getName()] = $association;
}
return $result;
} | [
"private",
"function",
"getAssociations",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getQueryFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"association",
"=",
"$",
"this",
"->",
"getAssociationByField",
"(",
"$",
"field",
")",
";",
"if",
"(",
"null",
"===",
"$",
"association",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"association",
"->",
"getName",
"(",
")",
",",
"$",
"result",
")",
")",
"{",
"continue",
";",
"}",
"$",
"result",
"[",
"$",
"association",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"association",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get required associations based on current search criteria.
@return mixed[] | [
"Get",
"required",
"associations",
"based",
"on",
"current",
"search",
"criteria",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L222-L239 |
28,589 | QoboLtd/cakephp-search | src/Service/Search.php | Search.getQueryFields | private function getQueryFields() : array
{
$result = [];
foreach ($this->criteria as $criteria) {
$field = $this->table->aliasField($criteria->getField());
if (! in_array($field, $result)) {
$result[] = $field;
}
}
foreach ($this->query->clause('select') as $field) {
if (is_string($field) && ! in_array($field, $result)) {
$result[] = $field;
}
}
return $result;
} | php | private function getQueryFields() : array
{
$result = [];
foreach ($this->criteria as $criteria) {
$field = $this->table->aliasField($criteria->getField());
if (! in_array($field, $result)) {
$result[] = $field;
}
}
foreach ($this->query->clause('select') as $field) {
if (is_string($field) && ! in_array($field, $result)) {
$result[] = $field;
}
}
return $result;
} | [
"private",
"function",
"getQueryFields",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"criteria",
"as",
"$",
"criteria",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"table",
"->",
"aliasField",
"(",
"$",
"criteria",
"->",
"getField",
"(",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"field",
",",
"$",
"result",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"field",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"query",
"->",
"clause",
"(",
"'select'",
")",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"field",
")",
"&&",
"!",
"in_array",
"(",
"$",
"field",
",",
"$",
"result",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"field",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Get search query fields from criteria and select clause.
@return string[] | [
"Get",
"search",
"query",
"fields",
"from",
"criteria",
"and",
"select",
"clause",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L246-L263 |
28,590 | QoboLtd/cakephp-search | src/Service/Search.php | Search.getAssociationByField | private function getAssociationByField(string $field) : ?Association
{
list($name) = explode('.', $this->table->aliasField($field), 2);
if ($name === $this->table->getAlias()) {
return null;
}
if (! $this->table->hasAssociation($name)) {
throw new \RuntimeException(sprintf('Table "%s" does not have association "%s"', $this->table->getAlias(), $name));
}
return $this->table->getAssociation($name);
} | php | private function getAssociationByField(string $field) : ?Association
{
list($name) = explode('.', $this->table->aliasField($field), 2);
if ($name === $this->table->getAlias()) {
return null;
}
if (! $this->table->hasAssociation($name)) {
throw new \RuntimeException(sprintf('Table "%s" does not have association "%s"', $this->table->getAlias(), $name));
}
return $this->table->getAssociation($name);
} | [
"private",
"function",
"getAssociationByField",
"(",
"string",
"$",
"field",
")",
":",
"?",
"Association",
"{",
"list",
"(",
"$",
"name",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"this",
"->",
"table",
"->",
"aliasField",
"(",
"$",
"field",
")",
",",
"2",
")",
";",
"if",
"(",
"$",
"name",
"===",
"$",
"this",
"->",
"table",
"->",
"getAlias",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"table",
"->",
"hasAssociation",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Table \"%s\" does not have association \"%s\"'",
",",
"$",
"this",
"->",
"table",
"->",
"getAlias",
"(",
")",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"table",
"->",
"getAssociation",
"(",
"$",
"name",
")",
";",
"}"
] | Retrieves table association by aliased field name.
Example: 'Author.name'
@param string $field Field name
@return \Cake\ORM\Association|null
@throws \RuntimeException When invalid association is found | [
"Retrieves",
"table",
"association",
"by",
"aliased",
"field",
"name",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L274-L287 |
28,591 | QoboLtd/cakephp-search | src/Model/Table/SavedSearchesTable.php | SavedSearchesTable.beforeMarshal | public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) : void
{
// @todo this will be removed once saved searches table schema is adjusted
$saved = Hash::get($data, 'content.saved', []);
if (! empty($saved)) {
$data['content']['latest'] = $saved;
}
} | php | public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) : void
{
// @todo this will be removed once saved searches table schema is adjusted
$saved = Hash::get($data, 'content.saved', []);
if (! empty($saved)) {
$data['content']['latest'] = $saved;
}
} | [
"public",
"function",
"beforeMarshal",
"(",
"Event",
"$",
"event",
",",
"ArrayObject",
"$",
"data",
",",
"ArrayObject",
"$",
"options",
")",
":",
"void",
"{",
"// @todo this will be removed once saved searches table schema is adjusted",
"$",
"saved",
"=",
"Hash",
"::",
"get",
"(",
"$",
"data",
",",
"'content.saved'",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"saved",
")",
")",
"{",
"$",
"data",
"[",
"'content'",
"]",
"[",
"'latest'",
"]",
"=",
"$",
"saved",
";",
"}",
"}"
] | Structures "content" data to suported format.
@param \Cake\Event\Event $event Event object
@param \ArrayObject $data Request data
@param \ArrayObject $options Marshaller options
@return void | [
"Structures",
"content",
"data",
"to",
"suported",
"format",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Model/Table/SavedSearchesTable.php#L128-L135 |
28,592 | TYPO3-CMS/redirects | Classes/Repository/Demand.php | Demand.createFromRequest | public static function createFromRequest(ServerRequestInterface $request): Demand
{
$page = (int)($request->getQueryParams()['page'] ?? $request->getParsedBody()['page'] ?? 1);
$demand = $request->getQueryParams()['demand'] ?? $request->getParsedBody()['demand'];
if (empty($demand)) {
return new self($page);
}
$sourceHost = $demand['source_host'] ?? '';
$sourcePath = $demand['source_path'] ?? '';
$statusCode = (int)$demand['target_statuscode'] ?? 0;
$target = $demand['target'] ?? '';
return new self($page, $sourceHost, $sourcePath, $target, $statusCode);
} | php | public static function createFromRequest(ServerRequestInterface $request): Demand
{
$page = (int)($request->getQueryParams()['page'] ?? $request->getParsedBody()['page'] ?? 1);
$demand = $request->getQueryParams()['demand'] ?? $request->getParsedBody()['demand'];
if (empty($demand)) {
return new self($page);
}
$sourceHost = $demand['source_host'] ?? '';
$sourcePath = $demand['source_path'] ?? '';
$statusCode = (int)$demand['target_statuscode'] ?? 0;
$target = $demand['target'] ?? '';
return new self($page, $sourceHost, $sourcePath, $target, $statusCode);
} | [
"public",
"static",
"function",
"createFromRequest",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"Demand",
"{",
"$",
"page",
"=",
"(",
"int",
")",
"(",
"$",
"request",
"->",
"getQueryParams",
"(",
")",
"[",
"'page'",
"]",
"??",
"$",
"request",
"->",
"getParsedBody",
"(",
")",
"[",
"'page'",
"]",
"??",
"1",
")",
";",
"$",
"demand",
"=",
"$",
"request",
"->",
"getQueryParams",
"(",
")",
"[",
"'demand'",
"]",
"??",
"$",
"request",
"->",
"getParsedBody",
"(",
")",
"[",
"'demand'",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"demand",
")",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"page",
")",
";",
"}",
"$",
"sourceHost",
"=",
"$",
"demand",
"[",
"'source_host'",
"]",
"??",
"''",
";",
"$",
"sourcePath",
"=",
"$",
"demand",
"[",
"'source_path'",
"]",
"??",
"''",
";",
"$",
"statusCode",
"=",
"(",
"int",
")",
"$",
"demand",
"[",
"'target_statuscode'",
"]",
"??",
"0",
";",
"$",
"target",
"=",
"$",
"demand",
"[",
"'target'",
"]",
"??",
"''",
";",
"return",
"new",
"self",
"(",
"$",
"page",
",",
"$",
"sourceHost",
",",
"$",
"sourcePath",
",",
"$",
"target",
",",
"$",
"statusCode",
")",
";",
"}"
] | Creates a Demand object from the current request.
@param ServerRequestInterface $request
@return Demand | [
"Creates",
"a",
"Demand",
"object",
"from",
"the",
"current",
"request",
"."
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Repository/Demand.php#L79-L91 |
28,593 | QoboLtd/cakephp-search | src/Service/Criteria.php | Criteria.validate | private function validate(array $data) : void
{
$diff = array_diff(self::REQUIRED_PARAMS, array_keys($data));
if (! empty($diff)) {
throw new \InvalidArgumentException(
sprintf('Search criteria is missing required parameter(s): %s', implode(', ', $diff))
);
}
if (! is_string($data['field'])) {
throw new \InvalidArgumentException('Field parameter must be a string');
}
if (! is_string($data['operator'])) {
throw new \InvalidArgumentException('Operator parameter must be a string');
}
if (! is_scalar($data['value']) && ! is_array($data['value'])) {
throw new \InvalidArgumentException(sprintf('Unsupported value type provided: %s', gettype($data['value'])));
}
} | php | private function validate(array $data) : void
{
$diff = array_diff(self::REQUIRED_PARAMS, array_keys($data));
if (! empty($diff)) {
throw new \InvalidArgumentException(
sprintf('Search criteria is missing required parameter(s): %s', implode(', ', $diff))
);
}
if (! is_string($data['field'])) {
throw new \InvalidArgumentException('Field parameter must be a string');
}
if (! is_string($data['operator'])) {
throw new \InvalidArgumentException('Operator parameter must be a string');
}
if (! is_scalar($data['value']) && ! is_array($data['value'])) {
throw new \InvalidArgumentException(sprintf('Unsupported value type provided: %s', gettype($data['value'])));
}
} | [
"private",
"function",
"validate",
"(",
"array",
"$",
"data",
")",
":",
"void",
"{",
"$",
"diff",
"=",
"array_diff",
"(",
"self",
"::",
"REQUIRED_PARAMS",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"diff",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Search criteria is missing required parameter(s): %s'",
",",
"implode",
"(",
"', '",
",",
"$",
"diff",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"data",
"[",
"'field'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Field parameter must be a string'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"data",
"[",
"'operator'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Operator parameter must be a string'",
")",
";",
"}",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"data",
"[",
"'value'",
"]",
")",
"&&",
"!",
"is_array",
"(",
"$",
"data",
"[",
"'value'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unsupported value type provided: %s'",
",",
"gettype",
"(",
"$",
"data",
"[",
"'value'",
"]",
")",
")",
")",
";",
"}",
"}"
] | Validates search criteria.
@param mixed[] $data Search criteria
@return void
@throws \InvalidArgumentException When invalid/incomplete data are provided | [
"Validates",
"search",
"criteria",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Criteria.php#L68-L89 |
28,594 | QoboLtd/cakephp-search | src/Model/Behavior/SearchableBehavior.php | SearchableBehavior.findSearch | public function findSearch(Query $query, array $options) : Query
{
$search = new Search($query, $this->getTable());
$search->setConjunction(Hash::get($options, 'conjunction', Search::DEFAULT_CONJUNCTION));
foreach (Hash::get($options, 'data', []) as $criteria) {
if (! is_array($criteria)) {
throw new \InvalidArgumentException(sprintf(
'Search criteria must be an array, %s provided instead',
gettype($criteria)
));
}
$search->addCriteria(new Criteria($criteria));
}
return $search->execute();
} | php | public function findSearch(Query $query, array $options) : Query
{
$search = new Search($query, $this->getTable());
$search->setConjunction(Hash::get($options, 'conjunction', Search::DEFAULT_CONJUNCTION));
foreach (Hash::get($options, 'data', []) as $criteria) {
if (! is_array($criteria)) {
throw new \InvalidArgumentException(sprintf(
'Search criteria must be an array, %s provided instead',
gettype($criteria)
));
}
$search->addCriteria(new Criteria($criteria));
}
return $search->execute();
} | [
"public",
"function",
"findSearch",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"options",
")",
":",
"Query",
"{",
"$",
"search",
"=",
"new",
"Search",
"(",
"$",
"query",
",",
"$",
"this",
"->",
"getTable",
"(",
")",
")",
";",
"$",
"search",
"->",
"setConjunction",
"(",
"Hash",
"::",
"get",
"(",
"$",
"options",
",",
"'conjunction'",
",",
"Search",
"::",
"DEFAULT_CONJUNCTION",
")",
")",
";",
"foreach",
"(",
"Hash",
"::",
"get",
"(",
"$",
"options",
",",
"'data'",
",",
"[",
"]",
")",
"as",
"$",
"criteria",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"criteria",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Search criteria must be an array, %s provided instead'",
",",
"gettype",
"(",
"$",
"criteria",
")",
")",
")",
";",
"}",
"$",
"search",
"->",
"addCriteria",
"(",
"new",
"Criteria",
"(",
"$",
"criteria",
")",
")",
";",
"}",
"return",
"$",
"search",
"->",
"execute",
"(",
")",
";",
"}"
] | Search finder method.
@param \Cake\ORM\Query $query The query object to apply the finder options to
@param mixed[] $options List of options to pass to the finder
@return \Cake\ORM\Query | [
"Search",
"finder",
"method",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Model/Behavior/SearchableBehavior.php#L46-L64 |
28,595 | php-enqueue/stomp | BufferedStompClient.php | BufferedStompClient.readMessageFrame | public function readMessageFrame(string $subscriptionId, int $timeout): ?Frame
{
// pop up frame from the buffer
if (isset($this->buffer[$subscriptionId]) && ($frame = array_shift($this->buffer[$subscriptionId]))) {
--$this->currentBufferSize;
return $frame;
}
// do nothing when buffer is full
if ($this->currentBufferSize >= $this->bufferSize) {
return null;
}
$startTime = microtime(true);
$remainingTimeout = $timeout * 1000;
while (true) {
$this->getConnection()->setReadTimeout(0, $remainingTimeout);
// there is nothing to read
if (false === $frame = $this->readFrame()) {
return null;
}
if ('MESSAGE' !== $frame->getCommand()) {
throw new \LogicException(sprintf('Unexpected frame was received: "%s"', $frame->getCommand()));
}
$headers = $frame->getHeaders();
if (false == isset($headers['subscription'])) {
throw new \LogicException('Got message frame with missing subscription header');
}
// frame belongs to another subscription
if ($headers['subscription'] !== $subscriptionId) {
$this->buffer[$headers['subscription']][] = $frame;
++$this->currentBufferSize;
$remainingTimeout -= (microtime(true) - $startTime) * 1000000;
if ($remainingTimeout <= 0) {
return null;
}
continue;
}
return $frame;
}
} | php | public function readMessageFrame(string $subscriptionId, int $timeout): ?Frame
{
// pop up frame from the buffer
if (isset($this->buffer[$subscriptionId]) && ($frame = array_shift($this->buffer[$subscriptionId]))) {
--$this->currentBufferSize;
return $frame;
}
// do nothing when buffer is full
if ($this->currentBufferSize >= $this->bufferSize) {
return null;
}
$startTime = microtime(true);
$remainingTimeout = $timeout * 1000;
while (true) {
$this->getConnection()->setReadTimeout(0, $remainingTimeout);
// there is nothing to read
if (false === $frame = $this->readFrame()) {
return null;
}
if ('MESSAGE' !== $frame->getCommand()) {
throw new \LogicException(sprintf('Unexpected frame was received: "%s"', $frame->getCommand()));
}
$headers = $frame->getHeaders();
if (false == isset($headers['subscription'])) {
throw new \LogicException('Got message frame with missing subscription header');
}
// frame belongs to another subscription
if ($headers['subscription'] !== $subscriptionId) {
$this->buffer[$headers['subscription']][] = $frame;
++$this->currentBufferSize;
$remainingTimeout -= (microtime(true) - $startTime) * 1000000;
if ($remainingTimeout <= 0) {
return null;
}
continue;
}
return $frame;
}
} | [
"public",
"function",
"readMessageFrame",
"(",
"string",
"$",
"subscriptionId",
",",
"int",
"$",
"timeout",
")",
":",
"?",
"Frame",
"{",
"// pop up frame from the buffer",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"buffer",
"[",
"$",
"subscriptionId",
"]",
")",
"&&",
"(",
"$",
"frame",
"=",
"array_shift",
"(",
"$",
"this",
"->",
"buffer",
"[",
"$",
"subscriptionId",
"]",
")",
")",
")",
"{",
"--",
"$",
"this",
"->",
"currentBufferSize",
";",
"return",
"$",
"frame",
";",
"}",
"// do nothing when buffer is full",
"if",
"(",
"$",
"this",
"->",
"currentBufferSize",
">=",
"$",
"this",
"->",
"bufferSize",
")",
"{",
"return",
"null",
";",
"}",
"$",
"startTime",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"remainingTimeout",
"=",
"$",
"timeout",
"*",
"1000",
";",
"while",
"(",
"true",
")",
"{",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"setReadTimeout",
"(",
"0",
",",
"$",
"remainingTimeout",
")",
";",
"// there is nothing to read",
"if",
"(",
"false",
"===",
"$",
"frame",
"=",
"$",
"this",
"->",
"readFrame",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"'MESSAGE'",
"!==",
"$",
"frame",
"->",
"getCommand",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Unexpected frame was received: \"%s\"'",
",",
"$",
"frame",
"->",
"getCommand",
"(",
")",
")",
")",
";",
"}",
"$",
"headers",
"=",
"$",
"frame",
"->",
"getHeaders",
"(",
")",
";",
"if",
"(",
"false",
"==",
"isset",
"(",
"$",
"headers",
"[",
"'subscription'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Got message frame with missing subscription header'",
")",
";",
"}",
"// frame belongs to another subscription",
"if",
"(",
"$",
"headers",
"[",
"'subscription'",
"]",
"!==",
"$",
"subscriptionId",
")",
"{",
"$",
"this",
"->",
"buffer",
"[",
"$",
"headers",
"[",
"'subscription'",
"]",
"]",
"[",
"]",
"=",
"$",
"frame",
";",
"++",
"$",
"this",
"->",
"currentBufferSize",
";",
"$",
"remainingTimeout",
"-=",
"(",
"microtime",
"(",
"true",
")",
"-",
"$",
"startTime",
")",
"*",
"1000000",
";",
"if",
"(",
"$",
"remainingTimeout",
"<=",
"0",
")",
"{",
"return",
"null",
";",
"}",
"continue",
";",
"}",
"return",
"$",
"frame",
";",
"}",
"}"
] | Timeout is in milliseconds. | [
"Timeout",
"is",
"in",
"milliseconds",
"."
] | b5c5742ba6c863bcc38396cc38110aa829e9336d | https://github.com/php-enqueue/stomp/blob/b5c5742ba6c863bcc38396cc38110aa829e9336d/BufferedStompClient.php#L53-L104 |
28,596 | BabDev/Transifex-API | src/Connector/Languages.php | Languages.createLanguage | public function createLanguage(
string $slug,
string $langCode,
array $coordinators,
array $options = [],
bool $skipInvalidUsername = false
): ResponseInterface {
// Make sure the $coordinators array is not empty
if (!\count($coordinators)) {
throw new \InvalidArgumentException('The coordinators array must contain at least one username.');
}
$uri = $this->createUri("/api/2/project/$slug/languages/");
if ($skipInvalidUsername) {
$uri = $uri->withQuery('skip_invalid_username');
}
// Build the required request data.
$data = [
'language_code' => $langCode,
'coordinators' => $coordinators,
];
// Valid options to check
$validOptions = ['translators', 'reviewers', 'list'];
// Loop through the valid options and if we have them, add them to the request data
foreach ($validOptions as $option) {
if (isset($options[$option])) {
$data[$option] = $options[$option];
}
}
$request = $this->createRequest('POST', $uri);
$request = $request->withBody($this->streamFactory->createStream(\json_encode($data)));
return $this->client->sendRequest($request);
} | php | public function createLanguage(
string $slug,
string $langCode,
array $coordinators,
array $options = [],
bool $skipInvalidUsername = false
): ResponseInterface {
// Make sure the $coordinators array is not empty
if (!\count($coordinators)) {
throw new \InvalidArgumentException('The coordinators array must contain at least one username.');
}
$uri = $this->createUri("/api/2/project/$slug/languages/");
if ($skipInvalidUsername) {
$uri = $uri->withQuery('skip_invalid_username');
}
// Build the required request data.
$data = [
'language_code' => $langCode,
'coordinators' => $coordinators,
];
// Valid options to check
$validOptions = ['translators', 'reviewers', 'list'];
// Loop through the valid options and if we have them, add them to the request data
foreach ($validOptions as $option) {
if (isset($options[$option])) {
$data[$option] = $options[$option];
}
}
$request = $this->createRequest('POST', $uri);
$request = $request->withBody($this->streamFactory->createStream(\json_encode($data)));
return $this->client->sendRequest($request);
} | [
"public",
"function",
"createLanguage",
"(",
"string",
"$",
"slug",
",",
"string",
"$",
"langCode",
",",
"array",
"$",
"coordinators",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"bool",
"$",
"skipInvalidUsername",
"=",
"false",
")",
":",
"ResponseInterface",
"{",
"// Make sure the $coordinators array is not empty",
"if",
"(",
"!",
"\\",
"count",
"(",
"$",
"coordinators",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The coordinators array must contain at least one username.'",
")",
";",
"}",
"$",
"uri",
"=",
"$",
"this",
"->",
"createUri",
"(",
"\"/api/2/project/$slug/languages/\"",
")",
";",
"if",
"(",
"$",
"skipInvalidUsername",
")",
"{",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withQuery",
"(",
"'skip_invalid_username'",
")",
";",
"}",
"// Build the required request data.",
"$",
"data",
"=",
"[",
"'language_code'",
"=>",
"$",
"langCode",
",",
"'coordinators'",
"=>",
"$",
"coordinators",
",",
"]",
";",
"// Valid options to check",
"$",
"validOptions",
"=",
"[",
"'translators'",
",",
"'reviewers'",
",",
"'list'",
"]",
";",
"// Loop through the valid options and if we have them, add them to the request data",
"foreach",
"(",
"$",
"validOptions",
"as",
"$",
"option",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"$",
"option",
"]",
")",
")",
"{",
"$",
"data",
"[",
"$",
"option",
"]",
"=",
"$",
"options",
"[",
"$",
"option",
"]",
";",
"}",
"}",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
"'POST'",
",",
"$",
"uri",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withBody",
"(",
"$",
"this",
"->",
"streamFactory",
"->",
"createStream",
"(",
"\\",
"json_encode",
"(",
"$",
"data",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"sendRequest",
"(",
"$",
"request",
")",
";",
"}"
] | Create a language for a project.
@param string $slug The slug for the project
@param string $langCode The language code for the new language
@param string[] $coordinators An array of coordinators for the language
@param array $options Optional additional params to send with the request
@param bool $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames
@return ResponseInterface
@throws \InvalidArgumentException | [
"Create",
"a",
"language",
"for",
"a",
"project",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L28-L66 |
28,597 | BabDev/Transifex-API | src/Connector/Languages.php | Languages.deleteLanguage | public function deleteLanguage(string $project, string $langCode): ResponseInterface
{
return $this->client->sendRequest($this->createRequest('DELETE', $this->createUri("/api/2/project/$project/language/$langCode/")));
} | php | public function deleteLanguage(string $project, string $langCode): ResponseInterface
{
return $this->client->sendRequest($this->createRequest('DELETE', $this->createUri("/api/2/project/$project/language/$langCode/")));
} | [
"public",
"function",
"deleteLanguage",
"(",
"string",
"$",
"project",
",",
"string",
"$",
"langCode",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"sendRequest",
"(",
"$",
"this",
"->",
"createRequest",
"(",
"'DELETE'",
",",
"$",
"this",
"->",
"createUri",
"(",
"\"/api/2/project/$project/language/$langCode/\"",
")",
")",
")",
";",
"}"
] | Delete a language within a project.
@param string $project The project to retrieve details for
@param string $langCode The language code to retrieve details for
@return ResponseInterface | [
"Delete",
"a",
"language",
"within",
"a",
"project",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L76-L79 |
28,598 | BabDev/Transifex-API | src/Connector/Languages.php | Languages.getLanguages | public function getLanguages(string $project): ResponseInterface
{
return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/project/$project/languages/")));
} | php | public function getLanguages(string $project): ResponseInterface
{
return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/project/$project/languages/")));
} | [
"public",
"function",
"getLanguages",
"(",
"string",
"$",
"project",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"sendRequest",
"(",
"$",
"this",
"->",
"createRequest",
"(",
"'GET'",
",",
"$",
"this",
"->",
"createUri",
"(",
"\"/api/2/project/$project/languages/\"",
")",
")",
")",
";",
"}"
] | Get a list of languages for a specified project.
@param string $project The project to retrieve details for
@return ResponseInterface | [
"Get",
"a",
"list",
"of",
"languages",
"for",
"a",
"specified",
"project",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L121-L124 |
28,599 | BabDev/Transifex-API | src/Connector/Languages.php | Languages.updateCoordinators | public function updateCoordinators(
string $project,
string $langCode,
array $coordinators,
bool $skipInvalidUsername = false
): ResponseInterface {
return $this->updateTeam($project, $langCode, $coordinators, $skipInvalidUsername, 'coordinators');
} | php | public function updateCoordinators(
string $project,
string $langCode,
array $coordinators,
bool $skipInvalidUsername = false
): ResponseInterface {
return $this->updateTeam($project, $langCode, $coordinators, $skipInvalidUsername, 'coordinators');
} | [
"public",
"function",
"updateCoordinators",
"(",
"string",
"$",
"project",
",",
"string",
"$",
"langCode",
",",
"array",
"$",
"coordinators",
",",
"bool",
"$",
"skipInvalidUsername",
"=",
"false",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"updateTeam",
"(",
"$",
"project",
",",
"$",
"langCode",
",",
"$",
"coordinators",
",",
"$",
"skipInvalidUsername",
",",
"'coordinators'",
")",
";",
"}"
] | Update the coordinators for a language team in a project.
@param string $project The project to retrieve details for
@param string $langCode The language code to retrieve details for
@param string[] $coordinators An array of coordinators for the language
@param bool $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames
@return ResponseInterface | [
"Update",
"the",
"coordinators",
"for",
"a",
"language",
"team",
"in",
"a",
"project",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L162-L169 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.