repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
hnhdigital-os/laravel-model-search | src/ModelSearch.php | ModelSearch.modelJoin | public function modelJoin($relationships, $operator = '=', $type = 'left', $where = false)
{
if (!is_array($relationships)) {
$relationships = [$relationships];
}
if (empty($this->query->columns)) {
$this->query->selectRaw('DISTINCT '.$this->model->getTable().'.*');
}
foreach ($relationships as $relation_name => $load_relationship) {
// Required variables.
$model = Arr::get($this->relationships, $relation_name.'.model');
$method = Arr::get($this->relationships, $relation_name.'.method');
$table = Arr::get($this->relationships, $relation_name.'.table');
$parent_key = Arr::get($this->relationships, $relation_name.'.parent_key');
$foreign_key = Arr::get($this->relationships, $relation_name.'.foreign_key');
// Add the columns from the other table.
// @todo do we need this?
//$this->query->addSelect(new Expression("`$table`.*"));
$this->query->join($table, $parent_key, $operator, $foreign_key, $type, $where);
// The join above is to the intimidatory table. This joins the query to the actual model.
if ($method === 'BelongsToMany') {
$related_foreign_key = $model->getQualifiedRelatedKeyName();
$related_relation = $model->getRelated();
$related_table = $related_relation->getTable();
$related_qualified_key_name = $related_relation->getQualifiedKeyName();
$this->query->join($related_table, $related_qualified_key_name, $operator, $related_foreign_key, $type, $where);
}
}
// Group by the original model.
$this->query->groupBy($this->model->getQualifiedKeyName());
} | php | public function modelJoin($relationships, $operator = '=', $type = 'left', $where = false)
{
if (!is_array($relationships)) {
$relationships = [$relationships];
}
if (empty($this->query->columns)) {
$this->query->selectRaw('DISTINCT '.$this->model->getTable().'.*');
}
foreach ($relationships as $relation_name => $load_relationship) {
// Required variables.
$model = Arr::get($this->relationships, $relation_name.'.model');
$method = Arr::get($this->relationships, $relation_name.'.method');
$table = Arr::get($this->relationships, $relation_name.'.table');
$parent_key = Arr::get($this->relationships, $relation_name.'.parent_key');
$foreign_key = Arr::get($this->relationships, $relation_name.'.foreign_key');
// Add the columns from the other table.
// @todo do we need this?
//$this->query->addSelect(new Expression("`$table`.*"));
$this->query->join($table, $parent_key, $operator, $foreign_key, $type, $where);
// The join above is to the intimidatory table. This joins the query to the actual model.
if ($method === 'BelongsToMany') {
$related_foreign_key = $model->getQualifiedRelatedKeyName();
$related_relation = $model->getRelated();
$related_table = $related_relation->getTable();
$related_qualified_key_name = $related_relation->getQualifiedKeyName();
$this->query->join($related_table, $related_qualified_key_name, $operator, $related_foreign_key, $type, $where);
}
}
// Group by the original model.
$this->query->groupBy($this->model->getQualifiedKeyName());
} | [
"public",
"function",
"modelJoin",
"(",
"$",
"relationships",
",",
"$",
"operator",
"=",
"'='",
",",
"$",
"type",
"=",
"'left'",
",",
"$",
"where",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"relationships",
")",
")",
"{",
"$",
"... | This determines the foreign key relations automatically to prevent the need to figure out the columns.
@param string $relation_name
@param string $operator
@param string $type
@param bool $where
@return Builder
@SuppressWarnings(PHPMD.BooleanArgumentFlag)
@SuppressWarnings(PHPMD.LongVariable)
@SuppressWarnings(PHPMD.StaticAccess) | [
"This",
"determines",
"the",
"foreign",
"key",
"relations",
"automatically",
"to",
"prevent",
"the",
"need",
"to",
"figure",
"out",
"the",
"columns",
"."
] | 4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d | https://github.com/hnhdigital-os/laravel-model-search/blob/4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d/src/ModelSearch.php#L1121-L1157 | train |
hnhdigital-os/laravel-model-search | src/ModelSearch.php | ModelSearch.applySearch | private static function applySearch(&$query, $search)
{
foreach ($search as $name => $filters) {
foreach ($filters as $filter) {
self::applySearchFilter($query, $filter);
}
}
} | php | private static function applySearch(&$query, $search)
{
foreach ($search as $name => $filters) {
foreach ($filters as $filter) {
self::applySearchFilter($query, $filter);
}
}
} | [
"private",
"static",
"function",
"applySearch",
"(",
"&",
"$",
"query",
",",
"$",
"search",
")",
"{",
"foreach",
"(",
"$",
"search",
"as",
"$",
"name",
"=>",
"$",
"filters",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filter",
")",
"{",
"... | Apply search items to the query.
@param Builder $query
@param array $search
@return void | [
"Apply",
"search",
"items",
"to",
"the",
"query",
"."
] | 4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d | https://github.com/hnhdigital-os/laravel-model-search/blob/4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d/src/ModelSearch.php#L1167-L1174 | train |
hnhdigital-os/laravel-model-search | src/ModelSearch.php | ModelSearch.applySearchFilter | private static function applySearchFilter(&$query, $filter)
{
$filter_type = Arr::get($filter, 'settings.filter');
$method = Arr::get($filter, 'method');
$arguments = Arr::get($filter, 'arguments');
$attributes = Arr::get($filter, 'settings.attributes');
$positive = Arr::get($filter, 'positive');
if ($filter_type !== 'scope' && is_array($arguments)) {
array_unshift($arguments, '');
}
$query->where(function ($query) use ($filter_type, $attributes, $method, $arguments, $positive) {
$count = 0;
foreach ($attributes as $attribute_name) {
// Place attribute name into argument.
if ($filter_type !== 'scope' && is_array($arguments)) {
$arguments[0] = $attribute_name;
// Argument is raw and using sprintf.
} elseif (!is_array($arguments)) {
$arguments = [sprintf($arguments, self::quoteIdentifier($attribute_name))];
}
if ($filter_type === 'scope') {
$arguments[] = $positive;
}
$query->$method(...$arguments);
// Apply an or to the where.
if ($filter_type !== 'scope' && $count === 0 && $positive) {
$method = 'or'.Str::studly($method);
}
$count++;
}
});
} | php | private static function applySearchFilter(&$query, $filter)
{
$filter_type = Arr::get($filter, 'settings.filter');
$method = Arr::get($filter, 'method');
$arguments = Arr::get($filter, 'arguments');
$attributes = Arr::get($filter, 'settings.attributes');
$positive = Arr::get($filter, 'positive');
if ($filter_type !== 'scope' && is_array($arguments)) {
array_unshift($arguments, '');
}
$query->where(function ($query) use ($filter_type, $attributes, $method, $arguments, $positive) {
$count = 0;
foreach ($attributes as $attribute_name) {
// Place attribute name into argument.
if ($filter_type !== 'scope' && is_array($arguments)) {
$arguments[0] = $attribute_name;
// Argument is raw and using sprintf.
} elseif (!is_array($arguments)) {
$arguments = [sprintf($arguments, self::quoteIdentifier($attribute_name))];
}
if ($filter_type === 'scope') {
$arguments[] = $positive;
}
$query->$method(...$arguments);
// Apply an or to the where.
if ($filter_type !== 'scope' && $count === 0 && $positive) {
$method = 'or'.Str::studly($method);
}
$count++;
}
});
} | [
"private",
"static",
"function",
"applySearchFilter",
"(",
"&",
"$",
"query",
",",
"$",
"filter",
")",
"{",
"$",
"filter_type",
"=",
"Arr",
"::",
"get",
"(",
"$",
"filter",
",",
"'settings.filter'",
")",
";",
"$",
"method",
"=",
"Arr",
"::",
"get",
"("... | Apply the filter item.
@return void | [
"Apply",
"the",
"filter",
"item",
"."
] | 4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d | https://github.com/hnhdigital-os/laravel-model-search/blob/4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d/src/ModelSearch.php#L1181-L1219 | train |
hnhdigital-os/laravel-model-search | src/ModelSearch.php | ModelSearch.getOperator | public static function getOperator($type, $operator)
{
$operators = self::getOperators($type);
return Arr::get($operators, $operator, []);
} | php | public static function getOperator($type, $operator)
{
$operators = self::getOperators($type);
return Arr::get($operators, $operator, []);
} | [
"public",
"static",
"function",
"getOperator",
"(",
"$",
"type",
",",
"$",
"operator",
")",
"{",
"$",
"operators",
"=",
"self",
"::",
"getOperators",
"(",
"$",
"type",
")",
";",
"return",
"Arr",
"::",
"get",
"(",
"$",
"operators",
",",
"$",
"operator",... | Get an operators details.
@param string $type
@param string $operator
@return bool | [
"Get",
"an",
"operators",
"details",
"."
] | 4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d | https://github.com/hnhdigital-os/laravel-model-search/blob/4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d/src/ModelSearch.php#L1266-L1271 | train |
hnhdigital-os/laravel-model-search | src/ModelSearch.php | ModelSearch.getOperators | public static function getOperators($type)
{
if (!in_array($type, self::getTypes())) {
return [];
}
$source = snake_case($type).'_operators';
return self::$$source;
} | php | public static function getOperators($type)
{
if (!in_array($type, self::getTypes())) {
return [];
}
$source = snake_case($type).'_operators';
return self::$$source;
} | [
"public",
"static",
"function",
"getOperators",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"self",
"::",
"getTypes",
"(",
")",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"source",
"=",
"snake_case",
"(",
... | Get an string|number|date operators as array|string.
@param string|number|date $type
@param bool $operator
@return array|string|null | [
"Get",
"an",
"string|number|date",
"operators",
"as",
"array|string",
"."
] | 4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d | https://github.com/hnhdigital-os/laravel-model-search/blob/4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d/src/ModelSearch.php#L1295-L1304 | train |
hnhdigital-os/laravel-model-search | src/ModelSearch.php | ModelSearch.getListFromString | private static function getListFromString($value)
{
if (is_string($value_array = $value)) {
$value = str_replace([',', ' '], ';', $value);
$value_array = explode(';', $value);
}
if (is_array($value_array)) {
return array_filter(array_map('trim', $value_array));
}
return [];
} | php | private static function getListFromString($value)
{
if (is_string($value_array = $value)) {
$value = str_replace([',', ' '], ';', $value);
$value_array = explode(';', $value);
}
if (is_array($value_array)) {
return array_filter(array_map('trim', $value_array));
}
return [];
} | [
"private",
"static",
"function",
"getListFromString",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value_array",
"=",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"[",
"','",
",",
"' '",
"]",
",",
"';'",
",",... | Get array of values from an input string.
@param string $string
@return array | [
"Get",
"array",
"of",
"values",
"from",
"an",
"input",
"string",
"."
] | 4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d | https://github.com/hnhdigital-os/laravel-model-search/blob/4e1b319b561eb2dfa4267a6a7cd4341ca51a1c0d/src/ModelSearch.php#L1313-L1325 | train |
lukefor/Laravel4-SmartyView | src/Dark/SmartyView/Smarty/libs/sysplugins/smarty_internal_template.php | Smarty_Internal_Template.compileTemplateSource | public function compileTemplateSource()
{
if (!$this->source->recompiled) {
$this->properties['file_dependency'] = array();
if ($this->source->components) {
// for the extends resource the compiler will fill it
// uses real resource for file dependency
// $source = end($this->source->components);
// $this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $source->type);
} else {
$this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $this->source->type);
}
}
// compile locking
if ($this->smarty->compile_locking && !$this->source->recompiled) {
if ($saved_timestamp = $this->compiled->timestamp) {
touch($this->compiled->filepath);
}
}
// call compiler
try {
$code = $this->compiler->compileTemplate($this);
}
catch (Exception $e) {
// restore old timestamp in case of error
if ($this->smarty->compile_locking && !$this->source->recompiled && $saved_timestamp) {
touch($this->compiled->filepath, $saved_timestamp);
}
throw $e;
}
// compiling succeded
if (!$this->source->recompiled && $this->compiler->write_compiled_code) {
// write compiled template
$_filepath = $this->compiled->filepath;
if ($_filepath === false) {
throw new SmartyException('getCompiledFilepath() did not return a destination to save the compiled template to');
}
Smarty_Internal_Write_File::writeFile($_filepath, $code, $this->smarty);
$this->compiled->exists = true;
$this->compiled->isCompiled = true;
}
// release compiler object to free memory
unset($this->compiler);
} | php | public function compileTemplateSource()
{
if (!$this->source->recompiled) {
$this->properties['file_dependency'] = array();
if ($this->source->components) {
// for the extends resource the compiler will fill it
// uses real resource for file dependency
// $source = end($this->source->components);
// $this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $source->type);
} else {
$this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $this->source->type);
}
}
// compile locking
if ($this->smarty->compile_locking && !$this->source->recompiled) {
if ($saved_timestamp = $this->compiled->timestamp) {
touch($this->compiled->filepath);
}
}
// call compiler
try {
$code = $this->compiler->compileTemplate($this);
}
catch (Exception $e) {
// restore old timestamp in case of error
if ($this->smarty->compile_locking && !$this->source->recompiled && $saved_timestamp) {
touch($this->compiled->filepath, $saved_timestamp);
}
throw $e;
}
// compiling succeded
if (!$this->source->recompiled && $this->compiler->write_compiled_code) {
// write compiled template
$_filepath = $this->compiled->filepath;
if ($_filepath === false) {
throw new SmartyException('getCompiledFilepath() did not return a destination to save the compiled template to');
}
Smarty_Internal_Write_File::writeFile($_filepath, $code, $this->smarty);
$this->compiled->exists = true;
$this->compiled->isCompiled = true;
}
// release compiler object to free memory
unset($this->compiler);
} | [
"public",
"function",
"compileTemplateSource",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"source",
"->",
"recompiled",
")",
"{",
"$",
"this",
"->",
"properties",
"[",
"'file_dependency'",
"]",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this"... | Compiles the template
If the template is not evaluated the compiled template is saved on disk | [
"Compiles",
"the",
"template",
"If",
"the",
"template",
"is",
"not",
"evaluated",
"the",
"compiled",
"template",
"is",
"saved",
"on",
"disk"
] | cb3a9bfae805e787cff179b3e41f1a9ad65b389e | https://github.com/lukefor/Laravel4-SmartyView/blob/cb3a9bfae805e787cff179b3e41f1a9ad65b389e/src/Dark/SmartyView/Smarty/libs/sysplugins/smarty_internal_template.php#L176-L219 | train |
lukefor/Laravel4-SmartyView | src/Dark/SmartyView/Smarty/libs/sysplugins/smarty_internal_template.php | Smarty_Internal_Template.getSubTemplate | public function getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
{
// already in template cache?
if ($this->smarty->allow_ambiguous_resources) {
$_templateId = Smarty_Resource::getUniqueTemplateName($this, $template) . $cache_id . $compile_id;
} else {
$_templateId = $this->smarty->joined_template_dir . '#' . $template . $cache_id . $compile_id;
}
if (isset($_templateId[150])) {
$_templateId = sha1($_templateId);
}
if (isset($this->smarty->template_objects[$_templateId])) {
// clone cached template object because of possible recursive call
$tpl = clone $this->smarty->template_objects[$_templateId];
$tpl->parent = $this;
$tpl->caching = $caching;
$tpl->cache_lifetime = $cache_lifetime;
} else {
$tpl = new $this->smarty->template_class($template, $this->smarty, $this, $cache_id, $compile_id, $caching, $cache_lifetime);
}
// get variables from calling scope
if ($parent_scope == Smarty::SCOPE_LOCAL) {
$tpl->tpl_vars = $this->tpl_vars;
$tpl->tpl_vars['smarty'] = clone $this->tpl_vars['smarty'];
} elseif ($parent_scope == Smarty::SCOPE_PARENT) {
$tpl->tpl_vars = & $this->tpl_vars;
} elseif ($parent_scope == Smarty::SCOPE_GLOBAL) {
$tpl->tpl_vars = & Smarty::$global_tpl_vars;
} elseif (($scope_ptr = $this->getScopePointer($parent_scope)) == null) {
$tpl->tpl_vars = & $this->tpl_vars;
} else {
$tpl->tpl_vars = & $scope_ptr->tpl_vars;
}
$tpl->config_vars = $this->config_vars;
if (!empty($data)) {
// set up variable values
foreach ($data as $_key => $_val) {
$tpl->tpl_vars[$_key] = new Smarty_variable($_val);
}
}
/// dark edit
\Dark\SmartyView\SmartyEngine::integrateViewComposers($tpl, $template);
/// end edit
return $tpl->fetch(null, null, null, null, false, false, true);
} | php | public function getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
{
// already in template cache?
if ($this->smarty->allow_ambiguous_resources) {
$_templateId = Smarty_Resource::getUniqueTemplateName($this, $template) . $cache_id . $compile_id;
} else {
$_templateId = $this->smarty->joined_template_dir . '#' . $template . $cache_id . $compile_id;
}
if (isset($_templateId[150])) {
$_templateId = sha1($_templateId);
}
if (isset($this->smarty->template_objects[$_templateId])) {
// clone cached template object because of possible recursive call
$tpl = clone $this->smarty->template_objects[$_templateId];
$tpl->parent = $this;
$tpl->caching = $caching;
$tpl->cache_lifetime = $cache_lifetime;
} else {
$tpl = new $this->smarty->template_class($template, $this->smarty, $this, $cache_id, $compile_id, $caching, $cache_lifetime);
}
// get variables from calling scope
if ($parent_scope == Smarty::SCOPE_LOCAL) {
$tpl->tpl_vars = $this->tpl_vars;
$tpl->tpl_vars['smarty'] = clone $this->tpl_vars['smarty'];
} elseif ($parent_scope == Smarty::SCOPE_PARENT) {
$tpl->tpl_vars = & $this->tpl_vars;
} elseif ($parent_scope == Smarty::SCOPE_GLOBAL) {
$tpl->tpl_vars = & Smarty::$global_tpl_vars;
} elseif (($scope_ptr = $this->getScopePointer($parent_scope)) == null) {
$tpl->tpl_vars = & $this->tpl_vars;
} else {
$tpl->tpl_vars = & $scope_ptr->tpl_vars;
}
$tpl->config_vars = $this->config_vars;
if (!empty($data)) {
// set up variable values
foreach ($data as $_key => $_val) {
$tpl->tpl_vars[$_key] = new Smarty_variable($_val);
}
}
/// dark edit
\Dark\SmartyView\SmartyEngine::integrateViewComposers($tpl, $template);
/// end edit
return $tpl->fetch(null, null, null, null, false, false, true);
} | [
"public",
"function",
"getSubTemplate",
"(",
"$",
"template",
",",
"$",
"cache_id",
",",
"$",
"compile_id",
",",
"$",
"caching",
",",
"$",
"cache_lifetime",
",",
"$",
"data",
",",
"$",
"parent_scope",
")",
"{",
"// already in template cache?",
"if",
"(",
"$"... | Template code runtime function to get subtemplate content
@param string $template the resource handle of the template file
@param mixed $cache_id cache id to be used with this template
@param mixed $compile_id compile id to be used with this template
@param integer $caching cache mode
@param integer $cache_lifetime life time of cache data
@param $data
@param int $parent_scope scope in which {include} should execute
@returns string template content | [
"Template",
"code",
"runtime",
"function",
"to",
"get",
"subtemplate",
"content"
] | cb3a9bfae805e787cff179b3e41f1a9ad65b389e | https://github.com/lukefor/Laravel4-SmartyView/blob/cb3a9bfae805e787cff179b3e41f1a9ad65b389e/src/Dark/SmartyView/Smarty/libs/sysplugins/smarty_internal_template.php#L261-L308 | train |
Celarius/spin-framework | src/Factories/Http/ServerRequestFactory.php | ServerRequestFactory.createServerRequestFromArray | public function createServerRequestFromArray(?array $server)
{
global $app;
# Copied from Guzzles ::fromGlobals(), but we need to support the $server array as
# paramter, so we use that instead of the $_SERVER array guzzle uses by default
$method = isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET';
$headers = \function_exists('getallheaders') ? \getallheaders() : [];
$uri = ServerRequest::getUriFromGlobals();
$body = new LazyOpenStream('php://input', 'r+');
$protocol = isset($server['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $server['SERVER_PROTOCOL']) : '1.1';
$serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $server);
\logger()->debug('Created PSR-7 ServerRequest("'.$method.'","'.$uri.'") from array (Guzzle)');
return $serverRequest
->withCookieParams($_COOKIE)
->withQueryParams($_GET)
->withParsedBody($_POST)
->withUploadedFiles(ServerRequest::normalizeFiles($_FILES));
} | php | public function createServerRequestFromArray(?array $server)
{
global $app;
# Copied from Guzzles ::fromGlobals(), but we need to support the $server array as
# paramter, so we use that instead of the $_SERVER array guzzle uses by default
$method = isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET';
$headers = \function_exists('getallheaders') ? \getallheaders() : [];
$uri = ServerRequest::getUriFromGlobals();
$body = new LazyOpenStream('php://input', 'r+');
$protocol = isset($server['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $server['SERVER_PROTOCOL']) : '1.1';
$serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $server);
\logger()->debug('Created PSR-7 ServerRequest("'.$method.'","'.$uri.'") from array (Guzzle)');
return $serverRequest
->withCookieParams($_COOKIE)
->withQueryParams($_GET)
->withParsedBody($_POST)
->withUploadedFiles(ServerRequest::normalizeFiles($_FILES));
} | [
"public",
"function",
"createServerRequestFromArray",
"(",
"?",
"array",
"$",
"server",
")",
"{",
"global",
"$",
"app",
";",
"# Copied from Guzzles ::fromGlobals(), but we need to support the $server array as",
"# paramter, so we use that instead of the $_SERVER array guzzle uses by de... | Create a new server request from server variables array
@param array $server Typically $_SERVER or similar
array
@return ServerRequestInterface
@throws \InvalidArgumentException If no valid method or URI can be determined. | [
"Create",
"a",
"new",
"server",
"request",
"from",
"server",
"variables",
"array"
] | 2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0 | https://github.com/Celarius/spin-framework/blob/2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0/src/Factories/Http/ServerRequestFactory.php#L74-L96 | train |
guss77/kohana-paypal | classes/Kohana/PayPal.php | Kohana_PayPal.payment | public static function payment($amount, $localTrxID = null) {
$impl = new PayPal();
$registration = $impl->registerTransaction($amount, $impl->storeLocalTrx($localTrxID));
Session::instance()->set(self::SESSION_TOKEN, $registration->id);
foreach ($registration->links as $link) {
if ($link->rel == 'approval_url') {
HTTP::redirect($link->href);
exit; // shouldn't be needed, redirect throws
}
}
throw new PayPal_Exception_InvalidResponse('Missing approval URL');
} | php | public static function payment($amount, $localTrxID = null) {
$impl = new PayPal();
$registration = $impl->registerTransaction($amount, $impl->storeLocalTrx($localTrxID));
Session::instance()->set(self::SESSION_TOKEN, $registration->id);
foreach ($registration->links as $link) {
if ($link->rel == 'approval_url') {
HTTP::redirect($link->href);
exit; // shouldn't be needed, redirect throws
}
}
throw new PayPal_Exception_InvalidResponse('Missing approval URL');
} | [
"public",
"static",
"function",
"payment",
"(",
"$",
"amount",
",",
"$",
"localTrxID",
"=",
"null",
")",
"{",
"$",
"impl",
"=",
"new",
"PayPal",
"(",
")",
";",
"$",
"registration",
"=",
"$",
"impl",
"->",
"registerTransaction",
"(",
"$",
"amount",
",",... | Start pyament processing through Paypal.
This method never returns.
@param string $amount a single transaction's price
@param unknown $localTrxID application transaciton object
@throws PayPal_Exception_InvalidResponse | [
"Start",
"pyament",
"processing",
"through",
"Paypal",
".",
"This",
"method",
"never",
"returns",
"."
] | bd66c29aec5be9438fed39c8f0b81c7cafd6d540 | https://github.com/guss77/kohana-paypal/blob/bd66c29aec5be9438fed39c8f0b81c7cafd6d540/classes/Kohana/PayPal.php#L46-L59 | train |
guss77/kohana-paypal | classes/Kohana/PayPal.php | Kohana_PayPal.registerTransaction | public function registerTransaction($amount, $localTrxID) {
$token = $this->authenticate();
// paypal like the amount as string, to prevent floating point errors
if (!is_string($amount))
$amount = sprintf("%0.2f", $amount);
$a = (object)[
"amount" => (object)[
"total" => $amount,
"currency" => $this->currency,
]
];
$route = Route::get('paypal_response');
$base = URL::base(true);
$payment_data = (object)[
'intent' => "sale",
'redirect_urls' => (object)[
'return_url' => $base . $route->uri([
'action' => 'complete', 'trxid' => $localTrxID]),
'cancel_url' => $base . $route->uri([
'action' => 'cancel', 'trxid' => $localTrxID]),
],
'payer' => (object)[ 'payment_method' => 'paypal', ],
"transactions" => [ $a ],
];
$request = $this->genRequest('payments/payment', $payment_data, $token);
return $this->call($request);
} | php | public function registerTransaction($amount, $localTrxID) {
$token = $this->authenticate();
// paypal like the amount as string, to prevent floating point errors
if (!is_string($amount))
$amount = sprintf("%0.2f", $amount);
$a = (object)[
"amount" => (object)[
"total" => $amount,
"currency" => $this->currency,
]
];
$route = Route::get('paypal_response');
$base = URL::base(true);
$payment_data = (object)[
'intent' => "sale",
'redirect_urls' => (object)[
'return_url' => $base . $route->uri([
'action' => 'complete', 'trxid' => $localTrxID]),
'cancel_url' => $base . $route->uri([
'action' => 'cancel', 'trxid' => $localTrxID]),
],
'payer' => (object)[ 'payment_method' => 'paypal', ],
"transactions" => [ $a ],
];
$request = $this->genRequest('payments/payment', $payment_data, $token);
return $this->call($request);
} | [
"public",
"function",
"registerTransaction",
"(",
"$",
"amount",
",",
"$",
"localTrxID",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"authenticate",
"(",
")",
";",
"// paypal like the amount as string, to prevent floating point errors",
"if",
"(",
"!",
"is_strin... | Register the transaction with PayPal
@param string $amount a single transaction price
@param unknown $localTrxID application transaciton object
@return mixed | [
"Register",
"the",
"transaction",
"with",
"PayPal"
] | bd66c29aec5be9438fed39c8f0b81c7cafd6d540 | https://github.com/guss77/kohana-paypal/blob/bd66c29aec5be9438fed39c8f0b81c7cafd6d540/classes/Kohana/PayPal.php#L132-L162 | train |
guss77/kohana-paypal | classes/Kohana/PayPal.php | Kohana_PayPal.storeLocalTrx | private function storeLocalTrx($localTrxID) {
if (is_null($localTrxID))
return $localTrxID;
$trxco = sha1(time() . "" . serialize($localTrxID));
$this->cache->set($trxco, $localTrxID, self::MAX_SESSION_LENGTH);
return $trxco;
} | php | private function storeLocalTrx($localTrxID) {
if (is_null($localTrxID))
return $localTrxID;
$trxco = sha1(time() . "" . serialize($localTrxID));
$this->cache->set($trxco, $localTrxID, self::MAX_SESSION_LENGTH);
return $trxco;
} | [
"private",
"function",
"storeLocalTrx",
"(",
"$",
"localTrxID",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"localTrxID",
")",
")",
"return",
"$",
"localTrxID",
";",
"$",
"trxco",
"=",
"sha1",
"(",
"time",
"(",
")",
".",
"\"\"",
".",
"serialize",
"(",
... | Store the local transaction data in the cache, so I don't have to pass it through
the client
@param unknown $localTrxID any data
@return string hash id to retrieve the data later | [
"Store",
"the",
"local",
"transaction",
"data",
"in",
"the",
"cache",
"so",
"I",
"don",
"t",
"have",
"to",
"pass",
"it",
"through",
"the",
"client"
] | bd66c29aec5be9438fed39c8f0b81c7cafd6d540 | https://github.com/guss77/kohana-paypal/blob/bd66c29aec5be9438fed39c8f0b81c7cafd6d540/classes/Kohana/PayPal.php#L192-L199 | train |
guss77/kohana-paypal | classes/Kohana/PayPal.php | Kohana_PayPal.retrieveLocalTrx | private function retrieveLocalTrx($localTrxHash) {
if (is_null($localTrxHash))
return $localTrxHash;
$trxid = $this->cache->get($localTrxHash, false);
if ($trxid === false)
throw new Exception("Failed to retrieve local data for " . $localTrxHash);
return $trxid;
} | php | private function retrieveLocalTrx($localTrxHash) {
if (is_null($localTrxHash))
return $localTrxHash;
$trxid = $this->cache->get($localTrxHash, false);
if ($trxid === false)
throw new Exception("Failed to retrieve local data for " . $localTrxHash);
return $trxid;
} | [
"private",
"function",
"retrieveLocalTrx",
"(",
"$",
"localTrxHash",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"localTrxHash",
")",
")",
"return",
"$",
"localTrxHash",
";",
"$",
"trxid",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",
"localTrxHa... | retrieve the local transaction data from the cache.
@param unknown $localTrxHash hash ID of the transaction data
@return mixed local transaction data | [
"retrieve",
"the",
"local",
"transaction",
"data",
"from",
"the",
"cache",
"."
] | bd66c29aec5be9438fed39c8f0b81c7cafd6d540 | https://github.com/guss77/kohana-paypal/blob/bd66c29aec5be9438fed39c8f0b81c7cafd6d540/classes/Kohana/PayPal.php#L206-L214 | train |
guss77/kohana-paypal | classes/Kohana/PayPal.php | Kohana_PayPal.extractSales | private function extractSales($transactions) {
$out = [];
foreach ($transactions as $trx) {
foreach ($trx->related_resources as $src) {
if (isset($src->sale)) {
$out[] = $src->sale;
}
}
}
return $out;
} | php | private function extractSales($transactions) {
$out = [];
foreach ($transactions as $trx) {
foreach ($trx->related_resources as $src) {
if (isset($src->sale)) {
$out[] = $src->sale;
}
}
}
return $out;
} | [
"private",
"function",
"extractSales",
"(",
"$",
"transactions",
")",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"transactions",
"as",
"$",
"trx",
")",
"{",
"foreach",
"(",
"$",
"trx",
"->",
"related_resources",
"as",
"$",
"src",
")",
... | Parse PayPal "transactions" list from execution approval call
and extract the "sale" objects which contain the refund URLs
@param object $transactions | [
"Parse",
"PayPal",
"transactions",
"list",
"from",
"execution",
"approval",
"call",
"and",
"extract",
"the",
"sale",
"objects",
"which",
"contain",
"the",
"refund",
"URLs"
] | bd66c29aec5be9438fed39c8f0b81c7cafd6d540 | https://github.com/guss77/kohana-paypal/blob/bd66c29aec5be9438fed39c8f0b81c7cafd6d540/classes/Kohana/PayPal.php#L221-L233 | train |
guss77/kohana-paypal | classes/Kohana/PayPal.php | Kohana_PayPal.getRefundURL | private function getRefundURL($paymentDetails) {
if (!is_object($paymentDetails))
throw new Exception("Invalid payment details in getRefundURL");
if (!is_array($paymentDetails->transactions))
throw new Exception("Invalid transaction list in getRefundURL");
foreach ($paymentDetails->transactions as $transact) {
if (!is_array($transact->related_resources))
throw new Exception("Invalid related resources in getRefundURL");
foreach ($transact->related_resources as $res) {
if (!is_array($res->sale->links))
throw new Exception("Invalid related links in getRefundURL");
foreach ($res->sale->links as $link) {
if ($link->rel == 'refund')
return $link->href;
}
}
}
throw new Exception("Missing refund URL in getRefundURL");
} | php | private function getRefundURL($paymentDetails) {
if (!is_object($paymentDetails))
throw new Exception("Invalid payment details in getRefundURL");
if (!is_array($paymentDetails->transactions))
throw new Exception("Invalid transaction list in getRefundURL");
foreach ($paymentDetails->transactions as $transact) {
if (!is_array($transact->related_resources))
throw new Exception("Invalid related resources in getRefundURL");
foreach ($transact->related_resources as $res) {
if (!is_array($res->sale->links))
throw new Exception("Invalid related links in getRefundURL");
foreach ($res->sale->links as $link) {
if ($link->rel == 'refund')
return $link->href;
}
}
}
throw new Exception("Missing refund URL in getRefundURL");
} | [
"private",
"function",
"getRefundURL",
"(",
"$",
"paymentDetails",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"paymentDetails",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"Invalid payment details in getRefundURL\"",
")",
";",
"if",
"(",
"!",
"is_array",... | Process a JSON parsed payment object, and locate the refund URL for that payment
@param object $paymentDetails Payment object
@return string refund URL
@throws Exception if the data does not look like a valid payment object, or if the object does not have a refund url | [
"Process",
"a",
"JSON",
"parsed",
"payment",
"object",
"and",
"locate",
"the",
"refund",
"URL",
"for",
"that",
"payment"
] | bd66c29aec5be9438fed39c8f0b81c7cafd6d540 | https://github.com/guss77/kohana-paypal/blob/bd66c29aec5be9438fed39c8f0b81c7cafd6d540/classes/Kohana/PayPal.php#L241-L259 | train |
guss77/kohana-paypal | classes/Kohana/PayPal.php | Kohana_PayPal.genRequest | protected function genRequest($address, $data = [], $token = null, $get = false) {
// compose request URL
if (strstr($address, 'https://'))
$url = $address;
else
$url = $this->endpoint . '/v1/' . $address;
$method = (is_null($data) || $get) ? 'GET' : 'POST';
self::debug("PayPal Auth: " . $token->token_type . ' ' . $token->access_token);
// create HTTP request
$req = (new Request($url))->method($method)
->headers('Accept','application/json')
->headers('Accept-Language', 'en_US')
->headers('Authorization', is_null($token) ?
'Basic ' . base64_encode($this->clientID . ":" . $this->secret) :
$token->token_type . ' ' . $token->access_token)
->headers('Content-Type', (is_array($data) && $method == 'POST') ?
'application/x-www-form-urlencoded' : 'application/json');
if (is_null($data)) {
self::debug("Sending message to $url");
return $req;
}
if (is_array($data)) {
$req = $req->post($data); // set all fields directly
self::debug("Sending POST message to $url :", $data);
return $req;
}
if (!is_object($data))
throw new PayPal_Exception("Invalid data type in PayPal::genRequest");
$data = json_encode($data);
$req = $req->body($data);
self::debug("Sending JSON message to $url : $data");
return $req;
} | php | protected function genRequest($address, $data = [], $token = null, $get = false) {
// compose request URL
if (strstr($address, 'https://'))
$url = $address;
else
$url = $this->endpoint . '/v1/' . $address;
$method = (is_null($data) || $get) ? 'GET' : 'POST';
self::debug("PayPal Auth: " . $token->token_type . ' ' . $token->access_token);
// create HTTP request
$req = (new Request($url))->method($method)
->headers('Accept','application/json')
->headers('Accept-Language', 'en_US')
->headers('Authorization', is_null($token) ?
'Basic ' . base64_encode($this->clientID . ":" . $this->secret) :
$token->token_type . ' ' . $token->access_token)
->headers('Content-Type', (is_array($data) && $method == 'POST') ?
'application/x-www-form-urlencoded' : 'application/json');
if (is_null($data)) {
self::debug("Sending message to $url");
return $req;
}
if (is_array($data)) {
$req = $req->post($data); // set all fields directly
self::debug("Sending POST message to $url :", $data);
return $req;
}
if (!is_object($data))
throw new PayPal_Exception("Invalid data type in PayPal::genRequest");
$data = json_encode($data);
$req = $req->body($data);
self::debug("Sending JSON message to $url : $data");
return $req;
} | [
"protected",
"function",
"genRequest",
"(",
"$",
"address",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"token",
"=",
"null",
",",
"$",
"get",
"=",
"false",
")",
"{",
"// compose request URL",
"if",
"(",
"strstr",
"(",
"$",
"address",
",",
"'https://'",... | Generate a PayPal v1 API request
@param string $address REST method to call
@param array|object $data array data to 'form POST' or object data to JSON POst
@param string $token OAuth authentication token
@param boolean $get whether to use GET request, or POST
@throws PayPal_Exception | [
"Generate",
"a",
"PayPal",
"v1",
"API",
"request"
] | bd66c29aec5be9438fed39c8f0b81c7cafd6d540 | https://github.com/guss77/kohana-paypal/blob/bd66c29aec5be9438fed39c8f0b81c7cafd6d540/classes/Kohana/PayPal.php#L269-L307 | train |
guss77/kohana-paypal | classes/Kohana/PayPal.php | Kohana_PayPal.call | protected function call(Request $request) {
$response = $request->execute();
if (!$response->isSuccess()) {
self::debug("Error in PayPal call", $response);
throw new PayPal_Exception_InvalidResponse("Error " . $response->status() . " in PayPal call (". $response->body() .")");
}
$res = json_decode($response->body());
if (isset($res->error)) {
self::error("Error in PayPal call: " . print_r($res, true));
throw new PayPal_Exception_InvalidResponse('PayPal: ' . $res->error_description . ' [' . $res->error .
'] while calling ' . $request->uri());
}
return $res;
} | php | protected function call(Request $request) {
$response = $request->execute();
if (!$response->isSuccess()) {
self::debug("Error in PayPal call", $response);
throw new PayPal_Exception_InvalidResponse("Error " . $response->status() . " in PayPal call (". $response->body() .")");
}
$res = json_decode($response->body());
if (isset($res->error)) {
self::error("Error in PayPal call: " . print_r($res, true));
throw new PayPal_Exception_InvalidResponse('PayPal: ' . $res->error_description . ' [' . $res->error .
'] while calling ' . $request->uri());
}
return $res;
} | [
"protected",
"function",
"call",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"$",
"request",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"!",
"$",
"response",
"->",
"isSuccess",
"(",
")",
")",
"{",
"self",
"::",
"debug",
"(",
"\"... | Execute a PayPal v1 API request
@param Request $request HTTP request to execute
@throws PayPal_Exception_InvalidResponse
@return mixed | [
"Execute",
"a",
"PayPal",
"v1",
"API",
"request"
] | bd66c29aec5be9438fed39c8f0b81c7cafd6d540 | https://github.com/guss77/kohana-paypal/blob/bd66c29aec5be9438fed39c8f0b81c7cafd6d540/classes/Kohana/PayPal.php#L315-L329 | train |
TheBnl/event-tickets | code/extensions/ImageExtension.php | ImageExtension.getBase64 | public function getBase64()
{
if ($this->owner->exists()) {
$file = $this->owner->getFullPath();
$mime = mime_content_type($file);
$fileContent = file_get_contents($file);
return "data://$mime;base64," . base64_encode($fileContent);
}
return null;
} | php | public function getBase64()
{
if ($this->owner->exists()) {
$file = $this->owner->getFullPath();
$mime = mime_content_type($file);
$fileContent = file_get_contents($file);
return "data://$mime;base64," . base64_encode($fileContent);
}
return null;
} | [
"public",
"function",
"getBase64",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"owner",
"->",
"getFullPath",
"(",
")",
";",
"$",
"mime",
"=",
"mime_content_type",
"(... | Get a base 64 encoded variant of the image
@return string | [
"Get",
"a",
"base",
"64",
"encoded",
"variant",
"of",
"the",
"image"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/extensions/ImageExtension.php#L27-L37 | train |
inc2734/wp-view-controller | src/App/Template_Part.php | Template_Part.set_var | public function set_var( $key, $value ) {
if ( null === $this->wp_query->get( $key, null ) ) {
$this->vars[ $key ] = $value;
$this->wp_query->set( $key, $value );
}
} | php | public function set_var( $key, $value ) {
if ( null === $this->wp_query->get( $key, null ) ) {
$this->vars[ $key ] = $value;
$this->wp_query->set( $key, $value );
}
} | [
"public",
"function",
"set_var",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"wp_query",
"->",
"get",
"(",
"$",
"key",
",",
"null",
")",
")",
"{",
"$",
"this",
"->",
"vars",
"[",
"$",
"key",
"]",
... | Sets a variable
@param string $key
@param mixed $value
@return void | [
"Sets",
"a",
"variable"
] | d146b7dce51fead749f83b48fc49d1386e676bae | https://github.com/inc2734/wp-view-controller/blob/d146b7dce51fead749f83b48fc49d1386e676bae/src/App/Template_Part.php#L69-L74 | train |
inc2734/wp-view-controller | src/App/Template_Part.php | Template_Part.render | public function render() {
$html = '';
ob_start();
if ( $this->_is_root_template() ) {
$this->_root_get_template_part();
} else {
get_template_part( $this->slug, $this->name );
}
$html = ob_get_clean();
// @codingStandardsIgnoreStart
echo apply_filters( 'inc2734_view_controller_template_part_render', $html, $this->slug, $this->name, $this->vars );
// @codingStandardsIgnoreEnd
foreach ( $this->vars as $key => $value ) {
unset( $value );
$this->wp_query->set( $key, null );
}
} | php | public function render() {
$html = '';
ob_start();
if ( $this->_is_root_template() ) {
$this->_root_get_template_part();
} else {
get_template_part( $this->slug, $this->name );
}
$html = ob_get_clean();
// @codingStandardsIgnoreStart
echo apply_filters( 'inc2734_view_controller_template_part_render', $html, $this->slug, $this->name, $this->vars );
// @codingStandardsIgnoreEnd
foreach ( $this->vars as $key => $value ) {
unset( $value );
$this->wp_query->set( $key, null );
}
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"html",
"=",
"''",
";",
"ob_start",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_is_root_template",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_root_get_template_part",
"(",
")",
";",
"}",
"else",
... | Rendering the template part
@return void | [
"Rendering",
"the",
"template",
"part"
] | d146b7dce51fead749f83b48fc49d1386e676bae | https://github.com/inc2734/wp-view-controller/blob/d146b7dce51fead749f83b48fc49d1386e676bae/src/App/Template_Part.php#L93-L112 | train |
inc2734/wp-view-controller | src/App/Template_Part.php | Template_Part._is_root_template | protected function _is_root_template() {
$hierarchy = [];
/**
* @deprecated
*/
$root = apply_filters(
'inc2734_view_controller_template_part_root',
'',
$this->slug,
$this->name,
$this->vars
);
if ( $root ) {
$hierarchy[] = $root;
}
$hierarchy = apply_filters(
'inc2734_view_controller_template_part_root_hierarchy',
$hierarchy,
$this->slug,
$this->name,
$this->vars
);
$hierarchy = array_unique( $hierarchy );
foreach ( $hierarchy as $root ) {
$is_root = $this->_is_root( $root );
if ( $is_root ) {
return $is_root;
}
}
return false;
} | php | protected function _is_root_template() {
$hierarchy = [];
/**
* @deprecated
*/
$root = apply_filters(
'inc2734_view_controller_template_part_root',
'',
$this->slug,
$this->name,
$this->vars
);
if ( $root ) {
$hierarchy[] = $root;
}
$hierarchy = apply_filters(
'inc2734_view_controller_template_part_root_hierarchy',
$hierarchy,
$this->slug,
$this->name,
$this->vars
);
$hierarchy = array_unique( $hierarchy );
foreach ( $hierarchy as $root ) {
$is_root = $this->_is_root( $root );
if ( $is_root ) {
return $is_root;
}
}
return false;
} | [
"protected",
"function",
"_is_root_template",
"(",
")",
"{",
"$",
"hierarchy",
"=",
"[",
"]",
";",
"/**\n\t\t * @deprecated\n\t\t */",
"$",
"root",
"=",
"apply_filters",
"(",
"'inc2734_view_controller_template_part_root'",
",",
"''",
",",
"$",
"this",
"->",
"slug",
... | Return true when the template exists in each roots
@return boolean | [
"Return",
"true",
"when",
"the",
"template",
"exists",
"in",
"each",
"roots"
] | d146b7dce51fead749f83b48fc49d1386e676bae | https://github.com/inc2734/wp-view-controller/blob/d146b7dce51fead749f83b48fc49d1386e676bae/src/App/Template_Part.php#L152-L187 | train |
inc2734/wp-view-controller | src/App/Template_Part.php | Template_Part._is_root | protected function _is_root( $root ) {
$this->root = $root;
$is_root = (bool) $this->_root_locate_template();
if ( ! $is_root ) {
$this->root = '';
}
return $is_root;
} | php | protected function _is_root( $root ) {
$this->root = $root;
$is_root = (bool) $this->_root_locate_template();
if ( ! $is_root ) {
$this->root = '';
}
return $is_root;
} | [
"protected",
"function",
"_is_root",
"(",
"$",
"root",
")",
"{",
"$",
"this",
"->",
"root",
"=",
"$",
"root",
";",
"$",
"is_root",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"_root_locate_template",
"(",
")",
";",
"if",
"(",
"!",
"$",
"is_root",
")"... | Return true when the template exists in the root
@param string $root root directory of template parts
@return boolean | [
"Return",
"true",
"when",
"the",
"template",
"exists",
"in",
"the",
"root"
] | d146b7dce51fead749f83b48fc49d1386e676bae | https://github.com/inc2734/wp-view-controller/blob/d146b7dce51fead749f83b48fc49d1386e676bae/src/App/Template_Part.php#L195-L204 | train |
inc2734/wp-view-controller | src/App/Template_Part.php | Template_Part._get_root_template_part_slugs | protected function _get_root_template_part_slugs() {
if ( ! $this->root ) {
return [];
}
if ( $this->name ) {
$templates[] = trailingslashit( $this->root ) . $this->slug . '-' . $this->name . '.php';
}
$templates[] = trailingslashit( $this->root ) . $this->slug . '.php';
return $templates;
} | php | protected function _get_root_template_part_slugs() {
if ( ! $this->root ) {
return [];
}
if ( $this->name ) {
$templates[] = trailingslashit( $this->root ) . $this->slug . '-' . $this->name . '.php';
}
$templates[] = trailingslashit( $this->root ) . $this->slug . '.php';
return $templates;
} | [
"protected",
"function",
"_get_root_template_part_slugs",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"root",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"name",
")",
"{",
"$",
"templates",
"[",
"]",
"=",
"trailingslas... | Return candidate file names of the root template part
@return array | [
"Return",
"candidate",
"file",
"names",
"of",
"the",
"root",
"template",
"part"
] | d146b7dce51fead749f83b48fc49d1386e676bae | https://github.com/inc2734/wp-view-controller/blob/d146b7dce51fead749f83b48fc49d1386e676bae/src/App/Template_Part.php#L211-L222 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php | DataCollection.getData | public function getData($page)
{
$this->loadData();
$start = ($page - 1) * $this->pageSize;
return array_slice($this->filteredData, $start, $this->pageSize);
} | php | public function getData($page)
{
$this->loadData();
$start = ($page - 1) * $this->pageSize;
return array_slice($this->filteredData, $start, $this->pageSize);
} | [
"public",
"function",
"getData",
"(",
"$",
"page",
")",
"{",
"$",
"this",
"->",
"loadData",
"(",
")",
";",
"$",
"start",
"=",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"this",
"->",
"pageSize",
";",
"return",
"array_slice",
"(",
"$",
"this",
"->... | Get the data that needs to be added on a certain page.
@param int $page The page to get the data for. Pages starts a 1.
@return array | [
"Get",
"the",
"data",
"that",
"needs",
"to",
"be",
"added",
"on",
"a",
"certain",
"page",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php#L53-L59 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php | DataCollection.getLastPageNumber | public function getLastPageNumber()
{
$this->loadData();
$count = count($this->filteredData);
return ceil($count / $this->pageSize);
} | php | public function getLastPageNumber()
{
$this->loadData();
$count = count($this->filteredData);
return ceil($count / $this->pageSize);
} | [
"public",
"function",
"getLastPageNumber",
"(",
")",
"{",
"$",
"this",
"->",
"loadData",
"(",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"filteredData",
")",
";",
"return",
"ceil",
"(",
"$",
"count",
"/",
"$",
"this",
"->",
"pageSi... | Get the number of the last page.
@return int | [
"Get",
"the",
"number",
"of",
"the",
"last",
"page",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php#L79-L85 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php | DataCollection.setFiltersAndSort | public function setFiltersAndSort($filters, $sortField = null, $sortOrder = "ASC")
{
$this->reset();
$this->filters = $filters;
if ($sortField && $sortOrder) {
$this->sort = [$sortField, $sortOrder];
}
return $this;
} | php | public function setFiltersAndSort($filters, $sortField = null, $sortOrder = "ASC")
{
$this->reset();
$this->filters = $filters;
if ($sortField && $sortOrder) {
$this->sort = [$sortField, $sortOrder];
}
return $this;
} | [
"public",
"function",
"setFiltersAndSort",
"(",
"$",
"filters",
",",
"$",
"sortField",
"=",
"null",
",",
"$",
"sortOrder",
"=",
"\"ASC\"",
")",
"{",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"$",
"this",
"->",
"filters",
"=",
"$",
"filters",
";",
"i... | Set filters & sorting to apply to the data.
@param array $filters List of filters with the fallowing format :
['key_to_filter'=> ['type_of_filter' , 'wordl"]]
For the possible types of filters check FilterInstance constants.
Example to find a map or author containing the keyword "hello"
['name'=> ['like', 'hello"], 'author_loin'=> ['like', 'hello"]]
@param string $sortField Field to sort on
@param string $sortOrder Order DESC or ASC.
@return $this | [
"Set",
"filters",
"&",
"sorting",
"to",
"apply",
"to",
"the",
"data",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php#L100-L110 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php | DataCollection.setDataByIndex | public function setDataByIndex($line, $data)
{
$this->data[$line] = $data;
$this->filteredData = null;
} | php | public function setDataByIndex($line, $data)
{
$this->data[$line] = $data;
$this->filteredData = null;
} | [
"public",
"function",
"setDataByIndex",
"(",
"$",
"line",
",",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"line",
"]",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"filteredData",
"=",
"null",
";",
"}"
] | sets new data to line
@param $index
@param $data | [
"sets",
"new",
"data",
"to",
"line"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php#L118-L122 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php | DataCollection.reset | public function reset()
{
$this->filteredData = null;
$this->filters = [];
$this->sort = null;
return $this;
} | php | public function reset()
{
$this->filteredData = null;
$this->filters = [];
$this->sort = null;
return $this;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"filteredData",
"=",
"null",
";",
"$",
"this",
"->",
"filters",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"sort",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Reset current filters & sorting.
@return $this | [
"Reset",
"current",
"filters",
"&",
"sorting",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php#L143-L150 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php | DataCollection.loadData | protected function loadData()
{
if (is_null($this->filteredData)) {
$this->filteredData = $this->filterHelper->filterData(
$this->data,
$this->filters,
FilterInterface::FILTER_LOGIC_OR
);
if (!is_null($this->sort)) {
$sort = $this->sort;
uasort($this->filteredData, function ($a, $b) use ($sort) {
if (is_numeric($a[$sort[0]])) {
$comp = ($a[$sort[0]] < $b[$sort[0]]) ? -1 : 1;
} else {
$comp = (strcmp($a[$sort[0]], $b[$sort[0]]));
}
if ($sort[1] == "DESC") {
return -1 * $comp;
} else {
return $comp;
}
});
}
}
} | php | protected function loadData()
{
if (is_null($this->filteredData)) {
$this->filteredData = $this->filterHelper->filterData(
$this->data,
$this->filters,
FilterInterface::FILTER_LOGIC_OR
);
if (!is_null($this->sort)) {
$sort = $this->sort;
uasort($this->filteredData, function ($a, $b) use ($sort) {
if (is_numeric($a[$sort[0]])) {
$comp = ($a[$sort[0]] < $b[$sort[0]]) ? -1 : 1;
} else {
$comp = (strcmp($a[$sort[0]], $b[$sort[0]]));
}
if ($sort[1] == "DESC") {
return -1 * $comp;
} else {
return $comp;
}
});
}
}
} | [
"protected",
"function",
"loadData",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"filteredData",
")",
")",
"{",
"$",
"this",
"->",
"filteredData",
"=",
"$",
"this",
"->",
"filterHelper",
"->",
"filterData",
"(",
"$",
"this",
"->",
"dat... | Filter & sort the data. | [
"Filter",
"&",
"sort",
"the",
"data",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Model/Gui/Grid/DataCollection.php#L155-L182 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Services/DataProviderManager.php | DataProviderManager.isProviderCompatible | public function isProviderCompatible($provider, $title, $mode, $script, Map $map)
{
return !is_null($this->getCompatibleProviderId($provider, $title, $mode, $script, $map));
} | php | public function isProviderCompatible($provider, $title, $mode, $script, Map $map)
{
return !is_null($this->getCompatibleProviderId($provider, $title, $mode, $script, $map));
} | [
"public",
"function",
"isProviderCompatible",
"(",
"$",
"provider",
",",
"$",
"title",
",",
"$",
"mode",
",",
"$",
"script",
",",
"Map",
"$",
"map",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getCompatibleProviderId",
"(",
"$",
"provide... | Check of a provider is compatible
@param string $provider
@param string $title
@param string $mode
@param string $script
@param Map $map
@return bool | [
"Check",
"of",
"a",
"provider",
"is",
"compatible"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Services/DataProviderManager.php#L145-L148 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Services/DataProviderManager.php | DataProviderManager.registerPlugin | public function registerPlugin($provider, $pluginId, $title, $mode, $script, Map $map)
{
$providerId = $this->getCompatibleProviderId($provider, $title, $mode, $script, $map);
if (empty($providerId)) {
return;
}
/** @var AbstractDataProvider $providerService */
$providerService = $this->container->get($providerId);
$pluginService = $this->container->get($pluginId);
$interface = $this->providerInterfaces[$provider];
if ($pluginService instanceof $interface) {
$this->deletePlugin($provider, $pluginId);
$providerService->registerPlugin($pluginId, $pluginService);
} else {
throw new UncompatibleException("Plugin $pluginId isn't compatible with $provider. Should be instance of $interface");
}
$this->logger->info("Plugin '$pluginId' will use data provider '$provider' : '$providerId'");
} | php | public function registerPlugin($provider, $pluginId, $title, $mode, $script, Map $map)
{
$providerId = $this->getCompatibleProviderId($provider, $title, $mode, $script, $map);
if (empty($providerId)) {
return;
}
/** @var AbstractDataProvider $providerService */
$providerService = $this->container->get($providerId);
$pluginService = $this->container->get($pluginId);
$interface = $this->providerInterfaces[$provider];
if ($pluginService instanceof $interface) {
$this->deletePlugin($provider, $pluginId);
$providerService->registerPlugin($pluginId, $pluginService);
} else {
throw new UncompatibleException("Plugin $pluginId isn't compatible with $provider. Should be instance of $interface");
}
$this->logger->info("Plugin '$pluginId' will use data provider '$provider' : '$providerId'");
} | [
"public",
"function",
"registerPlugin",
"(",
"$",
"provider",
",",
"$",
"pluginId",
",",
"$",
"title",
",",
"$",
"mode",
",",
"$",
"script",
",",
"Map",
"$",
"map",
")",
"{",
"$",
"providerId",
"=",
"$",
"this",
"->",
"getCompatibleProviderId",
"(",
"$... | Register a plugin to the DataProviders.
@param string $provider The provider to register the plugin to.
@param string $pluginId The id of the plugin to be registered.
@param string $title The title to register it for.
@param string $mode The mode to register it for.
@param string $script The script to register it for.
@param Map $map Current map
@throws UncompatibleException | [
"Register",
"a",
"plugin",
"to",
"the",
"DataProviders",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Services/DataProviderManager.php#L193-L214 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Services/DataProviderManager.php | DataProviderManager.deletePlugin | public function deletePlugin($provider, $pluginId)
{
foreach ($this->providersByCompatibility[$provider] as $titleProviders) {
foreach ($titleProviders as $modeProviders) {
foreach ($modeProviders as $providerId) {
$providerService = $this->container->get($providerId);
$providerService->deletePlugin($pluginId);
}
}
}
} | php | public function deletePlugin($provider, $pluginId)
{
foreach ($this->providersByCompatibility[$provider] as $titleProviders) {
foreach ($titleProviders as $modeProviders) {
foreach ($modeProviders as $providerId) {
$providerService = $this->container->get($providerId);
$providerService->deletePlugin($pluginId);
}
}
}
} | [
"public",
"function",
"deletePlugin",
"(",
"$",
"provider",
",",
"$",
"pluginId",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"providersByCompatibility",
"[",
"$",
"provider",
"]",
"as",
"$",
"titleProviders",
")",
"{",
"foreach",
"(",
"$",
"titleProviders"... | Provider to delete a plugin from.
@param $provider
@param $pluginId | [
"Provider",
"to",
"delete",
"a",
"plugin",
"from",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Services/DataProviderManager.php#L223-L233 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Services/DataProviderManager.php | DataProviderManager.dispatch | public function dispatch($eventName, $params)
{
if (isset($this->enabledProviderListeners[$eventName])) {
foreach ($this->enabledProviderListeners[$eventName] as $callback) {
call_user_func_array($callback, $params);
}
}
} | php | public function dispatch($eventName, $params)
{
if (isset($this->enabledProviderListeners[$eventName])) {
foreach ($this->enabledProviderListeners[$eventName] as $callback) {
call_user_func_array($callback, $params);
}
}
} | [
"public",
"function",
"dispatch",
"(",
"$",
"eventName",
",",
"$",
"params",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"enabledProviderListeners",
"[",
"$",
"eventName",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"enabledProviderL... | Dispatch event to the data providers.
@param $eventName
@param $params | [
"Dispatch",
"event",
"to",
"the",
"data",
"providers",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Services/DataProviderManager.php#L241-L248 | train |
jefersondaniel/novoboletophp | src/NovoBoletoPHP/Api/Soap/Service.php | Service.makeBoletoAsHTML | public function makeBoletoAsHTML($codigoBanco, $boleto)
{
$boleto = new Boleto($boleto);
$factory = new BoletoFactory($this->config);
return $factory->makeBoletoAsHTML($codigoBanco, $boleto->toArray());
} | php | public function makeBoletoAsHTML($codigoBanco, $boleto)
{
$boleto = new Boleto($boleto);
$factory = new BoletoFactory($this->config);
return $factory->makeBoletoAsHTML($codigoBanco, $boleto->toArray());
} | [
"public",
"function",
"makeBoletoAsHTML",
"(",
"$",
"codigoBanco",
",",
"$",
"boleto",
")",
"{",
"$",
"boleto",
"=",
"new",
"Boleto",
"(",
"$",
"boleto",
")",
";",
"$",
"factory",
"=",
"new",
"BoletoFactory",
"(",
"$",
"this",
"->",
"config",
")",
";",... | Gera um boleto como html
@param int $codigoBanco
@param wrapper $boleto @className=\NovoBoletoPHP\Api\Soap\Boleto
@return string | [
"Gera",
"um",
"boleto",
"como",
"html"
] | 36f66fa94eef7f9bcde454c50409a9ed22574325 | https://github.com/jefersondaniel/novoboletophp/blob/36f66fa94eef7f9bcde454c50409a9ed22574325/src/NovoBoletoPHP/Api/Soap/Service.php#L21-L26 | train |
ansas/php-component | src/Faker/Provider/CountryIpv4.php | CountryIpv4.ipv4For | protected function ipv4For($country)
{
$country = self::toUpper($country);
if (!isset(self::$ipv4Ranges[$country])) {
return '';
}
return static::randomElement(self::$ipv4Ranges[$country]) . mt_rand(1, 254);
} | php | protected function ipv4For($country)
{
$country = self::toUpper($country);
if (!isset(self::$ipv4Ranges[$country])) {
return '';
}
return static::randomElement(self::$ipv4Ranges[$country]) . mt_rand(1, 254);
} | [
"protected",
"function",
"ipv4For",
"(",
"$",
"country",
")",
"{",
"$",
"country",
"=",
"self",
"::",
"toUpper",
"(",
"$",
"country",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"ipv4Ranges",
"[",
"$",
"country",
"]",
")",
")",
"{",
... | Generate an IPv4 for country
@param string $country
@return string | [
"Generate",
"an",
"IPv4",
"for",
"country"
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Faker/Provider/CountryIpv4.php#L46-L55 | train |
lukefor/Laravel4-SmartyView | src/Dark/SmartyView/Smarty/demo/plugins/cacheresource.memcache.php | Smarty_CacheResource_Memcache.delete | protected function delete(array $keys)
{
foreach ($keys as $k) {
$k = sha1($k);
$this->memcache->delete($k);
}
return true;
} | php | protected function delete(array $keys)
{
foreach ($keys as $k) {
$k = sha1($k);
$this->memcache->delete($k);
}
return true;
} | [
"protected",
"function",
"delete",
"(",
"array",
"$",
"keys",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"k",
")",
"{",
"$",
"k",
"=",
"sha1",
"(",
"$",
"k",
")",
";",
"$",
"this",
"->",
"memcache",
"->",
"delete",
"(",
"$",
"k",
")",
... | Remove values from cache
@param array $keys list of keys to delete
@return boolean true on success, false on failure | [
"Remove",
"values",
"from",
"cache"
] | cb3a9bfae805e787cff179b3e41f1a9ad65b389e | https://github.com/lukefor/Laravel4-SmartyView/blob/cb3a9bfae805e787cff179b3e41f1a9ad65b389e/src/Dark/SmartyView/Smarty/demo/plugins/cacheresource.memcache.php#L78-L86 | train |
melisplatform/melis-installer | src/Module.php | Module.initSession | public function initSession()
{
$sessionManager = new SessionManager();
$sessionManager->start();
Container::setDefaultManager($sessionManager);
$container = new Container('melisinstaller');
} | php | public function initSession()
{
$sessionManager = new SessionManager();
$sessionManager->start();
Container::setDefaultManager($sessionManager);
$container = new Container('melisinstaller');
} | [
"public",
"function",
"initSession",
"(",
")",
"{",
"$",
"sessionManager",
"=",
"new",
"SessionManager",
"(",
")",
";",
"$",
"sessionManager",
"->",
"start",
"(",
")",
";",
"Container",
"::",
"setDefaultManager",
"(",
"$",
"sessionManager",
")",
";",
"$",
... | Create module's session container | [
"Create",
"module",
"s",
"session",
"container"
] | f34d925b847c1389a5498844fdae890eeb34e461 | https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Module.php#L155-L162 | train |
joshiausdemwald/Force.com-Toolkit-for-PHP-5.3 | Form/Metadata/FormField.php | FormField.getEditable | public function getEditable($is_create = true)
{
return
(
$this->getParent()->getEditable() ||
$this->getParent()->getRequired()
) &&
! $this->getField()->getCalculated() &&
! $this->getField()->getAutoNumber() &&
(
$is_create && $this->getField()->getCreateable() ||
! $is_create && $this->getField()->getUpdateable()
)
;
} | php | public function getEditable($is_create = true)
{
return
(
$this->getParent()->getEditable() ||
$this->getParent()->getRequired()
) &&
! $this->getField()->getCalculated() &&
! $this->getField()->getAutoNumber() &&
(
$is_create && $this->getField()->getCreateable() ||
! $is_create && $this->getField()->getUpdateable()
)
;
} | [
"public",
"function",
"getEditable",
"(",
"$",
"is_create",
"=",
"true",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getEditable",
"(",
")",
"||",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getRequired",
"(",
")",
... | Returns true if the field is editable as
specified on the page layout.
@param bool $is_create
@return bool $editable | [
"Returns",
"true",
"if",
"the",
"field",
"is",
"editable",
"as",
"specified",
"on",
"the",
"page",
"layout",
"."
] | 7fd3194eb3155f019e34439e586e6baf6cbb202f | https://github.com/joshiausdemwald/Force.com-Toolkit-for-PHP-5.3/blob/7fd3194eb3155f019e34439e586e6baf6cbb202f/Form/Metadata/FormField.php#L114-L128 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Gui/Layouts/LayoutScrollable.php | LayoutScrollable.forceContainerSize | public function forceContainerSize($x, $y)
{
$this->force = true;
$this->_X = $x;
$this->_Y = $y;
} | php | public function forceContainerSize($x, $y)
{
$this->force = true;
$this->_X = $x;
$this->_Y = $y;
} | [
"public",
"function",
"forceContainerSize",
"(",
"$",
"x",
",",
"$",
"y",
")",
"{",
"$",
"this",
"->",
"force",
"=",
"true",
";",
"$",
"this",
"->",
"_X",
"=",
"$",
"x",
";",
"$",
"this",
"->",
"_Y",
"=",
"$",
"y",
";",
"}"
] | Forces container size.
@param $x
@param $y | [
"Forces",
"container",
"size",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Gui/Layouts/LayoutScrollable.php#L67-L72 | train |
TheBnl/event-tickets | code/controllers/CheckoutSteps.php | CheckoutSteps.nextStep | public static function nextStep($step)
{
$steps = self::getSteps();
$key = self::getStepIndex($step) + 1;
if (key_exists($key, $steps)) {
return $steps[$key];
} else {
return null;
}
} | php | public static function nextStep($step)
{
$steps = self::getSteps();
$key = self::getStepIndex($step) + 1;
if (key_exists($key, $steps)) {
return $steps[$key];
} else {
return null;
}
} | [
"public",
"static",
"function",
"nextStep",
"(",
"$",
"step",
")",
"{",
"$",
"steps",
"=",
"self",
"::",
"getSteps",
"(",
")",
";",
"$",
"key",
"=",
"self",
"::",
"getStepIndex",
"(",
"$",
"step",
")",
"+",
"1",
";",
"if",
"(",
"key_exists",
"(",
... | Return the next step
@param $step
@return null | [
"Return",
"the",
"next",
"step"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/controllers/CheckoutSteps.php#L42-L51 | train |
TheBnl/event-tickets | code/controllers/CheckoutSteps.php | CheckoutSteps.get | public static function get(CheckoutStepController $controller)
{
$list = new ArrayList();
$steps = self::getSteps();
foreach ($steps as $step) {
$data = new ViewableData();
$data->Link = $controller->Link($step);
$data->Title = _t("CheckoutSteps.$step", ucfirst($step));
$data->InPast = self::inPast($step, $controller);
$data->InFuture = self::inFuture($step, $controller);
$data->Current = self::current($step, $controller);
$list->add($data);
}
return $list;
} | php | public static function get(CheckoutStepController $controller)
{
$list = new ArrayList();
$steps = self::getSteps();
foreach ($steps as $step) {
$data = new ViewableData();
$data->Link = $controller->Link($step);
$data->Title = _t("CheckoutSteps.$step", ucfirst($step));
$data->InPast = self::inPast($step, $controller);
$data->InFuture = self::inFuture($step, $controller);
$data->Current = self::current($step, $controller);
$list->add($data);
}
return $list;
} | [
"public",
"static",
"function",
"get",
"(",
"CheckoutStepController",
"$",
"controller",
")",
"{",
"$",
"list",
"=",
"new",
"ArrayList",
"(",
")",
";",
"$",
"steps",
"=",
"self",
"::",
"getSteps",
"(",
")",
";",
"foreach",
"(",
"$",
"steps",
"as",
"$",... | Get the formatted steps
@param CheckoutStepController $controller
@return ArrayList | [
"Get",
"the",
"formatted",
"steps"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/controllers/CheckoutSteps.php#L70-L85 | train |
TheBnl/event-tickets | code/controllers/CheckoutSteps.php | CheckoutSteps.inPast | private static function inPast($step, CheckoutStepController $controller)
{
$currentStep = $controller->getURLParams()['Action'];
return self::getStepIndex($step) < self::getStepIndex($currentStep);
} | php | private static function inPast($step, CheckoutStepController $controller)
{
$currentStep = $controller->getURLParams()['Action'];
return self::getStepIndex($step) < self::getStepIndex($currentStep);
} | [
"private",
"static",
"function",
"inPast",
"(",
"$",
"step",
",",
"CheckoutStepController",
"$",
"controller",
")",
"{",
"$",
"currentStep",
"=",
"$",
"controller",
"->",
"getURLParams",
"(",
")",
"[",
"'Action'",
"]",
";",
"return",
"self",
"::",
"getStepIn... | Check if the step is in the past
@param $step
@param CheckoutStepController $controller
@return bool | [
"Check",
"if",
"the",
"step",
"is",
"in",
"the",
"past"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/controllers/CheckoutSteps.php#L107-L111 | train |
TheBnl/event-tickets | code/controllers/CheckoutSteps.php | CheckoutSteps.inFuture | private static function inFuture($step, CheckoutStepController $controller)
{
$currentStep = $controller->getURLParams()['Action'];
return self::getStepIndex($step) > self::getStepIndex($currentStep);
} | php | private static function inFuture($step, CheckoutStepController $controller)
{
$currentStep = $controller->getURLParams()['Action'];
return self::getStepIndex($step) > self::getStepIndex($currentStep);
} | [
"private",
"static",
"function",
"inFuture",
"(",
"$",
"step",
",",
"CheckoutStepController",
"$",
"controller",
")",
"{",
"$",
"currentStep",
"=",
"$",
"controller",
"->",
"getURLParams",
"(",
")",
"[",
"'Action'",
"]",
";",
"return",
"self",
"::",
"getStep... | Check if the step is in the future
@param $step
@param CheckoutStepController $controller
@return bool | [
"Check",
"if",
"the",
"step",
"is",
"in",
"the",
"future"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/controllers/CheckoutSteps.php#L121-L125 | train |
TheBnl/event-tickets | code/controllers/CheckoutSteps.php | CheckoutSteps.current | private static function current($step, CheckoutStepController $controller)
{
$currentStep = $controller->getURLParams()['Action'];
return self::getStepIndex($step) === self::getStepIndex($currentStep);
} | php | private static function current($step, CheckoutStepController $controller)
{
$currentStep = $controller->getURLParams()['Action'];
return self::getStepIndex($step) === self::getStepIndex($currentStep);
} | [
"private",
"static",
"function",
"current",
"(",
"$",
"step",
",",
"CheckoutStepController",
"$",
"controller",
")",
"{",
"$",
"currentStep",
"=",
"$",
"controller",
"->",
"getURLParams",
"(",
")",
"[",
"'Action'",
"]",
";",
"return",
"self",
"::",
"getStepI... | Check at the current step
@param $step
@param CheckoutStepController $controller
@return bool | [
"Check",
"at",
"the",
"current",
"step"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/controllers/CheckoutSteps.php#L135-L139 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/GameManiaplanet/DataProviders/ScriptMapDataProvider.php | ScriptMapDataProvider.dispatchMapEvent | protected function dispatchMapEvent($eventName, $params)
{
$map = $this->mapStorage->getMap($params['map']['uid']);
$this->dispatch(
$eventName,
[
$params['count'],
isset($params['time']) ? $params['time'] : time(),
isset($params['restarted']) ? $params['restarted'] : false,
$map,
]
);
} | php | protected function dispatchMapEvent($eventName, $params)
{
$map = $this->mapStorage->getMap($params['map']['uid']);
$this->dispatch(
$eventName,
[
$params['count'],
isset($params['time']) ? $params['time'] : time(),
isset($params['restarted']) ? $params['restarted'] : false,
$map,
]
);
} | [
"protected",
"function",
"dispatchMapEvent",
"(",
"$",
"eventName",
",",
"$",
"params",
")",
"{",
"$",
"map",
"=",
"$",
"this",
"->",
"mapStorage",
"->",
"getMap",
"(",
"$",
"params",
"[",
"'map'",
"]",
"[",
"'uid'",
"]",
")",
";",
"$",
"this",
"->",... | Dispatch map event.
@param $eventName
@param $params | [
"Dispatch",
"map",
"event",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/GameManiaplanet/DataProviders/ScriptMapDataProvider.php#L76-L89 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalMapRatings/Model/Map/MapratingTableMap.php | MapratingTableMap.doDelete | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(MapratingTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \eXpansion\Bundle\LocalMapRatings\Model\Maprating) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(MapratingTableMap::DATABASE_NAME);
$criteria->add(MapratingTableMap::COL_ID, (array) $values, Criteria::IN);
}
$query = MapratingQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
MapratingTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
MapratingTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | php | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(MapratingTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \eXpansion\Bundle\LocalMapRatings\Model\Maprating) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(MapratingTableMap::DATABASE_NAME);
$criteria->add(MapratingTableMap::COL_ID, (array) $values, Criteria::IN);
}
$query = MapratingQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
MapratingTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
MapratingTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | [
"public",
"static",
"function",
"doDelete",
"(",
"$",
"values",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getW... | Performs a DELETE on the database, given a Maprating or Criteria object OR a primary key value.
@param mixed $values Criteria or Maprating object or primary key or array of primary keys
which is used to create the DELETE statement
@param ConnectionInterface $con the connection to use
@return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
if supported by native driver or if emulated using Propel.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Performs",
"a",
"DELETE",
"on",
"the",
"database",
"given",
"a",
"Maprating",
"or",
"Criteria",
"object",
"OR",
"a",
"primary",
"key",
"value",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalMapRatings/Model/Map/MapratingTableMap.php#L374-L402 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Modules/UserProfile.php | UserProfile.formUserInfo | protected function formUserInfo()
{
$form = new XmlFormCollection($this->_context, $this->_url, $this->_myWords->Value("UPDATETITLE"));
$this->_paragraph->addXmlnukeObject($form);
$hidden = new XmlInputHidden("action", "update");
$form->addXmlnukeObject($hidden);
$labelField = new XmlInputLabelField($this->_myWords->Value("LABEL_LOGIN"), $this->_user->getField($this->_users->getUserTable()->username));
$form->addXmlnukeObject($labelField);
$textBox = new XmlInputTextBox($this->_myWords->Value("LABEL_NAME"), "name",$this->_user->getField($this->_users->getUserTable()->name));
$form->addXmlnukeObject($textBox);
$textBox = new XmlInputTextBox($this->_myWords->Value("LABEL_EMAIL"), "email", $this->_user->getField($this->_users->getUserTable()->email));
$form->addXmlnukeObject($textBox);
$button = new XmlInputButtons();
$button->addSubmit($this->_myWords->Value("TXT_UPDATE"),"");
$form->addXmlnukeObject($button);
} | php | protected function formUserInfo()
{
$form = new XmlFormCollection($this->_context, $this->_url, $this->_myWords->Value("UPDATETITLE"));
$this->_paragraph->addXmlnukeObject($form);
$hidden = new XmlInputHidden("action", "update");
$form->addXmlnukeObject($hidden);
$labelField = new XmlInputLabelField($this->_myWords->Value("LABEL_LOGIN"), $this->_user->getField($this->_users->getUserTable()->username));
$form->addXmlnukeObject($labelField);
$textBox = new XmlInputTextBox($this->_myWords->Value("LABEL_NAME"), "name",$this->_user->getField($this->_users->getUserTable()->name));
$form->addXmlnukeObject($textBox);
$textBox = new XmlInputTextBox($this->_myWords->Value("LABEL_EMAIL"), "email", $this->_user->getField($this->_users->getUserTable()->email));
$form->addXmlnukeObject($textBox);
$button = new XmlInputButtons();
$button->addSubmit($this->_myWords->Value("TXT_UPDATE"),"");
$form->addXmlnukeObject($button);
} | [
"protected",
"function",
"formUserInfo",
"(",
")",
"{",
"$",
"form",
"=",
"new",
"XmlFormCollection",
"(",
"$",
"this",
"->",
"_context",
",",
"$",
"this",
"->",
"_url",
",",
"$",
"this",
"->",
"_myWords",
"->",
"Value",
"(",
"\"UPDATETITLE\"",
")",
")",... | Show the info of user in the form | [
"Show",
"the",
"info",
"of",
"user",
"in",
"the",
"form"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Modules/UserProfile.php#L230-L250 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Modules/UserProfile.php | UserProfile.formPasswordInfo | protected function formPasswordInfo()
{
$form = new XmlFormCollection($this->_context, $this->_url, $this->_myWords->Value("CHANGEPASSTITLE"));
$this->_paragraph->addXmlnukeObject($form);
$hidden = new XmlInputHidden("action", "changepassword");
$form->addXmlnukeObject($hidden);
$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSOLDPASS"), "oldpassword","");
$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD );
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSNEWPASS"), "newpassword","");
$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD );
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSNEWPASS2"), "newpassword2","");
$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD );
$form->addXmlnukeObject($textbox);
$button = new XmlInputButtons();
$button->addSubmit($this->_myWords->Value("TXT_CHANGE"),"");
$form->addXmlnukeObject($button);
} | php | protected function formPasswordInfo()
{
$form = new XmlFormCollection($this->_context, $this->_url, $this->_myWords->Value("CHANGEPASSTITLE"));
$this->_paragraph->addXmlnukeObject($form);
$hidden = new XmlInputHidden("action", "changepassword");
$form->addXmlnukeObject($hidden);
$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSOLDPASS"), "oldpassword","");
$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD );
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSNEWPASS"), "newpassword","");
$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD );
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSNEWPASS2"), "newpassword2","");
$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD );
$form->addXmlnukeObject($textbox);
$button = new XmlInputButtons();
$button->addSubmit($this->_myWords->Value("TXT_CHANGE"),"");
$form->addXmlnukeObject($button);
} | [
"protected",
"function",
"formPasswordInfo",
"(",
")",
"{",
"$",
"form",
"=",
"new",
"XmlFormCollection",
"(",
"$",
"this",
"->",
"_context",
",",
"$",
"this",
"->",
"_url",
",",
"$",
"this",
"->",
"_myWords",
"->",
"Value",
"(",
"\"CHANGEPASSTITLE\"",
")"... | Form Password Info | [
"Form",
"Password",
"Info"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Modules/UserProfile.php#L256-L279 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Modules/UserProfile.php | UserProfile.formRolesInfo | protected function formRolesInfo()
{
$form = new XmlFormCollection($this->_context, $this->_url, $this->_myWords->Value("OTHERTITLE"));
$this->_paragraph->addXmlnukeObject($form);
$easyList = new XmlEasyList(EasyListType::SELECTLIST , "", $this->_myWords->Value("OTHERROLE"), $this->_users->returnUserProperty($this->_context->authenticatedUserId(), UserProperty::Role));
$form->addXmlnukeObject($easyList);
} | php | protected function formRolesInfo()
{
$form = new XmlFormCollection($this->_context, $this->_url, $this->_myWords->Value("OTHERTITLE"));
$this->_paragraph->addXmlnukeObject($form);
$easyList = new XmlEasyList(EasyListType::SELECTLIST , "", $this->_myWords->Value("OTHERROLE"), $this->_users->returnUserProperty($this->_context->authenticatedUserId(), UserProperty::Role));
$form->addXmlnukeObject($easyList);
} | [
"protected",
"function",
"formRolesInfo",
"(",
")",
"{",
"$",
"form",
"=",
"new",
"XmlFormCollection",
"(",
"$",
"this",
"->",
"_context",
",",
"$",
"this",
"->",
"_url",
",",
"$",
"this",
"->",
"_myWords",
"->",
"Value",
"(",
"\"OTHERTITLE\"",
")",
")",... | Form Roles Info | [
"Form",
"Roles",
"Info"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Modules/UserProfile.php#L285-L292 | train |
TheBnl/event-tickets | code/controllers/ReservationController.php | ReservationController.ReservationForm | public function ReservationForm()
{
$reservationForm = new ReservationForm($this, 'ReservationForm', ReservationSession::get());
$reservationForm->setNextStep(CheckoutSteps::nextStep($this->step));
return $reservationForm;
} | php | public function ReservationForm()
{
$reservationForm = new ReservationForm($this, 'ReservationForm', ReservationSession::get());
$reservationForm->setNextStep(CheckoutSteps::nextStep($this->step));
return $reservationForm;
} | [
"public",
"function",
"ReservationForm",
"(",
")",
"{",
"$",
"reservationForm",
"=",
"new",
"ReservationForm",
"(",
"$",
"this",
",",
"'ReservationForm'",
",",
"ReservationSession",
"::",
"get",
"(",
")",
")",
";",
"$",
"reservationForm",
"->",
"setNextStep",
... | Get the reservation form
@return ReservationForm | [
"Get",
"the",
"reservation",
"form"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/controllers/ReservationController.php#L29-L34 | train |
Celarius/spin-framework | src/Helpers/UUID.php | UUID.generate | public static function generate(): string
{
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
\mt_rand( 0, 0xffff ), \mt_rand( 0, 0xffff ),
// 16 bits for "time_mid"
\mt_rand( 0, 0xffff ),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
\mt_rand( 0, 0x0fff ) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
\mt_rand( 0, 0x3fff ) | 0x8000,
// 48 bits for "node"
\mt_rand( 0, 0xffff ), \mt_rand( 0, 0xffff ), \mt_rand( 0, 0xffff )
);
} | php | public static function generate(): string
{
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
\mt_rand( 0, 0xffff ), \mt_rand( 0, 0xffff ),
// 16 bits for "time_mid"
\mt_rand( 0, 0xffff ),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
\mt_rand( 0, 0x0fff ) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
\mt_rand( 0, 0x3fff ) | 0x8000,
// 48 bits for "node"
\mt_rand( 0, 0xffff ), \mt_rand( 0, 0xffff ), \mt_rand( 0, 0xffff )
);
} | [
"public",
"static",
"function",
"generate",
"(",
")",
":",
"string",
"{",
"return",
"sprintf",
"(",
"'%04x%04x-%04x-%04x-%04x-%04x%04x%04x'",
",",
"// 32 bits for \"time_low\"",
"\\",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"\\",
"mt_rand",
"(",
"0",
",",
... | Generate v4 UUID
@return string | [
"Generate",
"v4",
"UUID"
] | 2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0 | https://github.com/Celarius/spin-framework/blob/2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0/src/Helpers/UUID.php#L26-L47 | train |
joshiausdemwald/Force.com-Toolkit-for-PHP-5.3 | Soql/Tokenizer/Tokenizer.php | Tokenizer.setInput | public function setInput($input)
{
$this->input = $input;
$this->pos = 0;
$this->line = 0;
$this->linePos = 0;
$this->tokenType = TokenType::BOF;
$this->tokenValue = null;
$this->length = strlen($this->input);
} | php | public function setInput($input)
{
$this->input = $input;
$this->pos = 0;
$this->line = 0;
$this->linePos = 0;
$this->tokenType = TokenType::BOF;
$this->tokenValue = null;
$this->length = strlen($this->input);
} | [
"public",
"function",
"setInput",
"(",
"$",
"input",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"$",
"input",
";",
"$",
"this",
"->",
"pos",
"=",
"0",
";",
"$",
"this",
"->",
"line",
"=",
"0",
";",
"$",
"this",
"->",
"linePos",
"=",
"0",
";",
... | Sets the input string, resets the tokenizer... | [
"Sets",
"the",
"input",
"string",
"resets",
"the",
"tokenizer",
"..."
] | 7fd3194eb3155f019e34439e586e6baf6cbb202f | https://github.com/joshiausdemwald/Force.com-Toolkit-for-PHP-5.3/blob/7fd3194eb3155f019e34439e586e6baf6cbb202f/Soql/Tokenizer/Tokenizer.php#L132-L147 | train |
joshiausdemwald/Force.com-Toolkit-for-PHP-5.3 | Soql/Tokenizer/Tokenizer.php | Tokenizer.nextChar | private function nextChar()
{
if( ! $this->isEOF())
{
$this->linePos ++;
return $this->input[$this->pos++];
}
return null;
} | php | private function nextChar()
{
if( ! $this->isEOF())
{
$this->linePos ++;
return $this->input[$this->pos++];
}
return null;
} | [
"private",
"function",
"nextChar",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEOF",
"(",
")",
")",
"{",
"$",
"this",
"->",
"linePos",
"++",
";",
"return",
"$",
"this",
"->",
"input",
"[",
"$",
"this",
"->",
"pos",
"++",
"]",
";",
"}",... | Returns current char,
then moves pointer.
@return string|null | [
"Returns",
"current",
"char",
"then",
"moves",
"pointer",
"."
] | 7fd3194eb3155f019e34439e586e6baf6cbb202f | https://github.com/joshiausdemwald/Force.com-Toolkit-for-PHP-5.3/blob/7fd3194eb3155f019e34439e586e6baf6cbb202f/Soql/Tokenizer/Tokenizer.php#L594-L603 | train |
frankfoerster/cakephp-environment | src/Environments.php | Environments.init | public static function init()
{
$instance = self::getInstance();
$instance->_environments = $instance->_loadEnvironment($instance->_envPath . DS . 'config.php');
if (!isset($instance->_environments['local'])) {
$instance->_environments['local'] = [];
}
$instance->_current = $instance->_getEnvironment();
if ($instance->_current !== null && isset($instance->_environments[$instance->_current])) {
$instance->_loadEnvironment($instance->_envPath . DS . 'environment.' . $instance->_current . '.php');
}
} | php | public static function init()
{
$instance = self::getInstance();
$instance->_environments = $instance->_loadEnvironment($instance->_envPath . DS . 'config.php');
if (!isset($instance->_environments['local'])) {
$instance->_environments['local'] = [];
}
$instance->_current = $instance->_getEnvironment();
if ($instance->_current !== null && isset($instance->_environments[$instance->_current])) {
$instance->_loadEnvironment($instance->_envPath . DS . 'environment.' . $instance->_current . '.php');
}
} | [
"public",
"static",
"function",
"init",
"(",
")",
"{",
"$",
"instance",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"instance",
"->",
"_environments",
"=",
"$",
"instance",
"->",
"_loadEnvironment",
"(",
"$",
"instance",
"->",
"_envPath",
".",
... | Initialize an Environments singleton with all available environments.
[
'live' => [
'domain' => [
'www.example.com',
'simsalabim.de',
'...'
],
'path' => [
'absolute/path/on/server/1',
'absolute/path/on/server/2'
)
],
'staging' => [
...
],
...
)
- initialize an instance
- load the global environment config
- determine the current environment (in order -> self::$forceEnvironment > HOST > PATH > local)
- load the environment file for the determined environment
@return void | [
"Initialize",
"an",
"Environments",
"singleton",
"with",
"all",
"available",
"environments",
"."
] | afc1b028383b031cee79edb9e1c0feb12dab9c1e | https://github.com/frankfoerster/cakephp-environment/blob/afc1b028383b031cee79edb9e1c0feb12dab9c1e/src/Environments.php#L107-L121 | train |
frankfoerster/cakephp-environment | src/Environments.php | Environments._loadEnvironment | protected function _loadEnvironment($envFilePath)
{
if (file_exists($envFilePath)) {
include $envFilePath;
// $configure has to be defined in the included environment file.
if (isset($configure) && is_array($configure) && !empty($configure)) {
$config = Hash::merge(Configure::read(), Hash::expand($configure));
Configure::write($config);
}
if (isset($availableEnvironments) && empty($this->_environments)) {
return $availableEnvironments;
}
}
return [];
} | php | protected function _loadEnvironment($envFilePath)
{
if (file_exists($envFilePath)) {
include $envFilePath;
// $configure has to be defined in the included environment file.
if (isset($configure) && is_array($configure) && !empty($configure)) {
$config = Hash::merge(Configure::read(), Hash::expand($configure));
Configure::write($config);
}
if (isset($availableEnvironments) && empty($this->_environments)) {
return $availableEnvironments;
}
}
return [];
} | [
"protected",
"function",
"_loadEnvironment",
"(",
"$",
"envFilePath",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"envFilePath",
")",
")",
"{",
"include",
"$",
"envFilePath",
";",
"// $configure has to be defined in the included environment file.",
"if",
"(",
"isset... | Load the specified environment file.
@param string $envFilePath file path to environment file
@return array $availableEnvironments | [
"Load",
"the",
"specified",
"environment",
"file",
"."
] | afc1b028383b031cee79edb9e1c0feb12dab9c1e | https://github.com/frankfoerster/cakephp-environment/blob/afc1b028383b031cee79edb9e1c0feb12dab9c1e/src/Environments.php#L141-L158 | train |
frankfoerster/cakephp-environment | src/Environments.php | Environments._getEnvironment | protected function _getEnvironment()
{
$environment = self::$forceEnvironment;
// Check if the environment has been manually set (forced).
if ($environment !== null) {
if (!isset($this->_environments[$environment])) {
throw new Exception('Environment configuration for "' . $environment . '" could not be found.');
}
}
// If no manual setting is available, use "host:port" to decide which config to use.
if ($environment === null && !empty($_SERVER['HTTP_HOST'])) {
$host = (string)$_SERVER['HTTP_HOST'];
foreach ($this->_environments as $env => $envConfig) {
if (isset($envConfig['domain']) && in_array($host, $envConfig['domain'])) {
$environment = $env;
break;
}
}
}
// If there is no host:port match, try "host" only.
if ($environment === null && !empty($_SERVER['SERVER_NAME'])) {
$host = (string)$_SERVER['SERVER_NAME'];
foreach ($this->_environments as $env => $envConfig) {
if (isset($envConfig['domain']) && in_array($host, $envConfig['domain'])) {
$environment = $env;
break;
}
}
}
// If no host matched then try to use the APP path.
if ($environment === null && ($serverPath = $this->_getRealAppPath())) {
foreach ($this->_environments as $env => $envConfig) {
if (isset($envConfig['path']) && in_array($serverPath, $envConfig['path'])) {
$environment = $env;
break;
}
}
}
// No environment could be identified -> we are on a dev machine.
if (!$environment) {
$environment = 'local';
}
return $environment;
} | php | protected function _getEnvironment()
{
$environment = self::$forceEnvironment;
// Check if the environment has been manually set (forced).
if ($environment !== null) {
if (!isset($this->_environments[$environment])) {
throw new Exception('Environment configuration for "' . $environment . '" could not be found.');
}
}
// If no manual setting is available, use "host:port" to decide which config to use.
if ($environment === null && !empty($_SERVER['HTTP_HOST'])) {
$host = (string)$_SERVER['HTTP_HOST'];
foreach ($this->_environments as $env => $envConfig) {
if (isset($envConfig['domain']) && in_array($host, $envConfig['domain'])) {
$environment = $env;
break;
}
}
}
// If there is no host:port match, try "host" only.
if ($environment === null && !empty($_SERVER['SERVER_NAME'])) {
$host = (string)$_SERVER['SERVER_NAME'];
foreach ($this->_environments as $env => $envConfig) {
if (isset($envConfig['domain']) && in_array($host, $envConfig['domain'])) {
$environment = $env;
break;
}
}
}
// If no host matched then try to use the APP path.
if ($environment === null && ($serverPath = $this->_getRealAppPath())) {
foreach ($this->_environments as $env => $envConfig) {
if (isset($envConfig['path']) && in_array($serverPath, $envConfig['path'])) {
$environment = $env;
break;
}
}
}
// No environment could be identified -> we are on a dev machine.
if (!$environment) {
$environment = 'local';
}
return $environment;
} | [
"protected",
"function",
"_getEnvironment",
"(",
")",
"{",
"$",
"environment",
"=",
"self",
"::",
"$",
"forceEnvironment",
";",
"// Check if the environment has been manually set (forced).",
"if",
"(",
"$",
"environment",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"... | Detect the environment and return its name.
@return string
@throws Exception | [
"Detect",
"the",
"environment",
"and",
"return",
"its",
"name",
"."
] | afc1b028383b031cee79edb9e1c0feb12dab9c1e | https://github.com/frankfoerster/cakephp-environment/blob/afc1b028383b031cee79edb9e1c0feb12dab9c1e/src/Environments.php#L166-L211 | train |
frankfoerster/cakephp-environment | src/Environments.php | Environments._getRealAppPath | protected function _getRealAppPath()
{
$path = realpath(APP);
if (substr($path, -1, 1) !== DS) {
$path .= DS;
}
return $path;
} | php | protected function _getRealAppPath()
{
$path = realpath(APP);
if (substr($path, -1, 1) !== DS) {
$path .= DS;
}
return $path;
} | [
"protected",
"function",
"_getRealAppPath",
"(",
")",
"{",
"$",
"path",
"=",
"realpath",
"(",
"APP",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"-",
"1",
",",
"1",
")",
"!==",
"DS",
")",
"{",
"$",
"path",
".=",
"DS",
";",
"}",
"retur... | Wrapper to get the absolute environment path.
Handles symlinks properly, as well.
@return string Path
@codeCoverageIgnore | [
"Wrapper",
"to",
"get",
"the",
"absolute",
"environment",
"path",
".",
"Handles",
"symlinks",
"properly",
"as",
"well",
"."
] | afc1b028383b031cee79edb9e1c0feb12dab9c1e | https://github.com/frankfoerster/cakephp-environment/blob/afc1b028383b031cee79edb9e1c0feb12dab9c1e/src/Environments.php#L220-L228 | train |
UseMuffin/Crypt | src/Model/Behavior/CryptBehavior.php | CryptBehavior.initialize | public function initialize(array $config)
{
$config += $this->_defaultConfig;
$this->config('fields', $this->_resolveFields($config['fields']));
$this->config('strategy', $this->_resolveStrategy($config['strategy']));
} | php | public function initialize(array $config)
{
$config += $this->_defaultConfig;
$this->config('fields', $this->_resolveFields($config['fields']));
$this->config('strategy', $this->_resolveStrategy($config['strategy']));
} | [
"public",
"function",
"initialize",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"config",
"+=",
"$",
"this",
"->",
"_defaultConfig",
";",
"$",
"this",
"->",
"config",
"(",
"'fields'",
",",
"$",
"this",
"->",
"_resolveFields",
"(",
"$",
"config",
"[",
"... | Initialize behavior configuration.
@param array $config Configuration passed to the behavior
@throws \Cake\Core\Exception\Exception
@return void | [
"Initialize",
"behavior",
"configuration",
"."
] | 7ab7e8548b41118fe361c8ee0c0ba687492f5184 | https://github.com/UseMuffin/Crypt/blob/7ab7e8548b41118fe361c8ee0c0ba687492f5184/src/Model/Behavior/CryptBehavior.php#L54-L59 | train |
UseMuffin/Crypt | src/Model/Behavior/CryptBehavior.php | CryptBehavior.beforeSave | public function beforeSave(Event $event, EntityInterface $entity)
{
$driver = $this->_table->connection()->driver();
foreach ($this->config('fields') as $field => $type) {
if (!$entity->has($field)) {
continue;
}
$raw = $entity->get($field);
$plain = Type::build($type)->toDatabase($raw, $driver);
$entity->set($field, $this->encrypt($plain));
}
} | php | public function beforeSave(Event $event, EntityInterface $entity)
{
$driver = $this->_table->connection()->driver();
foreach ($this->config('fields') as $field => $type) {
if (!$entity->has($field)) {
continue;
}
$raw = $entity->get($field);
$plain = Type::build($type)->toDatabase($raw, $driver);
$entity->set($field, $this->encrypt($plain));
}
} | [
"public",
"function",
"beforeSave",
"(",
"Event",
"$",
"event",
",",
"EntityInterface",
"$",
"entity",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"_table",
"->",
"connection",
"(",
")",
"->",
"driver",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
... | Event listener to encrypt data.
@param \Cake\Event\Event $event Event.
@param \Cake\Datasource\EntityInterface $entity Entity.
@return void | [
"Event",
"listener",
"to",
"encrypt",
"data",
"."
] | 7ab7e8548b41118fe361c8ee0c0ba687492f5184 | https://github.com/UseMuffin/Crypt/blob/7ab7e8548b41118fe361c8ee0c0ba687492f5184/src/Model/Behavior/CryptBehavior.php#L68-L81 | train |
UseMuffin/Crypt | src/Model/Behavior/CryptBehavior.php | CryptBehavior.findDecrypted | public function findDecrypted(Query $query, array $options)
{
$options += ['fields' => []];
$mapper = function ($row) use ($options) {
$driver = $this->_table->connection()->driver();
foreach ($this->config('fields') as $field => $type) {
if (($options['fields'] && !in_array($field, (array)$options['fields']))
|| !($row instanceof EntityInterface) || !$row->has($field)
) {
continue;
}
$cipher = $row->get($field);
$plain = $this->decrypt($cipher);
$row->set($field, Type::build($type)->toPHP($plain, $driver));
}
return $row;
};
$formatter = function ($results) use ($mapper) {
return $results->map($mapper);
};
return $query->formatResults($formatter);
} | php | public function findDecrypted(Query $query, array $options)
{
$options += ['fields' => []];
$mapper = function ($row) use ($options) {
$driver = $this->_table->connection()->driver();
foreach ($this->config('fields') as $field => $type) {
if (($options['fields'] && !in_array($field, (array)$options['fields']))
|| !($row instanceof EntityInterface) || !$row->has($field)
) {
continue;
}
$cipher = $row->get($field);
$plain = $this->decrypt($cipher);
$row->set($field, Type::build($type)->toPHP($plain, $driver));
}
return $row;
};
$formatter = function ($results) use ($mapper) {
return $results->map($mapper);
};
return $query->formatResults($formatter);
} | [
"public",
"function",
"findDecrypted",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"+=",
"[",
"'fields'",
"=>",
"[",
"]",
"]",
";",
"$",
"mapper",
"=",
"function",
"(",
"$",
"row",
")",
"use",
"(",
"$",
"opti... | Custom finder to retrieve decrypted values.
@param \Cake\ORM\Query $query Query.
@param array $options Options.
@return \Cake\ORM\Query | [
"Custom",
"finder",
"to",
"retrieve",
"decrypted",
"values",
"."
] | 7ab7e8548b41118fe361c8ee0c0ba687492f5184 | https://github.com/UseMuffin/Crypt/blob/7ab7e8548b41118fe361c8ee0c0ba687492f5184/src/Model/Behavior/CryptBehavior.php#L90-L115 | train |
UseMuffin/Crypt | src/Model/Behavior/CryptBehavior.php | CryptBehavior.beforeFind | public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
{
$query->find('decrypted');
} | php | public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
{
$query->find('decrypted');
} | [
"public",
"function",
"beforeFind",
"(",
"Event",
"$",
"event",
",",
"Query",
"$",
"query",
",",
"ArrayObject",
"$",
"options",
",",
"$",
"primary",
")",
"{",
"$",
"query",
"->",
"find",
"(",
"'decrypted'",
")",
";",
"}"
] | Decrypts value after every find operation ONLY IF it was added to the
implemented events.
@param \Cake\Event\Event $event Event.
@param \Cake\ORM\Query $query Query.
@param \ArrayObject $options Options.
@param bool $primary Whether or not this is the root query or an associated query.
@return void | [
"Decrypts",
"value",
"after",
"every",
"find",
"operation",
"ONLY",
"IF",
"it",
"was",
"added",
"to",
"the",
"implemented",
"events",
"."
] | 7ab7e8548b41118fe361c8ee0c0ba687492f5184 | https://github.com/UseMuffin/Crypt/blob/7ab7e8548b41118fe361c8ee0c0ba687492f5184/src/Model/Behavior/CryptBehavior.php#L127-L130 | train |
UseMuffin/Crypt | src/Model/Behavior/CryptBehavior.php | CryptBehavior.decrypt | public function decrypt($cipher)
{
if (is_resource($cipher)) {
$cipher = stream_get_contents($cipher);
}
return $this->config('strategy')->decrypt($cipher);
} | php | public function decrypt($cipher)
{
if (is_resource($cipher)) {
$cipher = stream_get_contents($cipher);
}
return $this->config('strategy')->decrypt($cipher);
} | [
"public",
"function",
"decrypt",
"(",
"$",
"cipher",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"cipher",
")",
")",
"{",
"$",
"cipher",
"=",
"stream_get_contents",
"(",
"$",
"cipher",
")",
";",
"}",
"return",
"$",
"this",
"->",
"config",
"(",
"'st... | Decrypts a value using the defined key.
@param string $cipher Cipher to decrypt.
@return string | [
"Decrypts",
"a",
"value",
"using",
"the",
"defined",
"key",
"."
] | 7ab7e8548b41118fe361c8ee0c0ba687492f5184 | https://github.com/UseMuffin/Crypt/blob/7ab7e8548b41118fe361c8ee0c0ba687492f5184/src/Model/Behavior/CryptBehavior.php#L149-L156 | train |
UseMuffin/Crypt | src/Model/Behavior/CryptBehavior.php | CryptBehavior._resolveStrategy | protected function _resolveStrategy($strategy)
{
$key = Security::salt();
if (!$strategy) {
$class = self::DEFAULT_STRATEGY;
$strategy = new $class($key);
}
if (is_string($strategy) && class_exists($strategy)) {
$strategy = new $strategy($key);
}
if (!($strategy instanceof StrategyInterface)) {
throw new Exception('Invalid "strategy" configuration.');
}
return $strategy;
} | php | protected function _resolveStrategy($strategy)
{
$key = Security::salt();
if (!$strategy) {
$class = self::DEFAULT_STRATEGY;
$strategy = new $class($key);
}
if (is_string($strategy) && class_exists($strategy)) {
$strategy = new $strategy($key);
}
if (!($strategy instanceof StrategyInterface)) {
throw new Exception('Invalid "strategy" configuration.');
}
return $strategy;
} | [
"protected",
"function",
"_resolveStrategy",
"(",
"$",
"strategy",
")",
"{",
"$",
"key",
"=",
"Security",
"::",
"salt",
"(",
")",
";",
"if",
"(",
"!",
"$",
"strategy",
")",
"{",
"$",
"class",
"=",
"self",
"::",
"DEFAULT_STRATEGY",
";",
"$",
"strategy",... | Resolves configured strategy.
@param string|\Muffin\Crypt\Model\Behavior\Strategy\StrategyInterface $strategy Strategy
@return mixed
@throws \Cake\Core\Exception\Exception | [
"Resolves",
"configured",
"strategy",
"."
] | 7ab7e8548b41118fe361c8ee0c0ba687492f5184 | https://github.com/UseMuffin/Crypt/blob/7ab7e8548b41118fe361c8ee0c0ba687492f5184/src/Model/Behavior/CryptBehavior.php#L175-L193 | train |
UseMuffin/Crypt | src/Model/Behavior/CryptBehavior.php | CryptBehavior._resolveFields | protected function _resolveFields($fields)
{
if (is_string($fields)) {
$fields = [$fields];
}
if (!is_array($fields)) {
throw new Exception('Invalid "fields" configuration.');
}
$types = array_keys(Type::map());
foreach ($fields as $field => $type) {
if (is_numeric($field) && is_string($type)) {
unset($fields[$field]);
$field = $type;
$type = self::DEFAULT_TYPE;
$fields[$field] = $type;
}
if (!in_array($type, $types)) {
throw new Exception(sprintf('The field "%s" mapped type "%s" was not found.', $field, $type));
}
}
return $fields;
} | php | protected function _resolveFields($fields)
{
if (is_string($fields)) {
$fields = [$fields];
}
if (!is_array($fields)) {
throw new Exception('Invalid "fields" configuration.');
}
$types = array_keys(Type::map());
foreach ($fields as $field => $type) {
if (is_numeric($field) && is_string($type)) {
unset($fields[$field]);
$field = $type;
$type = self::DEFAULT_TYPE;
$fields[$field] = $type;
}
if (!in_array($type, $types)) {
throw new Exception(sprintf('The field "%s" mapped type "%s" was not found.', $field, $type));
}
}
return $fields;
} | [
"protected",
"function",
"_resolveFields",
"(",
"$",
"fields",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"fields",
"=",
"[",
"$",
"fields",
"]",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"fields",
")",
")",
"... | Resolves configured fields.
@param string|array $fields Fields to resolve.
@return array
@throws \Cake\Core\Exception\Exception | [
"Resolves",
"configured",
"fields",
"."
] | 7ab7e8548b41118fe361c8ee0c0ba687492f5184 | https://github.com/UseMuffin/Crypt/blob/7ab7e8548b41118fe361c8ee0c0ba687492f5184/src/Model/Behavior/CryptBehavior.php#L202-L228 | train |
inc2734/wp-oembed-blog-card | src/App/Model/Parser.php | Parser._get_title | protected function _get_title( $content ) {
preg_match( '/<meta +?property=["\']og:title["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
preg_match( '/<title>([^"\']+?)<\/title>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
} | php | protected function _get_title( $content ) {
preg_match( '/<meta +?property=["\']og:title["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
preg_match( '/<title>([^"\']+?)<\/title>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
} | [
"protected",
"function",
"_get_title",
"(",
"$",
"content",
")",
"{",
"preg_match",
"(",
"'/<meta +?property=[\"\\']og:title[\"\\'][^\\/>]*? content=[\"\\']([^\"\\']+?)[\"\\'].*?\\/?>/si'",
",",
"$",
"content",
",",
"$",
"reg",
")",
";",
"if",
"(",
"!",
"empty",
"(",
... | Return page title of the page you want to blog card
@param string $content
@return string | [
"Return",
"page",
"title",
"of",
"the",
"page",
"you",
"want",
"to",
"blog",
"card"
] | 4882994152f9003db9c68517a53090cbef13ff4d | https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/Model/Parser.php#L117-L127 | train |
inc2734/wp-oembed-blog-card | src/App/Model/Parser.php | Parser._get_permalink | protected function _get_permalink( $content ) {
preg_match( '/<meta +?property=["\']og:url["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
return $this->url;
} | php | protected function _get_permalink( $content ) {
preg_match( '/<meta +?property=["\']og:url["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
return $this->url;
} | [
"protected",
"function",
"_get_permalink",
"(",
"$",
"content",
")",
"{",
"preg_match",
"(",
"'/<meta +?property=[\"\\']og:url[\"\\'][^\\/>]*? content=[\"\\']([^\"\\']+?)[\"\\'].*?\\/?>/si'",
",",
"$",
"content",
",",
"$",
"reg",
")",
";",
"if",
"(",
"!",
"empty",
"(",
... | Return URL of the page you want to blog card
@param string $content
@return string | [
"Return",
"URL",
"of",
"the",
"page",
"you",
"want",
"to",
"blog",
"card"
] | 4882994152f9003db9c68517a53090cbef13ff4d | https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/Model/Parser.php#L135-L142 | train |
inc2734/wp-oembed-blog-card | src/App/Model/Parser.php | Parser._get_description | protected function _get_description( $content ) {
preg_match( '/<meta +?property=["\']og:description["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
preg_match( '/<meta +?name=["\']description["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
} | php | protected function _get_description( $content ) {
preg_match( '/<meta +?property=["\']og:description["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
preg_match( '/<meta +?name=["\']description["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
} | [
"protected",
"function",
"_get_description",
"(",
"$",
"content",
")",
"{",
"preg_match",
"(",
"'/<meta +?property=[\"\\']og:description[\"\\'][^\\/>]*? content=[\"\\']([^\"\\']+?)[\"\\'].*?\\/?>/si'",
",",
"$",
"content",
",",
"$",
"reg",
")",
";",
"if",
"(",
"!",
"empty... | Return page description of the page you want to blog card
@param string $content
@return string | [
"Return",
"page",
"description",
"of",
"the",
"page",
"you",
"want",
"to",
"blog",
"card"
] | 4882994152f9003db9c68517a53090cbef13ff4d | https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/Model/Parser.php#L150-L160 | train |
inc2734/wp-oembed-blog-card | src/App/Model/Parser.php | Parser._get_domain | protected function _get_domain( $content ) {
$permalink = $this->get_permalink();
if ( ! $permalink ) {
$permalink = $this->_get_permalink( $content );
}
preg_match( '/https?:\/\/([^\/]+)/', $permalink, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
} | php | protected function _get_domain( $content ) {
$permalink = $this->get_permalink();
if ( ! $permalink ) {
$permalink = $this->_get_permalink( $content );
}
preg_match( '/https?:\/\/([^\/]+)/', $permalink, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
}
} | [
"protected",
"function",
"_get_domain",
"(",
"$",
"content",
")",
"{",
"$",
"permalink",
"=",
"$",
"this",
"->",
"get_permalink",
"(",
")",
";",
"if",
"(",
"!",
"$",
"permalink",
")",
"{",
"$",
"permalink",
"=",
"$",
"this",
"->",
"_get_permalink",
"("... | Return domain of the page you want to blog card
@param string $content
@return string | [
"Return",
"domain",
"of",
"the",
"page",
"you",
"want",
"to",
"blog",
"card"
] | 4882994152f9003db9c68517a53090cbef13ff4d | https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/Model/Parser.php#L168-L178 | train |
inc2734/wp-oembed-blog-card | src/App/Model/Parser.php | Parser._get_favicon | protected function _get_favicon( $content ) {
preg_match( '/<link +?rel=["\']shortcut icon["\'][^\/>]*? href=["\']([^"\']+?)["\'][^\/>]*?\/?>/si', $content, $reg );
if ( empty( $reg[1] ) ) {
preg_match( '/<link +?rel=["\']icon["\'][^\/>]*? href=["\']([^"\']+?)["\'][^\/>]*?\/?>/si', $content, $reg );
}
if ( empty( $reg[1] ) ) {
return;
}
$favicon = $reg[1];
$favicon = $this->_relative_path_to_url( $favicon, $content );
if ( is_ssl() ) {
$favicon = preg_replace( '|^http:|', 'https:', $favicon );
}
$requester = new Requester( $favicon );
$response = $requester->request( $favicon );
if ( is_wp_error( $response ) ) {
return;
}
$status_code = $requester->get_status_code();
if ( 200 != $status_code && 304 != $status_code ) {
return;
}
return $favicon;
} | php | protected function _get_favicon( $content ) {
preg_match( '/<link +?rel=["\']shortcut icon["\'][^\/>]*? href=["\']([^"\']+?)["\'][^\/>]*?\/?>/si', $content, $reg );
if ( empty( $reg[1] ) ) {
preg_match( '/<link +?rel=["\']icon["\'][^\/>]*? href=["\']([^"\']+?)["\'][^\/>]*?\/?>/si', $content, $reg );
}
if ( empty( $reg[1] ) ) {
return;
}
$favicon = $reg[1];
$favicon = $this->_relative_path_to_url( $favicon, $content );
if ( is_ssl() ) {
$favicon = preg_replace( '|^http:|', 'https:', $favicon );
}
$requester = new Requester( $favicon );
$response = $requester->request( $favicon );
if ( is_wp_error( $response ) ) {
return;
}
$status_code = $requester->get_status_code();
if ( 200 != $status_code && 304 != $status_code ) {
return;
}
return $favicon;
} | [
"protected",
"function",
"_get_favicon",
"(",
"$",
"content",
")",
"{",
"preg_match",
"(",
"'/<link +?rel=[\"\\']shortcut icon[\"\\'][^\\/>]*? href=[\"\\']([^\"\\']+?)[\"\\'][^\\/>]*?\\/?>/si'",
",",
"$",
"content",
",",
"$",
"reg",
")",
";",
"if",
"(",
"empty",
"(",
"$... | Return favicon of the page you want to blog card
@param string $content
@return string | [
"Return",
"favicon",
"of",
"the",
"page",
"you",
"want",
"to",
"blog",
"card"
] | 4882994152f9003db9c68517a53090cbef13ff4d | https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/Model/Parser.php#L186-L215 | train |
inc2734/wp-oembed-blog-card | src/App/Model/Parser.php | Parser._get_thumbnail | protected function _get_thumbnail( $content ) {
preg_match( '/<meta +?property=["\']og:image["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( empty( $reg[1] ) ) {
return;
}
$thumbnail = $reg[1];
$thumbnail = $this->_relative_path_to_url( $thumbnail, $content );
if ( is_ssl() ) {
$thumbnail = preg_replace( '|^http:|', 'https:', $thumbnail );
}
$requester = new Requester( $thumbnail );
$response = $requester->request( $thumbnail );
if ( is_wp_error( $response ) ) {
return;
}
$status_code = $requester->get_status_code();
if ( 200 != $status_code && 304 != $status_code ) {
return;
}
return $thumbnail;
} | php | protected function _get_thumbnail( $content ) {
preg_match( '/<meta +?property=["\']og:image["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( empty( $reg[1] ) ) {
return;
}
$thumbnail = $reg[1];
$thumbnail = $this->_relative_path_to_url( $thumbnail, $content );
if ( is_ssl() ) {
$thumbnail = preg_replace( '|^http:|', 'https:', $thumbnail );
}
$requester = new Requester( $thumbnail );
$response = $requester->request( $thumbnail );
if ( is_wp_error( $response ) ) {
return;
}
$status_code = $requester->get_status_code();
if ( 200 != $status_code && 304 != $status_code ) {
return;
}
return $thumbnail;
} | [
"protected",
"function",
"_get_thumbnail",
"(",
"$",
"content",
")",
"{",
"preg_match",
"(",
"'/<meta +?property=[\"\\']og:image[\"\\'][^\\/>]*? content=[\"\\']([^\"\\']+?)[\"\\'].*?\\/?>/si'",
",",
"$",
"content",
",",
"$",
"reg",
")",
";",
"if",
"(",
"empty",
"(",
"$"... | Return thumbnail of the page you want to blog card
@param string $content
@return string | [
"Return",
"thumbnail",
"of",
"the",
"page",
"you",
"want",
"to",
"blog",
"card"
] | 4882994152f9003db9c68517a53090cbef13ff4d | https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/Model/Parser.php#L223-L248 | train |
inc2734/wp-oembed-blog-card | src/App/Model/Parser.php | Parser._relative_path_to_url | protected function _relative_path_to_url( $path, $content ) {
if ( wp_http_validate_url( $path ) ) {
return $path;
}
$permalink = $this->get_permalink();
if ( ! $permalink ) {
$permalink = $this->_get_permalink( $content );
}
preg_match( '/(https?:\/\/[^\/]+)/', $permalink, $reg );
if ( empty( $reg[0] ) ) {
return false;
}
return trailingslashit( $reg[0] ) . $path;
} | php | protected function _relative_path_to_url( $path, $content ) {
if ( wp_http_validate_url( $path ) ) {
return $path;
}
$permalink = $this->get_permalink();
if ( ! $permalink ) {
$permalink = $this->_get_permalink( $content );
}
preg_match( '/(https?:\/\/[^\/]+)/', $permalink, $reg );
if ( empty( $reg[0] ) ) {
return false;
}
return trailingslashit( $reg[0] ) . $path;
} | [
"protected",
"function",
"_relative_path_to_url",
"(",
"$",
"path",
",",
"$",
"content",
")",
"{",
"if",
"(",
"wp_http_validate_url",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"$",
"permalink",
"=",
"$",
"this",
"->",
"get_permali... | Return url that converted from relative path
@param string $path
@param string $content
@return string | [
"Return",
"url",
"that",
"converted",
"from",
"relative",
"path"
] | 4882994152f9003db9c68517a53090cbef13ff4d | https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/Model/Parser.php#L257-L273 | train |
video-games-records/CoreBundle | Repository/GameRepository.php | GameRepository.findWithLetter | public function findWithLetter($letter, $locale)
{
$query = $this->createQueryBuilder('g')
->addSelect('translation');
if ($letter === '0') {
$query
->innerJoin('g.translations', 'translation')
->where('SUBSTRING(translation.name , 1, 1) NOT IN (:list)')
->setParameter('list', range('a', 'z'));
} else {
$query
->innerJoin('g.translations', 'translation')
->where('SUBSTRING(translation.name , 1, 1) = :letter')
->setParameter('letter', $letter);
}
$query
->andWhere('translation.locale = :locale')
->setParameter('locale', $locale)
->orderBy('translation.name', 'ASC');
$this->onlyActive($query);
$this->withPlatforms($query);
return $query->getQuery();
} | php | public function findWithLetter($letter, $locale)
{
$query = $this->createQueryBuilder('g')
->addSelect('translation');
if ($letter === '0') {
$query
->innerJoin('g.translations', 'translation')
->where('SUBSTRING(translation.name , 1, 1) NOT IN (:list)')
->setParameter('list', range('a', 'z'));
} else {
$query
->innerJoin('g.translations', 'translation')
->where('SUBSTRING(translation.name , 1, 1) = :letter')
->setParameter('letter', $letter);
}
$query
->andWhere('translation.locale = :locale')
->setParameter('locale', $locale)
->orderBy('translation.name', 'ASC');
$this->onlyActive($query);
$this->withPlatforms($query);
return $query->getQuery();
} | [
"public",
"function",
"findWithLetter",
"(",
"$",
"letter",
",",
"$",
"locale",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'g'",
")",
"->",
"addSelect",
"(",
"'translation'",
")",
";",
"if",
"(",
"$",
"letter",
"===",
"... | Finds games begining with a letter.
@param string $letter
@param string $locale
@return \Doctrine\ORM\Query | [
"Finds",
"games",
"begining",
"with",
"a",
"letter",
"."
] | 64fc8fbc8217f4593b26223168463bfbe8f3fd61 | https://github.com/video-games-records/CoreBundle/blob/64fc8fbc8217f4593b26223168463bfbe8f3fd61/Repository/GameRepository.php#L19-L43 | train |
video-games-records/CoreBundle | Repository/GameRepository.php | GameRepository.findSerieGames | public function findSerieGames($idSerie)
{
$query = $this->createQueryBuilder('g');
$query
->where('g.idSerie = :idSerie')
->setParameter('idSerie', $idSerie);
$this->onlyActive($query);
$this->withPlatforms($query);
return $query->getQuery()->getResult();
} | php | public function findSerieGames($idSerie)
{
$query = $this->createQueryBuilder('g');
$query
->where('g.idSerie = :idSerie')
->setParameter('idSerie', $idSerie);
$this->onlyActive($query);
$this->withPlatforms($query);
return $query->getQuery()->getResult();
} | [
"public",
"function",
"findSerieGames",
"(",
"$",
"idSerie",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'g'",
")",
";",
"$",
"query",
"->",
"where",
"(",
"'g.idSerie = :idSerie'",
")",
"->",
"setParameter",
"(",
"'idSerie'",
... | Finds games in the given series.
@param int $idSerie
@return array | [
"Finds",
"games",
"in",
"the",
"given",
"series",
"."
] | 64fc8fbc8217f4593b26223168463bfbe8f3fd61 | https://github.com/video-games-records/CoreBundle/blob/64fc8fbc8217f4593b26223168463bfbe8f3fd61/Repository/GameRepository.php#L51-L62 | train |
netgen-layouts/layouts-sylius | bundle/Templating/Twig/Runtime/SyliusRuntime.php | SyliusRuntime.getProductName | public function getProductName($productId): ?string
{
$product = $this->productRepository->find($productId);
if (!$product instanceof ProductInterface) {
return null;
}
return $product->getName();
} | php | public function getProductName($productId): ?string
{
$product = $this->productRepository->find($productId);
if (!$product instanceof ProductInterface) {
return null;
}
return $product->getName();
} | [
"public",
"function",
"getProductName",
"(",
"$",
"productId",
")",
":",
"?",
"string",
"{",
"$",
"product",
"=",
"$",
"this",
"->",
"productRepository",
"->",
"find",
"(",
"$",
"productId",
")",
";",
"if",
"(",
"!",
"$",
"product",
"instanceof",
"Produc... | Returns the product name.
@param int|string $productId
@return string|null | [
"Returns",
"the",
"product",
"name",
"."
] | a261f1b312cc7e18ac48e2c5ff19775672f60947 | https://github.com/netgen-layouts/layouts-sylius/blob/a261f1b312cc7e18ac48e2c5ff19775672f60947/bundle/Templating/Twig/Runtime/SyliusRuntime.php#L39-L47 | train |
netgen-layouts/layouts-sylius | bundle/Templating/Twig/Runtime/SyliusRuntime.php | SyliusRuntime.getTaxonPath | public function getTaxonPath($taxonId): ?array
{
$taxon = $this->taxonRepository->find($taxonId);
if (!$taxon instanceof TaxonInterface) {
return null;
}
$parts = [$taxon->getName()];
while ($taxon->getParent() instanceof TaxonInterface) {
$taxon = $taxon->getParent();
$parts[] = $taxon->getName();
}
return array_reverse($parts);
} | php | public function getTaxonPath($taxonId): ?array
{
$taxon = $this->taxonRepository->find($taxonId);
if (!$taxon instanceof TaxonInterface) {
return null;
}
$parts = [$taxon->getName()];
while ($taxon->getParent() instanceof TaxonInterface) {
$taxon = $taxon->getParent();
$parts[] = $taxon->getName();
}
return array_reverse($parts);
} | [
"public",
"function",
"getTaxonPath",
"(",
"$",
"taxonId",
")",
":",
"?",
"array",
"{",
"$",
"taxon",
"=",
"$",
"this",
"->",
"taxonRepository",
"->",
"find",
"(",
"$",
"taxonId",
")",
";",
"if",
"(",
"!",
"$",
"taxon",
"instanceof",
"TaxonInterface",
... | Returns the taxon path.
@param int|string $taxonId
@return array<string|null>|null | [
"Returns",
"the",
"taxon",
"path",
"."
] | a261f1b312cc7e18ac48e2c5ff19775672f60947 | https://github.com/netgen-layouts/layouts-sylius/blob/a261f1b312cc7e18ac48e2c5ff19775672f60947/bundle/Templating/Twig/Runtime/SyliusRuntime.php#L56-L71 | train |
ansas/php-component | src/Util/Debug.php | Debug.separator | public static function separator($char = '=', $repeat = 50)
{
if (self::isCli()) {
echo str_repeat($char, $repeat) . "\n";
} else {
echo "<div class=\"debug-separator\">" . str_repeat($char, $repeat) . "</div>\n";
}
} | php | public static function separator($char = '=', $repeat = 50)
{
if (self::isCli()) {
echo str_repeat($char, $repeat) . "\n";
} else {
echo "<div class=\"debug-separator\">" . str_repeat($char, $repeat) . "</div>\n";
}
} | [
"public",
"static",
"function",
"separator",
"(",
"$",
"char",
"=",
"'='",
",",
"$",
"repeat",
"=",
"50",
")",
"{",
"if",
"(",
"self",
"::",
"isCli",
"(",
")",
")",
"{",
"echo",
"str_repeat",
"(",
"$",
"char",
",",
"$",
"repeat",
")",
".",
"\"\\n... | Print separator.
@param string $char
@param int $repeat | [
"Print",
"separator",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Debug.php#L72-L79 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent.export | public function export($id = null, $type = 'docx') {
$type = mb_strtolower($type);
if (!empty($type) && !$this->_controller->RequestHandler->prefers($type)) {
throw new BadRequestException(__d('view_extension', 'Invalid request'));
}
if (!method_exists($this->_model, 'generateExportFile') || !method_exists($this->_model, 'getExportFilename')) {
throw new InternalErrorException(__d('view_extension', 'Export method not found'));
}
$tempFile = $this->_model->generateExportFile($id);
if (empty($tempFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid generated file'));
}
$exportFile = pathinfo($tempFile, PATHINFO_FILENAME);
return $this->download($id, $exportFile);
} | php | public function export($id = null, $type = 'docx') {
$type = mb_strtolower($type);
if (!empty($type) && !$this->_controller->RequestHandler->prefers($type)) {
throw new BadRequestException(__d('view_extension', 'Invalid request'));
}
if (!method_exists($this->_model, 'generateExportFile') || !method_exists($this->_model, 'getExportFilename')) {
throw new InternalErrorException(__d('view_extension', 'Export method not found'));
}
$tempFile = $this->_model->generateExportFile($id);
if (empty($tempFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid generated file'));
}
$exportFile = pathinfo($tempFile, PATHINFO_FILENAME);
return $this->download($id, $exportFile);
} | [
"public",
"function",
"export",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"type",
"=",
"'docx'",
")",
"{",
"$",
"type",
"=",
"mb_strtolower",
"(",
"$",
"type",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"type",
")",
"&&",
"!",
"$",
"this",
"->",... | Export file from server
@param int|string $id ID for exported data.
@param string $type Extension of exported file.
@throws BadRequestException if not empty $type and extension of
requested file is not equal $type.
@throws InternalErrorException if method Model::generateExportFile() is
not exists.
@throws InternalErrorException if empty result of call method Model::generateExportFile().
@return object Return response object of exported file. | [
"Export",
"file",
"from",
"server"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L168-L186 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent.preview | public function preview($id = null) {
if (!method_exists($this->_model, 'generateExportFile')) {
throw new InternalErrorException(__d(
'view_extension',
'Method "%s" is not exists in model "%s"',
'generateExportFile()',
$this->_model->name
));
}
if (!method_exists($this->_model, 'getExportFilename')) {
throw new InternalErrorException(__d(
'view_extension',
'Method "%s" is not exists in model "%s"',
'getExportFilename()',
$this->_model->name
));
}
$tempFile = $this->_model->generateExportFile($id);
if (empty($tempFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid generated file'));
}
$previewFile = $tempFile;
$exportPath = $this->_getExportDir();
$pdfTempFile = $exportPath . uniqid() . '.pdf';
if ($this->_convertFileToPdf($tempFile, $pdfTempFile)) {
$previewFile = $pdfTempFile;
}
$exportFileName = $this->_model->getExportFilename($id, false);
$preview = $this->_createImgPreview($previewFile);
$orig = pathinfo($tempFile, PATHINFO_FILENAME);
$pdf = null;
if (!empty($pdfTempFile)) {
$pdf = pathinfo($pdfTempFile, PATHINFO_FILENAME);
}
$download = compact('orig', 'pdf');
$result = compact('exportFileName', 'preview', 'download');
return $result;
} | php | public function preview($id = null) {
if (!method_exists($this->_model, 'generateExportFile')) {
throw new InternalErrorException(__d(
'view_extension',
'Method "%s" is not exists in model "%s"',
'generateExportFile()',
$this->_model->name
));
}
if (!method_exists($this->_model, 'getExportFilename')) {
throw new InternalErrorException(__d(
'view_extension',
'Method "%s" is not exists in model "%s"',
'getExportFilename()',
$this->_model->name
));
}
$tempFile = $this->_model->generateExportFile($id);
if (empty($tempFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid generated file'));
}
$previewFile = $tempFile;
$exportPath = $this->_getExportDir();
$pdfTempFile = $exportPath . uniqid() . '.pdf';
if ($this->_convertFileToPdf($tempFile, $pdfTempFile)) {
$previewFile = $pdfTempFile;
}
$exportFileName = $this->_model->getExportFilename($id, false);
$preview = $this->_createImgPreview($previewFile);
$orig = pathinfo($tempFile, PATHINFO_FILENAME);
$pdf = null;
if (!empty($pdfTempFile)) {
$pdf = pathinfo($pdfTempFile, PATHINFO_FILENAME);
}
$download = compact('orig', 'pdf');
$result = compact('exportFileName', 'preview', 'download');
return $result;
} | [
"public",
"function",
"preview",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"_model",
",",
"'generateExportFile'",
")",
")",
"{",
"throw",
"new",
"InternalErrorException",
"(",
"__d",
"(",
"'view_extensi... | Generate preview images of exported file
@param int|string $id ID for exported data.
@throws InternalErrorException if method Model::generateExportFile() is
not exists.
@throws InternalErrorException if empty result of call method Model::generateExportFile().
@throws InternalErrorException if the exported file is not converted into the PDF file.
@return array Return array of information for preview exported file. Format:
- key `exportFileName`; value - name of preview file;
- key `preview` - array of preview images; value - relative path to preview images.
- key `download` - array of files for downloading; value:
- key `orig`; value - file name of original file;
- key `pdf`; value - file name of PDF preview file. | [
"Generate",
"preview",
"images",
"of",
"exported",
"file"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L203-L245 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent._convertFileToPdf | protected function _convertFileToPdf($inputFile = null, $outputFile = null) {
$cfgUnoconv = $this->_getUnoconvConfig();
if ($cfgUnoconv === false) {
throw new InternalErrorException(__d('view_extension', 'Unoconv is not configured'));
}
if (!file_exists($inputFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid input file for converting to PDF'));
}
if (empty($outputFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid output file for converting to PDF'));
}
if (mime_content_type($inputFile) === 'application/pdf') {
return false;
}
extract($cfgUnoconv);
if ($timeout <= 0) {
$timeout = 60;
}
$unoconvOpt = [
'timeout' => $timeout,
'unoconv.binaries' => $binaries,
];
$unoconv = Unoconv\Unoconv::create($unoconvOpt);
$unoconv->transcode($inputFile, 'pdf', $outputFile);
if (!file_exists($outputFile)) {
throw new InternalErrorException(__d('view_extension', 'Error on creation PDF file'));
}
return true;
} | php | protected function _convertFileToPdf($inputFile = null, $outputFile = null) {
$cfgUnoconv = $this->_getUnoconvConfig();
if ($cfgUnoconv === false) {
throw new InternalErrorException(__d('view_extension', 'Unoconv is not configured'));
}
if (!file_exists($inputFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid input file for converting to PDF'));
}
if (empty($outputFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid output file for converting to PDF'));
}
if (mime_content_type($inputFile) === 'application/pdf') {
return false;
}
extract($cfgUnoconv);
if ($timeout <= 0) {
$timeout = 60;
}
$unoconvOpt = [
'timeout' => $timeout,
'unoconv.binaries' => $binaries,
];
$unoconv = Unoconv\Unoconv::create($unoconvOpt);
$unoconv->transcode($inputFile, 'pdf', $outputFile);
if (!file_exists($outputFile)) {
throw new InternalErrorException(__d('view_extension', 'Error on creation PDF file'));
}
return true;
} | [
"protected",
"function",
"_convertFileToPdf",
"(",
"$",
"inputFile",
"=",
"null",
",",
"$",
"outputFile",
"=",
"null",
")",
"{",
"$",
"cfgUnoconv",
"=",
"$",
"this",
"->",
"_getUnoconvConfig",
"(",
")",
";",
"if",
"(",
"$",
"cfgUnoconv",
"===",
"false",
... | Converting input file into PDf file
@param string $inputFile Input file for converting.
@param string $outputFile Output file of converting.
@throws InternalErrorException if Unoconv is not configured.
@throws InternalErrorException if input file is
not exists.
@throws InternalErrorException if empty path to output file.
@throws InternalErrorException if PDF file is not created.
@return bool Return True, if input file is successfully converted
into PDF file. False otherwise. | [
"Converting",
"input",
"file",
"into",
"PDf",
"file"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L260-L293 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent._createImgPreview | protected function _createImgPreview($inputFile = null) {
$result = [];
if (empty($inputFile) || !file_exists($inputFile)) {
return $result;
}
$previewFullPath = $this->_getPreviewDir();
$wwwRoot = Configure::read('App.www_root');
if (empty($wwwRoot)) {
throw new InternalErrorException(__d('view_extension', 'Invalid path to "www_root" directory'));
}
$wwwRootPos = mb_stripos($previewFullPath, $wwwRoot);
if ($wwwRootPos !== 0) {
throw new InternalErrorException(__d('view_extension', 'Path to preview directory is not contain path to "www_root" directory'));
}
$previewWebRootPath = mb_substr($previewFullPath, mb_strlen($wwwRoot) - 1);
if (empty($previewWebRootPath)) {
throw new InternalErrorException(__d('view_extension', 'Invalid path to preview directory'));
}
$jpgTempFile = uniqid();
$im = new Imagick();
$im->setResolution(150, 150);
if (!$im->readimage($inputFile)) {
$im->clear();
$im->destroy();
return $result;
}
$numPages = $im->getNumberImages();
for ($page = 0; $page < $numPages; $page++) {
$postfix = '[' . $page . ']';
$previewFile = $jpgTempFile . $postfix . '.jpg';
if (!$im->readimage($inputFile . $postfix)) {
continue;
}
$im->setImageFormat('jpeg');
$im->setImageCompressionQuality(90);
if ($im->writeImage($previewFullPath . $previewFile)) {
$result[] = $previewWebRootPath . $previewFile;
}
}
$im->clear();
$im->destroy();
if (!empty($result) && (DIRECTORY_SEPARATOR === '\\')) {
foreach ($result as &$resultItem) {
$resultItem = mb_ereg_replace('\\\\', '/', $resultItem);
}
}
return $result;
} | php | protected function _createImgPreview($inputFile = null) {
$result = [];
if (empty($inputFile) || !file_exists($inputFile)) {
return $result;
}
$previewFullPath = $this->_getPreviewDir();
$wwwRoot = Configure::read('App.www_root');
if (empty($wwwRoot)) {
throw new InternalErrorException(__d('view_extension', 'Invalid path to "www_root" directory'));
}
$wwwRootPos = mb_stripos($previewFullPath, $wwwRoot);
if ($wwwRootPos !== 0) {
throw new InternalErrorException(__d('view_extension', 'Path to preview directory is not contain path to "www_root" directory'));
}
$previewWebRootPath = mb_substr($previewFullPath, mb_strlen($wwwRoot) - 1);
if (empty($previewWebRootPath)) {
throw new InternalErrorException(__d('view_extension', 'Invalid path to preview directory'));
}
$jpgTempFile = uniqid();
$im = new Imagick();
$im->setResolution(150, 150);
if (!$im->readimage($inputFile)) {
$im->clear();
$im->destroy();
return $result;
}
$numPages = $im->getNumberImages();
for ($page = 0; $page < $numPages; $page++) {
$postfix = '[' . $page . ']';
$previewFile = $jpgTempFile . $postfix . '.jpg';
if (!$im->readimage($inputFile . $postfix)) {
continue;
}
$im->setImageFormat('jpeg');
$im->setImageCompressionQuality(90);
if ($im->writeImage($previewFullPath . $previewFile)) {
$result[] = $previewWebRootPath . $previewFile;
}
}
$im->clear();
$im->destroy();
if (!empty($result) && (DIRECTORY_SEPARATOR === '\\')) {
foreach ($result as &$resultItem) {
$resultItem = mb_ereg_replace('\\\\', '/', $resultItem);
}
}
return $result;
} | [
"protected",
"function",
"_createImgPreview",
"(",
"$",
"inputFile",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"inputFile",
")",
"||",
"!",
"file_exists",
"(",
"$",
"inputFile",
")",
")",
"{",
"return",
"... | Creating images of every page for preview file
@param string $inputFile Input file for creating images.
@throws InternalErrorException if empty path to www_root folder.
@throws InternalErrorException if Path to preview folder is not
contain path to www_root folder.
@throws InternalErrorException if empty path to preview folder.
@return array Return array of relative path to preview images of pages. | [
"Creating",
"images",
"of",
"every",
"page",
"for",
"preview",
"file"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L305-L361 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent._setExportDir | protected function _setExportDir($path = null) {
$path = (string)$path;
if (file_exists($path)) {
$this->_pathExportDir = $path;
}
} | php | protected function _setExportDir($path = null) {
$path = (string)$path;
if (file_exists($path)) {
$this->_pathExportDir = $path;
}
} | [
"protected",
"function",
"_setExportDir",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"(",
"string",
")",
"$",
"path",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"_pathExportDir",
"=",
"$",
"pa... | Set path to export directory
@param string $path Path to export directory
@return void | [
"Set",
"path",
"to",
"export",
"directory"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L369-L374 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent._setPreviewDir | protected function _setPreviewDir($path = null) {
$path = (string)$path;
if (file_exists($path)) {
$this->_pathPreviewDir = $path;
}
} | php | protected function _setPreviewDir($path = null) {
$path = (string)$path;
if (file_exists($path)) {
$this->_pathPreviewDir = $path;
}
} | [
"protected",
"function",
"_setPreviewDir",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"(",
"string",
")",
"$",
"path",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"_pathPreviewDir",
"=",
"$",
"... | Set path to preview directory
@param string $path Path to preview derictory
@return void | [
"Set",
"path",
"to",
"preview",
"directory"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L391-L396 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent._setStorageTimeExport | protected function _setStorageTimeExport($time = null) {
$time = (int)$time;
if ($time > 0) {
$this->_storageTimeExport = $time;
}
} | php | protected function _setStorageTimeExport($time = null) {
$time = (int)$time;
if ($time > 0) {
$this->_storageTimeExport = $time;
}
} | [
"protected",
"function",
"_setStorageTimeExport",
"(",
"$",
"time",
"=",
"null",
")",
"{",
"$",
"time",
"=",
"(",
"int",
")",
"$",
"time",
";",
"if",
"(",
"$",
"time",
">",
"0",
")",
"{",
"$",
"this",
"->",
"_storageTimeExport",
"=",
"$",
"time",
"... | Set time for storage old exported files
@param int $time Time limit in seconds for storage exported file.
@return void | [
"Set",
"time",
"for",
"storage",
"old",
"exported",
"files"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L413-L418 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent._setStorageTimePreview | protected function _setStorageTimePreview($time = null) {
$time = (int)$time;
if ($time > 0) {
$this->_storageTimePreview = $time;
}
} | php | protected function _setStorageTimePreview($time = null) {
$time = (int)$time;
if ($time > 0) {
$this->_storageTimePreview = $time;
}
} | [
"protected",
"function",
"_setStorageTimePreview",
"(",
"$",
"time",
"=",
"null",
")",
"{",
"$",
"time",
"=",
"(",
"int",
")",
"$",
"time",
";",
"if",
"(",
"$",
"time",
">",
"0",
")",
"{",
"$",
"this",
"->",
"_storageTimePreview",
"=",
"$",
"time",
... | Set time for storage old preview files
@param int $time limit in seconds for storage preview file.
@return void | [
"Set",
"time",
"for",
"storage",
"old",
"preview",
"files"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L435-L440 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent.download | public function download($id = null, $file = null) {
$type = $this->_controller->RequestHandler->prefers();
$exportFileName = null;
if (method_exists($this->_model, 'getExportFilename')) {
$exportFileName = $this->_model->getExportFilename($id, true);
}
$exportPath = $this->_getExportDir();
$downloadFile = $exportPath . $file;
if (!empty($type)) {
$downloadFile .= '.' . $type;
}
if (!file_exists($downloadFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid file for downloading'));
}
if (!empty($type) && !empty($exportFileName)) {
$this->_controller->response->type($type);
$exportFileName .= '.' . $type;
}
$responseOpt = [
'download' => true,
];
if (!empty($exportFileName)) {
if ($this->_controller->request->is('msie')) {
$exportFileName = rawurlencode($exportFileName);
}
$responseOpt['name'] = $exportFileName;
}
$this->_controller->response->file($downloadFile, $responseOpt);
return $this->_controller->response;
} | php | public function download($id = null, $file = null) {
$type = $this->_controller->RequestHandler->prefers();
$exportFileName = null;
if (method_exists($this->_model, 'getExportFilename')) {
$exportFileName = $this->_model->getExportFilename($id, true);
}
$exportPath = $this->_getExportDir();
$downloadFile = $exportPath . $file;
if (!empty($type)) {
$downloadFile .= '.' . $type;
}
if (!file_exists($downloadFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid file for downloading'));
}
if (!empty($type) && !empty($exportFileName)) {
$this->_controller->response->type($type);
$exportFileName .= '.' . $type;
}
$responseOpt = [
'download' => true,
];
if (!empty($exportFileName)) {
if ($this->_controller->request->is('msie')) {
$exportFileName = rawurlencode($exportFileName);
}
$responseOpt['name'] = $exportFileName;
}
$this->_controller->response->file($downloadFile, $responseOpt);
return $this->_controller->response;
} | [
"public",
"function",
"download",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"file",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"_controller",
"->",
"RequestHandler",
"->",
"prefers",
"(",
")",
";",
"$",
"exportFileName",
"=",
"null",
";... | Downloading preview file
@param int|string $id ID for downloaded data.
@param string $file File name of downloaded file.
@throws InternalErrorException if downloaded is not exists.
@return CakeRequest Return CakeRequest object for download request. | [
"Downloading",
"preview",
"file"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L459-L492 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent._clearDir | protected function _clearDir($type = null, $timeNow = null) {
switch (mb_strtolower($type)) {
case 'export':
$clearPath = $this->_getExportDir();
$storageTime = $this->_getStorageTimeExport();
break;
case 'preview':
$clearPath = $this->_getPreviewDir();
$storageTime = $this->_getStorageTimePreview();
break;
default:
return false;
}
$result = true;
$oFolder = new Folder($clearPath, true);
$exportFiles = $oFolder->find('.*', false);
if (empty($exportFiles)) {
return $result;
}
if (!empty($timeNow)) {
$timeNow = (int)$timeNow;
} else {
$timeNow = time();
}
$exportFilesPath = $oFolder->pwd();
foreach ($exportFiles as $exportFile) {
$oFile = new File($exportFilesPath . DS . $exportFile);
$lastChangeTime = $oFile->lastChange();
if ($lastChangeTime === false) {
continue;
}
if (($timeNow - $lastChangeTime) > $storageTime) {
if (!$oFile->delete()) {
$result = false;
}
}
}
return true;
} | php | protected function _clearDir($type = null, $timeNow = null) {
switch (mb_strtolower($type)) {
case 'export':
$clearPath = $this->_getExportDir();
$storageTime = $this->_getStorageTimeExport();
break;
case 'preview':
$clearPath = $this->_getPreviewDir();
$storageTime = $this->_getStorageTimePreview();
break;
default:
return false;
}
$result = true;
$oFolder = new Folder($clearPath, true);
$exportFiles = $oFolder->find('.*', false);
if (empty($exportFiles)) {
return $result;
}
if (!empty($timeNow)) {
$timeNow = (int)$timeNow;
} else {
$timeNow = time();
}
$exportFilesPath = $oFolder->pwd();
foreach ($exportFiles as $exportFile) {
$oFile = new File($exportFilesPath . DS . $exportFile);
$lastChangeTime = $oFile->lastChange();
if ($lastChangeTime === false) {
continue;
}
if (($timeNow - $lastChangeTime) > $storageTime) {
if (!$oFile->delete()) {
$result = false;
}
}
}
return true;
} | [
"protected",
"function",
"_clearDir",
"(",
"$",
"type",
"=",
"null",
",",
"$",
"timeNow",
"=",
"null",
")",
"{",
"switch",
"(",
"mb_strtolower",
"(",
"$",
"type",
")",
")",
"{",
"case",
"'export'",
":",
"$",
"clearPath",
"=",
"$",
"this",
"->",
"_get... | Cleanup the export directory from old files
@param string $type Type of target directory. One of:
- `export`;
- `preview`;
@param int $timeNow Timestamp of current date and time.
@return bool Success | [
"Cleanup",
"the",
"export",
"directory",
"from",
"old",
"files"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L503-L546 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent._getUnoconvConfig | protected function _getUnoconvConfig() {
$cfgUnoconv = $this->_modelConfigTheme->getUnoconvConfig();
if (empty($cfgUnoconv)) {
return false;
}
$timeout = (int)Hash::get($cfgUnoconv, 'timeout');
$binaries = (string)Hash::get($cfgUnoconv, 'binaries');
$result = compact('timeout', 'binaries');
return $result;
} | php | protected function _getUnoconvConfig() {
$cfgUnoconv = $this->_modelConfigTheme->getUnoconvConfig();
if (empty($cfgUnoconv)) {
return false;
}
$timeout = (int)Hash::get($cfgUnoconv, 'timeout');
$binaries = (string)Hash::get($cfgUnoconv, 'binaries');
$result = compact('timeout', 'binaries');
return $result;
} | [
"protected",
"function",
"_getUnoconvConfig",
"(",
")",
"{",
"$",
"cfgUnoconv",
"=",
"$",
"this",
"->",
"_modelConfigTheme",
"->",
"getUnoconvConfig",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"cfgUnoconv",
")",
")",
"{",
"return",
"false",
";",
"}",
... | Return configuration of Unoconv
@return array|bool Return array of Unoconv configuration,
or False on failure. | [
"Return",
"configuration",
"of",
"Unoconv"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L554-L566 | train |
anklimsk/cakephp-theme | Controller/Component/ExportComponent.php | ExportComponent.isUnoconvReady | public function isUnoconvReady() {
$cfgUnoconv = $this->_getUnoconvConfig();
if ($cfgUnoconv === false) {
return false;
}
if (!file_exists($cfgUnoconv['binaries'])) {
return false;
}
return true;
} | php | public function isUnoconvReady() {
$cfgUnoconv = $this->_getUnoconvConfig();
if ($cfgUnoconv === false) {
return false;
}
if (!file_exists($cfgUnoconv['binaries'])) {
return false;
}
return true;
} | [
"public",
"function",
"isUnoconvReady",
"(",
")",
"{",
"$",
"cfgUnoconv",
"=",
"$",
"this",
"->",
"_getUnoconvConfig",
"(",
")",
";",
"if",
"(",
"$",
"cfgUnoconv",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(... | Readiness check use the configuration Unoconv
@return bool Return True, if configuration Unoconv is ready.
False otherwise. | [
"Readiness",
"check",
"use",
"the",
"configuration",
"Unoconv"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ExportComponent.php#L574-L585 | train |
ansas/php-component | src/Slim/Handler/TwigHandlerTrait.php | TwigHandlerTrait.fetchTemplate | public function fetchTemplate(Request $request, $template)
{
if (!$this->view instanceof Twig) {
throw new Exception("Twig provider not registered.");
}
foreach ($this->settings['view']['global'] as $key => $map) {
$key = is_numeric($key) ? $map : $key;
switch ($key) {
case 'request':
$value = $request;
break;
default:
$value = isset($this->container[$key]) ? $this->container[$key] : null;
break;
}
$this->view->getEnvironment()->addGlobal($map, $value);
}
$result = $this->view->fetch(
$template . $this->settings['view']['extension'],
$this->data->all()
);
return $result;
} | php | public function fetchTemplate(Request $request, $template)
{
if (!$this->view instanceof Twig) {
throw new Exception("Twig provider not registered.");
}
foreach ($this->settings['view']['global'] as $key => $map) {
$key = is_numeric($key) ? $map : $key;
switch ($key) {
case 'request':
$value = $request;
break;
default:
$value = isset($this->container[$key]) ? $this->container[$key] : null;
break;
}
$this->view->getEnvironment()->addGlobal($map, $value);
}
$result = $this->view->fetch(
$template . $this->settings['view']['extension'],
$this->data->all()
);
return $result;
} | [
"public",
"function",
"fetchTemplate",
"(",
"Request",
"$",
"request",
",",
"$",
"template",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"view",
"instanceof",
"Twig",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Twig provider not registered.\"",
")",
";",... | Fetches template with previous set data.
@param Request $request
@param string $template The template to render
@return string
@throws Exception | [
"Fetches",
"template",
"with",
"previous",
"set",
"data",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Slim/Handler/TwigHandlerTrait.php#L44-L72 | train |
ansas/php-component | src/Slim/Handler/TwigHandlerTrait.php | TwigHandlerTrait.renderTemplate | public function renderTemplate(Request $request, Response $response, $template, $status = null)
{
$response->getBody()->write($this->fetchTemplate($request, $template));
if ($status) {
$response = $response->withStatus($status);
}
return $response;
} | php | public function renderTemplate(Request $request, Response $response, $template, $status = null)
{
$response->getBody()->write($this->fetchTemplate($request, $template));
if ($status) {
$response = $response->withStatus($status);
}
return $response;
} | [
"public",
"function",
"renderTemplate",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"$",
"template",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"write",
"(",
"$",
"this",
"->"... | Renders template with previous set data.
@param Request $request
@param Response $response
@param string $template The template to render
@param int $status [optional] Response status code
@return Response
@throws Exception | [
"Renders",
"template",
"with",
"previous",
"set",
"data",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Slim/Handler/TwigHandlerTrait.php#L85-L94 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/GateKeeper.php | GateKeeper.isAccessibleBy | public static function isAccessibleBy($document, $user)
{
$result = null;
switch (Convertor::baseClassName($user)) {
case 'User': //Admin
$result = true;
break;
case 'Customer': //Customer
$result = (self::getDocumentCompany($document) == self::getCustomerCompany($user));
break;
case 'Anonym': //Anonymous
$result = false;
break;
}
return $result;
} | php | public static function isAccessibleBy($document, $user)
{
$result = null;
switch (Convertor::baseClassName($user)) {
case 'User': //Admin
$result = true;
break;
case 'Customer': //Customer
$result = (self::getDocumentCompany($document) == self::getCustomerCompany($user));
break;
case 'Anonym': //Anonymous
$result = false;
break;
}
return $result;
} | [
"public",
"static",
"function",
"isAccessibleBy",
"(",
"$",
"document",
",",
"$",
"user",
")",
"{",
"$",
"result",
"=",
"null",
";",
"switch",
"(",
"Convertor",
"::",
"baseClassName",
"(",
"$",
"user",
")",
")",
"{",
"case",
"'User'",
":",
"//Admin",
"... | Is document accessible by user ?
@param \FlexiPeeHP\FlexiBeeRO $document FlexiBee documnet
@param Customer|User|\Ease\Anonym $user Current User
@return boolean | [
"Is",
"document",
"accessible",
"by",
"user",
"?"
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/GateKeeper.php#L29-L44 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/GateKeeper.php | GateKeeper.getDocumentCompany | public static function getDocumentCompany($document)
{
return $document->getDataValue('firma') ? \FlexiPeeHP\FlexiBeeRO::uncode(
$document->getDataValue('firma')) : null;
} | php | public static function getDocumentCompany($document)
{
return $document->getDataValue('firma') ? \FlexiPeeHP\FlexiBeeRO::uncode(
$document->getDataValue('firma')) : null;
} | [
"public",
"static",
"function",
"getDocumentCompany",
"(",
"$",
"document",
")",
"{",
"return",
"$",
"document",
"->",
"getDataValue",
"(",
"'firma'",
")",
"?",
"\\",
"FlexiPeeHP",
"\\",
"FlexiBeeRO",
"::",
"uncode",
"(",
"$",
"document",
"->",
"getDataValue",... | Get Company code for document
@param \FlexiPeeHP\FlexiBeeRO $document
@return string documnent code | [
"Get",
"Company",
"code",
"for",
"document"
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/GateKeeper.php#L53-L57 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/GateKeeper.php | GateKeeper.getCustomerCompany | public static function getCustomerCompany($customer)
{
return $customer->adresar->getDataValue('kod') ? \FlexiPeeHP\FlexiBeeRO::uncode($customer->adresar->getDataValue('kod'))
: null;
} | php | public static function getCustomerCompany($customer)
{
return $customer->adresar->getDataValue('kod') ? \FlexiPeeHP\FlexiBeeRO::uncode($customer->adresar->getDataValue('kod'))
: null;
} | [
"public",
"static",
"function",
"getCustomerCompany",
"(",
"$",
"customer",
")",
"{",
"return",
"$",
"customer",
"->",
"adresar",
"->",
"getDataValue",
"(",
"'kod'",
")",
"?",
"\\",
"FlexiPeeHP",
"\\",
"FlexiBeeRO",
"::",
"uncode",
"(",
"$",
"customer",
"->"... | Obtain customer company code
@param Customer $customer
@return int | [
"Obtain",
"customer",
"company",
"code"
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/GateKeeper.php#L66-L70 | train |
Corviz/framework | src/Mvc/Controller.php | Controller.redirect | protected function redirect(string $ref, array $params = [], string $schema = null)
{
$url = $this->link($ref, $params, $schema);
$response = new Response();
$response->setCode(Response::CODE_REDIRECT_SEE_OTHER);
$response->addHeader('Location', $url);
return $response;
} | php | protected function redirect(string $ref, array $params = [], string $schema = null)
{
$url = $this->link($ref, $params, $schema);
$response = new Response();
$response->setCode(Response::CODE_REDIRECT_SEE_OTHER);
$response->addHeader('Location', $url);
return $response;
} | [
"protected",
"function",
"redirect",
"(",
"string",
"$",
"ref",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"string",
"$",
"schema",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"link",
"(",
"$",
"ref",
",",
"$",
"params",
",",... | Creates a redirect response.
@param string $ref
@param array $params
@param string|null $schema
@return Response | [
"Creates",
"a",
"redirect",
"response",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Mvc/Controller.php#L141-L150 | train |
honeybee/trellis | src/Runtime/Attribute/Attribute.php | Attribute.getDefaultValue | public function getDefaultValue()
{
if ($this->hasOption(self::OPTION_DEFAULT_VALUE)) {
return $this->getSanitizedValue(
$this->getOption(self::OPTION_DEFAULT_VALUE, $this->getNullValue())
);
}
return $this->getNullValue();
} | php | public function getDefaultValue()
{
if ($this->hasOption(self::OPTION_DEFAULT_VALUE)) {
return $this->getSanitizedValue(
$this->getOption(self::OPTION_DEFAULT_VALUE, $this->getNullValue())
);
}
return $this->getNullValue();
} | [
"public",
"function",
"getDefaultValue",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"self",
"::",
"OPTION_DEFAULT_VALUE",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSanitizedValue",
"(",
"$",
"this",
"->",
"getOption",
"(",
"self",... | Returns the default value of the attribute.
@return mixed value to be used/interpreted as the default value | [
"Returns",
"the",
"default",
"value",
"of",
"the",
"attribute",
"."
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Attribute/Attribute.php#L148-L157 | train |
honeybee/trellis | src/Runtime/Attribute/Attribute.php | Attribute.getValidator | public function getValidator()
{
if (!$this->validator) {
$default_validator_class = Validator::CLASS;
$validator_implementor = $this->getOption(self::OPTION_VALIDATOR, $default_validator_class);
if (!class_exists($validator_implementor, true)) {
throw new InvalidConfigException(
sprintf(
"Unable to resolve validator implementor '%s' given for attribute '%s' on entity type '%s'.",
$validator_implementor,
$this->getName(),
$this->getType()->getName()
)
);
}
$validator = new $validator_implementor($this->getName(), $this->buildValidationRules());
if (!$validator instanceof ValidatorInterface) {
throw new InvalidTypeException(
sprintf(
"Invalid validator implementor '%s' given for attribute '%s' on entity type '%s'. " .
"Make sure to implement '%s'.",
$validator_implementor,
$this->getName(),
$this->getType() ? $this->getType()->getName() : 'undefined',
ValidatorInterface::CLASS
)
);
}
$this->validator = $validator;
}
return $this->validator;
} | php | public function getValidator()
{
if (!$this->validator) {
$default_validator_class = Validator::CLASS;
$validator_implementor = $this->getOption(self::OPTION_VALIDATOR, $default_validator_class);
if (!class_exists($validator_implementor, true)) {
throw new InvalidConfigException(
sprintf(
"Unable to resolve validator implementor '%s' given for attribute '%s' on entity type '%s'.",
$validator_implementor,
$this->getName(),
$this->getType()->getName()
)
);
}
$validator = new $validator_implementor($this->getName(), $this->buildValidationRules());
if (!$validator instanceof ValidatorInterface) {
throw new InvalidTypeException(
sprintf(
"Invalid validator implementor '%s' given for attribute '%s' on entity type '%s'. " .
"Make sure to implement '%s'.",
$validator_implementor,
$this->getName(),
$this->getType() ? $this->getType()->getName() : 'undefined',
ValidatorInterface::CLASS
)
);
}
$this->validator = $validator;
}
return $this->validator;
} | [
"public",
"function",
"getValidator",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validator",
")",
"{",
"$",
"default_validator_class",
"=",
"Validator",
"::",
"CLASS",
";",
"$",
"validator_implementor",
"=",
"$",
"this",
"->",
"getOption",
"(",
"se... | Returns the ValidatorInterface implementation to use when validating values for this attribute.
Override this method if you want inject your own implementation.
@return ValidatorInterface implementation | [
"Returns",
"the",
"ValidatorInterface",
"implementation",
"to",
"use",
"when",
"validating",
"values",
"for",
"this",
"attribute",
".",
"Override",
"this",
"method",
"if",
"you",
"want",
"inject",
"your",
"own",
"implementation",
"."
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Attribute/Attribute.php#L175-L209 | train |
honeybee/trellis | src/Runtime/Attribute/Attribute.php | Attribute.createValueHolder | public function createValueHolder($apply_default_values = false)
{
if (!$this->value_holder_implementor) {
$implementor = $this->hasOption(self::OPTION_VALUE_HOLDER)
? $this->getOption(self::OPTION_VALUE_HOLDER)
: $this->buildDefaultValueHolderClassName();
if (!class_exists($implementor)) {
throw new InvalidConfigException(
sprintf(
"Invalid valueholder implementor '%s' configured for attribute '%s' on entity '%s'.",
$implementor,
$this->getName(),
$this->getType() ? $this->getType()->getName() : 'undefined'
)
);
}
$test_value_holder = new $implementor($this);
if (!$test_value_holder instanceof ValueHolderInterface) {
throw new InvalidTypeException(
sprintf(
"Invalid valueholder implementation '%s' given for attribute '%s' on entity type '%s'. " .
"Make sure to implement '%s'.",
$implementor,
$this->getName(),
$this->getType() ? $this->getType()->getName() : 'undefined',
ValueHolderInterface::CLASS
)
);
}
$this->value_holder_implementor = $implementor;
}
$value_holder = new $this->value_holder_implementor($this);
if ($apply_default_values === true) {
$value_holder->setValue($this->getDefaultValue());
} elseif ($apply_default_values === false) {
$value_holder->setValue($this->getNullValue());
} else {
throw new InvalidTypeException(
sprintf(
"Only boolean arguments are acceptable for attribute '%s' on entity type '%s'. ",
$this->getName(),
$this->getType() ? $this->getType()->getName() : 'undefined'
)
);
}
return $value_holder;
} | php | public function createValueHolder($apply_default_values = false)
{
if (!$this->value_holder_implementor) {
$implementor = $this->hasOption(self::OPTION_VALUE_HOLDER)
? $this->getOption(self::OPTION_VALUE_HOLDER)
: $this->buildDefaultValueHolderClassName();
if (!class_exists($implementor)) {
throw new InvalidConfigException(
sprintf(
"Invalid valueholder implementor '%s' configured for attribute '%s' on entity '%s'.",
$implementor,
$this->getName(),
$this->getType() ? $this->getType()->getName() : 'undefined'
)
);
}
$test_value_holder = new $implementor($this);
if (!$test_value_holder instanceof ValueHolderInterface) {
throw new InvalidTypeException(
sprintf(
"Invalid valueholder implementation '%s' given for attribute '%s' on entity type '%s'. " .
"Make sure to implement '%s'.",
$implementor,
$this->getName(),
$this->getType() ? $this->getType()->getName() : 'undefined',
ValueHolderInterface::CLASS
)
);
}
$this->value_holder_implementor = $implementor;
}
$value_holder = new $this->value_holder_implementor($this);
if ($apply_default_values === true) {
$value_holder->setValue($this->getDefaultValue());
} elseif ($apply_default_values === false) {
$value_holder->setValue($this->getNullValue());
} else {
throw new InvalidTypeException(
sprintf(
"Only boolean arguments are acceptable for attribute '%s' on entity type '%s'. ",
$this->getName(),
$this->getType() ? $this->getType()->getName() : 'undefined'
)
);
}
return $value_holder;
} | [
"public",
"function",
"createValueHolder",
"(",
"$",
"apply_default_values",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"value_holder_implementor",
")",
"{",
"$",
"implementor",
"=",
"$",
"this",
"->",
"hasOption",
"(",
"self",
"::",
"OPTION_... | Creates a ValueHolderInterface, that is specific to the current attribute instance.
@return ValueHolderInterface | [
"Creates",
"a",
"ValueHolderInterface",
"that",
"is",
"specific",
"to",
"the",
"current",
"attribute",
"instance",
"."
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Attribute/Attribute.php#L216-L268 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Services/Console.php | Console.init | public function init(OutputInterface $consoleOutput, $dispatcher)
{
$this->consoleOutput = $consoleOutput;
$this->dispatcher = $dispatcher;
$this->sfStyleOutput = new SymfonyStyle(new StringInput(''), $consoleOutput);
} | php | public function init(OutputInterface $consoleOutput, $dispatcher)
{
$this->consoleOutput = $consoleOutput;
$this->dispatcher = $dispatcher;
$this->sfStyleOutput = new SymfonyStyle(new StringInput(''), $consoleOutput);
} | [
"public",
"function",
"init",
"(",
"OutputInterface",
"$",
"consoleOutput",
",",
"$",
"dispatcher",
")",
"{",
"$",
"this",
"->",
"consoleOutput",
"=",
"$",
"consoleOutput",
";",
"$",
"this",
"->",
"dispatcher",
"=",
"$",
"dispatcher",
";",
"$",
"this",
"->... | Initialize service with the console output.
@param OutputInterface $consoleOutput
@param $dispatcher | [
"Initialize",
"service",
"with",
"the",
"console",
"output",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Services/Console.php#L82-L88 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Services/Console.php | Console.getSfStyleOutput | public function getSfStyleOutput(): SymfonyStyle
{
if (is_null($this->sfStyleOutput)) {
$this->sfStyleOutput = new SymfonyStyle(new StringInput(''), new NullOutput());
}
return $this->sfStyleOutput;
} | php | public function getSfStyleOutput(): SymfonyStyle
{
if (is_null($this->sfStyleOutput)) {
$this->sfStyleOutput = new SymfonyStyle(new StringInput(''), new NullOutput());
}
return $this->sfStyleOutput;
} | [
"public",
"function",
"getSfStyleOutput",
"(",
")",
":",
"SymfonyStyle",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"sfStyleOutput",
")",
")",
"{",
"$",
"this",
"->",
"sfStyleOutput",
"=",
"new",
"SymfonyStyle",
"(",
"new",
"StringInput",
"(",
"''"... | Get symfony style output.
@return SymfonyStyle | [
"Get",
"symfony",
"style",
"output",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Services/Console.php#L241-L247 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Library/OAuthClient/v10/BaseOAuth.php | BaseOAuth.getRequestToken | function getRequestToken($args = array()) {/*{{{*/
$r = $this->oAuthRequest($this->requestTokenURL(), $args);
$token = $this->oAuthParseResponse($r);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
} | php | function getRequestToken($args = array()) {/*{{{*/
$r = $this->oAuthRequest($this->requestTokenURL(), $args);
$token = $this->oAuthParseResponse($r);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
} | [
"function",
"getRequestToken",
"(",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"/*{{{*/",
"$",
"r",
"=",
"$",
"this",
"->",
"oAuthRequest",
"(",
"$",
"this",
"->",
"requestTokenURL",
"(",
")",
",",
"$",
"args",
")",
";",
"$",
"token",
"=",
"$",... | Get a request_token from OAuth server
@returns a key/value array containing oauth_token and oauth_token_secret | [
"Get",
"a",
"request_token",
"from",
"OAuth",
"server"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Library/OAuthClient/v10/BaseOAuth.php#L92-L97 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.