id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
39,700 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.sendNotification | protected function sendNotification( $model, $config = [] ) {
$templateData = $config[ 'data' ] ?? [];
$templateConfig = [];
$templateData = ArrayHelper::merge( [ 'model' => $model, 'service' => $this ], $templateData );
$templateConfig[ 'createdBy' ] = $config[ 'createdBy' ] ?? null;
$templateConfig[ 'parentId' ] = $model->id;
$templateConfig[ 'parentType' ] = self::$parentType;
$templateConfig[ 'link' ] = $config[ 'link' ] ?? null;
$templateConfig[ 'adminLink' ] = $config[ 'adminLink' ] ?? null;
$templateConfig[ 'title' ] = $config[ 'title' ] ?? $model->name ?? null;
$templateConfig[ 'users' ] = $config[ 'users' ] ?? [];
return Yii::$app->eventManager->triggerNotification( $config[ 'template' ], $templateData, $templateConfig );
} | php | protected function sendNotification( $model, $config = [] ) {
$templateData = $config[ 'data' ] ?? [];
$templateConfig = [];
$templateData = ArrayHelper::merge( [ 'model' => $model, 'service' => $this ], $templateData );
$templateConfig[ 'createdBy' ] = $config[ 'createdBy' ] ?? null;
$templateConfig[ 'parentId' ] = $model->id;
$templateConfig[ 'parentType' ] = self::$parentType;
$templateConfig[ 'link' ] = $config[ 'link' ] ?? null;
$templateConfig[ 'adminLink' ] = $config[ 'adminLink' ] ?? null;
$templateConfig[ 'title' ] = $config[ 'title' ] ?? $model->name ?? null;
$templateConfig[ 'users' ] = $config[ 'users' ] ?? [];
return Yii::$app->eventManager->triggerNotification( $config[ 'template' ], $templateData, $templateConfig );
} | [
"protected",
"function",
"sendNotification",
"(",
"$",
"model",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"templateData",
"=",
"$",
"config",
"[",
"'data'",
"]",
"??",
"[",
"]",
";",
"$",
"templateConfig",
"=",
"[",
"]",
";",
"$",
"templateDa... | Prepare the notification data and configuration and trigger it using the active
event manager.
@param \cmsgears\core\common\models\base\ActiveRecord $model
@param array $config
@return type | [
"Prepare",
"the",
"notification",
"data",
"and",
"configuration",
"and",
"trigger",
"it",
"using",
"the",
"active",
"event",
"manager",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L651-L668 |
39,701 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.findPage | public static function findPage( $config = [] ) {
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
$sort = isset( $config[ 'sort' ] ) ? $config[ 'sort' ] : false;
// Default sort
if( !$sort ) {
$defaultSort = isset( $config[ 'defaultSort' ] ) ? $config[ 'defaultSort' ] : [ 'id' => SORT_DESC ];
$sort = new Sort([
'attributes' => [
'id' => [
'asc' => [ "$modelTable.id" => SORT_ASC ],
'desc' => [ "$modelTable.id" => SORT_DESC ],
'default' => SORT_DESC,
'label' => 'Id'
]
],
'defaultOrder' => $defaultSort
]);
$config[ 'sort' ] = $sort;
}
// Default conditions
$config[ 'conditions' ] = $config[ 'conditions' ] ?? [];
// Default query
if( !isset( $config[ 'query' ] ) ) {
$modelClass = static::$modelClass;
$hasOne = isset( $config[ 'hasOne' ] ) ? $config[ 'hasOne' ] : false;
if( $hasOne ) {
$config[ 'query' ] = $modelClass::queryWithHasOne();
}
}
// Filters
$config = static::applyPublicFilters( $config );
$config = static::applySiteFilters( $config );
// Default search column
if( !isset( $config[ 'search-col' ] ) ) {
$config[ 'search-col' ][] = "$modelTable.id";
}
return static::findDataProvider( $config );
} | php | public static function findPage( $config = [] ) {
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
$sort = isset( $config[ 'sort' ] ) ? $config[ 'sort' ] : false;
// Default sort
if( !$sort ) {
$defaultSort = isset( $config[ 'defaultSort' ] ) ? $config[ 'defaultSort' ] : [ 'id' => SORT_DESC ];
$sort = new Sort([
'attributes' => [
'id' => [
'asc' => [ "$modelTable.id" => SORT_ASC ],
'desc' => [ "$modelTable.id" => SORT_DESC ],
'default' => SORT_DESC,
'label' => 'Id'
]
],
'defaultOrder' => $defaultSort
]);
$config[ 'sort' ] = $sort;
}
// Default conditions
$config[ 'conditions' ] = $config[ 'conditions' ] ?? [];
// Default query
if( !isset( $config[ 'query' ] ) ) {
$modelClass = static::$modelClass;
$hasOne = isset( $config[ 'hasOne' ] ) ? $config[ 'hasOne' ] : false;
if( $hasOne ) {
$config[ 'query' ] = $modelClass::queryWithHasOne();
}
}
// Filters
$config = static::applyPublicFilters( $config );
$config = static::applySiteFilters( $config );
// Default search column
if( !isset( $config[ 'search-col' ] ) ) {
$config[ 'search-col' ][] = "$modelTable.id";
}
return static::findDataProvider( $config );
} | [
"public",
"static",
"function",
"findPage",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"modelClass",
"=",
"static",
"::",
"$",
"modelClass",
";",
"$",
"modelTable",
"=",
"$",
"modelClass",
"::",
"tableName",
"(",
")",
";",
"$",
"sort",
"=",
"i... | The method findPage provide data provider after generating appropriate query.
It uses find or queryWithHasOne as default method to generate base query. | [
"The",
"method",
"findPage",
"provide",
"data",
"provider",
"after",
"generating",
"appropriate",
"query",
".",
"It",
"uses",
"find",
"or",
"queryWithHasOne",
"as",
"default",
"method",
"to",
"generate",
"base",
"query",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L991-L1045 |
39,702 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.findPageForSearch | public static function findPageForSearch( $config = [] ) {
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
$parentType = $config[ 'parentType' ] ?? static::$parentType;
// Search in
$searchModel = $config[ 'searchModel' ] ?? true; // Search in model name
$searchCategory = $config[ 'searchCategory' ] ?? false; // Search in category name
$searchTag = $config[ 'searchTag' ] ?? false; // Search in tag name
// DB Tables
$mcategoryTable = CoreTables::TABLE_MODEL_CATEGORY;
$categoryTable = CoreTables::TABLE_CATEGORY;
$mtagTable = CoreTables::TABLE_MODEL_TAG;
$tagTable = CoreTables::TABLE_TAG;
// Sort
$sortParam = Yii::$app->request->get( 'sort' );
$sortParam = preg_replace( '/-/', '', $sortParam );
// Keywords
$searchParam = isset( $config[ 'search-param' ] ) ? $config[ 'search-param' ] : 'keywords';
$keywords = Yii::$app->request->getQueryParam( $searchParam );
// Search Query
$query = $config[ 'query' ] ?? $modelClass::find();
$hasOne = $config[ 'hasOne' ] ?? false;
// Use model joins
if( $hasOne ) {
$query = $modelClass::queryWithHasOne();
}
// Tag
if( $searchTag || isset( $config[ 'tag' ] ) || $sortParam === 'tag' ) {
$query->leftJoin( $mtagTable, "$modelTable.id=$mtagTable.parentId AND $mtagTable.parentType='$parentType' AND $mtagTable.active=TRUE" )
->leftJoin( $tagTable, "$mtagTable.modelId=$tagTable.id" );
}
if( isset( $config[ 'tag' ] ) ) {
$query->andWhere( "$tagTable.id=" . $config[ 'tag' ]->id );
}
// Category
if( $searchCategory || isset( $config[ 'category' ] ) || $sortParam === 'category' ) {
$query->leftJoin( $mcategoryTable, "$modelTable.id=$mcategoryTable.parentId AND $mcategoryTable.parentType='$parentType' AND $mcategoryTable.active=TRUE" )
->leftJoin( $categoryTable, "$mcategoryTable.modelId=$categoryTable.id" );
}
if( isset( $config[ 'category' ] ) ) {
$query->andWhere( "$categoryTable.id=" . $config[ 'category' ]->id );
}
// Search
if( isset( $keywords ) ) {
if( $searchModel ) {
$config[ 'search-col' ][] = "$modelTable.name";
}
if( $searchCategory ) {
$config[ 'search-col' ][] = "$categoryTable.name";
}
if( $searchTag ) {
$config[ 'search-col' ][] = "$tagTable.name";
}
}
// Group by model id
$query->groupBy( "$modelTable.id" );
$config[ 'query' ] = $query;
return static::findPage( $config );
} | php | public static function findPageForSearch( $config = [] ) {
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
$parentType = $config[ 'parentType' ] ?? static::$parentType;
// Search in
$searchModel = $config[ 'searchModel' ] ?? true; // Search in model name
$searchCategory = $config[ 'searchCategory' ] ?? false; // Search in category name
$searchTag = $config[ 'searchTag' ] ?? false; // Search in tag name
// DB Tables
$mcategoryTable = CoreTables::TABLE_MODEL_CATEGORY;
$categoryTable = CoreTables::TABLE_CATEGORY;
$mtagTable = CoreTables::TABLE_MODEL_TAG;
$tagTable = CoreTables::TABLE_TAG;
// Sort
$sortParam = Yii::$app->request->get( 'sort' );
$sortParam = preg_replace( '/-/', '', $sortParam );
// Keywords
$searchParam = isset( $config[ 'search-param' ] ) ? $config[ 'search-param' ] : 'keywords';
$keywords = Yii::$app->request->getQueryParam( $searchParam );
// Search Query
$query = $config[ 'query' ] ?? $modelClass::find();
$hasOne = $config[ 'hasOne' ] ?? false;
// Use model joins
if( $hasOne ) {
$query = $modelClass::queryWithHasOne();
}
// Tag
if( $searchTag || isset( $config[ 'tag' ] ) || $sortParam === 'tag' ) {
$query->leftJoin( $mtagTable, "$modelTable.id=$mtagTable.parentId AND $mtagTable.parentType='$parentType' AND $mtagTable.active=TRUE" )
->leftJoin( $tagTable, "$mtagTable.modelId=$tagTable.id" );
}
if( isset( $config[ 'tag' ] ) ) {
$query->andWhere( "$tagTable.id=" . $config[ 'tag' ]->id );
}
// Category
if( $searchCategory || isset( $config[ 'category' ] ) || $sortParam === 'category' ) {
$query->leftJoin( $mcategoryTable, "$modelTable.id=$mcategoryTable.parentId AND $mcategoryTable.parentType='$parentType' AND $mcategoryTable.active=TRUE" )
->leftJoin( $categoryTable, "$mcategoryTable.modelId=$categoryTable.id" );
}
if( isset( $config[ 'category' ] ) ) {
$query->andWhere( "$categoryTable.id=" . $config[ 'category' ]->id );
}
// Search
if( isset( $keywords ) ) {
if( $searchModel ) {
$config[ 'search-col' ][] = "$modelTable.name";
}
if( $searchCategory ) {
$config[ 'search-col' ][] = "$categoryTable.name";
}
if( $searchTag ) {
$config[ 'search-col' ][] = "$tagTable.name";
}
}
// Group by model id
$query->groupBy( "$modelTable.id" );
$config[ 'query' ] = $query;
return static::findPage( $config );
} | [
"public",
"static",
"function",
"findPageForSearch",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"modelClass",
"=",
"static",
"::",
"$",
"modelClass",
";",
"$",
"modelTable",
"=",
"$",
"modelClass",
"::",
"tableName",
"(",
")",
";",
"$",
"parentTyp... | Generate search query using tag and category tables. The search will be done in model, category and tag names. | [
"Generate",
"search",
"query",
"using",
"tag",
"and",
"category",
"tables",
".",
"The",
"search",
"will",
"be",
"done",
"in",
"model",
"category",
"and",
"tag",
"names",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L1050-L1135 |
39,703 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.searchModels | public static function searchModels( $config = [] ) {
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
// Filters
$config = static::applyPublicFilters( $config );
$config = static::applySiteFilters( $config );
// Generate Query
$query = $config[ 'query' ] ?? $modelClass::find();
$offset = $config[ 'offset' ] ?? 0;
$limit = $config[ 'limit' ] ?? self::PAGE_LIMIT;
$conditions = $config[ 'conditions' ] ?? null;
$filters = $config[ 'filters' ] ?? null;
$sort = $config[ 'sort' ] ?? [ 'id' => SORT_DESC ]; // Show latest first
$public = $config[ 'public' ] ?? false;
// Result Columns
$columns = $config[ 'columns' ] ?? [];
// Array Result
$array = $config[ 'array' ] ?? false;
// Selective columns ---
if( count( $columns ) > 0 ) {
$query->select( $columns );
}
// Conditions ----------
if( isset( $conditions ) ) {
foreach( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
$interfaces = class_implements( static::class );
if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {
$statusFilter = $modelClass::STATUS_TERMINATED;
$query->andWhere( "$modelTable.status<$statusFilter" );
}
// Filters -------------
if( isset( $filters ) ) {
foreach( $filters as $filter ) {
$query->andFilterWhere( $filter );
}
}
// Offset --------------
if( $offset > 0 ) {
$query->offset( $offset );
}
// Limit ---------------
if( $limit > 0 ) {
$query->limit( $limit );
}
// Sort -----------------
if( count( $sort ) > 0 ) {
$query->orderBy( $sort );
}
// Print to Debug -------
if( isset( $config[ 'pquery' ] ) && $config[ 'pquery' ] ) {
$command = $query->createCommand();
var_dump( $command );
}
// Models ---------------
if( $array ) {
$models = $query->asArray( $array )->all();
}
else {
$models = $query->all();
}
return $models;
} | php | public static function searchModels( $config = [] ) {
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
// Filters
$config = static::applyPublicFilters( $config );
$config = static::applySiteFilters( $config );
// Generate Query
$query = $config[ 'query' ] ?? $modelClass::find();
$offset = $config[ 'offset' ] ?? 0;
$limit = $config[ 'limit' ] ?? self::PAGE_LIMIT;
$conditions = $config[ 'conditions' ] ?? null;
$filters = $config[ 'filters' ] ?? null;
$sort = $config[ 'sort' ] ?? [ 'id' => SORT_DESC ]; // Show latest first
$public = $config[ 'public' ] ?? false;
// Result Columns
$columns = $config[ 'columns' ] ?? [];
// Array Result
$array = $config[ 'array' ] ?? false;
// Selective columns ---
if( count( $columns ) > 0 ) {
$query->select( $columns );
}
// Conditions ----------
if( isset( $conditions ) ) {
foreach( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
$interfaces = class_implements( static::class );
if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {
$statusFilter = $modelClass::STATUS_TERMINATED;
$query->andWhere( "$modelTable.status<$statusFilter" );
}
// Filters -------------
if( isset( $filters ) ) {
foreach( $filters as $filter ) {
$query->andFilterWhere( $filter );
}
}
// Offset --------------
if( $offset > 0 ) {
$query->offset( $offset );
}
// Limit ---------------
if( $limit > 0 ) {
$query->limit( $limit );
}
// Sort -----------------
if( count( $sort ) > 0 ) {
$query->orderBy( $sort );
}
// Print to Debug -------
if( isset( $config[ 'pquery' ] ) && $config[ 'pquery' ] ) {
$command = $query->createCommand();
var_dump( $command );
}
// Models ---------------
if( $array ) {
$models = $query->asArray( $array )->all();
}
else {
$models = $query->all();
}
return $models;
} | [
"public",
"static",
"function",
"searchModels",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"modelClass",
"=",
"static",
"::",
"$",
"modelClass",
";",
"$",
"modelTable",
"=",
"$",
"modelClass",
"::",
"tableName",
"(",
")",
";",
"// Filters",
"$",
... | Advanced findModels having more options to search. | [
"Advanced",
"findModels",
"having",
"more",
"options",
"to",
"search",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L1161-L1270 |
39,704 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.generateList | public static function generateList( $config = [] ) {
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
// Query and Column
$query = new Query();
$column = $config[ 'column' ] ?? 'id';
// Conditions, Filters and Sorting
$conditions = $config[ 'conditions' ] ?? null;
$filters = $config[ 'filters' ] ?? null;
$order = $config[ 'order' ] ?? null;
// Conditions ----------
$query->select( $column )->from( $modelTable );
if( isset( $conditions ) ) {
foreach ( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
$interfaces = class_implements( static::class );
if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {
$statusFilter = $modelClass::STATUS_TERMINATED;
$query->andWhere( "$modelTable.status<$statusFilter" );
}
// Filters -------------
if( isset( $filters ) ) {
foreach ( $filters as $filter ) {
$query = $query->andFilterWhere( $filter );
}
}
// Sorting -------------
if( isset( $order ) ) {
$query->orderBy( $order );
}
// Quering -------------
// Get column
$query->column();
// Create command
$command = $query->createCommand();
// Execute the command
$list = $command->queryAll();
$resultList = [];
// Result --------------
foreach ( $list as $item ) {
$resultList[] = $item[ $column ];
}
return $resultList;
} | php | public static function generateList( $config = [] ) {
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
// Query and Column
$query = new Query();
$column = $config[ 'column' ] ?? 'id';
// Conditions, Filters and Sorting
$conditions = $config[ 'conditions' ] ?? null;
$filters = $config[ 'filters' ] ?? null;
$order = $config[ 'order' ] ?? null;
// Conditions ----------
$query->select( $column )->from( $modelTable );
if( isset( $conditions ) ) {
foreach ( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
$interfaces = class_implements( static::class );
if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {
$statusFilter = $modelClass::STATUS_TERMINATED;
$query->andWhere( "$modelTable.status<$statusFilter" );
}
// Filters -------------
if( isset( $filters ) ) {
foreach ( $filters as $filter ) {
$query = $query->andFilterWhere( $filter );
}
}
// Sorting -------------
if( isset( $order ) ) {
$query->orderBy( $order );
}
// Quering -------------
// Get column
$query->column();
// Create command
$command = $query->createCommand();
// Execute the command
$list = $command->queryAll();
$resultList = [];
// Result --------------
foreach ( $list as $item ) {
$resultList[] = $item[ $column ];
}
return $resultList;
} | [
"public",
"static",
"function",
"generateList",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"modelClass",
"=",
"static",
"::",
"$",
"modelClass",
";",
"$",
"modelTable",
"=",
"$",
"modelClass",
"::",
"tableName",
"(",
")",
";",
"// Query and Column",... | The method generateList returns an array of list for given column
@param array $config
@return array - array of values. | [
"The",
"method",
"generateList",
"returns",
"an",
"array",
"of",
"list",
"for",
"given",
"column"
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L1308-L1387 |
39,705 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.generateNameValueList | public static function generateNameValueList( $config = [] ) {
$config = static::applySiteFilters( $config );
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
// map columns
$nameColumn = $config[ 'nameColumn' ] ?? 'name';
$valueColumn = $config[ 'valueColumn' ] ?? 'value';
// column alias
$nameAlias = $config[ 'nameAlias' ] ?? 'name';
$valueAlias = $config[ 'valueAlias' ] ?? 'value';
// limit
$limit = $config[ 'limit' ] ?? 0;
// Query
$query = $config[ 'query' ] ?? new Query();
// Conditions, Filters and Sorting
$conditions = $config[ 'conditions' ] ?? null;
$filters = $config[ 'filters' ] ?? null;
$order = $config[ 'order' ] ?? null;
// additional data
$prepend = $config[ 'prepend' ] ?? [];
$append = $config[ 'append' ] ?? [];
// Conditions ----------
$query->select( [ "$nameColumn as $nameAlias", "$valueColumn as $valueAlias" ] )
->from( $modelTable );
if( isset( $conditions ) ) {
foreach( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
$interfaces = class_implements( static::class );
if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {
$statusFilter = $modelClass::STATUS_TERMINATED;
$query->andWhere( "$modelTable.status<$statusFilter" );
}
// Filters -------------
if( isset( $filters ) ) {
foreach( $filters as $filter ) {
$query = $query->andFilterWhere( $filter );
}
}
// Sorting -------------
if( isset( $order ) ) {
$query->orderBy( $order );
}
// Limit ---------------
if( $limit > 0 ) {
$query->limit( $limit );
}
// Quering -------------
// Create command
$command = $query->createCommand();
// Execute the command
$arrayList = $command->queryAll();
// Result --------------
// Prepend given list
if( count( $prepend ) > 0 ) {
$arrayList = ArrayHelper::merge( $prepend, $arrayList );
}
// Append given list
if( count( $append ) > 0 ) {
$arrayList = ArrayHelper::merge( $arrayList, $append );
}
return $arrayList;
} | php | public static function generateNameValueList( $config = [] ) {
$config = static::applySiteFilters( $config );
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
// map columns
$nameColumn = $config[ 'nameColumn' ] ?? 'name';
$valueColumn = $config[ 'valueColumn' ] ?? 'value';
// column alias
$nameAlias = $config[ 'nameAlias' ] ?? 'name';
$valueAlias = $config[ 'valueAlias' ] ?? 'value';
// limit
$limit = $config[ 'limit' ] ?? 0;
// Query
$query = $config[ 'query' ] ?? new Query();
// Conditions, Filters and Sorting
$conditions = $config[ 'conditions' ] ?? null;
$filters = $config[ 'filters' ] ?? null;
$order = $config[ 'order' ] ?? null;
// additional data
$prepend = $config[ 'prepend' ] ?? [];
$append = $config[ 'append' ] ?? [];
// Conditions ----------
$query->select( [ "$nameColumn as $nameAlias", "$valueColumn as $valueAlias" ] )
->from( $modelTable );
if( isset( $conditions ) ) {
foreach( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
$interfaces = class_implements( static::class );
if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {
$statusFilter = $modelClass::STATUS_TERMINATED;
$query->andWhere( "$modelTable.status<$statusFilter" );
}
// Filters -------------
if( isset( $filters ) ) {
foreach( $filters as $filter ) {
$query = $query->andFilterWhere( $filter );
}
}
// Sorting -------------
if( isset( $order ) ) {
$query->orderBy( $order );
}
// Limit ---------------
if( $limit > 0 ) {
$query->limit( $limit );
}
// Quering -------------
// Create command
$command = $query->createCommand();
// Execute the command
$arrayList = $command->queryAll();
// Result --------------
// Prepend given list
if( count( $prepend ) > 0 ) {
$arrayList = ArrayHelper::merge( $prepend, $arrayList );
}
// Append given list
if( count( $append ) > 0 ) {
$arrayList = ArrayHelper::merge( $arrayList, $append );
}
return $arrayList;
} | [
"public",
"static",
"function",
"generateNameValueList",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"static",
"::",
"applySiteFilters",
"(",
"$",
"config",
")",
";",
"$",
"modelClass",
"=",
"static",
"::",
"$",
"modelClass",
";",
"$... | The method generateNameValueList returns an array of associative arrays having name and value as keys for the defined columns.
@param array $config
@return array - associative array of arrays having name and value as keys. | [
"The",
"method",
"generateNameValueList",
"returns",
"an",
"array",
"of",
"associative",
"arrays",
"having",
"name",
"and",
"value",
"as",
"keys",
"for",
"the",
"defined",
"columns",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L1394-L1500 |
39,706 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.generateMap | public static function generateMap( $config = [] ) {
$parentType = static::$parentType;
// column alias
$defaultValue = preg_replace( '/-/', ' ', $parentType );
$default = $config[ 'default' ] ?? false;
$defaultValue = $config[ 'defaultValue' ] ?? ucfirst( $defaultValue );
$nameAlias = $config[ 'nameAlias' ] ?? 'name';
$valueAlias = $config[ 'valueAlias' ] ?? 'value';
$arrayList = static::generateNameValueList( $config );
$map = $default ? [ '0' => "Choose $defaultValue" ] : [];
foreach( $arrayList as $item ) {
$map[ $item[ $nameAlias ] ] = $item[ $valueAlias ];
}
return $map;
} | php | public static function generateMap( $config = [] ) {
$parentType = static::$parentType;
// column alias
$defaultValue = preg_replace( '/-/', ' ', $parentType );
$default = $config[ 'default' ] ?? false;
$defaultValue = $config[ 'defaultValue' ] ?? ucfirst( $defaultValue );
$nameAlias = $config[ 'nameAlias' ] ?? 'name';
$valueAlias = $config[ 'valueAlias' ] ?? 'value';
$arrayList = static::generateNameValueList( $config );
$map = $default ? [ '0' => "Choose $defaultValue" ] : [];
foreach( $arrayList as $item ) {
$map[ $item[ $nameAlias ] ] = $item[ $valueAlias ];
}
return $map;
} | [
"public",
"static",
"function",
"generateMap",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"parentType",
"=",
"static",
"::",
"$",
"parentType",
";",
"// column alias",
"$",
"defaultValue",
"=",
"preg_replace",
"(",
"'/-/'",
",",
"' '",
",",
"$",
"... | The method findMap returns an associative array for the defined table and columns. It also apply the provided conditions.
@param array $config
@return array - associative array of arrays having name as key and value as value. | [
"The",
"method",
"findMap",
"returns",
"an",
"associative",
"array",
"for",
"the",
"defined",
"table",
"and",
"columns",
".",
"It",
"also",
"apply",
"the",
"provided",
"conditions",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L1531-L1552 |
39,707 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.generateObjectMap | public static function generateObjectMap( $config = [] ) {
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
// map columns
$key = $config[ 'key' ] ?? 'id';
$value = static::$modelClass;
// query generation
$query = $config[ 'query' ] ?? $value::find();
$limit = $config[ 'limit' ] ?? self::PAGE_LIMIT;
$conditions = $config[ 'conditions' ] ?? null;
$filters = $config[ 'filters' ] ?? null;
// Conditions ----------
if( isset( $conditions ) ) {
foreach ( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
$interfaces = class_implements( static::class );
if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {
$statusFilter = $modelClass::STATUS_TERMINATED;
$query->andWhere( "$modelTable.status<$statusFilter" );
}
// Filters -------------
if( isset( $filters ) ) {
foreach ( $filters as $filter ) {
$query = $query->andFilterWhere( $filter );
}
}
// Quering -------------
$objects = $query->all();
// Result --------------
$map = [];
foreach( $objects as $object ) {
$map[ $object->$key ] = $object;
}
return $map;
} | php | public static function generateObjectMap( $config = [] ) {
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
// map columns
$key = $config[ 'key' ] ?? 'id';
$value = static::$modelClass;
// query generation
$query = $config[ 'query' ] ?? $value::find();
$limit = $config[ 'limit' ] ?? self::PAGE_LIMIT;
$conditions = $config[ 'conditions' ] ?? null;
$filters = $config[ 'filters' ] ?? null;
// Conditions ----------
if( isset( $conditions ) ) {
foreach ( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
$interfaces = class_implements( static::class );
if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {
$statusFilter = $modelClass::STATUS_TERMINATED;
$query->andWhere( "$modelTable.status<$statusFilter" );
}
// Filters -------------
if( isset( $filters ) ) {
foreach ( $filters as $filter ) {
$query = $query->andFilterWhere( $filter );
}
}
// Quering -------------
$objects = $query->all();
// Result --------------
$map = [];
foreach( $objects as $object ) {
$map[ $object->$key ] = $object;
}
return $map;
} | [
"public",
"static",
"function",
"generateObjectMap",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"modelClass",
"=",
"static",
"::",
"$",
"modelClass",
";",
"$",
"modelTable",
"=",
"$",
"modelClass",
"::",
"tableName",
"(",
")",
";",
"// map columns",... | The method findObjectMap returns an associative array for the defined table and columns. It also apply the provided conditions.
@param array $config | [
"The",
"method",
"findObjectMap",
"returns",
"an",
"associative",
"array",
"for",
"the",
"defined",
"table",
"and",
"columns",
".",
"It",
"also",
"apply",
"the",
"provided",
"conditions",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L1558-L1623 |
39,708 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.generateSearchQuery | public static function generateSearchQuery( $columns, $searchTerms ) {
$searchTerms = preg_split( '/,/', $searchTerms );
$searchQuery = "";
// Multiple columns
if( is_array( $columns ) ) {
foreach( $columns as $ckey => $column ) {
$query = null;
foreach( $searchTerms as $skey => $term ) {
if( $skey == 0 ) {
$query = " $column like '%$term%' ";
}
else {
$query .= " OR $column like '%$term%' ";
}
}
if( isset( $query ) ) {
if( $ckey == 0 ) {
$searchQuery = "( $query )";
}
else {
$searchQuery .= " OR ( $query )";
}
}
}
}
// Single column
else {
foreach( $searchTerms as $key => $value ) {
if( $key == 0 ) {
$searchQuery .= " $columns like '%$value%' ";
}
else {
$searchQuery .= " OR $columns like '%$value%' ";
}
}
}
return $searchQuery;
} | php | public static function generateSearchQuery( $columns, $searchTerms ) {
$searchTerms = preg_split( '/,/', $searchTerms );
$searchQuery = "";
// Multiple columns
if( is_array( $columns ) ) {
foreach( $columns as $ckey => $column ) {
$query = null;
foreach( $searchTerms as $skey => $term ) {
if( $skey == 0 ) {
$query = " $column like '%$term%' ";
}
else {
$query .= " OR $column like '%$term%' ";
}
}
if( isset( $query ) ) {
if( $ckey == 0 ) {
$searchQuery = "( $query )";
}
else {
$searchQuery .= " OR ( $query )";
}
}
}
}
// Single column
else {
foreach( $searchTerms as $key => $value ) {
if( $key == 0 ) {
$searchQuery .= " $columns like '%$value%' ";
}
else {
$searchQuery .= " OR $columns like '%$value%' ";
}
}
}
return $searchQuery;
} | [
"public",
"static",
"function",
"generateSearchQuery",
"(",
"$",
"columns",
",",
"$",
"searchTerms",
")",
"{",
"$",
"searchTerms",
"=",
"preg_split",
"(",
"'/,/'",
",",
"$",
"searchTerms",
")",
";",
"$",
"searchQuery",
"=",
"\"\"",
";",
"// Multiple columns",
... | It generate search query for specified columns by parsing the comma separated search terms | [
"It",
"generate",
"search",
"query",
"for",
"specified",
"columns",
"by",
"parsing",
"the",
"comma",
"separated",
"search",
"terms"
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L1630-L1684 |
39,709 | mcaskill/charcoal-support | src/Admin/Mixin/AdminSearchableTrait.php | AdminSearchableTrait.generateAdminSearchable | protected function generateAdminSearchable()
{
$translator = $this->translator();
$languages = $translator->availableLocales();
$searchKeywords = [];
$searchableProperties = $this->metadata()->get('admin.search.properties');
foreach ($searchableProperties as $propIdent => $searchData) {
$property = $this->property($propIdent);
$objValue = $this[$propIdent];
if (empty($objValue)) {
continue;
}
if ($property instanceof ObjectProperty) {
if (empty($searchData['properties'])) {
continue;
}
$searchProps = $searchData['properties'];
$fillKeywords = function ($relObj) use (&$searchKeywords, $searchProps, $translator, $languages) {
foreach ($searchProps as $searchProp) {
foreach ($languages as $lang) {
$relValue = $relObj->get($searchProp);
$searchKeywords[$lang][] = $translator->translate($relValue, [], null, $lang);
}
}
};
$relObjType = $property->objType();
if ($property->multiple()) {
if (!count($objValue)) {
continue;
}
$relObjIds = implode($property->multipleSeparator(), $objValue);
$this->collectionLoader()
->setModel($relObjType)
->addFilter([
'condition' => sprintf('FIND_IN_SET(objTable.id, "%s")', $relObjIds),
])
->setCallback($fillKeywords)
->load();
} else {
$relObj = $this->modelFactory()->create($relObjType)->load($objValue);
$fillKeywords($relObj);
}
} else {
foreach ($languages as $lang) {
$objValue = $property->parseVal($objValue);
$searchKeywords[$lang][] = $translator->translate($objValue, [], null, $lang);
}
}
}
$this->setAdminSearchKeywords($searchKeywords);
} | php | protected function generateAdminSearchable()
{
$translator = $this->translator();
$languages = $translator->availableLocales();
$searchKeywords = [];
$searchableProperties = $this->metadata()->get('admin.search.properties');
foreach ($searchableProperties as $propIdent => $searchData) {
$property = $this->property($propIdent);
$objValue = $this[$propIdent];
if (empty($objValue)) {
continue;
}
if ($property instanceof ObjectProperty) {
if (empty($searchData['properties'])) {
continue;
}
$searchProps = $searchData['properties'];
$fillKeywords = function ($relObj) use (&$searchKeywords, $searchProps, $translator, $languages) {
foreach ($searchProps as $searchProp) {
foreach ($languages as $lang) {
$relValue = $relObj->get($searchProp);
$searchKeywords[$lang][] = $translator->translate($relValue, [], null, $lang);
}
}
};
$relObjType = $property->objType();
if ($property->multiple()) {
if (!count($objValue)) {
continue;
}
$relObjIds = implode($property->multipleSeparator(), $objValue);
$this->collectionLoader()
->setModel($relObjType)
->addFilter([
'condition' => sprintf('FIND_IN_SET(objTable.id, "%s")', $relObjIds),
])
->setCallback($fillKeywords)
->load();
} else {
$relObj = $this->modelFactory()->create($relObjType)->load($objValue);
$fillKeywords($relObj);
}
} else {
foreach ($languages as $lang) {
$objValue = $property->parseVal($objValue);
$searchKeywords[$lang][] = $translator->translate($objValue, [], null, $lang);
}
}
}
$this->setAdminSearchKeywords($searchKeywords);
} | [
"protected",
"function",
"generateAdminSearchable",
"(",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"translator",
"(",
")",
";",
"$",
"languages",
"=",
"$",
"translator",
"->",
"availableLocales",
"(",
")",
";",
"$",
"searchKeywords",
"=",
"[",
"... | Generate this object's search keywords for the Charcoal Admin.
@return void | [
"Generate",
"this",
"object",
"s",
"search",
"keywords",
"for",
"the",
"Charcoal",
"Admin",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Admin/Mixin/AdminSearchableTrait.php#L53-L112 |
39,710 | plumephp/plume | src/Plume/Provider/ExceptionProvider.php | ExceptionProvider.error_function | public function error_function($errno, $errstr, $errfile, $errline, $errcontext){
$this->provider('log')->exception('error_function',
array('errno' => $errno,'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline, 'errcontext' => $errcontext));
require $this->plume('plume.root.path').$this->plume('plume.templates.500');
die();
// return false;//如果函数返回 FALSE,标准错误处理处理程序将会继续调用。
} | php | public function error_function($errno, $errstr, $errfile, $errline, $errcontext){
$this->provider('log')->exception('error_function',
array('errno' => $errno,'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline, 'errcontext' => $errcontext));
require $this->plume('plume.root.path').$this->plume('plume.templates.500');
die();
// return false;//如果函数返回 FALSE,标准错误处理处理程序将会继续调用。
} | [
"public",
"function",
"error_function",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
",",
"$",
"errcontext",
")",
"{",
"$",
"this",
"->",
"provider",
"(",
"'log'",
")",
"->",
"exception",
"(",
"'error_function'",
",",
... | 1=>'ERROR', 2=>'WARNING', 4=>'PARSE', 8=>'NOTICE' | [
"1",
"=",
">",
"ERROR",
"2",
"=",
">",
"WARNING",
"4",
"=",
">",
"PARSE",
"8",
"=",
">",
"NOTICE"
] | e30baf34729e01fca30e713fe59d285216218eca | https://github.com/plumephp/plume/blob/e30baf34729e01fca30e713fe59d285216218eca/src/Plume/Provider/ExceptionProvider.php#L21-L27 |
39,711 | cmsgears/module-core | common/models/entities/User.php | User.validateSlugUpdate | public function validateSlugUpdate( $attribute, $params ) {
if( !$this->hasErrors() ) {
$existingUser = self::findBySlug( $this->slug );
if( isset( $existingUser ) && $this->id != $existingUser->id ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_SLUG_EXIST ) );
}
}
} | php | public function validateSlugUpdate( $attribute, $params ) {
if( !$this->hasErrors() ) {
$existingUser = self::findBySlug( $this->slug );
if( isset( $existingUser ) && $this->id != $existingUser->id ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_SLUG_EXIST ) );
}
}
} | [
"public",
"function",
"validateSlugUpdate",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasErrors",
"(",
")",
")",
"{",
"$",
"existingUser",
"=",
"self",
"::",
"findBySlug",
"(",
"$",
"this",
"->",
"slug",
... | Validates user slug to ensure that only one user exist with the given slug.
@param type $attribute
@param type $params
@return void | [
"Validates",
"user",
"slug",
"to",
"ensure",
"that",
"only",
"one",
"user",
"exist",
"with",
"the",
"given",
"slug",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L476-L487 |
39,712 | cmsgears/module-core | common/models/entities/User.php | User.validateMobileChange | public function validateMobileChange( $attribute, $params ) {
if( !$this->hasErrors() ) {
$properties = CoreProperties::getInstance();
$existingUser = self::findById( $this->id );
if( isset( $existingUser ) && $existingUser->mobile !== $this->mobile && !$properties->isChangeMobile() ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_CHANGE_USERNAME ) );
}
}
} | php | public function validateMobileChange( $attribute, $params ) {
if( !$this->hasErrors() ) {
$properties = CoreProperties::getInstance();
$existingUser = self::findById( $this->id );
if( isset( $existingUser ) && $existingUser->mobile !== $this->mobile && !$properties->isChangeMobile() ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_CHANGE_USERNAME ) );
}
}
} | [
"public",
"function",
"validateMobileChange",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasErrors",
"(",
")",
")",
"{",
"$",
"properties",
"=",
"CoreProperties",
"::",
"getInstance",
"(",
")",
";",
"$",
"e... | Validates mobile to ensure that it does not allow to change while changing user profile.
@param type $attribute
@param type $params
@return void | [
"Validates",
"mobile",
"to",
"ensure",
"that",
"it",
"does",
"not",
"allow",
"to",
"change",
"while",
"changing",
"user",
"profile",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L554-L566 |
39,713 | cmsgears/module-core | common/models/entities/User.php | User.validatePassword | public function validatePassword( $password ) {
if( isset( $password ) && isset( $this->passwordHash ) ) {
return Yii::$app->getSecurity()->validatePassword( $password, $this->passwordHash );
}
return false;
} | php | public function validatePassword( $password ) {
if( isset( $password ) && isset( $this->passwordHash ) ) {
return Yii::$app->getSecurity()->validatePassword( $password, $this->passwordHash );
}
return false;
} | [
"public",
"function",
"validatePassword",
"(",
"$",
"password",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"password",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"passwordHash",
")",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"getSecurity",
"(",
... | Validates user password while login.
@param type $password
@return boolean | [
"Validates",
"user",
"password",
"while",
"login",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L574-L582 |
39,714 | cmsgears/module-core | common/models/entities/User.php | User.getActiveSiteMember | public function getActiveSiteMember() {
$site = Yii::$app->core->site;
return $this->hasOne( SiteMember::class, [ "userId" => 'id' ] )->where( [ "siteId" => $site->id ] );
} | php | public function getActiveSiteMember() {
$site = Yii::$app->core->site;
return $this->hasOne( SiteMember::class, [ "userId" => 'id' ] )->where( [ "siteId" => $site->id ] );
} | [
"public",
"function",
"getActiveSiteMember",
"(",
")",
"{",
"$",
"site",
"=",
"Yii",
"::",
"$",
"app",
"->",
"core",
"->",
"site",
";",
"return",
"$",
"this",
"->",
"hasOne",
"(",
"SiteMember",
"::",
"class",
",",
"[",
"\"userId\"",
"=>",
"'id'",
"]",
... | Returns site member mapping of active site.
It's useful in multi-site environment to get the member of current site.
@return \cmsgears\core\common\models\mappers\SiteMember | [
"Returns",
"site",
"member",
"mapping",
"of",
"active",
"site",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L603-L608 |
39,715 | cmsgears/module-core | common/models/entities/User.php | User.getRole | public function getRole() {
$roleTable = CoreTables::getTableName( CoreTables::TABLE_ROLE );
$siteTable = CoreTables::getTableName( CoreTables::TABLE_SITE );
$siteMemberTable = CoreTables::getTableName( CoreTables::TABLE_SITE_MEMBER );
// TODO: Check why it's not working without appending one() after recent Yii Upgrade
return Role::find()
->leftJoin( $siteMemberTable, "$siteMemberTable.roleId = $roleTable.id" )
->leftJoin( $siteTable, "$siteTable.id = $siteMemberTable.siteId" )
->where( "$siteMemberTable.userId=:id AND $siteTable.slug=:slug", [ ':id' => $this->id, ':slug' => Yii::$app->core->getSiteSlug() ] )
->one();
} | php | public function getRole() {
$roleTable = CoreTables::getTableName( CoreTables::TABLE_ROLE );
$siteTable = CoreTables::getTableName( CoreTables::TABLE_SITE );
$siteMemberTable = CoreTables::getTableName( CoreTables::TABLE_SITE_MEMBER );
// TODO: Check why it's not working without appending one() after recent Yii Upgrade
return Role::find()
->leftJoin( $siteMemberTable, "$siteMemberTable.roleId = $roleTable.id" )
->leftJoin( $siteTable, "$siteTable.id = $siteMemberTable.siteId" )
->where( "$siteMemberTable.userId=:id AND $siteTable.slug=:slug", [ ':id' => $this->id, ':slug' => Yii::$app->core->getSiteSlug() ] )
->one();
} | [
"public",
"function",
"getRole",
"(",
")",
"{",
"$",
"roleTable",
"=",
"CoreTables",
"::",
"getTableName",
"(",
"CoreTables",
"::",
"TABLE_ROLE",
")",
";",
"$",
"siteTable",
"=",
"CoreTables",
"::",
"getTableName",
"(",
"CoreTables",
"::",
"TABLE_SITE",
")",
... | Returns role assigned to user for active site.
@return Role Assigned to User. | [
"Returns",
"role",
"assigned",
"to",
"user",
"for",
"active",
"site",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L615-L627 |
39,716 | cmsgears/module-core | common/models/entities/User.php | User.getFullName | public function getFullName() {
$name = $this->firstName;
if( !empty( $this->middleName ) ) {
$name = "$name $this->middleName";
}
if( !empty( $this->lastName ) ) {
$name = "$name $this->lastName";
}
return $name;
} | php | public function getFullName() {
$name = $this->firstName;
if( !empty( $this->middleName ) ) {
$name = "$name $this->middleName";
}
if( !empty( $this->lastName ) ) {
$name = "$name $this->lastName";
}
return $name;
} | [
"public",
"function",
"getFullName",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"firstName",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"middleName",
")",
")",
"{",
"$",
"name",
"=",
"\"$name $this->middleName\"",
";",
"}",
"if",
... | Returns full name of user using first name, middle name and last name.
@return string | [
"Returns",
"full",
"name",
"of",
"user",
"using",
"first",
"name",
"middle",
"name",
"and",
"last",
"name",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L681-L696 |
39,717 | cmsgears/module-core | common/models/entities/User.php | User.getName | public function getName() {
$name = $this->getFullName();
if( empty( $name ) ) {
$name = $this->username;
if( empty( $name ) ) {
$name = preg_split( '/@/', $this->email );
$name = $name[ 0 ];
}
}
return $name;
} | php | public function getName() {
$name = $this->getFullName();
if( empty( $name ) ) {
$name = $this->username;
if( empty( $name ) ) {
$name = preg_split( '/@/', $this->email );
$name = $name[ 0 ];
}
}
return $name;
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getFullName",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"username",
";",
"if",
"(",
"empty",
"(... | Returns name of user using first name, middle name and last name.
It returns username or user id of email in case name is not set for the user.
@return string | [
"Returns",
"name",
"of",
"user",
"using",
"first",
"name",
"middle",
"name",
"and",
"last",
"name",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L710-L726 |
39,718 | cmsgears/module-core | common/models/entities/User.php | User.isVerified | public function isVerified( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_VERIFIED;
}
return $this->status >= self::STATUS_VERIFIED;
} | php | public function isVerified( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_VERIFIED;
}
return $this->status >= self::STATUS_VERIFIED;
} | [
"public",
"function",
"isVerified",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_VERIFIED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"s... | Check whether user is verified.
@param boolean $strict
@return boolean | [
"Check",
"whether",
"user",
"is",
"verified",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L747-L755 |
39,719 | cmsgears/module-core | common/models/entities/User.php | User.generateOtp | public function generateOtp() {
$this->otp = random_int( 100000, 999999 );
$valid = DateUtil::getDateTime();
$valid = strtotime( $valid ) + Yii::$app->core->getOtpValidity();
$this->otpValidTill = DateUtil::getDateTimeFromMillis( $valid );
return $this->otp;
} | php | public function generateOtp() {
$this->otp = random_int( 100000, 999999 );
$valid = DateUtil::getDateTime();
$valid = strtotime( $valid ) + Yii::$app->core->getOtpValidity();
$this->otpValidTill = DateUtil::getDateTimeFromMillis( $valid );
return $this->otp;
} | [
"public",
"function",
"generateOtp",
"(",
")",
"{",
"$",
"this",
"->",
"otp",
"=",
"random_int",
"(",
"100000",
",",
"999999",
")",
";",
"$",
"valid",
"=",
"DateUtil",
"::",
"getDateTime",
"(",
")",
";",
"$",
"valid",
"=",
"strtotime",
"(",
"$",
"val... | Generate and set 6 digit random OTP.
@return void | [
"Generate",
"and",
"set",
"6",
"digit",
"random",
"OTP",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L849-L859 |
39,720 | cmsgears/module-core | common/models/entities/User.php | User.isOtpValid | public function isOtpValid( $otp ) {
$now = DateUtil::getDateTime();
return $this->otp == $otp && DateUtil::lessThan( $now, $this->otpValidTill );
} | php | public function isOtpValid( $otp ) {
$now = DateUtil::getDateTime();
return $this->otp == $otp && DateUtil::lessThan( $now, $this->otpValidTill );
} | [
"public",
"function",
"isOtpValid",
"(",
"$",
"otp",
")",
"{",
"$",
"now",
"=",
"DateUtil",
"::",
"getDateTime",
"(",
")",
";",
"return",
"$",
"this",
"->",
"otp",
"==",
"$",
"otp",
"&&",
"DateUtil",
"::",
"lessThan",
"(",
"$",
"now",
",",
"$",
"th... | Check whether OTP is valid.
@param integer $otp
@return boolean | [
"Check",
"whether",
"OTP",
"is",
"valid",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L877-L882 |
39,721 | cmsgears/module-core | common/models/entities/User.php | User.loadPermissions | public function loadPermissions() {
$role = $this->role;
if( isset( $role ) ) {
$this->permissions = $role->getPermissionsSlugList();
}
else {
throw new ForbiddenHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NO_ACCESS ) );
}
} | php | public function loadPermissions() {
$role = $this->role;
if( isset( $role ) ) {
$this->permissions = $role->getPermissionsSlugList();
}
else {
throw new ForbiddenHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NO_ACCESS ) );
}
} | [
"public",
"function",
"loadPermissions",
"(",
")",
"{",
"$",
"role",
"=",
"$",
"this",
"->",
"role",
";",
"if",
"(",
"isset",
"(",
"$",
"role",
")",
")",
"{",
"$",
"this",
"->",
"permissions",
"=",
"$",
"role",
"->",
"getPermissionsSlugList",
"(",
")... | Load the permissions assigned to the user.
The loaded permissions will be queried for access to specific features.
@throws \yii\web\ForbiddenHttpException
@return void | [
"Load",
"the",
"permissions",
"assigned",
"to",
"the",
"user",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L902-L914 |
39,722 | cmsgears/module-core | common/models/entities/User.php | User.isPermitted | public function isPermitted( $permission ) {
if( is_string( $permission ) ) {
return in_array( $permission, $this->permissions );
}
else {
$permitted = false;
foreach( $permission as $perm ) {
if( in_array( $perm, $this->permissions ) ) {
$permitted = true;
break;
}
}
return $permitted;
}
} | php | public function isPermitted( $permission ) {
if( is_string( $permission ) ) {
return in_array( $permission, $this->permissions );
}
else {
$permitted = false;
foreach( $permission as $perm ) {
if( in_array( $perm, $this->permissions ) ) {
$permitted = true;
break;
}
}
return $permitted;
}
} | [
"public",
"function",
"isPermitted",
"(",
"$",
"permission",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"permission",
")",
")",
"{",
"return",
"in_array",
"(",
"$",
"permission",
",",
"$",
"this",
"->",
"permissions",
")",
";",
"}",
"else",
"{",
"$",
... | Check whether given permission is assigned to the user.
@param string $permission Permission slug
@return boolean | [
"Check",
"whether",
"given",
"permission",
"is",
"assigned",
"to",
"the",
"user",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L922-L944 |
39,723 | cmsgears/module-core | common/models/entities/User.php | User.findIdentity | public static function findIdentity( $id ) {
// Find valid User
$user = static::findById( $id );
// Load User Permissions
if( isset( $user ) ) {
if( Yii::$app->core->isRbac() ) {
$user->loadPermissions();
}
return $user;
}
throw new NotFoundHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
} | php | public static function findIdentity( $id ) {
// Find valid User
$user = static::findById( $id );
// Load User Permissions
if( isset( $user ) ) {
if( Yii::$app->core->isRbac() ) {
$user->loadPermissions();
}
return $user;
}
throw new NotFoundHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
} | [
"public",
"static",
"function",
"findIdentity",
"(",
"$",
"id",
")",
"{",
"// Find valid User",
"$",
"user",
"=",
"static",
"::",
"findById",
"(",
"$",
"id",
")",
";",
"// Load User Permissions",
"if",
"(",
"isset",
"(",
"$",
"user",
")",
")",
"{",
"if",... | Finds user identity using the given id and also loads the available permissions if
RBAC is enabled for the application.
@param integer $id
@throws \yii\web\NotFoundHttpException
@return User based on given id. | [
"Finds",
"user",
"identity",
"using",
"the",
"given",
"id",
"and",
"also",
"loads",
"the",
"available",
"permissions",
"if",
"RBAC",
"is",
"enabled",
"for",
"the",
"application",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L960-L977 |
39,724 | cmsgears/module-core | common/models/entities/User.php | User.findIdentityByAccessToken | public static function findIdentityByAccessToken( $token, $type = null ) {
// TODO: Also check access token validity using apiValidDays config
if( Yii::$app->core->isApis() ) {
// Find valid User
$user = static::findByAccessToken( $token );
// Load User Permissions
if( isset( $user ) ) {
if( Yii::$app->core->isRbac() ) {
$user->loadPermissions();
}
return $user;
}
throw new NotFoundHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
}
throw new NotSupportedException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_APIS_DISABLED ) );
} | php | public static function findIdentityByAccessToken( $token, $type = null ) {
// TODO: Also check access token validity using apiValidDays config
if( Yii::$app->core->isApis() ) {
// Find valid User
$user = static::findByAccessToken( $token );
// Load User Permissions
if( isset( $user ) ) {
if( Yii::$app->core->isRbac() ) {
$user->loadPermissions();
}
return $user;
}
throw new NotFoundHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
}
throw new NotSupportedException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_APIS_DISABLED ) );
} | [
"public",
"static",
"function",
"findIdentityByAccessToken",
"(",
"$",
"token",
",",
"$",
"type",
"=",
"null",
")",
"{",
"// TODO: Also check access token validity using apiValidDays config",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"core",
"->",
"isApis",
"(",
"... | Finds user identity using the given access token and also loads the available
permissions if RBAC is enabled for the application.
@param string $token
@param string $type
@throws \yii\web\NotFoundHttpException
@throws \yii\base\NotSupportedException
@return a valid user based on given token and type | [
"Finds",
"user",
"identity",
"using",
"the",
"given",
"access",
"token",
"and",
"also",
"loads",
"the",
"available",
"permissions",
"if",
"RBAC",
"is",
"enabled",
"for",
"the",
"application",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L989-L1013 |
39,725 | cmsgears/module-core | common/models/entities/User.php | User.isExistByEmail | public static function isExistByEmail( $email ) {
$user = self::find()->where( 'email=:email', [ ':email' => $email ] )->one();
return isset( $user );
} | php | public static function isExistByEmail( $email ) {
$user = self::find()->where( 'email=:email', [ ':email' => $email ] )->one();
return isset( $user );
} | [
"public",
"static",
"function",
"isExistByEmail",
"(",
"$",
"email",
")",
"{",
"$",
"user",
"=",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'email=:email'",
",",
"[",
"':email'",
"=>",
"$",
"email",
"]",
")",
"->",
"one",
"(",
")",
";",
"... | Check whether user exist for given email.
@param string $email
@return boolean | [
"Check",
"whether",
"user",
"exist",
"for",
"given",
"email",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L1131-L1136 |
39,726 | cmsgears/module-core | common/models/entities/User.php | User.isExistByUsername | public static function isExistByUsername( $username ) {
$user = self::find()->where( 'username=:username', [ ':username' => $username ] )->one();
return isset( $user );
} | php | public static function isExistByUsername( $username ) {
$user = self::find()->where( 'username=:username', [ ':username' => $username ] )->one();
return isset( $user );
} | [
"public",
"static",
"function",
"isExistByUsername",
"(",
"$",
"username",
")",
"{",
"$",
"user",
"=",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'username=:username'",
",",
"[",
"':username'",
"=>",
"$",
"username",
"]",
")",
"->",
"one",
"(",... | Check whether user exist for given username.
@param string $username
@return boolean | [
"Check",
"whether",
"user",
"exist",
"for",
"given",
"username",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L1155-L1160 |
39,727 | cmsgears/module-core | common/models/entities/User.php | User.isExistBySlug | public static function isExistBySlug( $slug ) {
$user = self::find()->where( 'slug=:slug', [ ':slug' => $slug ] )->one();
return isset( $user );
} | php | public static function isExistBySlug( $slug ) {
$user = self::find()->where( 'slug=:slug', [ ':slug' => $slug ] )->one();
return isset( $user );
} | [
"public",
"static",
"function",
"isExistBySlug",
"(",
"$",
"slug",
")",
"{",
"$",
"user",
"=",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'slug=:slug'",
",",
"[",
"':slug'",
"=>",
"$",
"slug",
"]",
")",
"->",
"one",
"(",
")",
";",
"return... | Check whether user exist for given slug.
@param string $slug
@return boolean | [
"Check",
"whether",
"user",
"exist",
"for",
"given",
"slug",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/User.php#L1179-L1184 |
39,728 | cmsgears/module-core | common/models/resources/FormField.php | FormField.getFieldValue | public function getFieldValue() {
switch( $this->type ) {
case self::TYPE_TEXT:
case self::TYPE_TEXTAREA:
case self::TYPE_RADIO:
case self::TYPE_RADIO_GROUP:
case self::TYPE_SELECT:
case self::TYPE_RATING:
case self::TYPE_ICON:
case self::TYPE_CHECKBOX_GROUP: {
return $this->value;
}
case self::TYPE_PASSWORD: {
return null;
}
case self::TYPE_CHECKBOX:
case self::TYPE_TOGGLE: {
return Yii::$app->formatter->asBoolean( $this->value );
}
}
} | php | public function getFieldValue() {
switch( $this->type ) {
case self::TYPE_TEXT:
case self::TYPE_TEXTAREA:
case self::TYPE_RADIO:
case self::TYPE_RADIO_GROUP:
case self::TYPE_SELECT:
case self::TYPE_RATING:
case self::TYPE_ICON:
case self::TYPE_CHECKBOX_GROUP: {
return $this->value;
}
case self::TYPE_PASSWORD: {
return null;
}
case self::TYPE_CHECKBOX:
case self::TYPE_TOGGLE: {
return Yii::$app->formatter->asBoolean( $this->value );
}
}
} | [
"public",
"function",
"getFieldValue",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"self",
"::",
"TYPE_TEXT",
":",
"case",
"self",
"::",
"TYPE_TEXTAREA",
":",
"case",
"self",
"::",
"TYPE_RADIO",
":",
"case",
"self",
"::",
... | Identify the field value type and return the value according to type.
@return mixed | [
"Identify",
"the",
"field",
"value",
"type",
"and",
"return",
"the",
"value",
"according",
"to",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/FormField.php#L347-L372 |
39,729 | cmsgears/module-core | common/models/resources/FormField.php | FormField.isExistByNameFormId | public static function isExistByNameFormId( $name, $formId ) {
$field = self::findByNameFormId( $name, $formId );
return isset( $field );
} | php | public static function isExistByNameFormId( $name, $formId ) {
$field = self::findByNameFormId( $name, $formId );
return isset( $field );
} | [
"public",
"static",
"function",
"isExistByNameFormId",
"(",
"$",
"name",
",",
"$",
"formId",
")",
"{",
"$",
"field",
"=",
"self",
"::",
"findByNameFormId",
"(",
"$",
"name",
",",
"$",
"formId",
")",
";",
"return",
"isset",
"(",
"$",
"field",
")",
";",
... | Check whether field exist for given name and form id.
@param string $name
@param integer $formId
@return boolean | [
"Check",
"whether",
"field",
"exist",
"for",
"given",
"name",
"and",
"form",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/FormField.php#L450-L455 |
39,730 | cmsgears/module-core | common/models/base/Meta.php | Meta.findByName | public static function findByName( $modelId, $name ) {
$query = self::queryByName( $modelId, $name );
return $query->all();
} | php | public static function findByName( $modelId, $name ) {
$query = self::queryByName( $modelId, $name );
return $query->all();
} | [
"public",
"static",
"function",
"findByName",
"(",
"$",
"modelId",
",",
"$",
"name",
")",
"{",
"$",
"query",
"=",
"self",
"::",
"queryByName",
"(",
"$",
"modelId",
",",
"$",
"name",
")",
";",
"return",
"$",
"query",
"->",
"all",
"(",
")",
";",
"}"
... | Return meta models by parent id and meta name.
@param integer $modelId Parent Id.
@param string $name
@return ModelMeta[] by parent id and meta name. | [
"Return",
"meta",
"models",
"by",
"parent",
"id",
"and",
"meta",
"name",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/Meta.php#L276-L281 |
39,731 | cmsgears/module-core | common/models/base/Meta.php | Meta.findFirstByName | public static function findFirstByName( $modelId, $name ) {
$query = self::queryByName( $modelId, $name );
return $query->one();
} | php | public static function findFirstByName( $modelId, $name ) {
$query = self::queryByName( $modelId, $name );
return $query->one();
} | [
"public",
"static",
"function",
"findFirstByName",
"(",
"$",
"modelId",
",",
"$",
"name",
")",
"{",
"$",
"query",
"=",
"self",
"::",
"queryByName",
"(",
"$",
"modelId",
",",
"$",
"name",
")",
";",
"return",
"$",
"query",
"->",
"one",
"(",
")",
";",
... | Return first meta model by parent id and meta name.
@param integer $modelId Parent Id.
@param string $name
@return ModelMeta|array|null by parent id and meta name. | [
"Return",
"first",
"meta",
"model",
"by",
"parent",
"id",
"and",
"meta",
"name",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/Meta.php#L290-L295 |
39,732 | cmsgears/module-core | common/models/base/Meta.php | Meta.findByNameType | public static function findByNameType( $modelId, $name, $type ) {
return self::queryByNameType( $modelId, $name, $type )->one();
} | php | public static function findByNameType( $modelId, $name, $type ) {
return self::queryByNameType( $modelId, $name, $type )->one();
} | [
"public",
"static",
"function",
"findByNameType",
"(",
"$",
"modelId",
",",
"$",
"name",
",",
"$",
"type",
")",
"{",
"return",
"self",
"::",
"queryByNameType",
"(",
"$",
"modelId",
",",
"$",
"name",
",",
"$",
"type",
")",
"->",
"one",
"(",
")",
";",
... | Return meta model by parent id, meta name and meta type.
@param integer $modelId Parent Id.
@param string $name
@param string $type
@return ModelMeta|array|null by parent id, meta name and meta type. | [
"Return",
"meta",
"model",
"by",
"parent",
"id",
"meta",
"name",
"and",
"meta",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/Meta.php#L317-L320 |
39,733 | cmsgears/module-core | common/models/base/Meta.php | Meta.isExistByNameType | public static function isExistByNameType( $modelId, $name, $type ) {
$meta = self::findByNameType( $modelId, $type, $name );
return isset( $meta );
} | php | public static function isExistByNameType( $modelId, $name, $type ) {
$meta = self::findByNameType( $modelId, $type, $name );
return isset( $meta );
} | [
"public",
"static",
"function",
"isExistByNameType",
"(",
"$",
"modelId",
",",
"$",
"name",
",",
"$",
"type",
")",
"{",
"$",
"meta",
"=",
"self",
"::",
"findByNameType",
"(",
"$",
"modelId",
",",
"$",
"type",
",",
"$",
"name",
")",
";",
"return",
"is... | Check whether meta exist by parent id, meta name and meta type.
@param integer $modelId Parent Id.
@param string $name
@param string $type
@return boolean | [
"Check",
"whether",
"meta",
"exist",
"by",
"parent",
"id",
"meta",
"name",
"and",
"meta",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/Meta.php#L330-L335 |
39,734 | cmsgears/module-core | common/models/base/Meta.php | Meta.updateByNameType | public static function updateByNameType( $modelId, $name, $type, $value ) {
$meta = self::findByNameType( $modelId, $name, $type );
if( isset( $meta ) ) {
$meta->value = $value;
return $meta->update();
}
return false;
} | php | public static function updateByNameType( $modelId, $name, $type, $value ) {
$meta = self::findByNameType( $modelId, $name, $type );
if( isset( $meta ) ) {
$meta->value = $value;
return $meta->update();
}
return false;
} | [
"public",
"static",
"function",
"updateByNameType",
"(",
"$",
"modelId",
",",
"$",
"name",
",",
"$",
"type",
",",
"$",
"value",
")",
"{",
"$",
"meta",
"=",
"self",
"::",
"findByNameType",
"(",
"$",
"modelId",
",",
"$",
"name",
",",
"$",
"type",
")",
... | Update the meta value for given parent id, name, type.
@param integer $modelId Parent Id.
@param string $name
@param string $type
@param type $value
@return int|false either 1 or false if meta not found or validation fails. | [
"Update",
"the",
"meta",
"value",
"for",
"given",
"parent",
"id",
"name",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/Meta.php#L350-L362 |
39,735 | techdivision/import-product-variant-ee | src/Subjects/EeVariantSubject.php | EeVariantSubject.mapSkuToRowId | public function mapSkuToRowId($sku)
{
// query weather or not the SKU has been mapped
if (isset($this->skuRowIdMapping[$sku])) {
return $this->skuRowIdMapping[$sku];
}
// throw an exception if the SKU has not been mapped yet
throw new \Exception(sprintf('Found not mapped SKU %s', $sku));
} | php | public function mapSkuToRowId($sku)
{
// query weather or not the SKU has been mapped
if (isset($this->skuRowIdMapping[$sku])) {
return $this->skuRowIdMapping[$sku];
}
// throw an exception if the SKU has not been mapped yet
throw new \Exception(sprintf('Found not mapped SKU %s', $sku));
} | [
"public",
"function",
"mapSkuToRowId",
"(",
"$",
"sku",
")",
"{",
"// query weather or not the SKU has been mapped",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"skuRowIdMapping",
"[",
"$",
"sku",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"skuRowIdMappi... | Return the row ID for the passed SKU.
@param string $sku The SKU to return the row ID for
@return integer The mapped row ID
@throws \Exception Is thrown if the SKU is not mapped yet | [
"Return",
"the",
"row",
"ID",
"for",
"the",
"passed",
"SKU",
"."
] | 9421d30782ea45924f9cc86fe5d6169aadc9817f | https://github.com/techdivision/import-product-variant-ee/blob/9421d30782ea45924f9cc86fe5d6169aadc9817f/src/Subjects/EeVariantSubject.php#L76-L86 |
39,736 | phPoirot/Std | src/CallableArgsResolver.php | CallableArgsResolver.makeReflectFromCallable | static function makeReflectFromCallable(callable $callable)
{
if ( $callable instanceof ipInvokableCallback )
$callable = $callable->getCallable();
if ( is_array($callable) )
// [className_orObject, 'method_name']
$reflection = new \ReflectionMethod($callable[0], $callable[1]);
if ( is_string($callable) ) {
if ( strpos($callable, '::') )
// 'classname::method'
$reflection = new \ReflectionMethod($callable);
else
// 'function_name'
$reflection = new \ReflectionFunction($callable);
}
if ( method_exists($callable, '__invoke') ) {
// Closure and Invokable
if ($callable instanceof \Closure)
$reflection = new \ReflectionFunction($callable);
else
$reflection = new \ReflectionMethod($callable, '__invoke');
}
if (! isset($reflection) )
throw new \ReflectionException;
return $reflection;
} | php | static function makeReflectFromCallable(callable $callable)
{
if ( $callable instanceof ipInvokableCallback )
$callable = $callable->getCallable();
if ( is_array($callable) )
// [className_orObject, 'method_name']
$reflection = new \ReflectionMethod($callable[0], $callable[1]);
if ( is_string($callable) ) {
if ( strpos($callable, '::') )
// 'classname::method'
$reflection = new \ReflectionMethod($callable);
else
// 'function_name'
$reflection = new \ReflectionFunction($callable);
}
if ( method_exists($callable, '__invoke') ) {
// Closure and Invokable
if ($callable instanceof \Closure)
$reflection = new \ReflectionFunction($callable);
else
$reflection = new \ReflectionMethod($callable, '__invoke');
}
if (! isset($reflection) )
throw new \ReflectionException;
return $reflection;
} | [
"static",
"function",
"makeReflectFromCallable",
"(",
"callable",
"$",
"callable",
")",
"{",
"if",
"(",
"$",
"callable",
"instanceof",
"ipInvokableCallback",
")",
"$",
"callable",
"=",
"$",
"callable",
"->",
"getCallable",
"(",
")",
";",
"if",
"(",
"is_array",... | Factory Reflection From Given Callable
$function
'function_name' | \closure
'classname::method'
[className_orObject, 'method_name']
@param $callable
@throws \ReflectionException
@return \ReflectionFunction|\ReflectionMethod | [
"Factory",
"Reflection",
"From",
"Given",
"Callable"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/CallableArgsResolver.php#L23-L53 |
39,737 | phPoirot/Std | src/CallableArgsResolver.php | CallableArgsResolver.resolveCallableWithArgs | static function resolveCallableWithArgs(callable $callable, $parameters)
{
if ($parameters instanceof \Traversable)
$parameters = \Poirot\Std\cast($parameters)->toArray();
$reflection = self::makeReflectFromCallable($callable);
$matchedArguments = self::resolveArgsForReflection($reflection, $parameters);
if (!empty($parameters) && empty($matchedArguments))
// In Case That Fun Has No Any Argument.
// exp. func() { $args = func_get_args() ..
$matchedArguments = $parameters;
$callbackResolved = function() use ($callable, $matchedArguments) {
return call_user_func_array($callable, $matchedArguments);
};
return $callbackResolved;
} | php | static function resolveCallableWithArgs(callable $callable, $parameters)
{
if ($parameters instanceof \Traversable)
$parameters = \Poirot\Std\cast($parameters)->toArray();
$reflection = self::makeReflectFromCallable($callable);
$matchedArguments = self::resolveArgsForReflection($reflection, $parameters);
if (!empty($parameters) && empty($matchedArguments))
// In Case That Fun Has No Any Argument.
// exp. func() { $args = func_get_args() ..
$matchedArguments = $parameters;
$callbackResolved = function() use ($callable, $matchedArguments) {
return call_user_func_array($callable, $matchedArguments);
};
return $callbackResolved;
} | [
"static",
"function",
"resolveCallableWithArgs",
"(",
"callable",
"$",
"callable",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"$",
"parameters",
"instanceof",
"\\",
"Traversable",
")",
"$",
"parameters",
"=",
"\\",
"Poirot",
"\\",
"Std",
"\\",
"cast",
"(",... | Resolve Arguments Matched With Callable Arguments
@param callable $callable
@param array|\Traversable $parameters Params to match with function arguments
@return \Closure
@throws \InvalidArgumentException | [
"Resolve",
"Arguments",
"Matched",
"With",
"Callable",
"Arguments"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/CallableArgsResolver.php#L64-L83 |
39,738 | mcaskill/charcoal-support | src/Cms/SectionAwareTrait.php | SectionAwareTrait.getSection | private function getSection()
{
$this->section = $this->modelFactory()->get($this->sectionClass());
return $this->section;
} | php | private function getSection()
{
$this->section = $this->modelFactory()->get($this->sectionClass());
return $this->section;
} | [
"private",
"function",
"getSection",
"(",
")",
"{",
"$",
"this",
"->",
"section",
"=",
"$",
"this",
"->",
"modelFactory",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"sectionClass",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"section",
";",
... | Retrieve a prototype from the section model name.
@return SectionInterface | [
"Retrieve",
"a",
"prototype",
"from",
"the",
"section",
"model",
"name",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/SectionAwareTrait.php#L69-L74 |
39,739 | mcaskill/charcoal-support | src/Cms/SectionAwareTrait.php | SectionAwareTrait.createSection | private function createSection()
{
$this->section = $this->modelFactory()->create($this->sectionClass());
return $this->section;
} | php | private function createSection()
{
$this->section = $this->modelFactory()->create($this->sectionClass());
return $this->section;
} | [
"private",
"function",
"createSection",
"(",
")",
"{",
"$",
"this",
"->",
"section",
"=",
"$",
"this",
"->",
"modelFactory",
"(",
")",
"->",
"create",
"(",
"$",
"this",
"->",
"sectionClass",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"section",
... | Create a new section object from the section model name.
@return SectionInterface | [
"Create",
"a",
"new",
"section",
"object",
"from",
"the",
"section",
"model",
"name",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/SectionAwareTrait.php#L81-L86 |
39,740 | mcaskill/charcoal-support | src/Cms/SectionAwareTrait.php | SectionAwareTrait.setSection | public function setSection($obj)
{
if ($obj instanceof SectionInterface) {
$this->section = $obj;
} else {
$this->createSection();
$this->section->load($obj);
}
return $this;
} | php | public function setSection($obj)
{
if ($obj instanceof SectionInterface) {
$this->section = $obj;
} else {
$this->createSection();
$this->section->load($obj);
}
return $this;
} | [
"public",
"function",
"setSection",
"(",
"$",
"obj",
")",
"{",
"if",
"(",
"$",
"obj",
"instanceof",
"SectionInterface",
")",
"{",
"$",
"this",
"->",
"section",
"=",
"$",
"obj",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"createSection",
"(",
")",
";",... | Assign the current section object.
@see Charcoal\Object\RoutableInterface The section object is usually determined by the route.
@param SectionInterface|integer $obj A section object or ID.
@return self | [
"Assign",
"the",
"current",
"section",
"object",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/SectionAwareTrait.php#L95-L106 |
39,741 | mcaskill/charcoal-support | src/Cms/SectionAwareTrait.php | SectionAwareTrait.templateOptions | public function templateOptions()
{
$section = $this->section();
$options = $section->templateOptions();
if (is_string($options)) {
return json_decode($options);
}
return [];
} | php | public function templateOptions()
{
$section = $this->section();
$options = $section->templateOptions();
if (is_string($options)) {
return json_decode($options);
}
return [];
} | [
"public",
"function",
"templateOptions",
"(",
")",
"{",
"$",
"section",
"=",
"$",
"this",
"->",
"section",
"(",
")",
";",
"$",
"options",
"=",
"$",
"section",
"->",
"templateOptions",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"options",
")",
"... | Retrieve the template options from the current section.
@return array | [
"Retrieve",
"the",
"template",
"options",
"from",
"the",
"current",
"section",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/SectionAwareTrait.php#L129-L139 |
39,742 | phpgithook/hello-world | src/Hooks/PostCommit.php | PostCommit.postCommit | public function postCommit(
InputInterface $input,
OutputInterface $output,
ParameterBagInterface $configuration
): void {
// Yes we can send a notification to slack fx?
// Then we would just add some configuration with slack channel, username etc etc
// And then require the slack API via composer and do the code here
// But very simple, we can say Hello World! to the console
$output->write('Hello World!');
} | php | public function postCommit(
InputInterface $input,
OutputInterface $output,
ParameterBagInterface $configuration
): void {
// Yes we can send a notification to slack fx?
// Then we would just add some configuration with slack channel, username etc etc
// And then require the slack API via composer and do the code here
// But very simple, we can say Hello World! to the console
$output->write('Hello World!');
} | [
"public",
"function",
"postCommit",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
",",
"ParameterBagInterface",
"$",
"configuration",
")",
":",
"void",
"{",
"// Yes we can send a notification to slack fx?",
"// Then we would just add some configu... | Called after the actual commit is made. Because of this, it cannot disrupt the commit.
It is mainly used to allow notifications.
@param InputInterface $input
@param OutputInterface $output
@param ParameterBagInterface $configuration | [
"Called",
"after",
"the",
"actual",
"commit",
"is",
"made",
".",
"Because",
"of",
"this",
"it",
"cannot",
"disrupt",
"the",
"commit",
".",
"It",
"is",
"mainly",
"used",
"to",
"allow",
"notifications",
"."
] | c01e5d57b24f5b4823c4007127d8fdf401f2f7da | https://github.com/phpgithook/hello-world/blob/c01e5d57b24f5b4823c4007127d8fdf401f2f7da/src/Hooks/PostCommit.php#L20-L31 |
39,743 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheConfig.php | CacheConfig.addType | public function addType($type)
{
if (!in_array($type, $this->validTypes())) {
throw new InvalidArgumentException(
sprintf('Invalid cache type: "%s"', $type)
);
}
$this->types[$type] = true;
return $this;
} | php | public function addType($type)
{
if (!in_array($type, $this->validTypes())) {
throw new InvalidArgumentException(
sprintf('Invalid cache type: "%s"', $type)
);
}
$this->types[$type] = true;
return $this;
} | [
"public",
"function",
"addType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"validTypes",
"(",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid cache typ... | Add a cache type to use.
@param string $type The cache type.
@throws InvalidArgumentException If the type is not a string or unsupported.
@return CacheConfig Chainable | [
"Add",
"a",
"cache",
"type",
"to",
"use",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheConfig.php#L139-L149 |
39,744 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheConfig.php | CacheConfig.setDefaultTtl | public function setDefaultTtl($ttl)
{
if (!is_numeric($ttl)) {
throw new InvalidArgumentException(
'TTL must be an integer (seconds)'
);
}
$this->defaultTtl = intval($ttl);
return $this;
} | php | public function setDefaultTtl($ttl)
{
if (!is_numeric($ttl)) {
throw new InvalidArgumentException(
'TTL must be an integer (seconds)'
);
}
$this->defaultTtl = intval($ttl);
return $this;
} | [
"public",
"function",
"setDefaultTtl",
"(",
"$",
"ttl",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"ttl",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'TTL must be an integer (seconds)'",
")",
";",
"}",
"$",
"this",
"->",
"defaultT... | Set the default time-to-live for cached items.
@param mixed $ttl A number representing time in seconds.
@throws InvalidArgumentException If the TTL is not numeric.
@return CacheConfig Chainable | [
"Set",
"the",
"default",
"time",
"-",
"to",
"-",
"live",
"for",
"cached",
"items",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheConfig.php#L201-L211 |
39,745 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheConfig.php | CacheConfig.setPrefix | public function setPrefix($prefix)
{
if (!is_string($prefix)) {
throw new InvalidArgumentException(
'Prefix must be a string'
);
}
/** @see \Stash\Pool\::setNamespace */
if (!ctype_alnum($prefix)) {
throw new InvalidArgumentException(
'Prefix must be alphanumeric'
);
}
$this->prefix = $prefix;
return $this;
} | php | public function setPrefix($prefix)
{
if (!is_string($prefix)) {
throw new InvalidArgumentException(
'Prefix must be a string'
);
}
/** @see \Stash\Pool\::setNamespace */
if (!ctype_alnum($prefix)) {
throw new InvalidArgumentException(
'Prefix must be alphanumeric'
);
}
$this->prefix = $prefix;
return $this;
} | [
"public",
"function",
"setPrefix",
"(",
"$",
"prefix",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"prefix",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Prefix must be a string'",
")",
";",
"}",
"/** @see \\Stash\\Pool\\::setNamespace */... | Set the cache namespace.
@param string $prefix The cache prefix (or namespace).
@throws InvalidArgumentException If the prefix is not a string.
@return CacheConfig Chainable | [
"Set",
"the",
"cache",
"namespace",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheConfig.php#L230-L247 |
39,746 | rodrigoiii/skeleton-core | src/classes/Utilities/Validator.php | Validator.validate | public static function validate($request, $rules, $messages=[])
{
$errors = [];
$files = $request->getUploadedFiles();
foreach ($rules as $field => $rule)
{
try
{
if ($rule instanceof v)
{
// check if the field is for file
if (isset($files[$field]))
{
if (is_array($files[$field])) // multiple file
{
$files = $files[$field];
foreach ($files as $file_row)
{
if ($file_row instanceof UploadedFile)
{
$rule->setName(str_title(ucfirst($field)))->assert(new \SplFileInfo($file_row->file));
}
}
}
else // single file
{
if ($files[$field] instanceof UploadedFile)
{
$rule->setName(str_title(ucfirst($field)))->assert(new \SplFileInfo($files[$field]->file));
}
}
}
else
{
$rule->setName(str_title(ucfirst($field)))->assert($request->getParam($field));
}
}
else
{
\Log::error("Error: Rule must be Respect\Validation\Validator object");
}
} catch (NestedValidationException $e) {
$translator = config('validation.translator');
$e->setParam('translator', function($message) use($translator) {
$language = $translator['lang'];
$messages = $translator['messages'];
return isset($messages[$message]) ? $messages[$message][$language] : $message;
});
$e->findMessages($messages);
$errors[$field] = $e->getMessages();
}
}
Session::set('errors', $errors);
return __CLASS__;
} | php | public static function validate($request, $rules, $messages=[])
{
$errors = [];
$files = $request->getUploadedFiles();
foreach ($rules as $field => $rule)
{
try
{
if ($rule instanceof v)
{
// check if the field is for file
if (isset($files[$field]))
{
if (is_array($files[$field])) // multiple file
{
$files = $files[$field];
foreach ($files as $file_row)
{
if ($file_row instanceof UploadedFile)
{
$rule->setName(str_title(ucfirst($field)))->assert(new \SplFileInfo($file_row->file));
}
}
}
else // single file
{
if ($files[$field] instanceof UploadedFile)
{
$rule->setName(str_title(ucfirst($field)))->assert(new \SplFileInfo($files[$field]->file));
}
}
}
else
{
$rule->setName(str_title(ucfirst($field)))->assert($request->getParam($field));
}
}
else
{
\Log::error("Error: Rule must be Respect\Validation\Validator object");
}
} catch (NestedValidationException $e) {
$translator = config('validation.translator');
$e->setParam('translator', function($message) use($translator) {
$language = $translator['lang'];
$messages = $translator['messages'];
return isset($messages[$message]) ? $messages[$message][$language] : $message;
});
$e->findMessages($messages);
$errors[$field] = $e->getMessages();
}
}
Session::set('errors', $errors);
return __CLASS__;
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"request",
",",
"$",
"rules",
",",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"$",
"request",
"->",
"getUploadedFiles",
"(",
")",
";",
"forea... | Put all fails in session
@param Psr\Http\Message\RequestInterface $request
@param array $rules
@return SkeletonCore\Utilities\Validator | [
"Put",
"all",
"fails",
"in",
"session"
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/Utilities/Validator.php#L18-L75 |
39,747 | cmsgears/module-core | common/models/resources/File.php | File.getFileUrl | public function getFileUrl() {
if( $this->changed ) {
return Yii::$app->fileManager->uploadUrl . '/' . CoreProperties::DIR_TEMP . $this->directory . "/" . $this->name . "." . $this->extension;
}
else if( $this->id > 0 ) {
return Yii::$app->fileManager->uploadUrl . '/' . $this->url;
}
return "";
} | php | public function getFileUrl() {
if( $this->changed ) {
return Yii::$app->fileManager->uploadUrl . '/' . CoreProperties::DIR_TEMP . $this->directory . "/" . $this->name . "." . $this->extension;
}
else if( $this->id > 0 ) {
return Yii::$app->fileManager->uploadUrl . '/' . $this->url;
}
return "";
} | [
"public",
"function",
"getFileUrl",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"changed",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"fileManager",
"->",
"uploadUrl",
".",
"'/'",
".",
"CoreProperties",
"::",
"DIR_TEMP",
".",
"$",
"this",
"->"... | Generate and Return file URL using file attributes.
@return string | [
"Generate",
"and",
"Return",
"file",
"URL",
"using",
"file",
"attributes",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/File.php#L259-L271 |
39,748 | cmsgears/module-core | common/models/resources/File.php | File.getMediumUrl | public function getMediumUrl() {
if( $this->changed ) {
return Yii::$app->fileManager->uploadUrl . '/' . CoreProperties::DIR_TEMP . $this->directory . "/" . $this->name . "-medium." . $this->extension;
}
else if( $this->id > 0 ) {
return Yii::$app->fileManager->uploadUrl . '/' . $this->medium;
}
return "";
} | php | public function getMediumUrl() {
if( $this->changed ) {
return Yii::$app->fileManager->uploadUrl . '/' . CoreProperties::DIR_TEMP . $this->directory . "/" . $this->name . "-medium." . $this->extension;
}
else if( $this->id > 0 ) {
return Yii::$app->fileManager->uploadUrl . '/' . $this->medium;
}
return "";
} | [
"public",
"function",
"getMediumUrl",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"changed",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"fileManager",
"->",
"uploadUrl",
".",
"'/'",
".",
"CoreProperties",
"::",
"DIR_TEMP",
".",
"$",
"this",
"-... | Generate and Return medium file URL using file attributes.
@return string | [
"Generate",
"and",
"Return",
"medium",
"file",
"URL",
"using",
"file",
"attributes",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/File.php#L278-L290 |
39,749 | cmsgears/module-core | common/models/resources/File.php | File.getThumbUrl | public function getThumbUrl() {
if( $this->changed ) {
return Yii::$app->fileManager->uploadUrl . '/' . CoreProperties::DIR_TEMP . $this->directory . "/" . $this->name . "-thumb." . $this->extension;
}
else if( $this->id > 0 ) {
return Yii::$app->fileManager->uploadUrl . '/' . $this->thumb;
}
return "";
} | php | public function getThumbUrl() {
if( $this->changed ) {
return Yii::$app->fileManager->uploadUrl . '/' . CoreProperties::DIR_TEMP . $this->directory . "/" . $this->name . "-thumb." . $this->extension;
}
else if( $this->id > 0 ) {
return Yii::$app->fileManager->uploadUrl . '/' . $this->thumb;
}
return "";
} | [
"public",
"function",
"getThumbUrl",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"changed",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"fileManager",
"->",
"uploadUrl",
".",
"'/'",
".",
"CoreProperties",
"::",
"DIR_TEMP",
".",
"$",
"this",
"->... | Generate and Return thumb URL using file attributes.
@return string | [
"Generate",
"and",
"Return",
"thumb",
"URL",
"using",
"file",
"attributes",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/File.php#L297-L309 |
39,750 | cmsgears/module-core | common/models/resources/File.php | File.getFilePath | public function getFilePath() {
if( isset( $this->url ) ) {
return Yii::$app->fileManager->uploadDir . '/' . $this->url;
}
return false;
} | php | public function getFilePath() {
if( isset( $this->url ) ) {
return Yii::$app->fileManager->uploadDir . '/' . $this->url;
}
return false;
} | [
"public",
"function",
"getFilePath",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"url",
")",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"fileManager",
"->",
"uploadDir",
".",
"'/'",
".",
"$",
"this",
"->",
"url",
";",
"}",
... | Return physical storage location of the file.
@return string|boolean | [
"Return",
"physical",
"storage",
"location",
"of",
"the",
"file",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/File.php#L316-L324 |
39,751 | cmsgears/module-core | common/models/resources/File.php | File.getMediumPath | public function getMediumPath() {
if( isset( $this->medium ) ) {
return Yii::$app->fileManager->uploadDir . '/' . $this->medium;
}
return false;
} | php | public function getMediumPath() {
if( isset( $this->medium ) ) {
return Yii::$app->fileManager->uploadDir . '/' . $this->medium;
}
return false;
} | [
"public",
"function",
"getMediumPath",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"medium",
")",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"fileManager",
"->",
"uploadDir",
".",
"'/'",
".",
"$",
"this",
"->",
"medium",
";",
... | Return physical storage location of the medium file.
@return string|boolean | [
"Return",
"physical",
"storage",
"location",
"of",
"the",
"medium",
"file",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/File.php#L331-L339 |
39,752 | cmsgears/module-core | common/models/resources/File.php | File.getThumbPath | public function getThumbPath() {
if( isset( $this->thumb ) ) {
return Yii::$app->fileManager->uploadDir . '/' . $this->thumb;
}
return false;
} | php | public function getThumbPath() {
if( isset( $this->thumb ) ) {
return Yii::$app->fileManager->uploadDir . '/' . $this->thumb;
}
return false;
} | [
"public",
"function",
"getThumbPath",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"thumb",
")",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"fileManager",
"->",
"uploadDir",
".",
"'/'",
".",
"$",
"this",
"->",
"thumb",
";",
"}... | Return physical storage location of thumb.
@return string|boolean | [
"Return",
"physical",
"storage",
"location",
"of",
"thumb",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/File.php#L346-L354 |
39,753 | cmsgears/module-core | common/models/resources/File.php | File.resetSize | public function resetSize() {
$filePath = $this->getFilePath();
if( $filePath && file_exists( $filePath ) && is_file( $filePath ) ) {
$size = filesize( $filePath ); // bytes
$sizeInMb = $size / pow( 1024, 2 );
$this->size = round( $sizeInMb, 4 ); // Round upto 4 precision, expected size at least in kb
}
} | php | public function resetSize() {
$filePath = $this->getFilePath();
if( $filePath && file_exists( $filePath ) && is_file( $filePath ) ) {
$size = filesize( $filePath ); // bytes
$sizeInMb = $size / pow( 1024, 2 );
$this->size = round( $sizeInMb, 4 ); // Round upto 4 precision, expected size at least in kb
}
} | [
"public",
"function",
"resetSize",
"(",
")",
"{",
"$",
"filePath",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
")",
";",
"if",
"(",
"$",
"filePath",
"&&",
"file_exists",
"(",
"$",
"filePath",
")",
"&&",
"is_file",
"(",
"$",
"filePath",
")",
")",
"{",... | Calculate and set the file size in MB.
@return void | [
"Calculate",
"and",
"set",
"the",
"file",
"size",
"in",
"MB",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/File.php#L361-L372 |
39,754 | cmsgears/module-core | common/models/resources/File.php | File.clearDisk | public function clearDisk() {
$filePath = $this->getFilePath();
$mediumPath = $this->getMediumPath();
$thumbPath = $this->getThumbPath();
// Delete from disk
if( $filePath && file_exists( $filePath ) && is_file( $filePath ) ) {
unlink( $filePath );
}
if( $mediumPath && file_exists( $mediumPath ) && is_file( $mediumPath ) ) {
unlink( $mediumPath );
}
if( $thumbPath && file_exists( $thumbPath ) && is_file( $thumbPath ) ) {
unlink( $thumbPath );
}
} | php | public function clearDisk() {
$filePath = $this->getFilePath();
$mediumPath = $this->getMediumPath();
$thumbPath = $this->getThumbPath();
// Delete from disk
if( $filePath && file_exists( $filePath ) && is_file( $filePath ) ) {
unlink( $filePath );
}
if( $mediumPath && file_exists( $mediumPath ) && is_file( $mediumPath ) ) {
unlink( $mediumPath );
}
if( $thumbPath && file_exists( $thumbPath ) && is_file( $thumbPath ) ) {
unlink( $thumbPath );
}
} | [
"public",
"function",
"clearDisk",
"(",
")",
"{",
"$",
"filePath",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
")",
";",
"$",
"mediumPath",
"=",
"$",
"this",
"->",
"getMediumPath",
"(",
")",
";",
"$",
"thumbPath",
"=",
"$",
"this",
"->",
"getThumbPath"... | Delete all the associated files from disk. Useful while updating file.
@return void | [
"Delete",
"all",
"the",
"associated",
"files",
"from",
"disk",
".",
"Useful",
"while",
"updating",
"file",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/File.php#L379-L400 |
39,755 | cmsgears/module-core | common/models/resources/File.php | File.loadFile | public static function loadFile( $file, $name ) {
if( !isset( $file ) ) {
$file = new File();
}
$file->load( Yii::$app->request->post(), $name );
return $file;
} | php | public static function loadFile( $file, $name ) {
if( !isset( $file ) ) {
$file = new File();
}
$file->load( Yii::$app->request->post(), $name );
return $file;
} | [
"public",
"static",
"function",
"loadFile",
"(",
"$",
"file",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"file",
")",
")",
"{",
"$",
"file",
"=",
"new",
"File",
"(",
")",
";",
"}",
"$",
"file",
"->",
"load",
"(",
"Yii",
":... | Load the file attributes submitted by form and return the updated file model.
@param File $file
@param string $name
@return File - after loading from request url | [
"Load",
"the",
"file",
"attributes",
"submitted",
"by",
"form",
"and",
"return",
"the",
"updated",
"file",
"model",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/File.php#L497-L507 |
39,756 | cmsgears/module-core | common/models/resources/File.php | File.loadFiles | public function loadFiles( $name, $files = [] ) {
$filesToLoad = Yii::$app->request->post( $name );
$count = count( $filesToLoad );
if ( $count > 0 ) {
$filesToLoad = [];
// TODO: Use existing file models using $files param.
for( $i = 0; $i < $count; $i++ ) {
$filesToLoad[] = new File();
}
File::loadMultiple( $filesToLoad, Yii::$app->request->post(), $name );
return $filesToLoad;
}
return $files;
} | php | public function loadFiles( $name, $files = [] ) {
$filesToLoad = Yii::$app->request->post( $name );
$count = count( $filesToLoad );
if ( $count > 0 ) {
$filesToLoad = [];
// TODO: Use existing file models using $files param.
for( $i = 0; $i < $count; $i++ ) {
$filesToLoad[] = new File();
}
File::loadMultiple( $filesToLoad, Yii::$app->request->post(), $name );
return $filesToLoad;
}
return $files;
} | [
"public",
"function",
"loadFiles",
"(",
"$",
"name",
",",
"$",
"files",
"=",
"[",
"]",
")",
"{",
"$",
"filesToLoad",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"$",
"name",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
... | Load file attributes submitted by form and return the updated file models.
@param string $name
@param File[] $files
@return File - after loading from request url | [
"Load",
"file",
"attributes",
"submitted",
"by",
"form",
"and",
"return",
"the",
"updated",
"file",
"models",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/File.php#L516-L537 |
39,757 | geekwright/RegDom | src/PublicSuffixList.php | PublicSuffixList.loadTree | protected function loadTree()
{
$this->setFallbackURL();
$this->tree = $this->readCachedPSL($this->url);
if (false !== $this->tree) {
return;
}
$this->tree = array();
$list = $this->readPSL();
if (false===$list) {
throw new \RuntimeException('Cannot read ' . $this->url);
}
$this->parsePSL($list);
$this->cachePSL($this->url);
} | php | protected function loadTree()
{
$this->setFallbackURL();
$this->tree = $this->readCachedPSL($this->url);
if (false !== $this->tree) {
return;
}
$this->tree = array();
$list = $this->readPSL();
if (false===$list) {
throw new \RuntimeException('Cannot read ' . $this->url);
}
$this->parsePSL($list);
$this->cachePSL($this->url);
} | [
"protected",
"function",
"loadTree",
"(",
")",
"{",
"$",
"this",
"->",
"setFallbackURL",
"(",
")",
";",
"$",
"this",
"->",
"tree",
"=",
"$",
"this",
"->",
"readCachedPSL",
"(",
"$",
"this",
"->",
"url",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"th... | load the PSL tree, automatically handling caches
@return void (results in $this->tree)
@throws \RuntimeException | [
"load",
"the",
"PSL",
"tree",
"automatically",
"handling",
"caches"
] | f51eb343c526913f699d84c47596195a8a63ce09 | https://github.com/geekwright/RegDom/blob/f51eb343c526913f699d84c47596195a8a63ce09/src/PublicSuffixList.php#L67-L85 |
39,758 | geekwright/RegDom | src/PublicSuffixList.php | PublicSuffixList.parsePSL | protected function parsePSL($fileData)
{
$lines = explode("\n", $fileData);
foreach ($lines as $line) {
if ($this->startsWith($line, "//") || $line == '') {
continue;
}
// this line should be a TLD
$tldParts = explode('.', $line);
$this->buildSubDomain($this->tree, $tldParts);
}
} | php | protected function parsePSL($fileData)
{
$lines = explode("\n", $fileData);
foreach ($lines as $line) {
if ($this->startsWith($line, "//") || $line == '') {
continue;
}
// this line should be a TLD
$tldParts = explode('.', $line);
$this->buildSubDomain($this->tree, $tldParts);
}
} | [
"protected",
"function",
"parsePSL",
"(",
"$",
"fileData",
")",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"fileData",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"startsWith",
... | Parse the PSL data
@param string $fileData the PSL data
@return void (results in $this->tree) | [
"Parse",
"the",
"PSL",
"data"
] | f51eb343c526913f699d84c47596195a8a63ce09 | https://github.com/geekwright/RegDom/blob/f51eb343c526913f699d84c47596195a8a63ce09/src/PublicSuffixList.php#L94-L108 |
39,759 | geekwright/RegDom | src/PublicSuffixList.php | PublicSuffixList.buildSubDomain | protected function buildSubDomain(&$node, $tldParts)
{
$dom = trim(array_pop($tldParts));
$isNotDomain = false;
if ($this->startsWith($dom, "!")) {
$dom = substr($dom, 1);
$isNotDomain = true;
}
if (!array_key_exists($dom, $node)) {
if ($isNotDomain) {
$node[$dom] = array("!" => "");
} else {
$node[$dom] = array();
}
}
if (!$isNotDomain && count($tldParts) > 0) {
$this->buildSubDomain($node[$dom], $tldParts);
}
} | php | protected function buildSubDomain(&$node, $tldParts)
{
$dom = trim(array_pop($tldParts));
$isNotDomain = false;
if ($this->startsWith($dom, "!")) {
$dom = substr($dom, 1);
$isNotDomain = true;
}
if (!array_key_exists($dom, $node)) {
if ($isNotDomain) {
$node[$dom] = array("!" => "");
} else {
$node[$dom] = array();
}
}
if (!$isNotDomain && count($tldParts) > 0) {
$this->buildSubDomain($node[$dom], $tldParts);
}
} | [
"protected",
"function",
"buildSubDomain",
"(",
"&",
"$",
"node",
",",
"$",
"tldParts",
")",
"{",
"$",
"dom",
"=",
"trim",
"(",
"array_pop",
"(",
"$",
"tldParts",
")",
")",
";",
"$",
"isNotDomain",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"... | Add domains to tree
@param array $node tree array by reference
@param string[] $tldParts array of domain parts
@return void - changes made to $node by reference | [
"Add",
"domains",
"to",
"tree"
] | f51eb343c526913f699d84c47596195a8a63ce09 | https://github.com/geekwright/RegDom/blob/f51eb343c526913f699d84c47596195a8a63ce09/src/PublicSuffixList.php#L131-L152 |
39,760 | geekwright/RegDom | src/PublicSuffixList.php | PublicSuffixList.readCachedPSL | protected function readCachedPSL($url)
{
$cacheFile = $this->getCacheFileName($url);
if (file_exists($cacheFile)) {
$cachedTree = file_get_contents($cacheFile);
return unserialize($cachedTree);
}
return false;
} | php | protected function readCachedPSL($url)
{
$cacheFile = $this->getCacheFileName($url);
if (file_exists($cacheFile)) {
$cachedTree = file_get_contents($cacheFile);
return unserialize($cachedTree);
}
return false;
} | [
"protected",
"function",
"readCachedPSL",
"(",
"$",
"url",
")",
"{",
"$",
"cacheFile",
"=",
"$",
"this",
"->",
"getCacheFileName",
"(",
"$",
"url",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"cacheFile",
")",
")",
"{",
"$",
"cachedTree",
"=",
"file_... | Attempt to load a cached Public Suffix List tree for a given source
@param string $url URL/filename of source PSL
@return bool|string[] PSL tree | [
"Attempt",
"to",
"load",
"a",
"cached",
"Public",
"Suffix",
"List",
"tree",
"for",
"a",
"given",
"source"
] | f51eb343c526913f699d84c47596195a8a63ce09 | https://github.com/geekwright/RegDom/blob/f51eb343c526913f699d84c47596195a8a63ce09/src/PublicSuffixList.php#L224-L232 |
39,761 | geekwright/RegDom | src/PublicSuffixList.php | PublicSuffixList.setLocalPSLName | protected function setLocalPSLName($url)
{
if (null === $url) {
$url = $this->sourceURL;
}
$parts = parse_url($url);
$fileName = basename($parts['path']);
$this->localPSL = $this->dataDir . $fileName;
} | php | protected function setLocalPSLName($url)
{
if (null === $url) {
$url = $this->sourceURL;
}
$parts = parse_url($url);
$fileName = basename($parts['path']);
$this->localPSL = $this->dataDir . $fileName;
} | [
"protected",
"function",
"setLocalPSLName",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"url",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"sourceURL",
";",
"}",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"fil... | Set localPSL name based on URL
@param null|string $url the URL for the PSL
@return void (sets $this->localPSL) | [
"Set",
"localPSL",
"name",
"based",
"on",
"URL"
] | f51eb343c526913f699d84c47596195a8a63ce09 | https://github.com/geekwright/RegDom/blob/f51eb343c526913f699d84c47596195a8a63ce09/src/PublicSuffixList.php#L265-L273 |
39,762 | geekwright/RegDom | src/PublicSuffixList.php | PublicSuffixList.clearDataDirectory | public function clearDataDirectory($cacheOnly = false)
{
$dir = __DIR__ . $this->dataDir;
if (is_dir($dir)) {
if ($dirHandle = opendir($dir)) {
while (($file = readdir($dirHandle)) !== false) {
if (filetype($dir . $file) === 'file'
&& (false === $cacheOnly || $this->startsWith($file, $this->cachedPrefix))) {
unlink($dir . $file);
}
}
closedir($dirHandle);
}
}
} | php | public function clearDataDirectory($cacheOnly = false)
{
$dir = __DIR__ . $this->dataDir;
if (is_dir($dir)) {
if ($dirHandle = opendir($dir)) {
while (($file = readdir($dirHandle)) !== false) {
if (filetype($dir . $file) === 'file'
&& (false === $cacheOnly || $this->startsWith($file, $this->cachedPrefix))) {
unlink($dir . $file);
}
}
closedir($dirHandle);
}
}
} | [
"public",
"function",
"clearDataDirectory",
"(",
"$",
"cacheOnly",
"=",
"false",
")",
"{",
"$",
"dir",
"=",
"__DIR__",
".",
"$",
"this",
"->",
"dataDir",
";",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"if",
"(",
"$",
"dirHandle",
"=",
"o... | Delete files in the data directory
@param bool $cacheOnly true to limit clearing to cached serialized PSLs, false to clear all
@return void | [
"Delete",
"files",
"in",
"the",
"data",
"directory"
] | f51eb343c526913f699d84c47596195a8a63ce09 | https://github.com/geekwright/RegDom/blob/f51eb343c526913f699d84c47596195a8a63ce09/src/PublicSuffixList.php#L282-L296 |
39,763 | atk14/UrlFetcher | src/url_fetcher.php | UrlFetcher.setAuthorization | function setAuthorization($username,$password){
settype($username,"string");
settype($password,"string");
$this->_Username = $username;
$this->_Password = $password;
$this->_AuthType = "basic";
} | php | function setAuthorization($username,$password){
settype($username,"string");
settype($password,"string");
$this->_Username = $username;
$this->_Password = $password;
$this->_AuthType = "basic";
} | [
"function",
"setAuthorization",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"settype",
"(",
"$",
"username",
",",
"\"string\"",
")",
";",
"settype",
"(",
"$",
"password",
",",
"\"string\"",
")",
";",
"$",
"this",
"->",
"_Username",
"=",
"$",
... | Set authorization parameters.
@param string $username
@param string $password | [
"Set",
"authorization",
"parameters",
"."
] | 80b3dab3c34edc6971925147021812990eb90fc4 | https://github.com/atk14/UrlFetcher/blob/80b3dab3c34edc6971925147021812990eb90fc4/src/url_fetcher.php#L244-L251 |
39,764 | atk14/UrlFetcher | src/url_fetcher.php | UrlFetcher.post | function post($data = "",$options = array()){
if(is_array($data)){
$d = array();
foreach($data as $k => $v){
$d[] = urlencode($k)."=".urlencode($v);
}
$data = join("&",$d);
}
$options = array_merge(array(
"content_type" => "application/x-www-form-urlencoded",
"additional_headers" => array(),
),$options);
$this->_RequestMethod = "POST";
$this->_PostData = $data;
$this->_AdditionalHeaders = $options["additional_headers"];
$this->_AdditionalHeaders[] = "Content-Type: $options[content_type]";
return $this->fetchContent();
} | php | function post($data = "",$options = array()){
if(is_array($data)){
$d = array();
foreach($data as $k => $v){
$d[] = urlencode($k)."=".urlencode($v);
}
$data = join("&",$d);
}
$options = array_merge(array(
"content_type" => "application/x-www-form-urlencoded",
"additional_headers" => array(),
),$options);
$this->_RequestMethod = "POST";
$this->_PostData = $data;
$this->_AdditionalHeaders = $options["additional_headers"];
$this->_AdditionalHeaders[] = "Content-Type: $options[content_type]";
return $this->fetchContent();
} | [
"function",
"post",
"(",
"$",
"data",
"=",
"\"\"",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"d",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
... | Performs a POST request
@param mixed $data when array it is sent as query parameters, otherwise $data is sent without processing
@param array $options
- content_type string - value for Content-Type HTTP header
- additional_headers array - more headers
@return bool result of request | [
"Performs",
"a",
"POST",
"request"
] | 80b3dab3c34edc6971925147021812990eb90fc4 | https://github.com/atk14/UrlFetcher/blob/80b3dab3c34edc6971925147021812990eb90fc4/src/url_fetcher.php#L417-L437 |
39,765 | atk14/UrlFetcher | src/url_fetcher.php | UrlFetcher.put | function put($url = "",$options = array()){
if(is_array($url)){
$options = $url;
$url = "";
}
$options["request_method"] = "PUT";
return $this->fetchContent($url,$options);
} | php | function put($url = "",$options = array()){
if(is_array($url)){
$options = $url;
$url = "";
}
$options["request_method"] = "PUT";
return $this->fetchContent($url,$options);
} | [
"function",
"put",
"(",
"$",
"url",
"=",
"\"\"",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"url",
")",
")",
"{",
"$",
"options",
"=",
"$",
"url",
";",
"$",
"url",
"=",
"\"\"",
";",
"}",
"$",
"op... | Performs a PUT request | [
"Performs",
"a",
"PUT",
"request"
] | 80b3dab3c34edc6971925147021812990eb90fc4 | https://github.com/atk14/UrlFetcher/blob/80b3dab3c34edc6971925147021812990eb90fc4/src/url_fetcher.php#L442-L449 |
39,766 | atk14/UrlFetcher | src/url_fetcher.php | UrlFetcher.delete | function delete($url = "",$options = array()){
if(is_array($url)){
$options = $url;
$url = "";
}
$options["request_method"] = "DELETE";
return $this->fetchContent($url,$options);
} | php | function delete($url = "",$options = array()){
if(is_array($url)){
$options = $url;
$url = "";
}
$options["request_method"] = "DELETE";
return $this->fetchContent($url,$options);
} | [
"function",
"delete",
"(",
"$",
"url",
"=",
"\"\"",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"url",
")",
")",
"{",
"$",
"options",
"=",
"$",
"url",
";",
"$",
"url",
"=",
"\"\"",
";",
"}",
"$",
... | Performs a DELETE request | [
"Performs",
"a",
"DELETE",
"request"
] | 80b3dab3c34edc6971925147021812990eb90fc4 | https://github.com/atk14/UrlFetcher/blob/80b3dab3c34edc6971925147021812990eb90fc4/src/url_fetcher.php#L454-L461 |
39,767 | atk14/UrlFetcher | src/url_fetcher.php | UrlFetcher.getResponseHeaders | function getResponseHeaders($options = array()){
$options = array_merge(array(
"as_hash" => false,
"lowerize_keys" => false
),$options);
$this->fetchContent();
$out = $this->_ResponseHeaders;
if($options["as_hash"]){
$headers = explode("\n",$out);
$out = array();
foreach($headers as $h){
if(preg_match("/^([^ ]+):(.*)/",trim($h),$matches)){
$key = $options["lowerize_keys"] ? strtolower($matches[1]) : $matches[1];
$out[$key] = trim($matches[2]);
}
}
}
return $out;
} | php | function getResponseHeaders($options = array()){
$options = array_merge(array(
"as_hash" => false,
"lowerize_keys" => false
),$options);
$this->fetchContent();
$out = $this->_ResponseHeaders;
if($options["as_hash"]){
$headers = explode("\n",$out);
$out = array();
foreach($headers as $h){
if(preg_match("/^([^ ]+):(.*)/",trim($h),$matches)){
$key = $options["lowerize_keys"] ? strtolower($matches[1]) : $matches[1];
$out[$key] = trim($matches[2]);
}
}
}
return $out;
} | [
"function",
"getResponseHeaders",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"array",
"(",
"\"as_hash\"",
"=>",
"false",
",",
"\"lowerize_keys\"",
"=>",
"false",
")",
",",
"$",
"options",
")",
";",
"$"... | Gets headers returned by the server.
@param array $options
- <b>as_hash</b> - returns headers as array when set to true [default: false]
- <b>lowerize_keys</b> - convert header names lowercase when set to true [default: false]
@return string|array | [
"Gets",
"headers",
"returned",
"by",
"the",
"server",
"."
] | 80b3dab3c34edc6971925147021812990eb90fc4 | https://github.com/atk14/UrlFetcher/blob/80b3dab3c34edc6971925147021812990eb90fc4/src/url_fetcher.php#L478-L500 |
39,768 | atk14/UrlFetcher | src/url_fetcher.php | UrlFetcher.getHeaderValue | function getHeaderValue($header){
$header = strtolower($header);
$headers = $this->getResponseHeaders(array("as_hash" => true, "lowerize_keys" => true));
if(isset($headers["$header"])){ return $headers["$header"]; }
} | php | function getHeaderValue($header){
$header = strtolower($header);
$headers = $this->getResponseHeaders(array("as_hash" => true, "lowerize_keys" => true));
if(isset($headers["$header"])){ return $headers["$header"]; }
} | [
"function",
"getHeaderValue",
"(",
"$",
"header",
")",
"{",
"$",
"header",
"=",
"strtolower",
"(",
"$",
"header",
")",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"getResponseHeaders",
"(",
"array",
"(",
"\"as_hash\"",
"=>",
"true",
",",
"\"lowerize_keys\... | Returns value of given header
```
$c_type = $uf->getHeaderValue("Content-Type"); // "text/xml"
```
@param string $header
@return string | [
"Returns",
"value",
"of",
"given",
"header"
] | 80b3dab3c34edc6971925147021812990eb90fc4 | https://github.com/atk14/UrlFetcher/blob/80b3dab3c34edc6971925147021812990eb90fc4/src/url_fetcher.php#L527-L531 |
39,769 | atk14/UrlFetcher | src/url_fetcher.php | UrlFetcher._fwriteStream | protected function _fwriteStream(&$fp, &$string) {
$fwrite = 0;
for($written = 0; $written < strlen($string); $written += $fwrite){
$fwrite = @fwrite($fp, substr($string, $written));
if($fwrite === false){
return $written;
}
if(!$fwrite){ // 0 bytes written; error code 11: Resource temporarily unavailable
usleep(10000);
continue;
}
}
return $written;
} | php | protected function _fwriteStream(&$fp, &$string) {
$fwrite = 0;
for($written = 0; $written < strlen($string); $written += $fwrite){
$fwrite = @fwrite($fp, substr($string, $written));
if($fwrite === false){
return $written;
}
if(!$fwrite){ // 0 bytes written; error code 11: Resource temporarily unavailable
usleep(10000);
continue;
}
}
return $written;
} | [
"protected",
"function",
"_fwriteStream",
"(",
"&",
"$",
"fp",
",",
"&",
"$",
"string",
")",
"{",
"$",
"fwrite",
"=",
"0",
";",
"for",
"(",
"$",
"written",
"=",
"0",
";",
"$",
"written",
"<",
"strlen",
"(",
"$",
"string",
")",
";",
"$",
"written"... | Writes string to a network socket
See http://php.net/fwrite
Note: Writing to a network stream may end before the whole string is written. Return value of fwrite() may be checked:
@ignore | [
"Writes",
"string",
"to",
"a",
"network",
"socket"
] | 80b3dab3c34edc6971925147021812990eb90fc4 | https://github.com/atk14/UrlFetcher/blob/80b3dab3c34edc6971925147021812990eb90fc4/src/url_fetcher.php#L719-L734 |
39,770 | locomotivemtl/charcoal-property | src/Charcoal/Property/IpProperty.php | IpProperty.storageVal | public function storageVal($val)
{
$mode = $this->storageMode();
if ($mode === self::STORAGE_MODE_INT) {
return $this->intVal($val);
} else {
return $this->stringVal($val);
}
} | php | public function storageVal($val)
{
$mode = $this->storageMode();
if ($mode === self::STORAGE_MODE_INT) {
return $this->intVal($val);
} else {
return $this->stringVal($val);
}
} | [
"public",
"function",
"storageVal",
"(",
"$",
"val",
")",
"{",
"$",
"mode",
"=",
"$",
"this",
"->",
"storageMode",
"(",
")",
";",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"STORAGE_MODE_INT",
")",
"{",
"return",
"$",
"this",
"->",
"intVal",
"(",
... | Get the IP value in the suitable format for storage.
@param mixed $val The value to convert to string.
@see StorablePropertyTrait::storageVal()
@return string | [
"Get",
"the",
"IP",
"value",
"in",
"the",
"suitable",
"format",
"for",
"storage",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/IpProperty.php#L167-L176 |
39,771 | cmsgears/module-core | common/utilities/CodeGenUtil.php | CodeGenUtil.getPaginationDetail | public static function getPaginationDetail( $dataProvider ) {
$total = $dataProvider->getTotalCount();
$pagination = $dataProvider->getPagination();
$current_page = $pagination->getPage();
$page_size = $pagination->getPageSize();
$start = $page_size * $current_page;
$end = $page_size * ( $current_page + 1 ) - 1;
$currentSize = count( $dataProvider->getModels() );
$currentDisplay = $end - $start;
if( $currentSize < $currentDisplay ) {
$end = $start + $currentSize;
}
if( $end > 0 ) {
$start += 1;
}
if( $currentSize == $page_size ) {
$end += 1;
}
return "Showing $start to $end out of $total entries";
} | php | public static function getPaginationDetail( $dataProvider ) {
$total = $dataProvider->getTotalCount();
$pagination = $dataProvider->getPagination();
$current_page = $pagination->getPage();
$page_size = $pagination->getPageSize();
$start = $page_size * $current_page;
$end = $page_size * ( $current_page + 1 ) - 1;
$currentSize = count( $dataProvider->getModels() );
$currentDisplay = $end - $start;
if( $currentSize < $currentDisplay ) {
$end = $start + $currentSize;
}
if( $end > 0 ) {
$start += 1;
}
if( $currentSize == $page_size ) {
$end += 1;
}
return "Showing $start to $end out of $total entries";
} | [
"public",
"static",
"function",
"getPaginationDetail",
"(",
"$",
"dataProvider",
")",
"{",
"$",
"total",
"=",
"$",
"dataProvider",
"->",
"getTotalCount",
"(",
")",
";",
"$",
"pagination",
"=",
"$",
"dataProvider",
"->",
"getPagination",
"(",
")",
";",
"$",
... | Return pagination info to be displayed on data grid footer or header.
@return string - pagination info | [
"Return",
"pagination",
"info",
"to",
"be",
"displayed",
"on",
"data",
"grid",
"footer",
"or",
"header",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/utilities/CodeGenUtil.php#L23-L50 |
39,772 | cmsgears/module-core | common/utilities/CodeGenUtil.php | CodeGenUtil.getImageThumbTag | public static function getImageThumbTag( $image, $options = [] ) {
// Use Image from DB
if( isset( $image ) ) {
$thumbUrl = $image->getThumbUrl();
if( isset( $options[ 'class' ] ) ) {
$class = $options[ 'class' ];
return "<img class='$class' src='$thumbUrl'>";
}
else {
return "<img src='$thumbUrl'>";
}
}
else {
// Use Image from web root directory
if( isset( $options[ 'image' ] ) ) {
$images = Yii::getAlias( '@images' );
$img = $options[ 'image' ];
if( isset( $options[ 'class' ] ) ) {
$class = $options[ 'class' ];
return "<img class='$class' src='$images/$img'>";
}
else {
return "<img src='$images/$img'>";
}
}
// Use icon
else if( isset( $options[ 'icon' ] ) ) {
$icon = $options[ 'icon' ];
return "<span class='$icon'></span>";
}
}
} | php | public static function getImageThumbTag( $image, $options = [] ) {
// Use Image from DB
if( isset( $image ) ) {
$thumbUrl = $image->getThumbUrl();
if( isset( $options[ 'class' ] ) ) {
$class = $options[ 'class' ];
return "<img class='$class' src='$thumbUrl'>";
}
else {
return "<img src='$thumbUrl'>";
}
}
else {
// Use Image from web root directory
if( isset( $options[ 'image' ] ) ) {
$images = Yii::getAlias( '@images' );
$img = $options[ 'image' ];
if( isset( $options[ 'class' ] ) ) {
$class = $options[ 'class' ];
return "<img class='$class' src='$images/$img'>";
}
else {
return "<img src='$images/$img'>";
}
}
// Use icon
else if( isset( $options[ 'icon' ] ) ) {
$icon = $options[ 'icon' ];
return "<span class='$icon'></span>";
}
}
} | [
"public",
"static",
"function",
"getImageThumbTag",
"(",
"$",
"image",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"// Use Image from DB",
"if",
"(",
"isset",
"(",
"$",
"image",
")",
")",
"{",
"$",
"thumbUrl",
"=",
"$",
"image",
"->",
"getThumbUrl",
... | Return Image Tag | [
"Return",
"Image",
"Tag"
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/utilities/CodeGenUtil.php#L289-L334 |
39,773 | locomotivemtl/charcoal-property | src/Charcoal/Property/StructureProperty.php | StructureProperty.setSqlType | public function setSqlType($sqlType)
{
if (!is_string($sqlType)) {
throw new InvalidArgumentException(
'SQL Type must be a string.'
);
}
switch (strtoupper($sqlType)) {
case 'TEXT':
$sqlType = 'TEXT';
break;
case 'TINY':
case 'TINYTEXT':
$sqlType = 'TINYTEXT';
break;
case 'MEDIUM':
case 'MEDIUMTEXT':
$sqlType = 'MEDIUMTEXT';
break;
case 'LONG':
case 'LONGTEXT':
$sqlType = 'LONGTEXT';
break;
default:
throw new InvalidArgumentException(
'SQL Type must be one of TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT.'
);
}
$this->sqlType = $sqlType;
return $this;
} | php | public function setSqlType($sqlType)
{
if (!is_string($sqlType)) {
throw new InvalidArgumentException(
'SQL Type must be a string.'
);
}
switch (strtoupper($sqlType)) {
case 'TEXT':
$sqlType = 'TEXT';
break;
case 'TINY':
case 'TINYTEXT':
$sqlType = 'TINYTEXT';
break;
case 'MEDIUM':
case 'MEDIUMTEXT':
$sqlType = 'MEDIUMTEXT';
break;
case 'LONG':
case 'LONGTEXT':
$sqlType = 'LONGTEXT';
break;
default:
throw new InvalidArgumentException(
'SQL Type must be one of TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT.'
);
}
$this->sqlType = $sqlType;
return $this;
} | [
"public",
"function",
"setSqlType",
"(",
"$",
"sqlType",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"sqlType",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'SQL Type must be a string.'",
")",
";",
"}",
"switch",
"(",
"strtoupper",
"... | Set the property's SQL encoding & collation.
@param string $sqlType The field SQL column type.
@throws InvalidArgumentException If the SQL type is invalid.
@return self | [
"Set",
"the",
"property",
"s",
"SQL",
"encoding",
"&",
"collation",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StructureProperty.php#L180-L217 |
39,774 | cmsgears/module-core | common/components/Core.php | Core.init | public function init() {
parent::init();
// Initialise core validators
CoreValidator::initValidators();
/** Set CMSGears alias to be used by all modules, plugins, widgets and themes.
* It will be located within the vendor directory for composer.
*/
Yii::setAlias( 'cmsgears', dirname( dirname( dirname( __DIR__ ) ) ) );
} | php | public function init() {
parent::init();
// Initialise core validators
CoreValidator::initValidators();
/** Set CMSGears alias to be used by all modules, plugins, widgets and themes.
* It will be located within the vendor directory for composer.
*/
Yii::setAlias( 'cmsgears', dirname( dirname( dirname( __DIR__ ) ) ) );
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"// Initialise core validators",
"CoreValidator",
"::",
"initValidators",
"(",
")",
";",
"/** Set CMSGears alias to be used by all modules, plugins, widgets and themes.\n\t\t * It will be locate... | Initialise the CMG Core Component. | [
"Initialise",
"the",
"CMG",
"Core",
"Component",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/Core.php#L231-L242 |
39,775 | cmsgears/module-core | common/components/Core.php | Core.setAppUser | public function setAppUser( $user ) {
$cookieName = '_app-user';
$guestUser[ 'user' ] = [ 'id' => $user->id, 'firstname' => $user->firstName, 'lastname' => $user->lastName, 'email' => $user->email ];
if( isset( $_COOKIE[ $cookieName ] ) ) {
$data = unserialize( $_COOKIE[ $cookieName ] );
if( $data[ 'user' ][ 'id' ] != $user->id ) {
return setcookie( $cookieName, serialize( $guestUser ), time() + ( 10 * 365 * 24 * 60 * 60 ), "/", null );
}
}
else {
return setcookie( $cookieName, serialize( $guestUser ), time() + ( 10 * 365 * 24 * 60 * 60 ), "/", null );
}
} | php | public function setAppUser( $user ) {
$cookieName = '_app-user';
$guestUser[ 'user' ] = [ 'id' => $user->id, 'firstname' => $user->firstName, 'lastname' => $user->lastName, 'email' => $user->email ];
if( isset( $_COOKIE[ $cookieName ] ) ) {
$data = unserialize( $_COOKIE[ $cookieName ] );
if( $data[ 'user' ][ 'id' ] != $user->id ) {
return setcookie( $cookieName, serialize( $guestUser ), time() + ( 10 * 365 * 24 * 60 * 60 ), "/", null );
}
}
else {
return setcookie( $cookieName, serialize( $guestUser ), time() + ( 10 * 365 * 24 * 60 * 60 ), "/", null );
}
} | [
"public",
"function",
"setAppUser",
"(",
"$",
"user",
")",
"{",
"$",
"cookieName",
"=",
"'_app-user'",
";",
"$",
"guestUser",
"[",
"'user'",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"user",
"->",
"id",
",",
"'firstname'",
"=>",
"$",
"user",
"->",
"firstName",... | Cookies & Session | [
"Cookies",
"&",
"Session"
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/Core.php#L556-L575 |
39,776 | cmsgears/module-core | common/components/Core.php | Core.getAppUser | public function getAppUser() {
$cookieName = '_app-user';
$appUser = null;
$user = Yii::$app->user->identity;
if( $user != null ) {
$appUser = $user;
}
else if( isset( $_COOKIE[ $cookieName ] ) ) {
$data = unserialize( $_COOKIE[ $cookieName ] );
if( isset( $data[ 'user' ] ) ) {
//$appUser = (object) $data[ 'user' ]['user'];
$appUser = UserService::findById( $data[ 'user' ][ 'id' ] );
}
}
return $appUser;
} | php | public function getAppUser() {
$cookieName = '_app-user';
$appUser = null;
$user = Yii::$app->user->identity;
if( $user != null ) {
$appUser = $user;
}
else if( isset( $_COOKIE[ $cookieName ] ) ) {
$data = unserialize( $_COOKIE[ $cookieName ] );
if( isset( $data[ 'user' ] ) ) {
//$appUser = (object) $data[ 'user' ]['user'];
$appUser = UserService::findById( $data[ 'user' ][ 'id' ] );
}
}
return $appUser;
} | [
"public",
"function",
"getAppUser",
"(",
")",
"{",
"$",
"cookieName",
"=",
"'_app-user'",
";",
"$",
"appUser",
"=",
"null",
";",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"identity",
";",
"if",
"(",
"$",
"user",
"!=",
"null",
"... | Call setAppUser at least once for new user before calling this method. | [
"Call",
"setAppUser",
"at",
"least",
"once",
"for",
"new",
"user",
"before",
"calling",
"this",
"method",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/Core.php#L578-L601 |
39,777 | tamago-db/LinkedinImporterBundle | Controller/DefaultController.php | DefaultController.requestPrivateAction | public function requestPrivateAction()
{
//load up the importer class
$importer = $this->get('linkedin.importer');
//set a redirect for linkedin to bump the user back to after they approve your app
$importer->setRedirect($this->generateUrl('ccc_linkedin_importer_receivePrivate', array('submit' => true), true));
//nothing on this form except for a submit button to start the process
$form = $this->createForm(new LiForm\RequestPrivate());
$request = $this->getRequest();
if ($request->isMethod('POST')) {
$form->handleRequest($request);
if ($form->isValid()) {
//user hit the start button, so request permission from the user to allow your app on their linkedin account
//this will redirect to linkedin's site
return $importer->requestPermission();
}
}
return $this->render('CCCLinkedinImporterBundle:Default:requestPrivate.html.twig', array('form' => $form->createView()));
} | php | public function requestPrivateAction()
{
//load up the importer class
$importer = $this->get('linkedin.importer');
//set a redirect for linkedin to bump the user back to after they approve your app
$importer->setRedirect($this->generateUrl('ccc_linkedin_importer_receivePrivate', array('submit' => true), true));
//nothing on this form except for a submit button to start the process
$form = $this->createForm(new LiForm\RequestPrivate());
$request = $this->getRequest();
if ($request->isMethod('POST')) {
$form->handleRequest($request);
if ($form->isValid()) {
//user hit the start button, so request permission from the user to allow your app on their linkedin account
//this will redirect to linkedin's site
return $importer->requestPermission();
}
}
return $this->render('CCCLinkedinImporterBundle:Default:requestPrivate.html.twig', array('form' => $form->createView()));
} | [
"public",
"function",
"requestPrivateAction",
"(",
")",
"{",
"//load up the importer class",
"$",
"importer",
"=",
"$",
"this",
"->",
"get",
"(",
"'linkedin.importer'",
")",
";",
"//set a redirect for linkedin to bump the user back to after they approve your app",
"$",
"impor... | Example of how to request the user's private data. | [
"Example",
"of",
"how",
"to",
"request",
"the",
"user",
"s",
"private",
"data",
"."
] | bf510a675311c181995b17744e1420fc4fbb2e60 | https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Controller/DefaultController.php#L13-L37 |
39,778 | tamago-db/LinkedinImporterBundle | Controller/DefaultController.php | DefaultController.requestPublicAction | public function requestPublicAction()
{
$importer = $this->get('linkedin.importer');
$form = $this->createForm(new LiForm\RequestPublic());
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->handleRequest($request);
if ($form->isValid()) {
$form_data = $form->getData();
//add the other user's public profile url to the redirect
$importer->setRedirect($this->generateUrl('ccc_linkedin_importer_receivePublic', array('submit' => true, 'url' => urlencode($form_data['url'])), true));
//still need to ask the current user for permission to go through our app
return $importer->requestPermission('public');
}
}
return $this->render('CCCLinkedinImporterBundle:Default:requestPublic.html.twig', array('form' => $form->createView()));
} | php | public function requestPublicAction()
{
$importer = $this->get('linkedin.importer');
$form = $this->createForm(new LiForm\RequestPublic());
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->handleRequest($request);
if ($form->isValid()) {
$form_data = $form->getData();
//add the other user's public profile url to the redirect
$importer->setRedirect($this->generateUrl('ccc_linkedin_importer_receivePublic', array('submit' => true, 'url' => urlencode($form_data['url'])), true));
//still need to ask the current user for permission to go through our app
return $importer->requestPermission('public');
}
}
return $this->render('CCCLinkedinImporterBundle:Default:requestPublic.html.twig', array('form' => $form->createView()));
} | [
"public",
"function",
"requestPublicAction",
"(",
")",
"{",
"$",
"importer",
"=",
"$",
"this",
"->",
"get",
"(",
"'linkedin.importer'",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"LiForm",
"\\",
"RequestPublic",
"(",
")",
")... | Example of how to request the user's public data.
First step is same as above, except that this form has a text field to input another user's public profile url | [
"Example",
"of",
"how",
"to",
"request",
"the",
"user",
"s",
"public",
"data",
".",
"First",
"step",
"is",
"same",
"as",
"above",
"except",
"that",
"this",
"form",
"has",
"a",
"text",
"field",
"to",
"input",
"another",
"user",
"s",
"public",
"profile",
... | bf510a675311c181995b17744e1420fc4fbb2e60 | https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Controller/DefaultController.php#L76-L96 |
39,779 | cmsgears/module-core | common/controllers/base/Controller.php | Controller.checkHome | protected function checkHome() {
// Send user to home if already logged in
if ( !Yii::$app->user->isGuest ) {
$user = Yii::$app->user->getIdentity();
$role = $user->role;
$storedLink = Url::previous( CoreGlobal::REDIRECT_LOGIN );
$siteId = Yii::$app->core->getSiteId();
$siteMember = Yii::$app->factory->get( 'siteMemberService' )->getBySiteIdUserId( $siteId, $user->id );
// Auto-Register site member
if( !isset( $siteMember ) ) {
Yii::$app->factory->get( 'siteMemberService' )->create( $user );
}
// Redirect user to stored link on login
if( isset( $storedLink ) ) {
Yii::$app->response->redirect( $storedLink )->send();
}
// Redirect user having role to home
else if( isset( $role ) ) {
// Switch according to app id
$appAdmin = Yii::$app->core->getAppAdmin();
$appFrontend = Yii::$app->core->getAppFrontend();
// User is on admin app
if( Yii::$app->id === $appAdmin && isset( $role->adminUrl ) ) {
Yii::$app->response->redirect( [ "/$role->adminUrl" ] )->send();
}
// User is on frontend app
else if( Yii::$app->id === $appFrontend && isset( $role->homeUrl ) ) {
Yii::$app->response->redirect( [ "/$role->homeUrl" ] )->send();
}
// Redirect user to home set by app config
else {
Yii::$app->response->redirect( [ Yii::$app->core->getLoginRedirectPage() ] )->send();
}
}
// Redirect user to home set by app config
else {
Yii::$app->response->redirect( [ Yii::$app->core->getLoginRedirectPage() ] )->send();
}
}
} | php | protected function checkHome() {
// Send user to home if already logged in
if ( !Yii::$app->user->isGuest ) {
$user = Yii::$app->user->getIdentity();
$role = $user->role;
$storedLink = Url::previous( CoreGlobal::REDIRECT_LOGIN );
$siteId = Yii::$app->core->getSiteId();
$siteMember = Yii::$app->factory->get( 'siteMemberService' )->getBySiteIdUserId( $siteId, $user->id );
// Auto-Register site member
if( !isset( $siteMember ) ) {
Yii::$app->factory->get( 'siteMemberService' )->create( $user );
}
// Redirect user to stored link on login
if( isset( $storedLink ) ) {
Yii::$app->response->redirect( $storedLink )->send();
}
// Redirect user having role to home
else if( isset( $role ) ) {
// Switch according to app id
$appAdmin = Yii::$app->core->getAppAdmin();
$appFrontend = Yii::$app->core->getAppFrontend();
// User is on admin app
if( Yii::$app->id === $appAdmin && isset( $role->adminUrl ) ) {
Yii::$app->response->redirect( [ "/$role->adminUrl" ] )->send();
}
// User is on frontend app
else if( Yii::$app->id === $appFrontend && isset( $role->homeUrl ) ) {
Yii::$app->response->redirect( [ "/$role->homeUrl" ] )->send();
}
// Redirect user to home set by app config
else {
Yii::$app->response->redirect( [ Yii::$app->core->getLoginRedirectPage() ] )->send();
}
}
// Redirect user to home set by app config
else {
Yii::$app->response->redirect( [ Yii::$app->core->getLoginRedirectPage() ] )->send();
}
}
} | [
"protected",
"function",
"checkHome",
"(",
")",
"{",
"// Send user to home if already logged in",
"if",
"(",
"!",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"isGuest",
")",
"{",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"getIdentity"... | The method check whether user is logged in and send to respective home page. | [
"The",
"method",
"check",
"whether",
"user",
"is",
"logged",
"in",
"and",
"send",
"to",
"respective",
"home",
"page",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/controllers/base/Controller.php#L212-L265 |
39,780 | locomotivemtl/charcoal-property | src/Charcoal/Property/MultiObjectProperty.php | MultiObjectProperty.createJoinTable | public function createJoinTable()
{
if ($this->joinTableExists() === true) {
return;
}
$q = 'CREATE TABLE \''.$this->joinTable().'\' (
target_type VARCHAR(255),
target_id VARCHAR(255),
target_property VARCHAR(255),
attachment_type VARCHAR(255),
attachment_id VARCHAR(255),
created DATETIME
)';
$this->logger->debug($q);
$this->source()->db()->query($q);
} | php | public function createJoinTable()
{
if ($this->joinTableExists() === true) {
return;
}
$q = 'CREATE TABLE \''.$this->joinTable().'\' (
target_type VARCHAR(255),
target_id VARCHAR(255),
target_property VARCHAR(255),
attachment_type VARCHAR(255),
attachment_id VARCHAR(255),
created DATETIME
)';
$this->logger->debug($q);
$this->source()->db()->query($q);
} | [
"public",
"function",
"createJoinTable",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"joinTableExists",
"(",
")",
"===",
"true",
")",
"{",
"return",
";",
"}",
"$",
"q",
"=",
"'CREATE TABLE \\''",
".",
"$",
"this",
"->",
"joinTable",
"(",
")",
".",
"... | Create the join table on the database source, if it does not exist.
@return void | [
"Create",
"the",
"join",
"table",
"on",
"the",
"database",
"source",
"if",
"it",
"does",
"not",
"exist",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/MultiObjectProperty.php#L94-L110 |
39,781 | nails/module-form-builder | src/Service/DefaultValue.php | DefaultValue.getAllFlat | public function getAllFlat()
{
$aAvailable = $this->getAll();
$aOut = [];
foreach ($aAvailable as $oDefault) {
$aOut[$oDefault->slug] = $oDefault->label;
}
return $aOut;
} | php | public function getAllFlat()
{
$aAvailable = $this->getAll();
$aOut = [];
foreach ($aAvailable as $oDefault) {
$aOut[$oDefault->slug] = $oDefault->label;
}
return $aOut;
} | [
"public",
"function",
"getAllFlat",
"(",
")",
"{",
"$",
"aAvailable",
"=",
"$",
"this",
"->",
"getAll",
"(",
")",
";",
"$",
"aOut",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"aAvailable",
"as",
"$",
"oDefault",
")",
"{",
"$",
"aOut",
"[",
"$",
"oD... | Returns the various default values which a field can have as a flat array
@return array | [
"Returns",
"the",
"various",
"default",
"values",
"which",
"a",
"field",
"can",
"have",
"as",
"a",
"flat",
"array"
] | a961a8791a75d01884f46f8e2b492d1cca07fb5b | https://github.com/nails/module-form-builder/blob/a961a8791a75d01884f46f8e2b492d1cca07fb5b/src/Service/DefaultValue.php#L108-L118 |
39,782 | nails/module-form-builder | src/Service/DefaultValue.php | DefaultValue.getBySlug | public function getBySlug($sSlug)
{
$aAvailable = $this->getAll();
foreach ($aAvailable as $oDefault) {
if ($oDefault->slug == $sSlug) {
if (!isset($oDefault->instance)) {
$oDefault->instance = Factory::factory(
$oDefault->component,
$oDefault->provider
);
}
return $oDefault->instance;
}
}
return null;
} | php | public function getBySlug($sSlug)
{
$aAvailable = $this->getAll();
foreach ($aAvailable as $oDefault) {
if ($oDefault->slug == $sSlug) {
if (!isset($oDefault->instance)) {
$oDefault->instance = Factory::factory(
$oDefault->component,
$oDefault->provider
);
}
return $oDefault->instance;
}
}
return null;
} | [
"public",
"function",
"getBySlug",
"(",
"$",
"sSlug",
")",
"{",
"$",
"aAvailable",
"=",
"$",
"this",
"->",
"getAll",
"(",
")",
";",
"foreach",
"(",
"$",
"aAvailable",
"as",
"$",
"oDefault",
")",
"{",
"if",
"(",
"$",
"oDefault",
"->",
"slug",
"==",
... | Get an individual default value instance by it's slug
@param string $sSlug The Default Value's slug
@return object | [
"Get",
"an",
"individual",
"default",
"value",
"instance",
"by",
"it",
"s",
"slug"
] | a961a8791a75d01884f46f8e2b492d1cca07fb5b | https://github.com/nails/module-form-builder/blob/a961a8791a75d01884f46f8e2b492d1cca07fb5b/src/Service/DefaultValue.php#L129-L149 |
39,783 | nails/module-email | admin/controllers/Utilities.php | Utilities.index | public function index()
{
if (!userHasPermission('admin:email:utilities:sendTest')) {
unauthorised();
}
// --------------------------------------------------------------------------
// Page Title
$this->data['page']->title = 'Send a Test Email';
// --------------------------------------------------------------------------
$oInput = Factory::service('Input');
if ($oInput->post()) {
// Form validation and update
$oFormValidation = Factory::service('FormValidation');
// Define rules
$oFormValidation->set_rules('recipient', '', 'required|valid_email');
// Set Messages
$oFormValidation->set_message('required', lang('fv_required'));
$oFormValidation->set_message('valid_email', lang('fv_valid_email'));
// Execute
if ($oFormValidation->run()) {
// Prepare data
$oNow = Factory::factory('DateTime');
$oEmail = (object) [
'type' => 'test_email',
'to_email' => $oInput->post('recipient', true),
'data' => [
'sentAt' => $oNow->format('Y-m-d H:i:s'),
],
];
// Send the email
$oEmailer = Factory::service('Emailer', 'nails/module-email');
if ($oEmailer->send($oEmail)) {
$this->data['success'] = '<strong>Done!</strong> Test email successfully sent to <strong>';
$this->data['success'] .= $oEmail->to_email . '</strong> at ' . toUserDatetime();
} else {
echo '<h1>Sending Failed, debugging data below:</h1>';
echo $oEmailer->print_debugger();
return;
}
}
}
// --------------------------------------------------------------------------
// Load views
Helper::loadView('index');
} | php | public function index()
{
if (!userHasPermission('admin:email:utilities:sendTest')) {
unauthorised();
}
// --------------------------------------------------------------------------
// Page Title
$this->data['page']->title = 'Send a Test Email';
// --------------------------------------------------------------------------
$oInput = Factory::service('Input');
if ($oInput->post()) {
// Form validation and update
$oFormValidation = Factory::service('FormValidation');
// Define rules
$oFormValidation->set_rules('recipient', '', 'required|valid_email');
// Set Messages
$oFormValidation->set_message('required', lang('fv_required'));
$oFormValidation->set_message('valid_email', lang('fv_valid_email'));
// Execute
if ($oFormValidation->run()) {
// Prepare data
$oNow = Factory::factory('DateTime');
$oEmail = (object) [
'type' => 'test_email',
'to_email' => $oInput->post('recipient', true),
'data' => [
'sentAt' => $oNow->format('Y-m-d H:i:s'),
],
];
// Send the email
$oEmailer = Factory::service('Emailer', 'nails/module-email');
if ($oEmailer->send($oEmail)) {
$this->data['success'] = '<strong>Done!</strong> Test email successfully sent to <strong>';
$this->data['success'] .= $oEmail->to_email . '</strong> at ' . toUserDatetime();
} else {
echo '<h1>Sending Failed, debugging data below:</h1>';
echo $oEmailer->print_debugger();
return;
}
}
}
// --------------------------------------------------------------------------
// Load views
Helper::loadView('index');
} | [
"public",
"function",
"index",
"(",
")",
"{",
"if",
"(",
"!",
"userHasPermission",
"(",
"'admin:email:utilities:sendTest'",
")",
")",
"{",
"unauthorised",
"(",
")",
";",
"}",
"// --------------------------------------------------------------------------",
"// Page Title",
... | Send a test email
@return void | [
"Send",
"a",
"test",
"email"
] | 42183b33a0465ab302f66a7b4f881410275eb6a4 | https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/admin/controllers/Utilities.php#L59-L118 |
39,784 | mcaskill/charcoal-support | src/Cms/LocaleAwareTrait.php | LocaleAwareTrait.setLocales | protected function setLocales(array $locales)
{
$this->locales = [];
foreach ($locales as $langCode => $localeStruct) {
$this->locales[$langCode] = $this->parseLocale($localeStruct, $langCode);
}
return $this;
} | php | protected function setLocales(array $locales)
{
$this->locales = [];
foreach ($locales as $langCode => $localeStruct) {
$this->locales[$langCode] = $this->parseLocale($localeStruct, $langCode);
}
return $this;
} | [
"protected",
"function",
"setLocales",
"(",
"array",
"$",
"locales",
")",
"{",
"$",
"this",
"->",
"locales",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"locales",
"as",
"$",
"langCode",
"=>",
"$",
"localeStruct",
")",
"{",
"$",
"this",
"->",
"locales",
... | Set the available locales.
@param array $locales The list of language structures.
@return self | [
"Set",
"the",
"available",
"locales",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/LocaleAwareTrait.php#L53-L61 |
39,785 | mcaskill/charcoal-support | src/Cms/LocaleAwareTrait.php | LocaleAwareTrait.parseLocale | private function parseLocale(array $localeStruct, $langCode)
{
$trans = 'locale.' . $langCode;
/** Setup the name of the language in the current locale */
if (isset($localeStruct['name'])) {
$name = $this->translator()->translate($localeStruct['name']);
} else {
$name = $this->translator()->translate($trans);
if ($trans === $name) {
$name = strtoupper($langCode);
}
}
/** Setup the native name of the language */
if (isset($localeStruct['native'])) {
$native = $this->translator()->translate($localeStruct['native'], [], null, $langCode);
} else {
$native = $this->translator()->translate($trans, [], null, $langCode);
if ($trans === $native) {
$native = strtoupper($langCode);
}
}
if (!isset($localeStruct['locale'])) {
$localeStruct['locale'] = $langCode;
}
$localeStruct['name'] = $name;
$localeStruct['native'] = $native;
$localeStruct['code'] = $langCode;
return $localeStruct;
} | php | private function parseLocale(array $localeStruct, $langCode)
{
$trans = 'locale.' . $langCode;
/** Setup the name of the language in the current locale */
if (isset($localeStruct['name'])) {
$name = $this->translator()->translate($localeStruct['name']);
} else {
$name = $this->translator()->translate($trans);
if ($trans === $name) {
$name = strtoupper($langCode);
}
}
/** Setup the native name of the language */
if (isset($localeStruct['native'])) {
$native = $this->translator()->translate($localeStruct['native'], [], null, $langCode);
} else {
$native = $this->translator()->translate($trans, [], null, $langCode);
if ($trans === $native) {
$native = strtoupper($langCode);
}
}
if (!isset($localeStruct['locale'])) {
$localeStruct['locale'] = $langCode;
}
$localeStruct['name'] = $name;
$localeStruct['native'] = $native;
$localeStruct['code'] = $langCode;
return $localeStruct;
} | [
"private",
"function",
"parseLocale",
"(",
"array",
"$",
"localeStruct",
",",
"$",
"langCode",
")",
"{",
"$",
"trans",
"=",
"'locale.'",
".",
"$",
"langCode",
";",
"/** Setup the name of the language in the current locale */",
"if",
"(",
"isset",
"(",
"$",
"locale... | Parse the given locale.
@see \Charcoal\Admin\Widget\FormSidebarWidget::languages()
@see \Charcoal\Admin\Widget\FormGroupWidget::languages()
@param array $localeStruct The language structure.
@param string $langCode The language code.
@throws InvalidArgumentException If the locale does not have a language code.
@return array | [
"Parse",
"the",
"given",
"locale",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/LocaleAwareTrait.php#L73-L106 |
39,786 | mcaskill/charcoal-support | src/Cms/LocaleAwareTrait.php | LocaleAwareTrait.buildAlternateTranslations | protected function buildAlternateTranslations()
{
$translations = [];
$context = $this->contextObject();
$origLang = $this->currentLanguage();
$this->translator()->isIteratingLocales = true;
foreach ($this->locales() as $langCode => $localeStruct) {
if ($langCode === $origLang) {
continue;
}
$this->translator()->setLocale($langCode);
$translations[$langCode] = $this->formatAlternateTranslation($context, $localeStruct);
}
$this->translator()->setLocale($origLang);
unset($this->translator()->isIteratingLocales);
return $translations;
} | php | protected function buildAlternateTranslations()
{
$translations = [];
$context = $this->contextObject();
$origLang = $this->currentLanguage();
$this->translator()->isIteratingLocales = true;
foreach ($this->locales() as $langCode => $localeStruct) {
if ($langCode === $origLang) {
continue;
}
$this->translator()->setLocale($langCode);
$translations[$langCode] = $this->formatAlternateTranslation($context, $localeStruct);
}
$this->translator()->setLocale($origLang);
unset($this->translator()->isIteratingLocales);
return $translations;
} | [
"protected",
"function",
"buildAlternateTranslations",
"(",
")",
"{",
"$",
"translations",
"=",
"[",
"]",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"contextObject",
"(",
")",
";",
"$",
"origLang",
"=",
"$",
"this",
"->",
"currentLanguage",
"(",
")",
"... | Build the alternate translations associated with the current route.
This method _excludes_ the current route's canonical URI.
@return array | [
"Build",
"the",
"alternate",
"translations",
"associated",
"with",
"the",
"current",
"route",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/LocaleAwareTrait.php#L125-L147 |
39,787 | mcaskill/charcoal-support | src/Cms/LocaleAwareTrait.php | LocaleAwareTrait.getAlternateTranslations | protected function getAlternateTranslations()
{
if ($this->alternateTranslations === null) {
$this->alternateTranslations = $this->buildAlternateTranslations();
}
return $this->alternateTranslations;
} | php | protected function getAlternateTranslations()
{
if ($this->alternateTranslations === null) {
$this->alternateTranslations = $this->buildAlternateTranslations();
}
return $this->alternateTranslations;
} | [
"protected",
"function",
"getAlternateTranslations",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"alternateTranslations",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"alternateTranslations",
"=",
"$",
"this",
"->",
"buildAlternateTranslations",
"(",
")",
";",
... | Retrieve the alternate translations associated with the current route.
This method _excludes_ the current route's canonical URI.
@return array | [
"Retrieve",
"the",
"alternate",
"translations",
"associated",
"with",
"the",
"current",
"route",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/LocaleAwareTrait.php#L156-L163 |
39,788 | mcaskill/charcoal-support | src/Cms/LocaleAwareTrait.php | LocaleAwareTrait.formatAlternateTranslation | protected function formatAlternateTranslation($context, array $localeStruct)
{
return [
'id' => ($context['id']) ? : $this->templateName(),
'title' => ((string)$context['title']) ? : $this->title(),
'url' => $this->formatAlternateTranslationUrl($context, $localeStruct),
'hreflang' => $localeStruct['code'],
'locale' => $localeStruct['locale'],
'name' => $localeStruct['name'],
'native' => $localeStruct['native'],
];
} | php | protected function formatAlternateTranslation($context, array $localeStruct)
{
return [
'id' => ($context['id']) ? : $this->templateName(),
'title' => ((string)$context['title']) ? : $this->title(),
'url' => $this->formatAlternateTranslationUrl($context, $localeStruct),
'hreflang' => $localeStruct['code'],
'locale' => $localeStruct['locale'],
'name' => $localeStruct['name'],
'native' => $localeStruct['native'],
];
} | [
"protected",
"function",
"formatAlternateTranslation",
"(",
"$",
"context",
",",
"array",
"$",
"localeStruct",
")",
"{",
"return",
"[",
"'id'",
"=>",
"(",
"$",
"context",
"[",
"'id'",
"]",
")",
"?",
":",
"$",
"this",
"->",
"templateName",
"(",
")",
",",
... | Format an alternate translation for the given translatable model.
Note: The application's locale is already modified and will be reset
after processing all available languages.
@param mixed $context The translated {@see \Charcoal\Model\ModelInterface model}
or array-accessible structure.
@param array $localeStruct The currently iterated language.
@return array Returns a link structure. | [
"Format",
"an",
"alternate",
"translation",
"for",
"the",
"given",
"translatable",
"model",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/LocaleAwareTrait.php#L176-L187 |
39,789 | mcaskill/charcoal-support | src/Cms/LocaleAwareTrait.php | LocaleAwareTrait.formatAlternateTranslationUrl | protected function formatAlternateTranslationUrl($context, array $localeStruct)
{
$isRoutable = ($context instanceof RoutableInterface && $context->isActiveRoute());
$langCode = $localeStruct['code'];
$path = ($isRoutable ? $context->url($langCode) : ($this->currentUrl() ? : $langCode));
if ($path instanceof UriInterface) {
$path = $path->getPath();
}
return $this->baseUrl()->withPath($path);
} | php | protected function formatAlternateTranslationUrl($context, array $localeStruct)
{
$isRoutable = ($context instanceof RoutableInterface && $context->isActiveRoute());
$langCode = $localeStruct['code'];
$path = ($isRoutable ? $context->url($langCode) : ($this->currentUrl() ? : $langCode));
if ($path instanceof UriInterface) {
$path = $path->getPath();
}
return $this->baseUrl()->withPath($path);
} | [
"protected",
"function",
"formatAlternateTranslationUrl",
"(",
"$",
"context",
",",
"array",
"$",
"localeStruct",
")",
"{",
"$",
"isRoutable",
"=",
"(",
"$",
"context",
"instanceof",
"RoutableInterface",
"&&",
"$",
"context",
"->",
"isActiveRoute",
"(",
")",
")"... | Format an alternate translation URL for the given translatable model.
Note: The application's locale is already modified and will be reset
after processing all available languages.
@param mixed $context The translated {@see \Charcoal\Model\ModelInterface model}
or array-accessible structure.
@param array $localeStruct The currently iterated language.
@return string Returns a link. | [
"Format",
"an",
"alternate",
"translation",
"URL",
"for",
"the",
"given",
"translatable",
"model",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/LocaleAwareTrait.php#L200-L211 |
39,790 | locomotivemtl/charcoal-property | src/Charcoal/Property/AbstractProperty.php | AbstractProperty.l10nIdent | public function l10nIdent($lang = null)
{
if ($this->ident === '') {
throw new RuntimeException('Missing Property Identifier');
}
if (!$this->l10n()) {
throw new LogicException(sprintf(
'Property "%s" is not multilingual',
$this->ident
));
}
if ($lang === null) {
$lang = $this->translator()->getLocale();
} elseif (!is_string($lang)) {
throw new InvalidArgumentException(sprintf(
'Language must be a string for Property "%s"',
$this->ident
));
}
return sprintf('%1$s_%2$s', $this->ident, $lang);
} | php | public function l10nIdent($lang = null)
{
if ($this->ident === '') {
throw new RuntimeException('Missing Property Identifier');
}
if (!$this->l10n()) {
throw new LogicException(sprintf(
'Property "%s" is not multilingual',
$this->ident
));
}
if ($lang === null) {
$lang = $this->translator()->getLocale();
} elseif (!is_string($lang)) {
throw new InvalidArgumentException(sprintf(
'Language must be a string for Property "%s"',
$this->ident
));
}
return sprintf('%1$s_%2$s', $this->ident, $lang);
} | [
"public",
"function",
"l10nIdent",
"(",
"$",
"lang",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ident",
"===",
"''",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Missing Property Identifier'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"thi... | Retrieve the property's localized identifier.
@param string|null $lang The language code to return the identifier with.
@throws LogicException If the property is not multilingual.
@throws RuntimeException If the property has no identifier.
@throws InvalidArgumentException If the language code is invalid.
@return string | [
"Retrieve",
"the",
"property",
"s",
"localized",
"identifier",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/AbstractProperty.php#L256-L279 |
39,791 | locomotivemtl/charcoal-property | src/Charcoal/Property/AbstractProperty.php | AbstractProperty.setMultiple | public function setMultiple($multiple)
{
if (!is_bool($multiple)) {
if (is_array($multiple)) {
$this->setMultipleOptions($multiple);
} elseif (is_int($multiple)) {
$this->setMultipleOptions([
'min' => $multiple,
'max' => $multiple
]);
}
}
$this->multiple = !!$multiple;
return $this;
} | php | public function setMultiple($multiple)
{
if (!is_bool($multiple)) {
if (is_array($multiple)) {
$this->setMultipleOptions($multiple);
} elseif (is_int($multiple)) {
$this->setMultipleOptions([
'min' => $multiple,
'max' => $multiple
]);
}
}
$this->multiple = !!$multiple;
return $this;
} | [
"public",
"function",
"setMultiple",
"(",
"$",
"multiple",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"multiple",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"multiple",
")",
")",
"{",
"$",
"this",
"->",
"setMultipleOptions",
"(",
"$",
"multi... | Set whether this property accepts multiple values or a single value.
@param boolean $multiple The multiple flag.
@return self | [
"Set",
"whether",
"this",
"property",
"accepts",
"multiple",
"values",
"or",
"a",
"single",
"value",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/AbstractProperty.php#L533-L549 |
39,792 | locomotivemtl/charcoal-property | src/Charcoal/Property/AbstractProperty.php | AbstractProperty.multipleOptions | public function multipleOptions($key = null)
{
if ($this->multipleOptions === null) {
$this->multipleOptions = $this->defaultMultipleOptions();
}
if (is_string($key)) {
if (isset($this->multipleOptions[$key])) {
return $this->multipleOptions[$key];
} else {
return null;
}
}
return $this->multipleOptions;
} | php | public function multipleOptions($key = null)
{
if ($this->multipleOptions === null) {
$this->multipleOptions = $this->defaultMultipleOptions();
}
if (is_string($key)) {
if (isset($this->multipleOptions[$key])) {
return $this->multipleOptions[$key];
} else {
return null;
}
}
return $this->multipleOptions;
} | [
"public",
"function",
"multipleOptions",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"multipleOptions",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"multipleOptions",
"=",
"$",
"this",
"->",
"defaultMultipleOptions",
"(",
")",
"... | The options defining the property behavior when the multiple flag is set to true.
@see self::defaultMultipleOptions
@param string|null $key Optional setting to retrieve from the options.
@return array|mixed|null | [
"The",
"options",
"defining",
"the",
"property",
"behavior",
"when",
"the",
"multiple",
"flag",
"is",
"set",
"to",
"true",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/AbstractProperty.php#L594-L609 |
39,793 | locomotivemtl/charcoal-property | src/Charcoal/Property/AbstractProperty.php | AbstractProperty.viewOptions | final public function viewOptions($ident = null)
{
// No options defined
if (!$this->viewOptions) {
return [];
}
// No ident defined
if (!$ident) {
return $this->viewOptions;
}
// Invalid ident
if (!isset($this->viewOptions[$ident])) {
return [];
}
// Success!
return $this->viewOptions[$ident];
} | php | final public function viewOptions($ident = null)
{
// No options defined
if (!$this->viewOptions) {
return [];
}
// No ident defined
if (!$ident) {
return $this->viewOptions;
}
// Invalid ident
if (!isset($this->viewOptions[$ident])) {
return [];
}
// Success!
return $this->viewOptions[$ident];
} | [
"final",
"public",
"function",
"viewOptions",
"(",
"$",
"ident",
"=",
"null",
")",
"{",
"// No options defined",
"if",
"(",
"!",
"$",
"this",
"->",
"viewOptions",
")",
"{",
"return",
"[",
"]",
";",
"}",
"// No ident defined",
"if",
"(",
"!",
"$",
"ident"... | View options.
@param string $ident The display ident (ex: charcoal/admin/property/display/text).
@return array Should ALWAYS be an array. | [
"View",
"options",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/AbstractProperty.php#L896-L915 |
39,794 | locomotivemtl/charcoal-property | src/Charcoal/Property/AbstractProperty.php | AbstractProperty.l10nVal | protected function l10nVal($val, $lang = null)
{
if (!is_string($lang)) {
if (is_array($lang) && isset($lang['lang'])) {
$lang = $lang['lang'];
} else {
$lang = $this->translator()->getLocale();
}
}
if (isset($val[$lang])) {
return $val[$lang];
} else {
return null;
}
} | php | protected function l10nVal($val, $lang = null)
{
if (!is_string($lang)) {
if (is_array($lang) && isset($lang['lang'])) {
$lang = $lang['lang'];
} else {
$lang = $this->translator()->getLocale();
}
}
if (isset($val[$lang])) {
return $val[$lang];
} else {
return null;
}
} | [
"protected",
"function",
"l10nVal",
"(",
"$",
"val",
",",
"$",
"lang",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"lang",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"lang",
")",
"&&",
"isset",
"(",
"$",
"lang",
"[",
"'la... | Attempt to get the multilingual value in the requested language.
@param mixed $val The multilingual value to lookup.
@param mixed $lang The language to return the value in.
@return string|null | [
"Attempt",
"to",
"get",
"the",
"multilingual",
"value",
"in",
"the",
"requested",
"language",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/AbstractProperty.php#L947-L962 |
39,795 | dotsunited/BundleFu | src/DotsUnited/BundleFu/Filter/FilterChain.php | FilterChain.addFilter | public function addFilter(FilterInterface $filter, $placement = self::CHAIN_APPEND)
{
if ($placement == self::CHAIN_PREPEND) {
array_unshift($this->filters, $filter);
} else {
$this->filters[] = $filter;
}
return $this;
} | php | public function addFilter(FilterInterface $filter, $placement = self::CHAIN_APPEND)
{
if ($placement == self::CHAIN_PREPEND) {
array_unshift($this->filters, $filter);
} else {
$this->filters[] = $filter;
}
return $this;
} | [
"public",
"function",
"addFilter",
"(",
"FilterInterface",
"$",
"filter",
",",
"$",
"placement",
"=",
"self",
"::",
"CHAIN_APPEND",
")",
"{",
"if",
"(",
"$",
"placement",
"==",
"self",
"::",
"CHAIN_PREPEND",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->... | Adds a filter to the chain
@param FilterInterface $filter
@param string $placement
@return FilterChain | [
"Adds",
"a",
"filter",
"to",
"the",
"chain"
] | d219bef65b5ca1dd6f542c816a1bad88383b924a | https://github.com/dotsunited/BundleFu/blob/d219bef65b5ca1dd6f542c816a1bad88383b924a/src/DotsUnited/BundleFu/Filter/FilterChain.php#L39-L48 |
39,796 | dotsunited/BundleFu | src/DotsUnited/BundleFu/Filter/CssUrlRewriteFilter.php | CssUrlRewriteFilter.rewriteUrl | protected function rewriteUrl($matches)
{
$matchedUrl = trim($matches['url']);
// First check also matches protocol-relative urls like //example.com/images/bg.gif
if ('/' === $matchedUrl[0] || false !== strpos($matchedUrl, '://') || 0 === strpos($matchedUrl, 'data:')) {
return $matches[0];
}
$sourceUrl = dirname($this->file);
if ('.' === $sourceUrl) {
$sourceUrl = '/';
}
$path = $this->bundleUrl;
if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
// parse_url() does not work with protocol-relative urls
list(, $url) = explode('//', $path, 2);
list(, $path) = explode('/', $url, 2);
}
$bundleUrl = dirname($path);
if ('.' === $bundleUrl) {
$bundleUrl = '/';
}
$url = $this->rewriteRelative($matchedUrl, $sourceUrl, $bundleUrl);
return str_replace($matchedUrl, $url, $matches[0]);
} | php | protected function rewriteUrl($matches)
{
$matchedUrl = trim($matches['url']);
// First check also matches protocol-relative urls like //example.com/images/bg.gif
if ('/' === $matchedUrl[0] || false !== strpos($matchedUrl, '://') || 0 === strpos($matchedUrl, 'data:')) {
return $matches[0];
}
$sourceUrl = dirname($this->file);
if ('.' === $sourceUrl) {
$sourceUrl = '/';
}
$path = $this->bundleUrl;
if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
// parse_url() does not work with protocol-relative urls
list(, $url) = explode('//', $path, 2);
list(, $path) = explode('/', $url, 2);
}
$bundleUrl = dirname($path);
if ('.' === $bundleUrl) {
$bundleUrl = '/';
}
$url = $this->rewriteRelative($matchedUrl, $sourceUrl, $bundleUrl);
return str_replace($matchedUrl, $url, $matches[0]);
} | [
"protected",
"function",
"rewriteUrl",
"(",
"$",
"matches",
")",
"{",
"$",
"matchedUrl",
"=",
"trim",
"(",
"$",
"matches",
"[",
"'url'",
"]",
")",
";",
"// First check also matches protocol-relative urls like //example.com/images/bg.gif",
"if",
"(",
"'/'",
"===",
"$... | Callback which rewrites matched CSS ruls.
@param array $matches
@return string | [
"Callback",
"which",
"rewrites",
"matched",
"CSS",
"ruls",
"."
] | d219bef65b5ca1dd6f542c816a1bad88383b924a | https://github.com/dotsunited/BundleFu/blob/d219bef65b5ca1dd6f542c816a1bad88383b924a/src/DotsUnited/BundleFu/Filter/CssUrlRewriteFilter.php#L55-L87 |
39,797 | dotsunited/BundleFu | src/DotsUnited/BundleFu/Filter/CssUrlRewriteFilter.php | CssUrlRewriteFilter.rewriteRelative | protected function rewriteRelative($url, $sourceUrl, $bundleUrl)
{
$sourceUrl = trim($sourceUrl, '/');
$bundleUrl = trim($bundleUrl, '/');
if ($bundleUrl === $sourceUrl) {
return $url;
}
if ('' === $sourceUrl) {
return str_repeat('../', count(explode('/', $bundleUrl))) . $url;
}
if ('' === $bundleUrl) {
return $this->canonicalize($sourceUrl . '/' . $url);
}
if (0 === strpos($bundleUrl, $sourceUrl)) {
$prepend = $bundleUrl;
$count = 0;
while ($prepend !== $sourceUrl) {
$count++;
$prepend = dirname($prepend);
}
return str_repeat('../', $count) . $url;
} elseif (0 === strpos($sourceUrl, $bundleUrl)) {
$path = $sourceUrl;
while (0 === strpos($url, '../') && $path !== $bundleUrl) {
$path = dirname($path);
$url = substr($url, 3);
}
return $url;
} else {
$prepend = str_repeat('../', count(explode('/', $bundleUrl)));
$path = $sourceUrl . '/' . $url;
return $prepend . $this->canonicalize($path);
}
} | php | protected function rewriteRelative($url, $sourceUrl, $bundleUrl)
{
$sourceUrl = trim($sourceUrl, '/');
$bundleUrl = trim($bundleUrl, '/');
if ($bundleUrl === $sourceUrl) {
return $url;
}
if ('' === $sourceUrl) {
return str_repeat('../', count(explode('/', $bundleUrl))) . $url;
}
if ('' === $bundleUrl) {
return $this->canonicalize($sourceUrl . '/' . $url);
}
if (0 === strpos($bundleUrl, $sourceUrl)) {
$prepend = $bundleUrl;
$count = 0;
while ($prepend !== $sourceUrl) {
$count++;
$prepend = dirname($prepend);
}
return str_repeat('../', $count) . $url;
} elseif (0 === strpos($sourceUrl, $bundleUrl)) {
$path = $sourceUrl;
while (0 === strpos($url, '../') && $path !== $bundleUrl) {
$path = dirname($path);
$url = substr($url, 3);
}
return $url;
} else {
$prepend = str_repeat('../', count(explode('/', $bundleUrl)));
$path = $sourceUrl . '/' . $url;
return $prepend . $this->canonicalize($path);
}
} | [
"protected",
"function",
"rewriteRelative",
"(",
"$",
"url",
",",
"$",
"sourceUrl",
",",
"$",
"bundleUrl",
")",
"{",
"$",
"sourceUrl",
"=",
"trim",
"(",
"$",
"sourceUrl",
",",
"'/'",
")",
";",
"$",
"bundleUrl",
"=",
"trim",
"(",
"$",
"bundleUrl",
",",
... | Rewrites to a relative url.
@param string $url
@param string $sourceUrl
@param string $bundleUrl
@return string | [
"Rewrites",
"to",
"a",
"relative",
"url",
"."
] | d219bef65b5ca1dd6f542c816a1bad88383b924a | https://github.com/dotsunited/BundleFu/blob/d219bef65b5ca1dd6f542c816a1bad88383b924a/src/DotsUnited/BundleFu/Filter/CssUrlRewriteFilter.php#L97-L138 |
39,798 | dotsunited/BundleFu | src/DotsUnited/BundleFu/Filter/CssUrlRewriteFilter.php | CssUrlRewriteFilter.canonicalize | protected function canonicalize($path)
{
$parts = array_filter(explode('/', $path));
$canonicalized = array();
foreach ($parts as $part) {
if ('.' == $part) {
continue;
}
if ('..' == $part) {
array_pop($canonicalized);
} else {
$canonicalized[] = $part;
}
}
return implode('/', $canonicalized);
} | php | protected function canonicalize($path)
{
$parts = array_filter(explode('/', $path));
$canonicalized = array();
foreach ($parts as $part) {
if ('.' == $part) {
continue;
}
if ('..' == $part) {
array_pop($canonicalized);
} else {
$canonicalized[] = $part;
}
}
return implode('/', $canonicalized);
} | [
"protected",
"function",
"canonicalize",
"(",
"$",
"path",
")",
"{",
"$",
"parts",
"=",
"array_filter",
"(",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
")",
";",
"$",
"canonicalized",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"parts",
"as"... | Canonicalizes a path.
@param string $path
@return string | [
"Canonicalizes",
"a",
"path",
"."
] | d219bef65b5ca1dd6f542c816a1bad88383b924a | https://github.com/dotsunited/BundleFu/blob/d219bef65b5ca1dd6f542c816a1bad88383b924a/src/DotsUnited/BundleFu/Filter/CssUrlRewriteFilter.php#L146-L164 |
39,799 | dotsunited/BundleFu | src/DotsUnited/BundleFu/Factory.php | Factory.setFilter | public function setFilter($name, FilterInterface $filter = null)
{
$this->filters[$name] = $filter;
return $this;
} | php | public function setFilter($name, FilterInterface $filter = null)
{
$this->filters[$name] = $filter;
return $this;
} | [
"public",
"function",
"setFilter",
"(",
"$",
"name",
",",
"FilterInterface",
"$",
"filter",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"filters",
"[",
"$",
"name",
"]",
"=",
"$",
"filter",
";",
"return",
"$",
"this",
";",
"}"
] | Set a filter.
@param string $name
@param \DotsUnited\BundleFu\Filter\FilterInterface $filter
@return \DotsUnited\BundleFu\Factory | [
"Set",
"a",
"filter",
"."
] | d219bef65b5ca1dd6f542c816a1bad88383b924a | https://github.com/dotsunited/BundleFu/blob/d219bef65b5ca1dd6f542c816a1bad88383b924a/src/DotsUnited/BundleFu/Factory.php#L76-L81 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.