repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
vaibhavpandeyvpz/sandesh | src/Stream.php | Stream.tell | public function tell()
{
if (!isset($this->resource)) {
throw new \RuntimeException('Cannot determine position from detached resource');
}
$position = ftell($this->resource);
if ($position !== false) {
return $position;
}
throw new \RuntimeException('Unable to determine stream position');
} | php | public function tell()
{
if (!isset($this->resource)) {
throw new \RuntimeException('Cannot determine position from detached resource');
}
$position = ftell($this->resource);
if ($position !== false) {
return $position;
}
throw new \RuntimeException('Unable to determine stream position');
} | [
"public",
"function",
"tell",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Cannot determine position from detached resource'",
")",
";",
"}",
"$",
"position",
"=",
"ftell",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"if",
"(",
"$",
"position",
"!==",
"false",
")",
"{",
"return",
"$",
"position",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to determine stream position'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vaibhavpandeyvpz/sandesh/blob/bea2d06c7cac099ed82da973c922859de4158de0/src/Stream.php#L209-L219 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/ProjectAnalyzer.php | ProjectAnalyzer.analyze | public function analyze(ProjectDescriptor $projectDescriptor)
{
$this->unresolvedParentClassesCount = 0;
$elementCounter = array();
foreach ($this->findAllElements($projectDescriptor) as $element) {
$elementCounter = $this->addElementToCounter($elementCounter, $element);
$this->incrementUnresolvedParentCounter($element);
}
$this->descriptorCountByType = $elementCounter;
$this->fileCount = count($projectDescriptor->getFiles());
$this->topLevelNamespaceCount = count($projectDescriptor->getNamespace()->getChildren());
} | php | public function analyze(ProjectDescriptor $projectDescriptor)
{
$this->unresolvedParentClassesCount = 0;
$elementCounter = array();
foreach ($this->findAllElements($projectDescriptor) as $element) {
$elementCounter = $this->addElementToCounter($elementCounter, $element);
$this->incrementUnresolvedParentCounter($element);
}
$this->descriptorCountByType = $elementCounter;
$this->fileCount = count($projectDescriptor->getFiles());
$this->topLevelNamespaceCount = count($projectDescriptor->getNamespace()->getChildren());
} | [
"public",
"function",
"analyze",
"(",
"ProjectDescriptor",
"$",
"projectDescriptor",
")",
"{",
"$",
"this",
"->",
"unresolvedParentClassesCount",
"=",
"0",
";",
"$",
"elementCounter",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"findAllElements",
"(",
"$",
"projectDescriptor",
")",
"as",
"$",
"element",
")",
"{",
"$",
"elementCounter",
"=",
"$",
"this",
"->",
"addElementToCounter",
"(",
"$",
"elementCounter",
",",
"$",
"element",
")",
";",
"$",
"this",
"->",
"incrementUnresolvedParentCounter",
"(",
"$",
"element",
")",
";",
"}",
"$",
"this",
"->",
"descriptorCountByType",
"=",
"$",
"elementCounter",
";",
"$",
"this",
"->",
"fileCount",
"=",
"count",
"(",
"$",
"projectDescriptor",
"->",
"getFiles",
"(",
")",
")",
";",
"$",
"this",
"->",
"topLevelNamespaceCount",
"=",
"count",
"(",
"$",
"projectDescriptor",
"->",
"getNamespace",
"(",
")",
"->",
"getChildren",
"(",
")",
")",
";",
"}"
] | Analyzes the given project descriptor and populates this object's properties.
@param ProjectDescriptor $projectDescriptor
@return void | [
"Analyzes",
"the",
"given",
"project",
"descriptor",
"and",
"populates",
"this",
"object",
"s",
"properties",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ProjectAnalyzer.php#L45-L58 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/ProjectAnalyzer.php | ProjectAnalyzer.addElementToCounter | protected function addElementToCounter($classCounters, $element)
{
if (!isset($classCounters[get_class($element)])) {
$classCounters[get_class($element)] = 0;
}
$classCounters[get_class($element)]++;
return $classCounters;
} | php | protected function addElementToCounter($classCounters, $element)
{
if (!isset($classCounters[get_class($element)])) {
$classCounters[get_class($element)] = 0;
}
$classCounters[get_class($element)]++;
return $classCounters;
} | [
"protected",
"function",
"addElementToCounter",
"(",
"$",
"classCounters",
",",
"$",
"element",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"classCounters",
"[",
"get_class",
"(",
"$",
"element",
")",
"]",
")",
")",
"{",
"$",
"classCounters",
"[",
"get_class",
"(",
"$",
"element",
")",
"]",
"=",
"0",
";",
"}",
"$",
"classCounters",
"[",
"get_class",
"(",
"$",
"element",
")",
"]",
"++",
";",
"return",
"$",
"classCounters",
";",
"}"
] | Increments the counter for element's class in the class counters.
@param array $classCounters
@param DescriptorAbstract $element
@return array | [
"Increments",
"the",
"counter",
"for",
"element",
"s",
"class",
"in",
"the",
"class",
"counters",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ProjectAnalyzer.php#L94-L102 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Core/Xslt/Extension.php | Extension.path | public static function path($fqsen)
{
$projectDescriptor = self::$descriptorBuilder->getProjectDescriptor();
$elementList = $projectDescriptor->getIndexes()->get('elements');
$node = $fqsen;
if (isset($elementList[$fqsen])) {
$node = $elementList[$fqsen];
} elseif (isset($elementList['~\\' . $fqsen])) {
$node = $elementList['~\\' . $fqsen];
}
$rule = self::$routers->match($node);
if (! $rule) {
return '';
}
$generatedUrl = $rule->generate($node);
return $generatedUrl ? ltrim($generatedUrl, '/') : false;
} | php | public static function path($fqsen)
{
$projectDescriptor = self::$descriptorBuilder->getProjectDescriptor();
$elementList = $projectDescriptor->getIndexes()->get('elements');
$node = $fqsen;
if (isset($elementList[$fqsen])) {
$node = $elementList[$fqsen];
} elseif (isset($elementList['~\\' . $fqsen])) {
$node = $elementList['~\\' . $fqsen];
}
$rule = self::$routers->match($node);
if (! $rule) {
return '';
}
$generatedUrl = $rule->generate($node);
return $generatedUrl ? ltrim($generatedUrl, '/') : false;
} | [
"public",
"static",
"function",
"path",
"(",
"$",
"fqsen",
")",
"{",
"$",
"projectDescriptor",
"=",
"self",
"::",
"$",
"descriptorBuilder",
"->",
"getProjectDescriptor",
"(",
")",
";",
"$",
"elementList",
"=",
"$",
"projectDescriptor",
"->",
"getIndexes",
"(",
")",
"->",
"get",
"(",
"'elements'",
")",
";",
"$",
"node",
"=",
"$",
"fqsen",
";",
"if",
"(",
"isset",
"(",
"$",
"elementList",
"[",
"$",
"fqsen",
"]",
")",
")",
"{",
"$",
"node",
"=",
"$",
"elementList",
"[",
"$",
"fqsen",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"elementList",
"[",
"'~\\\\'",
".",
"$",
"fqsen",
"]",
")",
")",
"{",
"$",
"node",
"=",
"$",
"elementList",
"[",
"'~\\\\'",
".",
"$",
"fqsen",
"]",
";",
"}",
"$",
"rule",
"=",
"self",
"::",
"$",
"routers",
"->",
"match",
"(",
"$",
"node",
")",
";",
"if",
"(",
"!",
"$",
"rule",
")",
"{",
"return",
"''",
";",
"}",
"$",
"generatedUrl",
"=",
"$",
"rule",
"->",
"generate",
"(",
"$",
"node",
")",
";",
"return",
"$",
"generatedUrl",
"?",
"ltrim",
"(",
"$",
"generatedUrl",
",",
"'/'",
")",
":",
"false",
";",
"}"
] | Returns a relative URL from the webroot if the given FQSEN exists in the project.
Example usage inside template would be (where @link is an attribute called link):
```
<xsl:value-of select="php:function('phpDocumentor\Plugin\Core\Xslt\Extension::path', string(@link))" />
```
@param string $fqsen
@return bool|string | [
"Returns",
"a",
"relative",
"URL",
"from",
"the",
"webroot",
"if",
"the",
"given",
"FQSEN",
"exists",
"in",
"the",
"project",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Xslt/Extension.php#L72-L92 |
sergmoro1/yii2-lookup | src/models/Lookup.php | Lookup.items | public static function items($property, $byId = false)
{
$property_id = self::getPropertyId($property, $byId);
if(!isset(self::$_items[$property_id]))
self::loadItems($property_id);
return self::$_items[$property_id];
} | php | public static function items($property, $byId = false)
{
$property_id = self::getPropertyId($property, $byId);
if(!isset(self::$_items[$property_id]))
self::loadItems($property_id);
return self::$_items[$property_id];
} | [
"public",
"static",
"function",
"items",
"(",
"$",
"property",
",",
"$",
"byId",
"=",
"false",
")",
"{",
"$",
"property_id",
"=",
"self",
"::",
"getPropertyId",
"(",
"$",
"property",
",",
"$",
"byId",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_items",
"[",
"$",
"property_id",
"]",
")",
")",
"self",
"::",
"loadItems",
"(",
"$",
"property_id",
")",
";",
"return",
"self",
"::",
"$",
"_items",
"[",
"$",
"property_id",
"]",
";",
"}"
] | Returns the items for the specified type.
@param string | integer property name or ID
@return array item names indexed by item code. The items are order by their position values.
@param boolean slug or integer ID
An empty array is returned if the item type does not exist. | [
"Returns",
"the",
"items",
"for",
"the",
"specified",
"type",
"."
] | train | https://github.com/sergmoro1/yii2-lookup/blob/deff08a2612b3c54d313a6c60a74fcaae1193b21/src/models/Lookup.php#L43-L49 |
sergmoro1/yii2-lookup | src/models/Lookup.php | Lookup.item | public static function item($property, $code, $byId = false)
{
$property_id = self::getPropertyId($property, $byId);
if(!isset(self::$_items[$property_id]))
self::loadItems($property_id);
return isset(self::$_items[$property_id][$code]) ? self::$_items[$property_id][$code] : false;
} | php | public static function item($property, $code, $byId = false)
{
$property_id = self::getPropertyId($property, $byId);
if(!isset(self::$_items[$property_id]))
self::loadItems($property_id);
return isset(self::$_items[$property_id][$code]) ? self::$_items[$property_id][$code] : false;
} | [
"public",
"static",
"function",
"item",
"(",
"$",
"property",
",",
"$",
"code",
",",
"$",
"byId",
"=",
"false",
")",
"{",
"$",
"property_id",
"=",
"self",
"::",
"getPropertyId",
"(",
"$",
"property",
",",
"$",
"byId",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_items",
"[",
"$",
"property_id",
"]",
")",
")",
"self",
"::",
"loadItems",
"(",
"$",
"property_id",
")",
";",
"return",
"isset",
"(",
"self",
"::",
"$",
"_items",
"[",
"$",
"property_id",
"]",
"[",
"$",
"code",
"]",
")",
"?",
"self",
"::",
"$",
"_items",
"[",
"$",
"property_id",
"]",
"[",
"$",
"code",
"]",
":",
"false",
";",
"}"
] | Returns the item name for the specified property and code.
@param string | integer property name or ID
@param integer the item code (corresponding to the 'code' column value)
@param boolean slug or integer ID
@return string the item name for the specified the code. False is returned if the item type or code does not exist. | [
"Returns",
"the",
"item",
"name",
"for",
"the",
"specified",
"property",
"and",
"code",
"."
] | train | https://github.com/sergmoro1/yii2-lookup/blob/deff08a2612b3c54d313a6c60a74fcaae1193b21/src/models/Lookup.php#L58-L64 |
sergmoro1/yii2-lookup | src/models/Lookup.php | Lookup.loadItems | private static function loadItems($property_id)
{
self::$_items[$property_id] = [];
$models = static::find()
->where('property_id=:property_id', [':property_id' => $property_id])
->orderBy('position')
->all();
foreach($models as $model)
self::$_items[$property_id][$model->code] = $model->name;
} | php | private static function loadItems($property_id)
{
self::$_items[$property_id] = [];
$models = static::find()
->where('property_id=:property_id', [':property_id' => $property_id])
->orderBy('position')
->all();
foreach($models as $model)
self::$_items[$property_id][$model->code] = $model->name;
} | [
"private",
"static",
"function",
"loadItems",
"(",
"$",
"property_id",
")",
"{",
"self",
"::",
"$",
"_items",
"[",
"$",
"property_id",
"]",
"=",
"[",
"]",
";",
"$",
"models",
"=",
"static",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'property_id=:property_id'",
",",
"[",
"':property_id'",
"=>",
"$",
"property_id",
"]",
")",
"->",
"orderBy",
"(",
"'position'",
")",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"models",
"as",
"$",
"model",
")",
"self",
"::",
"$",
"_items",
"[",
"$",
"property_id",
"]",
"[",
"$",
"model",
"->",
"code",
"]",
"=",
"$",
"model",
"->",
"name",
";",
"}"
] | Loads the lookup items for the specified property ID.
@param string the item type | [
"Loads",
"the",
"lookup",
"items",
"for",
"the",
"specified",
"property",
"ID",
"."
] | train | https://github.com/sergmoro1/yii2-lookup/blob/deff08a2612b3c54d313a6c60a74fcaae1193b21/src/models/Lookup.php#L74-L83 |
thienhungho/yii2-product-management | src/modules/ProductManage/controllers/ProductController.php | ProductController.actionCreate | public function actionCreate($slug = 'product')
{
if (!is_product_type_slug($slug)) {
throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
}
$product_type = ProductType::find()
->where(['slug' => $slug])
->one();
$model = new Product();
$model->author = get_current_user_id();
$model->status = STATUS_PUBLIC;
$model->language = get_primary_language();
$model->comment_status = STATUS_ENABLE;
$model->rating_status = STATUS_ENABLE;
$model->product_type = $slug;
$model->unit = Product::UNIT_1_PRODUCT;
$model->currency_unit = 'USD';
$model->id = 0;
$model->product_type = $slug;
if ($model->loadAll(request()->post())) {
if ($model->saveAll()) {
set_flash_has_been_saved();
create_all_term_relationships_of_all_term_type_of_product_type($model->product_type, $model->primaryKey);
create_all_meta_of_all_product_type_meta($model->product_type, $model->primaryKey);
return $this->redirect([
'update',
'id' => $model->id,
]);
} else {
set_flash_has_not_been_saved();
}
}
return $this->render('create', [
'model' => $model,
'product_type' => $product_type
]);
} | php | public function actionCreate($slug = 'product')
{
if (!is_product_type_slug($slug)) {
throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
}
$product_type = ProductType::find()
->where(['slug' => $slug])
->one();
$model = new Product();
$model->author = get_current_user_id();
$model->status = STATUS_PUBLIC;
$model->language = get_primary_language();
$model->comment_status = STATUS_ENABLE;
$model->rating_status = STATUS_ENABLE;
$model->product_type = $slug;
$model->unit = Product::UNIT_1_PRODUCT;
$model->currency_unit = 'USD';
$model->id = 0;
$model->product_type = $slug;
if ($model->loadAll(request()->post())) {
if ($model->saveAll()) {
set_flash_has_been_saved();
create_all_term_relationships_of_all_term_type_of_product_type($model->product_type, $model->primaryKey);
create_all_meta_of_all_product_type_meta($model->product_type, $model->primaryKey);
return $this->redirect([
'update',
'id' => $model->id,
]);
} else {
set_flash_has_not_been_saved();
}
}
return $this->render('create', [
'model' => $model,
'product_type' => $product_type
]);
} | [
"public",
"function",
"actionCreate",
"(",
"$",
"slug",
"=",
"'product'",
")",
"{",
"if",
"(",
"!",
"is_product_type_slug",
"(",
"$",
"slug",
")",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"t",
"(",
"'app'",
",",
"'The requested page does not exist.'",
")",
")",
";",
"}",
"$",
"product_type",
"=",
"ProductType",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'slug'",
"=>",
"$",
"slug",
"]",
")",
"->",
"one",
"(",
")",
";",
"$",
"model",
"=",
"new",
"Product",
"(",
")",
";",
"$",
"model",
"->",
"author",
"=",
"get_current_user_id",
"(",
")",
";",
"$",
"model",
"->",
"status",
"=",
"STATUS_PUBLIC",
";",
"$",
"model",
"->",
"language",
"=",
"get_primary_language",
"(",
")",
";",
"$",
"model",
"->",
"comment_status",
"=",
"STATUS_ENABLE",
";",
"$",
"model",
"->",
"rating_status",
"=",
"STATUS_ENABLE",
";",
"$",
"model",
"->",
"product_type",
"=",
"$",
"slug",
";",
"$",
"model",
"->",
"unit",
"=",
"Product",
"::",
"UNIT_1_PRODUCT",
";",
"$",
"model",
"->",
"currency_unit",
"=",
"'USD'",
";",
"$",
"model",
"->",
"id",
"=",
"0",
";",
"$",
"model",
"->",
"product_type",
"=",
"$",
"slug",
";",
"if",
"(",
"$",
"model",
"->",
"loadAll",
"(",
"request",
"(",
")",
"->",
"post",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"saveAll",
"(",
")",
")",
"{",
"set_flash_has_been_saved",
"(",
")",
";",
"create_all_term_relationships_of_all_term_type_of_product_type",
"(",
"$",
"model",
"->",
"product_type",
",",
"$",
"model",
"->",
"primaryKey",
")",
";",
"create_all_meta_of_all_product_type_meta",
"(",
"$",
"model",
"->",
"product_type",
",",
"$",
"model",
"->",
"primaryKey",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'update'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"]",
")",
";",
"}",
"else",
"{",
"set_flash_has_not_been_saved",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'create'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"'product_type'",
"=>",
"$",
"product_type",
"]",
")",
";",
"}"
] | @param string $slug
@return string|\yii\web\Response
@throws NotFoundHttpException
@throws \yii\db\Exception | [
"@param",
"string",
"$slug"
] | train | https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManage/controllers/ProductController.php#L89-L127 |
thienhungho/yii2-product-management | src/modules/ProductManage/controllers/ProductController.php | ProductController.actionUpdate | public function actionUpdate($id)
{
if (request()->post('_asnew') == '1') {
$model = new Product();
} else {
$model = $this->findModel($id);
}
if ($model->loadAll(request()->post())) {
if ($model->saveAll()) {
set_flash_has_been_saved();
create_all_term_relationships_of_all_term_type_of_product_type($model->product_type, $model->primaryKey);
create_all_meta_of_all_product_type_meta($model->product_type, $model->primaryKey);
} else {
set_flash_has_not_been_saved();
}
}
return $this->render('update', [
'model' => $model,
]);
} | php | public function actionUpdate($id)
{
if (request()->post('_asnew') == '1') {
$model = new Product();
} else {
$model = $this->findModel($id);
}
if ($model->loadAll(request()->post())) {
if ($model->saveAll()) {
set_flash_has_been_saved();
create_all_term_relationships_of_all_term_type_of_product_type($model->product_type, $model->primaryKey);
create_all_meta_of_all_product_type_meta($model->product_type, $model->primaryKey);
} else {
set_flash_has_not_been_saved();
}
}
return $this->render('update', [
'model' => $model,
]);
} | [
"public",
"function",
"actionUpdate",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"request",
"(",
")",
"->",
"post",
"(",
"'_asnew'",
")",
"==",
"'1'",
")",
"{",
"$",
"model",
"=",
"new",
"Product",
"(",
")",
";",
"}",
"else",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"loadAll",
"(",
"request",
"(",
")",
"->",
"post",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"saveAll",
"(",
")",
")",
"{",
"set_flash_has_been_saved",
"(",
")",
";",
"create_all_term_relationships_of_all_term_type_of_product_type",
"(",
"$",
"model",
"->",
"product_type",
",",
"$",
"model",
"->",
"primaryKey",
")",
";",
"create_all_meta_of_all_product_type_meta",
"(",
"$",
"model",
"->",
"product_type",
",",
"$",
"model",
"->",
"primaryKey",
")",
";",
"}",
"else",
"{",
"set_flash_has_not_been_saved",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'update'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] | @param $id
@return string
@throws NotFoundHttpException
@throws \yii\db\Exception | [
"@param",
"$id"
] | train | https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManage/controllers/ProductController.php#L136-L157 |
thienhungho/yii2-product-management | src/modules/ProductManage/controllers/ProductController.php | ProductController.actionSaveAsNewLanguage | public function actionSaveAsNewLanguage($id)
{
if (request()->post('_asnew') == '1') {
$product = $this->findModel($id);
$model = new Product();
$model->feature_img = $product->feature_img;
$model->gallery = $product->gallery;
$model->status = $product->status;
$model->comment_status = $product->comment_status;
$model->rating_status = $product->rating_status;
$model->quantity = $product->quantity;
$model->sku = $product->sku;
$model->assign_with = $product->id;
} else {
$model = $this->findModel($id);
}
if ($model->loadAll(request()->post())) {
if ($model->saveAll()) {
set_flash_has_been_saved();
create_all_term_relationships_of_all_term_type_of_product_type($model->product_type, $model->primaryKey);
create_all_meta_of_all_product_type_meta($model->product_type, $model->primaryKey);
} else {
set_flash_has_not_been_saved();
}
}
return $this->render('saveAsNewLanguage', [
'model' => $model,
]);
} | php | public function actionSaveAsNewLanguage($id)
{
if (request()->post('_asnew') == '1') {
$product = $this->findModel($id);
$model = new Product();
$model->feature_img = $product->feature_img;
$model->gallery = $product->gallery;
$model->status = $product->status;
$model->comment_status = $product->comment_status;
$model->rating_status = $product->rating_status;
$model->quantity = $product->quantity;
$model->sku = $product->sku;
$model->assign_with = $product->id;
} else {
$model = $this->findModel($id);
}
if ($model->loadAll(request()->post())) {
if ($model->saveAll()) {
set_flash_has_been_saved();
create_all_term_relationships_of_all_term_type_of_product_type($model->product_type, $model->primaryKey);
create_all_meta_of_all_product_type_meta($model->product_type, $model->primaryKey);
} else {
set_flash_has_not_been_saved();
}
}
return $this->render('saveAsNewLanguage', [
'model' => $model,
]);
} | [
"public",
"function",
"actionSaveAsNewLanguage",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"request",
"(",
")",
"->",
"post",
"(",
"'_asnew'",
")",
"==",
"'1'",
")",
"{",
"$",
"product",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"=",
"new",
"Product",
"(",
")",
";",
"$",
"model",
"->",
"feature_img",
"=",
"$",
"product",
"->",
"feature_img",
";",
"$",
"model",
"->",
"gallery",
"=",
"$",
"product",
"->",
"gallery",
";",
"$",
"model",
"->",
"status",
"=",
"$",
"product",
"->",
"status",
";",
"$",
"model",
"->",
"comment_status",
"=",
"$",
"product",
"->",
"comment_status",
";",
"$",
"model",
"->",
"rating_status",
"=",
"$",
"product",
"->",
"rating_status",
";",
"$",
"model",
"->",
"quantity",
"=",
"$",
"product",
"->",
"quantity",
";",
"$",
"model",
"->",
"sku",
"=",
"$",
"product",
"->",
"sku",
";",
"$",
"model",
"->",
"assign_with",
"=",
"$",
"product",
"->",
"id",
";",
"}",
"else",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"loadAll",
"(",
"request",
"(",
")",
"->",
"post",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"saveAll",
"(",
")",
")",
"{",
"set_flash_has_been_saved",
"(",
")",
";",
"create_all_term_relationships_of_all_term_type_of_product_type",
"(",
"$",
"model",
"->",
"product_type",
",",
"$",
"model",
"->",
"primaryKey",
")",
";",
"create_all_meta_of_all_product_type_meta",
"(",
"$",
"model",
"->",
"product_type",
",",
"$",
"model",
"->",
"primaryKey",
")",
";",
"}",
"else",
"{",
"set_flash_has_not_been_saved",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'saveAsNewLanguage'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] | @param $id
@return string|\yii\web\Response
@throws NotFoundHttpException
@throws \yii\db\Exception | [
"@param",
"$id"
] | train | https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManage/controllers/ProductController.php#L166-L195 |
thienhungho/yii2-product-management | src/modules/ProductManage/controllers/ProductController.php | ProductController.actionDelete | public function actionDelete($id)
{
$model = $this->findModel($id);
if ($model->deleteWithRelated()) {
delete_seo_data($model->product_type, $model->primaryKey);
Meta::deleteAll([
'obj_type' => $model->product_type,
'obj_id' => $model->primaryKey,
]);
TermRelationships::deleteAll([
'obj_type' => $model->product_type,
'obj_id' => $model->primaryKey,
]);
set_flash_success_delete_content();
} else {
set_flash_error_delete_content();
}
return $this->goBack(request()->referrer);
} | php | public function actionDelete($id)
{
$model = $this->findModel($id);
if ($model->deleteWithRelated()) {
delete_seo_data($model->product_type, $model->primaryKey);
Meta::deleteAll([
'obj_type' => $model->product_type,
'obj_id' => $model->primaryKey,
]);
TermRelationships::deleteAll([
'obj_type' => $model->product_type,
'obj_id' => $model->primaryKey,
]);
set_flash_success_delete_content();
} else {
set_flash_error_delete_content();
}
return $this->goBack(request()->referrer);
} | [
"public",
"function",
"actionDelete",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"->",
"deleteWithRelated",
"(",
")",
")",
"{",
"delete_seo_data",
"(",
"$",
"model",
"->",
"product_type",
",",
"$",
"model",
"->",
"primaryKey",
")",
";",
"Meta",
"::",
"deleteAll",
"(",
"[",
"'obj_type'",
"=>",
"$",
"model",
"->",
"product_type",
",",
"'obj_id'",
"=>",
"$",
"model",
"->",
"primaryKey",
",",
"]",
")",
";",
"TermRelationships",
"::",
"deleteAll",
"(",
"[",
"'obj_type'",
"=>",
"$",
"model",
"->",
"product_type",
",",
"'obj_id'",
"=>",
"$",
"model",
"->",
"primaryKey",
",",
"]",
")",
";",
"set_flash_success_delete_content",
"(",
")",
";",
"}",
"else",
"{",
"set_flash_error_delete_content",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"goBack",
"(",
"request",
"(",
")",
"->",
"referrer",
")",
";",
"}"
] | @param $id
@return \yii\web\Response
@throws NotFoundHttpException
@throws \yii\db\Exception | [
"@param",
"$id"
] | train | https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManage/controllers/ProductController.php#L204-L223 |
thienhungho/yii2-product-management | src/modules/ProductManage/controllers/ProductController.php | ProductController.actionSaveAsNew | public function actionSaveAsNew($id)
{
$model = new Product();
if (request()->post('_asnew') != '1') {
$model = $this->findModel($id);
}
if ($model->loadAll(request()->post())) {
if ($model->saveAll()) {
set_flash_has_been_saved();
create_all_term_relationships_of_all_term_type_of_product_type($model->product_type, $model->primaryKey);
return $this->redirect([
'update',
'id' => $model->id,
]);
} else {
set_flash_has_not_been_saved();
}
}
return $this->render('saveAsNew', [
'model' => $model,
]);
} | php | public function actionSaveAsNew($id)
{
$model = new Product();
if (request()->post('_asnew') != '1') {
$model = $this->findModel($id);
}
if ($model->loadAll(request()->post())) {
if ($model->saveAll()) {
set_flash_has_been_saved();
create_all_term_relationships_of_all_term_type_of_product_type($model->product_type, $model->primaryKey);
return $this->redirect([
'update',
'id' => $model->id,
]);
} else {
set_flash_has_not_been_saved();
}
}
return $this->render('saveAsNew', [
'model' => $model,
]);
} | [
"public",
"function",
"actionSaveAsNew",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"new",
"Product",
"(",
")",
";",
"if",
"(",
"request",
"(",
")",
"->",
"post",
"(",
"'_asnew'",
")",
"!=",
"'1'",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"loadAll",
"(",
"request",
"(",
")",
"->",
"post",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"saveAll",
"(",
")",
")",
"{",
"set_flash_has_been_saved",
"(",
")",
";",
"create_all_term_relationships_of_all_term_type_of_product_type",
"(",
"$",
"model",
"->",
"product_type",
",",
"$",
"model",
"->",
"primaryKey",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'update'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"]",
")",
";",
"}",
"else",
"{",
"set_flash_has_not_been_saved",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'saveAsNew'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] | @param $id
@return string|\yii\web\Response
@throws NotFoundHttpException
@throws \yii\db\Exception | [
"@param",
"$id"
] | train | https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManage/controllers/ProductController.php#L310-L333 |
syzygypl/page-media-set-bundle | DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('page_media_set');
$rootNode->children()->booleanNode('indexer')->defaultFalse();
/** @var ArrayNodeDefinition $types */
$types = $rootNode->children()->arrayNode('types');
$types->defaultValue([]);
$types = $types->prototype('array');
$types->prototype('scalar');
$formats = $rootNode->children()->arrayNode('formats');
$formats->isRequired();
$formats->requiresAtLeastOneElement();
$formats->beforeNormalization()->ifNull()->then(function () { return []; });
/** @var ArrayNodeDefinition $prototype */
$prototype = $formats->prototype('array');
$prototype->children()->scalarNode('min_width')->defaultNull();
$prototype->children()->scalarNode('min_height')->defaultNull();
$prototype->children()->scalarNode('max_width')->defaultNull();
$prototype->children()->scalarNode('max_height')->defaultNull();
return $treeBuilder;
} | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('page_media_set');
$rootNode->children()->booleanNode('indexer')->defaultFalse();
/** @var ArrayNodeDefinition $types */
$types = $rootNode->children()->arrayNode('types');
$types->defaultValue([]);
$types = $types->prototype('array');
$types->prototype('scalar');
$formats = $rootNode->children()->arrayNode('formats');
$formats->isRequired();
$formats->requiresAtLeastOneElement();
$formats->beforeNormalization()->ifNull()->then(function () { return []; });
/** @var ArrayNodeDefinition $prototype */
$prototype = $formats->prototype('array');
$prototype->children()->scalarNode('min_width')->defaultNull();
$prototype->children()->scalarNode('min_height')->defaultNull();
$prototype->children()->scalarNode('max_width')->defaultNull();
$prototype->children()->scalarNode('max_height')->defaultNull();
return $treeBuilder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"'page_media_set'",
")",
";",
"$",
"rootNode",
"->",
"children",
"(",
")",
"->",
"booleanNode",
"(",
"'indexer'",
")",
"->",
"defaultFalse",
"(",
")",
";",
"/** @var ArrayNodeDefinition $types */",
"$",
"types",
"=",
"$",
"rootNode",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'types'",
")",
";",
"$",
"types",
"->",
"defaultValue",
"(",
"[",
"]",
")",
";",
"$",
"types",
"=",
"$",
"types",
"->",
"prototype",
"(",
"'array'",
")",
";",
"$",
"types",
"->",
"prototype",
"(",
"'scalar'",
")",
";",
"$",
"formats",
"=",
"$",
"rootNode",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'formats'",
")",
";",
"$",
"formats",
"->",
"isRequired",
"(",
")",
";",
"$",
"formats",
"->",
"requiresAtLeastOneElement",
"(",
")",
";",
"$",
"formats",
"->",
"beforeNormalization",
"(",
")",
"->",
"ifNull",
"(",
")",
"->",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"[",
"]",
";",
"}",
")",
";",
"/** @var ArrayNodeDefinition $prototype */",
"$",
"prototype",
"=",
"$",
"formats",
"->",
"prototype",
"(",
"'array'",
")",
";",
"$",
"prototype",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'min_width'",
")",
"->",
"defaultNull",
"(",
")",
";",
"$",
"prototype",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'min_height'",
")",
"->",
"defaultNull",
"(",
")",
";",
"$",
"prototype",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'max_width'",
")",
"->",
"defaultNull",
"(",
")",
";",
"$",
"prototype",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'max_height'",
")",
"->",
"defaultNull",
"(",
")",
";",
"return",
"$",
"treeBuilder",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/syzygypl/page-media-set-bundle/blob/013d5321518755b07d292d63d5b3f1ddeb635107/DependencyInjection/Configuration.php#L20-L48 |
VincentChalnot/SidusDataGridBundle | Form/Type/LinkType.php | LinkType.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'route' => null,
'route_parameters' => [],
'uri' => null,
'attr' => [
'class' => 'btn btn-default btn-light',
],
]
);
$resolver->setAllowedTypes('route_parameters', 'array');
$resolver->setNormalizer(
'route',
function (Options $options, $value) {
if (!($value xor $options['uri'])) {
throw new \UnexpectedValueException("You must specify either a 'route' or an 'uri' option");
}
return $value;
}
);
} | php | public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'route' => null,
'route_parameters' => [],
'uri' => null,
'attr' => [
'class' => 'btn btn-default btn-light',
],
]
);
$resolver->setAllowedTypes('route_parameters', 'array');
$resolver->setNormalizer(
'route',
function (Options $options, $value) {
if (!($value xor $options['uri'])) {
throw new \UnexpectedValueException("You must specify either a 'route' or an 'uri' option");
}
return $value;
}
);
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"$",
"resolver",
"->",
"setDefaults",
"(",
"[",
"'route'",
"=>",
"null",
",",
"'route_parameters'",
"=>",
"[",
"]",
",",
"'uri'",
"=>",
"null",
",",
"'attr'",
"=>",
"[",
"'class'",
"=>",
"'btn btn-default btn-light'",
",",
"]",
",",
"]",
")",
";",
"$",
"resolver",
"->",
"setAllowedTypes",
"(",
"'route_parameters'",
",",
"'array'",
")",
";",
"$",
"resolver",
"->",
"setNormalizer",
"(",
"'route'",
",",
"function",
"(",
"Options",
"$",
"options",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"value",
"xor",
"$",
"options",
"[",
"'uri'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"You must specify either a 'route' or an 'uri' option\"",
")",
";",
"}",
"return",
"$",
"value",
";",
"}",
")",
";",
"}"
] | @param OptionsResolver $resolver
@throws AccessException
@throws UndefinedOptionsException
@throws \UnexpectedValueException | [
"@param",
"OptionsResolver",
"$resolver"
] | train | https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Form/Type/LinkType.php#L47-L70 |
codezero-be/laravel-localizer | src/Middleware/SetLocale.php | SetLocale.handle | public function handle($request, Closure $next)
{
$locale = $this->localizer->detect();
if ($locale) {
$this->localizer->store($locale);
}
return $next($request);
} | php | public function handle($request, Closure $next)
{
$locale = $this->localizer->detect();
if ($locale) {
$this->localizer->store($locale);
}
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"localizer",
"->",
"detect",
"(",
")",
";",
"if",
"(",
"$",
"locale",
")",
"{",
"$",
"this",
"->",
"localizer",
"->",
"store",
"(",
"$",
"locale",
")",
";",
"}",
"return",
"$",
"next",
"(",
"$",
"request",
")",
";",
"}"
] | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed | [
"Handle",
"an",
"incoming",
"request",
"."
] | train | https://github.com/codezero-be/laravel-localizer/blob/812692796a73bd38fc205404d8ef90df5bfa0d83/src/Middleware/SetLocale.php#L35-L44 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.hydrate | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
{
try {
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CustomerGroupTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
$this->code = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerGroupTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)];
$this->is_default = (null !== $col) ? (boolean) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerGroupTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
$this->id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerGroupTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerGroupTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerGroupTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
$this->position = (null !== $col) ? (int) $col : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
return $startcol + 6; // 6 = CustomerGroupTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \CustomerGroup\Model\CustomerGroup object", 0, $e);
}
} | php | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
{
try {
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CustomerGroupTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
$this->code = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerGroupTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)];
$this->is_default = (null !== $col) ? (boolean) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerGroupTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
$this->id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerGroupTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerGroupTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerGroupTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
$this->position = (null !== $col) ? (int) $col : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
return $startcol + 6; // 6 = CustomerGroupTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \CustomerGroup\Model\CustomerGroup object", 0, $e);
}
} | [
"public",
"function",
"hydrate",
"(",
"$",
"row",
",",
"$",
"startcol",
"=",
"0",
",",
"$",
"rehydrate",
"=",
"false",
",",
"$",
"indexType",
"=",
"TableMap",
"::",
"TYPE_NUM",
")",
"{",
"try",
"{",
"$",
"col",
"=",
"$",
"row",
"[",
"TableMap",
"::",
"TYPE_NUM",
"==",
"$",
"indexType",
"?",
"0",
"+",
"$",
"startcol",
":",
"CustomerGroupTableMap",
"::",
"translateFieldName",
"(",
"'Code'",
",",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"indexType",
")",
"]",
";",
"$",
"this",
"->",
"code",
"=",
"(",
"null",
"!==",
"$",
"col",
")",
"?",
"(",
"string",
")",
"$",
"col",
":",
"null",
";",
"$",
"col",
"=",
"$",
"row",
"[",
"TableMap",
"::",
"TYPE_NUM",
"==",
"$",
"indexType",
"?",
"1",
"+",
"$",
"startcol",
":",
"CustomerGroupTableMap",
"::",
"translateFieldName",
"(",
"'IsDefault'",
",",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"indexType",
")",
"]",
";",
"$",
"this",
"->",
"is_default",
"=",
"(",
"null",
"!==",
"$",
"col",
")",
"?",
"(",
"boolean",
")",
"$",
"col",
":",
"null",
";",
"$",
"col",
"=",
"$",
"row",
"[",
"TableMap",
"::",
"TYPE_NUM",
"==",
"$",
"indexType",
"?",
"2",
"+",
"$",
"startcol",
":",
"CustomerGroupTableMap",
"::",
"translateFieldName",
"(",
"'Id'",
",",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"indexType",
")",
"]",
";",
"$",
"this",
"->",
"id",
"=",
"(",
"null",
"!==",
"$",
"col",
")",
"?",
"(",
"int",
")",
"$",
"col",
":",
"null",
";",
"$",
"col",
"=",
"$",
"row",
"[",
"TableMap",
"::",
"TYPE_NUM",
"==",
"$",
"indexType",
"?",
"3",
"+",
"$",
"startcol",
":",
"CustomerGroupTableMap",
"::",
"translateFieldName",
"(",
"'CreatedAt'",
",",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"indexType",
")",
"]",
";",
"if",
"(",
"$",
"col",
"===",
"'0000-00-00 00:00:00'",
")",
"{",
"$",
"col",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"created_at",
"=",
"(",
"null",
"!==",
"$",
"col",
")",
"?",
"PropelDateTime",
"::",
"newInstance",
"(",
"$",
"col",
",",
"null",
",",
"'\\DateTime'",
")",
":",
"null",
";",
"$",
"col",
"=",
"$",
"row",
"[",
"TableMap",
"::",
"TYPE_NUM",
"==",
"$",
"indexType",
"?",
"4",
"+",
"$",
"startcol",
":",
"CustomerGroupTableMap",
"::",
"translateFieldName",
"(",
"'UpdatedAt'",
",",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"indexType",
")",
"]",
";",
"if",
"(",
"$",
"col",
"===",
"'0000-00-00 00:00:00'",
")",
"{",
"$",
"col",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"updated_at",
"=",
"(",
"null",
"!==",
"$",
"col",
")",
"?",
"PropelDateTime",
"::",
"newInstance",
"(",
"$",
"col",
",",
"null",
",",
"'\\DateTime'",
")",
":",
"null",
";",
"$",
"col",
"=",
"$",
"row",
"[",
"TableMap",
"::",
"TYPE_NUM",
"==",
"$",
"indexType",
"?",
"5",
"+",
"$",
"startcol",
":",
"CustomerGroupTableMap",
"::",
"translateFieldName",
"(",
"'Position'",
",",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"indexType",
")",
"]",
";",
"$",
"this",
"->",
"position",
"=",
"(",
"null",
"!==",
"$",
"col",
")",
"?",
"(",
"int",
")",
"$",
"col",
":",
"null",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"if",
"(",
"$",
"rehydrate",
")",
"{",
"$",
"this",
"->",
"ensureConsistency",
"(",
")",
";",
"}",
"return",
"$",
"startcol",
"+",
"6",
";",
"// 6 = CustomerGroupTableMap::NUM_HYDRATE_COLUMNS.",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Error populating \\CustomerGroup\\Model\\CustomerGroup object\"",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Hydrates (populates) the object variables with values from the database resultset.
An offset (0-based "start column") is specified so that objects can be hydrated
with a subset of the columns in the resultset rows. This is needed, for example,
for results of JOIN queries where the resultset row includes columns from two or
more tables.
@param array $row The row returned by DataFetcher->fetch().
@param int $startcol 0-based offset column which indicates which restultset column to start with.
@param boolean $rehydrate Whether this object is being re-hydrated from the database.
@param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
@return int next starting column
@throws PropelException - Any caught Exception will be rewrapped as a PropelException. | [
"Hydrates",
"(",
"populates",
")",
"the",
"object",
"variables",
"with",
"values",
"from",
"the",
"database",
"resultset",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L691-L732 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.reload | public function reload($deep = false, ConnectionInterface $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("Cannot reload a deleted object.");
}
if ($this->isNew()) {
throw new PropelException("Cannot reload an unsaved object.");
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(CustomerGroupTableMap::DATABASE_NAME);
}
// We don't need to alter the object instance pool; we're just modifying this instance
// already in the pool.
$dataFetcher = ChildCustomerGroupQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
$row = $dataFetcher->fetch();
$dataFetcher->close();
if (!$row) {
throw new PropelException('Cannot find matching row in the database to reload object values.');
}
$this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
if ($deep) { // also de-associate any related objects?
$this->collCustomerCustomerGroups = null;
$this->collCustomerGroupI18ns = null;
$this->collCustomers = null;
} // if (deep)
} | php | public function reload($deep = false, ConnectionInterface $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("Cannot reload a deleted object.");
}
if ($this->isNew()) {
throw new PropelException("Cannot reload an unsaved object.");
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(CustomerGroupTableMap::DATABASE_NAME);
}
// We don't need to alter the object instance pool; we're just modifying this instance
// already in the pool.
$dataFetcher = ChildCustomerGroupQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
$row = $dataFetcher->fetch();
$dataFetcher->close();
if (!$row) {
throw new PropelException('Cannot find matching row in the database to reload object values.');
}
$this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
if ($deep) { // also de-associate any related objects?
$this->collCustomerCustomerGroups = null;
$this->collCustomerGroupI18ns = null;
$this->collCustomers = null;
} // if (deep)
} | [
"public",
"function",
"reload",
"(",
"$",
"deep",
"=",
"false",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDeleted",
"(",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Cannot reload a deleted object.\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Cannot reload an unsaved object.\"",
")",
";",
"}",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getReadConnection",
"(",
"CustomerGroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"// We don't need to alter the object instance pool; we're just modifying this instance",
"// already in the pool.",
"$",
"dataFetcher",
"=",
"ChildCustomerGroupQuery",
"::",
"create",
"(",
"null",
",",
"$",
"this",
"->",
"buildPkeyCriteria",
"(",
")",
")",
"->",
"setFormatter",
"(",
"ModelCriteria",
"::",
"FORMAT_STATEMENT",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"$",
"row",
"=",
"$",
"dataFetcher",
"->",
"fetch",
"(",
")",
";",
"$",
"dataFetcher",
"->",
"close",
"(",
")",
";",
"if",
"(",
"!",
"$",
"row",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot find matching row in the database to reload object values.'",
")",
";",
"}",
"$",
"this",
"->",
"hydrate",
"(",
"$",
"row",
",",
"0",
",",
"true",
",",
"$",
"dataFetcher",
"->",
"getIndexType",
"(",
")",
")",
";",
"// rehydrate",
"if",
"(",
"$",
"deep",
")",
"{",
"// also de-associate any related objects?",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"=",
"null",
";",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"=",
"null",
";",
"$",
"this",
"->",
"collCustomers",
"=",
"null",
";",
"}",
"// if (deep)",
"}"
] | Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
This will only work if the object has been saved and has a valid primary key set.
@param boolean $deep (optional) Whether to also de-associated any related objects.
@param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
@return void
@throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db | [
"Reloads",
"this",
"object",
"from",
"datastore",
"based",
"on",
"primary",
"key",
"and",
"(",
"optionally",
")",
"resets",
"all",
"associated",
"objects",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L761-L794 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.delete | public function delete(ConnectionInterface $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$deleteQuery = ChildCustomerGroupQuery::create()
->filterByPrimaryKey($this->getPrimaryKey());
$ret = $this->preDelete($con);
// sortable behavior
ChildCustomerGroupQuery::sortableShiftRank(-1, $this->getPosition() + 1, null, $con);
CustomerGroupTableMap::clearInstancePool();
if ($ret) {
$deleteQuery->delete($con);
$this->postDelete($con);
$con->commit();
$this->setDeleted(true);
} else {
$con->commit();
}
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | php | public function delete(ConnectionInterface $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$deleteQuery = ChildCustomerGroupQuery::create()
->filterByPrimaryKey($this->getPrimaryKey());
$ret = $this->preDelete($con);
// sortable behavior
ChildCustomerGroupQuery::sortableShiftRank(-1, $this->getPosition() + 1, null, $con);
CustomerGroupTableMap::clearInstancePool();
if ($ret) {
$deleteQuery->delete($con);
$this->postDelete($con);
$con->commit();
$this->setDeleted(true);
} else {
$con->commit();
}
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | [
"public",
"function",
"delete",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDeleted",
"(",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"This object has already been deleted.\"",
")",
";",
"}",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getWriteConnection",
"(",
"CustomerGroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"$",
"deleteQuery",
"=",
"ChildCustomerGroupQuery",
"::",
"create",
"(",
")",
"->",
"filterByPrimaryKey",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"preDelete",
"(",
"$",
"con",
")",
";",
"// sortable behavior",
"ChildCustomerGroupQuery",
"::",
"sortableShiftRank",
"(",
"-",
"1",
",",
"$",
"this",
"->",
"getPosition",
"(",
")",
"+",
"1",
",",
"null",
",",
"$",
"con",
")",
";",
"CustomerGroupTableMap",
"::",
"clearInstancePool",
"(",
")",
";",
"if",
"(",
"$",
"ret",
")",
"{",
"$",
"deleteQuery",
"->",
"delete",
"(",
"$",
"con",
")",
";",
"$",
"this",
"->",
"postDelete",
"(",
"$",
"con",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"$",
"this",
"->",
"setDeleted",
"(",
"true",
")",
";",
"}",
"else",
"{",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollBack",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Removes this object from datastore and sets delete attribute.
@param ConnectionInterface $con
@return void
@throws PropelException
@see CustomerGroup::setDeleted()
@see CustomerGroup::isDeleted() | [
"Removes",
"this",
"object",
"from",
"datastore",
"and",
"sets",
"delete",
"attribute",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L805-L837 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.doSave | protected function doSave(ConnectionInterface $con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->customersScheduledForDeletion !== null) {
if (!$this->customersScheduledForDeletion->isEmpty()) {
$pks = array();
$pk = $this->getPrimaryKey();
foreach ($this->customersScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
$pks[] = array($remotePk, $pk);
}
CustomerCustomerGroupQuery::create()
->filterByPrimaryKeys($pks)
->delete($con);
$this->customersScheduledForDeletion = null;
}
foreach ($this->getCustomers() as $customer) {
if ($customer->isModified()) {
$customer->save($con);
}
}
} elseif ($this->collCustomers) {
foreach ($this->collCustomers as $customer) {
if ($customer->isModified()) {
$customer->save($con);
}
}
}
if ($this->customerCustomerGroupsScheduledForDeletion !== null) {
if (!$this->customerCustomerGroupsScheduledForDeletion->isEmpty()) {
\CustomerGroup\Model\CustomerCustomerGroupQuery::create()
->filterByPrimaryKeys($this->customerCustomerGroupsScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->customerCustomerGroupsScheduledForDeletion = null;
}
}
if ($this->collCustomerCustomerGroups !== null) {
foreach ($this->collCustomerCustomerGroups as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->customerGroupI18nsScheduledForDeletion !== null) {
if (!$this->customerGroupI18nsScheduledForDeletion->isEmpty()) {
\CustomerGroup\Model\CustomerGroupI18nQuery::create()
->filterByPrimaryKeys($this->customerGroupI18nsScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->customerGroupI18nsScheduledForDeletion = null;
}
}
if ($this->collCustomerGroupI18ns !== null) {
foreach ($this->collCustomerGroupI18ns as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
} | php | protected function doSave(ConnectionInterface $con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->customersScheduledForDeletion !== null) {
if (!$this->customersScheduledForDeletion->isEmpty()) {
$pks = array();
$pk = $this->getPrimaryKey();
foreach ($this->customersScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
$pks[] = array($remotePk, $pk);
}
CustomerCustomerGroupQuery::create()
->filterByPrimaryKeys($pks)
->delete($con);
$this->customersScheduledForDeletion = null;
}
foreach ($this->getCustomers() as $customer) {
if ($customer->isModified()) {
$customer->save($con);
}
}
} elseif ($this->collCustomers) {
foreach ($this->collCustomers as $customer) {
if ($customer->isModified()) {
$customer->save($con);
}
}
}
if ($this->customerCustomerGroupsScheduledForDeletion !== null) {
if (!$this->customerCustomerGroupsScheduledForDeletion->isEmpty()) {
\CustomerGroup\Model\CustomerCustomerGroupQuery::create()
->filterByPrimaryKeys($this->customerCustomerGroupsScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->customerCustomerGroupsScheduledForDeletion = null;
}
}
if ($this->collCustomerCustomerGroups !== null) {
foreach ($this->collCustomerCustomerGroups as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->customerGroupI18nsScheduledForDeletion !== null) {
if (!$this->customerGroupI18nsScheduledForDeletion->isEmpty()) {
\CustomerGroup\Model\CustomerGroupI18nQuery::create()
->filterByPrimaryKeys($this->customerGroupI18nsScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->customerGroupI18nsScheduledForDeletion = null;
}
}
if ($this->collCustomerGroupI18ns !== null) {
foreach ($this->collCustomerGroupI18ns as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
} | [
"protected",
"function",
"doSave",
"(",
"ConnectionInterface",
"$",
"con",
")",
"{",
"$",
"affectedRows",
"=",
"0",
";",
"// initialize var to track total num of affected rows",
"if",
"(",
"!",
"$",
"this",
"->",
"alreadyInSave",
")",
"{",
"$",
"this",
"->",
"alreadyInSave",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"||",
"$",
"this",
"->",
"isModified",
"(",
")",
")",
"{",
"// persist changes",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"this",
"->",
"doInsert",
"(",
"$",
"con",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"doUpdate",
"(",
"$",
"con",
")",
";",
"}",
"$",
"affectedRows",
"+=",
"1",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"customersScheduledForDeletion",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"customersScheduledForDeletion",
"->",
"isEmpty",
"(",
")",
")",
"{",
"$",
"pks",
"=",
"array",
"(",
")",
";",
"$",
"pk",
"=",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"customersScheduledForDeletion",
"->",
"getPrimaryKeys",
"(",
"false",
")",
"as",
"$",
"remotePk",
")",
"{",
"$",
"pks",
"[",
"]",
"=",
"array",
"(",
"$",
"remotePk",
",",
"$",
"pk",
")",
";",
"}",
"CustomerCustomerGroupQuery",
"::",
"create",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"pks",
")",
"->",
"delete",
"(",
"$",
"con",
")",
";",
"$",
"this",
"->",
"customersScheduledForDeletion",
"=",
"null",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getCustomers",
"(",
")",
"as",
"$",
"customer",
")",
"{",
"if",
"(",
"$",
"customer",
"->",
"isModified",
"(",
")",
")",
"{",
"$",
"customer",
"->",
"save",
"(",
"$",
"con",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"collCustomers",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomers",
"as",
"$",
"customer",
")",
"{",
"if",
"(",
"$",
"customer",
"->",
"isModified",
"(",
")",
")",
"{",
"$",
"customer",
"->",
"save",
"(",
"$",
"con",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"customerCustomerGroupsScheduledForDeletion",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"customerCustomerGroupsScheduledForDeletion",
"->",
"isEmpty",
"(",
")",
")",
"{",
"\\",
"CustomerGroup",
"\\",
"Model",
"\\",
"CustomerCustomerGroupQuery",
"::",
"create",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"this",
"->",
"customerCustomerGroupsScheduledForDeletion",
"->",
"getPrimaryKeys",
"(",
"false",
")",
")",
"->",
"delete",
"(",
"$",
"con",
")",
";",
"$",
"this",
"->",
"customerCustomerGroupsScheduledForDeletion",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"as",
"$",
"referrerFK",
")",
"{",
"if",
"(",
"!",
"$",
"referrerFK",
"->",
"isDeleted",
"(",
")",
"&&",
"(",
"$",
"referrerFK",
"->",
"isNew",
"(",
")",
"||",
"$",
"referrerFK",
"->",
"isModified",
"(",
")",
")",
")",
"{",
"$",
"affectedRows",
"+=",
"$",
"referrerFK",
"->",
"save",
"(",
"$",
"con",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"customerGroupI18nsScheduledForDeletion",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"customerGroupI18nsScheduledForDeletion",
"->",
"isEmpty",
"(",
")",
")",
"{",
"\\",
"CustomerGroup",
"\\",
"Model",
"\\",
"CustomerGroupI18nQuery",
"::",
"create",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"this",
"->",
"customerGroupI18nsScheduledForDeletion",
"->",
"getPrimaryKeys",
"(",
"false",
")",
")",
"->",
"delete",
"(",
"$",
"con",
")",
";",
"$",
"this",
"->",
"customerGroupI18nsScheduledForDeletion",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"as",
"$",
"referrerFK",
")",
"{",
"if",
"(",
"!",
"$",
"referrerFK",
"->",
"isDeleted",
"(",
")",
"&&",
"(",
"$",
"referrerFK",
"->",
"isNew",
"(",
")",
"||",
"$",
"referrerFK",
"->",
"isModified",
"(",
")",
")",
")",
"{",
"$",
"affectedRows",
"+=",
"$",
"referrerFK",
"->",
"save",
"(",
"$",
"con",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"alreadyInSave",
"=",
"false",
";",
"}",
"return",
"$",
"affectedRows",
";",
"}"
] | Performs the work of inserting or updating the row in the database.
If the object is new, it inserts it; otherwise an update is performed.
All related objects are also updated in this method.
@param ConnectionInterface $con
@return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
@throws PropelException
@see save() | [
"Performs",
"the",
"work",
"of",
"inserting",
"or",
"updating",
"the",
"row",
"in",
"the",
"database",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L921-L1004 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.toArray | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['CustomerGroup'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['CustomerGroup'][$this->getPrimaryKey()] = true;
$keys = CustomerGroupTableMap::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getCode(),
$keys[1] => $this->getIsDefault(),
$keys[2] => $this->getId(),
$keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getUpdatedAt(),
$keys[5] => $this->getPosition(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->collCustomerCustomerGroups) {
$result['CustomerCustomerGroups'] = $this->collCustomerCustomerGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collCustomerGroupI18ns) {
$result['CustomerGroupI18ns'] = $this->collCustomerGroupI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
} | php | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['CustomerGroup'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['CustomerGroup'][$this->getPrimaryKey()] = true;
$keys = CustomerGroupTableMap::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getCode(),
$keys[1] => $this->getIsDefault(),
$keys[2] => $this->getId(),
$keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getUpdatedAt(),
$keys[5] => $this->getPosition(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->collCustomerCustomerGroups) {
$result['CustomerCustomerGroups'] = $this->collCustomerCustomerGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collCustomerGroupI18ns) {
$result['CustomerGroupI18ns'] = $this->collCustomerGroupI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
} | [
"public",
"function",
"toArray",
"(",
"$",
"keyType",
"=",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"includeLazyLoadColumns",
"=",
"true",
",",
"$",
"alreadyDumpedObjects",
"=",
"array",
"(",
")",
",",
"$",
"includeForeignObjects",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"alreadyDumpedObjects",
"[",
"'CustomerGroup'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
")",
")",
"{",
"return",
"'*RECURSION*'",
";",
"}",
"$",
"alreadyDumpedObjects",
"[",
"'CustomerGroup'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
"=",
"true",
";",
"$",
"keys",
"=",
"CustomerGroupTableMap",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"$",
"result",
"=",
"array",
"(",
"$",
"keys",
"[",
"0",
"]",
"=>",
"$",
"this",
"->",
"getCode",
"(",
")",
",",
"$",
"keys",
"[",
"1",
"]",
"=>",
"$",
"this",
"->",
"getIsDefault",
"(",
")",
",",
"$",
"keys",
"[",
"2",
"]",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"keys",
"[",
"3",
"]",
"=>",
"$",
"this",
"->",
"getCreatedAt",
"(",
")",
",",
"$",
"keys",
"[",
"4",
"]",
"=>",
"$",
"this",
"->",
"getUpdatedAt",
"(",
")",
",",
"$",
"keys",
"[",
"5",
"]",
"=>",
"$",
"this",
"->",
"getPosition",
"(",
")",
",",
")",
";",
"$",
"virtualColumns",
"=",
"$",
"this",
"->",
"virtualColumns",
";",
"foreach",
"(",
"$",
"virtualColumns",
"as",
"$",
"key",
"=>",
"$",
"virtualColumn",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"virtualColumn",
";",
"}",
"if",
"(",
"$",
"includeForeignObjects",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collCustomerCustomerGroups",
")",
"{",
"$",
"result",
"[",
"'CustomerCustomerGroups'",
"]",
"=",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"->",
"toArray",
"(",
"null",
",",
"true",
",",
"$",
"keyType",
",",
"$",
"includeLazyLoadColumns",
",",
"$",
"alreadyDumpedObjects",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collCustomerGroupI18ns",
")",
"{",
"$",
"result",
"[",
"'CustomerGroupI18ns'",
"]",
"=",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"->",
"toArray",
"(",
"null",
",",
"true",
",",
"$",
"keyType",
",",
"$",
"includeLazyLoadColumns",
",",
"$",
"alreadyDumpedObjects",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Exports the object as an array.
You can specify the key type of the array by passing one of the class
type constants.
@param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
Defaults to TableMap::TYPE_PHPNAME.
@param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
@param array $alreadyDumpedObjects List of objects to skip to avoid recursion
@param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
@return array an associative array containing the field names (as keys) and field values | [
"Exports",
"the",
"object",
"as",
"an",
"array",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1173-L1203 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.fromArray | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
{
$keys = CustomerGroupTableMap::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setCode($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setIsDefault($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setPosition($arr[$keys[5]]);
} | php | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
{
$keys = CustomerGroupTableMap::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setCode($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setIsDefault($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setPosition($arr[$keys[5]]);
} | [
"public",
"function",
"fromArray",
"(",
"$",
"arr",
",",
"$",
"keyType",
"=",
"TableMap",
"::",
"TYPE_PHPNAME",
")",
"{",
"$",
"keys",
"=",
"CustomerGroupTableMap",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"0",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setCode",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"1",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setIsDefault",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"1",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"2",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"2",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"3",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setCreatedAt",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"3",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"4",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setUpdatedAt",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"4",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"5",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setPosition",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"5",
"]",
"]",
")",
";",
"}"
] | Populates the object using an array.
This is particularly useful when populating an object from one of the
request arrays (e.g. $_POST). This method goes through the column
names, checking to see whether a matching key exists in populated
array. If so the setByName() method is called for that column.
You can specify the key type of the array by additionally passing one
of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
The default key type is the column's TableMap::TYPE_PHPNAME.
@param array $arr An array to populate the object from.
@param string $keyType The type of keys the array uses.
@return void | [
"Populates",
"the",
"object",
"using",
"an",
"array",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1272-L1282 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.buildCriteria | public function buildCriteria()
{
$criteria = new Criteria(CustomerGroupTableMap::DATABASE_NAME);
if ($this->isColumnModified(CustomerGroupTableMap::CODE)) $criteria->add(CustomerGroupTableMap::CODE, $this->code);
if ($this->isColumnModified(CustomerGroupTableMap::IS_DEFAULT)) $criteria->add(CustomerGroupTableMap::IS_DEFAULT, $this->is_default);
if ($this->isColumnModified(CustomerGroupTableMap::ID)) $criteria->add(CustomerGroupTableMap::ID, $this->id);
if ($this->isColumnModified(CustomerGroupTableMap::CREATED_AT)) $criteria->add(CustomerGroupTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(CustomerGroupTableMap::UPDATED_AT)) $criteria->add(CustomerGroupTableMap::UPDATED_AT, $this->updated_at);
if ($this->isColumnModified(CustomerGroupTableMap::POSITION)) $criteria->add(CustomerGroupTableMap::POSITION, $this->position);
return $criteria;
} | php | public function buildCriteria()
{
$criteria = new Criteria(CustomerGroupTableMap::DATABASE_NAME);
if ($this->isColumnModified(CustomerGroupTableMap::CODE)) $criteria->add(CustomerGroupTableMap::CODE, $this->code);
if ($this->isColumnModified(CustomerGroupTableMap::IS_DEFAULT)) $criteria->add(CustomerGroupTableMap::IS_DEFAULT, $this->is_default);
if ($this->isColumnModified(CustomerGroupTableMap::ID)) $criteria->add(CustomerGroupTableMap::ID, $this->id);
if ($this->isColumnModified(CustomerGroupTableMap::CREATED_AT)) $criteria->add(CustomerGroupTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(CustomerGroupTableMap::UPDATED_AT)) $criteria->add(CustomerGroupTableMap::UPDATED_AT, $this->updated_at);
if ($this->isColumnModified(CustomerGroupTableMap::POSITION)) $criteria->add(CustomerGroupTableMap::POSITION, $this->position);
return $criteria;
} | [
"public",
"function",
"buildCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"CustomerGroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CustomerGroupTableMap",
"::",
"CODE",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CustomerGroupTableMap",
"::",
"CODE",
",",
"$",
"this",
"->",
"code",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CustomerGroupTableMap",
"::",
"IS_DEFAULT",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CustomerGroupTableMap",
"::",
"IS_DEFAULT",
",",
"$",
"this",
"->",
"is_default",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CustomerGroupTableMap",
"::",
"ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CustomerGroupTableMap",
"::",
"ID",
",",
"$",
"this",
"->",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CustomerGroupTableMap",
"::",
"CREATED_AT",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CustomerGroupTableMap",
"::",
"CREATED_AT",
",",
"$",
"this",
"->",
"created_at",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CustomerGroupTableMap",
"::",
"UPDATED_AT",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CustomerGroupTableMap",
"::",
"UPDATED_AT",
",",
"$",
"this",
"->",
"updated_at",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CustomerGroupTableMap",
"::",
"POSITION",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CustomerGroupTableMap",
"::",
"POSITION",
",",
"$",
"this",
"->",
"position",
")",
";",
"return",
"$",
"criteria",
";",
"}"
] | Build a Criteria object containing the values of all modified columns in this object.
@return Criteria The Criteria object containing all modified values. | [
"Build",
"a",
"Criteria",
"object",
"containing",
"the",
"values",
"of",
"all",
"modified",
"columns",
"in",
"this",
"object",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1289-L1301 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.copyInto | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setCode($this->getCode());
$copyObj->setIsDefault($this->getIsDefault());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
$copyObj->setPosition($this->getPosition());
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
foreach ($this->getCustomerCustomerGroups() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCustomerCustomerGroup($relObj->copy($deepCopy));
}
}
foreach ($this->getCustomerGroupI18ns() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCustomerGroupI18n($relObj->copy($deepCopy));
}
}
} // if ($deepCopy)
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
} | php | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setCode($this->getCode());
$copyObj->setIsDefault($this->getIsDefault());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
$copyObj->setPosition($this->getPosition());
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
foreach ($this->getCustomerCustomerGroups() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCustomerCustomerGroup($relObj->copy($deepCopy));
}
}
foreach ($this->getCustomerGroupI18ns() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCustomerGroupI18n($relObj->copy($deepCopy));
}
}
} // if ($deepCopy)
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
} | [
"public",
"function",
"copyInto",
"(",
"$",
"copyObj",
",",
"$",
"deepCopy",
"=",
"false",
",",
"$",
"makeNew",
"=",
"true",
")",
"{",
"$",
"copyObj",
"->",
"setCode",
"(",
"$",
"this",
"->",
"getCode",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setIsDefault",
"(",
"$",
"this",
"->",
"getIsDefault",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setCreatedAt",
"(",
"$",
"this",
"->",
"getCreatedAt",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setUpdatedAt",
"(",
"$",
"this",
"->",
"getUpdatedAt",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setPosition",
"(",
"$",
"this",
"->",
"getPosition",
"(",
")",
")",
";",
"if",
"(",
"$",
"deepCopy",
")",
"{",
"// important: temporarily setNew(false) because this affects the behavior of",
"// the getter/setter methods for fkey referrer objects.",
"$",
"copyObj",
"->",
"setNew",
"(",
"false",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getCustomerCustomerGroups",
"(",
")",
"as",
"$",
"relObj",
")",
"{",
"if",
"(",
"$",
"relObj",
"!==",
"$",
"this",
")",
"{",
"// ensure that we don't try to copy a reference to ourselves",
"$",
"copyObj",
"->",
"addCustomerCustomerGroup",
"(",
"$",
"relObj",
"->",
"copy",
"(",
"$",
"deepCopy",
")",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getCustomerGroupI18ns",
"(",
")",
"as",
"$",
"relObj",
")",
"{",
"if",
"(",
"$",
"relObj",
"!==",
"$",
"this",
")",
"{",
"// ensure that we don't try to copy a reference to ourselves",
"$",
"copyObj",
"->",
"addCustomerGroupI18n",
"(",
"$",
"relObj",
"->",
"copy",
"(",
"$",
"deepCopy",
")",
")",
";",
"}",
"}",
"}",
"// if ($deepCopy)",
"if",
"(",
"$",
"makeNew",
")",
"{",
"$",
"copyObj",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"copyObj",
"->",
"setId",
"(",
"NULL",
")",
";",
"// this is a auto-increment column, so set to default value",
"}",
"}"
] | Sets contents of passed object to values from current object.
If desired, this method can also make copies of all associated (fkey referrers)
objects.
@param object $copyObj An object of \CustomerGroup\Model\CustomerGroup (or compatible) type.
@param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
@param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
@throws PropelException | [
"Sets",
"contents",
"of",
"passed",
"object",
"to",
"values",
"from",
"current",
"object",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1360-L1391 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.initCustomerCustomerGroups | public function initCustomerCustomerGroups($overrideExisting = true)
{
if (null !== $this->collCustomerCustomerGroups && !$overrideExisting) {
return;
}
$this->collCustomerCustomerGroups = new ObjectCollection();
$this->collCustomerCustomerGroups->setModel('\CustomerGroup\Model\CustomerCustomerGroup');
} | php | public function initCustomerCustomerGroups($overrideExisting = true)
{
if (null !== $this->collCustomerCustomerGroups && !$overrideExisting) {
return;
}
$this->collCustomerCustomerGroups = new ObjectCollection();
$this->collCustomerCustomerGroups->setModel('\CustomerGroup\Model\CustomerCustomerGroup');
} | [
"public",
"function",
"initCustomerCustomerGroups",
"(",
"$",
"overrideExisting",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"&&",
"!",
"$",
"overrideExisting",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"=",
"new",
"ObjectCollection",
"(",
")",
";",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"->",
"setModel",
"(",
"'\\CustomerGroup\\Model\\CustomerCustomerGroup'",
")",
";",
"}"
] | Initializes the collCustomerCustomerGroups collection.
By default this just sets the collCustomerCustomerGroups collection to an empty array (like clearcollCustomerCustomerGroups());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@param boolean $overrideExisting If set to true, the method call initializes
the collection even if it is not empty
@return void | [
"Initializes",
"the",
"collCustomerCustomerGroups",
"collection",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1468-L1475 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.getCustomerCustomerGroups | public function getCustomerCustomerGroups($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collCustomerCustomerGroupsPartial && !$this->isNew();
if (null === $this->collCustomerCustomerGroups || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomerCustomerGroups) {
// return empty collection
$this->initCustomerCustomerGroups();
} else {
$collCustomerCustomerGroups = ChildCustomerCustomerGroupQuery::create(null, $criteria)
->filterByCustomerGroup($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collCustomerCustomerGroupsPartial && count($collCustomerCustomerGroups)) {
$this->initCustomerCustomerGroups(false);
foreach ($collCustomerCustomerGroups as $obj) {
if (false == $this->collCustomerCustomerGroups->contains($obj)) {
$this->collCustomerCustomerGroups->append($obj);
}
}
$this->collCustomerCustomerGroupsPartial = true;
}
reset($collCustomerCustomerGroups);
return $collCustomerCustomerGroups;
}
if ($partial && $this->collCustomerCustomerGroups) {
foreach ($this->collCustomerCustomerGroups as $obj) {
if ($obj->isNew()) {
$collCustomerCustomerGroups[] = $obj;
}
}
}
$this->collCustomerCustomerGroups = $collCustomerCustomerGroups;
$this->collCustomerCustomerGroupsPartial = false;
}
}
return $this->collCustomerCustomerGroups;
} | php | public function getCustomerCustomerGroups($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collCustomerCustomerGroupsPartial && !$this->isNew();
if (null === $this->collCustomerCustomerGroups || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomerCustomerGroups) {
// return empty collection
$this->initCustomerCustomerGroups();
} else {
$collCustomerCustomerGroups = ChildCustomerCustomerGroupQuery::create(null, $criteria)
->filterByCustomerGroup($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collCustomerCustomerGroupsPartial && count($collCustomerCustomerGroups)) {
$this->initCustomerCustomerGroups(false);
foreach ($collCustomerCustomerGroups as $obj) {
if (false == $this->collCustomerCustomerGroups->contains($obj)) {
$this->collCustomerCustomerGroups->append($obj);
}
}
$this->collCustomerCustomerGroupsPartial = true;
}
reset($collCustomerCustomerGroups);
return $collCustomerCustomerGroups;
}
if ($partial && $this->collCustomerCustomerGroups) {
foreach ($this->collCustomerCustomerGroups as $obj) {
if ($obj->isNew()) {
$collCustomerCustomerGroups[] = $obj;
}
}
}
$this->collCustomerCustomerGroups = $collCustomerCustomerGroups;
$this->collCustomerCustomerGroupsPartial = false;
}
}
return $this->collCustomerCustomerGroups;
} | [
"public",
"function",
"getCustomerCustomerGroups",
"(",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collCustomerCustomerGroupsPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collCustomerCustomerGroups",
")",
"{",
"// return empty collection",
"$",
"this",
"->",
"initCustomerCustomerGroups",
"(",
")",
";",
"}",
"else",
"{",
"$",
"collCustomerCustomerGroups",
"=",
"ChildCustomerCustomerGroupQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"filterByCustomerGroup",
"(",
"$",
"this",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"criteria",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"this",
"->",
"collCustomerCustomerGroupsPartial",
"&&",
"count",
"(",
"$",
"collCustomerCustomerGroups",
")",
")",
"{",
"$",
"this",
"->",
"initCustomerCustomerGroups",
"(",
"false",
")",
";",
"foreach",
"(",
"$",
"collCustomerCustomerGroups",
"as",
"$",
"obj",
")",
"{",
"if",
"(",
"false",
"==",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"->",
"contains",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"->",
"append",
"(",
"$",
"obj",
")",
";",
"}",
"}",
"$",
"this",
"->",
"collCustomerCustomerGroupsPartial",
"=",
"true",
";",
"}",
"reset",
"(",
"$",
"collCustomerCustomerGroups",
")",
";",
"return",
"$",
"collCustomerCustomerGroups",
";",
"}",
"if",
"(",
"$",
"partial",
"&&",
"$",
"this",
"->",
"collCustomerCustomerGroups",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"as",
"$",
"obj",
")",
"{",
"if",
"(",
"$",
"obj",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"collCustomerCustomerGroups",
"[",
"]",
"=",
"$",
"obj",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"=",
"$",
"collCustomerCustomerGroups",
";",
"$",
"this",
"->",
"collCustomerCustomerGroupsPartial",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"collCustomerCustomerGroups",
";",
"}"
] | Gets an array of ChildCustomerCustomerGroup objects which contain a foreign key that references this object.
If the $criteria is not null, it is used to always fetch the results from the database.
Otherwise the results are fetched from the database the first time, then cached.
Next time the same method is called without $criteria, the cached collection is returned.
If this ChildCustomerGroup is new, it will return
an empty collection or the current collection; the criteria is ignored on a new object.
@param Criteria $criteria optional Criteria object to narrow the query
@param ConnectionInterface $con optional connection object
@return Collection|ChildCustomerCustomerGroup[] List of ChildCustomerCustomerGroup objects
@throws PropelException | [
"Gets",
"an",
"array",
"of",
"ChildCustomerCustomerGroup",
"objects",
"which",
"contain",
"a",
"foreign",
"key",
"that",
"references",
"this",
"object",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1491-L1535 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.setCustomerCustomerGroups | public function setCustomerCustomerGroups(Collection $customerCustomerGroups, ConnectionInterface $con = null)
{
$customerCustomerGroupsToDelete = $this->getCustomerCustomerGroups(new Criteria(), $con)->diff($customerCustomerGroups);
//since at least one column in the foreign key is at the same time a PK
//we can not just set a PK to NULL in the lines below. We have to store
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
$this->customerCustomerGroupsScheduledForDeletion = clone $customerCustomerGroupsToDelete;
foreach ($customerCustomerGroupsToDelete as $customerCustomerGroupRemoved) {
$customerCustomerGroupRemoved->setCustomerGroup(null);
}
$this->collCustomerCustomerGroups = null;
foreach ($customerCustomerGroups as $customerCustomerGroup) {
$this->addCustomerCustomerGroup($customerCustomerGroup);
}
$this->collCustomerCustomerGroups = $customerCustomerGroups;
$this->collCustomerCustomerGroupsPartial = false;
return $this;
} | php | public function setCustomerCustomerGroups(Collection $customerCustomerGroups, ConnectionInterface $con = null)
{
$customerCustomerGroupsToDelete = $this->getCustomerCustomerGroups(new Criteria(), $con)->diff($customerCustomerGroups);
//since at least one column in the foreign key is at the same time a PK
//we can not just set a PK to NULL in the lines below. We have to store
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
$this->customerCustomerGroupsScheduledForDeletion = clone $customerCustomerGroupsToDelete;
foreach ($customerCustomerGroupsToDelete as $customerCustomerGroupRemoved) {
$customerCustomerGroupRemoved->setCustomerGroup(null);
}
$this->collCustomerCustomerGroups = null;
foreach ($customerCustomerGroups as $customerCustomerGroup) {
$this->addCustomerCustomerGroup($customerCustomerGroup);
}
$this->collCustomerCustomerGroups = $customerCustomerGroups;
$this->collCustomerCustomerGroupsPartial = false;
return $this;
} | [
"public",
"function",
"setCustomerCustomerGroups",
"(",
"Collection",
"$",
"customerCustomerGroups",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"customerCustomerGroupsToDelete",
"=",
"$",
"this",
"->",
"getCustomerCustomerGroups",
"(",
"new",
"Criteria",
"(",
")",
",",
"$",
"con",
")",
"->",
"diff",
"(",
"$",
"customerCustomerGroups",
")",
";",
"//since at least one column in the foreign key is at the same time a PK",
"//we can not just set a PK to NULL in the lines below. We have to store",
"//a backup of all values, so we are able to manipulate these items based on the onDelete value later.",
"$",
"this",
"->",
"customerCustomerGroupsScheduledForDeletion",
"=",
"clone",
"$",
"customerCustomerGroupsToDelete",
";",
"foreach",
"(",
"$",
"customerCustomerGroupsToDelete",
"as",
"$",
"customerCustomerGroupRemoved",
")",
"{",
"$",
"customerCustomerGroupRemoved",
"->",
"setCustomerGroup",
"(",
"null",
")",
";",
"}",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"=",
"null",
";",
"foreach",
"(",
"$",
"customerCustomerGroups",
"as",
"$",
"customerCustomerGroup",
")",
"{",
"$",
"this",
"->",
"addCustomerCustomerGroup",
"(",
"$",
"customerCustomerGroup",
")",
";",
"}",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"=",
"$",
"customerCustomerGroups",
";",
"$",
"this",
"->",
"collCustomerCustomerGroupsPartial",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] | Sets a collection of CustomerCustomerGroup objects related by a one-to-many relationship
to the current object.
It will also schedule objects for deletion based on a diff between old objects (aka persisted)
and new objects from the given Propel collection.
@param Collection $customerCustomerGroups A Propel collection.
@param ConnectionInterface $con Optional connection object
@return ChildCustomerGroup The current object (for fluent API support) | [
"Sets",
"a",
"collection",
"of",
"CustomerCustomerGroup",
"objects",
"related",
"by",
"a",
"one",
"-",
"to",
"-",
"many",
"relationship",
"to",
"the",
"current",
"object",
".",
"It",
"will",
"also",
"schedule",
"objects",
"for",
"deletion",
"based",
"on",
"a",
"diff",
"between",
"old",
"objects",
"(",
"aka",
"persisted",
")",
"and",
"new",
"objects",
"from",
"the",
"given",
"Propel",
"collection",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1547-L1570 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.countCustomerCustomerGroups | public function countCustomerCustomerGroups(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collCustomerCustomerGroupsPartial && !$this->isNew();
if (null === $this->collCustomerCustomerGroups || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomerCustomerGroups) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getCustomerCustomerGroups());
}
$query = ChildCustomerCustomerGroupQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByCustomerGroup($this)
->count($con);
}
return count($this->collCustomerCustomerGroups);
} | php | public function countCustomerCustomerGroups(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collCustomerCustomerGroupsPartial && !$this->isNew();
if (null === $this->collCustomerCustomerGroups || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomerCustomerGroups) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getCustomerCustomerGroups());
}
$query = ChildCustomerCustomerGroupQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByCustomerGroup($this)
->count($con);
}
return count($this->collCustomerCustomerGroups);
} | [
"public",
"function",
"countCustomerCustomerGroups",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collCustomerCustomerGroupsPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collCustomerCustomerGroups",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"$",
"partial",
"&&",
"!",
"$",
"criteria",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"getCustomerCustomerGroups",
"(",
")",
")",
";",
"}",
"$",
"query",
"=",
"ChildCustomerCustomerGroupQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"distinct",
")",
"{",
"$",
"query",
"->",
"distinct",
"(",
")",
";",
"}",
"return",
"$",
"query",
"->",
"filterByCustomerGroup",
"(",
"$",
"this",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"collCustomerCustomerGroups",
")",
";",
"}"
] | Returns the number of related CustomerCustomerGroup objects.
@param Criteria $criteria
@param boolean $distinct
@param ConnectionInterface $con
@return int Count of related CustomerCustomerGroup objects.
@throws PropelException | [
"Returns",
"the",
"number",
"of",
"related",
"CustomerCustomerGroup",
"objects",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1581-L1604 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.addCustomerCustomerGroup | public function addCustomerCustomerGroup(ChildCustomerCustomerGroup $l)
{
if ($this->collCustomerCustomerGroups === null) {
$this->initCustomerCustomerGroups();
$this->collCustomerCustomerGroupsPartial = true;
}
if (!in_array($l, $this->collCustomerCustomerGroups->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddCustomerCustomerGroup($l);
}
return $this;
} | php | public function addCustomerCustomerGroup(ChildCustomerCustomerGroup $l)
{
if ($this->collCustomerCustomerGroups === null) {
$this->initCustomerCustomerGroups();
$this->collCustomerCustomerGroupsPartial = true;
}
if (!in_array($l, $this->collCustomerCustomerGroups->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddCustomerCustomerGroup($l);
}
return $this;
} | [
"public",
"function",
"addCustomerCustomerGroup",
"(",
"ChildCustomerCustomerGroup",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initCustomerCustomerGroups",
"(",
")",
";",
"$",
"this",
"->",
"collCustomerCustomerGroupsPartial",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"l",
",",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"->",
"getArrayCopy",
"(",
")",
",",
"true",
")",
")",
"{",
"// only add it if the **same** object is not already associated",
"$",
"this",
"->",
"doAddCustomerCustomerGroup",
"(",
"$",
"l",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Method called to associate a ChildCustomerCustomerGroup object to this object
through the ChildCustomerCustomerGroup foreign key attribute.
@param ChildCustomerCustomerGroup $l ChildCustomerCustomerGroup
@return \CustomerGroup\Model\CustomerGroup The current object (for fluent API support) | [
"Method",
"called",
"to",
"associate",
"a",
"ChildCustomerCustomerGroup",
"object",
"to",
"this",
"object",
"through",
"the",
"ChildCustomerCustomerGroup",
"foreign",
"key",
"attribute",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1613-L1625 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.getCustomerCustomerGroupsJoinCustomer | public function getCustomerCustomerGroupsJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildCustomerCustomerGroupQuery::create(null, $criteria);
$query->joinWith('Customer', $joinBehavior);
return $this->getCustomerCustomerGroups($query, $con);
} | php | public function getCustomerCustomerGroupsJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildCustomerCustomerGroupQuery::create(null, $criteria);
$query->joinWith('Customer', $joinBehavior);
return $this->getCustomerCustomerGroups($query, $con);
} | [
"public",
"function",
"getCustomerCustomerGroupsJoinCustomer",
"(",
"$",
"criteria",
"=",
"null",
",",
"$",
"con",
"=",
"null",
",",
"$",
"joinBehavior",
"=",
"Criteria",
"::",
"LEFT_JOIN",
")",
"{",
"$",
"query",
"=",
"ChildCustomerCustomerGroupQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"$",
"query",
"->",
"joinWith",
"(",
"'Customer'",
",",
"$",
"joinBehavior",
")",
";",
"return",
"$",
"this",
"->",
"getCustomerCustomerGroups",
"(",
"$",
"query",
",",
"$",
"con",
")",
";",
"}"
] | If this collection has already been initialized with
an identical criteria, it returns the collection.
Otherwise if this CustomerGroup is new, it will return
an empty collection; or if this CustomerGroup has previously
been saved, it will retrieve related CustomerCustomerGroups from storage.
This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in CustomerGroup.
@param Criteria $criteria optional Criteria object to narrow the query
@param ConnectionInterface $con optional connection object
@param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
@return Collection|ChildCustomerCustomerGroup[] List of ChildCustomerCustomerGroup objects | [
"If",
"this",
"collection",
"has",
"already",
"been",
"initialized",
"with",
"an",
"identical",
"criteria",
"it",
"returns",
"the",
"collection",
".",
"Otherwise",
"if",
"this",
"CustomerGroup",
"is",
"new",
"it",
"will",
"return",
"an",
"empty",
"collection",
";",
"or",
"if",
"this",
"CustomerGroup",
"has",
"previously",
"been",
"saved",
"it",
"will",
"retrieve",
"related",
"CustomerCustomerGroups",
"from",
"storage",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1672-L1678 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.initCustomerGroupI18ns | public function initCustomerGroupI18ns($overrideExisting = true)
{
if (null !== $this->collCustomerGroupI18ns && !$overrideExisting) {
return;
}
$this->collCustomerGroupI18ns = new ObjectCollection();
$this->collCustomerGroupI18ns->setModel('\CustomerGroup\Model\CustomerGroupI18n');
} | php | public function initCustomerGroupI18ns($overrideExisting = true)
{
if (null !== $this->collCustomerGroupI18ns && !$overrideExisting) {
return;
}
$this->collCustomerGroupI18ns = new ObjectCollection();
$this->collCustomerGroupI18ns->setModel('\CustomerGroup\Model\CustomerGroupI18n');
} | [
"public",
"function",
"initCustomerGroupI18ns",
"(",
"$",
"overrideExisting",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"&&",
"!",
"$",
"overrideExisting",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"=",
"new",
"ObjectCollection",
"(",
")",
";",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"->",
"setModel",
"(",
"'\\CustomerGroup\\Model\\CustomerGroupI18n'",
")",
";",
"}"
] | Initializes the collCustomerGroupI18ns collection.
By default this just sets the collCustomerGroupI18ns collection to an empty array (like clearcollCustomerGroupI18ns());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@param boolean $overrideExisting If set to true, the method call initializes
the collection even if it is not empty
@return void | [
"Initializes",
"the",
"collCustomerGroupI18ns",
"collection",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1714-L1721 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.getCustomerGroupI18ns | public function getCustomerGroupI18ns($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collCustomerGroupI18nsPartial && !$this->isNew();
if (null === $this->collCustomerGroupI18ns || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomerGroupI18ns) {
// return empty collection
$this->initCustomerGroupI18ns();
} else {
$collCustomerGroupI18ns = ChildCustomerGroupI18nQuery::create(null, $criteria)
->filterByCustomerGroup($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collCustomerGroupI18nsPartial && count($collCustomerGroupI18ns)) {
$this->initCustomerGroupI18ns(false);
foreach ($collCustomerGroupI18ns as $obj) {
if (false == $this->collCustomerGroupI18ns->contains($obj)) {
$this->collCustomerGroupI18ns->append($obj);
}
}
$this->collCustomerGroupI18nsPartial = true;
}
reset($collCustomerGroupI18ns);
return $collCustomerGroupI18ns;
}
if ($partial && $this->collCustomerGroupI18ns) {
foreach ($this->collCustomerGroupI18ns as $obj) {
if ($obj->isNew()) {
$collCustomerGroupI18ns[] = $obj;
}
}
}
$this->collCustomerGroupI18ns = $collCustomerGroupI18ns;
$this->collCustomerGroupI18nsPartial = false;
}
}
return $this->collCustomerGroupI18ns;
} | php | public function getCustomerGroupI18ns($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collCustomerGroupI18nsPartial && !$this->isNew();
if (null === $this->collCustomerGroupI18ns || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomerGroupI18ns) {
// return empty collection
$this->initCustomerGroupI18ns();
} else {
$collCustomerGroupI18ns = ChildCustomerGroupI18nQuery::create(null, $criteria)
->filterByCustomerGroup($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collCustomerGroupI18nsPartial && count($collCustomerGroupI18ns)) {
$this->initCustomerGroupI18ns(false);
foreach ($collCustomerGroupI18ns as $obj) {
if (false == $this->collCustomerGroupI18ns->contains($obj)) {
$this->collCustomerGroupI18ns->append($obj);
}
}
$this->collCustomerGroupI18nsPartial = true;
}
reset($collCustomerGroupI18ns);
return $collCustomerGroupI18ns;
}
if ($partial && $this->collCustomerGroupI18ns) {
foreach ($this->collCustomerGroupI18ns as $obj) {
if ($obj->isNew()) {
$collCustomerGroupI18ns[] = $obj;
}
}
}
$this->collCustomerGroupI18ns = $collCustomerGroupI18ns;
$this->collCustomerGroupI18nsPartial = false;
}
}
return $this->collCustomerGroupI18ns;
} | [
"public",
"function",
"getCustomerGroupI18ns",
"(",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collCustomerGroupI18nsPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collCustomerGroupI18ns",
")",
"{",
"// return empty collection",
"$",
"this",
"->",
"initCustomerGroupI18ns",
"(",
")",
";",
"}",
"else",
"{",
"$",
"collCustomerGroupI18ns",
"=",
"ChildCustomerGroupI18nQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"filterByCustomerGroup",
"(",
"$",
"this",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"criteria",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"this",
"->",
"collCustomerGroupI18nsPartial",
"&&",
"count",
"(",
"$",
"collCustomerGroupI18ns",
")",
")",
"{",
"$",
"this",
"->",
"initCustomerGroupI18ns",
"(",
"false",
")",
";",
"foreach",
"(",
"$",
"collCustomerGroupI18ns",
"as",
"$",
"obj",
")",
"{",
"if",
"(",
"false",
"==",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"->",
"contains",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"->",
"append",
"(",
"$",
"obj",
")",
";",
"}",
"}",
"$",
"this",
"->",
"collCustomerGroupI18nsPartial",
"=",
"true",
";",
"}",
"reset",
"(",
"$",
"collCustomerGroupI18ns",
")",
";",
"return",
"$",
"collCustomerGroupI18ns",
";",
"}",
"if",
"(",
"$",
"partial",
"&&",
"$",
"this",
"->",
"collCustomerGroupI18ns",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"as",
"$",
"obj",
")",
"{",
"if",
"(",
"$",
"obj",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"collCustomerGroupI18ns",
"[",
"]",
"=",
"$",
"obj",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"=",
"$",
"collCustomerGroupI18ns",
";",
"$",
"this",
"->",
"collCustomerGroupI18nsPartial",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"collCustomerGroupI18ns",
";",
"}"
] | Gets an array of ChildCustomerGroupI18n objects which contain a foreign key that references this object.
If the $criteria is not null, it is used to always fetch the results from the database.
Otherwise the results are fetched from the database the first time, then cached.
Next time the same method is called without $criteria, the cached collection is returned.
If this ChildCustomerGroup is new, it will return
an empty collection or the current collection; the criteria is ignored on a new object.
@param Criteria $criteria optional Criteria object to narrow the query
@param ConnectionInterface $con optional connection object
@return Collection|ChildCustomerGroupI18n[] List of ChildCustomerGroupI18n objects
@throws PropelException | [
"Gets",
"an",
"array",
"of",
"ChildCustomerGroupI18n",
"objects",
"which",
"contain",
"a",
"foreign",
"key",
"that",
"references",
"this",
"object",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1737-L1781 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.setCustomerGroupI18ns | public function setCustomerGroupI18ns(Collection $customerGroupI18ns, ConnectionInterface $con = null)
{
$customerGroupI18nsToDelete = $this->getCustomerGroupI18ns(new Criteria(), $con)->diff($customerGroupI18ns);
//since at least one column in the foreign key is at the same time a PK
//we can not just set a PK to NULL in the lines below. We have to store
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
$this->customerGroupI18nsScheduledForDeletion = clone $customerGroupI18nsToDelete;
foreach ($customerGroupI18nsToDelete as $customerGroupI18nRemoved) {
$customerGroupI18nRemoved->setCustomerGroup(null);
}
$this->collCustomerGroupI18ns = null;
foreach ($customerGroupI18ns as $customerGroupI18n) {
$this->addCustomerGroupI18n($customerGroupI18n);
}
$this->collCustomerGroupI18ns = $customerGroupI18ns;
$this->collCustomerGroupI18nsPartial = false;
return $this;
} | php | public function setCustomerGroupI18ns(Collection $customerGroupI18ns, ConnectionInterface $con = null)
{
$customerGroupI18nsToDelete = $this->getCustomerGroupI18ns(new Criteria(), $con)->diff($customerGroupI18ns);
//since at least one column in the foreign key is at the same time a PK
//we can not just set a PK to NULL in the lines below. We have to store
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
$this->customerGroupI18nsScheduledForDeletion = clone $customerGroupI18nsToDelete;
foreach ($customerGroupI18nsToDelete as $customerGroupI18nRemoved) {
$customerGroupI18nRemoved->setCustomerGroup(null);
}
$this->collCustomerGroupI18ns = null;
foreach ($customerGroupI18ns as $customerGroupI18n) {
$this->addCustomerGroupI18n($customerGroupI18n);
}
$this->collCustomerGroupI18ns = $customerGroupI18ns;
$this->collCustomerGroupI18nsPartial = false;
return $this;
} | [
"public",
"function",
"setCustomerGroupI18ns",
"(",
"Collection",
"$",
"customerGroupI18ns",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"customerGroupI18nsToDelete",
"=",
"$",
"this",
"->",
"getCustomerGroupI18ns",
"(",
"new",
"Criteria",
"(",
")",
",",
"$",
"con",
")",
"->",
"diff",
"(",
"$",
"customerGroupI18ns",
")",
";",
"//since at least one column in the foreign key is at the same time a PK",
"//we can not just set a PK to NULL in the lines below. We have to store",
"//a backup of all values, so we are able to manipulate these items based on the onDelete value later.",
"$",
"this",
"->",
"customerGroupI18nsScheduledForDeletion",
"=",
"clone",
"$",
"customerGroupI18nsToDelete",
";",
"foreach",
"(",
"$",
"customerGroupI18nsToDelete",
"as",
"$",
"customerGroupI18nRemoved",
")",
"{",
"$",
"customerGroupI18nRemoved",
"->",
"setCustomerGroup",
"(",
"null",
")",
";",
"}",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"=",
"null",
";",
"foreach",
"(",
"$",
"customerGroupI18ns",
"as",
"$",
"customerGroupI18n",
")",
"{",
"$",
"this",
"->",
"addCustomerGroupI18n",
"(",
"$",
"customerGroupI18n",
")",
";",
"}",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"=",
"$",
"customerGroupI18ns",
";",
"$",
"this",
"->",
"collCustomerGroupI18nsPartial",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] | Sets a collection of CustomerGroupI18n objects related by a one-to-many relationship
to the current object.
It will also schedule objects for deletion based on a diff between old objects (aka persisted)
and new objects from the given Propel collection.
@param Collection $customerGroupI18ns A Propel collection.
@param ConnectionInterface $con Optional connection object
@return ChildCustomerGroup The current object (for fluent API support) | [
"Sets",
"a",
"collection",
"of",
"CustomerGroupI18n",
"objects",
"related",
"by",
"a",
"one",
"-",
"to",
"-",
"many",
"relationship",
"to",
"the",
"current",
"object",
".",
"It",
"will",
"also",
"schedule",
"objects",
"for",
"deletion",
"based",
"on",
"a",
"diff",
"between",
"old",
"objects",
"(",
"aka",
"persisted",
")",
"and",
"new",
"objects",
"from",
"the",
"given",
"Propel",
"collection",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1793-L1816 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.countCustomerGroupI18ns | public function countCustomerGroupI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collCustomerGroupI18nsPartial && !$this->isNew();
if (null === $this->collCustomerGroupI18ns || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomerGroupI18ns) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getCustomerGroupI18ns());
}
$query = ChildCustomerGroupI18nQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByCustomerGroup($this)
->count($con);
}
return count($this->collCustomerGroupI18ns);
} | php | public function countCustomerGroupI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collCustomerGroupI18nsPartial && !$this->isNew();
if (null === $this->collCustomerGroupI18ns || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomerGroupI18ns) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getCustomerGroupI18ns());
}
$query = ChildCustomerGroupI18nQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByCustomerGroup($this)
->count($con);
}
return count($this->collCustomerGroupI18ns);
} | [
"public",
"function",
"countCustomerGroupI18ns",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collCustomerGroupI18nsPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collCustomerGroupI18ns",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"$",
"partial",
"&&",
"!",
"$",
"criteria",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"getCustomerGroupI18ns",
"(",
")",
")",
";",
"}",
"$",
"query",
"=",
"ChildCustomerGroupI18nQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"distinct",
")",
"{",
"$",
"query",
"->",
"distinct",
"(",
")",
";",
"}",
"return",
"$",
"query",
"->",
"filterByCustomerGroup",
"(",
"$",
"this",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"collCustomerGroupI18ns",
")",
";",
"}"
] | Returns the number of related CustomerGroupI18n objects.
@param Criteria $criteria
@param boolean $distinct
@param ConnectionInterface $con
@return int Count of related CustomerGroupI18n objects.
@throws PropelException | [
"Returns",
"the",
"number",
"of",
"related",
"CustomerGroupI18n",
"objects",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1827-L1850 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.addCustomerGroupI18n | public function addCustomerGroupI18n(ChildCustomerGroupI18n $l)
{
if ($l && $locale = $l->getLocale()) {
$this->setLocale($locale);
$this->currentTranslations[$locale] = $l;
}
if ($this->collCustomerGroupI18ns === null) {
$this->initCustomerGroupI18ns();
$this->collCustomerGroupI18nsPartial = true;
}
if (!in_array($l, $this->collCustomerGroupI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddCustomerGroupI18n($l);
}
return $this;
} | php | public function addCustomerGroupI18n(ChildCustomerGroupI18n $l)
{
if ($l && $locale = $l->getLocale()) {
$this->setLocale($locale);
$this->currentTranslations[$locale] = $l;
}
if ($this->collCustomerGroupI18ns === null) {
$this->initCustomerGroupI18ns();
$this->collCustomerGroupI18nsPartial = true;
}
if (!in_array($l, $this->collCustomerGroupI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddCustomerGroupI18n($l);
}
return $this;
} | [
"public",
"function",
"addCustomerGroupI18n",
"(",
"ChildCustomerGroupI18n",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"l",
"&&",
"$",
"locale",
"=",
"$",
"l",
"->",
"getLocale",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"locale",
")",
";",
"$",
"this",
"->",
"currentTranslations",
"[",
"$",
"locale",
"]",
"=",
"$",
"l",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initCustomerGroupI18ns",
"(",
")",
";",
"$",
"this",
"->",
"collCustomerGroupI18nsPartial",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"l",
",",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"->",
"getArrayCopy",
"(",
")",
",",
"true",
")",
")",
"{",
"// only add it if the **same** object is not already associated",
"$",
"this",
"->",
"doAddCustomerGroupI18n",
"(",
"$",
"l",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Method called to associate a ChildCustomerGroupI18n object to this object
through the ChildCustomerGroupI18n foreign key attribute.
@param ChildCustomerGroupI18n $l ChildCustomerGroupI18n
@return \CustomerGroup\Model\CustomerGroup The current object (for fluent API support) | [
"Method",
"called",
"to",
"associate",
"a",
"ChildCustomerGroupI18n",
"object",
"to",
"this",
"object",
"through",
"the",
"ChildCustomerGroupI18n",
"foreign",
"key",
"attribute",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1859-L1875 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.getCustomers | public function getCustomers($criteria = null, ConnectionInterface $con = null)
{
if (null === $this->collCustomers || null !== $criteria) {
if ($this->isNew() && null === $this->collCustomers) {
// return empty collection
$this->initCustomers();
} else {
$collCustomers = CustomerQuery::create(null, $criteria)
->filterByCustomerGroup($this)
->find($con);
if (null !== $criteria) {
return $collCustomers;
}
$this->collCustomers = $collCustomers;
}
}
return $this->collCustomers;
} | php | public function getCustomers($criteria = null, ConnectionInterface $con = null)
{
if (null === $this->collCustomers || null !== $criteria) {
if ($this->isNew() && null === $this->collCustomers) {
// return empty collection
$this->initCustomers();
} else {
$collCustomers = CustomerQuery::create(null, $criteria)
->filterByCustomerGroup($this)
->find($con);
if (null !== $criteria) {
return $collCustomers;
}
$this->collCustomers = $collCustomers;
}
}
return $this->collCustomers;
} | [
"public",
"function",
"getCustomers",
"(",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collCustomers",
"||",
"null",
"!==",
"$",
"criteria",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collCustomers",
")",
"{",
"// return empty collection",
"$",
"this",
"->",
"initCustomers",
"(",
")",
";",
"}",
"else",
"{",
"$",
"collCustomers",
"=",
"CustomerQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"filterByCustomerGroup",
"(",
"$",
"this",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"criteria",
")",
"{",
"return",
"$",
"collCustomers",
";",
"}",
"$",
"this",
"->",
"collCustomers",
"=",
"$",
"collCustomers",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"collCustomers",
";",
"}"
] | Gets a collection of ChildCustomer objects related by a many-to-many relationship
to the current object by way of the customer_customer_group cross-reference table.
If the $criteria is not null, it is used to always fetch the results from the database.
Otherwise the results are fetched from the database the first time, then cached.
Next time the same method is called without $criteria, the cached collection is returned.
If this ChildCustomerGroup is new, it will return
an empty collection or the current collection; the criteria is ignored on a new object.
@param Criteria $criteria Optional query object to filter the query
@param ConnectionInterface $con Optional connection object
@return ObjectCollection|ChildCustomer[] List of ChildCustomer objects | [
"Gets",
"a",
"collection",
"of",
"ChildCustomer",
"objects",
"related",
"by",
"a",
"many",
"-",
"to",
"-",
"many",
"relationship",
"to",
"the",
"current",
"object",
"by",
"way",
"of",
"the",
"customer_customer_group",
"cross",
"-",
"reference",
"table",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1950-L1968 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.setCustomers | public function setCustomers(Collection $customers, ConnectionInterface $con = null)
{
$this->clearCustomers();
$currentCustomers = $this->getCustomers();
$this->customersScheduledForDeletion = $currentCustomers->diff($customers);
foreach ($customers as $customer) {
if (!$currentCustomers->contains($customer)) {
$this->doAddCustomer($customer);
}
}
$this->collCustomers = $customers;
return $this;
} | php | public function setCustomers(Collection $customers, ConnectionInterface $con = null)
{
$this->clearCustomers();
$currentCustomers = $this->getCustomers();
$this->customersScheduledForDeletion = $currentCustomers->diff($customers);
foreach ($customers as $customer) {
if (!$currentCustomers->contains($customer)) {
$this->doAddCustomer($customer);
}
}
$this->collCustomers = $customers;
return $this;
} | [
"public",
"function",
"setCustomers",
"(",
"Collection",
"$",
"customers",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"clearCustomers",
"(",
")",
";",
"$",
"currentCustomers",
"=",
"$",
"this",
"->",
"getCustomers",
"(",
")",
";",
"$",
"this",
"->",
"customersScheduledForDeletion",
"=",
"$",
"currentCustomers",
"->",
"diff",
"(",
"$",
"customers",
")",
";",
"foreach",
"(",
"$",
"customers",
"as",
"$",
"customer",
")",
"{",
"if",
"(",
"!",
"$",
"currentCustomers",
"->",
"contains",
"(",
"$",
"customer",
")",
")",
"{",
"$",
"this",
"->",
"doAddCustomer",
"(",
"$",
"customer",
")",
";",
"}",
"}",
"$",
"this",
"->",
"collCustomers",
"=",
"$",
"customers",
";",
"return",
"$",
"this",
";",
"}"
] | Sets a collection of Customer objects related by a many-to-many relationship
to the current object by way of the customer_customer_group cross-reference table.
It will also schedule objects for deletion based on a diff between old objects (aka persisted)
and new objects from the given Propel collection.
@param Collection $customers A Propel collection.
@param ConnectionInterface $con Optional connection object
@return ChildCustomerGroup The current object (for fluent API support) | [
"Sets",
"a",
"collection",
"of",
"Customer",
"objects",
"related",
"by",
"a",
"many",
"-",
"to",
"-",
"many",
"relationship",
"to",
"the",
"current",
"object",
"by",
"way",
"of",
"the",
"customer_customer_group",
"cross",
"-",
"reference",
"table",
".",
"It",
"will",
"also",
"schedule",
"objects",
"for",
"deletion",
"based",
"on",
"a",
"diff",
"between",
"old",
"objects",
"(",
"aka",
"persisted",
")",
"and",
"new",
"objects",
"from",
"the",
"given",
"Propel",
"collection",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L1980-L1996 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.countCustomers | public function countCustomers($criteria = null, $distinct = false, ConnectionInterface $con = null)
{
if (null === $this->collCustomers || null !== $criteria) {
if ($this->isNew() && null === $this->collCustomers) {
return 0;
} else {
$query = CustomerQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByCustomerGroup($this)
->count($con);
}
} else {
return count($this->collCustomers);
}
} | php | public function countCustomers($criteria = null, $distinct = false, ConnectionInterface $con = null)
{
if (null === $this->collCustomers || null !== $criteria) {
if ($this->isNew() && null === $this->collCustomers) {
return 0;
} else {
$query = CustomerQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByCustomerGroup($this)
->count($con);
}
} else {
return count($this->collCustomers);
}
} | [
"public",
"function",
"countCustomers",
"(",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collCustomers",
"||",
"null",
"!==",
"$",
"criteria",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collCustomers",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"CustomerQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"distinct",
")",
"{",
"$",
"query",
"->",
"distinct",
"(",
")",
";",
"}",
"return",
"$",
"query",
"->",
"filterByCustomerGroup",
"(",
"$",
"this",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}",
"}",
"else",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"collCustomers",
")",
";",
"}",
"}"
] | Gets the number of ChildCustomer objects related by a many-to-many relationship
to the current object by way of the customer_customer_group cross-reference table.
@param Criteria $criteria Optional query object to filter the query
@param boolean $distinct Set to true to force count distinct
@param ConnectionInterface $con Optional connection object
@return int the number of related ChildCustomer objects | [
"Gets",
"the",
"number",
"of",
"ChildCustomer",
"objects",
"related",
"by",
"a",
"many",
"-",
"to",
"-",
"many",
"relationship",
"to",
"the",
"current",
"object",
"by",
"way",
"of",
"the",
"customer_customer_group",
"cross",
"-",
"reference",
"table",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2008-L2026 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.addCustomer | public function addCustomer(ChildCustomer $customer)
{
if ($this->collCustomers === null) {
$this->initCustomers();
}
if (!$this->collCustomers->contains($customer)) { // only add it if the **same** object is not already associated
$this->doAddCustomer($customer);
$this->collCustomers[] = $customer;
}
return $this;
} | php | public function addCustomer(ChildCustomer $customer)
{
if ($this->collCustomers === null) {
$this->initCustomers();
}
if (!$this->collCustomers->contains($customer)) { // only add it if the **same** object is not already associated
$this->doAddCustomer($customer);
$this->collCustomers[] = $customer;
}
return $this;
} | [
"public",
"function",
"addCustomer",
"(",
"ChildCustomer",
"$",
"customer",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collCustomers",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initCustomers",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"collCustomers",
"->",
"contains",
"(",
"$",
"customer",
")",
")",
"{",
"// only add it if the **same** object is not already associated",
"$",
"this",
"->",
"doAddCustomer",
"(",
"$",
"customer",
")",
";",
"$",
"this",
"->",
"collCustomers",
"[",
"]",
"=",
"$",
"customer",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Associate a ChildCustomer object to this object
through the customer_customer_group cross reference table.
@param ChildCustomer $customer The ChildCustomerCustomerGroup object to relate
@return ChildCustomerGroup The current object (for fluent API support) | [
"Associate",
"a",
"ChildCustomer",
"object",
"to",
"this",
"object",
"through",
"the",
"customer_customer_group",
"cross",
"reference",
"table",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2035-L2047 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.clearAllReferences | public function clearAllReferences($deep = false)
{
if ($deep) {
if ($this->collCustomerCustomerGroups) {
foreach ($this->collCustomerCustomerGroups as $o) {
$o->clearAllReferences($deep);
}
}
if ($this->collCustomerGroupI18ns) {
foreach ($this->collCustomerGroupI18ns as $o) {
$o->clearAllReferences($deep);
}
}
if ($this->collCustomers) {
foreach ($this->collCustomers as $o) {
$o->clearAllReferences($deep);
}
}
} // if ($deep)
// i18n behavior
$this->currentLocale = 'en_US';
$this->currentTranslations = null;
$this->collCustomerCustomerGroups = null;
$this->collCustomerGroupI18ns = null;
$this->collCustomers = null;
} | php | public function clearAllReferences($deep = false)
{
if ($deep) {
if ($this->collCustomerCustomerGroups) {
foreach ($this->collCustomerCustomerGroups as $o) {
$o->clearAllReferences($deep);
}
}
if ($this->collCustomerGroupI18ns) {
foreach ($this->collCustomerGroupI18ns as $o) {
$o->clearAllReferences($deep);
}
}
if ($this->collCustomers) {
foreach ($this->collCustomers as $o) {
$o->clearAllReferences($deep);
}
}
} // if ($deep)
// i18n behavior
$this->currentLocale = 'en_US';
$this->currentTranslations = null;
$this->collCustomerCustomerGroups = null;
$this->collCustomerGroupI18ns = null;
$this->collCustomers = null;
} | [
"public",
"function",
"clearAllReferences",
"(",
"$",
"deep",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"deep",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collCustomerCustomerGroups",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"as",
"$",
"o",
")",
"{",
"$",
"o",
"->",
"clearAllReferences",
"(",
"$",
"deep",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"collCustomerGroupI18ns",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"as",
"$",
"o",
")",
"{",
"$",
"o",
"->",
"clearAllReferences",
"(",
"$",
"deep",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"collCustomers",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomers",
"as",
"$",
"o",
")",
"{",
"$",
"o",
"->",
"clearAllReferences",
"(",
"$",
"deep",
")",
";",
"}",
"}",
"}",
"// if ($deep)",
"// i18n behavior",
"$",
"this",
"->",
"currentLocale",
"=",
"'en_US'",
";",
"$",
"this",
"->",
"currentTranslations",
"=",
"null",
";",
"$",
"this",
"->",
"collCustomerCustomerGroups",
"=",
"null",
";",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"=",
"null",
";",
"$",
"this",
"->",
"collCustomers",
"=",
"null",
";",
"}"
] | Resets all references to other model objects or collections of model objects.
This method is a user-space workaround for PHP's inability to garbage collect
objects with circular references (even in PHP 5.3). This is currently necessary
when using Propel in certain daemon or large-volume/high-memory operations.
@param boolean $deep Whether to also clear the references on all referrer objects. | [
"Resets",
"all",
"references",
"to",
"other",
"model",
"objects",
"or",
"collections",
"of",
"model",
"objects",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2116-L2143 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.getTranslation | public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
{
if (!isset($this->currentTranslations[$locale])) {
if (null !== $this->collCustomerGroupI18ns) {
foreach ($this->collCustomerGroupI18ns as $translation) {
if ($translation->getLocale() == $locale) {
$this->currentTranslations[$locale] = $translation;
return $translation;
}
}
}
if ($this->isNew()) {
$translation = new ChildCustomerGroupI18n();
$translation->setLocale($locale);
} else {
$translation = ChildCustomerGroupI18nQuery::create()
->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
->findOneOrCreate($con);
$this->currentTranslations[$locale] = $translation;
}
$this->addCustomerGroupI18n($translation);
}
return $this->currentTranslations[$locale];
} | php | public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
{
if (!isset($this->currentTranslations[$locale])) {
if (null !== $this->collCustomerGroupI18ns) {
foreach ($this->collCustomerGroupI18ns as $translation) {
if ($translation->getLocale() == $locale) {
$this->currentTranslations[$locale] = $translation;
return $translation;
}
}
}
if ($this->isNew()) {
$translation = new ChildCustomerGroupI18n();
$translation->setLocale($locale);
} else {
$translation = ChildCustomerGroupI18nQuery::create()
->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
->findOneOrCreate($con);
$this->currentTranslations[$locale] = $translation;
}
$this->addCustomerGroupI18n($translation);
}
return $this->currentTranslations[$locale];
} | [
"public",
"function",
"getTranslation",
"(",
"$",
"locale",
"=",
"'en_US'",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"currentTranslations",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collCustomerGroupI18ns",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomerGroupI18ns",
"as",
"$",
"translation",
")",
"{",
"if",
"(",
"$",
"translation",
"->",
"getLocale",
"(",
")",
"==",
"$",
"locale",
")",
"{",
"$",
"this",
"->",
"currentTranslations",
"[",
"$",
"locale",
"]",
"=",
"$",
"translation",
";",
"return",
"$",
"translation",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"translation",
"=",
"new",
"ChildCustomerGroupI18n",
"(",
")",
";",
"$",
"translation",
"->",
"setLocale",
"(",
"$",
"locale",
")",
";",
"}",
"else",
"{",
"$",
"translation",
"=",
"ChildCustomerGroupI18nQuery",
"::",
"create",
"(",
")",
"->",
"filterByPrimaryKey",
"(",
"array",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
",",
"$",
"locale",
")",
")",
"->",
"findOneOrCreate",
"(",
"$",
"con",
")",
";",
"$",
"this",
"->",
"currentTranslations",
"[",
"$",
"locale",
"]",
"=",
"$",
"translation",
";",
"}",
"$",
"this",
"->",
"addCustomerGroupI18n",
"(",
"$",
"translation",
")",
";",
"}",
"return",
"$",
"this",
"->",
"currentTranslations",
"[",
"$",
"locale",
"]",
";",
"}"
] | Returns the current translation for a given locale
@param string $locale Locale to use for the translation, e.g. 'fr_FR'
@param ConnectionInterface $con an optional connection object
@return ChildCustomerGroupI18n | [
"Returns",
"the",
"current",
"translation",
"for",
"a",
"given",
"locale"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2202-L2227 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.isLast | public function isLast(ConnectionInterface $con = null)
{
return $this->getPosition() == ChildCustomerGroupQuery::create()->getMaxRankArray($con);
} | php | public function isLast(ConnectionInterface $con = null)
{
return $this->getPosition() == ChildCustomerGroupQuery::create()->getMaxRankArray($con);
} | [
"public",
"function",
"isLast",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getPosition",
"(",
")",
"==",
"ChildCustomerGroupQuery",
"::",
"create",
"(",
")",
"->",
"getMaxRankArray",
"(",
"$",
"con",
")",
";",
"}"
] | Check if the object is last in the list, i.e. if its rank is the highest rank
@param ConnectionInterface $con optional connection
@return boolean | [
"Check",
"if",
"the",
"object",
"is",
"last",
"in",
"the",
"list",
"i",
".",
"e",
".",
"if",
"its",
"rank",
"is",
"the",
"highest",
"rank"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2356-L2359 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.getNext | public function getNext(ConnectionInterface $con = null)
{
$query = ChildCustomerGroupQuery::create();
$query->filterByRank($this->getPosition() + 1);
return $query->findOne($con);
} | php | public function getNext(ConnectionInterface $con = null)
{
$query = ChildCustomerGroupQuery::create();
$query->filterByRank($this->getPosition() + 1);
return $query->findOne($con);
} | [
"public",
"function",
"getNext",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"ChildCustomerGroupQuery",
"::",
"create",
"(",
")",
";",
"$",
"query",
"->",
"filterByRank",
"(",
"$",
"this",
"->",
"getPosition",
"(",
")",
"+",
"1",
")",
";",
"return",
"$",
"query",
"->",
"findOne",
"(",
"$",
"con",
")",
";",
"}"
] | Get the next item in the list, i.e. the one for which rank is immediately higher
@param ConnectionInterface $con optional connection
@return ChildCustomerGroup | [
"Get",
"the",
"next",
"item",
"in",
"the",
"list",
"i",
".",
"e",
".",
"the",
"one",
"for",
"which",
"rank",
"is",
"immediately",
"higher"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2368-L2377 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.insertAtRank | public function insertAtRank($rank, ConnectionInterface $con = null)
{
$maxRank = ChildCustomerGroupQuery::create()->getMaxRankArray($con);
if ($rank < 1 || $rank > $maxRank + 1) {
throw new PropelException('Invalid rank ' . $rank);
}
// move the object in the list, at the given rank
$this->setPosition($rank);
if ($rank != $maxRank + 1) {
// Keep the list modification query for the save() transaction
$this->sortableQueries []= array(
'callable' => array('\CustomerGroup\Model\CustomerGroupQuery', 'sortableShiftRank'),
'arguments' => array(1, $rank, null, )
);
}
return $this;
} | php | public function insertAtRank($rank, ConnectionInterface $con = null)
{
$maxRank = ChildCustomerGroupQuery::create()->getMaxRankArray($con);
if ($rank < 1 || $rank > $maxRank + 1) {
throw new PropelException('Invalid rank ' . $rank);
}
// move the object in the list, at the given rank
$this->setPosition($rank);
if ($rank != $maxRank + 1) {
// Keep the list modification query for the save() transaction
$this->sortableQueries []= array(
'callable' => array('\CustomerGroup\Model\CustomerGroupQuery', 'sortableShiftRank'),
'arguments' => array(1, $rank, null, )
);
}
return $this;
} | [
"public",
"function",
"insertAtRank",
"(",
"$",
"rank",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"maxRank",
"=",
"ChildCustomerGroupQuery",
"::",
"create",
"(",
")",
"->",
"getMaxRankArray",
"(",
"$",
"con",
")",
";",
"if",
"(",
"$",
"rank",
"<",
"1",
"||",
"$",
"rank",
">",
"$",
"maxRank",
"+",
"1",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Invalid rank '",
".",
"$",
"rank",
")",
";",
"}",
"// move the object in the list, at the given rank",
"$",
"this",
"->",
"setPosition",
"(",
"$",
"rank",
")",
";",
"if",
"(",
"$",
"rank",
"!=",
"$",
"maxRank",
"+",
"1",
")",
"{",
"// Keep the list modification query for the save() transaction",
"$",
"this",
"->",
"sortableQueries",
"[",
"]",
"=",
"array",
"(",
"'callable'",
"=>",
"array",
"(",
"'\\CustomerGroup\\Model\\CustomerGroupQuery'",
",",
"'sortableShiftRank'",
")",
",",
"'arguments'",
"=>",
"array",
"(",
"1",
",",
"$",
"rank",
",",
"null",
",",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Insert at specified rank
The modifications are not persisted until the object is saved.
@param integer $rank rank value
@param ConnectionInterface $con optional connection
@return ChildCustomerGroup the current object
@throws PropelException | [
"Insert",
"at",
"specified",
"rank",
"The",
"modifications",
"are",
"not",
"persisted",
"until",
"the",
"object",
"is",
"saved",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2408-L2425 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.insertAtBottom | public function insertAtBottom(ConnectionInterface $con = null)
{
$this->setPosition(ChildCustomerGroupQuery::create()->getMaxRankArray($con) + 1);
return $this;
} | php | public function insertAtBottom(ConnectionInterface $con = null)
{
$this->setPosition(ChildCustomerGroupQuery::create()->getMaxRankArray($con) + 1);
return $this;
} | [
"public",
"function",
"insertAtBottom",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setPosition",
"(",
"ChildCustomerGroupQuery",
"::",
"create",
"(",
")",
"->",
"getMaxRankArray",
"(",
"$",
"con",
")",
"+",
"1",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Insert in the last rank
The modifications are not persisted until the object is saved.
@param ConnectionInterface $con optional connection
@return ChildCustomerGroup the current object
@throws PropelException | [
"Insert",
"in",
"the",
"last",
"rank",
"The",
"modifications",
"are",
"not",
"persisted",
"until",
"the",
"object",
"is",
"saved",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2437-L2442 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.moveToRank | public function moveToRank($newRank, ConnectionInterface $con = null)
{
if ($this->isNew()) {
throw new PropelException('New objects cannot be moved. Please use insertAtRank() instead');
}
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
if ($newRank < 1 || $newRank > ChildCustomerGroupQuery::create()->getMaxRankArray($con)) {
throw new PropelException('Invalid rank ' . $newRank);
}
$oldRank = $this->getPosition();
if ($oldRank == $newRank) {
return $this;
}
$con->beginTransaction();
try {
// shift the objects between the old and the new rank
$delta = ($oldRank < $newRank) ? -1 : 1;
ChildCustomerGroupQuery::sortableShiftRank($delta, min($oldRank, $newRank), max($oldRank, $newRank), $con);
// move the object to its new rank
$this->setPosition($newRank);
$this->save($con);
$con->commit();
return $this;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | php | public function moveToRank($newRank, ConnectionInterface $con = null)
{
if ($this->isNew()) {
throw new PropelException('New objects cannot be moved. Please use insertAtRank() instead');
}
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
if ($newRank < 1 || $newRank > ChildCustomerGroupQuery::create()->getMaxRankArray($con)) {
throw new PropelException('Invalid rank ' . $newRank);
}
$oldRank = $this->getPosition();
if ($oldRank == $newRank) {
return $this;
}
$con->beginTransaction();
try {
// shift the objects between the old and the new rank
$delta = ($oldRank < $newRank) ? -1 : 1;
ChildCustomerGroupQuery::sortableShiftRank($delta, min($oldRank, $newRank), max($oldRank, $newRank), $con);
// move the object to its new rank
$this->setPosition($newRank);
$this->save($con);
$con->commit();
return $this;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | [
"public",
"function",
"moveToRank",
"(",
"$",
"newRank",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'New objects cannot be moved. Please use insertAtRank() instead'",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getWriteConnection",
"(",
"CustomerGroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"if",
"(",
"$",
"newRank",
"<",
"1",
"||",
"$",
"newRank",
">",
"ChildCustomerGroupQuery",
"::",
"create",
"(",
")",
"->",
"getMaxRankArray",
"(",
"$",
"con",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Invalid rank '",
".",
"$",
"newRank",
")",
";",
"}",
"$",
"oldRank",
"=",
"$",
"this",
"->",
"getPosition",
"(",
")",
";",
"if",
"(",
"$",
"oldRank",
"==",
"$",
"newRank",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"// shift the objects between the old and the new rank",
"$",
"delta",
"=",
"(",
"$",
"oldRank",
"<",
"$",
"newRank",
")",
"?",
"-",
"1",
":",
"1",
";",
"ChildCustomerGroupQuery",
"::",
"sortableShiftRank",
"(",
"$",
"delta",
",",
"min",
"(",
"$",
"oldRank",
",",
"$",
"newRank",
")",
",",
"max",
"(",
"$",
"oldRank",
",",
"$",
"newRank",
")",
",",
"$",
"con",
")",
";",
"// move the object to its new rank",
"$",
"this",
"->",
"setPosition",
"(",
"$",
"newRank",
")",
";",
"$",
"this",
"->",
"save",
"(",
"$",
"con",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"this",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Move the object to a new rank, and shifts the rank
Of the objects inbetween the old and new rank accordingly
@param integer $newRank rank value
@param ConnectionInterface $con optional connection
@return ChildCustomerGroup the current object
@throws PropelException | [
"Move",
"the",
"object",
"to",
"a",
"new",
"rank",
"and",
"shifts",
"the",
"rank",
"Of",
"the",
"objects",
"inbetween",
"the",
"old",
"and",
"new",
"rank",
"accordingly"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2466-L2500 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.swapWith | public function swapWith($object, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$oldRank = $this->getPosition();
$newRank = $object->getPosition();
$this->setPosition($newRank);
$object->setPosition($oldRank);
$this->save($con);
$object->save($con);
$con->commit();
return $this;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | php | public function swapWith($object, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$oldRank = $this->getPosition();
$newRank = $object->getPosition();
$this->setPosition($newRank);
$object->setPosition($oldRank);
$this->save($con);
$object->save($con);
$con->commit();
return $this;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | [
"public",
"function",
"swapWith",
"(",
"$",
"object",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getWriteConnection",
"(",
"CustomerGroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"$",
"oldRank",
"=",
"$",
"this",
"->",
"getPosition",
"(",
")",
";",
"$",
"newRank",
"=",
"$",
"object",
"->",
"getPosition",
"(",
")",
";",
"$",
"this",
"->",
"setPosition",
"(",
"$",
"newRank",
")",
";",
"$",
"object",
"->",
"setPosition",
"(",
"$",
"oldRank",
")",
";",
"$",
"this",
"->",
"save",
"(",
"$",
"con",
")",
";",
"$",
"object",
"->",
"save",
"(",
"$",
"con",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"this",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Exchange the rank of the object with the one passed as argument, and saves both objects
@param ChildCustomerGroup $object
@param ConnectionInterface $con optional connection
@return ChildCustomerGroup the current object
@throws Exception if the database cannot execute the two updates | [
"Exchange",
"the",
"rank",
"of",
"the",
"object",
"with",
"the",
"one",
"passed",
"as",
"argument",
"and",
"saves",
"both",
"objects"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2512-L2534 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.moveUp | public function moveUp(ConnectionInterface $con = null)
{
if ($this->isFirst()) {
return $this;
}
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$prev = $this->getPrevious($con);
$this->swapWith($prev, $con);
$con->commit();
return $this;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | php | public function moveUp(ConnectionInterface $con = null)
{
if ($this->isFirst()) {
return $this;
}
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$prev = $this->getPrevious($con);
$this->swapWith($prev, $con);
$con->commit();
return $this;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | [
"public",
"function",
"moveUp",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFirst",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getWriteConnection",
"(",
"CustomerGroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"$",
"prev",
"=",
"$",
"this",
"->",
"getPrevious",
"(",
"$",
"con",
")",
";",
"$",
"this",
"->",
"swapWith",
"(",
"$",
"prev",
",",
"$",
"con",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"this",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Move the object higher in the list, i.e. exchanges its rank with the one of the previous object
@param ConnectionInterface $con optional connection
@return ChildCustomerGroup the current object | [
"Move",
"the",
"object",
"higher",
"in",
"the",
"list",
"i",
".",
"e",
".",
"exchanges",
"its",
"rank",
"with",
"the",
"one",
"of",
"the",
"previous",
"object"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2543-L2562 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.moveDown | public function moveDown(ConnectionInterface $con = null)
{
if ($this->isLast($con)) {
return $this;
}
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$next = $this->getNext($con);
$this->swapWith($next, $con);
$con->commit();
return $this;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | php | public function moveDown(ConnectionInterface $con = null)
{
if ($this->isLast($con)) {
return $this;
}
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$next = $this->getNext($con);
$this->swapWith($next, $con);
$con->commit();
return $this;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | [
"public",
"function",
"moveDown",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLast",
"(",
"$",
"con",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getWriteConnection",
"(",
"CustomerGroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"$",
"next",
"=",
"$",
"this",
"->",
"getNext",
"(",
"$",
"con",
")",
";",
"$",
"this",
"->",
"swapWith",
"(",
"$",
"next",
",",
"$",
"con",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"this",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Move the object higher in the list, i.e. exchanges its rank with the one of the next object
@param ConnectionInterface $con optional connection
@return ChildCustomerGroup the current object | [
"Move",
"the",
"object",
"higher",
"in",
"the",
"list",
"i",
".",
"e",
".",
"exchanges",
"its",
"rank",
"with",
"the",
"one",
"of",
"the",
"next",
"object"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2571-L2590 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.moveToTop | public function moveToTop(ConnectionInterface $con = null)
{
if ($this->isFirst()) {
return $this;
}
return $this->moveToRank(1, $con);
} | php | public function moveToTop(ConnectionInterface $con = null)
{
if ($this->isFirst()) {
return $this;
}
return $this->moveToRank(1, $con);
} | [
"public",
"function",
"moveToTop",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFirst",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"return",
"$",
"this",
"->",
"moveToRank",
"(",
"1",
",",
"$",
"con",
")",
";",
"}"
] | Move the object to the top of the list
@param ConnectionInterface $con optional connection
@return ChildCustomerGroup the current object | [
"Move",
"the",
"object",
"to",
"the",
"top",
"of",
"the",
"list"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2599-L2606 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.moveToBottom | public function moveToBottom(ConnectionInterface $con = null)
{
if ($this->isLast($con)) {
return false;
}
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$bottom = ChildCustomerGroupQuery::create()->getMaxRankArray($con);
$res = $this->moveToRank($bottom, $con);
$con->commit();
return $res;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | php | public function moveToBottom(ConnectionInterface $con = null)
{
if ($this->isLast($con)) {
return false;
}
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$bottom = ChildCustomerGroupQuery::create()->getMaxRankArray($con);
$res = $this->moveToRank($bottom, $con);
$con->commit();
return $res;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | [
"public",
"function",
"moveToBottom",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLast",
"(",
"$",
"con",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getWriteConnection",
"(",
"CustomerGroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"$",
"bottom",
"=",
"ChildCustomerGroupQuery",
"::",
"create",
"(",
")",
"->",
"getMaxRankArray",
"(",
"$",
"con",
")",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"moveToRank",
"(",
"$",
"bottom",
",",
"$",
"con",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"res",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Move the object to the bottom of the list
@param ConnectionInterface $con optional connection
@return integer the old object's rank | [
"Move",
"the",
"object",
"to",
"the",
"bottom",
"of",
"the",
"list"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2615-L2634 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.removeFromList | public function removeFromList()
{
// Keep the list modification query for the save() transaction
$this->sortableQueries[] = array(
'callable' => array('\CustomerGroup\Model\CustomerGroupQuery', 'sortableShiftRank'),
'arguments' => array(-1, $this->getPosition() + 1, null)
);
// remove the object from the list
$this->setPosition(null);
return $this;
} | php | public function removeFromList()
{
// Keep the list modification query for the save() transaction
$this->sortableQueries[] = array(
'callable' => array('\CustomerGroup\Model\CustomerGroupQuery', 'sortableShiftRank'),
'arguments' => array(-1, $this->getPosition() + 1, null)
);
// remove the object from the list
$this->setPosition(null);
return $this;
} | [
"public",
"function",
"removeFromList",
"(",
")",
"{",
"// Keep the list modification query for the save() transaction",
"$",
"this",
"->",
"sortableQueries",
"[",
"]",
"=",
"array",
"(",
"'callable'",
"=>",
"array",
"(",
"'\\CustomerGroup\\Model\\CustomerGroupQuery'",
",",
"'sortableShiftRank'",
")",
",",
"'arguments'",
"=>",
"array",
"(",
"-",
"1",
",",
"$",
"this",
"->",
"getPosition",
"(",
")",
"+",
"1",
",",
"null",
")",
")",
";",
"// remove the object from the list",
"$",
"this",
"->",
"setPosition",
"(",
"null",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Removes the current object from the list.
The modifications are not persisted until the object is saved.
@return ChildCustomerGroup the current object | [
"Removes",
"the",
"current",
"object",
"from",
"the",
"list",
".",
"The",
"modifications",
"are",
"not",
"persisted",
"until",
"the",
"object",
"is",
"saved",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2642-L2654 |
thelia-modules/CustomerGroup | Model/Base/CustomerGroup.php | CustomerGroup.processSortableQueries | protected function processSortableQueries($con)
{
foreach ($this->sortableQueries as $query) {
$query['arguments'][]= $con;
call_user_func_array($query['callable'], $query['arguments']);
}
$this->sortableQueries = array();
} | php | protected function processSortableQueries($con)
{
foreach ($this->sortableQueries as $query) {
$query['arguments'][]= $con;
call_user_func_array($query['callable'], $query['arguments']);
}
$this->sortableQueries = array();
} | [
"protected",
"function",
"processSortableQueries",
"(",
"$",
"con",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"sortableQueries",
"as",
"$",
"query",
")",
"{",
"$",
"query",
"[",
"'arguments'",
"]",
"[",
"]",
"=",
"$",
"con",
";",
"call_user_func_array",
"(",
"$",
"query",
"[",
"'callable'",
"]",
",",
"$",
"query",
"[",
"'arguments'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"sortableQueries",
"=",
"array",
"(",
")",
";",
"}"
] | Execute queries that were saved to be run inside the save transaction | [
"Execute",
"queries",
"that",
"were",
"saved",
"to",
"be",
"run",
"inside",
"the",
"save",
"transaction"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroup.php#L2659-L2666 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php | MethodAssembler.create | public function create($data)
{
$methodDescriptor = new MethodDescriptor();
$this->mapReflectorToDescriptor($data, $methodDescriptor);
$this->assembleDocBlock($data->getDocBlock(), $methodDescriptor);
$this->addArguments($data, $methodDescriptor);
$this->addVariadicArgument($data, $methodDescriptor);
return $methodDescriptor;
} | php | public function create($data)
{
$methodDescriptor = new MethodDescriptor();
$this->mapReflectorToDescriptor($data, $methodDescriptor);
$this->assembleDocBlock($data->getDocBlock(), $methodDescriptor);
$this->addArguments($data, $methodDescriptor);
$this->addVariadicArgument($data, $methodDescriptor);
return $methodDescriptor;
} | [
"public",
"function",
"create",
"(",
"$",
"data",
")",
"{",
"$",
"methodDescriptor",
"=",
"new",
"MethodDescriptor",
"(",
")",
";",
"$",
"this",
"->",
"mapReflectorToDescriptor",
"(",
"$",
"data",
",",
"$",
"methodDescriptor",
")",
";",
"$",
"this",
"->",
"assembleDocBlock",
"(",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
",",
"$",
"methodDescriptor",
")",
";",
"$",
"this",
"->",
"addArguments",
"(",
"$",
"data",
",",
"$",
"methodDescriptor",
")",
";",
"$",
"this",
"->",
"addVariadicArgument",
"(",
"$",
"data",
",",
"$",
"methodDescriptor",
")",
";",
"return",
"$",
"methodDescriptor",
";",
"}"
] | Creates a Descriptor from the provided data.
@param MethodReflector $data
@return MethodDescriptor | [
"Creates",
"a",
"Descriptor",
"from",
"the",
"provided",
"data",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php#L46-L56 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php | MethodAssembler.mapReflectorToDescriptor | protected function mapReflectorToDescriptor($reflector, $descriptor)
{
$descriptor->setFullyQualifiedStructuralElementName($reflector->getName() . '()');
$descriptor->setName($reflector->getShortName());
$descriptor->setVisibility($reflector->getVisibility() ? : 'public');
$descriptor->setFinal($reflector->isFinal());
$descriptor->setAbstract($reflector->isAbstract());
$descriptor->setStatic($reflector->isStatic());
$descriptor->setLine($reflector->getLinenumber());
} | php | protected function mapReflectorToDescriptor($reflector, $descriptor)
{
$descriptor->setFullyQualifiedStructuralElementName($reflector->getName() . '()');
$descriptor->setName($reflector->getShortName());
$descriptor->setVisibility($reflector->getVisibility() ? : 'public');
$descriptor->setFinal($reflector->isFinal());
$descriptor->setAbstract($reflector->isAbstract());
$descriptor->setStatic($reflector->isStatic());
$descriptor->setLine($reflector->getLinenumber());
} | [
"protected",
"function",
"mapReflectorToDescriptor",
"(",
"$",
"reflector",
",",
"$",
"descriptor",
")",
"{",
"$",
"descriptor",
"->",
"setFullyQualifiedStructuralElementName",
"(",
"$",
"reflector",
"->",
"getName",
"(",
")",
".",
"'()'",
")",
";",
"$",
"descriptor",
"->",
"setName",
"(",
"$",
"reflector",
"->",
"getShortName",
"(",
")",
")",
";",
"$",
"descriptor",
"->",
"setVisibility",
"(",
"$",
"reflector",
"->",
"getVisibility",
"(",
")",
"?",
":",
"'public'",
")",
";",
"$",
"descriptor",
"->",
"setFinal",
"(",
"$",
"reflector",
"->",
"isFinal",
"(",
")",
")",
";",
"$",
"descriptor",
"->",
"setAbstract",
"(",
"$",
"reflector",
"->",
"isAbstract",
"(",
")",
")",
";",
"$",
"descriptor",
"->",
"setStatic",
"(",
"$",
"reflector",
"->",
"isStatic",
"(",
")",
")",
";",
"$",
"descriptor",
"->",
"setLine",
"(",
"$",
"reflector",
"->",
"getLinenumber",
"(",
")",
")",
";",
"}"
] | Maps the fields to the reflector to the descriptor.
@param MethodReflector $reflector
@param MethodDescriptor $descriptor
@return void | [
"Maps",
"the",
"fields",
"to",
"the",
"reflector",
"to",
"the",
"descriptor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php#L66-L75 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php | MethodAssembler.addArguments | protected function addArguments($reflector, $descriptor)
{
foreach ($reflector->getArguments() as $argument) {
$this->addArgument($argument, $descriptor);
}
} | php | protected function addArguments($reflector, $descriptor)
{
foreach ($reflector->getArguments() as $argument) {
$this->addArgument($argument, $descriptor);
}
} | [
"protected",
"function",
"addArguments",
"(",
"$",
"reflector",
",",
"$",
"descriptor",
")",
"{",
"foreach",
"(",
"$",
"reflector",
"->",
"getArguments",
"(",
")",
"as",
"$",
"argument",
")",
"{",
"$",
"this",
"->",
"addArgument",
"(",
"$",
"argument",
",",
"$",
"descriptor",
")",
";",
"}",
"}"
] | Adds the reflected Arguments to the Descriptor.
@param MethodReflector $reflector
@param MethodDescriptor $descriptor
@return void | [
"Adds",
"the",
"reflected",
"Arguments",
"to",
"the",
"Descriptor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php#L85-L90 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php | MethodAssembler.addArgument | protected function addArgument($argument, $descriptor)
{
$params = $descriptor->getTags()->get('param', array());
if (!$this->argumentAssembler->getBuilder()) {
$this->argumentAssembler->setBuilder($this->builder);
}
$argumentDescriptor = $this->argumentAssembler->create($argument, $params);
$descriptor->addArgument($argumentDescriptor->getName(), $argumentDescriptor);
} | php | protected function addArgument($argument, $descriptor)
{
$params = $descriptor->getTags()->get('param', array());
if (!$this->argumentAssembler->getBuilder()) {
$this->argumentAssembler->setBuilder($this->builder);
}
$argumentDescriptor = $this->argumentAssembler->create($argument, $params);
$descriptor->addArgument($argumentDescriptor->getName(), $argumentDescriptor);
} | [
"protected",
"function",
"addArgument",
"(",
"$",
"argument",
",",
"$",
"descriptor",
")",
"{",
"$",
"params",
"=",
"$",
"descriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'param'",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"argumentAssembler",
"->",
"getBuilder",
"(",
")",
")",
"{",
"$",
"this",
"->",
"argumentAssembler",
"->",
"setBuilder",
"(",
"$",
"this",
"->",
"builder",
")",
";",
"}",
"$",
"argumentDescriptor",
"=",
"$",
"this",
"->",
"argumentAssembler",
"->",
"create",
"(",
"$",
"argument",
",",
"$",
"params",
")",
";",
"$",
"descriptor",
"->",
"addArgument",
"(",
"$",
"argumentDescriptor",
"->",
"getName",
"(",
")",
",",
"$",
"argumentDescriptor",
")",
";",
"}"
] | Adds a single reflected Argument to the Method Descriptor.
@param ArgumentReflector $argument
@param MethodDescriptor $descriptor
@return void | [
"Adds",
"a",
"single",
"reflected",
"Argument",
"to",
"the",
"Method",
"Descriptor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php#L100-L110 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php | MethodAssembler.addVariadicArgument | protected function addVariadicArgument($data, $methodDescriptor)
{
if (!$data->getDocBlock()) {
return;
}
$paramTags = $data->getDocBlock()->getTagsByName('param');
/** @var ParamTag $lastParamTag */
$lastParamTag = end($paramTags);
if (!$lastParamTag) {
return;
}
if ($lastParamTag->isVariadic()
&& !in_array($lastParamTag->getVariableName(), array_keys($methodDescriptor->getArguments()->getAll()))
) {
$types = $this->builder->buildDescriptor(new Collection($lastParamTag->getTypes()));
$argument = new ArgumentDescriptor();
$argument->setName($lastParamTag->getVariableName());
$argument->setTypes($types);
$argument->setDescription($lastParamTag->getDescription());
$argument->setLine($methodDescriptor->getLine());
$argument->setVariadic(true);
$methodDescriptor->getArguments()->set($argument->getName(), $argument);
}
} | php | protected function addVariadicArgument($data, $methodDescriptor)
{
if (!$data->getDocBlock()) {
return;
}
$paramTags = $data->getDocBlock()->getTagsByName('param');
/** @var ParamTag $lastParamTag */
$lastParamTag = end($paramTags);
if (!$lastParamTag) {
return;
}
if ($lastParamTag->isVariadic()
&& !in_array($lastParamTag->getVariableName(), array_keys($methodDescriptor->getArguments()->getAll()))
) {
$types = $this->builder->buildDescriptor(new Collection($lastParamTag->getTypes()));
$argument = new ArgumentDescriptor();
$argument->setName($lastParamTag->getVariableName());
$argument->setTypes($types);
$argument->setDescription($lastParamTag->getDescription());
$argument->setLine($methodDescriptor->getLine());
$argument->setVariadic(true);
$methodDescriptor->getArguments()->set($argument->getName(), $argument);
}
} | [
"protected",
"function",
"addVariadicArgument",
"(",
"$",
"data",
",",
"$",
"methodDescriptor",
")",
"{",
"if",
"(",
"!",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"paramTags",
"=",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
"->",
"getTagsByName",
"(",
"'param'",
")",
";",
"/** @var ParamTag $lastParamTag */",
"$",
"lastParamTag",
"=",
"end",
"(",
"$",
"paramTags",
")",
";",
"if",
"(",
"!",
"$",
"lastParamTag",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"lastParamTag",
"->",
"isVariadic",
"(",
")",
"&&",
"!",
"in_array",
"(",
"$",
"lastParamTag",
"->",
"getVariableName",
"(",
")",
",",
"array_keys",
"(",
"$",
"methodDescriptor",
"->",
"getArguments",
"(",
")",
"->",
"getAll",
"(",
")",
")",
")",
")",
"{",
"$",
"types",
"=",
"$",
"this",
"->",
"builder",
"->",
"buildDescriptor",
"(",
"new",
"Collection",
"(",
"$",
"lastParamTag",
"->",
"getTypes",
"(",
")",
")",
")",
";",
"$",
"argument",
"=",
"new",
"ArgumentDescriptor",
"(",
")",
";",
"$",
"argument",
"->",
"setName",
"(",
"$",
"lastParamTag",
"->",
"getVariableName",
"(",
")",
")",
";",
"$",
"argument",
"->",
"setTypes",
"(",
"$",
"types",
")",
";",
"$",
"argument",
"->",
"setDescription",
"(",
"$",
"lastParamTag",
"->",
"getDescription",
"(",
")",
")",
";",
"$",
"argument",
"->",
"setLine",
"(",
"$",
"methodDescriptor",
"->",
"getLine",
"(",
")",
")",
";",
"$",
"argument",
"->",
"setVariadic",
"(",
"true",
")",
";",
"$",
"methodDescriptor",
"->",
"getArguments",
"(",
")",
"->",
"set",
"(",
"$",
"argument",
"->",
"getName",
"(",
")",
",",
"$",
"argument",
")",
";",
"}",
"}"
] | Checks if there is a variadic argument in the `@param` tags and adds it to the list of Arguments in
the Descriptor unless there is already one present.
@param MethodReflector $data
@param MethodDescriptor $methodDescriptor
@return void | [
"Checks",
"if",
"there",
"is",
"a",
"variadic",
"argument",
"in",
"the",
"@param",
"tags",
"and",
"adds",
"it",
"to",
"the",
"list",
"of",
"Arguments",
"in",
"the",
"Descriptor",
"unless",
"there",
"is",
"already",
"one",
"present",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php#L121-L149 |
Jimdo/jimphle-data-structure | src/Jimphle/DataStructure/Base.php | Base.fromArray | public static function fromArray(array $data)
{
foreach ($data as $property => $value) {
if ($value instanceof BaseInterface) {
continue;
}
if (is_object($value)) {
$data[$property] = Map::fromObject($value);
}
if (is_array($value)) {
if (Vector::isSequentialList($value)) {
$data[$property] = Vector::fromArray($value);
} else {
$data[$property] = Map::fromArray($value);
}
}
}
return new static($data);
} | php | public static function fromArray(array $data)
{
foreach ($data as $property => $value) {
if ($value instanceof BaseInterface) {
continue;
}
if (is_object($value)) {
$data[$property] = Map::fromObject($value);
}
if (is_array($value)) {
if (Vector::isSequentialList($value)) {
$data[$property] = Vector::fromArray($value);
} else {
$data[$property] = Map::fromArray($value);
}
}
}
return new static($data);
} | [
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"BaseInterface",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"data",
"[",
"$",
"property",
"]",
"=",
"Map",
"::",
"fromObject",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"Vector",
"::",
"isSequentialList",
"(",
"$",
"value",
")",
")",
"{",
"$",
"data",
"[",
"$",
"property",
"]",
"=",
"Vector",
"::",
"fromArray",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"$",
"property",
"]",
"=",
"Map",
"::",
"fromArray",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}",
"return",
"new",
"static",
"(",
"$",
"data",
")",
";",
"}"
] | You should use this:
* If you want to convert an associative array into a map:
\Jimphle\DataStructure\Map::fromArray(array("foo" => "bar"));
* If you want to convert a sequential indexed array into a vector:
\Jimphle\DataStructure\Vector::fromArray(array("foo", "bar"));
@param array $data
@return BaseInterface | [
"You",
"should",
"use",
"this",
":",
"*",
"If",
"you",
"want",
"to",
"convert",
"an",
"associative",
"array",
"into",
"a",
"map",
":",
"\\",
"Jimphle",
"\\",
"DataStructure",
"\\",
"Map",
"::",
"fromArray",
"(",
"array",
"(",
"foo",
"=",
">",
"bar",
"))",
";",
"*",
"If",
"you",
"want",
"to",
"convert",
"a",
"sequential",
"indexed",
"array",
"into",
"a",
"vector",
":",
"\\",
"Jimphle",
"\\",
"DataStructure",
"\\",
"Vector",
"::",
"fromArray",
"(",
"array",
"(",
"foo",
"bar",
"))",
";"
] | train | https://github.com/Jimdo/jimphle-data-structure/blob/15f784e4af48520079f8639748ab68b074dbc005/src/Jimphle/DataStructure/Base.php#L104-L122 |
KodiComponents/Support | src/Extendable.php | Extendable.extend | public function extend($name, ExtensionInterface $extension)
{
$this->getExtensions()->put($name, $extension);
$extension->set($this);
return $extension;
} | php | public function extend($name, ExtensionInterface $extension)
{
$this->getExtensions()->put($name, $extension);
$extension->set($this);
return $extension;
} | [
"public",
"function",
"extend",
"(",
"$",
"name",
",",
"ExtensionInterface",
"$",
"extension",
")",
"{",
"$",
"this",
"->",
"getExtensions",
"(",
")",
"->",
"put",
"(",
"$",
"name",
",",
"$",
"extension",
")",
";",
"$",
"extension",
"->",
"set",
"(",
"$",
"this",
")",
";",
"return",
"$",
"extension",
";",
"}"
] | @param string $name
@param ExtensionInterface $extension
@return ExtensionInterface | [
"@param",
"string",
"$name",
"@param",
"ExtensionInterface",
"$extension"
] | train | https://github.com/KodiComponents/Support/blob/9090543605a2354c7454d707650a0abdb815b60a/src/Extendable.php#L22-L29 |
Erdiko/core | src/Template.php | Template.initiate | public function initiate($template = null, $data = null, $templateRootFolder = ERDIKO_APP)
{
$template = ($template === null) ? $this->getDefaultTemplate() : $template;
$this->setTemplate($template);
$this->setData($data);
$this->setTemplateRootFolder($templateRootFolder);
} | php | public function initiate($template = null, $data = null, $templateRootFolder = ERDIKO_APP)
{
$template = ($template === null) ? $this->getDefaultTemplate() : $template;
$this->setTemplate($template);
$this->setData($data);
$this->setTemplateRootFolder($templateRootFolder);
} | [
"public",
"function",
"initiate",
"(",
"$",
"template",
"=",
"null",
",",
"$",
"data",
"=",
"null",
",",
"$",
"templateRootFolder",
"=",
"ERDIKO_APP",
")",
"{",
"$",
"template",
"=",
"(",
"$",
"template",
"===",
"null",
")",
"?",
"$",
"this",
"->",
"getDefaultTemplate",
"(",
")",
":",
"$",
"template",
";",
"$",
"this",
"->",
"setTemplate",
"(",
"$",
"template",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setTemplateRootFolder",
"(",
"$",
"templateRootFolder",
")",
";",
"}"
] | Constructor like initiation
@param string $template , Theme Object (Contaier)
@param mixed $data | [
"Constructor",
"like",
"initiation"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Template.php#L33-L39 |
Erdiko/core | src/Template.php | Template.getTemplateFile | public function getTemplateFile($filename, $data)
{
if (is_file($filename.'.php')) {
ob_start();
include $filename.'.php';
return ob_get_clean();
} elseif (is_file($filename.'.html')) {
return $this->renderMustache($filename, $data);
} elseif (is_file($filename.'.md')) {
$parsedown = new \Parsedown;
return $parsedown->text(file_get_contents($filename.'.md'));
}
throw new \Exception("Template file does not exist ({$filename})");
} | php | public function getTemplateFile($filename, $data)
{
if (is_file($filename.'.php')) {
ob_start();
include $filename.'.php';
return ob_get_clean();
} elseif (is_file($filename.'.html')) {
return $this->renderMustache($filename, $data);
} elseif (is_file($filename.'.md')) {
$parsedown = new \Parsedown;
return $parsedown->text(file_get_contents($filename.'.md'));
}
throw new \Exception("Template file does not exist ({$filename})");
} | [
"public",
"function",
"getTemplateFile",
"(",
"$",
"filename",
",",
"$",
"data",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"filename",
".",
"'.php'",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"include",
"$",
"filename",
".",
"'.php'",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}",
"elseif",
"(",
"is_file",
"(",
"$",
"filename",
".",
"'.html'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"renderMustache",
"(",
"$",
"filename",
",",
"$",
"data",
")",
";",
"}",
"elseif",
"(",
"is_file",
"(",
"$",
"filename",
".",
"'.md'",
")",
")",
"{",
"$",
"parsedown",
"=",
"new",
"\\",
"Parsedown",
";",
"return",
"$",
"parsedown",
"->",
"text",
"(",
"file_get_contents",
"(",
"$",
"filename",
".",
"'.md'",
")",
")",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Template file does not exist ({$filename})\"",
")",
";",
"}"
] | Get rendered template file
Accepts one of the types of template files in this order:
php (.php), html/mustache (.html), markdown (.md)
@param string $filename , file without extension
@param array $data , associative array of data
@throws \Exception , template file does not exist | [
"Get",
"rendered",
"template",
"file",
"Accepts",
"one",
"of",
"the",
"types",
"of",
"template",
"files",
"in",
"this",
"order",
":",
"php",
"(",
".",
"php",
")",
"html",
"/",
"mustache",
"(",
".",
"html",
")",
"markdown",
"(",
".",
"md",
")"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Template.php#L143-L159 |
Erdiko/core | src/Template.php | Template.toHtml | public function toHtml()
{
$filename = $this->getTemplateFolder().$this->getTemplate();
$data = (is_subclass_of($this->_data, 'erdiko\core\Container')) ? $this->_data->toHtml() : $this->_data;
return $this->getTemplateFile($filename, $data);
} | php | public function toHtml()
{
$filename = $this->getTemplateFolder().$this->getTemplate();
$data = (is_subclass_of($this->_data, 'erdiko\core\Container')) ? $this->_data->toHtml() : $this->_data;
return $this->getTemplateFile($filename, $data);
} | [
"public",
"function",
"toHtml",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getTemplateFolder",
"(",
")",
".",
"$",
"this",
"->",
"getTemplate",
"(",
")",
";",
"$",
"data",
"=",
"(",
"is_subclass_of",
"(",
"$",
"this",
"->",
"_data",
",",
"'erdiko\\core\\Container'",
")",
")",
"?",
"$",
"this",
"->",
"_data",
"->",
"toHtml",
"(",
")",
":",
"$",
"this",
"->",
"_data",
";",
"return",
"$",
"this",
"->",
"getTemplateFile",
"(",
"$",
"filename",
",",
"$",
"data",
")",
";",
"}"
] | Render container to HTML
@return string $html | [
"Render",
"container",
"to",
"HTML"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Template.php#L187-L193 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php | BaseConverter.convert | public function convert(Collection $source, TemplateInterface $template)
{
$this->fileset = $source;
$this->assets->setProjectRoot($this->fileset->getProjectRoot());
$template->setExtension(current($this->definition->getOutputFormat()->getExtensions()));
$this->configure();
$this->discover();
$this->addTemplateAssets($template);
$this->setOption('toc', $this->toc);
return $this->create($template);
} | php | public function convert(Collection $source, TemplateInterface $template)
{
$this->fileset = $source;
$this->assets->setProjectRoot($this->fileset->getProjectRoot());
$template->setExtension(current($this->definition->getOutputFormat()->getExtensions()));
$this->configure();
$this->discover();
$this->addTemplateAssets($template);
$this->setOption('toc', $this->toc);
return $this->create($template);
} | [
"public",
"function",
"convert",
"(",
"Collection",
"$",
"source",
",",
"TemplateInterface",
"$",
"template",
")",
"{",
"$",
"this",
"->",
"fileset",
"=",
"$",
"source",
";",
"$",
"this",
"->",
"assets",
"->",
"setProjectRoot",
"(",
"$",
"this",
"->",
"fileset",
"->",
"getProjectRoot",
"(",
")",
")",
";",
"$",
"template",
"->",
"setExtension",
"(",
"current",
"(",
"$",
"this",
"->",
"definition",
"->",
"getOutputFormat",
"(",
")",
"->",
"getExtensions",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"configure",
"(",
")",
";",
"$",
"this",
"->",
"discover",
"(",
")",
";",
"$",
"this",
"->",
"addTemplateAssets",
"(",
"$",
"template",
")",
";",
"$",
"this",
"->",
"setOption",
"(",
"'toc'",
",",
"$",
"this",
"->",
"toc",
")",
";",
"return",
"$",
"this",
"->",
"create",
"(",
"$",
"template",
")",
";",
"}"
] | Converts the given $source using the formats that belong to this
converter.
This method will return null unless the 'scrybe://result' is used.
@param Collection $source Collection of input files.
@param TemplateInterface $template Template used to decorate the
output with.
@return string[]|null | [
"Converts",
"the",
"given",
"$source",
"using",
"the",
"formats",
"that",
"belong",
"to",
"this",
"converter",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php#L198-L212 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php | BaseConverter.addTemplateAssets | protected function addTemplateAssets($template)
{
/** @var SplFileInfo $file_info */
foreach ($template->getAssets() as $filename => $file_info) {
$this->assets->set($filename, $file_info->getRelativePathname());
}
} | php | protected function addTemplateAssets($template)
{
/** @var SplFileInfo $file_info */
foreach ($template->getAssets() as $filename => $file_info) {
$this->assets->set($filename, $file_info->getRelativePathname());
}
} | [
"protected",
"function",
"addTemplateAssets",
"(",
"$",
"template",
")",
"{",
"/** @var SplFileInfo $file_info */",
"foreach",
"(",
"$",
"template",
"->",
"getAssets",
"(",
")",
"as",
"$",
"filename",
"=>",
"$",
"file_info",
")",
"{",
"$",
"this",
"->",
"assets",
"->",
"set",
"(",
"$",
"filename",
",",
"$",
"file_info",
"->",
"getRelativePathname",
"(",
")",
")",
";",
"}",
"}"
] | Adds the assets of the template to the Assets manager.
@param TemplateInterface $template
@return void | [
"Adds",
"the",
"assets",
"of",
"the",
"template",
"to",
"the",
"Assets",
"manager",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php#L221-L227 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php | BaseConverter.getDestinationFilenameRelativeToProjectRoot | public function getDestinationFilenameRelativeToProjectRoot(File $file)
{
return substr($this->getDestinationFilename($file), strlen($this->fileset->getProjectRoot()));
} | php | public function getDestinationFilenameRelativeToProjectRoot(File $file)
{
return substr($this->getDestinationFilename($file), strlen($this->fileset->getProjectRoot()));
} | [
"public",
"function",
"getDestinationFilenameRelativeToProjectRoot",
"(",
"File",
"$",
"file",
")",
"{",
"return",
"substr",
"(",
"$",
"this",
"->",
"getDestinationFilename",
"(",
"$",
"file",
")",
",",
"strlen",
"(",
"$",
"this",
"->",
"fileset",
"->",
"getProjectRoot",
"(",
")",
")",
")",
";",
"}"
] | Returns the filename relative to the Project Root of the fileset.
@param File $file
@return string | [
"Returns",
"the",
"filename",
"relative",
"to",
"the",
"Project",
"Root",
"of",
"the",
"fileset",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php#L248-L251 |
mithun12000/yii2-process | src/components/Process.php | Process.create | public function create(Action $action, $timeout = 0, ProcessPool $pcontrol = null){
if($pcontrol && $pcontrol->control instanceof Control){
$this->control = $pcontrol->control;
}else{
$this->createControl();
}
$this->process = new Child($action, $this->control, $timeout);
} | php | public function create(Action $action, $timeout = 0, ProcessPool $pcontrol = null){
if($pcontrol && $pcontrol->control instanceof Control){
$this->control = $pcontrol->control;
}else{
$this->createControl();
}
$this->process = new Child($action, $this->control, $timeout);
} | [
"public",
"function",
"create",
"(",
"Action",
"$",
"action",
",",
"$",
"timeout",
"=",
"0",
",",
"ProcessPool",
"$",
"pcontrol",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"pcontrol",
"&&",
"$",
"pcontrol",
"->",
"control",
"instanceof",
"Control",
")",
"{",
"$",
"this",
"->",
"control",
"=",
"$",
"pcontrol",
"->",
"control",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"createControl",
"(",
")",
";",
"}",
"$",
"this",
"->",
"process",
"=",
"new",
"Child",
"(",
"$",
"action",
",",
"$",
"this",
"->",
"control",
",",
"$",
"timeout",
")",
";",
"}"
] | Create a process
@param Action $action
@param number $timeout
@param ProcessPool $pcontrol | [
"Create",
"a",
"process"
] | train | https://github.com/mithun12000/yii2-process/blob/d4c660010381fee76159eb4c92d4b75e38442d3c/src/components/Process.php#L41-L48 |
jnaxo/country-codes | src/Country.php | Country.getInlcudeResources | public function getInlcudeResources($resource)
{
switch ($resource) {
case 'administrative_areas':
return $this->administrativeAreas()->getQuery();
case 'cities':
return $this->cities()->getQuery()->select("ctrystore_cities.*");
}
return false;
} | php | public function getInlcudeResources($resource)
{
switch ($resource) {
case 'administrative_areas':
return $this->administrativeAreas()->getQuery();
case 'cities':
return $this->cities()->getQuery()->select("ctrystore_cities.*");
}
return false;
} | [
"public",
"function",
"getInlcudeResources",
"(",
"$",
"resource",
")",
"{",
"switch",
"(",
"$",
"resource",
")",
"{",
"case",
"'administrative_areas'",
":",
"return",
"$",
"this",
"->",
"administrativeAreas",
"(",
")",
"->",
"getQuery",
"(",
")",
";",
"case",
"'cities'",
":",
"return",
"$",
"this",
"->",
"cities",
"(",
")",
"->",
"getQuery",
"(",
")",
"->",
"select",
"(",
"\"ctrystore_cities.*\"",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Check if resource is related with the model. Then return resource query.
@param string $resource
@return boolean | [
"Check",
"if",
"resource",
"is",
"related",
"with",
"the",
"model",
".",
"Then",
"return",
"resource",
"query",
"."
] | train | https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Country.php#L61-L70 |
eghojansu/moe | src/tools/Audit.php | Audit.email | function email($str,$mx=TRUE) {
$hosts=array();
return is_string(filter_var($str,FILTER_VALIDATE_EMAIL)) &&
(!$mx || getmxrr(substr($str,strrpos($str,'@')+1),$hosts));
} | php | function email($str,$mx=TRUE) {
$hosts=array();
return is_string(filter_var($str,FILTER_VALIDATE_EMAIL)) &&
(!$mx || getmxrr(substr($str,strrpos($str,'@')+1),$hosts));
} | [
"function",
"email",
"(",
"$",
"str",
",",
"$",
"mx",
"=",
"TRUE",
")",
"{",
"$",
"hosts",
"=",
"array",
"(",
")",
";",
"return",
"is_string",
"(",
"filter_var",
"(",
"$",
"str",
",",
"FILTER_VALIDATE_EMAIL",
")",
")",
"&&",
"(",
"!",
"$",
"mx",
"||",
"getmxrr",
"(",
"substr",
"(",
"$",
"str",
",",
"strrpos",
"(",
"$",
"str",
",",
"'@'",
")",
"+",
"1",
")",
",",
"$",
"hosts",
")",
")",
";",
"}"
] | Return TRUE if string is a valid e-mail address;
Check DNS MX records if specified
@return bool
@param $str string
@param $mx boolean | [
"Return",
"TRUE",
"if",
"string",
"is",
"a",
"valid",
"e",
"-",
"mail",
"address",
";",
"Check",
"DNS",
"MX",
"records",
"if",
"specified"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Audit.php#L34-L38 |
chubbyphp/chubbyphp-negotiation | src/AcceptLanguageNegotiator.php | AcceptLanguageNegotiator.negotiate | public function negotiate(Request $request)
{
if ([] === $this->supportedLocales) {
return null;
}
if (!$request->hasHeader('Accept-Language')) {
return null;
}
$aggregatedValues = $this->aggregatedValues($request->getHeaderLine('Accept-Language'));
return $this->compareAgainstSupportedLocales($aggregatedValues);
} | php | public function negotiate(Request $request)
{
if ([] === $this->supportedLocales) {
return null;
}
if (!$request->hasHeader('Accept-Language')) {
return null;
}
$aggregatedValues = $this->aggregatedValues($request->getHeaderLine('Accept-Language'));
return $this->compareAgainstSupportedLocales($aggregatedValues);
} | [
"public",
"function",
"negotiate",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"[",
"]",
"===",
"$",
"this",
"->",
"supportedLocales",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"request",
"->",
"hasHeader",
"(",
"'Accept-Language'",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"aggregatedValues",
"=",
"$",
"this",
"->",
"aggregatedValues",
"(",
"$",
"request",
"->",
"getHeaderLine",
"(",
"'Accept-Language'",
")",
")",
";",
"return",
"$",
"this",
"->",
"compareAgainstSupportedLocales",
"(",
"$",
"aggregatedValues",
")",
";",
"}"
] | @param Request $request
@return NegotiatedValueInterface|null | [
"@param",
"Request",
"$request"
] | train | https://github.com/chubbyphp/chubbyphp-negotiation/blob/f4f8a10f2f067ecd868db9177c81f00428c42049/src/AcceptLanguageNegotiator.php#L40-L53 |
chubbyphp/chubbyphp-negotiation | src/AcceptLanguageNegotiator.php | AcceptLanguageNegotiator.compareAgainstSupportedLocales | private function compareAgainstSupportedLocales(array $aggregatedValues)
{
if (null !== $negotiatedValue = $this->exactCompareAgainstSupportedLocales($aggregatedValues)) {
return $negotiatedValue;
}
if (null !== $negotiatedValue = $this->languageCompareAgainstSupportedLocales($aggregatedValues)) {
return $negotiatedValue;
}
if (isset($aggregatedValues['*'])) {
return new NegotiatedValue(reset($this->supportedLocales), $aggregatedValues['*']);
}
return null;
} | php | private function compareAgainstSupportedLocales(array $aggregatedValues)
{
if (null !== $negotiatedValue = $this->exactCompareAgainstSupportedLocales($aggregatedValues)) {
return $negotiatedValue;
}
if (null !== $negotiatedValue = $this->languageCompareAgainstSupportedLocales($aggregatedValues)) {
return $negotiatedValue;
}
if (isset($aggregatedValues['*'])) {
return new NegotiatedValue(reset($this->supportedLocales), $aggregatedValues['*']);
}
return null;
} | [
"private",
"function",
"compareAgainstSupportedLocales",
"(",
"array",
"$",
"aggregatedValues",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"negotiatedValue",
"=",
"$",
"this",
"->",
"exactCompareAgainstSupportedLocales",
"(",
"$",
"aggregatedValues",
")",
")",
"{",
"return",
"$",
"negotiatedValue",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"negotiatedValue",
"=",
"$",
"this",
"->",
"languageCompareAgainstSupportedLocales",
"(",
"$",
"aggregatedValues",
")",
")",
"{",
"return",
"$",
"negotiatedValue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"aggregatedValues",
"[",
"'*'",
"]",
")",
")",
"{",
"return",
"new",
"NegotiatedValue",
"(",
"reset",
"(",
"$",
"this",
"->",
"supportedLocales",
")",
",",
"$",
"aggregatedValues",
"[",
"'*'",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] | @param array $aggregatedValues
@return NegotiatedValueInterface|null | [
"@param",
"array",
"$aggregatedValues"
] | train | https://github.com/chubbyphp/chubbyphp-negotiation/blob/f4f8a10f2f067ecd868db9177c81f00428c42049/src/AcceptLanguageNegotiator.php#L91-L106 |
chubbyphp/chubbyphp-negotiation | src/AcceptLanguageNegotiator.php | AcceptLanguageNegotiator.exactCompareAgainstSupportedLocales | private function exactCompareAgainstSupportedLocales(array $aggregatedValues)
{
foreach ($aggregatedValues as $locale => $attributes) {
if ('*' === $locale) {
continue;
}
if (in_array($locale, $this->supportedLocales, true)) {
return new NegotiatedValue($locale, $attributes);
}
}
return null;
} | php | private function exactCompareAgainstSupportedLocales(array $aggregatedValues)
{
foreach ($aggregatedValues as $locale => $attributes) {
if ('*' === $locale) {
continue;
}
if (in_array($locale, $this->supportedLocales, true)) {
return new NegotiatedValue($locale, $attributes);
}
}
return null;
} | [
"private",
"function",
"exactCompareAgainstSupportedLocales",
"(",
"array",
"$",
"aggregatedValues",
")",
"{",
"foreach",
"(",
"$",
"aggregatedValues",
"as",
"$",
"locale",
"=>",
"$",
"attributes",
")",
"{",
"if",
"(",
"'*'",
"===",
"$",
"locale",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"locale",
",",
"$",
"this",
"->",
"supportedLocales",
",",
"true",
")",
")",
"{",
"return",
"new",
"NegotiatedValue",
"(",
"$",
"locale",
",",
"$",
"attributes",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | @param array $aggregatedValues
@return NegotiatedValueInterface|null | [
"@param",
"array",
"$aggregatedValues"
] | train | https://github.com/chubbyphp/chubbyphp-negotiation/blob/f4f8a10f2f067ecd868db9177c81f00428c42049/src/AcceptLanguageNegotiator.php#L113-L126 |
chubbyphp/chubbyphp-negotiation | src/AcceptLanguageNegotiator.php | AcceptLanguageNegotiator.languageCompareAgainstSupportedLocales | private function languageCompareAgainstSupportedLocales(array $aggregatedValues)
{
foreach ($aggregatedValues as $locale => $attributes) {
if ('*' === $locale) {
continue;
}
$localeParts = explode('-', $locale);
if (2 !== count($localeParts)) {
continue;
}
$language = $localeParts[0];
if (in_array($language, $this->supportedLocales, true)) {
return new NegotiatedValue($language, $attributes);
}
}
return null;
} | php | private function languageCompareAgainstSupportedLocales(array $aggregatedValues)
{
foreach ($aggregatedValues as $locale => $attributes) {
if ('*' === $locale) {
continue;
}
$localeParts = explode('-', $locale);
if (2 !== count($localeParts)) {
continue;
}
$language = $localeParts[0];
if (in_array($language, $this->supportedLocales, true)) {
return new NegotiatedValue($language, $attributes);
}
}
return null;
} | [
"private",
"function",
"languageCompareAgainstSupportedLocales",
"(",
"array",
"$",
"aggregatedValues",
")",
"{",
"foreach",
"(",
"$",
"aggregatedValues",
"as",
"$",
"locale",
"=>",
"$",
"attributes",
")",
"{",
"if",
"(",
"'*'",
"===",
"$",
"locale",
")",
"{",
"continue",
";",
"}",
"$",
"localeParts",
"=",
"explode",
"(",
"'-'",
",",
"$",
"locale",
")",
";",
"if",
"(",
"2",
"!==",
"count",
"(",
"$",
"localeParts",
")",
")",
"{",
"continue",
";",
"}",
"$",
"language",
"=",
"$",
"localeParts",
"[",
"0",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"language",
",",
"$",
"this",
"->",
"supportedLocales",
",",
"true",
")",
")",
"{",
"return",
"new",
"NegotiatedValue",
"(",
"$",
"language",
",",
"$",
"attributes",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | @param array $aggregatedValues
@return NegotiatedValueInterface|null | [
"@param",
"array",
"$aggregatedValues"
] | train | https://github.com/chubbyphp/chubbyphp-negotiation/blob/f4f8a10f2f067ecd868db9177c81f00428c42049/src/AcceptLanguageNegotiator.php#L133-L153 |
php-lug/lug | src/Component/Behat/Context/FormContext.php | FormContext.assertSelectOptionFound | public function assertSelectOptionFound($field, $option)
{
\PHPUnit_Framework_Assert::assertTrue(
in_array($option, $this->findSelectOptions($field), true),
sprintf('The select option "%s" from the select "%s" does not exist.', $option, $field)
);
} | php | public function assertSelectOptionFound($field, $option)
{
\PHPUnit_Framework_Assert::assertTrue(
in_array($option, $this->findSelectOptions($field), true),
sprintf('The select option "%s" from the select "%s" does not exist.', $option, $field)
);
} | [
"public",
"function",
"assertSelectOptionFound",
"(",
"$",
"field",
",",
"$",
"option",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertTrue",
"(",
"in_array",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"findSelectOptions",
"(",
"$",
"field",
")",
",",
"true",
")",
",",
"sprintf",
"(",
"'The select option \"%s\" from the select \"%s\" does not exist.'",
",",
"$",
"option",
",",
"$",
"field",
")",
")",
";",
"}"
] | @param string $field
@param string $option
@Then the option ":option" from the select ":field" should exist | [
"@param",
"string",
"$field",
"@param",
"string",
"$option"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Behat/Context/FormContext.php#L64-L70 |
php-lug/lug | src/Component/Behat/Context/FormContext.php | FormContext.assertSelectOptionNotFound | public function assertSelectOptionNotFound($field, $option)
{
\PHPUnit_Framework_Assert::assertFalse(
in_array($option, $this->findSelectOptions($field), true),
sprintf('The select option "%s" from the select "%s" exists.', $option, $field)
);
} | php | public function assertSelectOptionNotFound($field, $option)
{
\PHPUnit_Framework_Assert::assertFalse(
in_array($option, $this->findSelectOptions($field), true),
sprintf('The select option "%s" from the select "%s" exists.', $option, $field)
);
} | [
"public",
"function",
"assertSelectOptionNotFound",
"(",
"$",
"field",
",",
"$",
"option",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertFalse",
"(",
"in_array",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"findSelectOptions",
"(",
"$",
"field",
")",
",",
"true",
")",
",",
"sprintf",
"(",
"'The select option \"%s\" from the select \"%s\" exists.'",
",",
"$",
"option",
",",
"$",
"field",
")",
")",
";",
"}"
] | @param string $field
@param string $option
@Then the option ":option" from the select ":field" should not exist | [
"@param",
"string",
"$field",
"@param",
"string",
"$option"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Behat/Context/FormContext.php#L78-L84 |
php-lug/lug | src/Component/Behat/Context/FormContext.php | FormContext.findEmbedField | private function findEmbedField($field)
{
$page = $node = $this->getPage();
$followingSiblingXPath = '/following-sibling::*';
$labelXpathPattern = '//label[contains(text(), "%s")]';
$labels = array_map('trim', explode('->', $field));
foreach ($labels as $label) {
if ($node !== $page) {
$node = $node->find('xpath', $followingSiblingXPath);
}
\PHPUnit_Framework_Assert::assertNotNull(
$node,
$message = sprintf('The field label "%s" could not be found.', $label)
);
$node = $node->find('xpath', sprintf($labelXpathPattern, $label));
\PHPUnit_Framework_Assert::assertNotNull($node, $message);
}
\PHPUnit_Framework_Assert::assertTrue(
$node->hasAttribute('for'),
sprintf('The attribute "for" of the embed field "%s" could not be found.', $field)
);
$field = $page->findById($for = $node->getAttribute('for'));
\PHPUnit_Framework_Assert::assertNotNull(
$field,
sprintf('The embed field "%s" could not be found.', $for)
);
return $field;
} | php | private function findEmbedField($field)
{
$page = $node = $this->getPage();
$followingSiblingXPath = '/following-sibling::*';
$labelXpathPattern = '//label[contains(text(), "%s")]';
$labels = array_map('trim', explode('->', $field));
foreach ($labels as $label) {
if ($node !== $page) {
$node = $node->find('xpath', $followingSiblingXPath);
}
\PHPUnit_Framework_Assert::assertNotNull(
$node,
$message = sprintf('The field label "%s" could not be found.', $label)
);
$node = $node->find('xpath', sprintf($labelXpathPattern, $label));
\PHPUnit_Framework_Assert::assertNotNull($node, $message);
}
\PHPUnit_Framework_Assert::assertTrue(
$node->hasAttribute('for'),
sprintf('The attribute "for" of the embed field "%s" could not be found.', $field)
);
$field = $page->findById($for = $node->getAttribute('for'));
\PHPUnit_Framework_Assert::assertNotNull(
$field,
sprintf('The embed field "%s" could not be found.', $for)
);
return $field;
} | [
"private",
"function",
"findEmbedField",
"(",
"$",
"field",
")",
"{",
"$",
"page",
"=",
"$",
"node",
"=",
"$",
"this",
"->",
"getPage",
"(",
")",
";",
"$",
"followingSiblingXPath",
"=",
"'/following-sibling::*'",
";",
"$",
"labelXpathPattern",
"=",
"'//label[contains(text(), \"%s\")]'",
";",
"$",
"labels",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"'->'",
",",
"$",
"field",
")",
")",
";",
"foreach",
"(",
"$",
"labels",
"as",
"$",
"label",
")",
"{",
"if",
"(",
"$",
"node",
"!==",
"$",
"page",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"find",
"(",
"'xpath'",
",",
"$",
"followingSiblingXPath",
")",
";",
"}",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertNotNull",
"(",
"$",
"node",
",",
"$",
"message",
"=",
"sprintf",
"(",
"'The field label \"%s\" could not be found.'",
",",
"$",
"label",
")",
")",
";",
"$",
"node",
"=",
"$",
"node",
"->",
"find",
"(",
"'xpath'",
",",
"sprintf",
"(",
"$",
"labelXpathPattern",
",",
"$",
"label",
")",
")",
";",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertNotNull",
"(",
"$",
"node",
",",
"$",
"message",
")",
";",
"}",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertTrue",
"(",
"$",
"node",
"->",
"hasAttribute",
"(",
"'for'",
")",
",",
"sprintf",
"(",
"'The attribute \"for\" of the embed field \"%s\" could not be found.'",
",",
"$",
"field",
")",
")",
";",
"$",
"field",
"=",
"$",
"page",
"->",
"findById",
"(",
"$",
"for",
"=",
"$",
"node",
"->",
"getAttribute",
"(",
"'for'",
")",
")",
";",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertNotNull",
"(",
"$",
"field",
",",
"sprintf",
"(",
"'The embed field \"%s\" could not be found.'",
",",
"$",
"for",
")",
")",
";",
"return",
"$",
"field",
";",
"}"
] | @param string $field
@return NodeElement | [
"@param",
"string",
"$field"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Behat/Context/FormContext.php#L122-L158 |
php-lug/lug | src/Component/Behat/Context/FormContext.php | FormContext.findSelectOptions | private function findSelectOptions($field)
{
\PHPUnit_Framework_Assert::assertNotNull(
$select = $this->getPage()->findField($field),
sprintf('The select field "%s" does not exist.', $field)
);
$options = [];
foreach ($select->find('xpath', '/option') as $option) {
$options[] = $option->getValue();
}
return $options;
} | php | private function findSelectOptions($field)
{
\PHPUnit_Framework_Assert::assertNotNull(
$select = $this->getPage()->findField($field),
sprintf('The select field "%s" does not exist.', $field)
);
$options = [];
foreach ($select->find('xpath', '/option') as $option) {
$options[] = $option->getValue();
}
return $options;
} | [
"private",
"function",
"findSelectOptions",
"(",
"$",
"field",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertNotNull",
"(",
"$",
"select",
"=",
"$",
"this",
"->",
"getPage",
"(",
")",
"->",
"findField",
"(",
"$",
"field",
")",
",",
"sprintf",
"(",
"'The select field \"%s\" does not exist.'",
",",
"$",
"field",
")",
")",
";",
"$",
"options",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"select",
"->",
"find",
"(",
"'xpath'",
",",
"'/option'",
")",
"as",
"$",
"option",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"$",
"option",
"->",
"getValue",
"(",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
] | @param $field
@return string[] | [
"@param",
"$field"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Behat/Context/FormContext.php#L165-L179 |
InactiveProjects/limoncello-illuminate | app/Database/Migrations/MigrateComments.php | MigrateComments.apply | public function apply()
{
Schema::create(Model::TABLE_NAME, function (Blueprint $table) {
$table->increments(Model::FIELD_ID);
$table->unsignedInteger(Model::FIELD_ID_USER);
$table->unsignedInteger(Model::FIELD_ID_POST);
$table->text(Model::FIELD_TEXT);
$table->softDeletes();
$table->timestamps();
/** @noinspection PhpUndefinedMethodInspection */
$table->foreign(Model::FIELD_ID_POST)
->references(Post::FIELD_ID)->on(Post::TABLE_NAME)->onDelete('cascade');
/** @noinspection PhpUndefinedMethodInspection */
$table->foreign(Model::FIELD_ID_USER)
->references(User::FIELD_ID)->on(User::TABLE_NAME)->onDelete('cascade');
});
} | php | public function apply()
{
Schema::create(Model::TABLE_NAME, function (Blueprint $table) {
$table->increments(Model::FIELD_ID);
$table->unsignedInteger(Model::FIELD_ID_USER);
$table->unsignedInteger(Model::FIELD_ID_POST);
$table->text(Model::FIELD_TEXT);
$table->softDeletes();
$table->timestamps();
/** @noinspection PhpUndefinedMethodInspection */
$table->foreign(Model::FIELD_ID_POST)
->references(Post::FIELD_ID)->on(Post::TABLE_NAME)->onDelete('cascade');
/** @noinspection PhpUndefinedMethodInspection */
$table->foreign(Model::FIELD_ID_USER)
->references(User::FIELD_ID)->on(User::TABLE_NAME)->onDelete('cascade');
});
} | [
"public",
"function",
"apply",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"Model",
"::",
"TABLE_NAME",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments",
"(",
"Model",
"::",
"FIELD_ID",
")",
";",
"$",
"table",
"->",
"unsignedInteger",
"(",
"Model",
"::",
"FIELD_ID_USER",
")",
";",
"$",
"table",
"->",
"unsignedInteger",
"(",
"Model",
"::",
"FIELD_ID_POST",
")",
";",
"$",
"table",
"->",
"text",
"(",
"Model",
"::",
"FIELD_TEXT",
")",
";",
"$",
"table",
"->",
"softDeletes",
"(",
")",
";",
"$",
"table",
"->",
"timestamps",
"(",
")",
";",
"/** @noinspection PhpUndefinedMethodInspection */",
"$",
"table",
"->",
"foreign",
"(",
"Model",
"::",
"FIELD_ID_POST",
")",
"->",
"references",
"(",
"Post",
"::",
"FIELD_ID",
")",
"->",
"on",
"(",
"Post",
"::",
"TABLE_NAME",
")",
"->",
"onDelete",
"(",
"'cascade'",
")",
";",
"/** @noinspection PhpUndefinedMethodInspection */",
"$",
"table",
"->",
"foreign",
"(",
"Model",
"::",
"FIELD_ID_USER",
")",
"->",
"references",
"(",
"User",
"::",
"FIELD_ID",
")",
"->",
"on",
"(",
"User",
"::",
"TABLE_NAME",
")",
"->",
"onDelete",
"(",
"'cascade'",
")",
";",
"}",
")",
";",
"}"
] | @inheritdoc
@SuppressWarnings(PHPMD.StaticAccess) | [
"@inheritdoc"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Database/Migrations/MigrateComments.php#L18-L36 |
bariew/yii2-i18n-cms-module | models/SourceMessage.php | SourceMessage.categoryList | public static function categoryList()
{
$data = self::find()->orderBy('category')->groupBy(['category'])->select(['category'])->column();
return array_combine($data, $data);
} | php | public static function categoryList()
{
$data = self::find()->orderBy('category')->groupBy(['category'])->select(['category'])->column();
return array_combine($data, $data);
} | [
"public",
"static",
"function",
"categoryList",
"(",
")",
"{",
"$",
"data",
"=",
"self",
"::",
"find",
"(",
")",
"->",
"orderBy",
"(",
"'category'",
")",
"->",
"groupBy",
"(",
"[",
"'category'",
"]",
")",
"->",
"select",
"(",
"[",
"'category'",
"]",
")",
"->",
"column",
"(",
")",
";",
"return",
"array_combine",
"(",
"$",
"data",
",",
"$",
"data",
")",
";",
"}"
] | Gets all used categories list.
@return array source category list | [
"Gets",
"all",
"used",
"categories",
"list",
"."
] | train | https://github.com/bariew/yii2-i18n-cms-module/blob/18d2394565cdd8b5070a287a739c9007705ef18a/models/SourceMessage.php#L91-L95 |
j-d/draggy | src/Draggy/Autocode/Attribute.php | Attribute.isEntitySubtype | public function isEntitySubtype()
{
return $this->getSubtype() !== null && (null === $this->getEntity() || !in_array($this->getSubtype(), array_keys($this->getEntity()->getProject()->getAttributeTypes())));
} | php | public function isEntitySubtype()
{
return $this->getSubtype() !== null && (null === $this->getEntity() || !in_array($this->getSubtype(), array_keys($this->getEntity()->getProject()->getAttributeTypes())));
} | [
"public",
"function",
"isEntitySubtype",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getSubtype",
"(",
")",
"!==",
"null",
"&&",
"(",
"null",
"===",
"$",
"this",
"->",
"getEntity",
"(",
")",
"||",
"!",
"in_array",
"(",
"$",
"this",
"->",
"getSubtype",
"(",
")",
",",
"array_keys",
"(",
"$",
"this",
"->",
"getEntity",
"(",
")",
"->",
"getProject",
"(",
")",
"->",
"getAttributeTypes",
"(",
")",
")",
")",
")",
";",
"}"
] | <user-additions part="otherMethods"> | [
"<user",
"-",
"additions",
"part",
"=",
"otherMethods",
">"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Attribute.php#L189-L192 |
inhere/php-librarys | src/Traits/LiteEventTrait.php | LiteEventTrait.on | public function on($name, callable $cb, $replace = false)
{
if ($replace || !isset($this->_events[$name])) {
$this->_events[$name] = $cb;
}
} | php | public function on($name, callable $cb, $replace = false)
{
if ($replace || !isset($this->_events[$name])) {
$this->_events[$name] = $cb;
}
} | [
"public",
"function",
"on",
"(",
"$",
"name",
",",
"callable",
"$",
"cb",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"replace",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"_events",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_events",
"[",
"$",
"name",
"]",
"=",
"$",
"cb",
";",
"}",
"}"
] | register a event callback
@param string $name event name
@param callable $cb event callback
@param bool $replace replace exists's event cb | [
"register",
"a",
"event",
"callback"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/LiteEventTrait.php#L34-L39 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/InterfaceAssembler.php | InterfaceAssembler.create | public function create($data)
{
$interfaceDescriptor = new InterfaceDescriptor();
$interfaceDescriptor->setFullyQualifiedStructuralElementName($data->getName());
$interfaceDescriptor->setName($data->getShortName());
$interfaceDescriptor->setLine($data->getLinenumber());
$interfaceDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: '');
// Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself
$interfaceDescriptor->setNamespace(
'\\' . (strtolower($data->getNamespace()) == 'global' ? '' :$data->getNamespace())
);
$this->assembleDocBlock($data->getDocBlock(), $interfaceDescriptor);
$this->addConstants($data->getConstants(), $interfaceDescriptor);
$this->addMethods($data->getMethods(), $interfaceDescriptor);
foreach ($data->getParentInterfaces() as $interfaceClassName) {
$interfaceDescriptor->getParent()->set($interfaceClassName, $interfaceClassName);
}
return $interfaceDescriptor;
} | php | public function create($data)
{
$interfaceDescriptor = new InterfaceDescriptor();
$interfaceDescriptor->setFullyQualifiedStructuralElementName($data->getName());
$interfaceDescriptor->setName($data->getShortName());
$interfaceDescriptor->setLine($data->getLinenumber());
$interfaceDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: '');
// Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself
$interfaceDescriptor->setNamespace(
'\\' . (strtolower($data->getNamespace()) == 'global' ? '' :$data->getNamespace())
);
$this->assembleDocBlock($data->getDocBlock(), $interfaceDescriptor);
$this->addConstants($data->getConstants(), $interfaceDescriptor);
$this->addMethods($data->getMethods(), $interfaceDescriptor);
foreach ($data->getParentInterfaces() as $interfaceClassName) {
$interfaceDescriptor->getParent()->set($interfaceClassName, $interfaceClassName);
}
return $interfaceDescriptor;
} | [
"public",
"function",
"create",
"(",
"$",
"data",
")",
"{",
"$",
"interfaceDescriptor",
"=",
"new",
"InterfaceDescriptor",
"(",
")",
";",
"$",
"interfaceDescriptor",
"->",
"setFullyQualifiedStructuralElementName",
"(",
"$",
"data",
"->",
"getName",
"(",
")",
")",
";",
"$",
"interfaceDescriptor",
"->",
"setName",
"(",
"$",
"data",
"->",
"getShortName",
"(",
")",
")",
";",
"$",
"interfaceDescriptor",
"->",
"setLine",
"(",
"$",
"data",
"->",
"getLinenumber",
"(",
")",
")",
";",
"$",
"interfaceDescriptor",
"->",
"setPackage",
"(",
"$",
"this",
"->",
"extractPackageFromDocBlock",
"(",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
")",
"?",
":",
"''",
")",
";",
"// Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself",
"$",
"interfaceDescriptor",
"->",
"setNamespace",
"(",
"'\\\\'",
".",
"(",
"strtolower",
"(",
"$",
"data",
"->",
"getNamespace",
"(",
")",
")",
"==",
"'global'",
"?",
"''",
":",
"$",
"data",
"->",
"getNamespace",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"assembleDocBlock",
"(",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
",",
"$",
"interfaceDescriptor",
")",
";",
"$",
"this",
"->",
"addConstants",
"(",
"$",
"data",
"->",
"getConstants",
"(",
")",
",",
"$",
"interfaceDescriptor",
")",
";",
"$",
"this",
"->",
"addMethods",
"(",
"$",
"data",
"->",
"getMethods",
"(",
")",
",",
"$",
"interfaceDescriptor",
")",
";",
"foreach",
"(",
"$",
"data",
"->",
"getParentInterfaces",
"(",
")",
"as",
"$",
"interfaceClassName",
")",
"{",
"$",
"interfaceDescriptor",
"->",
"getParent",
"(",
")",
"->",
"set",
"(",
"$",
"interfaceClassName",
",",
"$",
"interfaceClassName",
")",
";",
"}",
"return",
"$",
"interfaceDescriptor",
";",
"}"
] | Creates a Descriptor from the provided data.
@param InterfaceReflector $data
@return InterfaceDescriptor | [
"Creates",
"a",
"Descriptor",
"from",
"the",
"provided",
"data",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/InterfaceAssembler.php#L31-L54 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Node.php | Node.iconGetName | public function iconGetName($key)
{
$iconid = ($this[$key] < 0) ? (pow(2, 32))-($this[$key]*-1) : $this[$key];
return new Str("/icon_" . $iconid);
} | php | public function iconGetName($key)
{
$iconid = ($this[$key] < 0) ? (pow(2, 32))-($this[$key]*-1) : $this[$key];
return new Str("/icon_" . $iconid);
} | [
"public",
"function",
"iconGetName",
"(",
"$",
"key",
")",
"{",
"$",
"iconid",
"=",
"(",
"$",
"this",
"[",
"$",
"key",
"]",
"<",
"0",
")",
"?",
"(",
"pow",
"(",
"2",
",",
"32",
")",
")",
"-",
"(",
"$",
"this",
"[",
"$",
"key",
"]",
"*",
"-",
"1",
")",
":",
"$",
"this",
"[",
"$",
"key",
"]",
";",
"return",
"new",
"Str",
"(",
"\"/icon_\"",
".",
"$",
"iconid",
")",
";",
"}"
] | Returns the internal path of the node icon.
@param string $key
@return Str | [
"Returns",
"the",
"internal",
"path",
"of",
"the",
"node",
"icon",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node.php#L145-L150 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Node.php | Node.filterList | protected function filterList(array $nodes = array(), array $rules = array())
{
if(!empty($rules))
{
foreach($nodes as $node)
{
if(!$node instanceof Node) continue;
$props = $node->getInfo(FALSE);
$props = array_intersect_key($props, $rules);
foreach($props as $key => $val)
{
if($val instanceof Str)
{
$match = $val->contains($rules[$key], TRUE);
}
else
{
$match = $val == $rules[$key];
}
if($match === FALSE)
{
unset($nodes[$node->getId()]);
}
}
}
}
return $nodes;
} | php | protected function filterList(array $nodes = array(), array $rules = array())
{
if(!empty($rules))
{
foreach($nodes as $node)
{
if(!$node instanceof Node) continue;
$props = $node->getInfo(FALSE);
$props = array_intersect_key($props, $rules);
foreach($props as $key => $val)
{
if($val instanceof Str)
{
$match = $val->contains($rules[$key], TRUE);
}
else
{
$match = $val == $rules[$key];
}
if($match === FALSE)
{
unset($nodes[$node->getId()]);
}
}
}
}
return $nodes;
} | [
"protected",
"function",
"filterList",
"(",
"array",
"$",
"nodes",
"=",
"array",
"(",
")",
",",
"array",
"$",
"rules",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"rules",
")",
")",
"{",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"!",
"$",
"node",
"instanceof",
"Node",
")",
"continue",
";",
"$",
"props",
"=",
"$",
"node",
"->",
"getInfo",
"(",
"FALSE",
")",
";",
"$",
"props",
"=",
"array_intersect_key",
"(",
"$",
"props",
",",
"$",
"rules",
")",
";",
"foreach",
"(",
"$",
"props",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"instanceof",
"Str",
")",
"{",
"$",
"match",
"=",
"$",
"val",
"->",
"contains",
"(",
"$",
"rules",
"[",
"$",
"key",
"]",
",",
"TRUE",
")",
";",
"}",
"else",
"{",
"$",
"match",
"=",
"$",
"val",
"==",
"$",
"rules",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"$",
"match",
"===",
"FALSE",
")",
"{",
"unset",
"(",
"$",
"nodes",
"[",
"$",
"node",
"->",
"getId",
"(",
")",
"]",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"nodes",
";",
"}"
] | Filters given node list array using specified filter rules.
@param array $nodes
@param array $rules
@return array | [
"Filters",
"given",
"node",
"list",
"array",
"using",
"specified",
"filter",
"rules",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node.php#L234-L265 |
Eresus/EresusCMS | src/core/CMS/Page.php | Eresus_CMS_Page.linkStyles | public function linkStyles($url, $media = '')
{
/* Проверяем, не добавлен ли уже этот URL */
for ($i = 0; $i < count($this->head['link']); $i++)
{
if ($this->head['link'][$i]['href'] == $url)
{
return;
}
}
$item = array('rel' => 'StyleSheet', 'href' => $url, 'type' => 'text/css');
if (!empty($media))
{
$item['media'] = $media;
}
$this->head['link'][] = $item;
} | php | public function linkStyles($url, $media = '')
{
/* Проверяем, не добавлен ли уже этот URL */
for ($i = 0; $i < count($this->head['link']); $i++)
{
if ($this->head['link'][$i]['href'] == $url)
{
return;
}
}
$item = array('rel' => 'StyleSheet', 'href' => $url, 'type' => 'text/css');
if (!empty($media))
{
$item['media'] = $media;
}
$this->head['link'][] = $item;
} | [
"public",
"function",
"linkStyles",
"(",
"$",
"url",
",",
"$",
"media",
"=",
"''",
")",
"{",
"/* Проверяем, не добавлен ли уже этот URL */",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"head",
"[",
"'link'",
"]",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"head",
"[",
"'link'",
"]",
"[",
"$",
"i",
"]",
"[",
"'href'",
"]",
"==",
"$",
"url",
")",
"{",
"return",
";",
"}",
"}",
"$",
"item",
"=",
"array",
"(",
"'rel'",
"=>",
"'StyleSheet'",
",",
"'href'",
"=>",
"$",
"url",
",",
"'type'",
"=>",
"'text/css'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"media",
")",
")",
"{",
"$",
"item",
"[",
"'media'",
"]",
"=",
"$",
"media",
";",
"}",
"$",
"this",
"->",
"head",
"[",
"'link'",
"]",
"[",
"]",
"=",
"$",
"item",
";",
"}"
] | Подключение CSS-файла
@param string $url URL файла
@param string $media Тип носителя
@since 2.10 | [
"Подключение",
"CSS",
"-",
"файла"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS/Page.php#L251-L270 |
Eresus/EresusCMS | src/core/CMS/Page.php | Eresus_CMS_Page.addStyles | public function addStyles($content, $media = '')
{
$content = preg_replace(array('/^(\s)+/m', '/^(\S)/m'), array(' ', ' \1'), $content);
$content = rtrim($content);
$item = array('content' => $content);
if (!empty($media))
{
$item['media'] = $media;
}
$this->head['style'][] = $item;
} | php | public function addStyles($content, $media = '')
{
$content = preg_replace(array('/^(\s)+/m', '/^(\S)/m'), array(' ', ' \1'), $content);
$content = rtrim($content);
$item = array('content' => $content);
if (!empty($media))
{
$item['media'] = $media;
}
$this->head['style'][] = $item;
} | [
"public",
"function",
"addStyles",
"(",
"$",
"content",
",",
"$",
"media",
"=",
"''",
")",
"{",
"$",
"content",
"=",
"preg_replace",
"(",
"array",
"(",
"'/^(\\s)+/m'",
",",
"'/^(\\S)/m'",
")",
",",
"array",
"(",
"'\t\t'",
",",
"'\t\\1'",
")",
",",
"$",
"content",
")",
";",
"$",
"content",
"=",
"rtrim",
"(",
"$",
"content",
")",
";",
"$",
"item",
"=",
"array",
"(",
"'content'",
"=>",
"$",
"content",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"media",
")",
")",
"{",
"$",
"item",
"[",
"'media'",
"]",
"=",
"$",
"media",
";",
"}",
"$",
"this",
"->",
"head",
"[",
"'style'",
"]",
"[",
"]",
"=",
"$",
"item",
";",
"}"
] | Встраивание CSS
@param string $content Стили CSS
@param string $media Тип носителя
@since 2.10 | [
"Встраивание",
"CSS"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS/Page.php#L280-L290 |
Eresus/EresusCMS | src/core/CMS/Page.php | Eresus_CMS_Page.linkScripts | public function linkScripts($url)
{
foreach ($this->head['scripts'] as $script)
{
/** @var HtmlScriptElement $script */
if ($script->getAttribute('src') == $url)
{
return;
}
}
foreach ($this->head['jslibs'] as $script)
{
if ($script->getAttribute('src') == $url)
{
return;
}
}
$script = new HtmlScriptElement($url);
$args = func_get_args();
// Отбрасываем $url
array_shift($args);
$top = false;
$lib = false;
foreach ($args as $arg)
{
switch (strtolower($arg))
{
case 'ecma':
case 'text/ecmascript':
$script->setAttribute('type', 'text/ecmascript');
break;
case 'javascript':
case 'text/javascript':
$script->setAttribute('type', 'text/javascript');
break;
case 'jscript':
case 'text/jscript':
$script->setAttribute('type', 'text/jscript');
break;
case 'vbscript':
case 'text/vbscript':
$script->setAttribute('type', 'text/vbscript');
break;
case 'async':
case 'defer':
$script->setAttribute($arg);
break;
case 'top':
$top = true;
break;
case 'lib':
$lib = true;
break;
}
}
if ($script->getAttribute('defer'))
{
$this->body['scripts'][] = $script;
}
else
{
if ($lib)
{
$this->head['jslibs'][] = $script;
}
elseif ($top)
{
array_unshift($this->head['scripts'], $script);
}
else
{
$this->head['scripts'][] = $script;
}
}
} | php | public function linkScripts($url)
{
foreach ($this->head['scripts'] as $script)
{
/** @var HtmlScriptElement $script */
if ($script->getAttribute('src') == $url)
{
return;
}
}
foreach ($this->head['jslibs'] as $script)
{
if ($script->getAttribute('src') == $url)
{
return;
}
}
$script = new HtmlScriptElement($url);
$args = func_get_args();
// Отбрасываем $url
array_shift($args);
$top = false;
$lib = false;
foreach ($args as $arg)
{
switch (strtolower($arg))
{
case 'ecma':
case 'text/ecmascript':
$script->setAttribute('type', 'text/ecmascript');
break;
case 'javascript':
case 'text/javascript':
$script->setAttribute('type', 'text/javascript');
break;
case 'jscript':
case 'text/jscript':
$script->setAttribute('type', 'text/jscript');
break;
case 'vbscript':
case 'text/vbscript':
$script->setAttribute('type', 'text/vbscript');
break;
case 'async':
case 'defer':
$script->setAttribute($arg);
break;
case 'top':
$top = true;
break;
case 'lib':
$lib = true;
break;
}
}
if ($script->getAttribute('defer'))
{
$this->body['scripts'][] = $script;
}
else
{
if ($lib)
{
$this->head['jslibs'][] = $script;
}
elseif ($top)
{
array_unshift($this->head['scripts'], $script);
}
else
{
$this->head['scripts'][] = $script;
}
}
} | [
"public",
"function",
"linkScripts",
"(",
"$",
"url",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"head",
"[",
"'scripts'",
"]",
"as",
"$",
"script",
")",
"{",
"/** @var HtmlScriptElement $script */",
"if",
"(",
"$",
"script",
"->",
"getAttribute",
"(",
"'src'",
")",
"==",
"$",
"url",
")",
"{",
"return",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"head",
"[",
"'jslibs'",
"]",
"as",
"$",
"script",
")",
"{",
"if",
"(",
"$",
"script",
"->",
"getAttribute",
"(",
"'src'",
")",
"==",
"$",
"url",
")",
"{",
"return",
";",
"}",
"}",
"$",
"script",
"=",
"new",
"HtmlScriptElement",
"(",
"$",
"url",
")",
";",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"// Отбрасываем $url",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"top",
"=",
"false",
";",
"$",
"lib",
"=",
"false",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"arg",
")",
")",
"{",
"case",
"'ecma'",
":",
"case",
"'text/ecmascript'",
":",
"$",
"script",
"->",
"setAttribute",
"(",
"'type'",
",",
"'text/ecmascript'",
")",
";",
"break",
";",
"case",
"'javascript'",
":",
"case",
"'text/javascript'",
":",
"$",
"script",
"->",
"setAttribute",
"(",
"'type'",
",",
"'text/javascript'",
")",
";",
"break",
";",
"case",
"'jscript'",
":",
"case",
"'text/jscript'",
":",
"$",
"script",
"->",
"setAttribute",
"(",
"'type'",
",",
"'text/jscript'",
")",
";",
"break",
";",
"case",
"'vbscript'",
":",
"case",
"'text/vbscript'",
":",
"$",
"script",
"->",
"setAttribute",
"(",
"'type'",
",",
"'text/vbscript'",
")",
";",
"break",
";",
"case",
"'async'",
":",
"case",
"'defer'",
":",
"$",
"script",
"->",
"setAttribute",
"(",
"$",
"arg",
")",
";",
"break",
";",
"case",
"'top'",
":",
"$",
"top",
"=",
"true",
";",
"break",
";",
"case",
"'lib'",
":",
"$",
"lib",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"script",
"->",
"getAttribute",
"(",
"'defer'",
")",
")",
"{",
"$",
"this",
"->",
"body",
"[",
"'scripts'",
"]",
"[",
"]",
"=",
"$",
"script",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"lib",
")",
"{",
"$",
"this",
"->",
"head",
"[",
"'jslibs'",
"]",
"[",
"]",
"=",
"$",
"script",
";",
"}",
"elseif",
"(",
"$",
"top",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"head",
"[",
"'scripts'",
"]",
",",
"$",
"script",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"head",
"[",
"'scripts'",
"]",
"[",
"]",
"=",
"$",
"script",
";",
"}",
"}",
"}"
] | Подключение клиентского скрипта
В качестве дополнительных параметров метод может принимать:
<b>Типы скриптов</b>
- ecma, text/ecmascript
- javascript, text/javascript
- jscript, text/jscript
- vbscript, text/vbscript
<b>Параметры загрузки скриптов</b>
- async
- defer
- top
Если скрипту передан параметр defer, то скрипт будет подключён в конце документа, перед
</body>, в противном случае он будет подключён в <head>.
Если передан аргумент «top», то скрипт будет подключен в самом начале блока скриптов.
@param string $url URL скрипта
@param string ... Дополнительные параметры
@since 2.10 | [
"Подключение",
"клиентского",
"скрипта"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS/Page.php#L318-L397 |
Eresus/EresusCMS | src/core/CMS/Page.php | Eresus_CMS_Page.addScripts | public function addScripts($code)
{
$script = new HtmlScriptElement($code);
$args = func_get_args();
// Отбрасываем $code
array_shift($args);
// По умолчанию помещаем скрипты в <head>
$body = false;
foreach ($args as $arg)
{
switch (strtolower($arg))
{
case 'ecma':
case 'text/ecmascript':
$script->setAttribute('type', 'text/ecmascript');
break;
case 'javascript':
case 'text/javascript':
$script->setAttribute('type', 'text/javascript');
break;
case 'jscript':
case 'text/jscript':
$script->setAttribute('type', 'text/jscript');
break;
case 'vbscript':
case 'text/vbscript':
$script->setAttribute('type', 'text/vbscript');
break;
case 'body':
$body = true;
break;
}
}
if ($body)
{
$this->body['scripts'][] = $script;
}
else
{
$this->head['scripts'][] = $script;
}
} | php | public function addScripts($code)
{
$script = new HtmlScriptElement($code);
$args = func_get_args();
// Отбрасываем $code
array_shift($args);
// По умолчанию помещаем скрипты в <head>
$body = false;
foreach ($args as $arg)
{
switch (strtolower($arg))
{
case 'ecma':
case 'text/ecmascript':
$script->setAttribute('type', 'text/ecmascript');
break;
case 'javascript':
case 'text/javascript':
$script->setAttribute('type', 'text/javascript');
break;
case 'jscript':
case 'text/jscript':
$script->setAttribute('type', 'text/jscript');
break;
case 'vbscript':
case 'text/vbscript':
$script->setAttribute('type', 'text/vbscript');
break;
case 'body':
$body = true;
break;
}
}
if ($body)
{
$this->body['scripts'][] = $script;
}
else
{
$this->head['scripts'][] = $script;
}
} | [
"public",
"function",
"addScripts",
"(",
"$",
"code",
")",
"{",
"$",
"script",
"=",
"new",
"HtmlScriptElement",
"(",
"$",
"code",
")",
";",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"// Отбрасываем $code",
"array_shift",
"(",
"$",
"args",
")",
";",
"// По умолчанию помещаем скрипты в <head>",
"$",
"body",
"=",
"false",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"arg",
")",
")",
"{",
"case",
"'ecma'",
":",
"case",
"'text/ecmascript'",
":",
"$",
"script",
"->",
"setAttribute",
"(",
"'type'",
",",
"'text/ecmascript'",
")",
";",
"break",
";",
"case",
"'javascript'",
":",
"case",
"'text/javascript'",
":",
"$",
"script",
"->",
"setAttribute",
"(",
"'type'",
",",
"'text/javascript'",
")",
";",
"break",
";",
"case",
"'jscript'",
":",
"case",
"'text/jscript'",
":",
"$",
"script",
"->",
"setAttribute",
"(",
"'type'",
",",
"'text/jscript'",
")",
";",
"break",
";",
"case",
"'vbscript'",
":",
"case",
"'text/vbscript'",
":",
"$",
"script",
"->",
"setAttribute",
"(",
"'type'",
",",
"'text/vbscript'",
")",
";",
"break",
";",
"case",
"'body'",
":",
"$",
"body",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"body",
")",
"{",
"$",
"this",
"->",
"body",
"[",
"'scripts'",
"]",
"[",
"]",
"=",
"$",
"script",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"head",
"[",
"'scripts'",
"]",
"[",
"]",
"=",
"$",
"script",
";",
"}",
"}"
] | Встраивает в страницу клиентские скрипты
<b>Типы скриптов</b>
- ecma, text/ecmascript
- javascript, text/javascript
- jscript, text/jscript
- vbscript, text/vbscript
<b>Параметры загрузки скриптов</b>
- head - вставить в секцию <head> (по умолчанию)
- body - вставить в секцию <body>
@param string $code Код скрипта
@param string ... Дополнительные параметры
@since 2.10 | [
"Встраивает",
"в",
"страницу",
"клиентские",
"скрипты"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS/Page.php#L417-L462 |
Eresus/EresusCMS | src/core/CMS/Page.php | Eresus_CMS_Page.linkJsLib | public function linkJsLib($library)
{
$args = func_get_args();
array_shift($args);
$root = Eresus_CMS::getLegacyKernel()->root;
switch ($library)
{
case 'jquery':
$this->linkScripts($root . 'core/jquery/jquery.min.js', 'lib');
if (in_array('cookie', $args))
{
$this->linkScripts($root . 'core/jquery/jquery.cookie.js', 'lib');
}
if (in_array('ui', $args))
{
$this->linkScripts($root . 'core/jquery/jquery-ui.min.js', 'lib');
}
break;
case 'modernizr':
$this->linkScripts($root . 'core/js/modernizr/modernizr.min.js', 'lib');
break;
case 'webshim':
case 'webshims':
$this->linkJsLib('jquery');
$this->linkJsLib('modernizr');
$this->linkScripts($root . 'core/js/webshim/polyfiller.js', 'lib');
$this->addScripts('jQuery.webshims.polyfill();');
break;
}
} | php | public function linkJsLib($library)
{
$args = func_get_args();
array_shift($args);
$root = Eresus_CMS::getLegacyKernel()->root;
switch ($library)
{
case 'jquery':
$this->linkScripts($root . 'core/jquery/jquery.min.js', 'lib');
if (in_array('cookie', $args))
{
$this->linkScripts($root . 'core/jquery/jquery.cookie.js', 'lib');
}
if (in_array('ui', $args))
{
$this->linkScripts($root . 'core/jquery/jquery-ui.min.js', 'lib');
}
break;
case 'modernizr':
$this->linkScripts($root . 'core/js/modernizr/modernizr.min.js', 'lib');
break;
case 'webshim':
case 'webshims':
$this->linkJsLib('jquery');
$this->linkJsLib('modernizr');
$this->linkScripts($root . 'core/js/webshim/polyfiller.js', 'lib');
$this->addScripts('jQuery.webshims.polyfill();');
break;
}
} | [
"public",
"function",
"linkJsLib",
"(",
"$",
"library",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"root",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
";",
"switch",
"(",
"$",
"library",
")",
"{",
"case",
"'jquery'",
":",
"$",
"this",
"->",
"linkScripts",
"(",
"$",
"root",
".",
"'core/jquery/jquery.min.js'",
",",
"'lib'",
")",
";",
"if",
"(",
"in_array",
"(",
"'cookie'",
",",
"$",
"args",
")",
")",
"{",
"$",
"this",
"->",
"linkScripts",
"(",
"$",
"root",
".",
"'core/jquery/jquery.cookie.js'",
",",
"'lib'",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"'ui'",
",",
"$",
"args",
")",
")",
"{",
"$",
"this",
"->",
"linkScripts",
"(",
"$",
"root",
".",
"'core/jquery/jquery-ui.min.js'",
",",
"'lib'",
")",
";",
"}",
"break",
";",
"case",
"'modernizr'",
":",
"$",
"this",
"->",
"linkScripts",
"(",
"$",
"root",
".",
"'core/js/modernizr/modernizr.min.js'",
",",
"'lib'",
")",
";",
"break",
";",
"case",
"'webshim'",
":",
"case",
"'webshims'",
":",
"$",
"this",
"->",
"linkJsLib",
"(",
"'jquery'",
")",
";",
"$",
"this",
"->",
"linkJsLib",
"(",
"'modernizr'",
")",
";",
"$",
"this",
"->",
"linkScripts",
"(",
"$",
"root",
".",
"'core/js/webshim/polyfiller.js'",
",",
"'lib'",
")",
";",
"$",
"this",
"->",
"addScripts",
"(",
"'jQuery.webshims.polyfill();'",
")",
";",
"break",
";",
"}",
"}"
] | Подключает библиотеку JavaScript
При множественном вызове метода, библиотека будет подключена только один раз.
Доступные библиотеки:
- jquery — {@link http://jquery.com/ jQuery}
- modernizr — {@link http://modernizr.com/ Modernizr}
- webshim — {@link http://afarkas.github.com/webshim/demos/ Webshim}
- webshims — устаревший синоним для webshim
Аргументы для библиотеки jquery:
- ui — jQuery UI
- cookie — jQuery.Cookie
@param string $library имя библиотеки
@param ... дополнительные аргументы
@return void
@since 2.16 | [
"Подключает",
"библиотеку",
"JavaScript"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS/Page.php#L488-L517 |
Eresus/EresusCMS | src/core/CMS/Page.php | Eresus_CMS_Page.renderHeadSection | public function renderHeadSection()
{
$result = array();
/* <meta> теги */
if (count($this->head['meta-http']))
{
foreach ($this->head['meta-http'] as $key => $value)
{
$result[] = ' <meta http-equiv="' . $key . '" content="' . $value . '" />';
}
}
if (count($this->head['meta-tags']))
{
foreach ($this->head['meta-tags'] as $key => $value)
{
$result[] = ' <meta name="' . $key . '" content="' . $value . '" />';
}
}
/* <link> */
if (count($this->head['link']))
{
foreach ($this->head['link'] as $value)
{
$result[] = ' <link rel="' . $value['rel'] . '" href="' . $value['href'] . '" type="' .
$value['type'] . '"' . (isset($value['media']) ? ' media="' . $value['media'] . '"' : '') . ' />';
}
}
/*
* <script>
*/
foreach ($this->head['jslibs'] as $script)
{
/** @var HtmlScriptElement $script */
$result[] = $script->getHTML();
}
foreach ($this->head['scripts'] as $script)
{
/** @var HtmlScriptElement $script */
$result[] = $script->getHTML();
}
/* <style> */
if (count($this->head['style']))
{
foreach ($this->head['style'] as $value)
{
$result[] = ' <style type="text/css"' . (isset($value['media']) ? ' media="' .
$value['media'] . '"' : '') . '>' . "\n" . $value['content'] . "\n </style>";
}
}
$this->head['content'] = trim($this->head['content']);
if (!empty($this->head['content']))
{
$result[] = $this->head['content'];
}
$result = implode("\n", $result);
return $result;
} | php | public function renderHeadSection()
{
$result = array();
/* <meta> теги */
if (count($this->head['meta-http']))
{
foreach ($this->head['meta-http'] as $key => $value)
{
$result[] = ' <meta http-equiv="' . $key . '" content="' . $value . '" />';
}
}
if (count($this->head['meta-tags']))
{
foreach ($this->head['meta-tags'] as $key => $value)
{
$result[] = ' <meta name="' . $key . '" content="' . $value . '" />';
}
}
/* <link> */
if (count($this->head['link']))
{
foreach ($this->head['link'] as $value)
{
$result[] = ' <link rel="' . $value['rel'] . '" href="' . $value['href'] . '" type="' .
$value['type'] . '"' . (isset($value['media']) ? ' media="' . $value['media'] . '"' : '') . ' />';
}
}
/*
* <script>
*/
foreach ($this->head['jslibs'] as $script)
{
/** @var HtmlScriptElement $script */
$result[] = $script->getHTML();
}
foreach ($this->head['scripts'] as $script)
{
/** @var HtmlScriptElement $script */
$result[] = $script->getHTML();
}
/* <style> */
if (count($this->head['style']))
{
foreach ($this->head['style'] as $value)
{
$result[] = ' <style type="text/css"' . (isset($value['media']) ? ' media="' .
$value['media'] . '"' : '') . '>' . "\n" . $value['content'] . "\n </style>";
}
}
$this->head['content'] = trim($this->head['content']);
if (!empty($this->head['content']))
{
$result[] = $this->head['content'];
}
$result = implode("\n", $result);
return $result;
} | [
"public",
"function",
"renderHeadSection",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"/* <meta> теги */",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"head",
"[",
"'meta-http'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"head",
"[",
"'meta-http'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"'\t<meta http-equiv=\"'",
".",
"$",
"key",
".",
"'\" content=\"'",
".",
"$",
"value",
".",
"'\" />'",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"head",
"[",
"'meta-tags'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"head",
"[",
"'meta-tags'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"'\t<meta name=\"'",
".",
"$",
"key",
".",
"'\" content=\"'",
".",
"$",
"value",
".",
"'\" />'",
";",
"}",
"}",
"/* <link> */",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"head",
"[",
"'link'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"head",
"[",
"'link'",
"]",
"as",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"'\t<link rel=\"'",
".",
"$",
"value",
"[",
"'rel'",
"]",
".",
"'\" href=\"'",
".",
"$",
"value",
"[",
"'href'",
"]",
".",
"'\" type=\"'",
".",
"$",
"value",
"[",
"'type'",
"]",
".",
"'\"'",
".",
"(",
"isset",
"(",
"$",
"value",
"[",
"'media'",
"]",
")",
"?",
"' media=\"'",
".",
"$",
"value",
"[",
"'media'",
"]",
".",
"'\"'",
":",
"''",
")",
".",
"' />'",
";",
"}",
"}",
"/*\n * <script>\n */",
"foreach",
"(",
"$",
"this",
"->",
"head",
"[",
"'jslibs'",
"]",
"as",
"$",
"script",
")",
"{",
"/** @var HtmlScriptElement $script */",
"$",
"result",
"[",
"]",
"=",
"$",
"script",
"->",
"getHTML",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"head",
"[",
"'scripts'",
"]",
"as",
"$",
"script",
")",
"{",
"/** @var HtmlScriptElement $script */",
"$",
"result",
"[",
"]",
"=",
"$",
"script",
"->",
"getHTML",
"(",
")",
";",
"}",
"/* <style> */",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"head",
"[",
"'style'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"head",
"[",
"'style'",
"]",
"as",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"'\t<style type=\"text/css\"'",
".",
"(",
"isset",
"(",
"$",
"value",
"[",
"'media'",
"]",
")",
"?",
"' media=\"'",
".",
"$",
"value",
"[",
"'media'",
"]",
".",
"'\"'",
":",
"''",
")",
".",
"'>'",
".",
"\"\\n\"",
".",
"$",
"value",
"[",
"'content'",
"]",
".",
"\"\\n </style>\"",
";",
"}",
"}",
"$",
"this",
"->",
"head",
"[",
"'content'",
"]",
"=",
"trim",
"(",
"$",
"this",
"->",
"head",
"[",
"'content'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"head",
"[",
"'content'",
"]",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"head",
"[",
"'content'",
"]",
";",
"}",
"$",
"result",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Отрисовка секции <head>
@return string Отрисованная секция <head> | [
"Отрисовка",
"секции",
"<head",
">"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS/Page.php#L524-L586 |
Eresus/EresusCMS | src/core/CMS/Page.php | Eresus_CMS_Page.renderBodySection | protected function renderBodySection()
{
$result = array();
/*
* <script>
*/
foreach ($this->body['scripts'] as $script)
{
/** @var HtmlScriptElement $script */
$result[] = $script->getHTML();
}
$result = implode("\n", $result);
return $result;
} | php | protected function renderBodySection()
{
$result = array();
/*
* <script>
*/
foreach ($this->body['scripts'] as $script)
{
/** @var HtmlScriptElement $script */
$result[] = $script->getHTML();
}
$result = implode("\n", $result);
return $result;
} | [
"protected",
"function",
"renderBodySection",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"/*\n * <script>\n */",
"foreach",
"(",
"$",
"this",
"->",
"body",
"[",
"'scripts'",
"]",
"as",
"$",
"script",
")",
"{",
"/** @var HtmlScriptElement $script */",
"$",
"result",
"[",
"]",
"=",
"$",
"script",
"->",
"getHTML",
"(",
")",
";",
"}",
"$",
"result",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Отрисовка секции <body>
@return string HTML | [
"Отрисовка",
"секции",
"<body",
">"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS/Page.php#L593-L607 |
thelia-modules/CustomerGroup | Model/CustomerQuery.php | CustomerQuery.addCustomerGroupsFilter | public static function addCustomerGroupsFilter(ModelCriteria $query, array $customerGroups)
{
if (!is_array($customerGroups) || empty($customerGroups)) {
return $query;
}
$query
// join to customer_customer_group
->addJoin(
CustomerTableMap::ID,
CustomerCustomerGroupTableMap::CUSTOMER_ID,
Criteria::LEFT_JOIN
)
// then join to customer_group
->addJoin(
CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID,
CustomerGroupTableMap::ID,
Criteria::LEFT_JOIN
);
// build the condition for each group
$groupConditionsNames = [];
foreach ($customerGroups as $customerGroup) {
$conditionName = 'condition_customer_group_' . $customerGroup;
$query->condition(
$conditionName,
CustomerGroupTableMap::CODE . Criteria::EQUAL . "?",
$customerGroup,
\PDO::PARAM_STR
);
$groupConditionsNames[] = $conditionName;
}
// add the group conditions
if (!empty($groupConditionsNames)) {
$query->where($groupConditionsNames, Criteria::LOGICAL_OR);
}
return $query;
} | php | public static function addCustomerGroupsFilter(ModelCriteria $query, array $customerGroups)
{
if (!is_array($customerGroups) || empty($customerGroups)) {
return $query;
}
$query
// join to customer_customer_group
->addJoin(
CustomerTableMap::ID,
CustomerCustomerGroupTableMap::CUSTOMER_ID,
Criteria::LEFT_JOIN
)
// then join to customer_group
->addJoin(
CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID,
CustomerGroupTableMap::ID,
Criteria::LEFT_JOIN
);
// build the condition for each group
$groupConditionsNames = [];
foreach ($customerGroups as $customerGroup) {
$conditionName = 'condition_customer_group_' . $customerGroup;
$query->condition(
$conditionName,
CustomerGroupTableMap::CODE . Criteria::EQUAL . "?",
$customerGroup,
\PDO::PARAM_STR
);
$groupConditionsNames[] = $conditionName;
}
// add the group conditions
if (!empty($groupConditionsNames)) {
$query->where($groupConditionsNames, Criteria::LOGICAL_OR);
}
return $query;
} | [
"public",
"static",
"function",
"addCustomerGroupsFilter",
"(",
"ModelCriteria",
"$",
"query",
",",
"array",
"$",
"customerGroups",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"customerGroups",
")",
"||",
"empty",
"(",
"$",
"customerGroups",
")",
")",
"{",
"return",
"$",
"query",
";",
"}",
"$",
"query",
"// join to customer_customer_group",
"->",
"addJoin",
"(",
"CustomerTableMap",
"::",
"ID",
",",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_ID",
",",
"Criteria",
"::",
"LEFT_JOIN",
")",
"// then join to customer_group",
"->",
"addJoin",
"(",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_GROUP_ID",
",",
"CustomerGroupTableMap",
"::",
"ID",
",",
"Criteria",
"::",
"LEFT_JOIN",
")",
";",
"// build the condition for each group",
"$",
"groupConditionsNames",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"customerGroups",
"as",
"$",
"customerGroup",
")",
"{",
"$",
"conditionName",
"=",
"'condition_customer_group_'",
".",
"$",
"customerGroup",
";",
"$",
"query",
"->",
"condition",
"(",
"$",
"conditionName",
",",
"CustomerGroupTableMap",
"::",
"CODE",
".",
"Criteria",
"::",
"EQUAL",
".",
"\"?\"",
",",
"$",
"customerGroup",
",",
"\\",
"PDO",
"::",
"PARAM_STR",
")",
";",
"$",
"groupConditionsNames",
"[",
"]",
"=",
"$",
"conditionName",
";",
"}",
"// add the group conditions",
"if",
"(",
"!",
"empty",
"(",
"$",
"groupConditionsNames",
")",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"groupConditionsNames",
",",
"Criteria",
"::",
"LOGICAL_OR",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] | Filter the query by customer groups.
@param ModelCriteria $query The query to filter.
@param array $customerGroups An array of customer groups codes.
@return ModelCriteria The query. | [
"Filter",
"the",
"query",
"by",
"customer",
"groups",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/CustomerQuery.php#L48-L89 |
mothership-ec/composer | src/Composer/Autoload/AutoloadGenerator.php | AutoloadGenerator.createLoader | public function createLoader(array $autoloads)
{
$loader = new ClassLoader();
if (isset($autoloads['psr-0'])) {
foreach ($autoloads['psr-0'] as $namespace => $path) {
$loader->add($namespace, $path);
}
}
if (isset($autoloads['psr-4'])) {
foreach ($autoloads['psr-4'] as $namespace => $path) {
$loader->addPsr4($namespace, $path);
}
}
return $loader;
} | php | public function createLoader(array $autoloads)
{
$loader = new ClassLoader();
if (isset($autoloads['psr-0'])) {
foreach ($autoloads['psr-0'] as $namespace => $path) {
$loader->add($namespace, $path);
}
}
if (isset($autoloads['psr-4'])) {
foreach ($autoloads['psr-4'] as $namespace => $path) {
$loader->addPsr4($namespace, $path);
}
}
return $loader;
} | [
"public",
"function",
"createLoader",
"(",
"array",
"$",
"autoloads",
")",
"{",
"$",
"loader",
"=",
"new",
"ClassLoader",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"autoloads",
"[",
"'psr-0'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"autoloads",
"[",
"'psr-0'",
"]",
"as",
"$",
"namespace",
"=>",
"$",
"path",
")",
"{",
"$",
"loader",
"->",
"add",
"(",
"$",
"namespace",
",",
"$",
"path",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"autoloads",
"[",
"'psr-4'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"autoloads",
"[",
"'psr-4'",
"]",
"as",
"$",
"namespace",
"=>",
"$",
"path",
")",
"{",
"$",
"loader",
"->",
"addPsr4",
"(",
"$",
"namespace",
",",
"$",
"path",
")",
";",
"}",
"}",
"return",
"$",
"loader",
";",
"}"
] | Registers an autoloader based on an autoload map returned by parseAutoloads
@param array $autoloads see parseAutoloads return value
@return ClassLoader | [
"Registers",
"an",
"autoloader",
"based",
"on",
"an",
"autoload",
"map",
"returned",
"by",
"parseAutoloads"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Autoload/AutoloadGenerator.php#L328-L345 |
mothership-ec/composer | src/Composer/Repository/Vcs/SvnDriver.php | SvnDriver.getComposerInformation | public function getComposerInformation($identifier)
{
$identifier = '/' . trim($identifier, '/') . '/';
if ($res = $this->cache->read($identifier.'.json')) {
$this->infoCache[$identifier] = JsonFile::parseJson($res);
}
if (!isset($this->infoCache[$identifier])) {
preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
if (!empty($match[2])) {
$path = $match[1];
$rev = $match[2];
} else {
$path = $identifier;
$rev = '';
}
try {
$resource = $path.'composer.json';
$output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
if (!trim($output)) {
return;
}
} catch (\RuntimeException $e) {
throw new TransportException($e->getMessage());
}
$composer = JsonFile::parseJson($output, $this->baseUrl . $resource . $rev);
if (empty($composer['time'])) {
$output = $this->execute('svn info', $this->baseUrl . $path . $rev);
foreach ($this->process->splitLines($output) as $line) {
if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {
$date = new \DateTime($match[1], new \DateTimeZone('UTC'));
$composer['time'] = $date->format('Y-m-d H:i:s');
break;
}
}
}
$this->cache->write($identifier.'.json', json_encode($composer));
$this->infoCache[$identifier] = $composer;
}
return $this->infoCache[$identifier];
} | php | public function getComposerInformation($identifier)
{
$identifier = '/' . trim($identifier, '/') . '/';
if ($res = $this->cache->read($identifier.'.json')) {
$this->infoCache[$identifier] = JsonFile::parseJson($res);
}
if (!isset($this->infoCache[$identifier])) {
preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
if (!empty($match[2])) {
$path = $match[1];
$rev = $match[2];
} else {
$path = $identifier;
$rev = '';
}
try {
$resource = $path.'composer.json';
$output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
if (!trim($output)) {
return;
}
} catch (\RuntimeException $e) {
throw new TransportException($e->getMessage());
}
$composer = JsonFile::parseJson($output, $this->baseUrl . $resource . $rev);
if (empty($composer['time'])) {
$output = $this->execute('svn info', $this->baseUrl . $path . $rev);
foreach ($this->process->splitLines($output) as $line) {
if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {
$date = new \DateTime($match[1], new \DateTimeZone('UTC'));
$composer['time'] = $date->format('Y-m-d H:i:s');
break;
}
}
}
$this->cache->write($identifier.'.json', json_encode($composer));
$this->infoCache[$identifier] = $composer;
}
return $this->infoCache[$identifier];
} | [
"public",
"function",
"getComposerInformation",
"(",
"$",
"identifier",
")",
"{",
"$",
"identifier",
"=",
"'/'",
".",
"trim",
"(",
"$",
"identifier",
",",
"'/'",
")",
".",
"'/'",
";",
"if",
"(",
"$",
"res",
"=",
"$",
"this",
"->",
"cache",
"->",
"read",
"(",
"$",
"identifier",
".",
"'.json'",
")",
")",
"{",
"$",
"this",
"->",
"infoCache",
"[",
"$",
"identifier",
"]",
"=",
"JsonFile",
"::",
"parseJson",
"(",
"$",
"res",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"infoCache",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"preg_match",
"(",
"'{^(.+?)(@\\d+)?/$}'",
",",
"$",
"identifier",
",",
"$",
"match",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"match",
"[",
"2",
"]",
")",
")",
"{",
"$",
"path",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"$",
"rev",
"=",
"$",
"match",
"[",
"2",
"]",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"$",
"identifier",
";",
"$",
"rev",
"=",
"''",
";",
"}",
"try",
"{",
"$",
"resource",
"=",
"$",
"path",
".",
"'composer.json'",
";",
"$",
"output",
"=",
"$",
"this",
"->",
"execute",
"(",
"'svn cat'",
",",
"$",
"this",
"->",
"baseUrl",
".",
"$",
"resource",
".",
"$",
"rev",
")",
";",
"if",
"(",
"!",
"trim",
"(",
"$",
"output",
")",
")",
"{",
"return",
";",
"}",
"}",
"catch",
"(",
"\\",
"RuntimeException",
"$",
"e",
")",
"{",
"throw",
"new",
"TransportException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"composer",
"=",
"JsonFile",
"::",
"parseJson",
"(",
"$",
"output",
",",
"$",
"this",
"->",
"baseUrl",
".",
"$",
"resource",
".",
"$",
"rev",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"composer",
"[",
"'time'",
"]",
")",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"execute",
"(",
"'svn info'",
",",
"$",
"this",
"->",
"baseUrl",
".",
"$",
"path",
".",
"$",
"rev",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"process",
"->",
"splitLines",
"(",
"$",
"output",
")",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"line",
"&&",
"preg_match",
"(",
"'{^Last Changed Date: ([^(]+)}'",
",",
"$",
"line",
",",
"$",
"match",
")",
")",
"{",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"match",
"[",
"1",
"]",
",",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"$",
"composer",
"[",
"'time'",
"]",
"=",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"break",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"cache",
"->",
"write",
"(",
"$",
"identifier",
".",
"'.json'",
",",
"json_encode",
"(",
"$",
"composer",
")",
")",
";",
"$",
"this",
"->",
"infoCache",
"[",
"$",
"identifier",
"]",
"=",
"$",
"composer",
";",
"}",
"return",
"$",
"this",
"->",
"infoCache",
"[",
"$",
"identifier",
"]",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/SvnDriver.php#L121-L167 |
soda-framework/eloquent-closure | src/Franzose/ClosureTable/Generators/Migration.php | Migration.create | public function create(array $options)
{
$paths = [];
$entityClass = $this->getClassName($options['entity-table']);
$closureClass = $this->getClassName($options['closure-table']);
$useInnoDB = $options['use-innodb'];
$stubPrefix = $useInnoDB ? '-innodb' : '';
$paths[] = $path = $this->getPath($options['entity-table'], $options['migrations-path']);
$stub = $this->getStub('entity' . $stubPrefix, 'migrations');
$this->filesystem->put($path, $this->parseStub($stub, [
'entity_table' => $options['entity-table'],
'entity_class' => $entityClass
]));
$paths[] = $path = $this->getPath($options['closure-table'], $options['migrations-path']);
$stub = $this->getStub('closuretable' . $stubPrefix, 'migrations');
$this->filesystem->put($path, $this->parseStub($stub, [
'closure_table' => $options['closure-table'],
'closure_class' => $closureClass,
'entity_table' => $options['entity-table']
]));
return $paths;
} | php | public function create(array $options)
{
$paths = [];
$entityClass = $this->getClassName($options['entity-table']);
$closureClass = $this->getClassName($options['closure-table']);
$useInnoDB = $options['use-innodb'];
$stubPrefix = $useInnoDB ? '-innodb' : '';
$paths[] = $path = $this->getPath($options['entity-table'], $options['migrations-path']);
$stub = $this->getStub('entity' . $stubPrefix, 'migrations');
$this->filesystem->put($path, $this->parseStub($stub, [
'entity_table' => $options['entity-table'],
'entity_class' => $entityClass
]));
$paths[] = $path = $this->getPath($options['closure-table'], $options['migrations-path']);
$stub = $this->getStub('closuretable' . $stubPrefix, 'migrations');
$this->filesystem->put($path, $this->parseStub($stub, [
'closure_table' => $options['closure-table'],
'closure_class' => $closureClass,
'entity_table' => $options['entity-table']
]));
return $paths;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"paths",
"=",
"[",
"]",
";",
"$",
"entityClass",
"=",
"$",
"this",
"->",
"getClassName",
"(",
"$",
"options",
"[",
"'entity-table'",
"]",
")",
";",
"$",
"closureClass",
"=",
"$",
"this",
"->",
"getClassName",
"(",
"$",
"options",
"[",
"'closure-table'",
"]",
")",
";",
"$",
"useInnoDB",
"=",
"$",
"options",
"[",
"'use-innodb'",
"]",
";",
"$",
"stubPrefix",
"=",
"$",
"useInnoDB",
"?",
"'-innodb'",
":",
"''",
";",
"$",
"paths",
"[",
"]",
"=",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"options",
"[",
"'entity-table'",
"]",
",",
"$",
"options",
"[",
"'migrations-path'",
"]",
")",
";",
"$",
"stub",
"=",
"$",
"this",
"->",
"getStub",
"(",
"'entity'",
".",
"$",
"stubPrefix",
",",
"'migrations'",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"put",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"parseStub",
"(",
"$",
"stub",
",",
"[",
"'entity_table'",
"=>",
"$",
"options",
"[",
"'entity-table'",
"]",
",",
"'entity_class'",
"=>",
"$",
"entityClass",
"]",
")",
")",
";",
"$",
"paths",
"[",
"]",
"=",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"options",
"[",
"'closure-table'",
"]",
",",
"$",
"options",
"[",
"'migrations-path'",
"]",
")",
";",
"$",
"stub",
"=",
"$",
"this",
"->",
"getStub",
"(",
"'closuretable'",
".",
"$",
"stubPrefix",
",",
"'migrations'",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"put",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"parseStub",
"(",
"$",
"stub",
",",
"[",
"'closure_table'",
"=>",
"$",
"options",
"[",
"'closure-table'",
"]",
",",
"'closure_class'",
"=>",
"$",
"closureClass",
",",
"'entity_table'",
"=>",
"$",
"options",
"[",
"'entity-table'",
"]",
"]",
")",
")",
";",
"return",
"$",
"paths",
";",
"}"
] | Creates migration files.
@param array $options
@return array | [
"Creates",
"migration",
"files",
"."
] | train | https://github.com/soda-framework/eloquent-closure/blob/0747773b476c3e15f599b97977261c51503d2f00/src/Franzose/ClosureTable/Generators/Migration.php#L25-L52 |
soda-framework/eloquent-closure | src/Franzose/ClosureTable/Generators/Migration.php | Migration.getPath | protected function getPath($name, $path)
{
$timestamp = Carbon::now();
if (in_array($timestamp, $this->usedTimestamps)) {
$timestamp->addSecond();
}
$this->usedTimestamps[] = $timestamp;
return $path . '/' . $timestamp->format('Y_m_d_His') . '_' . $this->getName($name) . '.php';
} | php | protected function getPath($name, $path)
{
$timestamp = Carbon::now();
if (in_array($timestamp, $this->usedTimestamps)) {
$timestamp->addSecond();
}
$this->usedTimestamps[] = $timestamp;
return $path . '/' . $timestamp->format('Y_m_d_His') . '_' . $this->getName($name) . '.php';
} | [
"protected",
"function",
"getPath",
"(",
"$",
"name",
",",
"$",
"path",
")",
"{",
"$",
"timestamp",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"timestamp",
",",
"$",
"this",
"->",
"usedTimestamps",
")",
")",
"{",
"$",
"timestamp",
"->",
"addSecond",
"(",
")",
";",
"}",
"$",
"this",
"->",
"usedTimestamps",
"[",
"]",
"=",
"$",
"timestamp",
";",
"return",
"$",
"path",
".",
"'/'",
".",
"$",
"timestamp",
"->",
"format",
"(",
"'Y_m_d_His'",
")",
".",
"'_'",
".",
"$",
"this",
"->",
"getName",
"(",
"$",
"name",
")",
".",
"'.php'",
";",
"}"
] | Constructs path to migration file in Laravel style.
@param $name
@param $path
@return string | [
"Constructs",
"path",
"to",
"migration",
"file",
"in",
"Laravel",
"style",
"."
] | train | https://github.com/soda-framework/eloquent-closure/blob/0747773b476c3e15f599b97977261c51503d2f00/src/Franzose/ClosureTable/Generators/Migration.php#L83-L93 |
kiwi-suite/frontend42 | src/Block/Service/BlockAbstractFactory.php | BlockAbstractFactory.canCreate | public function canCreate(ContainerInterface $container, $requestedName)
{
/** @var BlockPluginManager $blockPluginManager */
$blockPluginManager = $container->get(BlockPluginManager::class);
$blocks = $blockPluginManager->getAvailableBlocks();
return in_array($requestedName, $blocks);
} | php | public function canCreate(ContainerInterface $container, $requestedName)
{
/** @var BlockPluginManager $blockPluginManager */
$blockPluginManager = $container->get(BlockPluginManager::class);
$blocks = $blockPluginManager->getAvailableBlocks();
return in_array($requestedName, $blocks);
} | [
"public",
"function",
"canCreate",
"(",
"ContainerInterface",
"$",
"container",
",",
"$",
"requestedName",
")",
"{",
"/** @var BlockPluginManager $blockPluginManager */",
"$",
"blockPluginManager",
"=",
"$",
"container",
"->",
"get",
"(",
"BlockPluginManager",
"::",
"class",
")",
";",
"$",
"blocks",
"=",
"$",
"blockPluginManager",
"->",
"getAvailableBlocks",
"(",
")",
";",
"return",
"in_array",
"(",
"$",
"requestedName",
",",
"$",
"blocks",
")",
";",
"}"
] | Can the factory create an instance for the service?
@param ContainerInterface $container
@param string $requestedName
@return bool | [
"Can",
"the",
"factory",
"create",
"an",
"instance",
"for",
"the",
"service?"
] | train | https://github.com/kiwi-suite/frontend42/blob/67e5208387957823ac84f7833eba83d4a8dab8cd/src/Block/Service/BlockAbstractFactory.php#L21-L28 |
expectation-php/expect | src/matcher/ToHaveLength.php | ToHaveLength.match | public function match($actual)
{
$this->actual = $actual;
if (is_string($this->actual)) {
$this->type = 'string';
$this->length = mb_strlen($this->actual);
} elseif (is_array($this->actual)) {
$this->type = 'array';
$this->length = count($this->actual);
} elseif ($this->actual instanceof Countable) {
$this->type = get_class($this->actual);
$this->length = count($this->actual);
}
return ($this->length === $this->expected);
} | php | public function match($actual)
{
$this->actual = $actual;
if (is_string($this->actual)) {
$this->type = 'string';
$this->length = mb_strlen($this->actual);
} elseif (is_array($this->actual)) {
$this->type = 'array';
$this->length = count($this->actual);
} elseif ($this->actual instanceof Countable) {
$this->type = get_class($this->actual);
$this->length = count($this->actual);
}
return ($this->length === $this->expected);
} | [
"public",
"function",
"match",
"(",
"$",
"actual",
")",
"{",
"$",
"this",
"->",
"actual",
"=",
"$",
"actual",
";",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"actual",
")",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"'string'",
";",
"$",
"this",
"->",
"length",
"=",
"mb_strlen",
"(",
"$",
"this",
"->",
"actual",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"this",
"->",
"actual",
")",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"'array'",
";",
"$",
"this",
"->",
"length",
"=",
"count",
"(",
"$",
"this",
"->",
"actual",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"actual",
"instanceof",
"Countable",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"get_class",
"(",
"$",
"this",
"->",
"actual",
")",
";",
"$",
"this",
"->",
"length",
"=",
"count",
"(",
"$",
"this",
"->",
"actual",
")",
";",
"}",
"return",
"(",
"$",
"this",
"->",
"length",
"===",
"$",
"this",
"->",
"expected",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToHaveLength.php#L66-L82 |
expectation-php/expect | src/matcher/ToHaveLength.php | ToHaveLength.reportFailed | public function reportFailed(FailedMessage $message)
{
$message->appendText('Expected ')
->appendText($this->type)
->appendText(' to have a length of ')
->appendText($this->expected)
->appendText("\n\n")
->appendText(' expected: ')
->appendValue($this->expected)
->appendText("\n")
->appendText(' length: ')
->appendValue($this->length);
} | php | public function reportFailed(FailedMessage $message)
{
$message->appendText('Expected ')
->appendText($this->type)
->appendText(' to have a length of ')
->appendText($this->expected)
->appendText("\n\n")
->appendText(' expected: ')
->appendValue($this->expected)
->appendText("\n")
->appendText(' length: ')
->appendValue($this->length);
} | [
"public",
"function",
"reportFailed",
"(",
"FailedMessage",
"$",
"message",
")",
"{",
"$",
"message",
"->",
"appendText",
"(",
"'Expected '",
")",
"->",
"appendText",
"(",
"$",
"this",
"->",
"type",
")",
"->",
"appendText",
"(",
"' to have a length of '",
")",
"->",
"appendText",
"(",
"$",
"this",
"->",
"expected",
")",
"->",
"appendText",
"(",
"\"\\n\\n\"",
")",
"->",
"appendText",
"(",
"' expected: '",
")",
"->",
"appendValue",
"(",
"$",
"this",
"->",
"expected",
")",
"->",
"appendText",
"(",
"\"\\n\"",
")",
"->",
"appendText",
"(",
"' length: '",
")",
"->",
"appendValue",
"(",
"$",
"this",
"->",
"length",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToHaveLength.php#L87-L99 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php | ProjectDescriptorBuilder.buildDescriptor | public function buildDescriptor($data)
{
$assembler = $this->getAssembler($data);
if (!$assembler) {
throw new \InvalidArgumentException(
'Unable to build a Descriptor; the provided data did not match any Assembler '. get_class($data)
);
}
if ($assembler instanceof Builder\AssemblerAbstract) {
$assembler->setBuilder($this);
}
// create Descriptor and populate with the provided data
$descriptor = $assembler->create($data);
if (!$descriptor) {
return null;
}
$descriptor = (!is_array($descriptor) && (!$descriptor instanceof Collection))
? $this->filterAndValidateDescriptor($descriptor)
: $this->filterAndValidateEachDescriptor($descriptor);
return $descriptor;
} | php | public function buildDescriptor($data)
{
$assembler = $this->getAssembler($data);
if (!$assembler) {
throw new \InvalidArgumentException(
'Unable to build a Descriptor; the provided data did not match any Assembler '. get_class($data)
);
}
if ($assembler instanceof Builder\AssemblerAbstract) {
$assembler->setBuilder($this);
}
// create Descriptor and populate with the provided data
$descriptor = $assembler->create($data);
if (!$descriptor) {
return null;
}
$descriptor = (!is_array($descriptor) && (!$descriptor instanceof Collection))
? $this->filterAndValidateDescriptor($descriptor)
: $this->filterAndValidateEachDescriptor($descriptor);
return $descriptor;
} | [
"public",
"function",
"buildDescriptor",
"(",
"$",
"data",
")",
"{",
"$",
"assembler",
"=",
"$",
"this",
"->",
"getAssembler",
"(",
"$",
"data",
")",
";",
"if",
"(",
"!",
"$",
"assembler",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unable to build a Descriptor; the provided data did not match any Assembler '",
".",
"get_class",
"(",
"$",
"data",
")",
")",
";",
"}",
"if",
"(",
"$",
"assembler",
"instanceof",
"Builder",
"\\",
"AssemblerAbstract",
")",
"{",
"$",
"assembler",
"->",
"setBuilder",
"(",
"$",
"this",
")",
";",
"}",
"// create Descriptor and populate with the provided data",
"$",
"descriptor",
"=",
"$",
"assembler",
"->",
"create",
"(",
"$",
"data",
")",
";",
"if",
"(",
"!",
"$",
"descriptor",
")",
"{",
"return",
"null",
";",
"}",
"$",
"descriptor",
"=",
"(",
"!",
"is_array",
"(",
"$",
"descriptor",
")",
"&&",
"(",
"!",
"$",
"descriptor",
"instanceof",
"Collection",
")",
")",
"?",
"$",
"this",
"->",
"filterAndValidateDescriptor",
"(",
"$",
"descriptor",
")",
":",
"$",
"this",
"->",
"filterAndValidateEachDescriptor",
"(",
"$",
"descriptor",
")",
";",
"return",
"$",
"descriptor",
";",
"}"
] | Takes the given data and attempts to build a Descriptor from it.
@param mixed $data
@throws \InvalidArgumentException if no Assembler could be found that matches the given data.
@return DescriptorAbstract|Collection|null | [
"Takes",
"the",
"given",
"data",
"and",
"attempts",
"to",
"build",
"a",
"Descriptor",
"from",
"it",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php#L128-L152 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php | ProjectDescriptorBuilder.validate | public function validate($descriptor)
{
$violations = $this->validator->validate($descriptor);
$errors = new Collection();
/** @var ConstraintViolation $violation */
foreach ($violations as $violation) {
$errors->add(
new Error(
$this->mapCodeToSeverity($violation->getCode()),
$violation->getMessageTemplate(),
$descriptor->getLine(),
$violation->getMessageParameters() + array($descriptor->getFullyQualifiedStructuralElementName())
)
);
}
return $errors;
} | php | public function validate($descriptor)
{
$violations = $this->validator->validate($descriptor);
$errors = new Collection();
/** @var ConstraintViolation $violation */
foreach ($violations as $violation) {
$errors->add(
new Error(
$this->mapCodeToSeverity($violation->getCode()),
$violation->getMessageTemplate(),
$descriptor->getLine(),
$violation->getMessageParameters() + array($descriptor->getFullyQualifiedStructuralElementName())
)
);
}
return $errors;
} | [
"public",
"function",
"validate",
"(",
"$",
"descriptor",
")",
"{",
"$",
"violations",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"$",
"descriptor",
")",
";",
"$",
"errors",
"=",
"new",
"Collection",
"(",
")",
";",
"/** @var ConstraintViolation $violation */",
"foreach",
"(",
"$",
"violations",
"as",
"$",
"violation",
")",
"{",
"$",
"errors",
"->",
"add",
"(",
"new",
"Error",
"(",
"$",
"this",
"->",
"mapCodeToSeverity",
"(",
"$",
"violation",
"->",
"getCode",
"(",
")",
")",
",",
"$",
"violation",
"->",
"getMessageTemplate",
"(",
")",
",",
"$",
"descriptor",
"->",
"getLine",
"(",
")",
",",
"$",
"violation",
"->",
"getMessageParameters",
"(",
")",
"+",
"array",
"(",
"$",
"descriptor",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"$",
"errors",
";",
"}"
] | Validates the contents of the Descriptor and outputs warnings and error if something is amiss.
@param DescriptorAbstract $descriptor
@return Collection | [
"Validates",
"the",
"contents",
"of",
"the",
"Descriptor",
"and",
"outputs",
"warnings",
"and",
"error",
"if",
"something",
"is",
"amiss",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php#L185-L203 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.