id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
8,700 | MINISTRYGmbH/morrow-core | src/Db.php | Db.delete | public function delete($table, $where, $where_tokens = [], $affected_rows = false) {
// add tokens of where clause
$values = [];
if (is_scalar($where_tokens)) $where_tokens = [$where_tokens];
foreach ($where_tokens as $value) {
$values[] = $value;
}
$query = "DELETE FROM `$table` $where";
$this->connect();
$sth = $this->prepare($query);
$returner['SUCCESS'] = $sth->execute($values);
if ($affected_rows) $returner['AFFECTED_ROWS'] = $sth->rowCount();
return $returner;
} | php | public function delete($table, $where, $where_tokens = [], $affected_rows = false) {
// add tokens of where clause
$values = [];
if (is_scalar($where_tokens)) $where_tokens = [$where_tokens];
foreach ($where_tokens as $value) {
$values[] = $value;
}
$query = "DELETE FROM `$table` $where";
$this->connect();
$sth = $this->prepare($query);
$returner['SUCCESS'] = $sth->execute($values);
if ($affected_rows) $returner['AFFECTED_ROWS'] = $sth->rowCount();
return $returner;
} | [
"public",
"function",
"delete",
"(",
"$",
"table",
",",
"$",
"where",
",",
"$",
"where_tokens",
"=",
"[",
"]",
",",
"$",
"affected_rows",
"=",
"false",
")",
"{",
"// add tokens of where clause",
"$",
"values",
"=",
"[",
"]",
";",
"if",
"(",
"is_scalar",
"(",
"$",
"where_tokens",
")",
")",
"$",
"where_tokens",
"=",
"[",
"$",
"where_tokens",
"]",
";",
"foreach",
"(",
"$",
"where_tokens",
"as",
"$",
"value",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"query",
"=",
"\"DELETE FROM `$table` $where\"",
";",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"sth",
"=",
"$",
"this",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
"$",
"returner",
"[",
"'SUCCESS'",
"]",
"=",
"$",
"sth",
"->",
"execute",
"(",
"$",
"values",
")",
";",
"if",
"(",
"$",
"affected_rows",
")",
"$",
"returner",
"[",
"'AFFECTED_ROWS'",
"]",
"=",
"$",
"sth",
"->",
"rowCount",
"(",
")",
";",
"return",
"$",
"returner",
";",
"}"
] | Deletes a database row.
@param string $table The table name the query refers to.
@param string $where The where condition in the update query
@param mixed $where_tokens An array (or a scalar) for use as a Prepared Statement in the where clause. Only question marks are allowed for the token in the where clause. You cannot use the colon syntax.
@param boolean $affected_rows Set to true to return the count of the affected rows
@return array An result array with the keys `SUCCESS` (boolean Was the query successful) and `AFFECTED_ROWS` (int The count of the affected rows) | [
"Deletes",
"a",
"database",
"row",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Db.php#L400-L416 |
8,701 | MINISTRYGmbH/morrow-core | src/Db.php | Db._createUpdateValues | protected function _createUpdateValues($array) {
$values = [];
$tokens = [];
// divide normal values from function calls
foreach ($array as $key => $value) {
if (is_array($value)) {
$tokens[] = '`'.$key.'`='.$value['FUNC'];
} else {
$tokens[] = '`'.$key.'`=?';
$values[] = $value;
}
}
$tokens = implode(', ', $tokens);
$returner = compact('tokens', 'values');
return $returner;
} | php | protected function _createUpdateValues($array) {
$values = [];
$tokens = [];
// divide normal values from function calls
foreach ($array as $key => $value) {
if (is_array($value)) {
$tokens[] = '`'.$key.'`='.$value['FUNC'];
} else {
$tokens[] = '`'.$key.'`=?';
$values[] = $value;
}
}
$tokens = implode(', ', $tokens);
$returner = compact('tokens', 'values');
return $returner;
} | [
"protected",
"function",
"_createUpdateValues",
"(",
"$",
"array",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"$",
"tokens",
"=",
"[",
"]",
";",
"// divide normal values from function calls",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"tokens",
"[",
"]",
"=",
"'`'",
".",
"$",
"key",
".",
"'`='",
".",
"$",
"value",
"[",
"'FUNC'",
"]",
";",
"}",
"else",
"{",
"$",
"tokens",
"[",
"]",
"=",
"'`'",
".",
"$",
"key",
".",
"'`=?'",
";",
"$",
"values",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"tokens",
"=",
"implode",
"(",
"', '",
",",
"$",
"tokens",
")",
";",
"$",
"returner",
"=",
"compact",
"(",
"'tokens'",
",",
"'values'",
")",
";",
"return",
"$",
"returner",
";",
"}"
] | Creates an update string of an associative array for use in a SQL query
@param array $array An associative array: column_name > value
@return string | [
"Creates",
"an",
"update",
"string",
"of",
"an",
"associative",
"array",
"for",
"use",
"in",
"a",
"SQL",
"query"
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Db.php#L461-L479 |
8,702 | MINISTRYGmbH/morrow-core | src/Db.php | Db._createInsertAndReplaceValues | protected function _createInsertAndReplaceValues($array) {
$keys = [];
$values = [];
$binds = [];
foreach ($array as $value) {
if (is_array($value)) {
$values[] = $value['FUNC'];
} else {
$values[] = '?';
$binds[] = $value;
}
}
$keys = implode(',', array_keys($array));
$values = implode(',', $values);
$returner = compact('keys', 'values', 'binds');
return $returner;
} | php | protected function _createInsertAndReplaceValues($array) {
$keys = [];
$values = [];
$binds = [];
foreach ($array as $value) {
if (is_array($value)) {
$values[] = $value['FUNC'];
} else {
$values[] = '?';
$binds[] = $value;
}
}
$keys = implode(',', array_keys($array));
$values = implode(',', $values);
$returner = compact('keys', 'values', 'binds');
return $returner;
} | [
"protected",
"function",
"_createInsertAndReplaceValues",
"(",
"$",
"array",
")",
"{",
"$",
"keys",
"=",
"[",
"]",
";",
"$",
"values",
"=",
"[",
"]",
";",
"$",
"binds",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"$",
"value",
"[",
"'FUNC'",
"]",
";",
"}",
"else",
"{",
"$",
"values",
"[",
"]",
"=",
"'?'",
";",
"$",
"binds",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"keys",
"=",
"implode",
"(",
"','",
",",
"array_keys",
"(",
"$",
"array",
")",
")",
";",
"$",
"values",
"=",
"implode",
"(",
"','",
",",
"$",
"values",
")",
";",
"$",
"returner",
"=",
"compact",
"(",
"'keys'",
",",
"'values'",
",",
"'binds'",
")",
";",
"return",
"$",
"returner",
";",
"}"
] | Creates an insert and replace string of an associative array for use in a SQL query
@param array $array An associative array: column_name > value
@return string | [
"Creates",
"an",
"insert",
"and",
"replace",
"string",
"of",
"an",
"associative",
"array",
"for",
"use",
"in",
"a",
"SQL",
"query"
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Db.php#L487-L506 |
8,703 | MINISTRYGmbH/morrow-core | src/Db.php | Db._safe | protected function _safe($table, $array) {
if (!isset($this->cache[$table])) {
$this->connect();
$query = "SHOW COLUMNS FROM `$table`";
if ($this->config['driver'] == 'sqlite') {
$query = 'PRAGMA table_info(`'.$table.'`);';
}
$sth = $this->prepare($query);
$sth->execute();
$result = $sth->fetchAll(\PDO::FETCH_ASSOC);
foreach ($result as $row) {
if ($this->config['driver'] == 'sqlite') {
$columns[] = $row['name'];
} else {
$columns[] = $row['Field'];
}
}
$this->cache[$table] = $columns;
}
// remove all not existent keys
foreach (array_keys($array) as $key) {
if (!in_array($key, $this->cache[$table])) unset ($array[$key]);
}
return $array;
} | php | protected function _safe($table, $array) {
if (!isset($this->cache[$table])) {
$this->connect();
$query = "SHOW COLUMNS FROM `$table`";
if ($this->config['driver'] == 'sqlite') {
$query = 'PRAGMA table_info(`'.$table.'`);';
}
$sth = $this->prepare($query);
$sth->execute();
$result = $sth->fetchAll(\PDO::FETCH_ASSOC);
foreach ($result as $row) {
if ($this->config['driver'] == 'sqlite') {
$columns[] = $row['name'];
} else {
$columns[] = $row['Field'];
}
}
$this->cache[$table] = $columns;
}
// remove all not existent keys
foreach (array_keys($array) as $key) {
if (!in_array($key, $this->cache[$table])) unset ($array[$key]);
}
return $array;
} | [
"protected",
"function",
"_safe",
"(",
"$",
"table",
",",
"$",
"array",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"table",
"]",
")",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"query",
"=",
"\"SHOW COLUMNS FROM `$table`\"",
";",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'driver'",
"]",
"==",
"'sqlite'",
")",
"{",
"$",
"query",
"=",
"'PRAGMA table_info(`'",
".",
"$",
"table",
".",
"'`);'",
";",
"}",
"$",
"sth",
"=",
"$",
"this",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
"$",
"sth",
"->",
"execute",
"(",
")",
";",
"$",
"result",
"=",
"$",
"sth",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'driver'",
"]",
"==",
"'sqlite'",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"$",
"row",
"[",
"'name'",
"]",
";",
"}",
"else",
"{",
"$",
"columns",
"[",
"]",
"=",
"$",
"row",
"[",
"'Field'",
"]",
";",
"}",
"}",
"$",
"this",
"->",
"cache",
"[",
"$",
"table",
"]",
"=",
"$",
"columns",
";",
"}",
"// remove all not existent keys",
"foreach",
"(",
"array_keys",
"(",
"$",
"array",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"cache",
"[",
"$",
"table",
"]",
")",
")",
"unset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"$",
"array",
";",
"}"
] | Removes all keys from an array which are not available in the given table
@param string $table The table name to compare the array with
@param array $array An associative array: column_name > value
@return array | [
"Removes",
"all",
"keys",
"from",
"an",
"array",
"which",
"are",
"not",
"available",
"in",
"the",
"given",
"table"
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Db.php#L515-L543 |
8,704 | asbsoft/yii2module-content_2_170309 | controllers/AdminController.php | AdminController.actionIndex | public function actionIndex($parent = null, $page = 1)
{
$searchModel = $this->module->model('ContentSearch');
// list filter parameters correction
$params = Yii::$app->request->queryParams;
if ($parent === '-') { // to show all nodes
$params['parent'] = $parent;
unset($params[$searchModel->formName()]['parent_id']);
} else {
$params[$searchModel->formName()]['parent_id'] = $params['parent'] = intval($parent);
}
if (!Yii::$app->user->can('roleContentModerator') && Yii::$app->user->can('roleContentAuthor')) {
$params[$searchModel->formName()]['owner_id'] = Yii::$app->user->id;
}
$dataProvider = $searchModel->search($params);
$pager = $dataProvider->getPagination();
$pager->pageSize = $this->pageSizeAdmin;
$pager->totalCount = $dataProvider->getTotalCount();
// page number correction:
$maxPage = ceil($pager->totalCount / $pager->pageSize);
if ($page > $maxPage) {
$pager->page = $maxPage - 1;
} else {
$pager->page = $page - 1; //! from 0
}
return $this->render('index', compact('dataProvider', 'searchModel', 'params'));
} | php | public function actionIndex($parent = null, $page = 1)
{
$searchModel = $this->module->model('ContentSearch');
// list filter parameters correction
$params = Yii::$app->request->queryParams;
if ($parent === '-') { // to show all nodes
$params['parent'] = $parent;
unset($params[$searchModel->formName()]['parent_id']);
} else {
$params[$searchModel->formName()]['parent_id'] = $params['parent'] = intval($parent);
}
if (!Yii::$app->user->can('roleContentModerator') && Yii::$app->user->can('roleContentAuthor')) {
$params[$searchModel->formName()]['owner_id'] = Yii::$app->user->id;
}
$dataProvider = $searchModel->search($params);
$pager = $dataProvider->getPagination();
$pager->pageSize = $this->pageSizeAdmin;
$pager->totalCount = $dataProvider->getTotalCount();
// page number correction:
$maxPage = ceil($pager->totalCount / $pager->pageSize);
if ($page > $maxPage) {
$pager->page = $maxPage - 1;
} else {
$pager->page = $page - 1; //! from 0
}
return $this->render('index', compact('dataProvider', 'searchModel', 'params'));
} | [
"public",
"function",
"actionIndex",
"(",
"$",
"parent",
"=",
"null",
",",
"$",
"page",
"=",
"1",
")",
"{",
"$",
"searchModel",
"=",
"$",
"this",
"->",
"module",
"->",
"model",
"(",
"'ContentSearch'",
")",
";",
"// list filter parameters correction",
"$",
"params",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"queryParams",
";",
"if",
"(",
"$",
"parent",
"===",
"'-'",
")",
"{",
"// to show all nodes",
"$",
"params",
"[",
"'parent'",
"]",
"=",
"$",
"parent",
";",
"unset",
"(",
"$",
"params",
"[",
"$",
"searchModel",
"->",
"formName",
"(",
")",
"]",
"[",
"'parent_id'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"params",
"[",
"$",
"searchModel",
"->",
"formName",
"(",
")",
"]",
"[",
"'parent_id'",
"]",
"=",
"$",
"params",
"[",
"'parent'",
"]",
"=",
"intval",
"(",
"$",
"parent",
")",
";",
"}",
"if",
"(",
"!",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'roleContentModerator'",
")",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'roleContentAuthor'",
")",
")",
"{",
"$",
"params",
"[",
"$",
"searchModel",
"->",
"formName",
"(",
")",
"]",
"[",
"'owner_id'",
"]",
"=",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"id",
";",
"}",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"$",
"params",
")",
";",
"$",
"pager",
"=",
"$",
"dataProvider",
"->",
"getPagination",
"(",
")",
";",
"$",
"pager",
"->",
"pageSize",
"=",
"$",
"this",
"->",
"pageSizeAdmin",
";",
"$",
"pager",
"->",
"totalCount",
"=",
"$",
"dataProvider",
"->",
"getTotalCount",
"(",
")",
";",
"// page number correction:",
"$",
"maxPage",
"=",
"ceil",
"(",
"$",
"pager",
"->",
"totalCount",
"/",
"$",
"pager",
"->",
"pageSize",
")",
";",
"if",
"(",
"$",
"page",
">",
"$",
"maxPage",
")",
"{",
"$",
"pager",
"->",
"page",
"=",
"$",
"maxPage",
"-",
"1",
";",
"}",
"else",
"{",
"$",
"pager",
"->",
"page",
"=",
"$",
"page",
"-",
"1",
";",
"//! from 0",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"compact",
"(",
"'dataProvider'",
",",
"'searchModel'",
",",
"'params'",
")",
")",
";",
"}"
] | Lists all Content models.
@param mixed $parent parent node id, '0' means show root children, '-' means show all nodes.
@param integer $page
@return mixed | [
"Lists",
"all",
"Content",
"models",
"."
] | 9e7ee40fd48ef9656a9f95379f20bf6a4004187b | https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/controllers/AdminController.php#L89-L121 |
8,705 | asbsoft/yii2module-content_2_170309 | controllers/AdminController.php | AdminController.actionView | public function actionView($id)
{
$model = $this->findModel($id);
$modelsI18n = $model->prepareI18nModels();
if ($model->pageSize > 0) {
$model->orderBy = $model::$defaultOrderBy;
$model->page = $model->calcPage();
}
// build frontend links
$lh = $this->module->langHelper;
$editAllLanguages = empty($this->module->params['editAllLanguages'])
? false : $this->module->params['editAllLanguages'];
$languages = $lh::activeLanguages($editAllLanguages);
if (Yii::$app instanceof UniApplication && Yii::$app->type == UniApplication::APP_TYPE_BACKEND) {
$containerModule = $this->module->module;
if ($containerModule instanceof UniModule && array_key_exists(static::$sysAppModel, $containerModule->models)) {
$appModel = $containerModule::model(static::$sysAppModel);
$appFront = $appModel::initFrontendApplication(); // for backend application init separate frontend-application
//$appFront->urlManager->baseUrl = 'http://www.mysite.com'; // frontend domain - set from app-params
}
}
$moduleUid = $this->module->uniqueId;
$frontendLinks = [];
foreach ($languages as $langCode => $lang) {
$frontendLinks[$langCode] = '';
if ($model->hasInvisibleParent()) {
if (empty($model->route)) {
$frontendLinks[$langCode] = Url::toRoute(["/{$moduleUid}/main/show", 'id' => $model->id, 'slug' => $model->slug]);
} else { // external/internal link
$frontendLinks[$langCode] = ContentMenuBuilder::routeToLink($model->route);
}
} else {
$frontendLinks[$langCode] = Url::toRoute(["/{$moduleUid}/main/view"
, 'id' => $model->id, 'lang' => $langCode], true);
}
}
if (!empty($appModel)) $appModel::restoreApplication();
return $this->render('view', compact('model', 'modelsI18n', 'frontendLinks'));
} | php | public function actionView($id)
{
$model = $this->findModel($id);
$modelsI18n = $model->prepareI18nModels();
if ($model->pageSize > 0) {
$model->orderBy = $model::$defaultOrderBy;
$model->page = $model->calcPage();
}
// build frontend links
$lh = $this->module->langHelper;
$editAllLanguages = empty($this->module->params['editAllLanguages'])
? false : $this->module->params['editAllLanguages'];
$languages = $lh::activeLanguages($editAllLanguages);
if (Yii::$app instanceof UniApplication && Yii::$app->type == UniApplication::APP_TYPE_BACKEND) {
$containerModule = $this->module->module;
if ($containerModule instanceof UniModule && array_key_exists(static::$sysAppModel, $containerModule->models)) {
$appModel = $containerModule::model(static::$sysAppModel);
$appFront = $appModel::initFrontendApplication(); // for backend application init separate frontend-application
//$appFront->urlManager->baseUrl = 'http://www.mysite.com'; // frontend domain - set from app-params
}
}
$moduleUid = $this->module->uniqueId;
$frontendLinks = [];
foreach ($languages as $langCode => $lang) {
$frontendLinks[$langCode] = '';
if ($model->hasInvisibleParent()) {
if (empty($model->route)) {
$frontendLinks[$langCode] = Url::toRoute(["/{$moduleUid}/main/show", 'id' => $model->id, 'slug' => $model->slug]);
} else { // external/internal link
$frontendLinks[$langCode] = ContentMenuBuilder::routeToLink($model->route);
}
} else {
$frontendLinks[$langCode] = Url::toRoute(["/{$moduleUid}/main/view"
, 'id' => $model->id, 'lang' => $langCode], true);
}
}
if (!empty($appModel)) $appModel::restoreApplication();
return $this->render('view', compact('model', 'modelsI18n', 'frontendLinks'));
} | [
"public",
"function",
"actionView",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"modelsI18n",
"=",
"$",
"model",
"->",
"prepareI18nModels",
"(",
")",
";",
"if",
"(",
"$",
"model",
"->",
"pageSize",
">",
"0",
")",
"{",
"$",
"model",
"->",
"orderBy",
"=",
"$",
"model",
"::",
"$",
"defaultOrderBy",
";",
"$",
"model",
"->",
"page",
"=",
"$",
"model",
"->",
"calcPage",
"(",
")",
";",
"}",
"// build frontend links",
"$",
"lh",
"=",
"$",
"this",
"->",
"module",
"->",
"langHelper",
";",
"$",
"editAllLanguages",
"=",
"empty",
"(",
"$",
"this",
"->",
"module",
"->",
"params",
"[",
"'editAllLanguages'",
"]",
")",
"?",
"false",
":",
"$",
"this",
"->",
"module",
"->",
"params",
"[",
"'editAllLanguages'",
"]",
";",
"$",
"languages",
"=",
"$",
"lh",
"::",
"activeLanguages",
"(",
"$",
"editAllLanguages",
")",
";",
"if",
"(",
"Yii",
"::",
"$",
"app",
"instanceof",
"UniApplication",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"type",
"==",
"UniApplication",
"::",
"APP_TYPE_BACKEND",
")",
"{",
"$",
"containerModule",
"=",
"$",
"this",
"->",
"module",
"->",
"module",
";",
"if",
"(",
"$",
"containerModule",
"instanceof",
"UniModule",
"&&",
"array_key_exists",
"(",
"static",
"::",
"$",
"sysAppModel",
",",
"$",
"containerModule",
"->",
"models",
")",
")",
"{",
"$",
"appModel",
"=",
"$",
"containerModule",
"::",
"model",
"(",
"static",
"::",
"$",
"sysAppModel",
")",
";",
"$",
"appFront",
"=",
"$",
"appModel",
"::",
"initFrontendApplication",
"(",
")",
";",
"// for backend application init separate frontend-application",
"//$appFront->urlManager->baseUrl = 'http://www.mysite.com'; // frontend domain - set from app-params",
"}",
"}",
"$",
"moduleUid",
"=",
"$",
"this",
"->",
"module",
"->",
"uniqueId",
";",
"$",
"frontendLinks",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"languages",
"as",
"$",
"langCode",
"=>",
"$",
"lang",
")",
"{",
"$",
"frontendLinks",
"[",
"$",
"langCode",
"]",
"=",
"''",
";",
"if",
"(",
"$",
"model",
"->",
"hasInvisibleParent",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"model",
"->",
"route",
")",
")",
"{",
"$",
"frontendLinks",
"[",
"$",
"langCode",
"]",
"=",
"Url",
"::",
"toRoute",
"(",
"[",
"\"/{$moduleUid}/main/show\"",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"'slug'",
"=>",
"$",
"model",
"->",
"slug",
"]",
")",
";",
"}",
"else",
"{",
"// external/internal link",
"$",
"frontendLinks",
"[",
"$",
"langCode",
"]",
"=",
"ContentMenuBuilder",
"::",
"routeToLink",
"(",
"$",
"model",
"->",
"route",
")",
";",
"}",
"}",
"else",
"{",
"$",
"frontendLinks",
"[",
"$",
"langCode",
"]",
"=",
"Url",
"::",
"toRoute",
"(",
"[",
"\"/{$moduleUid}/main/view\"",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"'lang'",
"=>",
"$",
"langCode",
"]",
",",
"true",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"appModel",
")",
")",
"$",
"appModel",
"::",
"restoreApplication",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'view'",
",",
"compact",
"(",
"'model'",
",",
"'modelsI18n'",
",",
"'frontendLinks'",
")",
")",
";",
"}"
] | Displays a single Content model.
@param integer $id
@return mixed | [
"Displays",
"a",
"single",
"Content",
"model",
"."
] | 9e7ee40fd48ef9656a9f95379f20bf6a4004187b | https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/controllers/AdminController.php#L128-L169 |
8,706 | asbsoft/yii2module-content_2_170309 | controllers/AdminController.php | AdminController.actionCreate | public function actionCreate($parent = 0)
{
$model = $this->module->model('Content');
if (!isset($model->parent_id)) {
$model->parent_id = $parent;
}
$post = Yii::$app->request->post();
$loaded = $model->load($post);
if ($loaded && $model->save()) {
if ($model->aftersave != $model::AFTERSAVE_LIST) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
$model->orderBy = $model::$defaultOrderBy;
$model->page = $model->calcPage($model::find()->where(['parent_id' => $model->parent_id]));
return $this->redirect(['index',
'parent' => $model->parent_id,
'page' => $model->page,
'id' => $model->id,
'sort' => $model->orderByToSort(),
]);
}
} else {
return $this->render('create', compact('model'));
}
} | php | public function actionCreate($parent = 0)
{
$model = $this->module->model('Content');
if (!isset($model->parent_id)) {
$model->parent_id = $parent;
}
$post = Yii::$app->request->post();
$loaded = $model->load($post);
if ($loaded && $model->save()) {
if ($model->aftersave != $model::AFTERSAVE_LIST) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
$model->orderBy = $model::$defaultOrderBy;
$model->page = $model->calcPage($model::find()->where(['parent_id' => $model->parent_id]));
return $this->redirect(['index',
'parent' => $model->parent_id,
'page' => $model->page,
'id' => $model->id,
'sort' => $model->orderByToSort(),
]);
}
} else {
return $this->render('create', compact('model'));
}
} | [
"public",
"function",
"actionCreate",
"(",
"$",
"parent",
"=",
"0",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"module",
"->",
"model",
"(",
"'Content'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"model",
"->",
"parent_id",
")",
")",
"{",
"$",
"model",
"->",
"parent_id",
"=",
"$",
"parent",
";",
"}",
"$",
"post",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
";",
"$",
"loaded",
"=",
"$",
"model",
"->",
"load",
"(",
"$",
"post",
")",
";",
"if",
"(",
"$",
"loaded",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"aftersave",
"!=",
"$",
"model",
"::",
"AFTERSAVE_LIST",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'view'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
"]",
")",
";",
"}",
"else",
"{",
"$",
"model",
"->",
"orderBy",
"=",
"$",
"model",
"::",
"$",
"defaultOrderBy",
";",
"$",
"model",
"->",
"page",
"=",
"$",
"model",
"->",
"calcPage",
"(",
"$",
"model",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'parent_id'",
"=>",
"$",
"model",
"->",
"parent_id",
"]",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'index'",
",",
"'parent'",
"=>",
"$",
"model",
"->",
"parent_id",
",",
"'page'",
"=>",
"$",
"model",
"->",
"page",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"'sort'",
"=>",
"$",
"model",
"->",
"orderByToSort",
"(",
")",
",",
"]",
")",
";",
"}",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'create'",
",",
"compact",
"(",
"'model'",
")",
")",
";",
"}",
"}"
] | Creates a new Content model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed | [
"Creates",
"a",
"new",
"Content",
"model",
".",
"If",
"creation",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 9e7ee40fd48ef9656a9f95379f20bf6a4004187b | https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/controllers/AdminController.php#L176-L201 |
8,707 | asbsoft/yii2module-content_2_170309 | controllers/AdminController.php | AdminController.actionUpdate | public function actionUpdate($id)
{
$model = $this->findModel($id);
// check permissions
if (!Yii::$app->user->can('roleContentModerator') // user is not moderator
&& Yii::$app->user->can('roleContentAuthor') // but is author ...
&& !Yii::$app->user->can('updateOwnContent', [ // ... can edit only own article
'content' => $model, // - if article unvisible - always can
'canEditVisible' // - but if not visible - see this param
=> $this->canAuthorEditOwnVisibleArticle,
])
) {
if ($this->canAuthorEditOwnVisibleArticle) {
throw new ForbiddenHttpException(Yii::t($this->tcModule, 'You can update only your own article'));
} else {
throw new ForbiddenHttpException(Yii::t($this->tcModule, 'You can update only your own article still unvisible'));
}
}
$post = Yii::$app->request->post();
$loaded = $model->load($post);
$attributes = $model->attributes;
if (!$this->canAuthorEditOwnVisibleArticle) unset($attributes['is_visible']);
$attributeNames = array_keys($attributes);
if ($loaded && $model->save(true, $attributeNames)) {
if ($model->aftersave != $model::AFTERSAVE_LIST) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
$model->orderBy = $model::$defaultOrderBy;
$model->page = $model->calcPage($model::find()->where(['parent_id' => $model->parent_id]));
return $this->redirect(['index',
'parent' => $model->parent_id,
'page' => $model->page,
'id' => $model->id,
'sort' => $model->orderByToSort(),
]);
}
} else {
return $this->render('update', compact('model'));
}
} | php | public function actionUpdate($id)
{
$model = $this->findModel($id);
// check permissions
if (!Yii::$app->user->can('roleContentModerator') // user is not moderator
&& Yii::$app->user->can('roleContentAuthor') // but is author ...
&& !Yii::$app->user->can('updateOwnContent', [ // ... can edit only own article
'content' => $model, // - if article unvisible - always can
'canEditVisible' // - but if not visible - see this param
=> $this->canAuthorEditOwnVisibleArticle,
])
) {
if ($this->canAuthorEditOwnVisibleArticle) {
throw new ForbiddenHttpException(Yii::t($this->tcModule, 'You can update only your own article'));
} else {
throw new ForbiddenHttpException(Yii::t($this->tcModule, 'You can update only your own article still unvisible'));
}
}
$post = Yii::$app->request->post();
$loaded = $model->load($post);
$attributes = $model->attributes;
if (!$this->canAuthorEditOwnVisibleArticle) unset($attributes['is_visible']);
$attributeNames = array_keys($attributes);
if ($loaded && $model->save(true, $attributeNames)) {
if ($model->aftersave != $model::AFTERSAVE_LIST) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
$model->orderBy = $model::$defaultOrderBy;
$model->page = $model->calcPage($model::find()->where(['parent_id' => $model->parent_id]));
return $this->redirect(['index',
'parent' => $model->parent_id,
'page' => $model->page,
'id' => $model->id,
'sort' => $model->orderByToSort(),
]);
}
} else {
return $this->render('update', compact('model'));
}
} | [
"public",
"function",
"actionUpdate",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"// check permissions",
"if",
"(",
"!",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'roleContentModerator'",
")",
"// user is not moderator",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'roleContentAuthor'",
")",
"// but is author ...",
"&&",
"!",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'updateOwnContent'",
",",
"[",
"// ... can edit only own article",
"'content'",
"=>",
"$",
"model",
",",
"// - if article unvisible - always can",
"'canEditVisible'",
"// - but if not visible - see this param",
"=>",
"$",
"this",
"->",
"canAuthorEditOwnVisibleArticle",
",",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"canAuthorEditOwnVisibleArticle",
")",
"{",
"throw",
"new",
"ForbiddenHttpException",
"(",
"Yii",
"::",
"t",
"(",
"$",
"this",
"->",
"tcModule",
",",
"'You can update only your own article'",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ForbiddenHttpException",
"(",
"Yii",
"::",
"t",
"(",
"$",
"this",
"->",
"tcModule",
",",
"'You can update only your own article still unvisible'",
")",
")",
";",
"}",
"}",
"$",
"post",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
";",
"$",
"loaded",
"=",
"$",
"model",
"->",
"load",
"(",
"$",
"post",
")",
";",
"$",
"attributes",
"=",
"$",
"model",
"->",
"attributes",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"canAuthorEditOwnVisibleArticle",
")",
"unset",
"(",
"$",
"attributes",
"[",
"'is_visible'",
"]",
")",
";",
"$",
"attributeNames",
"=",
"array_keys",
"(",
"$",
"attributes",
")",
";",
"if",
"(",
"$",
"loaded",
"&&",
"$",
"model",
"->",
"save",
"(",
"true",
",",
"$",
"attributeNames",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"aftersave",
"!=",
"$",
"model",
"::",
"AFTERSAVE_LIST",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'view'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
"]",
")",
";",
"}",
"else",
"{",
"$",
"model",
"->",
"orderBy",
"=",
"$",
"model",
"::",
"$",
"defaultOrderBy",
";",
"$",
"model",
"->",
"page",
"=",
"$",
"model",
"->",
"calcPage",
"(",
"$",
"model",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'parent_id'",
"=>",
"$",
"model",
"->",
"parent_id",
"]",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'index'",
",",
"'parent'",
"=>",
"$",
"model",
"->",
"parent_id",
",",
"'page'",
"=>",
"$",
"model",
"->",
"page",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"'sort'",
"=>",
"$",
"model",
"->",
"orderByToSort",
"(",
")",
",",
"]",
")",
";",
"}",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'update'",
",",
"compact",
"(",
"'model'",
")",
")",
";",
"}",
"}"
] | Updates an existing Content model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed | [
"Updates",
"an",
"existing",
"Content",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 9e7ee40fd48ef9656a9f95379f20bf6a4004187b | https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/controllers/AdminController.php#L209-L252 |
8,708 | asbsoft/yii2module-content_2_170309 | controllers/AdminController.php | AdminController.actionDelete | public function actionDelete($id)
{
$model = $this->findModel($id);
$model->orderBy = $model::$defaultOrderBy;
$model->page = $model->calcPage($model::find()->where(['parent_id' => $model->parent_id]));
$returnTo = ['index', // try to return to same place - deletion may be unsuccessfull
'parent_id' => $model->parent_id,
'page' => $model->page,
'id' => $id,
'sort' => $model->orderByToSort(),
];
$model->delete();
return $this->redirect($returnTo);
} | php | public function actionDelete($id)
{
$model = $this->findModel($id);
$model->orderBy = $model::$defaultOrderBy;
$model->page = $model->calcPage($model::find()->where(['parent_id' => $model->parent_id]));
$returnTo = ['index', // try to return to same place - deletion may be unsuccessfull
'parent_id' => $model->parent_id,
'page' => $model->page,
'id' => $id,
'sort' => $model->orderByToSort(),
];
$model->delete();
return $this->redirect($returnTo);
} | [
"public",
"function",
"actionDelete",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"->",
"orderBy",
"=",
"$",
"model",
"::",
"$",
"defaultOrderBy",
";",
"$",
"model",
"->",
"page",
"=",
"$",
"model",
"->",
"calcPage",
"(",
"$",
"model",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'parent_id'",
"=>",
"$",
"model",
"->",
"parent_id",
"]",
")",
")",
";",
"$",
"returnTo",
"=",
"[",
"'index'",
",",
"// try to return to same place - deletion may be unsuccessfull",
"'parent_id'",
"=>",
"$",
"model",
"->",
"parent_id",
",",
"'page'",
"=>",
"$",
"model",
"->",
"page",
",",
"'id'",
"=>",
"$",
"id",
",",
"'sort'",
"=>",
"$",
"model",
"->",
"orderByToSort",
"(",
")",
",",
"]",
";",
"$",
"model",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"returnTo",
")",
";",
"}"
] | Deletes an existing Content model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed | [
"Deletes",
"an",
"existing",
"Content",
"model",
".",
"If",
"deletion",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] | 9e7ee40fd48ef9656a9f95379f20bf6a4004187b | https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/controllers/AdminController.php#L260-L276 |
8,709 | asbsoft/yii2module-content_2_170309 | controllers/AdminController.php | AdminController.findModel | protected function findModel($id)
{
$model = $this->module->model('Content')->findOne($id);
if ($model !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
} | php | protected function findModel($id)
{
$model = $this->module->model('Content')->findOne($id);
if ($model !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
} | [
"protected",
"function",
"findModel",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"module",
"->",
"model",
"(",
"'Content'",
")",
"->",
"findOne",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"!==",
"null",
")",
"{",
"return",
"$",
"model",
";",
"}",
"else",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The requested page does not exist.'",
")",
";",
"}",
"}"
] | Finds the Content model based on its primary key value.
If the model is not found, a 404 HTTP exception will be thrown.
@param integer $id
@return Content the loaded model
@throws NotFoundHttpException if the model cannot be found | [
"Finds",
"the",
"Content",
"model",
"based",
"on",
"its",
"primary",
"key",
"value",
".",
"If",
"the",
"model",
"is",
"not",
"found",
"a",
"404",
"HTTP",
"exception",
"will",
"be",
"thrown",
"."
] | 9e7ee40fd48ef9656a9f95379f20bf6a4004187b | https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/controllers/AdminController.php#L354-L362 |
8,710 | pgraham/database | src/PreparedStatement.php | PreparedStatement.execute | public function execute($params = null) {
if ($params === null) {
$params = [];
}
try {
$this->stmt->execute($params);
return new QueryResult($this->stmt, $this->pdo);
} catch (PDOException $e) {
throw $this->exAdapter->adapt($e, $this->stmt, $params);
}
} | php | public function execute($params = null) {
if ($params === null) {
$params = [];
}
try {
$this->stmt->execute($params);
return new QueryResult($this->stmt, $this->pdo);
} catch (PDOException $e) {
throw $this->exAdapter->adapt($e, $this->stmt, $params);
}
} | [
"public",
"function",
"execute",
"(",
"$",
"params",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"params",
"===",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"stmt",
"->",
"execute",
"(",
"$",
"params",
")",
";",
"return",
"new",
"QueryResult",
"(",
"$",
"this",
"->",
"stmt",
",",
"$",
"this",
"->",
"pdo",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"throw",
"$",
"this",
"->",
"exAdapter",
"->",
"adapt",
"(",
"$",
"e",
",",
"$",
"this",
"->",
"stmt",
",",
"$",
"params",
")",
";",
"}",
"}"
] | Execute the prepared statment with the given parameter values.
@throws DatabaseException | [
"Execute",
"the",
"prepared",
"statment",
"with",
"the",
"given",
"parameter",
"values",
"."
] | b325425da23273536772d4fe62da4b669b78601b | https://github.com/pgraham/database/blob/b325425da23273536772d4fe62da4b669b78601b/src/PreparedStatement.php#L69-L81 |
8,711 | remote-office/libx | src/Util/Date.php | Date.getValue | public function getValue()
{
$value = sprintf("%04d-%02d-%02d", $this->year, $this->month, $this->day);
return $value;
} | php | public function getValue()
{
$value = sprintf("%04d-%02d-%02d", $this->year, $this->month, $this->day);
return $value;
} | [
"public",
"function",
"getValue",
"(",
")",
"{",
"$",
"value",
"=",
"sprintf",
"(",
"\"%04d-%02d-%02d\"",
",",
"$",
"this",
"->",
"year",
",",
"$",
"this",
"->",
"month",
",",
"$",
"this",
"->",
"day",
")",
";",
"return",
"$",
"value",
";",
"}"
] | Get the value of this Date as an ISO string
@param void
@return string | [
"Get",
"the",
"value",
"of",
"this",
"Date",
"as",
"an",
"ISO",
"string"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Util/Date.php#L57-L62 |
8,712 | remote-office/libx | src/Util/Date.php | Date.getLocale | public function getLocale()
{
$value = sprintf("%02d-%02d-%04d", $this->day, $this->month, $this->year);
return $value;
} | php | public function getLocale()
{
$value = sprintf("%02d-%02d-%04d", $this->day, $this->month, $this->year);
return $value;
} | [
"public",
"function",
"getLocale",
"(",
")",
"{",
"$",
"value",
"=",
"sprintf",
"(",
"\"%02d-%02d-%04d\"",
",",
"$",
"this",
"->",
"day",
",",
"$",
"this",
"->",
"month",
",",
"$",
"this",
"->",
"year",
")",
";",
"return",
"$",
"value",
";",
"}"
] | Get the value of this Date as a locale string
@param void
@return string | [
"Get",
"the",
"value",
"of",
"this",
"Date",
"as",
"a",
"locale",
"string"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Util/Date.php#L70-L75 |
8,713 | remote-office/libx | src/Util/Date.php | Date.setDate | public function setDate($year, $month, $day)
{
// Validate
self::validateDate($year, $month, $day);
// Set internal year, month and day variables
$this->year = (int)$year;
$this->month = (int)$month;
$this->day = (int)$day;
} | php | public function setDate($year, $month, $day)
{
// Validate
self::validateDate($year, $month, $day);
// Set internal year, month and day variables
$this->year = (int)$year;
$this->month = (int)$month;
$this->day = (int)$day;
} | [
"public",
"function",
"setDate",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
"{",
"// Validate",
"self",
"::",
"validateDate",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
";",
"// Set internal year, month and day variables",
"$",
"this",
"->",
"year",
"=",
"(",
"int",
")",
"$",
"year",
";",
"$",
"this",
"->",
"month",
"=",
"(",
"int",
")",
"$",
"month",
";",
"$",
"this",
"->",
"day",
"=",
"(",
"int",
")",
"$",
"day",
";",
"}"
] | Set the date represented by this Date
@param integer $year
@param integer $month
@param integer $day
@return void | [
"Set",
"the",
"date",
"represented",
"by",
"this",
"Date"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Util/Date.php#L85-L94 |
8,714 | remote-office/libx | src/Util/Date.php | Date.validate | static public function validate($date)
{
// Check if date is a string
if(is_string($date) && strlen(trim($date)) > 0)
return false;
// Check if date matches pattern
if(!preg_match('/^' . self::PATTERN . '$/', $date, $matches))
return false;
// Extract values from date
list($original, $year, $month, $day) = $matches;
// Check if all values are valid
if(!self::validateDate($year, $month, $day))
return false;
return true;
} | php | static public function validate($date)
{
// Check if date is a string
if(is_string($date) && strlen(trim($date)) > 0)
return false;
// Check if date matches pattern
if(!preg_match('/^' . self::PATTERN . '$/', $date, $matches))
return false;
// Extract values from date
list($original, $year, $month, $day) = $matches;
// Check if all values are valid
if(!self::validateDate($year, $month, $day))
return false;
return true;
} | [
"static",
"public",
"function",
"validate",
"(",
"$",
"date",
")",
"{",
"// Check if date is a string",
"if",
"(",
"is_string",
"(",
"$",
"date",
")",
"&&",
"strlen",
"(",
"trim",
"(",
"$",
"date",
")",
")",
">",
"0",
")",
"return",
"false",
";",
"// Check if date matches pattern",
"if",
"(",
"!",
"preg_match",
"(",
"'/^'",
".",
"self",
"::",
"PATTERN",
".",
"'$/'",
",",
"$",
"date",
",",
"$",
"matches",
")",
")",
"return",
"false",
";",
"// Extract values from date",
"list",
"(",
"$",
"original",
",",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
"=",
"$",
"matches",
";",
"// Check if all values are valid",
"if",
"(",
"!",
"self",
"::",
"validateDate",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | Validate if a string is a date
@param string $date
@return boolean true if string is a date, false otherwise | [
"Validate",
"if",
"a",
"string",
"is",
"a",
"date"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Util/Date.php#L117-L135 |
8,715 | calgamo/event-loop | src/EventLoop.php | EventLoop.run | public function run(string $startup_event, $startup_data = null)
{
$event = new Event($startup_event, $startup_data);
$ctx = new EventContext($event, $this->event_queue);
$loop_exit = $this->loop_exit ?? function (int $counter){
return $counter > $this->max_loop_count;
};
$loop_counter = 0;
while($event && !($loop_exit)($loop_counter, $this->event_queue))
{
foreach($this->workers as $worker)
{
if ($worker instanceof WorkerInterface){
// dispatch event to worker
if (self::isProcessEventGenerator($worker)){
foreach($worker->processEvent($ctx) as $event){
$ctx->setEvent($event);
$this->dispatchImmediateEvent($ctx);
}
}
else{
$worker->processEvent($ctx);
}
}
else if (is_callable($worker)){
// callback worker routine
if (self::isFunctionGenerator($worker)){
foreach(($worker)($ctx) as $event){
$ctx->setEvent($event);
$this->dispatchImmediateEvent($ctx);
}
}
else{
($worker)($ctx);
}
}
// remove singlecast event
if ($event->isConsumed() && !$event->isMulticast()){
break;
}
}
if ($event->isConsumed()) {
$this->event_queue->dequeue($event);
$ctx->setEvent($event);
}
$loop_counter ++;
}
} | php | public function run(string $startup_event, $startup_data = null)
{
$event = new Event($startup_event, $startup_data);
$ctx = new EventContext($event, $this->event_queue);
$loop_exit = $this->loop_exit ?? function (int $counter){
return $counter > $this->max_loop_count;
};
$loop_counter = 0;
while($event && !($loop_exit)($loop_counter, $this->event_queue))
{
foreach($this->workers as $worker)
{
if ($worker instanceof WorkerInterface){
// dispatch event to worker
if (self::isProcessEventGenerator($worker)){
foreach($worker->processEvent($ctx) as $event){
$ctx->setEvent($event);
$this->dispatchImmediateEvent($ctx);
}
}
else{
$worker->processEvent($ctx);
}
}
else if (is_callable($worker)){
// callback worker routine
if (self::isFunctionGenerator($worker)){
foreach(($worker)($ctx) as $event){
$ctx->setEvent($event);
$this->dispatchImmediateEvent($ctx);
}
}
else{
($worker)($ctx);
}
}
// remove singlecast event
if ($event->isConsumed() && !$event->isMulticast()){
break;
}
}
if ($event->isConsumed()) {
$this->event_queue->dequeue($event);
$ctx->setEvent($event);
}
$loop_counter ++;
}
} | [
"public",
"function",
"run",
"(",
"string",
"$",
"startup_event",
",",
"$",
"startup_data",
"=",
"null",
")",
"{",
"$",
"event",
"=",
"new",
"Event",
"(",
"$",
"startup_event",
",",
"$",
"startup_data",
")",
";",
"$",
"ctx",
"=",
"new",
"EventContext",
"(",
"$",
"event",
",",
"$",
"this",
"->",
"event_queue",
")",
";",
"$",
"loop_exit",
"=",
"$",
"this",
"->",
"loop_exit",
"??",
"function",
"(",
"int",
"$",
"counter",
")",
"{",
"return",
"$",
"counter",
">",
"$",
"this",
"->",
"max_loop_count",
";",
"}",
";",
"$",
"loop_counter",
"=",
"0",
";",
"while",
"(",
"$",
"event",
"&&",
"!",
"(",
"$",
"loop_exit",
")",
"(",
"$",
"loop_counter",
",",
"$",
"this",
"->",
"event_queue",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"workers",
"as",
"$",
"worker",
")",
"{",
"if",
"(",
"$",
"worker",
"instanceof",
"WorkerInterface",
")",
"{",
"// dispatch event to worker",
"if",
"(",
"self",
"::",
"isProcessEventGenerator",
"(",
"$",
"worker",
")",
")",
"{",
"foreach",
"(",
"$",
"worker",
"->",
"processEvent",
"(",
"$",
"ctx",
")",
"as",
"$",
"event",
")",
"{",
"$",
"ctx",
"->",
"setEvent",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"dispatchImmediateEvent",
"(",
"$",
"ctx",
")",
";",
"}",
"}",
"else",
"{",
"$",
"worker",
"->",
"processEvent",
"(",
"$",
"ctx",
")",
";",
"}",
"}",
"else",
"if",
"(",
"is_callable",
"(",
"$",
"worker",
")",
")",
"{",
"// callback worker routine",
"if",
"(",
"self",
"::",
"isFunctionGenerator",
"(",
"$",
"worker",
")",
")",
"{",
"foreach",
"(",
"(",
"$",
"worker",
")",
"(",
"$",
"ctx",
")",
"as",
"$",
"event",
")",
"{",
"$",
"ctx",
"->",
"setEvent",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"dispatchImmediateEvent",
"(",
"$",
"ctx",
")",
";",
"}",
"}",
"else",
"{",
"(",
"$",
"worker",
")",
"(",
"$",
"ctx",
")",
";",
"}",
"}",
"// remove singlecast event",
"if",
"(",
"$",
"event",
"->",
"isConsumed",
"(",
")",
"&&",
"!",
"$",
"event",
"->",
"isMulticast",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"event",
"->",
"isConsumed",
"(",
")",
")",
"{",
"$",
"this",
"->",
"event_queue",
"->",
"dequeue",
"(",
"$",
"event",
")",
";",
"$",
"ctx",
"->",
"setEvent",
"(",
"$",
"event",
")",
";",
"}",
"$",
"loop_counter",
"++",
";",
"}",
"}"
] | Process event loop
@param string $startup_event
@param mixed $startup_data | [
"Process",
"event",
"loop"
] | f85a9c153f2548a94ddc58334c001f241dd8f12d | https://github.com/calgamo/event-loop/blob/f85a9c153f2548a94ddc58334c001f241dd8f12d/src/EventLoop.php#L66-L117 |
8,716 | unyx/diagnostics | debug/handlers/Exception.php | Exception.register | public static function register(interfaces\handlers\Exception $handler = null) : Exception
{
set_exception_handler([$handler ?: $handler = new static, 'handle']);
return $handler;
} | php | public static function register(interfaces\handlers\Exception $handler = null) : Exception
{
set_exception_handler([$handler ?: $handler = new static, 'handle']);
return $handler;
} | [
"public",
"static",
"function",
"register",
"(",
"interfaces",
"\\",
"handlers",
"\\",
"Exception",
"$",
"handler",
"=",
"null",
")",
":",
"Exception",
"{",
"set_exception_handler",
"(",
"[",
"$",
"handler",
"?",
":",
"$",
"handler",
"=",
"new",
"static",
",",
"'handle'",
"]",
")",
";",
"return",
"$",
"handler",
";",
"}"
] | Registers the given or this Exception Handler with PHP.
@param interfaces\handlers\Exception $handler An optional, already instantiated Exception Handler
instance. If none is given, a new one will be
instantiated.
@return Exception An instance of the Exception Handler which got registered.
Either the same as the given one or if none was given,
a new instance. | [
"Registers",
"the",
"given",
"or",
"this",
"Exception",
"Handler",
"with",
"PHP",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/handlers/Exception.php#L73-L78 |
8,717 | unyx/diagnostics | debug/handlers/Exception.php | Exception.add | public function add($delegate, string $name = null, int $priority = 0) : self
{
// Which name should we use?
// Micro-optimization note: mt_rand() turned out to be several times faster than uniqid and somewhat
// faster than counting the current number of delegates.
$name = $name ?: ($delegate instanceof interfaces\Delegate ? get_class($delegate) : 'c\\'.mt_rand());
if (isset($this->delegates[$name])) {
throw new \OverflowException("A Delegate with the given name [$name] is already set.");
}
return $this->set($name, $delegate, $priority);
} | php | public function add($delegate, string $name = null, int $priority = 0) : self
{
// Which name should we use?
// Micro-optimization note: mt_rand() turned out to be several times faster than uniqid and somewhat
// faster than counting the current number of delegates.
$name = $name ?: ($delegate instanceof interfaces\Delegate ? get_class($delegate) : 'c\\'.mt_rand());
if (isset($this->delegates[$name])) {
throw new \OverflowException("A Delegate with the given name [$name] is already set.");
}
return $this->set($name, $delegate, $priority);
} | [
"public",
"function",
"add",
"(",
"$",
"delegate",
",",
"string",
"$",
"name",
"=",
"null",
",",
"int",
"$",
"priority",
"=",
"0",
")",
":",
"self",
"{",
"// Which name should we use?",
"// Micro-optimization note: mt_rand() turned out to be several times faster than uniqid and somewhat",
"// faster than counting the current number of delegates.",
"$",
"name",
"=",
"$",
"name",
"?",
":",
"(",
"$",
"delegate",
"instanceof",
"interfaces",
"\\",
"Delegate",
"?",
"get_class",
"(",
"$",
"delegate",
")",
":",
"'c\\\\'",
".",
"mt_rand",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"delegates",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"OverflowException",
"(",
"\"A Delegate with the given name [$name] is already set.\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"delegate",
",",
"$",
"priority",
")",
";",
"}"
] | Adds the given Delegate with the given optional priority to the stack.
@param interfaces\Delegate|callable $delegate The Delegate to be inserted into the stack.
@param string $name The name of the Delegate. Has to be unique. If none is
given, the full (ie. with namespace) classname will be
be for Delegates and "c\{mt_rand()}" for callables.
*Also* has to be unique. In other words - If you add an
instance of the same class (or even the same instance)
multiple times, assign different names.
@param int $priority The priority at which the Delegate should be invoked
when an exception gets handled.
Also {@see self::getHighestPriority()}.
@return $this
@throws \OverflowException When the given name (or when not given, the class name)
is already set. | [
"Adds",
"the",
"given",
"Delegate",
"with",
"the",
"given",
"optional",
"priority",
"to",
"the",
"stack",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/handlers/Exception.php#L210-L222 |
8,718 | unyx/diagnostics | debug/handlers/Exception.php | Exception.remove | public function remove($delegate, bool $all = true) : self
{
// When a string was passed, we will need to distinguish what to compare within our search.
$name = is_string($delegate) ? $delegate : null;
foreach ($this->delegates as $k => $v) {
if (($name and $k === $name) or (!$name and $v['delegate'] === $delegate)) {
unset($this->delegates[$k]);
$this->applicable = null;
if ($name or false === $all) {
break;
}
}
}
return $this;
} | php | public function remove($delegate, bool $all = true) : self
{
// When a string was passed, we will need to distinguish what to compare within our search.
$name = is_string($delegate) ? $delegate : null;
foreach ($this->delegates as $k => $v) {
if (($name and $k === $name) or (!$name and $v['delegate'] === $delegate)) {
unset($this->delegates[$k]);
$this->applicable = null;
if ($name or false === $all) {
break;
}
}
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"delegate",
",",
"bool",
"$",
"all",
"=",
"true",
")",
":",
"self",
"{",
"// When a string was passed, we will need to distinguish what to compare within our search.",
"$",
"name",
"=",
"is_string",
"(",
"$",
"delegate",
")",
"?",
"$",
"delegate",
":",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"delegates",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"(",
"$",
"name",
"and",
"$",
"k",
"===",
"$",
"name",
")",
"or",
"(",
"!",
"$",
"name",
"and",
"$",
"v",
"[",
"'delegate'",
"]",
"===",
"$",
"delegate",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"delegates",
"[",
"$",
"k",
"]",
")",
";",
"$",
"this",
"->",
"applicable",
"=",
"null",
";",
"if",
"(",
"$",
"name",
"or",
"false",
"===",
"$",
"all",
")",
"{",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes a specific Delegate or callable from the stack.
Important note: This will remove all *instances* of the given Delegate if it passes the strict match unless
$all is set to false *or* a name is used instead of an instance as the first argument to this method, since
Delegate names are unique within this Handler.
@param string|interfaces\Delegate|callable $delegate Either the name of the Delegate/callable or
an actual instance to search for.
@param bool $all Whether to search for all matches (true) or stop
after the first match (false).
@return $this | [
"Removes",
"a",
"specific",
"Delegate",
"or",
"callable",
"from",
"the",
"stack",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/handlers/Exception.php#L237-L254 |
8,719 | unyx/diagnostics | debug/handlers/Exception.php | Exception.sort | protected function sort(array &$delegates) : self
{
uasort($delegates, function($a, $b) {
return $b['priority'] - $a['priority'];
});
return $this;
} | php | protected function sort(array &$delegates) : self
{
uasort($delegates, function($a, $b) {
return $b['priority'] - $a['priority'];
});
return $this;
} | [
"protected",
"function",
"sort",
"(",
"array",
"&",
"$",
"delegates",
")",
":",
"self",
"{",
"uasort",
"(",
"$",
"delegates",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"$",
"b",
"[",
"'priority'",
"]",
"-",
"$",
"a",
"[",
"'priority'",
"]",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sorts the given Delegates by their priority, highest first.
@param array &$delegates The Delegates to sort.
@return $this | [
"Sorts",
"the",
"given",
"Delegates",
"by",
"their",
"priority",
"highest",
"first",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/handlers/Exception.php#L407-L414 |
8,720 | unyx/diagnostics | debug/handlers/Exception.php | Exception.pushToList | protected function pushToList(array &$list, $name) : self
{
// Handle arrays (recursively).
if (is_array($name)) {
foreach ($name as $single) {
$this->pushToList($list, $single);
}
return $this;
}
$list[] = $name;
// Reset the applicable Delegates as we will need to recompile the list.
$this->applicable = null;
return $this;
} | php | protected function pushToList(array &$list, $name) : self
{
// Handle arrays (recursively).
if (is_array($name)) {
foreach ($name as $single) {
$this->pushToList($list, $single);
}
return $this;
}
$list[] = $name;
// Reset the applicable Delegates as we will need to recompile the list.
$this->applicable = null;
return $this;
} | [
"protected",
"function",
"pushToList",
"(",
"array",
"&",
"$",
"list",
",",
"$",
"name",
")",
":",
"self",
"{",
"// Handle arrays (recursively).",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"foreach",
"(",
"$",
"name",
"as",
"$",
"single",
")",
"{",
"$",
"this",
"->",
"pushToList",
"(",
"$",
"list",
",",
"$",
"single",
")",
";",
"}",
"return",
"$",
"this",
";",
"}",
"$",
"list",
"[",
"]",
"=",
"$",
"name",
";",
"// Reset the applicable Delegates as we will need to recompile the list.",
"$",
"this",
"->",
"applicable",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Pushes the given values to either the black-or-white-list.
@param array &$list Either $this->blacklist or $this->whitelist.
@param string|array $name {@see self::blacklist()} or {@see self::whitelist()}
@return $this | [
"Pushes",
"the",
"given",
"values",
"to",
"either",
"the",
"black",
"-",
"or",
"-",
"white",
"-",
"list",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/handlers/Exception.php#L423-L439 |
8,721 | unyx/diagnostics | debug/handlers/Exception.php | Exception.compileList | protected function compileList(array &$list, array $delegates)
{
$return = [];
foreach ($list as $name) {
$return[] = preg_grep('/'.$name.'/', $delegates);
}
return call_user_func_array('array_merge', $return);
} | php | protected function compileList(array &$list, array $delegates)
{
$return = [];
foreach ($list as $name) {
$return[] = preg_grep('/'.$name.'/', $delegates);
}
return call_user_func_array('array_merge', $return);
} | [
"protected",
"function",
"compileList",
"(",
"array",
"&",
"$",
"list",
",",
"array",
"$",
"delegates",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"name",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"preg_grep",
"(",
"'/'",
".",
"$",
"name",
".",
"'/'",
",",
"$",
"delegates",
")",
";",
"}",
"return",
"call_user_func_array",
"(",
"'array_merge'",
",",
"$",
"return",
")",
";",
"}"
] | Compiles the given black-or-white-list based on the given Delegate names, ie. run regex matches against
the Delegate names.
@param array &$list Either $this->blacklist or $this->whitelist.
@param array $delegates An array of Delegate names that should be considered.
@return array The compiled List. | [
"Compiles",
"the",
"given",
"black",
"-",
"or",
"-",
"white",
"-",
"list",
"based",
"on",
"the",
"given",
"Delegate",
"names",
"ie",
".",
"run",
"regex",
"matches",
"against",
"the",
"Delegate",
"names",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/handlers/Exception.php#L449-L458 |
8,722 | lbausch/laravel-cornerstone | src/Http/Controllers/CornerstoneController.php | CornerstoneController.getTitle | public function getTitle()
{
$title = $this->title;
if (isset($this->title_suffix)) {
$title = $title.$this->title_suffix;
}
if (isset($this->title_prefix)) {
$title = $this->title_prefix.$title;
}
return $title;
} | php | public function getTitle()
{
$title = $this->title;
if (isset($this->title_suffix)) {
$title = $title.$this->title_suffix;
}
if (isset($this->title_prefix)) {
$title = $this->title_prefix.$title;
}
return $title;
} | [
"public",
"function",
"getTitle",
"(",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"title",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"title_suffix",
")",
")",
"{",
"$",
"title",
"=",
"$",
"title",
".",
"$",
"this",
"->",
"title_suffix",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"title_prefix",
")",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"title_prefix",
".",
"$",
"title",
";",
"}",
"return",
"$",
"title",
";",
"}"
] | Get title.
@return string | [
"Get",
"title",
"."
] | c0907c5e3dce1737bfa5dac30e6bb89f448d15f3 | https://github.com/lbausch/laravel-cornerstone/blob/c0907c5e3dce1737bfa5dac30e6bb89f448d15f3/src/Http/Controllers/CornerstoneController.php#L37-L50 |
8,723 | easy-system/es-http | src/Factory/UploadedFilesFactory.php | UploadedFilesFactory.normalize | protected static function normalize(array $files)
{
$normalized = [];
foreach ($files as $key => $value) {
if ($value instanceof UploadedFileInterface) {
$normalized[$key] = $value;
continue;
}
if (! is_array($value)) {
throw new InvalidArgumentException(
'Invalid value in files specification.'
);
}
if (isset($value['tmp_name'])) {
$normalized[$key] = static::build($value);
continue;
}
$normalized[$key] = static::normalize($value);
}
return $normalized;
} | php | protected static function normalize(array $files)
{
$normalized = [];
foreach ($files as $key => $value) {
if ($value instanceof UploadedFileInterface) {
$normalized[$key] = $value;
continue;
}
if (! is_array($value)) {
throw new InvalidArgumentException(
'Invalid value in files specification.'
);
}
if (isset($value['tmp_name'])) {
$normalized[$key] = static::build($value);
continue;
}
$normalized[$key] = static::normalize($value);
}
return $normalized;
} | [
"protected",
"static",
"function",
"normalize",
"(",
"array",
"$",
"files",
")",
"{",
"$",
"normalized",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"UploadedFileInterface",
")",
"{",
"$",
"normalized",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid value in files specification.'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"value",
"[",
"'tmp_name'",
"]",
")",
")",
"{",
"$",
"normalized",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"build",
"(",
"$",
"value",
")",
";",
"continue",
";",
"}",
"$",
"normalized",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"normalize",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"normalized",
";",
"}"
] | Normalizes the array.
@param array $files The array with specifications of uploaded files
@throws \InvalidArgumentException If invalid value present in
files specification
@return array The normalized array | [
"Normalizes",
"the",
"array",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Factory/UploadedFilesFactory.php#L48-L74 |
8,724 | easy-system/es-http | src/Factory/UploadedFilesFactory.php | UploadedFilesFactory.build | protected static function build(array $file)
{
if (is_array($file['tmp_name'])) {
return static::normalizeNested($file);
}
return new UploadedFile(
$file['name'],
$file['tmp_name'],
$file['type'],
$file['size'],
$file['error']
);
} | php | protected static function build(array $file)
{
if (is_array($file['tmp_name'])) {
return static::normalizeNested($file);
}
return new UploadedFile(
$file['name'],
$file['tmp_name'],
$file['type'],
$file['size'],
$file['error']
);
} | [
"protected",
"static",
"function",
"build",
"(",
"array",
"$",
"file",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"file",
"[",
"'tmp_name'",
"]",
")",
")",
"{",
"return",
"static",
"::",
"normalizeNested",
"(",
"$",
"file",
")",
";",
"}",
"return",
"new",
"UploadedFile",
"(",
"$",
"file",
"[",
"'name'",
"]",
",",
"$",
"file",
"[",
"'tmp_name'",
"]",
",",
"$",
"file",
"[",
"'type'",
"]",
",",
"$",
"file",
"[",
"'size'",
"]",
",",
"$",
"file",
"[",
"'error'",
"]",
")",
";",
"}"
] | Builds the uploaded file from specification.
@param array $file The specification of uploaded file or a nested array
@return \Es\Http\UploadedFile The uploaded file | [
"Builds",
"the",
"uploaded",
"file",
"from",
"specification",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Factory/UploadedFilesFactory.php#L83-L96 |
8,725 | easy-system/es-http | src/Factory/UploadedFilesFactory.php | UploadedFilesFactory.normalizeNested | protected static function normalizeNested(array $files)
{
$normalized = [];
foreach (array_keys($files['tmp_name']) as $key) {
$spec = [
'name' => $files['name'][$key],
'tmp_name' => $files['tmp_name'][$key],
'type' => $files['type'][$key],
'size' => $files['size'][$key],
'error' => $files['error'][$key],
];
$normalized[$key] = static::build($spec);
}
return $normalized;
} | php | protected static function normalizeNested(array $files)
{
$normalized = [];
foreach (array_keys($files['tmp_name']) as $key) {
$spec = [
'name' => $files['name'][$key],
'tmp_name' => $files['tmp_name'][$key],
'type' => $files['type'][$key],
'size' => $files['size'][$key],
'error' => $files['error'][$key],
];
$normalized[$key] = static::build($spec);
}
return $normalized;
} | [
"protected",
"static",
"function",
"normalizeNested",
"(",
"array",
"$",
"files",
")",
"{",
"$",
"normalized",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"files",
"[",
"'tmp_name'",
"]",
")",
"as",
"$",
"key",
")",
"{",
"$",
"spec",
"=",
"[",
"'name'",
"=>",
"$",
"files",
"[",
"'name'",
"]",
"[",
"$",
"key",
"]",
",",
"'tmp_name'",
"=>",
"$",
"files",
"[",
"'tmp_name'",
"]",
"[",
"$",
"key",
"]",
",",
"'type'",
"=>",
"$",
"files",
"[",
"'type'",
"]",
"[",
"$",
"key",
"]",
",",
"'size'",
"=>",
"$",
"files",
"[",
"'size'",
"]",
"[",
"$",
"key",
"]",
",",
"'error'",
"=>",
"$",
"files",
"[",
"'error'",
"]",
"[",
"$",
"key",
"]",
",",
"]",
";",
"$",
"normalized",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"build",
"(",
"$",
"spec",
")",
";",
"}",
"return",
"$",
"normalized",
";",
"}"
] | Normalizes a nested array.
@param array $files The nested array
@return array Normalized array | [
"Normalizes",
"a",
"nested",
"array",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Factory/UploadedFilesFactory.php#L105-L120 |
8,726 | flavorzyb/simple | src/Log/Writer.php | Writer.setDirPath | public function setDirPath($dirPath)
{
$dirPath = trim($dirPath);
if ($this->filesystem->isDirectory($dirPath)) {
$this->dirPath = $this->filesystem->realPath($dirPath);
}
} | php | public function setDirPath($dirPath)
{
$dirPath = trim($dirPath);
if ($this->filesystem->isDirectory($dirPath)) {
$this->dirPath = $this->filesystem->realPath($dirPath);
}
} | [
"public",
"function",
"setDirPath",
"(",
"$",
"dirPath",
")",
"{",
"$",
"dirPath",
"=",
"trim",
"(",
"$",
"dirPath",
")",
";",
"if",
"(",
"$",
"this",
"->",
"filesystem",
"->",
"isDirectory",
"(",
"$",
"dirPath",
")",
")",
"{",
"$",
"this",
"->",
"dirPath",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"realPath",
"(",
"$",
"dirPath",
")",
";",
"}",
"}"
] | set the log dir path
@param string $dirPath | [
"set",
"the",
"log",
"dir",
"path"
] | 8c4c539ae2057217b2637fc72c2a90ba266e8e6c | https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Log/Writer.php#L80-L86 |
8,727 | flavorzyb/simple | src/Log/Writer.php | Writer.log | protected function log($type, $msg)
{
$msg = trim($msg);
if ('' == $msg) {
return false;
}
$filesystem = $this->filesystem;
if (!$filesystem->isDirectory($this->dirPath)) {
return false;
}
$type = intval($type);
$subPath = sprintf("%s%s%s%s", date('Y'), DIRECTORY_SEPARATOR, date('m'), DIRECTORY_SEPARATOR);
$file = $this->dirPath . DIRECTORY_SEPARATOR . $subPath;
switch($type) {
case self::TYPE_DEBUG:
$file .= "debug";
$str = "[debug]";
break;
case self::TYPE_INFO:
$file .= "info";
$str = "[info]";
break;
case self::TYPE_NOTICE:
$file .= "notice";
$str = "[notice]";
break;
case self::TYPE_WARNING:
$file .= "warning";
$str = "[warning]";
break;
case self::TYPE_ERROR:
$file .= "error";
$str = "[error]";
break;
case self::TYPE_API:
$file .= "api";
$str = "[api]";
break;
case self::TYPE_DB:
$file .= "db";
$str = "[db]";
break;
// @codeCoverageIgnoreStart
default:
return false;
}
// @codeCoverageIgnoreEnd
$file .= '_' . date('Y_m_d');
$target = $file . '_' . date('His') . '.log';
$file .= '.log';
// check log file size
if ($filesystem->isFile($file) && ($filesystem->size($file) > self::MAX_FILE_SIZE)) {
$filesystem->move($file, $target);
}
// Determine if log dir exists
$dirPath = $filesystem->dirName($file);
if (!$filesystem->isDirectory($dirPath)) {
$filesystem->makeDirectory($dirPath, 0755, true, true);
}
$str .= date('Y-m-d H:i:s') . '|' . $msg . "\n";
return $filesystem->append($file, $str) > 0;
} | php | protected function log($type, $msg)
{
$msg = trim($msg);
if ('' == $msg) {
return false;
}
$filesystem = $this->filesystem;
if (!$filesystem->isDirectory($this->dirPath)) {
return false;
}
$type = intval($type);
$subPath = sprintf("%s%s%s%s", date('Y'), DIRECTORY_SEPARATOR, date('m'), DIRECTORY_SEPARATOR);
$file = $this->dirPath . DIRECTORY_SEPARATOR . $subPath;
switch($type) {
case self::TYPE_DEBUG:
$file .= "debug";
$str = "[debug]";
break;
case self::TYPE_INFO:
$file .= "info";
$str = "[info]";
break;
case self::TYPE_NOTICE:
$file .= "notice";
$str = "[notice]";
break;
case self::TYPE_WARNING:
$file .= "warning";
$str = "[warning]";
break;
case self::TYPE_ERROR:
$file .= "error";
$str = "[error]";
break;
case self::TYPE_API:
$file .= "api";
$str = "[api]";
break;
case self::TYPE_DB:
$file .= "db";
$str = "[db]";
break;
// @codeCoverageIgnoreStart
default:
return false;
}
// @codeCoverageIgnoreEnd
$file .= '_' . date('Y_m_d');
$target = $file . '_' . date('His') . '.log';
$file .= '.log';
// check log file size
if ($filesystem->isFile($file) && ($filesystem->size($file) > self::MAX_FILE_SIZE)) {
$filesystem->move($file, $target);
}
// Determine if log dir exists
$dirPath = $filesystem->dirName($file);
if (!$filesystem->isDirectory($dirPath)) {
$filesystem->makeDirectory($dirPath, 0755, true, true);
}
$str .= date('Y-m-d H:i:s') . '|' . $msg . "\n";
return $filesystem->append($file, $str) > 0;
} | [
"protected",
"function",
"log",
"(",
"$",
"type",
",",
"$",
"msg",
")",
"{",
"$",
"msg",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"if",
"(",
"''",
"==",
"$",
"msg",
")",
"{",
"return",
"false",
";",
"}",
"$",
"filesystem",
"=",
"$",
"this",
"->",
"filesystem",
";",
"if",
"(",
"!",
"$",
"filesystem",
"->",
"isDirectory",
"(",
"$",
"this",
"->",
"dirPath",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"type",
"=",
"intval",
"(",
"$",
"type",
")",
";",
"$",
"subPath",
"=",
"sprintf",
"(",
"\"%s%s%s%s\"",
",",
"date",
"(",
"'Y'",
")",
",",
"DIRECTORY_SEPARATOR",
",",
"date",
"(",
"'m'",
")",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"dirPath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"subPath",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"TYPE_DEBUG",
":",
"$",
"file",
".=",
"\"debug\"",
";",
"$",
"str",
"=",
"\"[debug]\"",
";",
"break",
";",
"case",
"self",
"::",
"TYPE_INFO",
":",
"$",
"file",
".=",
"\"info\"",
";",
"$",
"str",
"=",
"\"[info]\"",
";",
"break",
";",
"case",
"self",
"::",
"TYPE_NOTICE",
":",
"$",
"file",
".=",
"\"notice\"",
";",
"$",
"str",
"=",
"\"[notice]\"",
";",
"break",
";",
"case",
"self",
"::",
"TYPE_WARNING",
":",
"$",
"file",
".=",
"\"warning\"",
";",
"$",
"str",
"=",
"\"[warning]\"",
";",
"break",
";",
"case",
"self",
"::",
"TYPE_ERROR",
":",
"$",
"file",
".=",
"\"error\"",
";",
"$",
"str",
"=",
"\"[error]\"",
";",
"break",
";",
"case",
"self",
"::",
"TYPE_API",
":",
"$",
"file",
".=",
"\"api\"",
";",
"$",
"str",
"=",
"\"[api]\"",
";",
"break",
";",
"case",
"self",
"::",
"TYPE_DB",
":",
"$",
"file",
".=",
"\"db\"",
";",
"$",
"str",
"=",
"\"[db]\"",
";",
"break",
";",
"// @codeCoverageIgnoreStart",
"default",
":",
"return",
"false",
";",
"}",
"// @codeCoverageIgnoreEnd",
"$",
"file",
".=",
"'_'",
".",
"date",
"(",
"'Y_m_d'",
")",
";",
"$",
"target",
"=",
"$",
"file",
".",
"'_'",
".",
"date",
"(",
"'His'",
")",
".",
"'.log'",
";",
"$",
"file",
".=",
"'.log'",
";",
"// check log file size",
"if",
"(",
"$",
"filesystem",
"->",
"isFile",
"(",
"$",
"file",
")",
"&&",
"(",
"$",
"filesystem",
"->",
"size",
"(",
"$",
"file",
")",
">",
"self",
"::",
"MAX_FILE_SIZE",
")",
")",
"{",
"$",
"filesystem",
"->",
"move",
"(",
"$",
"file",
",",
"$",
"target",
")",
";",
"}",
"// Determine if log dir exists",
"$",
"dirPath",
"=",
"$",
"filesystem",
"->",
"dirName",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"$",
"filesystem",
"->",
"isDirectory",
"(",
"$",
"dirPath",
")",
")",
"{",
"$",
"filesystem",
"->",
"makeDirectory",
"(",
"$",
"dirPath",
",",
"0755",
",",
"true",
",",
"true",
")",
";",
"}",
"$",
"str",
".=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
".",
"'|'",
".",
"$",
"msg",
".",
"\"\\n\"",
";",
"return",
"$",
"filesystem",
"->",
"append",
"(",
"$",
"file",
",",
"$",
"str",
")",
">",
"0",
";",
"}"
] | write log to file
@param int $type
@param string $msg
@return boolean | [
"write",
"log",
"to",
"file"
] | 8c4c539ae2057217b2637fc72c2a90ba266e8e6c | https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Log/Writer.php#L103-L170 |
8,728 | northern/PHP-Common | src/Northern/Common/Util/TokenUtil.php | TokenUtil.getNonce | public static function getNonce($length = 32)
{
do {
$entropy = openssl_random_pseudo_bytes($length, $strong);
} while ($strong === false);
$nonce = sha1($entropy);
return $nonce;
} | php | public static function getNonce($length = 32)
{
do {
$entropy = openssl_random_pseudo_bytes($length, $strong);
} while ($strong === false);
$nonce = sha1($entropy);
return $nonce;
} | [
"public",
"static",
"function",
"getNonce",
"(",
"$",
"length",
"=",
"32",
")",
"{",
"do",
"{",
"$",
"entropy",
"=",
"openssl_random_pseudo_bytes",
"(",
"$",
"length",
",",
"$",
"strong",
")",
";",
"}",
"while",
"(",
"$",
"strong",
"===",
"false",
")",
";",
"$",
"nonce",
"=",
"sha1",
"(",
"$",
"entropy",
")",
";",
"return",
"$",
"nonce",
";",
"}"
] | This method will generate a pseudo random SHA1 that can be used as nonce or
other kind of token. To specifiy the length of the token use the length
parameter.
@param int $length | [
"This",
"method",
"will",
"generate",
"a",
"pseudo",
"random",
"SHA1",
"that",
"can",
"be",
"used",
"as",
"nonce",
"or",
"other",
"kind",
"of",
"token",
".",
"To",
"specifiy",
"the",
"length",
"of",
"the",
"token",
"use",
"the",
"length",
"parameter",
"."
] | 7c63ef19252fd540fb412a18af956b8563afaa55 | https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/TokenUtil.php#L32-L41 |
8,729 | mszewcz/php-light-framework | src/Variables/Specific/Get.php | Get.buildString | public function buildString(array $variables = [], bool $useExisting = true): string
{
if ($useExisting === true) {
$variables = \array_merge($this->variables, $variables);
}
$tmp = [];
foreach ($variables as $name => $val) {
if ($val !== null) {
$tmp[] = $name.'='.\urlencode((string)$val);
}
}
$ret = '';
if (\count($tmp) > 0) {
$ret .= '?'.\implode('&', $tmp);
}
return $ret;
} | php | public function buildString(array $variables = [], bool $useExisting = true): string
{
if ($useExisting === true) {
$variables = \array_merge($this->variables, $variables);
}
$tmp = [];
foreach ($variables as $name => $val) {
if ($val !== null) {
$tmp[] = $name.'='.\urlencode((string)$val);
}
}
$ret = '';
if (\count($tmp) > 0) {
$ret .= '?'.\implode('&', $tmp);
}
return $ret;
} | [
"public",
"function",
"buildString",
"(",
"array",
"$",
"variables",
"=",
"[",
"]",
",",
"bool",
"$",
"useExisting",
"=",
"true",
")",
":",
"string",
"{",
"if",
"(",
"$",
"useExisting",
"===",
"true",
")",
"{",
"$",
"variables",
"=",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"variables",
",",
"$",
"variables",
")",
";",
"}",
"$",
"tmp",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"variables",
"as",
"$",
"name",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"!==",
"null",
")",
"{",
"$",
"tmp",
"[",
"]",
"=",
"$",
"name",
".",
"'='",
".",
"\\",
"urlencode",
"(",
"(",
"string",
")",
"$",
"val",
")",
";",
"}",
"}",
"$",
"ret",
"=",
"''",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"tmp",
")",
">",
"0",
")",
"{",
"$",
"ret",
".=",
"'?'",
".",
"\\",
"implode",
"(",
"'&'",
",",
"$",
"tmp",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Builds GET variables string.
@param array $variables
@param bool $useExisting
@return string | [
"Builds",
"GET",
"variables",
"string",
"."
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Variables/Specific/Get.php#L73-L91 |
8,730 | synapsestudios/synapse-base | src/Synapse/Mapper/DeleterTrait.php | DeleterTrait.deleteWhere | public function deleteWhere(array $wheres)
{
$query = $this->getSqlObject()
->delete()
->where($wheres);
return $this->execute($query);
} | php | public function deleteWhere(array $wheres)
{
$query = $this->getSqlObject()
->delete()
->where($wheres);
return $this->execute($query);
} | [
"public",
"function",
"deleteWhere",
"(",
"array",
"$",
"wheres",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getSqlObject",
"(",
")",
"->",
"delete",
"(",
")",
"->",
"where",
"(",
"$",
"wheres",
")",
";",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"query",
")",
";",
"}"
] | Delete all records in this table that meet the provided conditions
@param array $wheres An array of where conditions in the format: ['column' => 'value']
@return Result | [
"Delete",
"all",
"records",
"in",
"this",
"table",
"that",
"meet",
"the",
"provided",
"conditions"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Mapper/DeleterTrait.php#L29-L36 |
8,731 | IVIR3zaM/ObjectArrayTools | src/Traits/ArrayAccessTrait.php | ArrayAccessTrait.offsetGet | public function offsetGet($offset)
{
if ($this->offsetExists($offset) &&
$this->internalFilterHooks($offset, $this->baseConcreteData[$offset], 'output')
) {
return $this->internalSanitizeHooks($offset, $this->baseConcreteData[$offset], 'output');
}
} | php | public function offsetGet($offset)
{
if ($this->offsetExists($offset) &&
$this->internalFilterHooks($offset, $this->baseConcreteData[$offset], 'output')
) {
return $this->internalSanitizeHooks($offset, $this->baseConcreteData[$offset], 'output');
}
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"offset",
")",
"&&",
"$",
"this",
"->",
"internalFilterHooks",
"(",
"$",
"offset",
",",
"$",
"this",
"->",
"baseConcreteData",
"[",
"$",
"offset",
"]",
",",
"'output'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"internalSanitizeHooks",
"(",
"$",
"offset",
",",
"$",
"this",
"->",
"baseConcreteData",
"[",
"$",
"offset",
"]",
",",
"'output'",
")",
";",
"}",
"}"
] | this is necessary for ArrayAccess Interface and return and element by offset
@param $offset
@return mixed the element data or null if it not exists | [
"this",
"is",
"necessary",
"for",
"ArrayAccess",
"Interface",
"and",
"return",
"and",
"element",
"by",
"offset"
] | 31c12fc6f8a40a36873c074409ae4299b35f9177 | https://github.com/IVIR3zaM/ObjectArrayTools/blob/31c12fc6f8a40a36873c074409ae4299b35f9177/src/Traits/ArrayAccessTrait.php#L39-L46 |
8,732 | IVIR3zaM/ObjectArrayTools | src/Traits/ArrayAccessTrait.php | ArrayAccessTrait.offsetSet | public function offsetSet($offset, $value)
{
if (!is_scalar($offset) && !is_null($offset)) {
return;
}
$isNew = $this->offsetIsNew($offset);
$oldData = $isNew ? null : $this->offsetGet($offset);
$index = $isNew ? $this->arrayAccessMapIndex++ : array_search($offset, $this->baseArrayMap);
$hook = $isNew ? 'insert' : 'update';
if (is_null($offset)) {
$offset = $this->arrayAccessConcreteIndex;
}
//filtering the key ($offset) based on http://www.php.net/manual/en/language.types.array.php
$offset = is_numeric($offset) || is_bool($offset) ? intval($offset) : (string)$offset;
if (!$this->internalFilterHooks($offset, $value, 'input')) {
return;
}
if (is_numeric($offset) && $offset >= $this->arrayAccessConcreteIndex) {
$this->arrayAccessConcreteIndex = $offset + 1;
}
$value = $this->internalSanitizeHooks($offset, $value, 'input');
$this->baseConcreteData[$offset] = $value;
$this->baseArrayMap[$index] = $offset;
$this->internalChangingHooks($offset, $value, $oldData, $hook);
} | php | public function offsetSet($offset, $value)
{
if (!is_scalar($offset) && !is_null($offset)) {
return;
}
$isNew = $this->offsetIsNew($offset);
$oldData = $isNew ? null : $this->offsetGet($offset);
$index = $isNew ? $this->arrayAccessMapIndex++ : array_search($offset, $this->baseArrayMap);
$hook = $isNew ? 'insert' : 'update';
if (is_null($offset)) {
$offset = $this->arrayAccessConcreteIndex;
}
//filtering the key ($offset) based on http://www.php.net/manual/en/language.types.array.php
$offset = is_numeric($offset) || is_bool($offset) ? intval($offset) : (string)$offset;
if (!$this->internalFilterHooks($offset, $value, 'input')) {
return;
}
if (is_numeric($offset) && $offset >= $this->arrayAccessConcreteIndex) {
$this->arrayAccessConcreteIndex = $offset + 1;
}
$value = $this->internalSanitizeHooks($offset, $value, 'input');
$this->baseConcreteData[$offset] = $value;
$this->baseArrayMap[$index] = $offset;
$this->internalChangingHooks($offset, $value, $oldData, $hook);
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"offset",
")",
"&&",
"!",
"is_null",
"(",
"$",
"offset",
")",
")",
"{",
"return",
";",
"}",
"$",
"isNew",
"=",
"$",
"this",
"->",
"offsetIsNew",
"(",
"$",
"offset",
")",
";",
"$",
"oldData",
"=",
"$",
"isNew",
"?",
"null",
":",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"offset",
")",
";",
"$",
"index",
"=",
"$",
"isNew",
"?",
"$",
"this",
"->",
"arrayAccessMapIndex",
"++",
":",
"array_search",
"(",
"$",
"offset",
",",
"$",
"this",
"->",
"baseArrayMap",
")",
";",
"$",
"hook",
"=",
"$",
"isNew",
"?",
"'insert'",
":",
"'update'",
";",
"if",
"(",
"is_null",
"(",
"$",
"offset",
")",
")",
"{",
"$",
"offset",
"=",
"$",
"this",
"->",
"arrayAccessConcreteIndex",
";",
"}",
"//filtering the key ($offset) based on http://www.php.net/manual/en/language.types.array.php",
"$",
"offset",
"=",
"is_numeric",
"(",
"$",
"offset",
")",
"||",
"is_bool",
"(",
"$",
"offset",
")",
"?",
"intval",
"(",
"$",
"offset",
")",
":",
"(",
"string",
")",
"$",
"offset",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"internalFilterHooks",
"(",
"$",
"offset",
",",
"$",
"value",
",",
"'input'",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"offset",
")",
"&&",
"$",
"offset",
">=",
"$",
"this",
"->",
"arrayAccessConcreteIndex",
")",
"{",
"$",
"this",
"->",
"arrayAccessConcreteIndex",
"=",
"$",
"offset",
"+",
"1",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"internalSanitizeHooks",
"(",
"$",
"offset",
",",
"$",
"value",
",",
"'input'",
")",
";",
"$",
"this",
"->",
"baseConcreteData",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"baseArrayMap",
"[",
"$",
"index",
"]",
"=",
"$",
"offset",
";",
"$",
"this",
"->",
"internalChangingHooks",
"(",
"$",
"offset",
",",
"$",
"value",
",",
"$",
"oldData",
",",
"$",
"hook",
")",
";",
"}"
] | this is necessary for ArrayAccess Interface and save and element to array by offset
@param mixed $offset
@param mixed $value
@return void | [
"this",
"is",
"necessary",
"for",
"ArrayAccess",
"Interface",
"and",
"save",
"and",
"element",
"to",
"array",
"by",
"offset"
] | 31c12fc6f8a40a36873c074409ae4299b35f9177 | https://github.com/IVIR3zaM/ObjectArrayTools/blob/31c12fc6f8a40a36873c074409ae4299b35f9177/src/Traits/ArrayAccessTrait.php#L59-L88 |
8,733 | IVIR3zaM/ObjectArrayTools | src/Traits/ArrayAccessTrait.php | ArrayAccessTrait.offsetUnset | public function offsetUnset($offset)
{
if ($this->offsetExists($offset) && $this->internalFilterHooks($offset, null, 'remove')) {
$oldData = $this->offsetGet($offset);
unset($this->baseConcreteData[$offset]);
if (($index = array_search($offset, $this->baseArrayMap, true)) !== false) {
unset($this->baseArrayMap[$index]);
}
$this->baseArrayMap = array_values($this->baseArrayMap);
$this->arrayAccessMapIndex = count($this->baseArrayMap);
$this->internalChangingHooks($offset, null, $oldData, 'remove');
}
} | php | public function offsetUnset($offset)
{
if ($this->offsetExists($offset) && $this->internalFilterHooks($offset, null, 'remove')) {
$oldData = $this->offsetGet($offset);
unset($this->baseConcreteData[$offset]);
if (($index = array_search($offset, $this->baseArrayMap, true)) !== false) {
unset($this->baseArrayMap[$index]);
}
$this->baseArrayMap = array_values($this->baseArrayMap);
$this->arrayAccessMapIndex = count($this->baseArrayMap);
$this->internalChangingHooks($offset, null, $oldData, 'remove');
}
} | [
"public",
"function",
"offsetUnset",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"offset",
")",
"&&",
"$",
"this",
"->",
"internalFilterHooks",
"(",
"$",
"offset",
",",
"null",
",",
"'remove'",
")",
")",
"{",
"$",
"oldData",
"=",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"offset",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"baseConcreteData",
"[",
"$",
"offset",
"]",
")",
";",
"if",
"(",
"(",
"$",
"index",
"=",
"array_search",
"(",
"$",
"offset",
",",
"$",
"this",
"->",
"baseArrayMap",
",",
"true",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"baseArrayMap",
"[",
"$",
"index",
"]",
")",
";",
"}",
"$",
"this",
"->",
"baseArrayMap",
"=",
"array_values",
"(",
"$",
"this",
"->",
"baseArrayMap",
")",
";",
"$",
"this",
"->",
"arrayAccessMapIndex",
"=",
"count",
"(",
"$",
"this",
"->",
"baseArrayMap",
")",
";",
"$",
"this",
"->",
"internalChangingHooks",
"(",
"$",
"offset",
",",
"null",
",",
"$",
"oldData",
",",
"'remove'",
")",
";",
"}",
"}"
] | this is necessary for ArrayAccess Interface and delete element by offset and rearrange the map
@param mixed $offset
@return void | [
"this",
"is",
"necessary",
"for",
"ArrayAccess",
"Interface",
"and",
"delete",
"element",
"by",
"offset",
"and",
"rearrange",
"the",
"map"
] | 31c12fc6f8a40a36873c074409ae4299b35f9177 | https://github.com/IVIR3zaM/ObjectArrayTools/blob/31c12fc6f8a40a36873c074409ae4299b35f9177/src/Traits/ArrayAccessTrait.php#L95-L110 |
8,734 | bishopb/vanilla | applications/dashboard/models/class.banmodel.php | BanModel.ApplyBan | public function ApplyBan($NewBan = NULL, $OldBan = NULL) {
if (!$NewBan && !$OldBan)
return;
$OldUsers = array();
$OldUserIDs = array();
$NewUsers = array();
$NewUserIDs = array();
$AllBans = $this->AllBans();
if ($NewBan) {
// Get a list of users affected by the new ban.
if (isset($NewBan['BanID']))
$AllBans[$NewBan['BanID']] = $NewBan;
$NewUsers = $this->SQL
->Select('u.UserID, u.Banned')
->From('User u')
->Where($this->BanWhere($NewBan))
->Get()->ResultArray();
$NewUserIDs = ConsolidateArrayValuesByKey($NewUsers, 'UserID');
} elseif (isset($OldBan['BanID'])) {
unset($AllBans[$OldBan['BanID']]);
}
if ($OldBan) {
// Get a list of users affected by the old ban.
$OldUsers = $this->SQL
->Select('u.UserID, u.LastIPAddress, u.Name, u.Email, u.Banned')
->From('User u')
->Where($this->BanWhere($OldBan))
->Get()->ResultArray();
$OldUserIDs = ConsolidateArrayValuesByKey($OldUsers, 'UserID');
}
// Check users that need to be unbanned.
foreach ($OldUsers as $User) {
if (in_array($User['UserID'], $NewUserIDs))
continue;
// TODO check the user against the other bans.
$this->SaveUser($User, FALSE);
}
// Check users that need to be banned.
foreach ($NewUsers as $User) {
if ($User['Banned'])
continue;
$this->SaveUser($User, TRUE, $NewBan);
}
} | php | public function ApplyBan($NewBan = NULL, $OldBan = NULL) {
if (!$NewBan && !$OldBan)
return;
$OldUsers = array();
$OldUserIDs = array();
$NewUsers = array();
$NewUserIDs = array();
$AllBans = $this->AllBans();
if ($NewBan) {
// Get a list of users affected by the new ban.
if (isset($NewBan['BanID']))
$AllBans[$NewBan['BanID']] = $NewBan;
$NewUsers = $this->SQL
->Select('u.UserID, u.Banned')
->From('User u')
->Where($this->BanWhere($NewBan))
->Get()->ResultArray();
$NewUserIDs = ConsolidateArrayValuesByKey($NewUsers, 'UserID');
} elseif (isset($OldBan['BanID'])) {
unset($AllBans[$OldBan['BanID']]);
}
if ($OldBan) {
// Get a list of users affected by the old ban.
$OldUsers = $this->SQL
->Select('u.UserID, u.LastIPAddress, u.Name, u.Email, u.Banned')
->From('User u')
->Where($this->BanWhere($OldBan))
->Get()->ResultArray();
$OldUserIDs = ConsolidateArrayValuesByKey($OldUsers, 'UserID');
}
// Check users that need to be unbanned.
foreach ($OldUsers as $User) {
if (in_array($User['UserID'], $NewUserIDs))
continue;
// TODO check the user against the other bans.
$this->SaveUser($User, FALSE);
}
// Check users that need to be banned.
foreach ($NewUsers as $User) {
if ($User['Banned'])
continue;
$this->SaveUser($User, TRUE, $NewBan);
}
} | [
"public",
"function",
"ApplyBan",
"(",
"$",
"NewBan",
"=",
"NULL",
",",
"$",
"OldBan",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"NewBan",
"&&",
"!",
"$",
"OldBan",
")",
"return",
";",
"$",
"OldUsers",
"=",
"array",
"(",
")",
";",
"$",
"OldUserIDs",
"=",
"array",
"(",
")",
";",
"$",
"NewUsers",
"=",
"array",
"(",
")",
";",
"$",
"NewUserIDs",
"=",
"array",
"(",
")",
";",
"$",
"AllBans",
"=",
"$",
"this",
"->",
"AllBans",
"(",
")",
";",
"if",
"(",
"$",
"NewBan",
")",
"{",
"// Get a list of users affected by the new ban.",
"if",
"(",
"isset",
"(",
"$",
"NewBan",
"[",
"'BanID'",
"]",
")",
")",
"$",
"AllBans",
"[",
"$",
"NewBan",
"[",
"'BanID'",
"]",
"]",
"=",
"$",
"NewBan",
";",
"$",
"NewUsers",
"=",
"$",
"this",
"->",
"SQL",
"->",
"Select",
"(",
"'u.UserID, u.Banned'",
")",
"->",
"From",
"(",
"'User u'",
")",
"->",
"Where",
"(",
"$",
"this",
"->",
"BanWhere",
"(",
"$",
"NewBan",
")",
")",
"->",
"Get",
"(",
")",
"->",
"ResultArray",
"(",
")",
";",
"$",
"NewUserIDs",
"=",
"ConsolidateArrayValuesByKey",
"(",
"$",
"NewUsers",
",",
"'UserID'",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"OldBan",
"[",
"'BanID'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"AllBans",
"[",
"$",
"OldBan",
"[",
"'BanID'",
"]",
"]",
")",
";",
"}",
"if",
"(",
"$",
"OldBan",
")",
"{",
"// Get a list of users affected by the old ban.",
"$",
"OldUsers",
"=",
"$",
"this",
"->",
"SQL",
"->",
"Select",
"(",
"'u.UserID, u.LastIPAddress, u.Name, u.Email, u.Banned'",
")",
"->",
"From",
"(",
"'User u'",
")",
"->",
"Where",
"(",
"$",
"this",
"->",
"BanWhere",
"(",
"$",
"OldBan",
")",
")",
"->",
"Get",
"(",
")",
"->",
"ResultArray",
"(",
")",
";",
"$",
"OldUserIDs",
"=",
"ConsolidateArrayValuesByKey",
"(",
"$",
"OldUsers",
",",
"'UserID'",
")",
";",
"}",
"// Check users that need to be unbanned.",
"foreach",
"(",
"$",
"OldUsers",
"as",
"$",
"User",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"User",
"[",
"'UserID'",
"]",
",",
"$",
"NewUserIDs",
")",
")",
"continue",
";",
"// TODO check the user against the other bans.",
"$",
"this",
"->",
"SaveUser",
"(",
"$",
"User",
",",
"FALSE",
")",
";",
"}",
"// Check users that need to be banned.",
"foreach",
"(",
"$",
"NewUsers",
"as",
"$",
"User",
")",
"{",
"if",
"(",
"$",
"User",
"[",
"'Banned'",
"]",
")",
"continue",
";",
"$",
"this",
"->",
"SaveUser",
"(",
"$",
"User",
",",
"TRUE",
",",
"$",
"NewBan",
")",
";",
"}",
"}"
] | Convert bans to new type.
@since 2.0.18
@access public
@param array $NewBan Data about the new ban.
@param array $OldBan Data about the old ban. | [
"Convert",
"bans",
"to",
"new",
"type",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.banmodel.php#L49-L100 |
8,735 | bishopb/vanilla | applications/dashboard/models/class.banmodel.php | BanModel.BanWhere | public function BanWhere($Ban) {
$Result = array('u.Admin' => 0, 'u.Deleted' => 0);
$Ban['BanValue'] = str_replace('*', '%', $Ban['BanValue']);
switch(strtolower($Ban['BanType'])) {
case 'email':
$Result['u.Email like'] = $Ban['BanValue'];
break;
case 'ipaddress':
$Result['u.LastIPAddress like'] = $Ban['BanValue'];
break;
case 'name':
$Result['u.Name like'] = $Ban['BanValue'];
break;
}
return $Result;
} | php | public function BanWhere($Ban) {
$Result = array('u.Admin' => 0, 'u.Deleted' => 0);
$Ban['BanValue'] = str_replace('*', '%', $Ban['BanValue']);
switch(strtolower($Ban['BanType'])) {
case 'email':
$Result['u.Email like'] = $Ban['BanValue'];
break;
case 'ipaddress':
$Result['u.LastIPAddress like'] = $Ban['BanValue'];
break;
case 'name':
$Result['u.Name like'] = $Ban['BanValue'];
break;
}
return $Result;
} | [
"public",
"function",
"BanWhere",
"(",
"$",
"Ban",
")",
"{",
"$",
"Result",
"=",
"array",
"(",
"'u.Admin'",
"=>",
"0",
",",
"'u.Deleted'",
"=>",
"0",
")",
";",
"$",
"Ban",
"[",
"'BanValue'",
"]",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"Ban",
"[",
"'BanValue'",
"]",
")",
";",
"switch",
"(",
"strtolower",
"(",
"$",
"Ban",
"[",
"'BanType'",
"]",
")",
")",
"{",
"case",
"'email'",
":",
"$",
"Result",
"[",
"'u.Email like'",
"]",
"=",
"$",
"Ban",
"[",
"'BanValue'",
"]",
";",
"break",
";",
"case",
"'ipaddress'",
":",
"$",
"Result",
"[",
"'u.LastIPAddress like'",
"]",
"=",
"$",
"Ban",
"[",
"'BanValue'",
"]",
";",
"break",
";",
"case",
"'name'",
":",
"$",
"Result",
"[",
"'u.Name like'",
"]",
"=",
"$",
"Ban",
"[",
"'BanValue'",
"]",
";",
"break",
";",
"}",
"return",
"$",
"Result",
";",
"}"
] | Ban users that meet conditions given.
@since 2.0.18
@access public
@param array $Ban Data about the ban.
Valid keys are BanType and BanValue. BanValue is what is to be banned.
Valid values for BanType are email, ipaddress or name. | [
"Ban",
"users",
"that",
"meet",
"conditions",
"given",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.banmodel.php#L111-L127 |
8,736 | bishopb/vanilla | applications/dashboard/models/class.banmodel.php | BanModel.CheckUser | public static function CheckUser($User, $Validation = NULL, $UpdateBlocks = FALSE, &$BansFound = NULL) {
$Bans = self::AllBans();
$Fields = array('Name' => 'Name', 'Email' => 'Email', 'IPAddress' => 'LastIPAddress');
$Banned = array();
if (!$BansFound)
$BansFound = array();
foreach ($Bans as $Ban) {
// Convert ban to regex.
$Parts = explode('*', str_replace('%', '*', $Ban['BanValue']));
$Parts = array_map('preg_quote', $Parts);
$Regex = '`^'.implode('.*', $Parts).'$`i';
if (preg_match($Regex, GetValue($Fields[$Ban['BanType']], $User))) {
$Banned[$Ban['BanType']] = TRUE;
$BansFound[] = $Ban;
if ($UpdateBlocks) {
Gdn::SQL()
->Update('Ban')
->Set('CountBlockedRegistrations', 'CountBlockedRegistrations + 1', FALSE, FALSE)
->Where('BanID', $Ban['BanID'])
->Put();
}
}
}
// Add the validation results.
if ($Validation) {
foreach ($Banned as $BanType => $Value) {
$Validation->AddValidationResult(Gdn_Form::LabelCode($BanType), 'ValidateBanned');
}
}
return count($Banned) == 0;
} | php | public static function CheckUser($User, $Validation = NULL, $UpdateBlocks = FALSE, &$BansFound = NULL) {
$Bans = self::AllBans();
$Fields = array('Name' => 'Name', 'Email' => 'Email', 'IPAddress' => 'LastIPAddress');
$Banned = array();
if (!$BansFound)
$BansFound = array();
foreach ($Bans as $Ban) {
// Convert ban to regex.
$Parts = explode('*', str_replace('%', '*', $Ban['BanValue']));
$Parts = array_map('preg_quote', $Parts);
$Regex = '`^'.implode('.*', $Parts).'$`i';
if (preg_match($Regex, GetValue($Fields[$Ban['BanType']], $User))) {
$Banned[$Ban['BanType']] = TRUE;
$BansFound[] = $Ban;
if ($UpdateBlocks) {
Gdn::SQL()
->Update('Ban')
->Set('CountBlockedRegistrations', 'CountBlockedRegistrations + 1', FALSE, FALSE)
->Where('BanID', $Ban['BanID'])
->Put();
}
}
}
// Add the validation results.
if ($Validation) {
foreach ($Banned as $BanType => $Value) {
$Validation->AddValidationResult(Gdn_Form::LabelCode($BanType), 'ValidateBanned');
}
}
return count($Banned) == 0;
} | [
"public",
"static",
"function",
"CheckUser",
"(",
"$",
"User",
",",
"$",
"Validation",
"=",
"NULL",
",",
"$",
"UpdateBlocks",
"=",
"FALSE",
",",
"&",
"$",
"BansFound",
"=",
"NULL",
")",
"{",
"$",
"Bans",
"=",
"self",
"::",
"AllBans",
"(",
")",
";",
"$",
"Fields",
"=",
"array",
"(",
"'Name'",
"=>",
"'Name'",
",",
"'Email'",
"=>",
"'Email'",
",",
"'IPAddress'",
"=>",
"'LastIPAddress'",
")",
";",
"$",
"Banned",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"BansFound",
")",
"$",
"BansFound",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"Bans",
"as",
"$",
"Ban",
")",
"{",
"// Convert ban to regex.",
"$",
"Parts",
"=",
"explode",
"(",
"'*'",
",",
"str_replace",
"(",
"'%'",
",",
"'*'",
",",
"$",
"Ban",
"[",
"'BanValue'",
"]",
")",
")",
";",
"$",
"Parts",
"=",
"array_map",
"(",
"'preg_quote'",
",",
"$",
"Parts",
")",
";",
"$",
"Regex",
"=",
"'`^'",
".",
"implode",
"(",
"'.*'",
",",
"$",
"Parts",
")",
".",
"'$`i'",
";",
"if",
"(",
"preg_match",
"(",
"$",
"Regex",
",",
"GetValue",
"(",
"$",
"Fields",
"[",
"$",
"Ban",
"[",
"'BanType'",
"]",
"]",
",",
"$",
"User",
")",
")",
")",
"{",
"$",
"Banned",
"[",
"$",
"Ban",
"[",
"'BanType'",
"]",
"]",
"=",
"TRUE",
";",
"$",
"BansFound",
"[",
"]",
"=",
"$",
"Ban",
";",
"if",
"(",
"$",
"UpdateBlocks",
")",
"{",
"Gdn",
"::",
"SQL",
"(",
")",
"->",
"Update",
"(",
"'Ban'",
")",
"->",
"Set",
"(",
"'CountBlockedRegistrations'",
",",
"'CountBlockedRegistrations + 1'",
",",
"FALSE",
",",
"FALSE",
")",
"->",
"Where",
"(",
"'BanID'",
",",
"$",
"Ban",
"[",
"'BanID'",
"]",
")",
"->",
"Put",
"(",
")",
";",
"}",
"}",
"}",
"// Add the validation results.",
"if",
"(",
"$",
"Validation",
")",
"{",
"foreach",
"(",
"$",
"Banned",
"as",
"$",
"BanType",
"=>",
"$",
"Value",
")",
"{",
"$",
"Validation",
"->",
"AddValidationResult",
"(",
"Gdn_Form",
"::",
"LabelCode",
"(",
"$",
"BanType",
")",
",",
"'ValidateBanned'",
")",
";",
"}",
"}",
"return",
"count",
"(",
"$",
"Banned",
")",
"==",
"0",
";",
"}"
] | Add ban data to all Get requests.
@since 2.0.18
@access public
@param mixed User data (array or object).
@param Gdn_Validation $Validation
@param bool $UpdateBlocks
@return bool Whether user is banned. | [
"Add",
"ban",
"data",
"to",
"all",
"Get",
"requests",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.banmodel.php#L155-L190 |
8,737 | bishopb/vanilla | applications/dashboard/models/class.banmodel.php | BanModel.Delete | public function Delete($Where = '', $Limit = FALSE, $ResetData = FALSE) {
if (isset($Where['BanID'])) {
$OldBan = $this->GetID($Where['BanID'], DATASET_TYPE_ARRAY);
}
parent::Delete($Where, $Limit, $ResetData);
if (isset($OldBan))
$this->ApplyBan(NULL, $OldBan);
} | php | public function Delete($Where = '', $Limit = FALSE, $ResetData = FALSE) {
if (isset($Where['BanID'])) {
$OldBan = $this->GetID($Where['BanID'], DATASET_TYPE_ARRAY);
}
parent::Delete($Where, $Limit, $ResetData);
if (isset($OldBan))
$this->ApplyBan(NULL, $OldBan);
} | [
"public",
"function",
"Delete",
"(",
"$",
"Where",
"=",
"''",
",",
"$",
"Limit",
"=",
"FALSE",
",",
"$",
"ResetData",
"=",
"FALSE",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"Where",
"[",
"'BanID'",
"]",
")",
")",
"{",
"$",
"OldBan",
"=",
"$",
"this",
"->",
"GetID",
"(",
"$",
"Where",
"[",
"'BanID'",
"]",
",",
"DATASET_TYPE_ARRAY",
")",
";",
"}",
"parent",
"::",
"Delete",
"(",
"$",
"Where",
",",
"$",
"Limit",
",",
"$",
"ResetData",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"OldBan",
")",
")",
"$",
"this",
"->",
"ApplyBan",
"(",
"NULL",
",",
"$",
"OldBan",
")",
";",
"}"
] | Remove a ban.
@since 2.0.18
@access public
@param array $Where
@param int $Limit
@param bool $ResetData | [
"Remove",
"a",
"ban",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.banmodel.php#L202-L211 |
8,738 | bishopb/vanilla | applications/dashboard/models/class.banmodel.php | BanModel.Save | public function Save($FormPostValues, $Settings = FALSE) {
$CurrentBanID = GetValue('BanID', $FormPostValues);
// Get the current ban before saving.
if ($CurrentBanID)
$CurrentBan = $this->GetID($CurrentBanID, DATASET_TYPE_ARRAY);
else
$CurrentBan = NULL;
$this->SetCounts($FormPostValues);
$BanID = parent::Save($FormPostValues, $Settings);
$FormPostValues['BanID'] = $BanID;
$this->ApplyBan($FormPostValues, $CurrentBan);
} | php | public function Save($FormPostValues, $Settings = FALSE) {
$CurrentBanID = GetValue('BanID', $FormPostValues);
// Get the current ban before saving.
if ($CurrentBanID)
$CurrentBan = $this->GetID($CurrentBanID, DATASET_TYPE_ARRAY);
else
$CurrentBan = NULL;
$this->SetCounts($FormPostValues);
$BanID = parent::Save($FormPostValues, $Settings);
$FormPostValues['BanID'] = $BanID;
$this->ApplyBan($FormPostValues, $CurrentBan);
} | [
"public",
"function",
"Save",
"(",
"$",
"FormPostValues",
",",
"$",
"Settings",
"=",
"FALSE",
")",
"{",
"$",
"CurrentBanID",
"=",
"GetValue",
"(",
"'BanID'",
",",
"$",
"FormPostValues",
")",
";",
"// Get the current ban before saving.",
"if",
"(",
"$",
"CurrentBanID",
")",
"$",
"CurrentBan",
"=",
"$",
"this",
"->",
"GetID",
"(",
"$",
"CurrentBanID",
",",
"DATASET_TYPE_ARRAY",
")",
";",
"else",
"$",
"CurrentBan",
"=",
"NULL",
";",
"$",
"this",
"->",
"SetCounts",
"(",
"$",
"FormPostValues",
")",
";",
"$",
"BanID",
"=",
"parent",
"::",
"Save",
"(",
"$",
"FormPostValues",
",",
"$",
"Settings",
")",
";",
"$",
"FormPostValues",
"[",
"'BanID'",
"]",
"=",
"$",
"BanID",
";",
"$",
"this",
"->",
"ApplyBan",
"(",
"$",
"FormPostValues",
",",
"$",
"CurrentBan",
")",
";",
"}"
] | Save data about ban from form.
@since 2.0.18
@access public
@param array $FormPostValues
@param array $Settings | [
"Save",
"data",
"about",
"ban",
"from",
"form",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.banmodel.php#L233-L247 |
8,739 | gregorybesson/PlaygroundFacebook | src/PlaygroundFacebook/Entity/Page.php | Page.addApps | public function addApps(ArrayCollection $apps)
{
foreach ($apps as $app) {
$app->addPage($this);
$this->apps->add($app);
}
} | php | public function addApps(ArrayCollection $apps)
{
foreach ($apps as $app) {
$app->addPage($this);
$this->apps->add($app);
}
} | [
"public",
"function",
"addApps",
"(",
"ArrayCollection",
"$",
"apps",
")",
"{",
"foreach",
"(",
"$",
"apps",
"as",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"addPage",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"apps",
"->",
"add",
"(",
"$",
"app",
")",
";",
"}",
"}"
] | Add apps to the page.
@param ArrayCollection $apps
@return void | [
"Add",
"apps",
"to",
"the",
"page",
"."
] | 35d9561af5af6ccda8a02f4c61a55ff0107e8efd | https://github.com/gregorybesson/PlaygroundFacebook/blob/35d9561af5af6ccda8a02f4c61a55ff0107e8efd/src/PlaygroundFacebook/Entity/Page.php#L222-L228 |
8,740 | gregorybesson/PlaygroundFacebook | src/PlaygroundFacebook/Entity/Page.php | Page.removeApps | public function removeApps(ArrayCollection $apps)
{
foreach ($apps as $app) {
$app->removePage($this);
$this->apps->removeElement($app);
}
} | php | public function removeApps(ArrayCollection $apps)
{
foreach ($apps as $app) {
$app->removePage($this);
$this->apps->removeElement($app);
}
} | [
"public",
"function",
"removeApps",
"(",
"ArrayCollection",
"$",
"apps",
")",
"{",
"foreach",
"(",
"$",
"apps",
"as",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"removePage",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"apps",
"->",
"removeElement",
"(",
"$",
"app",
")",
";",
"}",
"}"
] | Remove apps from the page.
@param ArrayCollection $apps
@return void | [
"Remove",
"apps",
"from",
"the",
"page",
"."
] | 35d9561af5af6ccda8a02f4c61a55ff0107e8efd | https://github.com/gregorybesson/PlaygroundFacebook/blob/35d9561af5af6ccda8a02f4c61a55ff0107e8efd/src/PlaygroundFacebook/Entity/Page.php#L237-L243 |
8,741 | heterogeny/heterogeny-php | src/Heterogeny/Seq.php | Seq.sanitizeOffset | protected function sanitizeOffset($offset): int
{
if (!is_numeric($offset)) {
throw new \InvalidArgumentException(
sprintf('`$index` must be an `int`, %s(%s) received', gettype($offset), var_export($offset, true))
);
}
return intval($offset);
} | php | protected function sanitizeOffset($offset): int
{
if (!is_numeric($offset)) {
throw new \InvalidArgumentException(
sprintf('`$index` must be an `int`, %s(%s) received', gettype($offset), var_export($offset, true))
);
}
return intval($offset);
} | [
"protected",
"function",
"sanitizeOffset",
"(",
"$",
"offset",
")",
":",
"int",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"offset",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'`$index` must be an `int`, %s(%s) received'",
",",
"gettype",
"(",
"$",
"offset",
")",
",",
"var_export",
"(",
"$",
"offset",
",",
"true",
")",
")",
")",
";",
"}",
"return",
"intval",
"(",
"$",
"offset",
")",
";",
"}"
] | Validates the offset throw an exception if invalid
@param mixed $offset offset to lookup
@return void
@throws \InvalidArgumentException | [
"Validates",
"the",
"offset",
"throw",
"an",
"exception",
"if",
"invalid"
] | 7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f | https://github.com/heterogeny/heterogeny-php/blob/7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f/src/Heterogeny/Seq.php#L167-L176 |
8,742 | heterogeny/heterogeny-php | src/Heterogeny/Seq.php | Seq.equals | public function equals($other): bool
{
if (is_array($other) || $other instanceof self) {
return count($other) === count($this) &&
$this->zip($other)->every(
function ($tuple) {
list($a, $b) = $tuple;
if ($a instanceof Equalable) {
return $a->equals($b);
}
return $a === $b;
}
);
}
throw new \InvalidArgumentException('`$other` must be `Seq` or `array`');
} | php | public function equals($other): bool
{
if (is_array($other) || $other instanceof self) {
return count($other) === count($this) &&
$this->zip($other)->every(
function ($tuple) {
list($a, $b) = $tuple;
if ($a instanceof Equalable) {
return $a->equals($b);
}
return $a === $b;
}
);
}
throw new \InvalidArgumentException('`$other` must be `Seq` or `array`');
} | [
"public",
"function",
"equals",
"(",
"$",
"other",
")",
":",
"bool",
"{",
"if",
"(",
"is_array",
"(",
"$",
"other",
")",
"||",
"$",
"other",
"instanceof",
"self",
")",
"{",
"return",
"count",
"(",
"$",
"other",
")",
"===",
"count",
"(",
"$",
"this",
")",
"&&",
"$",
"this",
"->",
"zip",
"(",
"$",
"other",
")",
"->",
"every",
"(",
"function",
"(",
"$",
"tuple",
")",
"{",
"list",
"(",
"$",
"a",
",",
"$",
"b",
")",
"=",
"$",
"tuple",
";",
"if",
"(",
"$",
"a",
"instanceof",
"Equalable",
")",
"{",
"return",
"$",
"a",
"->",
"equals",
"(",
"$",
"b",
")",
";",
"}",
"return",
"$",
"a",
"===",
"$",
"b",
";",
"}",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'`$other` must be `Seq` or `array`'",
")",
";",
"}"
] | Deep strict comparison, preferable over `==`
@param array|Seq $other other `Seq` to compare
@return bool | [
"Deep",
"strict",
"comparison",
"preferable",
"over",
"=="
] | 7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f | https://github.com/heterogeny/heterogeny-php/blob/7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f/src/Heterogeny/Seq.php#L440-L458 |
8,743 | heterogeny/heterogeny-php | src/Heterogeny/Seq.php | Seq.mapWithIndex | public function mapWithIndex(callable $function)
{
$values = array_values($this->data);
return new Seq(array_map($function, array_keys($values), $values));
} | php | public function mapWithIndex(callable $function)
{
$values = array_values($this->data);
return new Seq(array_map($function, array_keys($values), $values));
} | [
"public",
"function",
"mapWithIndex",
"(",
"callable",
"$",
"function",
")",
"{",
"$",
"values",
"=",
"array_values",
"(",
"$",
"this",
"->",
"data",
")",
";",
"return",
"new",
"Seq",
"(",
"array_map",
"(",
"$",
"function",
",",
"array_keys",
"(",
"$",
"values",
")",
",",
"$",
"values",
")",
")",
";",
"}"
] | Map over each `Seq` item with index
@param callable $function map function
@return static | [
"Map",
"over",
"each",
"Seq",
"item",
"with",
"index"
] | 7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f | https://github.com/heterogeny/heterogeny-php/blob/7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f/src/Heterogeny/Seq.php#L479-L484 |
8,744 | heterogeny/heterogeny-php | src/Heterogeny/Seq.php | Seq.filterWithIndex | public function filterWithIndex(callable $function): Seq
{
$result = new Seq();
foreach ($this->data as $key => $value) {
if (!!$function($key, $value)) {
$result = $result->append($value);
}
}
return $result;
} | php | public function filterWithIndex(callable $function): Seq
{
$result = new Seq();
foreach ($this->data as $key => $value) {
if (!!$function($key, $value)) {
$result = $result->append($value);
}
}
return $result;
} | [
"public",
"function",
"filterWithIndex",
"(",
"callable",
"$",
"function",
")",
":",
"Seq",
"{",
"$",
"result",
"=",
"new",
"Seq",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"!",
"$",
"function",
"(",
"$",
"key",
",",
"$",
"value",
")",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"->",
"append",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Filter an Seq using a predicate which receives key and value return a new `Seq` with elements
that doesn't match the predicate
@param callable $function
@return Seq | [
"Filter",
"an",
"Seq",
"using",
"a",
"predicate",
"which",
"receives",
"key",
"and",
"value",
"return",
"a",
"new",
"Seq",
"with",
"elements",
"that",
"doesn",
"t",
"match",
"the",
"predicate"
] | 7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f | https://github.com/heterogeny/heterogeny-php/blob/7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f/src/Heterogeny/Seq.php#L506-L517 |
8,745 | heterogeny/heterogeny-php | src/Heterogeny/Seq.php | Seq.reduceLeft | public function reduceLeft(callable $function)
{
if ($this->isEmpty()) {
return null;
}
list($head, $tail) = $this->headAndTail();
return array_reduce($tail->all(), $function, $head);
} | php | public function reduceLeft(callable $function)
{
if ($this->isEmpty()) {
return null;
}
list($head, $tail) = $this->headAndTail();
return array_reduce($tail->all(), $function, $head);
} | [
"public",
"function",
"reduceLeft",
"(",
"callable",
"$",
"function",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"list",
"(",
"$",
"head",
",",
"$",
"tail",
")",
"=",
"$",
"this",
"->",
"headAndTail",
"(",
")",
";",
"return",
"array_reduce",
"(",
"$",
"tail",
"->",
"all",
"(",
")",
",",
"$",
"function",
",",
"$",
"head",
")",
";",
"}"
] | Reduces `Seq` items to the left
Reduce does not take any initial value, instead,
it uses head as initial.
@param callable $function function which will reduce the Seq
@return mixed|null | [
"Reduces",
"Seq",
"items",
"to",
"the",
"left"
] | 7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f | https://github.com/heterogeny/heterogeny-php/blob/7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f/src/Heterogeny/Seq.php#L563-L572 |
8,746 | heterogeny/heterogeny-php | src/Heterogeny/Seq.php | Seq.reduceRight | public function reduceRight(callable $function)
{
if ($this->isEmpty()) {
return null;
}
list($head, $tail) = $this->reverse()->headAndTail();
return array_reduce($tail->all(), $function, $head);
} | php | public function reduceRight(callable $function)
{
if ($this->isEmpty()) {
return null;
}
list($head, $tail) = $this->reverse()->headAndTail();
return array_reduce($tail->all(), $function, $head);
} | [
"public",
"function",
"reduceRight",
"(",
"callable",
"$",
"function",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"list",
"(",
"$",
"head",
",",
"$",
"tail",
")",
"=",
"$",
"this",
"->",
"reverse",
"(",
")",
"->",
"headAndTail",
"(",
")",
";",
"return",
"array_reduce",
"(",
"$",
"tail",
"->",
"all",
"(",
")",
",",
"$",
"function",
",",
"$",
"head",
")",
";",
"}"
] | Reduces `Seq` items to the right
Reduce does not take any initial value, instead,
it uses head as initial.
@param callable $function function which will reduce the Seq
@return mixed|null | [
"Reduces",
"Seq",
"items",
"to",
"the",
"right"
] | 7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f | https://github.com/heterogeny/heterogeny-php/blob/7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f/src/Heterogeny/Seq.php#L584-L593 |
8,747 | heterogeny/heterogeny-php | src/Heterogeny/Seq.php | Seq.zipLeft | public function zipLeft($other)
{
if (count($other) !== count($this)) {
throw new \InvalidArgumentException(
'Both left and right must have same size.'
);
}
if (is_array($other)) {
return new Seq(
array_map(
function ($a, $b) {
return new Tuple([$a, $b]);
},
$other,
$this->data
)
);
}
if ($other instanceof Seq) {
return $other->zip($this->data);
}
throw new \InvalidArgumentException('`$other` must be `Seq` or `array`');
} | php | public function zipLeft($other)
{
if (count($other) !== count($this)) {
throw new \InvalidArgumentException(
'Both left and right must have same size.'
);
}
if (is_array($other)) {
return new Seq(
array_map(
function ($a, $b) {
return new Tuple([$a, $b]);
},
$other,
$this->data
)
);
}
if ($other instanceof Seq) {
return $other->zip($this->data);
}
throw new \InvalidArgumentException('`$other` must be `Seq` or `array`');
} | [
"public",
"function",
"zipLeft",
"(",
"$",
"other",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"other",
")",
"!==",
"count",
"(",
"$",
"this",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Both left and right must have same size.'",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"other",
")",
")",
"{",
"return",
"new",
"Seq",
"(",
"array_map",
"(",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"new",
"Tuple",
"(",
"[",
"$",
"a",
",",
"$",
"b",
"]",
")",
";",
"}",
",",
"$",
"other",
",",
"$",
"this",
"->",
"data",
")",
")",
";",
"}",
"if",
"(",
"$",
"other",
"instanceof",
"Seq",
")",
"{",
"return",
"$",
"other",
"->",
"zip",
"(",
"$",
"this",
"->",
"data",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'`$other` must be `Seq` or `array`'",
")",
";",
"}"
] | Zip with another `Seq` values on the left
@param array|Seq $other another list
@return static | [
"Zip",
"with",
"another",
"Seq",
"values",
"on",
"the",
"left"
] | 7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f | https://github.com/heterogeny/heterogeny-php/blob/7b110dfe0ab0a7b37bfb60d61fae8efdcabb1e8f/src/Heterogeny/Seq.php#L602-L627 |
8,748 | flavorzyb/simple | src/Environment/DotEnv.php | DotEnv.getFilePath | protected function getFilePath($path, $file)
{
if (!is_string($file)) {
$file = ".env";
}
return rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;
} | php | protected function getFilePath($path, $file)
{
if (!is_string($file)) {
$file = ".env";
}
return rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;
} | [
"protected",
"function",
"getFilePath",
"(",
"$",
"path",
",",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"file",
")",
")",
"{",
"$",
"file",
"=",
"\".env\"",
";",
"}",
"return",
"rtrim",
"(",
"$",
"path",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
";",
"}"
] | Returns the full path to the file.
@param string $path
@param string $file
@return string | [
"Returns",
"the",
"full",
"path",
"to",
"the",
"file",
"."
] | 8c4c539ae2057217b2637fc72c2a90ba266e8e6c | https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Environment/DotEnv.php#L55-L62 |
8,749 | erickmerchant/wright | src/DI/Definition.php | Definition.resolve | public function resolve()
{
$instance = null;
$args = [];
if (isset($this->concrete)) {
$reflected_class = new \ReflectionClass($this->concrete);
} else {
throw new ResolveException;
}
$reflected_method = $reflected_class->getConstructor();
if ($reflected_method) {
$args = $this->resolveArgs($reflected_method, $this->args);
}
$instance = $reflected_class->newInstanceArgs($args);
foreach ($this->afters as $after) {
$after($instance);
}
return $instance;
} | php | public function resolve()
{
$instance = null;
$args = [];
if (isset($this->concrete)) {
$reflected_class = new \ReflectionClass($this->concrete);
} else {
throw new ResolveException;
}
$reflected_method = $reflected_class->getConstructor();
if ($reflected_method) {
$args = $this->resolveArgs($reflected_method, $this->args);
}
$instance = $reflected_class->newInstanceArgs($args);
foreach ($this->afters as $after) {
$after($instance);
}
return $instance;
} | [
"public",
"function",
"resolve",
"(",
")",
"{",
"$",
"instance",
"=",
"null",
";",
"$",
"args",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"concrete",
")",
")",
"{",
"$",
"reflected_class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"concrete",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ResolveException",
";",
"}",
"$",
"reflected_method",
"=",
"$",
"reflected_class",
"->",
"getConstructor",
"(",
")",
";",
"if",
"(",
"$",
"reflected_method",
")",
"{",
"$",
"args",
"=",
"$",
"this",
"->",
"resolveArgs",
"(",
"$",
"reflected_method",
",",
"$",
"this",
"->",
"args",
")",
";",
"}",
"$",
"instance",
"=",
"$",
"reflected_class",
"->",
"newInstanceArgs",
"(",
"$",
"args",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"afters",
"as",
"$",
"after",
")",
"{",
"$",
"after",
"(",
"$",
"instance",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] | Resolves the definition
@throws DefinitionException If a class has not yet been set.
@return object | [
"Resolves",
"the",
"definition"
] | 3b2d46b9b4df4d47a5197c1efca7cd309d5e6cfd | https://github.com/erickmerchant/wright/blob/3b2d46b9b4df4d47a5197c1efca7cd309d5e6cfd/src/DI/Definition.php#L91-L120 |
8,750 | the-kbA-team/typecast | src/TypeCastValue.php | TypeCastValue.prepareNumericCast | protected static function prepareNumericCast($value)
{
if (!in_array(gettype($value), static::$numericCastable, true)) {
return '';
}
if (is_string($value)) {
return trim($value);
}
return $value;
} | php | protected static function prepareNumericCast($value)
{
if (!in_array(gettype($value), static::$numericCastable, true)) {
return '';
}
if (is_string($value)) {
return trim($value);
}
return $value;
} | [
"protected",
"static",
"function",
"prepareNumericCast",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"gettype",
"(",
"$",
"value",
")",
",",
"static",
"::",
"$",
"numericCastable",
",",
"true",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"trim",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Return empty string in case the type is not castable to a numeric data type
and trim the value.
@param mixed $value
@return string|float|int|bool | [
"Return",
"empty",
"string",
"in",
"case",
"the",
"type",
"is",
"not",
"castable",
"to",
"a",
"numeric",
"data",
"type",
"and",
"trim",
"the",
"value",
"."
] | 89939ad0dbf92f6ef09c48764347f473d51e8786 | https://github.com/the-kbA-team/typecast/blob/89939ad0dbf92f6ef09c48764347f473d51e8786/src/TypeCastValue.php#L147-L156 |
8,751 | FiveLab/Exception | src/ViolationListException.php | ViolationListException.create | public static function create(ConstraintViolationListInterface $violationList, $code = 0, \Exception $prev = null)
{
$violationMessages = [];
/** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
foreach ($violationList as $violation) {
$violationMessages[] = sprintf(
'[%s]: %s;',
$violation->getPropertyPath(),
$violation->getMessage()
);
}
$message = 'Not valid. ' . implode(' ', $violationMessages);
return new static($violationList, $message, $code, $prev);
} | php | public static function create(ConstraintViolationListInterface $violationList, $code = 0, \Exception $prev = null)
{
$violationMessages = [];
/** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
foreach ($violationList as $violation) {
$violationMessages[] = sprintf(
'[%s]: %s;',
$violation->getPropertyPath(),
$violation->getMessage()
);
}
$message = 'Not valid. ' . implode(' ', $violationMessages);
return new static($violationList, $message, $code, $prev);
} | [
"public",
"static",
"function",
"create",
"(",
"ConstraintViolationListInterface",
"$",
"violationList",
",",
"$",
"code",
"=",
"0",
",",
"\\",
"Exception",
"$",
"prev",
"=",
"null",
")",
"{",
"$",
"violationMessages",
"=",
"[",
"]",
";",
"/** @var \\Symfony\\Component\\Validator\\ConstraintViolationInterface $violation */",
"foreach",
"(",
"$",
"violationList",
"as",
"$",
"violation",
")",
"{",
"$",
"violationMessages",
"[",
"]",
"=",
"sprintf",
"(",
"'[%s]: %s;'",
",",
"$",
"violation",
"->",
"getPropertyPath",
"(",
")",
",",
"$",
"violation",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"message",
"=",
"'Not valid. '",
".",
"implode",
"(",
"' '",
",",
"$",
"violationMessages",
")",
";",
"return",
"new",
"static",
"(",
"$",
"violationList",
",",
"$",
"message",
",",
"$",
"code",
",",
"$",
"prev",
")",
";",
"}"
] | Create a new instance with violation list
@param ConstraintViolationListInterface $violationList
@param int $code
@param \Exception $prev
@return ViolationListException | [
"Create",
"a",
"new",
"instance",
"with",
"violation",
"list"
] | 6fc8bb53fe8f70b32e3cf71840799179893220a7 | https://github.com/FiveLab/Exception/blob/6fc8bb53fe8f70b32e3cf71840799179893220a7/src/ViolationListException.php#L67-L83 |
8,752 | AnonymPHP/Anonym-Library | src/Anonym/Cron/Crontab/CrontabFileHandler.php | CrontabFileHandler.listJobs | public function listJobs($crontab){
$process = new Process($this->crontabCommand($crontab).' -l');
$process->run();
$this->error = $process->getErrorOutput();
return $process->getOutput();
} | php | public function listJobs($crontab){
$process = new Process($this->crontabCommand($crontab).' -l');
$process->run();
$this->error = $process->getErrorOutput();
return $process->getOutput();
} | [
"public",
"function",
"listJobs",
"(",
"$",
"crontab",
")",
"{",
"$",
"process",
"=",
"new",
"Process",
"(",
"$",
"this",
"->",
"crontabCommand",
"(",
"$",
"crontab",
")",
".",
"' -l'",
")",
";",
"$",
"process",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"error",
"=",
"$",
"process",
"->",
"getErrorOutput",
"(",
")",
";",
"return",
"$",
"process",
"->",
"getOutput",
"(",
")",
";",
"}"
] | list the current jobs
@param Crontab $crontab
@return array | [
"list",
"the",
"current",
"jobs"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Cron/Crontab/CrontabFileHandler.php#L40-L48 |
8,753 | tekkla/core-framework | Core/Framework/Core.php | Core.registerClassloader | private function registerClassloader()
{
// Register core classloader
require_once ('SplClassLoader.php');
// Classloader to register
$register = [
'Core' => $this->basedir,
'Apps' => $this->basedir,
'AppsSec' => $this->basedir,
'Themes' => $this->basedir
];
// Register classloader
foreach ($register as $key => $path) {
$loader = new \SplClassLoader($key, $path);
$loader->register();
}
} | php | private function registerClassloader()
{
// Register core classloader
require_once ('SplClassLoader.php');
// Classloader to register
$register = [
'Core' => $this->basedir,
'Apps' => $this->basedir,
'AppsSec' => $this->basedir,
'Themes' => $this->basedir
];
// Register classloader
foreach ($register as $key => $path) {
$loader = new \SplClassLoader($key, $path);
$loader->register();
}
} | [
"private",
"function",
"registerClassloader",
"(",
")",
"{",
"// Register core classloader",
"require_once",
"(",
"'SplClassLoader.php'",
")",
";",
"// Classloader to register",
"$",
"register",
"=",
"[",
"'Core'",
"=>",
"$",
"this",
"->",
"basedir",
",",
"'Apps'",
"=>",
"$",
"this",
"->",
"basedir",
",",
"'AppsSec'",
"=>",
"$",
"this",
"->",
"basedir",
",",
"'Themes'",
"=>",
"$",
"this",
"->",
"basedir",
"]",
";",
"// Register classloader",
"foreach",
"(",
"$",
"register",
"as",
"$",
"key",
"=>",
"$",
"path",
")",
"{",
"$",
"loader",
"=",
"new",
"\\",
"SplClassLoader",
"(",
"$",
"key",
",",
"$",
"path",
")",
";",
"$",
"loader",
"->",
"register",
"(",
")",
";",
"}",
"}"
] | Registers SPL classloader | [
"Registers",
"SPL",
"classloader"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Core.php#L306-L324 |
8,754 | tekkla/core-framework | Core/Framework/Core.php | Core.initHttp | private function initHttp()
{
$this->di->mapService('core.http', '\Core\Http\Http', [
'core.http.cookie',
'core.http.header'
]);
$this->di->mapService('core.http.cookie', '\Core\Http\Cookie\CookieHandler');
$this->di->mapService('core.http.header', '\Core\Http\Header\HeaderHandler');
$this->http = $this->di->get('core.http');
} | php | private function initHttp()
{
$this->di->mapService('core.http', '\Core\Http\Http', [
'core.http.cookie',
'core.http.header'
]);
$this->di->mapService('core.http.cookie', '\Core\Http\Cookie\CookieHandler');
$this->di->mapService('core.http.header', '\Core\Http\Header\HeaderHandler');
$this->http = $this->di->get('core.http');
} | [
"private",
"function",
"initHttp",
"(",
")",
"{",
"$",
"this",
"->",
"di",
"->",
"mapService",
"(",
"'core.http'",
",",
"'\\Core\\Http\\Http'",
",",
"[",
"'core.http.cookie'",
",",
"'core.http.header'",
"]",
")",
";",
"$",
"this",
"->",
"di",
"->",
"mapService",
"(",
"'core.http.cookie'",
",",
"'\\Core\\Http\\Cookie\\CookieHandler'",
")",
";",
"$",
"this",
"->",
"di",
"->",
"mapService",
"(",
"'core.http.header'",
",",
"'\\Core\\Http\\Header\\HeaderHandler'",
")",
";",
"$",
"this",
"->",
"http",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'core.http'",
")",
";",
"}"
] | Inits the http library system for cookie and header handling | [
"Inits",
"the",
"http",
"library",
"system",
"for",
"cookie",
"and",
"header",
"handling"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Core.php#L636-L646 |
8,755 | tekkla/core-framework | Core/Framework/Core.php | Core.initAssetManager | private function initAssetManager()
{
$this->di->mapService('core.asset', '\Core\Asset\AssetManager');
$this->assetmanager = $this->di->get('core.asset');
// Create default js asset handler
$ah = $this->assetmanager->createAssetHandler('js', 'js');
$ah->setBasedir($this->basedir);
$ah->setBaseurl(BASEURL);
$this->di->mapValue('core.asset.js', $ah);
// Add minify processor on config demand
if ($this->config->get('Core', 'asset.general.minify_js')) {
$ah->addProcessor(new \Core\Asset\Processor\JSMinProcessor());
}
// Create default css asset handler
$ah = $this->assetmanager->createAssetHandler('css', 'css');
$ah->setBasedir($this->basedir);
$ah->setBaseurl(BASEURL);
$this->di->mapValue('core.asset.css', $ah);
// Add minify processor on config demand
if ($this->config->get('Core', 'asset.general.minify_css')) {
$ah->addProcessor(new \Core\Asset\Processor\CssMinProcessor());
$ah->addProcessor(new \Core\Asset\Processor\ReplaceProcessor('../fonts/', '../Themes/Core/fonts/'));
$ah->addProcessor(new \Core\Asset\Processor\ReplaceProcessor('../img/', '../Themes/Core/img/'));
}
} | php | private function initAssetManager()
{
$this->di->mapService('core.asset', '\Core\Asset\AssetManager');
$this->assetmanager = $this->di->get('core.asset');
// Create default js asset handler
$ah = $this->assetmanager->createAssetHandler('js', 'js');
$ah->setBasedir($this->basedir);
$ah->setBaseurl(BASEURL);
$this->di->mapValue('core.asset.js', $ah);
// Add minify processor on config demand
if ($this->config->get('Core', 'asset.general.minify_js')) {
$ah->addProcessor(new \Core\Asset\Processor\JSMinProcessor());
}
// Create default css asset handler
$ah = $this->assetmanager->createAssetHandler('css', 'css');
$ah->setBasedir($this->basedir);
$ah->setBaseurl(BASEURL);
$this->di->mapValue('core.asset.css', $ah);
// Add minify processor on config demand
if ($this->config->get('Core', 'asset.general.minify_css')) {
$ah->addProcessor(new \Core\Asset\Processor\CssMinProcessor());
$ah->addProcessor(new \Core\Asset\Processor\ReplaceProcessor('../fonts/', '../Themes/Core/fonts/'));
$ah->addProcessor(new \Core\Asset\Processor\ReplaceProcessor('../img/', '../Themes/Core/img/'));
}
} | [
"private",
"function",
"initAssetManager",
"(",
")",
"{",
"$",
"this",
"->",
"di",
"->",
"mapService",
"(",
"'core.asset'",
",",
"'\\Core\\Asset\\AssetManager'",
")",
";",
"$",
"this",
"->",
"assetmanager",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'core.asset'",
")",
";",
"// Create default js asset handler",
"$",
"ah",
"=",
"$",
"this",
"->",
"assetmanager",
"->",
"createAssetHandler",
"(",
"'js'",
",",
"'js'",
")",
";",
"$",
"ah",
"->",
"setBasedir",
"(",
"$",
"this",
"->",
"basedir",
")",
";",
"$",
"ah",
"->",
"setBaseurl",
"(",
"BASEURL",
")",
";",
"$",
"this",
"->",
"di",
"->",
"mapValue",
"(",
"'core.asset.js'",
",",
"$",
"ah",
")",
";",
"// Add minify processor on config demand",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'Core'",
",",
"'asset.general.minify_js'",
")",
")",
"{",
"$",
"ah",
"->",
"addProcessor",
"(",
"new",
"\\",
"Core",
"\\",
"Asset",
"\\",
"Processor",
"\\",
"JSMinProcessor",
"(",
")",
")",
";",
"}",
"// Create default css asset handler",
"$",
"ah",
"=",
"$",
"this",
"->",
"assetmanager",
"->",
"createAssetHandler",
"(",
"'css'",
",",
"'css'",
")",
";",
"$",
"ah",
"->",
"setBasedir",
"(",
"$",
"this",
"->",
"basedir",
")",
";",
"$",
"ah",
"->",
"setBaseurl",
"(",
"BASEURL",
")",
";",
"$",
"this",
"->",
"di",
"->",
"mapValue",
"(",
"'core.asset.css'",
",",
"$",
"ah",
")",
";",
"// Add minify processor on config demand",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'Core'",
",",
"'asset.general.minify_css'",
")",
")",
"{",
"$",
"ah",
"->",
"addProcessor",
"(",
"new",
"\\",
"Core",
"\\",
"Asset",
"\\",
"Processor",
"\\",
"CssMinProcessor",
"(",
")",
")",
";",
"$",
"ah",
"->",
"addProcessor",
"(",
"new",
"\\",
"Core",
"\\",
"Asset",
"\\",
"Processor",
"\\",
"ReplaceProcessor",
"(",
"'../fonts/'",
",",
"'../Themes/Core/fonts/'",
")",
")",
";",
"$",
"ah",
"->",
"addProcessor",
"(",
"new",
"\\",
"Core",
"\\",
"Asset",
"\\",
"Processor",
"\\",
"ReplaceProcessor",
"(",
"'../img/'",
",",
"'../Themes/Core/img/'",
")",
")",
";",
"}",
"}"
] | Initiates the AssetManager | [
"Initiates",
"the",
"AssetManager"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Core.php#L651-L682 |
8,756 | tekkla/core-framework | Core/Framework/Core.php | Core.initMessageHandler | private function initMessageHandler()
{
$this->di->mapFactory('core.message.message_handler', '\Core\Message\MessageHandler');
$this->di->mapFactory('core.message.message_storage', '\Core\Message\MessageStorage');
$this->di->mapFactory('core.message.message', '\Core\Notification\Notifcation');
/* @var $handler \Core\Message\MessageHandler */
$handler = $this->di->get('core.message.message_handler');
// Init a message session array if not exists until now
if (empty($_SESSION['Core']['messages'])) {
$_SESSION['Core']['messages'] = [];
}
// Create the message storage
/* @var $storage \Core\Message\MessageStorage */
$storage = $this->di->get('core.message.message_storage');
$storage->setStorage($_SESSION['Core']['messages']);
$handler->setStorage($storage);
$this->message = new MessageFacade($handler);
// Map the handler as frameworks default messagehandler
$this->di->mapValue('core.message.default', $handler);
} | php | private function initMessageHandler()
{
$this->di->mapFactory('core.message.message_handler', '\Core\Message\MessageHandler');
$this->di->mapFactory('core.message.message_storage', '\Core\Message\MessageStorage');
$this->di->mapFactory('core.message.message', '\Core\Notification\Notifcation');
/* @var $handler \Core\Message\MessageHandler */
$handler = $this->di->get('core.message.message_handler');
// Init a message session array if not exists until now
if (empty($_SESSION['Core']['messages'])) {
$_SESSION['Core']['messages'] = [];
}
// Create the message storage
/* @var $storage \Core\Message\MessageStorage */
$storage = $this->di->get('core.message.message_storage');
$storage->setStorage($_SESSION['Core']['messages']);
$handler->setStorage($storage);
$this->message = new MessageFacade($handler);
// Map the handler as frameworks default messagehandler
$this->di->mapValue('core.message.default', $handler);
} | [
"private",
"function",
"initMessageHandler",
"(",
")",
"{",
"$",
"this",
"->",
"di",
"->",
"mapFactory",
"(",
"'core.message.message_handler'",
",",
"'\\Core\\Message\\MessageHandler'",
")",
";",
"$",
"this",
"->",
"di",
"->",
"mapFactory",
"(",
"'core.message.message_storage'",
",",
"'\\Core\\Message\\MessageStorage'",
")",
";",
"$",
"this",
"->",
"di",
"->",
"mapFactory",
"(",
"'core.message.message'",
",",
"'\\Core\\Notification\\Notifcation'",
")",
";",
"/* @var $handler \\Core\\Message\\MessageHandler */",
"$",
"handler",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'core.message.message_handler'",
")",
";",
"// Init a message session array if not exists until now",
"if",
"(",
"empty",
"(",
"$",
"_SESSION",
"[",
"'Core'",
"]",
"[",
"'messages'",
"]",
")",
")",
"{",
"$",
"_SESSION",
"[",
"'Core'",
"]",
"[",
"'messages'",
"]",
"=",
"[",
"]",
";",
"}",
"// Create the message storage",
"/* @var $storage \\Core\\Message\\MessageStorage */",
"$",
"storage",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'core.message.message_storage'",
")",
";",
"$",
"storage",
"->",
"setStorage",
"(",
"$",
"_SESSION",
"[",
"'Core'",
"]",
"[",
"'messages'",
"]",
")",
";",
"$",
"handler",
"->",
"setStorage",
"(",
"$",
"storage",
")",
";",
"$",
"this",
"->",
"message",
"=",
"new",
"MessageFacade",
"(",
"$",
"handler",
")",
";",
"// Map the handler as frameworks default messagehandler",
"$",
"this",
"->",
"di",
"->",
"mapValue",
"(",
"'core.message.default'",
",",
"$",
"handler",
")",
";",
"}"
] | Inits message handler | [
"Inits",
"message",
"handler"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Core.php#L687-L712 |
8,757 | tekkla/core-framework | Core/Framework/Core.php | Core.callAppEvent | private function callAppEvent(AbstractApp $app, string $event)
{
if (method_exists($app, $event)) {
return call_user_func([
$app,
$event
]);
}
} | php | private function callAppEvent(AbstractApp $app, string $event)
{
if (method_exists($app, $event)) {
return call_user_func([
$app,
$event
]);
}
} | [
"private",
"function",
"callAppEvent",
"(",
"AbstractApp",
"$",
"app",
",",
"string",
"$",
"event",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"app",
",",
"$",
"event",
")",
")",
"{",
"return",
"call_user_func",
"(",
"[",
"$",
"app",
",",
"$",
"event",
"]",
")",
";",
"}",
"}"
] | Calls an existing event method of an app
@param AbstractApp $app
@param string $event | [
"Calls",
"an",
"existing",
"event",
"method",
"of",
"an",
"app"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Core.php#L855-L863 |
8,758 | tekkla/core-framework | Core/Framework/Core.php | Core.processAssets | private function processAssets()
{
$js = $this->assetmanager->getAssetHandler('js');
$afh = new \Core\Asset\AssetFileHandler();
$afh->setFilename($this->config->get('Core', 'dir.cache') . '/script.js');
$afh->setTTL($this->config->get('Core', 'cache.ttl.js'));
$js->setFileHandler($afh);
$css = $this->assetmanager->getAssetHandler('css');
$theme = $this->config->get('Core', 'style.theme.name');
$css->addProcessor(new \Core\Asset\Processor\ReplaceProcessor('../fonts/', '../Themes/' . $theme . '/fonts/'));
$css->addProcessor(new \Core\Asset\Processor\ReplaceProcessor('../img/', '../Themes/' . $theme . '/img/'));
$afh = new \Core\Asset\AssetFileHandler();
$afh->setFilename($this->config->get('Core', 'dir.cache') . '/style.css');
$afh->setTTL($this->config->get('Core', 'cache.ttl.css'));
$css->setFileHandler($afh);
foreach ($this->apps as $app) {
foreach ($app->javascript as $aio) {
$js->addObject($aio);
}
foreach ($app->css as $aio) {
$css->addObject($aio);
}
}
// Process assets
$this->assetmanager->process();
} | php | private function processAssets()
{
$js = $this->assetmanager->getAssetHandler('js');
$afh = new \Core\Asset\AssetFileHandler();
$afh->setFilename($this->config->get('Core', 'dir.cache') . '/script.js');
$afh->setTTL($this->config->get('Core', 'cache.ttl.js'));
$js->setFileHandler($afh);
$css = $this->assetmanager->getAssetHandler('css');
$theme = $this->config->get('Core', 'style.theme.name');
$css->addProcessor(new \Core\Asset\Processor\ReplaceProcessor('../fonts/', '../Themes/' . $theme . '/fonts/'));
$css->addProcessor(new \Core\Asset\Processor\ReplaceProcessor('../img/', '../Themes/' . $theme . '/img/'));
$afh = new \Core\Asset\AssetFileHandler();
$afh->setFilename($this->config->get('Core', 'dir.cache') . '/style.css');
$afh->setTTL($this->config->get('Core', 'cache.ttl.css'));
$css->setFileHandler($afh);
foreach ($this->apps as $app) {
foreach ($app->javascript as $aio) {
$js->addObject($aio);
}
foreach ($app->css as $aio) {
$css->addObject($aio);
}
}
// Process assets
$this->assetmanager->process();
} | [
"private",
"function",
"processAssets",
"(",
")",
"{",
"$",
"js",
"=",
"$",
"this",
"->",
"assetmanager",
"->",
"getAssetHandler",
"(",
"'js'",
")",
";",
"$",
"afh",
"=",
"new",
"\\",
"Core",
"\\",
"Asset",
"\\",
"AssetFileHandler",
"(",
")",
";",
"$",
"afh",
"->",
"setFilename",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'Core'",
",",
"'dir.cache'",
")",
".",
"'/script.js'",
")",
";",
"$",
"afh",
"->",
"setTTL",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'Core'",
",",
"'cache.ttl.js'",
")",
")",
";",
"$",
"js",
"->",
"setFileHandler",
"(",
"$",
"afh",
")",
";",
"$",
"css",
"=",
"$",
"this",
"->",
"assetmanager",
"->",
"getAssetHandler",
"(",
"'css'",
")",
";",
"$",
"theme",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'Core'",
",",
"'style.theme.name'",
")",
";",
"$",
"css",
"->",
"addProcessor",
"(",
"new",
"\\",
"Core",
"\\",
"Asset",
"\\",
"Processor",
"\\",
"ReplaceProcessor",
"(",
"'../fonts/'",
",",
"'../Themes/'",
".",
"$",
"theme",
".",
"'/fonts/'",
")",
")",
";",
"$",
"css",
"->",
"addProcessor",
"(",
"new",
"\\",
"Core",
"\\",
"Asset",
"\\",
"Processor",
"\\",
"ReplaceProcessor",
"(",
"'../img/'",
",",
"'../Themes/'",
".",
"$",
"theme",
".",
"'/img/'",
")",
")",
";",
"$",
"afh",
"=",
"new",
"\\",
"Core",
"\\",
"Asset",
"\\",
"AssetFileHandler",
"(",
")",
";",
"$",
"afh",
"->",
"setFilename",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'Core'",
",",
"'dir.cache'",
")",
".",
"'/style.css'",
")",
";",
"$",
"afh",
"->",
"setTTL",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'Core'",
",",
"'cache.ttl.css'",
")",
")",
";",
"$",
"css",
"->",
"setFileHandler",
"(",
"$",
"afh",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"apps",
"as",
"$",
"app",
")",
"{",
"foreach",
"(",
"$",
"app",
"->",
"javascript",
"as",
"$",
"aio",
")",
"{",
"$",
"js",
"->",
"addObject",
"(",
"$",
"aio",
")",
";",
"}",
"foreach",
"(",
"$",
"app",
"->",
"css",
"as",
"$",
"aio",
")",
"{",
"$",
"css",
"->",
"addObject",
"(",
"$",
"aio",
")",
";",
"}",
"}",
"// Process assets",
"$",
"this",
"->",
"assetmanager",
"->",
"process",
"(",
")",
";",
"}"
] | Processes asset handlers and their contents | [
"Processes",
"asset",
"handlers",
"and",
"their",
"contents"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Core.php#L1042-L1077 |
8,759 | tekkla/core-framework | Core/Framework/Core.php | Core.initApps | private function initApps()
{
// Run app specfic functions
/* @var $app \Core\Amvc\App\Abstractapp */
foreach ($this->apps as $app) {
// Call additional Init() methods in apps
if (method_exists($app, 'Init')) {
$app->Init();
}
switch ($app->getName()) {
case 'Core':
$config = $this->config->getStorage('Core');
// Create home url
$type = $this->user->isGuest() ? 'guest' : 'user';
$route = $config->get('home.' . $type . '.route');
$params = parse_ini_string($config->get('home.' . $type . '.params'));
$config->set('url.home', $app->url($route, $params));
break;
}
}
} | php | private function initApps()
{
// Run app specfic functions
/* @var $app \Core\Amvc\App\Abstractapp */
foreach ($this->apps as $app) {
// Call additional Init() methods in apps
if (method_exists($app, 'Init')) {
$app->Init();
}
switch ($app->getName()) {
case 'Core':
$config = $this->config->getStorage('Core');
// Create home url
$type = $this->user->isGuest() ? 'guest' : 'user';
$route = $config->get('home.' . $type . '.route');
$params = parse_ini_string($config->get('home.' . $type . '.params'));
$config->set('url.home', $app->url($route, $params));
break;
}
}
} | [
"private",
"function",
"initApps",
"(",
")",
"{",
"// Run app specfic functions",
"/* @var $app \\Core\\Amvc\\App\\Abstractapp */",
"foreach",
"(",
"$",
"this",
"->",
"apps",
"as",
"$",
"app",
")",
"{",
"// Call additional Init() methods in apps",
"if",
"(",
"method_exists",
"(",
"$",
"app",
",",
"'Init'",
")",
")",
"{",
"$",
"app",
"->",
"Init",
"(",
")",
";",
"}",
"switch",
"(",
"$",
"app",
"->",
"getName",
"(",
")",
")",
"{",
"case",
"'Core'",
":",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"->",
"getStorage",
"(",
"'Core'",
")",
";",
"// Create home url",
"$",
"type",
"=",
"$",
"this",
"->",
"user",
"->",
"isGuest",
"(",
")",
"?",
"'guest'",
":",
"'user'",
";",
"$",
"route",
"=",
"$",
"config",
"->",
"get",
"(",
"'home.'",
".",
"$",
"type",
".",
"'.route'",
")",
";",
"$",
"params",
"=",
"parse_ini_string",
"(",
"$",
"config",
"->",
"get",
"(",
"'home.'",
".",
"$",
"type",
".",
"'.params'",
")",
")",
";",
"$",
"config",
"->",
"set",
"(",
"'url.home'",
",",
"$",
"app",
"->",
"url",
"(",
"$",
"route",
",",
"$",
"params",
")",
")",
";",
"break",
";",
"}",
"}",
"}"
] | Inits all loaded apps, calls core specific actions and maps | [
"Inits",
"all",
"loaded",
"apps",
"calls",
"core",
"specific",
"actions",
"and",
"maps"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Core.php#L1212-L1240 |
8,760 | Cyberrebell/ZF2DoctrineCrudHandler | library/ZF2DoctrineCrudHandler/src/ZF2DoctrineCrudHandler/Request/RequestHandler.php | RequestHandler.filterEntity | protected static function filterEntity($filter, $entity) {
if ($filter !== null && $filter($entity) === false) {
return false;
} else {
return $entity;
}
} | php | protected static function filterEntity($filter, $entity) {
if ($filter !== null && $filter($entity) === false) {
return false;
} else {
return $entity;
}
} | [
"protected",
"static",
"function",
"filterEntity",
"(",
"$",
"filter",
",",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"filter",
"!==",
"null",
"&&",
"$",
"filter",
"(",
"$",
"entity",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"$",
"entity",
";",
"}",
"}"
] | Use given entityFilter to check if entity is allowed
@param object $entity Doctrine-Entity
@return object|boolean | [
"Use",
"given",
"entityFilter",
"to",
"check",
"if",
"entity",
"is",
"allowed"
] | 9ed9b1ae8d7a2a051a1f4638be1dfeefa150d8bb | https://github.com/Cyberrebell/ZF2DoctrineCrudHandler/blob/9ed9b1ae8d7a2a051a1f4638be1dfeefa150d8bb/library/ZF2DoctrineCrudHandler/src/ZF2DoctrineCrudHandler/Request/RequestHandler.php#L111-L117 |
8,761 | kambo-1st/HttpMessage | src/Environment/Environment.php | Environment.getProtocolVersion | public function getProtocolVersion()
{
$version = null;
if (isset($this->server['SERVER_PROTOCOL'])) {
$protocol = $this->server['SERVER_PROTOCOL'];
list(,$version) = explode("/", $protocol);
}
return $version;
} | php | public function getProtocolVersion()
{
$version = null;
if (isset($this->server['SERVER_PROTOCOL'])) {
$protocol = $this->server['SERVER_PROTOCOL'];
list(,$version) = explode("/", $protocol);
}
return $version;
} | [
"public",
"function",
"getProtocolVersion",
"(",
")",
"{",
"$",
"version",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"server",
"[",
"'SERVER_PROTOCOL'",
"]",
")",
")",
"{",
"$",
"protocol",
"=",
"$",
"this",
"->",
"server",
"[",
"'SERVER_PROTOCOL'",
"]",
";",
"list",
"(",
",",
"$",
"version",
")",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"protocol",
")",
";",
"}",
"return",
"$",
"version",
";",
"}"
] | Get protocol version
@return string|null | [
"Get",
"protocol",
"version"
] | 38877b9d895f279fdd5bdf957d8f23f9808a940a | https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Environment/Environment.php#L142-L151 |
8,762 | academic/VipaImportBundle | Importer/PKP/ArticleFileImporter.php | ArticleFileImporter.importArticleFiles | public function importArticleFiles($article, $oldId, $slug)
{
$fileIdsSql = "SELECT DISTINCT file_id FROM article_files WHERE article_id = :id";
$fileIdsStatement = $this->dbalConnection->prepare($fileIdsSql);
$fileIdsStatement->bindValue('id', $oldId);
$fileIdsStatement->execute();
$fileIds = $fileIdsStatement->fetchAll();
$articleFiles = array();
foreach ($fileIds as $fileId) {
$articleFileSql = "SELECT file_id, file_type, original_file_name, revision FROM article_files" .
" WHERE article_id = :id AND file_id = :fileId ORDER BY revision DESC LIMIT 1";
$articleFileStatement = $this->dbalConnection->prepare($articleFileSql);
$articleFileStatement->bindValue('fileId', $fileId['file_id']);
$articleFileStatement->bindValue('id', $oldId);
$articleFileStatement->execute();
$articleFiles[] = $articleFileStatement->fetch();
}
foreach ($articleFiles as $articleFile) {
$this->importArticleFile($articleFile, $oldId, $article, $slug);
}
} | php | public function importArticleFiles($article, $oldId, $slug)
{
$fileIdsSql = "SELECT DISTINCT file_id FROM article_files WHERE article_id = :id";
$fileIdsStatement = $this->dbalConnection->prepare($fileIdsSql);
$fileIdsStatement->bindValue('id', $oldId);
$fileIdsStatement->execute();
$fileIds = $fileIdsStatement->fetchAll();
$articleFiles = array();
foreach ($fileIds as $fileId) {
$articleFileSql = "SELECT file_id, file_type, original_file_name, revision FROM article_files" .
" WHERE article_id = :id AND file_id = :fileId ORDER BY revision DESC LIMIT 1";
$articleFileStatement = $this->dbalConnection->prepare($articleFileSql);
$articleFileStatement->bindValue('fileId', $fileId['file_id']);
$articleFileStatement->bindValue('id', $oldId);
$articleFileStatement->execute();
$articleFiles[] = $articleFileStatement->fetch();
}
foreach ($articleFiles as $articleFile) {
$this->importArticleFile($articleFile, $oldId, $article, $slug);
}
} | [
"public",
"function",
"importArticleFiles",
"(",
"$",
"article",
",",
"$",
"oldId",
",",
"$",
"slug",
")",
"{",
"$",
"fileIdsSql",
"=",
"\"SELECT DISTINCT file_id FROM article_files WHERE article_id = :id\"",
";",
"$",
"fileIdsStatement",
"=",
"$",
"this",
"->",
"dbalConnection",
"->",
"prepare",
"(",
"$",
"fileIdsSql",
")",
";",
"$",
"fileIdsStatement",
"->",
"bindValue",
"(",
"'id'",
",",
"$",
"oldId",
")",
";",
"$",
"fileIdsStatement",
"->",
"execute",
"(",
")",
";",
"$",
"fileIds",
"=",
"$",
"fileIdsStatement",
"->",
"fetchAll",
"(",
")",
";",
"$",
"articleFiles",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fileIds",
"as",
"$",
"fileId",
")",
"{",
"$",
"articleFileSql",
"=",
"\"SELECT file_id, file_type, original_file_name, revision FROM article_files\"",
".",
"\" WHERE article_id = :id AND file_id = :fileId ORDER BY revision DESC LIMIT 1\"",
";",
"$",
"articleFileStatement",
"=",
"$",
"this",
"->",
"dbalConnection",
"->",
"prepare",
"(",
"$",
"articleFileSql",
")",
";",
"$",
"articleFileStatement",
"->",
"bindValue",
"(",
"'fileId'",
",",
"$",
"fileId",
"[",
"'file_id'",
"]",
")",
";",
"$",
"articleFileStatement",
"->",
"bindValue",
"(",
"'id'",
",",
"$",
"oldId",
")",
";",
"$",
"articleFileStatement",
"->",
"execute",
"(",
")",
";",
"$",
"articleFiles",
"[",
"]",
"=",
"$",
"articleFileStatement",
"->",
"fetch",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"articleFiles",
"as",
"$",
"articleFile",
")",
"{",
"$",
"this",
"->",
"importArticleFile",
"(",
"$",
"articleFile",
",",
"$",
"oldId",
",",
"$",
"article",
",",
"$",
"slug",
")",
";",
"}",
"}"
] | Imports files of the given article
@param Article $article The Article whose files are going to be imported
@param int $oldId Old ID of the article
@param String $slug Journal's slug
@throws \Doctrine\DBAL\DBALException | [
"Imports",
"files",
"of",
"the",
"given",
"article"
] | cee7d9e51613706a4fd6e2eade44041ce1af9ad3 | https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/ArticleFileImporter.php#L22-L46 |
8,763 | academic/VipaImportBundle | Importer/PKP/ArticleFileImporter.php | ArticleFileImporter.importArticleFile | public function importArticleFile($pkpArticleFile, $oldArticleId, $article, $slug)
{
$this->consoleOutput->writeln("Reading article file #" . $pkpArticleFile['file_id'] . "... ", true);
$galleysSql = "SELECT galley_id, article_id, locale, label FROM article_galleys " .
"WHERE article_id = :article_id AND file_id = :id";
$galleysStatement = $this->dbalConnection->prepare($galleysSql);
$galleysStatement->bindValue('article_id', $oldArticleId);
$galleysStatement->bindValue('id', $pkpArticleFile['file_id']);
$galleysStatement->execute();
$pkpGalleys = $galleysStatement->fetchAll();
foreach ($pkpGalleys as $galley) {
$locale = !empty($galley['locale']) ? mb_substr($galley['locale'], 0, 2, 'UTF-8') : 'en';
$label = !empty($galley['label']) ? $galley['label'] : '-';
$version = !empty($pkpArticleFile['revision']) ? $pkpArticleFile['revision'] : 0;
$filename = sprintf('imported/%s/%s.%s',
$galley['article_id'],
$galley['galley_id'],
FileHelper::$mimeToExtMap[$pkpArticleFile['file_type']]);
$articleFile = new ArticleFile();
$articleFile->setFile($filename);
$articleFile->setArticle($article);
$articleFile->setVersion($version);
$articleFile->setTitle($label);
$articleFile->setLangCode($locale);
$articleFile->setDescription('-');
$articleFile->setType(ArticleFileParams::FULL_TEXT);
$history = $this->em->getRepository(FileHistory::class)->findOneBy(['fileName' => $filename]);
if (!$history) {
$history = new FileHistory();
$history->setFileName($filename);
$history->setOriginalName($pkpArticleFile['original_file_name']);
$history->setType('articlefiles');
$this->em->persist($history);
}
$source = sprintf('%s/article/download/%s/%s', $slug, $galley['article_id'], $galley['galley_id']);
$target = sprintf('/../web/uploads/articlefiles/imported/%s/%s.%s',
$galley['article_id'],
$galley['galley_id'],
FileHelper::$mimeToExtMap[$pkpArticleFile['file_type']]);
$pendingDownload = new PendingDownload();
$pendingDownload->setSource($source);
$pendingDownload->setTarget($target);
$this->em->persist($pendingDownload);
$this->em->persist($articleFile);
}
} | php | public function importArticleFile($pkpArticleFile, $oldArticleId, $article, $slug)
{
$this->consoleOutput->writeln("Reading article file #" . $pkpArticleFile['file_id'] . "... ", true);
$galleysSql = "SELECT galley_id, article_id, locale, label FROM article_galleys " .
"WHERE article_id = :article_id AND file_id = :id";
$galleysStatement = $this->dbalConnection->prepare($galleysSql);
$galleysStatement->bindValue('article_id', $oldArticleId);
$galleysStatement->bindValue('id', $pkpArticleFile['file_id']);
$galleysStatement->execute();
$pkpGalleys = $galleysStatement->fetchAll();
foreach ($pkpGalleys as $galley) {
$locale = !empty($galley['locale']) ? mb_substr($galley['locale'], 0, 2, 'UTF-8') : 'en';
$label = !empty($galley['label']) ? $galley['label'] : '-';
$version = !empty($pkpArticleFile['revision']) ? $pkpArticleFile['revision'] : 0;
$filename = sprintf('imported/%s/%s.%s',
$galley['article_id'],
$galley['galley_id'],
FileHelper::$mimeToExtMap[$pkpArticleFile['file_type']]);
$articleFile = new ArticleFile();
$articleFile->setFile($filename);
$articleFile->setArticle($article);
$articleFile->setVersion($version);
$articleFile->setTitle($label);
$articleFile->setLangCode($locale);
$articleFile->setDescription('-');
$articleFile->setType(ArticleFileParams::FULL_TEXT);
$history = $this->em->getRepository(FileHistory::class)->findOneBy(['fileName' => $filename]);
if (!$history) {
$history = new FileHistory();
$history->setFileName($filename);
$history->setOriginalName($pkpArticleFile['original_file_name']);
$history->setType('articlefiles');
$this->em->persist($history);
}
$source = sprintf('%s/article/download/%s/%s', $slug, $galley['article_id'], $galley['galley_id']);
$target = sprintf('/../web/uploads/articlefiles/imported/%s/%s.%s',
$galley['article_id'],
$galley['galley_id'],
FileHelper::$mimeToExtMap[$pkpArticleFile['file_type']]);
$pendingDownload = new PendingDownload();
$pendingDownload->setSource($source);
$pendingDownload->setTarget($target);
$this->em->persist($pendingDownload);
$this->em->persist($articleFile);
}
} | [
"public",
"function",
"importArticleFile",
"(",
"$",
"pkpArticleFile",
",",
"$",
"oldArticleId",
",",
"$",
"article",
",",
"$",
"slug",
")",
"{",
"$",
"this",
"->",
"consoleOutput",
"->",
"writeln",
"(",
"\"Reading article file #\"",
".",
"$",
"pkpArticleFile",
"[",
"'file_id'",
"]",
".",
"\"... \"",
",",
"true",
")",
";",
"$",
"galleysSql",
"=",
"\"SELECT galley_id, article_id, locale, label FROM article_galleys \"",
".",
"\"WHERE article_id = :article_id AND file_id = :id\"",
";",
"$",
"galleysStatement",
"=",
"$",
"this",
"->",
"dbalConnection",
"->",
"prepare",
"(",
"$",
"galleysSql",
")",
";",
"$",
"galleysStatement",
"->",
"bindValue",
"(",
"'article_id'",
",",
"$",
"oldArticleId",
")",
";",
"$",
"galleysStatement",
"->",
"bindValue",
"(",
"'id'",
",",
"$",
"pkpArticleFile",
"[",
"'file_id'",
"]",
")",
";",
"$",
"galleysStatement",
"->",
"execute",
"(",
")",
";",
"$",
"pkpGalleys",
"=",
"$",
"galleysStatement",
"->",
"fetchAll",
"(",
")",
";",
"foreach",
"(",
"$",
"pkpGalleys",
"as",
"$",
"galley",
")",
"{",
"$",
"locale",
"=",
"!",
"empty",
"(",
"$",
"galley",
"[",
"'locale'",
"]",
")",
"?",
"mb_substr",
"(",
"$",
"galley",
"[",
"'locale'",
"]",
",",
"0",
",",
"2",
",",
"'UTF-8'",
")",
":",
"'en'",
";",
"$",
"label",
"=",
"!",
"empty",
"(",
"$",
"galley",
"[",
"'label'",
"]",
")",
"?",
"$",
"galley",
"[",
"'label'",
"]",
":",
"'-'",
";",
"$",
"version",
"=",
"!",
"empty",
"(",
"$",
"pkpArticleFile",
"[",
"'revision'",
"]",
")",
"?",
"$",
"pkpArticleFile",
"[",
"'revision'",
"]",
":",
"0",
";",
"$",
"filename",
"=",
"sprintf",
"(",
"'imported/%s/%s.%s'",
",",
"$",
"galley",
"[",
"'article_id'",
"]",
",",
"$",
"galley",
"[",
"'galley_id'",
"]",
",",
"FileHelper",
"::",
"$",
"mimeToExtMap",
"[",
"$",
"pkpArticleFile",
"[",
"'file_type'",
"]",
"]",
")",
";",
"$",
"articleFile",
"=",
"new",
"ArticleFile",
"(",
")",
";",
"$",
"articleFile",
"->",
"setFile",
"(",
"$",
"filename",
")",
";",
"$",
"articleFile",
"->",
"setArticle",
"(",
"$",
"article",
")",
";",
"$",
"articleFile",
"->",
"setVersion",
"(",
"$",
"version",
")",
";",
"$",
"articleFile",
"->",
"setTitle",
"(",
"$",
"label",
")",
";",
"$",
"articleFile",
"->",
"setLangCode",
"(",
"$",
"locale",
")",
";",
"$",
"articleFile",
"->",
"setDescription",
"(",
"'-'",
")",
";",
"$",
"articleFile",
"->",
"setType",
"(",
"ArticleFileParams",
"::",
"FULL_TEXT",
")",
";",
"$",
"history",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"FileHistory",
"::",
"class",
")",
"->",
"findOneBy",
"(",
"[",
"'fileName'",
"=>",
"$",
"filename",
"]",
")",
";",
"if",
"(",
"!",
"$",
"history",
")",
"{",
"$",
"history",
"=",
"new",
"FileHistory",
"(",
")",
";",
"$",
"history",
"->",
"setFileName",
"(",
"$",
"filename",
")",
";",
"$",
"history",
"->",
"setOriginalName",
"(",
"$",
"pkpArticleFile",
"[",
"'original_file_name'",
"]",
")",
";",
"$",
"history",
"->",
"setType",
"(",
"'articlefiles'",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"history",
")",
";",
"}",
"$",
"source",
"=",
"sprintf",
"(",
"'%s/article/download/%s/%s'",
",",
"$",
"slug",
",",
"$",
"galley",
"[",
"'article_id'",
"]",
",",
"$",
"galley",
"[",
"'galley_id'",
"]",
")",
";",
"$",
"target",
"=",
"sprintf",
"(",
"'/../web/uploads/articlefiles/imported/%s/%s.%s'",
",",
"$",
"galley",
"[",
"'article_id'",
"]",
",",
"$",
"galley",
"[",
"'galley_id'",
"]",
",",
"FileHelper",
"::",
"$",
"mimeToExtMap",
"[",
"$",
"pkpArticleFile",
"[",
"'file_type'",
"]",
"]",
")",
";",
"$",
"pendingDownload",
"=",
"new",
"PendingDownload",
"(",
")",
";",
"$",
"pendingDownload",
"->",
"setSource",
"(",
"$",
"source",
")",
";",
"$",
"pendingDownload",
"->",
"setTarget",
"(",
"$",
"target",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"pendingDownload",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"articleFile",
")",
";",
"}",
"}"
] | Imports the given article file
@param int $pkpArticleFile ID of the old article file
@param int $oldArticleId ID of the old article
@param Article $article Newly imported Article entity
@param string $slug Journal's slug | [
"Imports",
"the",
"given",
"article",
"file"
] | cee7d9e51613706a4fd6e2eade44041ce1af9ad3 | https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/ArticleFileImporter.php#L55-L109 |
8,764 | lucifurious/kisma | src/Kisma/Core/SeedBag.php | SeedBag.contains | public function contains( $key )
{
if ( $key instanceof Interfaces\SeedLike )
{
$key = $key->getId();
}
return Utility\Option::contains( $this->_bag, $key );
} | php | public function contains( $key )
{
if ( $key instanceof Interfaces\SeedLike )
{
$key = $key->getId();
}
return Utility\Option::contains( $this->_bag, $key );
} | [
"public",
"function",
"contains",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"key",
"instanceof",
"Interfaces",
"\\",
"SeedLike",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"->",
"getId",
"(",
")",
";",
"}",
"return",
"Utility",
"\\",
"Option",
"::",
"contains",
"(",
"$",
"this",
"->",
"_bag",
",",
"$",
"key",
")",
";",
"}"
] | Checks to see if a key is in the bag.
@param string $key
@return bool | [
"Checks",
"to",
"see",
"if",
"a",
"key",
"is",
"in",
"the",
"bag",
"."
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/SeedBag.php#L238-L246 |
8,765 | jaimeeee/laravelpanel | src/LaravelPanel/models/Form.php | Form.header | private function header()
{
$fields = collect($this->entity->fields)->unique('type')->all();
$codeArray = [];
foreach ($fields as $name => $options) {
$type = ucwords($options['type']);
$className = 'Jaimeeee\\Panel\\Fields\\'.$type.'\\'.$type.'Field';
if (method_exists($className, 'header')) {
$codeArray[] = ' '.$className::header();
}
}
return implode(chr(10), $codeArray);
} | php | private function header()
{
$fields = collect($this->entity->fields)->unique('type')->all();
$codeArray = [];
foreach ($fields as $name => $options) {
$type = ucwords($options['type']);
$className = 'Jaimeeee\\Panel\\Fields\\'.$type.'\\'.$type.'Field';
if (method_exists($className, 'header')) {
$codeArray[] = ' '.$className::header();
}
}
return implode(chr(10), $codeArray);
} | [
"private",
"function",
"header",
"(",
")",
"{",
"$",
"fields",
"=",
"collect",
"(",
"$",
"this",
"->",
"entity",
"->",
"fields",
")",
"->",
"unique",
"(",
"'type'",
")",
"->",
"all",
"(",
")",
";",
"$",
"codeArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"name",
"=>",
"$",
"options",
")",
"{",
"$",
"type",
"=",
"ucwords",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"$",
"className",
"=",
"'Jaimeeee\\\\Panel\\\\Fields\\\\'",
".",
"$",
"type",
".",
"'\\\\'",
".",
"$",
"type",
".",
"'Field'",
";",
"if",
"(",
"method_exists",
"(",
"$",
"className",
",",
"'header'",
")",
")",
"{",
"$",
"codeArray",
"[",
"]",
"=",
"' '",
".",
"$",
"className",
"::",
"header",
"(",
")",
";",
"}",
"}",
"return",
"implode",
"(",
"chr",
"(",
"10",
")",
",",
"$",
"codeArray",
")",
";",
"}"
] | Return each fields' header code.
@return string | [
"Return",
"each",
"fields",
"header",
"code",
"."
] | 211599ba0be7dc5ea11af292a75d4104c41512ca | https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/models/Form.php#L124-L139 |
8,766 | jaimeeee/laravelpanel | src/LaravelPanel/models/Form.php | Form.view | public function view()
{
$code = $this->code();
// If there are images supposed to appear on the editor, lets find them
$imageList = [];
if (isset($this->entity->images['class']) && $imageClass = $this->entity->images['class']) {
$images = $imageClass::orderBy(isset($this->entity->images['field']) ? $this->entity->images['field'] : 'created_at',
isset($this->entity->images['order']) ? $this->entity->images['order'] : 'desc')
->get();
foreach ($images as $image) {
$value = isset($this->entity->images['value']) ?
$image->$this->entity->images['value'] :
$image->image_name;
$imageList[] = [
'title' => (isset($this->entity->images['title']) ? $image->$this->entity->images['title'] : $image->description) ?: $value,
'value' => asset(rtrim($this->entity->images['path'], '/').'/'.$value),
];
}
}
return view('panel::form', [
'entity' => $this->entity,
'header' => $this->header(),
'record' => $this->record,
'title' => $this->entity->title,
'panel' => $this->record ? trans('panel::global.edit_entity', ['entity' => $this->entity->name()]) : trans('panel::global.save_entity', ['entity' => $this->entity->name()]),
'footer' => $this->footer(),
'formCode' => $code,
'imageList' => $imageList,
]);
} | php | public function view()
{
$code = $this->code();
// If there are images supposed to appear on the editor, lets find them
$imageList = [];
if (isset($this->entity->images['class']) && $imageClass = $this->entity->images['class']) {
$images = $imageClass::orderBy(isset($this->entity->images['field']) ? $this->entity->images['field'] : 'created_at',
isset($this->entity->images['order']) ? $this->entity->images['order'] : 'desc')
->get();
foreach ($images as $image) {
$value = isset($this->entity->images['value']) ?
$image->$this->entity->images['value'] :
$image->image_name;
$imageList[] = [
'title' => (isset($this->entity->images['title']) ? $image->$this->entity->images['title'] : $image->description) ?: $value,
'value' => asset(rtrim($this->entity->images['path'], '/').'/'.$value),
];
}
}
return view('panel::form', [
'entity' => $this->entity,
'header' => $this->header(),
'record' => $this->record,
'title' => $this->entity->title,
'panel' => $this->record ? trans('panel::global.edit_entity', ['entity' => $this->entity->name()]) : trans('panel::global.save_entity', ['entity' => $this->entity->name()]),
'footer' => $this->footer(),
'formCode' => $code,
'imageList' => $imageList,
]);
} | [
"public",
"function",
"view",
"(",
")",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"code",
"(",
")",
";",
"// If there are images supposed to appear on the editor, lets find them",
"$",
"imageList",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'class'",
"]",
")",
"&&",
"$",
"imageClass",
"=",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'class'",
"]",
")",
"{",
"$",
"images",
"=",
"$",
"imageClass",
"::",
"orderBy",
"(",
"isset",
"(",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'field'",
"]",
")",
"?",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'field'",
"]",
":",
"'created_at'",
",",
"isset",
"(",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'order'",
"]",
")",
"?",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'order'",
"]",
":",
"'desc'",
")",
"->",
"get",
"(",
")",
";",
"foreach",
"(",
"$",
"images",
"as",
"$",
"image",
")",
"{",
"$",
"value",
"=",
"isset",
"(",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'value'",
"]",
")",
"?",
"$",
"image",
"->",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'value'",
"]",
":",
"$",
"image",
"->",
"image_name",
";",
"$",
"imageList",
"[",
"]",
"=",
"[",
"'title'",
"=>",
"(",
"isset",
"(",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'title'",
"]",
")",
"?",
"$",
"image",
"->",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'title'",
"]",
":",
"$",
"image",
"->",
"description",
")",
"?",
":",
"$",
"value",
",",
"'value'",
"=>",
"asset",
"(",
"rtrim",
"(",
"$",
"this",
"->",
"entity",
"->",
"images",
"[",
"'path'",
"]",
",",
"'/'",
")",
".",
"'/'",
".",
"$",
"value",
")",
",",
"]",
";",
"}",
"}",
"return",
"view",
"(",
"'panel::form'",
",",
"[",
"'entity'",
"=>",
"$",
"this",
"->",
"entity",
",",
"'header'",
"=>",
"$",
"this",
"->",
"header",
"(",
")",
",",
"'record'",
"=>",
"$",
"this",
"->",
"record",
",",
"'title'",
"=>",
"$",
"this",
"->",
"entity",
"->",
"title",
",",
"'panel'",
"=>",
"$",
"this",
"->",
"record",
"?",
"trans",
"(",
"'panel::global.edit_entity'",
",",
"[",
"'entity'",
"=>",
"$",
"this",
"->",
"entity",
"->",
"name",
"(",
")",
"]",
")",
":",
"trans",
"(",
"'panel::global.save_entity'",
",",
"[",
"'entity'",
"=>",
"$",
"this",
"->",
"entity",
"->",
"name",
"(",
")",
"]",
")",
",",
"'footer'",
"=>",
"$",
"this",
"->",
"footer",
"(",
")",
",",
"'formCode'",
"=>",
"$",
"code",
",",
"'imageList'",
"=>",
"$",
"imageList",
",",
"]",
")",
";",
"}"
] | Return the form view.
@return \Illuminate\Http\Response | [
"Return",
"the",
"form",
"view",
"."
] | 211599ba0be7dc5ea11af292a75d4104c41512ca | https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/models/Form.php#L168-L201 |
8,767 | setrun/setrun-component-sys | src/components/Configurator.php | Configurator.setting | public function setting($key = null) : Storage
{
$this->getStorage()->clearKey();
$storage = $this->getStorage()->addKey(self::SETTING);
if ($key === null) {
return $this->getStorage()->get();
}
return $storage->addKey($key);
} | php | public function setting($key = null) : Storage
{
$this->getStorage()->clearKey();
$storage = $this->getStorage()->addKey(self::SETTING);
if ($key === null) {
return $this->getStorage()->get();
}
return $storage->addKey($key);
} | [
"public",
"function",
"setting",
"(",
"$",
"key",
"=",
"null",
")",
":",
"Storage",
"{",
"$",
"this",
"->",
"getStorage",
"(",
")",
"->",
"clearKey",
"(",
")",
";",
"$",
"storage",
"=",
"$",
"this",
"->",
"getStorage",
"(",
")",
"->",
"addKey",
"(",
"self",
"::",
"SETTING",
")",
";",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getStorage",
"(",
")",
"->",
"get",
"(",
")",
";",
"}",
"return",
"$",
"storage",
"->",
"addKey",
"(",
"$",
"key",
")",
";",
"}"
] | Get a settings of key.
@param null $key
@return Storage | [
"Get",
"a",
"settings",
"of",
"key",
"."
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/Configurator.php#L84-L92 |
8,768 | setrun/setrun-component-sys | src/components/Configurator.php | Configurator.application | public function application(bool $null = true) : array
{
$config = $this->appConfig;
if ($null) {
$this->appConfig = [];
}
return $config;
} | php | public function application(bool $null = true) : array
{
$config = $this->appConfig;
if ($null) {
$this->appConfig = [];
}
return $config;
} | [
"public",
"function",
"application",
"(",
"bool",
"$",
"null",
"=",
"true",
")",
":",
"array",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"appConfig",
";",
"if",
"(",
"$",
"null",
")",
"{",
"$",
"this",
"->",
"appConfig",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"config",
";",
"}"
] | Get a configurations of launch app.
@param bool $null
@return array | [
"Get",
"a",
"configurations",
"of",
"launch",
"app",
"."
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/Configurator.php#L99-L106 |
8,769 | setrun/setrun-component-sys | src/components/Configurator.php | Configurator.getStorage | public function getStorage($clone = false) : Storage
{
if ($this->storage === null) {
$this->storage = new Storage($this->getCache());
}
return $clone ? clone $this->storage : $this->storage;
} | php | public function getStorage($clone = false) : Storage
{
if ($this->storage === null) {
$this->storage = new Storage($this->getCache());
}
return $clone ? clone $this->storage : $this->storage;
} | [
"public",
"function",
"getStorage",
"(",
"$",
"clone",
"=",
"false",
")",
":",
"Storage",
"{",
"if",
"(",
"$",
"this",
"->",
"storage",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"storage",
"=",
"new",
"Storage",
"(",
"$",
"this",
"->",
"getCache",
"(",
")",
")",
";",
"}",
"return",
"$",
"clone",
"?",
"clone",
"$",
"this",
"->",
"storage",
":",
"$",
"this",
"->",
"storage",
";",
"}"
] | Get storage interface
@param bool $clone
@return Storage | [
"Get",
"storage",
"interface"
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/Configurator.php#L113-L119 |
8,770 | setrun/setrun-component-sys | src/components/Configurator.php | Configurator.load | public function load(array $files) : void
{
$this->appConfig = $this->getCache()->getOrSet($this->env, function() use ($files){
$config = $this->loadBaseConfig($files);
return $this->loadInstalledComponentsConfig($config);
});
} | php | public function load(array $files) : void
{
$this->appConfig = $this->getCache()->getOrSet($this->env, function() use ($files){
$config = $this->loadBaseConfig($files);
return $this->loadInstalledComponentsConfig($config);
});
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"files",
")",
":",
"void",
"{",
"$",
"this",
"->",
"appConfig",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"getOrSet",
"(",
"$",
"this",
"->",
"env",
",",
"function",
"(",
")",
"use",
"(",
"$",
"files",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"loadBaseConfig",
"(",
"$",
"files",
")",
";",
"return",
"$",
"this",
"->",
"loadInstalledComponentsConfig",
"(",
"$",
"config",
")",
";",
"}",
")",
";",
"}"
] | Load a configuration of app.
@param array $files
@return void | [
"Load",
"a",
"configuration",
"of",
"app",
"."
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/Configurator.php#L126-L132 |
8,771 | setrun/setrun-component-sys | src/components/Configurator.php | Configurator.loadInstalledComponentsConfig | protected function loadInstalledComponentsConfig(array $config = []) : array
{
$env = $this->env === self::WEB ? 'web' : 'console';
$config = FileHelper::loadExtensionsFiles('config/main.php', $config);
$config = FileHelper::loadExtensionsFiles("config/{$env}.php", $config);
return $config;
} | php | protected function loadInstalledComponentsConfig(array $config = []) : array
{
$env = $this->env === self::WEB ? 'web' : 'console';
$config = FileHelper::loadExtensionsFiles('config/main.php', $config);
$config = FileHelper::loadExtensionsFiles("config/{$env}.php", $config);
return $config;
} | [
"protected",
"function",
"loadInstalledComponentsConfig",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"env",
"=",
"$",
"this",
"->",
"env",
"===",
"self",
"::",
"WEB",
"?",
"'web'",
":",
"'console'",
";",
"$",
"config",
"=",
"FileHelper",
"::",
"loadExtensionsFiles",
"(",
"'config/main.php'",
",",
"$",
"config",
")",
";",
"$",
"config",
"=",
"FileHelper",
"::",
"loadExtensionsFiles",
"(",
"\"config/{$env}.php\"",
",",
"$",
"config",
")",
";",
"return",
"$",
"config",
";",
"}"
] | Load a configuration of installed components.
@param array $config
@return array | [
"Load",
"a",
"configuration",
"of",
"installed",
"components",
"."
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/Configurator.php#L155-L161 |
8,772 | setrun/setrun-component-sys | src/components/Configurator.php | Configurator.getCache | public function getCache() : FileCache
{
if (!$this->cache) {
$this->cache = Yii::createObject([
'class' => FileCache::className(),
'cachePath' => Yii::getAlias($this->cachePath)
]);
}
return $this->cache;
} | php | public function getCache() : FileCache
{
if (!$this->cache) {
$this->cache = Yii::createObject([
'class' => FileCache::className(),
'cachePath' => Yii::getAlias($this->cachePath)
]);
}
return $this->cache;
} | [
"public",
"function",
"getCache",
"(",
")",
":",
"FileCache",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cache",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"Yii",
"::",
"createObject",
"(",
"[",
"'class'",
"=>",
"FileCache",
"::",
"className",
"(",
")",
",",
"'cachePath'",
"=>",
"Yii",
"::",
"getAlias",
"(",
"$",
"this",
"->",
"cachePath",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
";",
"}"
] | Get a cache object.
@return object|FileCache | [
"Get",
"a",
"cache",
"object",
"."
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/Configurator.php#L167-L176 |
8,773 | remote-office/libx | src/Util/Time.php | Time.getValue | public function getValue()
{
$value = sprintf("%02d:%02d", $this->hours, $this->minutes);
if(isset($this->seconds))
$value .= sprintf(":%02d", $this->seconds);
if(isset($this->microtime))
$value .= substr($this->microtime, 1);
return $value;
} | php | public function getValue()
{
$value = sprintf("%02d:%02d", $this->hours, $this->minutes);
if(isset($this->seconds))
$value .= sprintf(":%02d", $this->seconds);
if(isset($this->microtime))
$value .= substr($this->microtime, 1);
return $value;
} | [
"public",
"function",
"getValue",
"(",
")",
"{",
"$",
"value",
"=",
"sprintf",
"(",
"\"%02d:%02d\"",
",",
"$",
"this",
"->",
"hours",
",",
"$",
"this",
"->",
"minutes",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"seconds",
")",
")",
"$",
"value",
".=",
"sprintf",
"(",
"\":%02d\"",
",",
"$",
"this",
"->",
"seconds",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"microtime",
")",
")",
"$",
"value",
".=",
"substr",
"(",
"$",
"this",
"->",
"microtime",
",",
"1",
")",
";",
"return",
"$",
"value",
";",
"}"
] | Get the value of this Time as an ISO string
@param void
@return string | [
"Get",
"the",
"value",
"of",
"this",
"Time",
"as",
"an",
"ISO",
"string"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Util/Time.php#L66-L77 |
8,774 | remote-office/libx | src/Util/Time.php | Time.setTime | public function setTime($hours, $minutes, $seconds)
{
// Validate
self::validateTime($hours, $minutes, $seconds);
// Set internal hours, minutes, seconds and microtime variables
$this->hours = (int)$hours;
$this->minutes = (int)$minutes;
$this->seconds = (int)$seconds;
if(is_float($seconds))
$this->microtime = fmod($seconds, floor($seconds));
} | php | public function setTime($hours, $minutes, $seconds)
{
// Validate
self::validateTime($hours, $minutes, $seconds);
// Set internal hours, minutes, seconds and microtime variables
$this->hours = (int)$hours;
$this->minutes = (int)$minutes;
$this->seconds = (int)$seconds;
if(is_float($seconds))
$this->microtime = fmod($seconds, floor($seconds));
} | [
"public",
"function",
"setTime",
"(",
"$",
"hours",
",",
"$",
"minutes",
",",
"$",
"seconds",
")",
"{",
"// Validate",
"self",
"::",
"validateTime",
"(",
"$",
"hours",
",",
"$",
"minutes",
",",
"$",
"seconds",
")",
";",
"// Set internal hours, minutes, seconds and microtime variables",
"$",
"this",
"->",
"hours",
"=",
"(",
"int",
")",
"$",
"hours",
";",
"$",
"this",
"->",
"minutes",
"=",
"(",
"int",
")",
"$",
"minutes",
";",
"$",
"this",
"->",
"seconds",
"=",
"(",
"int",
")",
"$",
"seconds",
";",
"if",
"(",
"is_float",
"(",
"$",
"seconds",
")",
")",
"$",
"this",
"->",
"microtime",
"=",
"fmod",
"(",
"$",
"seconds",
",",
"floor",
"(",
"$",
"seconds",
")",
")",
";",
"}"
] | Set the time represented by this Time
@param integer $hours
@param integer $minutes
@param integer $seconds
@return void | [
"Set",
"the",
"time",
"represented",
"by",
"this",
"Time"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Util/Time.php#L87-L99 |
8,775 | remote-office/libx | src/Util/Time.php | Time.validate | static public function validate($time)
{
// Check if date is a string
if(is_string($time) && strlen(trim($time)) > 0)
return false;
// Check if date matches pattern
if(!preg_match('/^' . self::PATTERN . '$/', $time, $matches))
return false;
// Extract values from time
if(count($matches) == 5)
list($original, $hours, $minutes, $seconds, $microtime) = $matches;
else
list($original, $hours, $minutes, $seconds) = $matches;
// If microtime is set at it to seconds
if(isset($microtime))
$seconds += $microtime;
// Check if all values are valid
if(!self::validateTime($hours, $minutes, $seconds))
return false;
return true;
} | php | static public function validate($time)
{
// Check if date is a string
if(is_string($time) && strlen(trim($time)) > 0)
return false;
// Check if date matches pattern
if(!preg_match('/^' . self::PATTERN . '$/', $time, $matches))
return false;
// Extract values from time
if(count($matches) == 5)
list($original, $hours, $minutes, $seconds, $microtime) = $matches;
else
list($original, $hours, $minutes, $seconds) = $matches;
// If microtime is set at it to seconds
if(isset($microtime))
$seconds += $microtime;
// Check if all values are valid
if(!self::validateTime($hours, $minutes, $seconds))
return false;
return true;
} | [
"static",
"public",
"function",
"validate",
"(",
"$",
"time",
")",
"{",
"// Check if date is a string",
"if",
"(",
"is_string",
"(",
"$",
"time",
")",
"&&",
"strlen",
"(",
"trim",
"(",
"$",
"time",
")",
")",
">",
"0",
")",
"return",
"false",
";",
"// Check if date matches pattern",
"if",
"(",
"!",
"preg_match",
"(",
"'/^'",
".",
"self",
"::",
"PATTERN",
".",
"'$/'",
",",
"$",
"time",
",",
"$",
"matches",
")",
")",
"return",
"false",
";",
"// Extract values from time",
"if",
"(",
"count",
"(",
"$",
"matches",
")",
"==",
"5",
")",
"list",
"(",
"$",
"original",
",",
"$",
"hours",
",",
"$",
"minutes",
",",
"$",
"seconds",
",",
"$",
"microtime",
")",
"=",
"$",
"matches",
";",
"else",
"list",
"(",
"$",
"original",
",",
"$",
"hours",
",",
"$",
"minutes",
",",
"$",
"seconds",
")",
"=",
"$",
"matches",
";",
"// If microtime is set at it to seconds",
"if",
"(",
"isset",
"(",
"$",
"microtime",
")",
")",
"$",
"seconds",
"+=",
"$",
"microtime",
";",
"// Check if all values are valid",
"if",
"(",
"!",
"self",
"::",
"validateTime",
"(",
"$",
"hours",
",",
"$",
"minutes",
",",
"$",
"seconds",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | Validate if a string is a time
@param string $time
@return boolean true if string is a time, false otherwise | [
"Validate",
"if",
"a",
"string",
"is",
"a",
"time"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Util/Time.php#L107-L132 |
8,776 | pdenis/SnideTravinizerBundle | Twig/Extension/GithubExtension.php | GithubExtension.getCommitUrl | public function getCommitUrl(Repo $repo, $commitSHA)
{
return $this->helper->getCommitUrl($repo->getSlug(), $commitSHA);
} | php | public function getCommitUrl(Repo $repo, $commitSHA)
{
return $this->helper->getCommitUrl($repo->getSlug(), $commitSHA);
} | [
"public",
"function",
"getCommitUrl",
"(",
"Repo",
"$",
"repo",
",",
"$",
"commitSHA",
")",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"getCommitUrl",
"(",
"$",
"repo",
"->",
"getSlug",
"(",
")",
",",
"$",
"commitSHA",
")",
";",
"}"
] | Get Repo commit url
@param Repo $repo
@param string $commitSHA
@return string | [
"Get",
"Repo",
"commit",
"url"
] | 53a6fd647280d81a496018d379e4b5c446f81729 | https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Twig/Extension/GithubExtension.php#L80-L83 |
8,777 | vinala/kernel | src/Caches/Drivers/PDODriver.php | PDODriver.find | private function find($key)
{
if ($this->exists($key)) {
$data = Query::from($this->table)
->where('name', '=', $key)
->first();
if ($data->lifetime >= time()) {
return ['name' => $key, 'value' => $this->unpacking($data->value), 'lifetime' => $data->lifetime];
} else {
$this->remove($key);
}
}
} | php | private function find($key)
{
if ($this->exists($key)) {
$data = Query::from($this->table)
->where('name', '=', $key)
->first();
if ($data->lifetime >= time()) {
return ['name' => $key, 'value' => $this->unpacking($data->value), 'lifetime' => $data->lifetime];
} else {
$this->remove($key);
}
}
} | [
"private",
"function",
"find",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"key",
")",
")",
"{",
"$",
"data",
"=",
"Query",
"::",
"from",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"where",
"(",
"'name'",
",",
"'='",
",",
"$",
"key",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"data",
"->",
"lifetime",
">=",
"time",
"(",
")",
")",
"{",
"return",
"[",
"'name'",
"=>",
"$",
"key",
",",
"'value'",
"=>",
"$",
"this",
"->",
"unpacking",
"(",
"$",
"data",
"->",
"value",
")",
",",
"'lifetime'",
"=>",
"$",
"data",
"->",
"lifetime",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"key",
")",
";",
"}",
"}",
"}"
] | Find item in cache.
@param string $key
@return array | [
"Find",
"item",
"in",
"cache",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Drivers/PDODriver.php#L53-L66 |
8,778 | vinala/kernel | src/Caches/Drivers/PDODriver.php | PDODriver.createTable | private function createTable()
{
Schema::create($this->table, function ($tab) {
$tab->inc('id');
$tab->string('name');
$tab->string('value');
$tab->long('lifetime');
$tab->unique('cacheunique', ['name']);
});
} | php | private function createTable()
{
Schema::create($this->table, function ($tab) {
$tab->inc('id');
$tab->string('name');
$tab->string('value');
$tab->long('lifetime');
$tab->unique('cacheunique', ['name']);
});
} | [
"private",
"function",
"createTable",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"$",
"this",
"->",
"table",
",",
"function",
"(",
"$",
"tab",
")",
"{",
"$",
"tab",
"->",
"inc",
"(",
"'id'",
")",
";",
"$",
"tab",
"->",
"string",
"(",
"'name'",
")",
";",
"$",
"tab",
"->",
"string",
"(",
"'value'",
")",
";",
"$",
"tab",
"->",
"long",
"(",
"'lifetime'",
")",
";",
"$",
"tab",
"->",
"unique",
"(",
"'cacheunique'",
",",
"[",
"'name'",
"]",
")",
";",
"}",
")",
";",
"}"
] | Create database cache table.
@return null | [
"Create",
"database",
"cache",
"table",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Drivers/PDODriver.php#L83-L92 |
8,779 | vinala/kernel | src/Caches/Drivers/PDODriver.php | PDODriver.put | public function put($name, $value, $lifetime = null, $timestamp = false)
{
if (is_null($lifetime)) {
$lifetime = confg('cache.lifetime');
}
if (!$timestamp) {
$lifetime = time() + $lifetime;
}
$value = $this->packing($value);
$this->save($name, $value, $lifetime);
} | php | public function put($name, $value, $lifetime = null, $timestamp = false)
{
if (is_null($lifetime)) {
$lifetime = confg('cache.lifetime');
}
if (!$timestamp) {
$lifetime = time() + $lifetime;
}
$value = $this->packing($value);
$this->save($name, $value, $lifetime);
} | [
"public",
"function",
"put",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lifetime",
"=",
"null",
",",
"$",
"timestamp",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"lifetime",
")",
")",
"{",
"$",
"lifetime",
"=",
"confg",
"(",
"'cache.lifetime'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"timestamp",
")",
"{",
"$",
"lifetime",
"=",
"time",
"(",
")",
"+",
"$",
"lifetime",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"packing",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"save",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lifetime",
")",
";",
"}"
] | Create new item cache.
@param string $name
@param mixed $value
@param int $lifetime
@return bool | [
"Create",
"new",
"item",
"cache",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Drivers/PDODriver.php#L141-L154 |
8,780 | vinala/kernel | src/Caches/Drivers/PDODriver.php | PDODriver.add | protected function add($name, $value, $lifetime)
{
return Query::into($this->table)
->column('name', 'value', 'lifetime')
->value($name, $value, $lifetime)
->insert();
} | php | protected function add($name, $value, $lifetime)
{
return Query::into($this->table)
->column('name', 'value', 'lifetime')
->value($name, $value, $lifetime)
->insert();
} | [
"protected",
"function",
"add",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lifetime",
")",
"{",
"return",
"Query",
"::",
"into",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"column",
"(",
"'name'",
",",
"'value'",
",",
"'lifetime'",
")",
"->",
"value",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lifetime",
")",
"->",
"insert",
"(",
")",
";",
"}"
] | Add data to cache database table.
@param string $name
@param string $value
@param int $lifetime
@return bool | [
"Add",
"data",
"to",
"cache",
"database",
"table",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Drivers/PDODriver.php#L165-L171 |
8,781 | vinala/kernel | src/Caches/Drivers/PDODriver.php | PDODriver.edit | protected function edit($name, $value, $lifetime)
{
return Query::into($this->table)
->set('name', $name)
->set('value', $value)
->set('lifetime', $lifetime)
->where('name', '=', $name)
->update();
} | php | protected function edit($name, $value, $lifetime)
{
return Query::into($this->table)
->set('name', $name)
->set('value', $value)
->set('lifetime', $lifetime)
->where('name', '=', $name)
->update();
} | [
"protected",
"function",
"edit",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lifetime",
")",
"{",
"return",
"Query",
"::",
"into",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"set",
"(",
"'name'",
",",
"$",
"name",
")",
"->",
"set",
"(",
"'value'",
",",
"$",
"value",
")",
"->",
"set",
"(",
"'lifetime'",
",",
"$",
"lifetime",
")",
"->",
"where",
"(",
"'name'",
",",
"'='",
",",
"$",
"name",
")",
"->",
"update",
"(",
")",
";",
"}"
] | Update data in cache database table.
@param string $name
@param string $value
@param int $lifetime
@return bool | [
"Update",
"data",
"in",
"cache",
"database",
"table",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Drivers/PDODriver.php#L182-L190 |
8,782 | vinala/kernel | src/Caches/Drivers/PDODriver.php | PDODriver.save | protected function save($name, $value, $lifetime)
{
if ($this->exists($name)) {
return $this->edit($name, $value, $lifetime);
}
return $this->add($name, $value, $lifetime);
} | php | protected function save($name, $value, $lifetime)
{
if ($this->exists($name)) {
return $this->edit($name, $value, $lifetime);
}
return $this->add($name, $value, $lifetime);
} | [
"protected",
"function",
"save",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lifetime",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"edit",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lifetime",
")",
";",
"}",
"return",
"$",
"this",
"->",
"add",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lifetime",
")",
";",
"}"
] | Save the data cache.
@param string $name
@param string $value
@param int $lifetime
@return bool | [
"Save",
"the",
"data",
"cache",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Drivers/PDODriver.php#L215-L222 |
8,783 | vinala/kernel | src/Caches/Drivers/PDODriver.php | PDODriver.exists | private function exists($key)
{
$data = Query::from($this->table)->where('name', '=', $key)->get();
return count($data) > 0;
} | php | private function exists($key)
{
$data = Query::from($this->table)->where('name', '=', $key)->get();
return count($data) > 0;
} | [
"private",
"function",
"exists",
"(",
"$",
"key",
")",
"{",
"$",
"data",
"=",
"Query",
"::",
"from",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"where",
"(",
"'name'",
",",
"'='",
",",
"$",
"key",
")",
"->",
"get",
"(",
")",
";",
"return",
"count",
"(",
"$",
"data",
")",
">",
"0",
";",
"}"
] | Check if cache key exists in database.
@param string $key
@return bool | [
"Check",
"if",
"cache",
"key",
"exists",
"in",
"database",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Drivers/PDODriver.php#L231-L236 |
8,784 | vinala/kernel | src/Caches/Drivers/PDODriver.php | PDODriver.get | public function get($name, $default = null)
{
if ($this->exists($name)) {
$data = Query::from($this->table)
->where('name', '=', $name)
->first();
if ($data->lifetime >= time()) {
return $this->unpacking($data->value);
} else {
$this->remove($name);
return $default;
}
}
return $default;
} | php | public function get($name, $default = null)
{
if ($this->exists($name)) {
$data = Query::from($this->table)
->where('name', '=', $name)
->first();
if ($data->lifetime >= time()) {
return $this->unpacking($data->value);
} else {
$this->remove($name);
return $default;
}
}
return $default;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"name",
")",
")",
"{",
"$",
"data",
"=",
"Query",
"::",
"from",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"where",
"(",
"'name'",
",",
"'='",
",",
"$",
"name",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"data",
"->",
"lifetime",
">=",
"time",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"unpacking",
"(",
"$",
"data",
"->",
"value",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"name",
")",
";",
"return",
"$",
"default",
";",
"}",
"}",
"return",
"$",
"default",
";",
"}"
] | Get a cache key.
@param string name
@return mixed | [
"Get",
"a",
"cache",
"key",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Drivers/PDODriver.php#L257-L274 |
8,785 | vinala/kernel | src/Caches/Drivers/PDODriver.php | PDODriver.expiration | public function expiration($key)
{
if ($this->exists($name)) {
$data = Query::from($this->table)
->where('name', '=', $name)
->first();
if ($data->lifetime >= time()) {
return $data->lifetime;
}
}
} | php | public function expiration($key)
{
if ($this->exists($name)) {
$data = Query::from($this->table)
->where('name', '=', $name)
->first();
if ($data->lifetime >= time()) {
return $data->lifetime;
}
}
} | [
"public",
"function",
"expiration",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"name",
")",
")",
"{",
"$",
"data",
"=",
"Query",
"::",
"from",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"where",
"(",
"'name'",
",",
"'='",
",",
"$",
"name",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"data",
"->",
"lifetime",
">=",
"time",
"(",
")",
")",
"{",
"return",
"$",
"data",
"->",
"lifetime",
";",
"}",
"}",
"}"
] | Get Expiration time of a key.
@param string $key
@return int | [
"Get",
"Expiration",
"time",
"of",
"a",
"key",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Drivers/PDODriver.php#L299-L310 |
8,786 | vinala/kernel | src/Caches/Drivers/PDODriver.php | PDODriver.prolong | public function prolong($key, $lifetime)
{
$item = $this->find($key);
if (!is_null($item)) {
$lifetime = $item['lifetime'] + $lifetime;
$this->put($key, $item['value'], $lifetime, true);
}
} | php | public function prolong($key, $lifetime)
{
$item = $this->find($key);
if (!is_null($item)) {
$lifetime = $item['lifetime'] + $lifetime;
$this->put($key, $item['value'], $lifetime, true);
}
} | [
"public",
"function",
"prolong",
"(",
"$",
"key",
",",
"$",
"lifetime",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"item",
")",
")",
"{",
"$",
"lifetime",
"=",
"$",
"item",
"[",
"'lifetime'",
"]",
"+",
"$",
"lifetime",
";",
"$",
"this",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"item",
"[",
"'value'",
"]",
",",
"$",
"lifetime",
",",
"true",
")",
";",
"}",
"}"
] | Prolong a lifetime of cache item.
@param string $key
@param int $lifetime
@return bool | [
"Prolong",
"a",
"lifetime",
"of",
"cache",
"item",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Drivers/PDODriver.php#L320-L329 |
8,787 | gbv/jskos-http | src/Result.php | Result.append | public function append($resource)
{
parent::append($resource);
if ($this->totalCount !== null) {
$this->setTotalCount($this->totalCount);
}
} | php | public function append($resource)
{
parent::append($resource);
if ($this->totalCount !== null) {
$this->setTotalCount($this->totalCount);
}
} | [
"public",
"function",
"append",
"(",
"$",
"resource",
")",
"{",
"parent",
"::",
"append",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"$",
"this",
"->",
"totalCount",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setTotalCount",
"(",
"$",
"this",
"->",
"totalCount",
")",
";",
"}",
"}"
] | Append a Resource and possibly increase totalCount if needed. | [
"Append",
"a",
"Resource",
"and",
"possibly",
"increase",
"totalCount",
"if",
"needed",
"."
] | 3a9e82d875bed409c129401b4bee9285562db265 | https://github.com/gbv/jskos-http/blob/3a9e82d875bed409c129401b4bee9285562db265/src/Result.php#L56-L62 |
8,788 | gbv/jskos-http | src/Result.php | Result.jsonLDSerialize | public function jsonLDSerialize(string $context = self::DEFAULT_CONTEXT, bool $types = NULL)
{
return array_map(function($m) use ($context, $types) {
return $m->jsonLDSerialize($context, $types ?? true);
}, $this->members);
} | php | public function jsonLDSerialize(string $context = self::DEFAULT_CONTEXT, bool $types = NULL)
{
return array_map(function($m) use ($context, $types) {
return $m->jsonLDSerialize($context, $types ?? true);
}, $this->members);
} | [
"public",
"function",
"jsonLDSerialize",
"(",
"string",
"$",
"context",
"=",
"self",
"::",
"DEFAULT_CONTEXT",
",",
"bool",
"$",
"types",
"=",
"NULL",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"m",
")",
"use",
"(",
"$",
"context",
",",
"$",
"types",
")",
"{",
"return",
"$",
"m",
"->",
"jsonLDSerialize",
"(",
"$",
"context",
",",
"$",
"types",
"??",
"true",
")",
";",
"}",
",",
"$",
"this",
"->",
"members",
")",
";",
"}"
] | Serialize with type and context fields for each member. | [
"Serialize",
"with",
"type",
"and",
"context",
"fields",
"for",
"each",
"member",
"."
] | 3a9e82d875bed409c129401b4bee9285562db265 | https://github.com/gbv/jskos-http/blob/3a9e82d875bed409c129401b4bee9285562db265/src/Result.php#L67-L72 |
8,789 | agencms/structured-data | src/StructuredData.php | StructuredData.repeater | public function repeater(string $key = 'structured_data')
{
return Group::full('Structured Data')
->repeater($key)
->addGroup(
Group::full('Person')
->key('structureddata.person')
->addField(
Field::string('name', 'Name'),
Field::string('jobTitle', 'Job Title'),
Field::string('telephone', 'Telephone'),
Field::string('url', 'Website URL'),
Field::string('email', 'Email Address'),
Field::date('birthDate', 'Birth Date'),
Field::string('streetAddress', 'Street Address'),
Field::string('addressLocality', 'City'),
Field::string('addressRegion', 'County'),
Field::string('postalCode', 'Post Code'),
Field::string('addressCountry', 'Country'),
Field::select('sameAs', 'Social Network URLs')->tags()
),
Group::full('Organization')
->key('structureddata.organization')
->addField(
Field::string('name', 'Name'),
Field::string('url', 'Website URL'),
Field::select('contactType', 'Contact Point')
->dropdown()->single()->addOptions([
'Customer service'
]),
Field::string('telephone', 'Contact Telephone'),
Field::string('email', 'Contact Email'),
Field::string('streetAddress', 'Street Address'),
Field::string('addressLocality', 'City'),
Field::string('addressRegion', 'County'),
Field::string('postalCode', 'Post Code'),
Field::string('addressCountry', 'Country'),
Field::select('sameAs', 'Social Network URLs')->tags()
)
);
} | php | public function repeater(string $key = 'structured_data')
{
return Group::full('Structured Data')
->repeater($key)
->addGroup(
Group::full('Person')
->key('structureddata.person')
->addField(
Field::string('name', 'Name'),
Field::string('jobTitle', 'Job Title'),
Field::string('telephone', 'Telephone'),
Field::string('url', 'Website URL'),
Field::string('email', 'Email Address'),
Field::date('birthDate', 'Birth Date'),
Field::string('streetAddress', 'Street Address'),
Field::string('addressLocality', 'City'),
Field::string('addressRegion', 'County'),
Field::string('postalCode', 'Post Code'),
Field::string('addressCountry', 'Country'),
Field::select('sameAs', 'Social Network URLs')->tags()
),
Group::full('Organization')
->key('structureddata.organization')
->addField(
Field::string('name', 'Name'),
Field::string('url', 'Website URL'),
Field::select('contactType', 'Contact Point')
->dropdown()->single()->addOptions([
'Customer service'
]),
Field::string('telephone', 'Contact Telephone'),
Field::string('email', 'Contact Email'),
Field::string('streetAddress', 'Street Address'),
Field::string('addressLocality', 'City'),
Field::string('addressRegion', 'County'),
Field::string('postalCode', 'Post Code'),
Field::string('addressCountry', 'Country'),
Field::select('sameAs', 'Social Network URLs')->tags()
)
);
} | [
"public",
"function",
"repeater",
"(",
"string",
"$",
"key",
"=",
"'structured_data'",
")",
"{",
"return",
"Group",
"::",
"full",
"(",
"'Structured Data'",
")",
"->",
"repeater",
"(",
"$",
"key",
")",
"->",
"addGroup",
"(",
"Group",
"::",
"full",
"(",
"'Person'",
")",
"->",
"key",
"(",
"'structureddata.person'",
")",
"->",
"addField",
"(",
"Field",
"::",
"string",
"(",
"'name'",
",",
"'Name'",
")",
",",
"Field",
"::",
"string",
"(",
"'jobTitle'",
",",
"'Job Title'",
")",
",",
"Field",
"::",
"string",
"(",
"'telephone'",
",",
"'Telephone'",
")",
",",
"Field",
"::",
"string",
"(",
"'url'",
",",
"'Website URL'",
")",
",",
"Field",
"::",
"string",
"(",
"'email'",
",",
"'Email Address'",
")",
",",
"Field",
"::",
"date",
"(",
"'birthDate'",
",",
"'Birth Date'",
")",
",",
"Field",
"::",
"string",
"(",
"'streetAddress'",
",",
"'Street Address'",
")",
",",
"Field",
"::",
"string",
"(",
"'addressLocality'",
",",
"'City'",
")",
",",
"Field",
"::",
"string",
"(",
"'addressRegion'",
",",
"'County'",
")",
",",
"Field",
"::",
"string",
"(",
"'postalCode'",
",",
"'Post Code'",
")",
",",
"Field",
"::",
"string",
"(",
"'addressCountry'",
",",
"'Country'",
")",
",",
"Field",
"::",
"select",
"(",
"'sameAs'",
",",
"'Social Network URLs'",
")",
"->",
"tags",
"(",
")",
")",
",",
"Group",
"::",
"full",
"(",
"'Organization'",
")",
"->",
"key",
"(",
"'structureddata.organization'",
")",
"->",
"addField",
"(",
"Field",
"::",
"string",
"(",
"'name'",
",",
"'Name'",
")",
",",
"Field",
"::",
"string",
"(",
"'url'",
",",
"'Website URL'",
")",
",",
"Field",
"::",
"select",
"(",
"'contactType'",
",",
"'Contact Point'",
")",
"->",
"dropdown",
"(",
")",
"->",
"single",
"(",
")",
"->",
"addOptions",
"(",
"[",
"'Customer service'",
"]",
")",
",",
"Field",
"::",
"string",
"(",
"'telephone'",
",",
"'Contact Telephone'",
")",
",",
"Field",
"::",
"string",
"(",
"'email'",
",",
"'Contact Email'",
")",
",",
"Field",
"::",
"string",
"(",
"'streetAddress'",
",",
"'Street Address'",
")",
",",
"Field",
"::",
"string",
"(",
"'addressLocality'",
",",
"'City'",
")",
",",
"Field",
"::",
"string",
"(",
"'addressRegion'",
",",
"'County'",
")",
",",
"Field",
"::",
"string",
"(",
"'postalCode'",
",",
"'Post Code'",
")",
",",
"Field",
"::",
"string",
"(",
"'addressCountry'",
",",
"'Country'",
")",
",",
"Field",
"::",
"select",
"(",
"'sameAs'",
",",
"'Social Network URLs'",
")",
"->",
"tags",
"(",
")",
")",
")",
";",
"}"
] | Returns the Agencms repeater configuration for Structured Data blocks
@param string $key
@return Group | [
"Returns",
"the",
"Agencms",
"repeater",
"configuration",
"for",
"Structured",
"Data",
"blocks"
] | f1da29a0c50e3ac5e922265895e4dbe353d2afd9 | https://github.com/agencms/structured-data/blob/f1da29a0c50e3ac5e922265895e4dbe353d2afd9/src/StructuredData.php#L16-L56 |
8,790 | budkit/budkit-framework | src/Budkit/Datastore/Drivers/MySQLi/Driver.php | Driver.hasUTF | final public function hasUTF()
{
$verParts = explode('.', $this->getVersion());
return ($verParts[0] == 5 || ($verParts[0] == 4 && $verParts[1] == 1 && (int)$verParts[2] >= 2));
} | php | final public function hasUTF()
{
$verParts = explode('.', $this->getVersion());
return ($verParts[0] == 5 || ($verParts[0] == 4 && $verParts[1] == 1 && (int)$verParts[2] >= 2));
} | [
"final",
"public",
"function",
"hasUTF",
"(",
")",
"{",
"$",
"verParts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"this",
"->",
"getVersion",
"(",
")",
")",
";",
"return",
"(",
"$",
"verParts",
"[",
"0",
"]",
"==",
"5",
"||",
"(",
"$",
"verParts",
"[",
"0",
"]",
"==",
"4",
"&&",
"$",
"verParts",
"[",
"1",
"]",
"==",
"1",
"&&",
"(",
"int",
")",
"$",
"verParts",
"[",
"2",
"]",
">=",
"2",
")",
")",
";",
"}"
] | Determines UTF support
@access public
@return boolean True - UTF is supported | [
"Determines",
"UTF",
"support"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Driver.php#L250-L254 |
8,791 | budkit/budkit-framework | src/Budkit/Datastore/Drivers/MySQLi/Driver.php | Driver.getEscaped | final public function getEscaped($text, $extra = false)
{
$result = mysqli_real_escape_string($this->resourceId, $text);
if ($extra) {
$result = addcslashes($result, '%_');
}
return $result;
} | php | final public function getEscaped($text, $extra = false)
{
$result = mysqli_real_escape_string($this->resourceId, $text);
if ($extra) {
$result = addcslashes($result, '%_');
}
return $result;
} | [
"final",
"public",
"function",
"getEscaped",
"(",
"$",
"text",
",",
"$",
"extra",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"mysqli_real_escape_string",
"(",
"$",
"this",
"->",
"resourceId",
",",
"$",
"text",
")",
";",
"if",
"(",
"$",
"extra",
")",
"{",
"$",
"result",
"=",
"addcslashes",
"(",
"$",
"result",
",",
"'%_'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get a database escaped string
@param string The string to be escaped
@param boolean Optional parameter to provide extra escaping
@return string
@access public
@abstract | [
"Get",
"a",
"database",
"escaped",
"string"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Driver.php#L275-L282 |
8,792 | budkit/budkit-framework | src/Budkit/Datastore/Drivers/MySQLi/Driver.php | Driver.startTransaction | public function startTransaction()
{
if (!is_a($this->resourceId, "mysqli")) {
throw new QueryException("No valid db resource Id found. This is required to start a transaction");
return false;
}
$this->resourceId->autocommit(FALSE); //Turns autocommit off;
} | php | public function startTransaction()
{
if (!is_a($this->resourceId, "mysqli")) {
throw new QueryException("No valid db resource Id found. This is required to start a transaction");
return false;
}
$this->resourceId->autocommit(FALSE); //Turns autocommit off;
} | [
"public",
"function",
"startTransaction",
"(",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"this",
"->",
"resourceId",
",",
"\"mysqli\"",
")",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"\"No valid db resource Id found. This is required to start a transaction\"",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"resourceId",
"->",
"autocommit",
"(",
"FALSE",
")",
";",
"//Turns autocommit off;",
"}"
] | Begins a database transaction
@return void; | [
"Begins",
"a",
"database",
"transaction"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Driver.php#L347-L356 |
8,793 | budkit/budkit-framework | src/Budkit/Datastore/Drivers/MySQLi/Driver.php | Driver.query | public function query($sql, $execute = FALSE)
{
$query = (empty($sql)) ? $this->query : $sql;
$this->transactions[] = $this->replacePrefix($query); //just for reference
//@TODO;
if ($execute) {
$this->exec($query);
}
return true;
} | php | public function query($sql, $execute = FALSE)
{
$query = (empty($sql)) ? $this->query : $sql;
$this->transactions[] = $this->replacePrefix($query); //just for reference
//@TODO;
if ($execute) {
$this->exec($query);
}
return true;
} | [
"public",
"function",
"query",
"(",
"$",
"sql",
",",
"$",
"execute",
"=",
"FALSE",
")",
"{",
"$",
"query",
"=",
"(",
"empty",
"(",
"$",
"sql",
")",
")",
"?",
"$",
"this",
"->",
"query",
":",
"$",
"sql",
";",
"$",
"this",
"->",
"transactions",
"[",
"]",
"=",
"$",
"this",
"->",
"replacePrefix",
"(",
"$",
"query",
")",
";",
"//just for reference",
"//@TODO;",
"if",
"(",
"$",
"execute",
")",
"{",
"$",
"this",
"->",
"exec",
"(",
"$",
"query",
")",
";",
"}",
"return",
"true",
";",
"}"
] | This method is intended for use in transsactions
@param type $sql
@param type $execute
@return boolean | [
"This",
"method",
"is",
"intended",
"for",
"use",
"in",
"transsactions"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Driver.php#L365-L377 |
8,794 | budkit/budkit-framework | src/Budkit/Datastore/Drivers/MySQLi/Driver.php | Driver.commitTransaction | public function commitTransaction()
{
if (empty($this->transactions) || !is_array($this->transactions)) {
throw new QueryException(t("No transaction queries found"));
$this->transactions = array();
$this->resourceId->autocommit(TRUE); //Turns autocommit back on
return false;
}
//Query transactions
foreach ($this->transactions as $query) {
if (!$this->exec($query)) {
$this->resourceId->rollback(); //Rolls back the transaction;
$this->transactions = array();
$this->resourceId->autocommit(TRUE); //Turns autocommit back on
return false;
}
}
//Commit the transaction
if (!$this->resourceId->commit()) {
throw new QueryException(t("The transaction could not be committed"));
$this->transactions = array();
$this->resourceId->autocommit(TRUE); //Turns autocommit back on
return false;
}
$this->transactions = array();
$this->resourceId->autocommit(TRUE); //Turns autocommit back on
return true;
} | php | public function commitTransaction()
{
if (empty($this->transactions) || !is_array($this->transactions)) {
throw new QueryException(t("No transaction queries found"));
$this->transactions = array();
$this->resourceId->autocommit(TRUE); //Turns autocommit back on
return false;
}
//Query transactions
foreach ($this->transactions as $query) {
if (!$this->exec($query)) {
$this->resourceId->rollback(); //Rolls back the transaction;
$this->transactions = array();
$this->resourceId->autocommit(TRUE); //Turns autocommit back on
return false;
}
}
//Commit the transaction
if (!$this->resourceId->commit()) {
throw new QueryException(t("The transaction could not be committed"));
$this->transactions = array();
$this->resourceId->autocommit(TRUE); //Turns autocommit back on
return false;
}
$this->transactions = array();
$this->resourceId->autocommit(TRUE); //Turns autocommit back on
return true;
} | [
"public",
"function",
"commitTransaction",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"transactions",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"transactions",
")",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"t",
"(",
"\"No transaction queries found\"",
")",
")",
";",
"$",
"this",
"->",
"transactions",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"resourceId",
"->",
"autocommit",
"(",
"TRUE",
")",
";",
"//Turns autocommit back on",
"return",
"false",
";",
"}",
"//Query transactions",
"foreach",
"(",
"$",
"this",
"->",
"transactions",
"as",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exec",
"(",
"$",
"query",
")",
")",
"{",
"$",
"this",
"->",
"resourceId",
"->",
"rollback",
"(",
")",
";",
"//Rolls back the transaction;",
"$",
"this",
"->",
"transactions",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"resourceId",
"->",
"autocommit",
"(",
"TRUE",
")",
";",
"//Turns autocommit back on",
"return",
"false",
";",
"}",
"}",
"//Commit the transaction",
"if",
"(",
"!",
"$",
"this",
"->",
"resourceId",
"->",
"commit",
"(",
")",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"t",
"(",
"\"The transaction could not be committed\"",
")",
")",
";",
"$",
"this",
"->",
"transactions",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"resourceId",
"->",
"autocommit",
"(",
"TRUE",
")",
";",
"//Turns autocommit back on",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"transactions",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"resourceId",
"->",
"autocommit",
"(",
"TRUE",
")",
";",
"//Turns autocommit back on",
"return",
"true",
";",
"}"
] | Commits a transaction or rollbacks on error
@return boolean | [
"Commits",
"a",
"transaction",
"or",
"rollbacks",
"on",
"error"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Driver.php#L384-L421 |
8,795 | lucifurious/kisma | src/Kisma/Core/Utility/Scalar.php | Scalar.is_array | public static function is_array( $possibleArray, $_ = null )
{
foreach ( func_get_args() as $_argument )
{
if ( !is_array( $_argument ) )
{
return false;
}
}
return true;
} | php | public static function is_array( $possibleArray, $_ = null )
{
foreach ( func_get_args() as $_argument )
{
if ( !is_array( $_argument ) )
{
return false;
}
}
return true;
} | [
"public",
"static",
"function",
"is_array",
"(",
"$",
"possibleArray",
",",
"$",
"_",
"=",
"null",
")",
"{",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"_argument",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"_argument",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Multi-argument is_array helper
Usage: is_array( $array1[, $array2][, ...])
@param mixed $possibleArray
@param mixed|null $_ [optional]
@return bool | [
"Multi",
"-",
"argument",
"is_array",
"helper"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Scalar.php#L111-L122 |
8,796 | lucifurious/kisma | src/Kisma/Core/Utility/Scalar.php | Scalar.array_prepend | public static function array_prepend( $array, $string, $deep = false )
{
if ( empty( $array ) || empty( $string ) )
{
return $array;
}
foreach ( $array as $key => $element )
{
if ( is_array( $element ) )
{
if ( $deep )
{
$array[$key] = self::array_prepend( $element, $string, $deep );
}
else
{
trigger_error( 'array_prepend: array element', E_USER_WARNING );
}
}
else
{
$array[$key] = $string . $element;
}
}
return $array;
} | php | public static function array_prepend( $array, $string, $deep = false )
{
if ( empty( $array ) || empty( $string ) )
{
return $array;
}
foreach ( $array as $key => $element )
{
if ( is_array( $element ) )
{
if ( $deep )
{
$array[$key] = self::array_prepend( $element, $string, $deep );
}
else
{
trigger_error( 'array_prepend: array element', E_USER_WARNING );
}
}
else
{
$array[$key] = $string . $element;
}
}
return $array;
} | [
"public",
"static",
"function",
"array_prepend",
"(",
"$",
"array",
",",
"$",
"string",
",",
"$",
"deep",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"array",
")",
"||",
"empty",
"(",
"$",
"string",
")",
")",
"{",
"return",
"$",
"array",
";",
"}",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"element",
")",
")",
"{",
"if",
"(",
"$",
"deep",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"array_prepend",
"(",
"$",
"element",
",",
"$",
"string",
",",
"$",
"deep",
")",
";",
"}",
"else",
"{",
"trigger_error",
"(",
"'array_prepend: array element'",
",",
"E_USER_WARNING",
")",
";",
"}",
"}",
"else",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"string",
".",
"$",
"element",
";",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] | Prepend an array
@param array $array
@param string $string
@param bool $deep
@return array | [
"Prepend",
"an",
"array"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Scalar.php#L133-L160 |
8,797 | lucifurious/kisma | src/Kisma/Core/Utility/Scalar.php | Scalar.argsToArray | public static function argsToArray()
{
$_array = array();
foreach ( func_get_args() as $_key => $_argument )
{
$_array[$_key] = $_argument;
}
// Return the fresh array...
return $_array;
} | php | public static function argsToArray()
{
$_array = array();
foreach ( func_get_args() as $_key => $_argument )
{
$_array[$_key] = $_argument;
}
// Return the fresh array...
return $_array;
} | [
"public",
"static",
"function",
"argsToArray",
"(",
")",
"{",
"$",
"_array",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"_key",
"=>",
"$",
"_argument",
")",
"{",
"$",
"_array",
"[",
"$",
"_key",
"]",
"=",
"$",
"_argument",
";",
"}",
"//\tReturn the fresh array...",
"return",
"$",
"_array",
";",
"}"
] | Takes a list of things and returns them in an array as the values. Keys are maintained.
@param ...
@return array | [
"Takes",
"a",
"list",
"of",
"things",
"and",
"returns",
"them",
"in",
"an",
"array",
"as",
"the",
"values",
".",
"Keys",
"are",
"maintained",
"."
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Scalar.php#L169-L180 |
8,798 | lucifurious/kisma | src/Kisma/Core/Utility/Scalar.php | Scalar.in | public static function in()
{
$_haystack = func_get_args();
if ( !empty( $_haystack ) && count( $_haystack ) > 1 )
{
$_needle = array_shift( $_haystack );
return in_array( $_needle, $_haystack );
}
return false;
} | php | public static function in()
{
$_haystack = func_get_args();
if ( !empty( $_haystack ) && count( $_haystack ) > 1 )
{
$_needle = array_shift( $_haystack );
return in_array( $_needle, $_haystack );
}
return false;
} | [
"public",
"static",
"function",
"in",
"(",
")",
"{",
"$",
"_haystack",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"_haystack",
")",
"&&",
"count",
"(",
"$",
"_haystack",
")",
">",
"1",
")",
"{",
"$",
"_needle",
"=",
"array_shift",
"(",
"$",
"_haystack",
")",
";",
"return",
"in_array",
"(",
"$",
"_needle",
",",
"$",
"_haystack",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Convenience "in_array" method. Takes variable args.
The first argument is the needle, the rest are considered in the haystack. For example:
Option::in( 'x', 'x', 'y', 'z' ) returns true
Option::in( 'a', 'x', 'y', 'z' ) returns false
@internal param mixed $needle
@internal param mixed $haystack
@return bool | [
"Convenience",
"in_array",
"method",
".",
"Takes",
"variable",
"args",
"."
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Scalar.php#L228-L240 |
8,799 | lucifurious/kisma | src/Kisma/Core/Utility/Scalar.php | Scalar.contains | public static function contains( $needle, $haystack, $strict = false )
{
foreach ( $haystack as $_index => $_value )
{
if ( is_string( $_value ) )
{
if ( 0 === strcasecmp( $needle, $_value ) )
{
return true;
}
}
else if ( in_array( $needle, $_value, $strict ) )
{
return true;
}
}
return false;
} | php | public static function contains( $needle, $haystack, $strict = false )
{
foreach ( $haystack as $_index => $_value )
{
if ( is_string( $_value ) )
{
if ( 0 === strcasecmp( $needle, $_value ) )
{
return true;
}
}
else if ( in_array( $needle, $_value, $strict ) )
{
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"contains",
"(",
"$",
"needle",
",",
"$",
"haystack",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"haystack",
"as",
"$",
"_index",
"=>",
"$",
"_value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"_value",
")",
")",
"{",
"if",
"(",
"0",
"===",
"strcasecmp",
"(",
"$",
"needle",
",",
"$",
"_value",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"in_array",
"(",
"$",
"needle",
",",
"$",
"_value",
",",
"$",
"strict",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | A case-insensitive "in_array" for all intents and purposes. Works with objects too!
@param string $needle
@param array|object $haystack
@param bool $strict
@return bool Returns true if found, false otherwise. Just like in_array | [
"A",
"case",
"-",
"insensitive",
"in_array",
"for",
"all",
"intents",
"and",
"purposes",
".",
"Works",
"with",
"objects",
"too!"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Scalar.php#L275-L293 |
Subsets and Splits