id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
11,200 | FrenzelGmbH/appcommon | components/DbFixtureManager.php | DbFixtureManager.checkIntegrity | public function checkIntegrity($check)
{
$db=$this->getDbConnection();
foreach($this->schemas as $schema){
$db->createCommand()->checkIntegrity($check,$schema)->execute();
}
} | php | public function checkIntegrity($check)
{
$db=$this->getDbConnection();
foreach($this->schemas as $schema){
$db->createCommand()->checkIntegrity($check,$schema)->execute();
}
} | [
"public",
"function",
"checkIntegrity",
"(",
"$",
"check",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"getDbConnection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"schemas",
"as",
"$",
"schema",
")",
"{",
"$",
"db",
"->",
"createCommand",
"(",
")",
"->",
"checkIntegrity",
"(",
"$",
"check",
",",
"$",
"schema",
")",
"->",
"execute",
"(",
")",
";",
"}",
"}"
] | Enables or disables database integrity check.
This method may be used to temporarily turn off foreign constraints check.
@param boolean $check whether to enable database integrity check | [
"Enables",
"or",
"disables",
"database",
"integrity",
"check",
".",
"This",
"method",
"may",
"be",
"used",
"to",
"temporarily",
"turn",
"off",
"foreign",
"constraints",
"check",
"."
] | d6d137b4c92b53832ce4b2e517644ed9fb545b7a | https://github.com/FrenzelGmbH/appcommon/blob/d6d137b4c92b53832ce4b2e517644ed9fb545b7a/components/DbFixtureManager.php#L243-L249 |
11,201 | FrenzelGmbH/appcommon | components/DbFixtureManager.php | DbFixtureManager.getRows | public function getRows($name)
{
if(isset($this->_rows[$name]))
return $this->_rows[$name];
else
return false;
} | php | public function getRows($name)
{
if(isset($this->_rows[$name]))
return $this->_rows[$name];
else
return false;
} | [
"public",
"function",
"getRows",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_rows",
"[",
"$",
"name",
"]",
")",
")",
"return",
"$",
"this",
"->",
"_rows",
"[",
"$",
"name",
"]",
";",
"else",
"return",
"false",
";",
"}"
] | Returns the fixture data rows.
The rows will have updated primary key values if the primary key is auto-incremental.
@param string $name the fixture name
@return array the fixture data rows. False is returned if there is no such fixture data. | [
"Returns",
"the",
"fixture",
"data",
"rows",
".",
"The",
"rows",
"will",
"have",
"updated",
"primary",
"key",
"values",
"if",
"the",
"primary",
"key",
"is",
"auto",
"-",
"incremental",
"."
] | d6d137b4c92b53832ce4b2e517644ed9fb545b7a | https://github.com/FrenzelGmbH/appcommon/blob/d6d137b4c92b53832ce4b2e517644ed9fb545b7a/components/DbFixtureManager.php#L343-L349 |
11,202 | FrenzelGmbH/appcommon | components/DbFixtureManager.php | DbFixtureManager.getRecord | public function getRecord($name,$alias)
{
if(isset($this->_records[$name][$alias]))
{
if(is_string($this->_records[$name][$alias]))
{
$row=$this->_rows[$name][$alias];
$model=ActiveRecord::model($this->_records[$name][$alias]);
$key=$model->getRawTableNameSchema()->primaryKey;
if(is_string($key))
$pk=$row[$key];
else
{
foreach($key as $k)
$pk[$k]=$row[$k];
}
$this->_records[$name][$alias]=$model->find($pk);
}
return $this->_records[$name][$alias];
}
else
return false;
} | php | public function getRecord($name,$alias)
{
if(isset($this->_records[$name][$alias]))
{
if(is_string($this->_records[$name][$alias]))
{
$row=$this->_rows[$name][$alias];
$model=ActiveRecord::model($this->_records[$name][$alias]);
$key=$model->getRawTableNameSchema()->primaryKey;
if(is_string($key))
$pk=$row[$key];
else
{
foreach($key as $k)
$pk[$k]=$row[$k];
}
$this->_records[$name][$alias]=$model->find($pk);
}
return $this->_records[$name][$alias];
}
else
return false;
} | [
"public",
"function",
"getRecord",
"(",
"$",
"name",
",",
"$",
"alias",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_records",
"[",
"$",
"name",
"]",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"_records",
"[",
"$",
"name",
"]",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"_rows",
"[",
"$",
"name",
"]",
"[",
"$",
"alias",
"]",
";",
"$",
"model",
"=",
"ActiveRecord",
"::",
"model",
"(",
"$",
"this",
"->",
"_records",
"[",
"$",
"name",
"]",
"[",
"$",
"alias",
"]",
")",
";",
"$",
"key",
"=",
"$",
"model",
"->",
"getRawTableNameSchema",
"(",
")",
"->",
"primaryKey",
";",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"$",
"pk",
"=",
"$",
"row",
"[",
"$",
"key",
"]",
";",
"else",
"{",
"foreach",
"(",
"$",
"key",
"as",
"$",
"k",
")",
"$",
"pk",
"[",
"$",
"k",
"]",
"=",
"$",
"row",
"[",
"$",
"k",
"]",
";",
"}",
"$",
"this",
"->",
"_records",
"[",
"$",
"name",
"]",
"[",
"$",
"alias",
"]",
"=",
"$",
"model",
"->",
"find",
"(",
"$",
"pk",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_records",
"[",
"$",
"name",
"]",
"[",
"$",
"alias",
"]",
";",
"}",
"else",
"return",
"false",
";",
"}"
] | Returns the specified ActiveRecord instance in the fixture data.
@param string $name the fixture name
@param string $alias the alias for the fixture data row
@return ActiveRecord the ActiveRecord instance. False is returned if there is no such fixture row. | [
"Returns",
"the",
"specified",
"ActiveRecord",
"instance",
"in",
"the",
"fixture",
"data",
"."
] | d6d137b4c92b53832ce4b2e517644ed9fb545b7a | https://github.com/FrenzelGmbH/appcommon/blob/d6d137b4c92b53832ce4b2e517644ed9fb545b7a/components/DbFixtureManager.php#L357-L379 |
11,203 | ciims/cii | models/CiiSettingsForm.php | CiiSettingsForm.init | public function init()
{
// Use Reflection::getProperties(PROTECTED) to get protected properties from the passed model
$reflection = new ReflectionClass($this->model);
$this->properties = $reflection->getProperties(ReflectionProperty::IS_PROTECTED);
return parent::init();
} | php | public function init()
{
// Use Reflection::getProperties(PROTECTED) to get protected properties from the passed model
$reflection = new ReflectionClass($this->model);
$this->properties = $reflection->getProperties(ReflectionProperty::IS_PROTECTED);
return parent::init();
} | [
"public",
"function",
"init",
"(",
")",
"{",
"// Use Reflection::getProperties(PROTECTED) to get protected properties from the passed model",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"this",
"->",
"model",
")",
";",
"$",
"this",
"->",
"properties",
"=",
"$",
"reflection",
"->",
"getProperties",
"(",
"ReflectionProperty",
"::",
"IS_PROTECTED",
")",
";",
"return",
"parent",
"::",
"init",
"(",
")",
";",
"}"
] | Widget init function
@see CActiveForm init() | [
"Widget",
"init",
"function"
] | cc8550b9a3a6a0bf0214554679de8743d50dc9ef | https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/models/CiiSettingsForm.php#L49-L56 |
11,204 | ciims/cii | models/CiiSettingsForm.php | CiiSettingsForm.run | public function run()
{
// Setup the form
$form = $this->beginWidget('cii.widgets.CiiActiveForm', array(
'id'=>get_class($this->model),
'enableAjaxValidation'=>true,
'action' => $this->action,
'htmlOptions' => array(
'class' => 'pure-form pure-form-aligned'
)
));
// Main Content
$this->renderMain($form);
// Close the form
$this->endWidget();
} | php | public function run()
{
// Setup the form
$form = $this->beginWidget('cii.widgets.CiiActiveForm', array(
'id'=>get_class($this->model),
'enableAjaxValidation'=>true,
'action' => $this->action,
'htmlOptions' => array(
'class' => 'pure-form pure-form-aligned'
)
));
// Main Content
$this->renderMain($form);
// Close the form
$this->endWidget();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"// Setup the form",
"$",
"form",
"=",
"$",
"this",
"->",
"beginWidget",
"(",
"'cii.widgets.CiiActiveForm'",
",",
"array",
"(",
"'id'",
"=>",
"get_class",
"(",
"$",
"this",
"->",
"model",
")",
",",
"'enableAjaxValidation'",
"=>",
"true",
",",
"'action'",
"=>",
"$",
"this",
"->",
"action",
",",
"'htmlOptions'",
"=>",
"array",
"(",
"'class'",
"=>",
"'pure-form pure-form-aligned'",
")",
")",
")",
";",
"// Main Content",
"$",
"this",
"->",
"renderMain",
"(",
"$",
"form",
")",
";",
"// Close the form",
"$",
"this",
"->",
"endWidget",
"(",
")",
";",
"}"
] | The following is run when the widget is called | [
"The",
"following",
"is",
"run",
"when",
"the",
"widget",
"is",
"called"
] | cc8550b9a3a6a0bf0214554679de8743d50dc9ef | https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/models/CiiSettingsForm.php#L61-L79 |
11,205 | ciims/cii | models/CiiSettingsForm.php | CiiSettingsForm.renderMain | private function renderMain($form)
{
// #main .content
echo CHtml::openTag('div', array('id' => 'main', 'class' => 'nano'));
echo CHtml::openTag('div', array('class' => 'nano-content'));
echo CHtml::openTag('fieldset');
// If we want a custom form view, render that view instead of the default behavior
if ($this->model->form !== NULL)
$this->controller->renderPartial($this->model->form, array('model' => $this->model, 'properties' => $this->properties, 'form' => $form));
else if (count($this->properties) == 0)
{
echo CHtml::tag('legend', array(), Yii::t('Dashboard.main', 'Change Theme Settings'));
echo CHtml::tag('div', array('class' => 'alert alert-info'), Yii::t('Dashboard.main', 'There are no settings for this section.'));
}
else
{
$groups = $this->model->groups();
if (!empty($groups))
{
foreach ($groups as $name=>$attributes)
{
echo CHtml::tag('legend', array(), $name);
echo CHtml::tag('div', array('class' => 'clearfix'), NULL);
foreach ($attributes as $property)
{
$p = new StdClass();
$p->name = $property;
$this->renderProperties($form, $p);
}
}
}
else
{
echo CHtml::tag('legend', array(), CiiInflector::titleize(get_class($this->model)));
foreach ($this->properties as $property)
{
$this->renderProperties($form, $property);
}
}
}
echo CHtml::closeTag('div');
echo CHtml::closeTag('div');
echo CHtml::closeTag('div');
} | php | private function renderMain($form)
{
// #main .content
echo CHtml::openTag('div', array('id' => 'main', 'class' => 'nano'));
echo CHtml::openTag('div', array('class' => 'nano-content'));
echo CHtml::openTag('fieldset');
// If we want a custom form view, render that view instead of the default behavior
if ($this->model->form !== NULL)
$this->controller->renderPartial($this->model->form, array('model' => $this->model, 'properties' => $this->properties, 'form' => $form));
else if (count($this->properties) == 0)
{
echo CHtml::tag('legend', array(), Yii::t('Dashboard.main', 'Change Theme Settings'));
echo CHtml::tag('div', array('class' => 'alert alert-info'), Yii::t('Dashboard.main', 'There are no settings for this section.'));
}
else
{
$groups = $this->model->groups();
if (!empty($groups))
{
foreach ($groups as $name=>$attributes)
{
echo CHtml::tag('legend', array(), $name);
echo CHtml::tag('div', array('class' => 'clearfix'), NULL);
foreach ($attributes as $property)
{
$p = new StdClass();
$p->name = $property;
$this->renderProperties($form, $p);
}
}
}
else
{
echo CHtml::tag('legend', array(), CiiInflector::titleize(get_class($this->model)));
foreach ($this->properties as $property)
{
$this->renderProperties($form, $property);
}
}
}
echo CHtml::closeTag('div');
echo CHtml::closeTag('div');
echo CHtml::closeTag('div');
} | [
"private",
"function",
"renderMain",
"(",
"$",
"form",
")",
"{",
"// #main .content",
"echo",
"CHtml",
"::",
"openTag",
"(",
"'div'",
",",
"array",
"(",
"'id'",
"=>",
"'main'",
",",
"'class'",
"=>",
"'nano'",
")",
")",
";",
"echo",
"CHtml",
"::",
"openTag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'nano-content'",
")",
")",
";",
"echo",
"CHtml",
"::",
"openTag",
"(",
"'fieldset'",
")",
";",
"// If we want a custom form view, render that view instead of the default behavior",
"if",
"(",
"$",
"this",
"->",
"model",
"->",
"form",
"!==",
"NULL",
")",
"$",
"this",
"->",
"controller",
"->",
"renderPartial",
"(",
"$",
"this",
"->",
"model",
"->",
"form",
",",
"array",
"(",
"'model'",
"=>",
"$",
"this",
"->",
"model",
",",
"'properties'",
"=>",
"$",
"this",
"->",
"properties",
",",
"'form'",
"=>",
"$",
"form",
")",
")",
";",
"else",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"properties",
")",
"==",
"0",
")",
"{",
"echo",
"CHtml",
"::",
"tag",
"(",
"'legend'",
",",
"array",
"(",
")",
",",
"Yii",
"::",
"t",
"(",
"'Dashboard.main'",
",",
"'Change Theme Settings'",
")",
")",
";",
"echo",
"CHtml",
"::",
"tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'alert alert-info'",
")",
",",
"Yii",
"::",
"t",
"(",
"'Dashboard.main'",
",",
"'There are no settings for this section.'",
")",
")",
";",
"}",
"else",
"{",
"$",
"groups",
"=",
"$",
"this",
"->",
"model",
"->",
"groups",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"groups",
")",
")",
"{",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"name",
"=>",
"$",
"attributes",
")",
"{",
"echo",
"CHtml",
"::",
"tag",
"(",
"'legend'",
",",
"array",
"(",
")",
",",
"$",
"name",
")",
";",
"echo",
"CHtml",
"::",
"tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'clearfix'",
")",
",",
"NULL",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"property",
")",
"{",
"$",
"p",
"=",
"new",
"StdClass",
"(",
")",
";",
"$",
"p",
"->",
"name",
"=",
"$",
"property",
";",
"$",
"this",
"->",
"renderProperties",
"(",
"$",
"form",
",",
"$",
"p",
")",
";",
"}",
"}",
"}",
"else",
"{",
"echo",
"CHtml",
"::",
"tag",
"(",
"'legend'",
",",
"array",
"(",
")",
",",
"CiiInflector",
"::",
"titleize",
"(",
"get_class",
"(",
"$",
"this",
"->",
"model",
")",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"properties",
"as",
"$",
"property",
")",
"{",
"$",
"this",
"->",
"renderProperties",
"(",
"$",
"form",
",",
"$",
"property",
")",
";",
"}",
"}",
"}",
"echo",
"CHtml",
"::",
"closeTag",
"(",
"'div'",
")",
";",
"echo",
"CHtml",
"::",
"closeTag",
"(",
"'div'",
")",
";",
"echo",
"CHtml",
"::",
"closeTag",
"(",
"'div'",
")",
";",
"}"
] | Renders the main body content
@param CActiveForm $form The Form we're working with | [
"Renders",
"the",
"main",
"body",
"content"
] | cc8550b9a3a6a0bf0214554679de8743d50dc9ef | https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/models/CiiSettingsForm.php#L85-L132 |
11,206 | ciims/cii | models/CiiSettingsForm.php | CiiSettingsForm.renderProperties | private function renderProperties(&$form, $property)
{
$htmlOptions = array(
'class' => 'pure-input-2-3'
);
$validators = $this->model->getValidators($property->name);
$stringValidators = $this->model->getStringValidator($property->name, $validators);
if (in_array('required', $stringValidators))
$htmlOptions['required'] = true;
echo CHtml::openTag('div', array('class' => 'pure-control-group'));
if (in_array('boolean', $stringValidators))
$form->toggleButtonRow($this->model, $property->name, $htmlOptions, $validators);
else if (in_array('number', $stringValidators) && isset($validators[0]->max) && isset($validators[0]->min))
$form->rangeFieldRow($this->model, $property->name, $htmlOptions, $validators);
else if (in_array('number', $stringValidators) && (isset($validators[0]->max) || isset($validators[0]->min)))
$form->numberFieldRow($this->model, $property->name, $htmlOptions, $validators);
else if (in_array('password', $stringValidators))
echo $form->passwordFieldRow($this->model, $property->name, $htmlOptions, $validators);
else
echo $form->textFieldRow($this->model, $property->name, $htmlOptions, $validators);
echo CHtml::closeTag('div');
} | php | private function renderProperties(&$form, $property)
{
$htmlOptions = array(
'class' => 'pure-input-2-3'
);
$validators = $this->model->getValidators($property->name);
$stringValidators = $this->model->getStringValidator($property->name, $validators);
if (in_array('required', $stringValidators))
$htmlOptions['required'] = true;
echo CHtml::openTag('div', array('class' => 'pure-control-group'));
if (in_array('boolean', $stringValidators))
$form->toggleButtonRow($this->model, $property->name, $htmlOptions, $validators);
else if (in_array('number', $stringValidators) && isset($validators[0]->max) && isset($validators[0]->min))
$form->rangeFieldRow($this->model, $property->name, $htmlOptions, $validators);
else if (in_array('number', $stringValidators) && (isset($validators[0]->max) || isset($validators[0]->min)))
$form->numberFieldRow($this->model, $property->name, $htmlOptions, $validators);
else if (in_array('password', $stringValidators))
echo $form->passwordFieldRow($this->model, $property->name, $htmlOptions, $validators);
else
echo $form->textFieldRow($this->model, $property->name, $htmlOptions, $validators);
echo CHtml::closeTag('div');
} | [
"private",
"function",
"renderProperties",
"(",
"&",
"$",
"form",
",",
"$",
"property",
")",
"{",
"$",
"htmlOptions",
"=",
"array",
"(",
"'class'",
"=>",
"'pure-input-2-3'",
")",
";",
"$",
"validators",
"=",
"$",
"this",
"->",
"model",
"->",
"getValidators",
"(",
"$",
"property",
"->",
"name",
")",
";",
"$",
"stringValidators",
"=",
"$",
"this",
"->",
"model",
"->",
"getStringValidator",
"(",
"$",
"property",
"->",
"name",
",",
"$",
"validators",
")",
";",
"if",
"(",
"in_array",
"(",
"'required'",
",",
"$",
"stringValidators",
")",
")",
"$",
"htmlOptions",
"[",
"'required'",
"]",
"=",
"true",
";",
"echo",
"CHtml",
"::",
"openTag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'pure-control-group'",
")",
")",
";",
"if",
"(",
"in_array",
"(",
"'boolean'",
",",
"$",
"stringValidators",
")",
")",
"$",
"form",
"->",
"toggleButtonRow",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"property",
"->",
"name",
",",
"$",
"htmlOptions",
",",
"$",
"validators",
")",
";",
"else",
"if",
"(",
"in_array",
"(",
"'number'",
",",
"$",
"stringValidators",
")",
"&&",
"isset",
"(",
"$",
"validators",
"[",
"0",
"]",
"->",
"max",
")",
"&&",
"isset",
"(",
"$",
"validators",
"[",
"0",
"]",
"->",
"min",
")",
")",
"$",
"form",
"->",
"rangeFieldRow",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"property",
"->",
"name",
",",
"$",
"htmlOptions",
",",
"$",
"validators",
")",
";",
"else",
"if",
"(",
"in_array",
"(",
"'number'",
",",
"$",
"stringValidators",
")",
"&&",
"(",
"isset",
"(",
"$",
"validators",
"[",
"0",
"]",
"->",
"max",
")",
"||",
"isset",
"(",
"$",
"validators",
"[",
"0",
"]",
"->",
"min",
")",
")",
")",
"$",
"form",
"->",
"numberFieldRow",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"property",
"->",
"name",
",",
"$",
"htmlOptions",
",",
"$",
"validators",
")",
";",
"else",
"if",
"(",
"in_array",
"(",
"'password'",
",",
"$",
"stringValidators",
")",
")",
"echo",
"$",
"form",
"->",
"passwordFieldRow",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"property",
"->",
"name",
",",
"$",
"htmlOptions",
",",
"$",
"validators",
")",
";",
"else",
"echo",
"$",
"form",
"->",
"textFieldRow",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"property",
"->",
"name",
",",
"$",
"htmlOptions",
",",
"$",
"validators",
")",
";",
"echo",
"CHtml",
"::",
"closeTag",
"(",
"'div'",
")",
";",
"}"
] | Renders form properties utilizing the appropriate
@param CActiveForm $form The form we're working with
@param Property Name $property The property name from Reflection | [
"Renders",
"form",
"properties",
"utilizing",
"the",
"appropriate"
] | cc8550b9a3a6a0bf0214554679de8743d50dc9ef | https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/models/CiiSettingsForm.php#L139-L165 |
11,207 | academic/VipaImportBundle | Importer/PKP/JournalUserImporter.php | JournalUserImporter.importJournalUsers | public function importJournalUsers($newJournalId, $oldJournalId, $userImporter)
{
$this->em->clear();
$journal = $this->em->getRepository('VipaJournalBundle:Journal')->find($newJournalId);
$roleMap = [
'1' => "ROLE_ADMIN",
'2' => "ROLE_USER",
'10' => "ROLE_JOURNAL_MANAGER",
'100' => "ROLE_EDITOR",
'200' => 'ROLE_SECTION_EDITOR',
'300' => 'ROLE_LAYOUT_EDITOR',
'1000' => "ROLE_REVIEWER",
'2000' => 'ROLE_COPYEDITOR',
'3000' => "ROLE_PROOFREADER",
'10000' => "ROLE_AUTHOR",
'100000' => 'ROLE_READER',
'200000' => "ROLE_SUBSCRIPTION_MANAGER",
];
// Replace role names with role entities
foreach ($roleMap as $id => $name) {
$role = $this->em->getRepository('VipaUserBundle:Role')->findOneBy(['role' => $name]);
if (!$role) {
$role = new Role();
$role->setName($name);
$role->setRole($name);
}
$roleMap[$id] = $role;
}
$roleStatement = $this->dbalConnection->prepare(
"SELECT roles.journal_id, roles.user_id, roles.role_id, users.email FROM " .
"roles JOIN users ON roles.user_id = users.user_id WHERE roles.journal_id" .
"= :id " . ImportHelper::spamUsersFilterSql()
);
$roleStatement->bindValue('id', $oldJournalId);
$roleStatement->execute();
$roles = $roleStatement->fetchAll();
$cache = array();
foreach ($roles as $role) {
$email = $role['email'];
// Put the user from DB to cache
if (empty($cache[$email]['user'])) {
$cache[$email]['user'] = $this->em
->getRepository('VipaUserBundle:User')
->findOneBy(['email' => $email]);
}
// Create the user and put it to cache
if(empty($cache[$email]['user'])) {
$cache[$email]['user'] = $userImporter
->importUser($role['user_id'], false);
}
/** @var JournalUser $journalUser */
$journalUser = $this->getJournalUser($cache, $email, $journal);
$journalUser->addRole($roleMap[dechex($role['role_id'])]);
}
$this->consoleOutput->writeln("Writing data...");
$this->em->flush();
$this->consoleOutput->writeln("Imported users.");
} | php | public function importJournalUsers($newJournalId, $oldJournalId, $userImporter)
{
$this->em->clear();
$journal = $this->em->getRepository('VipaJournalBundle:Journal')->find($newJournalId);
$roleMap = [
'1' => "ROLE_ADMIN",
'2' => "ROLE_USER",
'10' => "ROLE_JOURNAL_MANAGER",
'100' => "ROLE_EDITOR",
'200' => 'ROLE_SECTION_EDITOR',
'300' => 'ROLE_LAYOUT_EDITOR',
'1000' => "ROLE_REVIEWER",
'2000' => 'ROLE_COPYEDITOR',
'3000' => "ROLE_PROOFREADER",
'10000' => "ROLE_AUTHOR",
'100000' => 'ROLE_READER',
'200000' => "ROLE_SUBSCRIPTION_MANAGER",
];
// Replace role names with role entities
foreach ($roleMap as $id => $name) {
$role = $this->em->getRepository('VipaUserBundle:Role')->findOneBy(['role' => $name]);
if (!$role) {
$role = new Role();
$role->setName($name);
$role->setRole($name);
}
$roleMap[$id] = $role;
}
$roleStatement = $this->dbalConnection->prepare(
"SELECT roles.journal_id, roles.user_id, roles.role_id, users.email FROM " .
"roles JOIN users ON roles.user_id = users.user_id WHERE roles.journal_id" .
"= :id " . ImportHelper::spamUsersFilterSql()
);
$roleStatement->bindValue('id', $oldJournalId);
$roleStatement->execute();
$roles = $roleStatement->fetchAll();
$cache = array();
foreach ($roles as $role) {
$email = $role['email'];
// Put the user from DB to cache
if (empty($cache[$email]['user'])) {
$cache[$email]['user'] = $this->em
->getRepository('VipaUserBundle:User')
->findOneBy(['email' => $email]);
}
// Create the user and put it to cache
if(empty($cache[$email]['user'])) {
$cache[$email]['user'] = $userImporter
->importUser($role['user_id'], false);
}
/** @var JournalUser $journalUser */
$journalUser = $this->getJournalUser($cache, $email, $journal);
$journalUser->addRole($roleMap[dechex($role['role_id'])]);
}
$this->consoleOutput->writeln("Writing data...");
$this->em->flush();
$this->consoleOutput->writeln("Imported users.");
} | [
"public",
"function",
"importJournalUsers",
"(",
"$",
"newJournalId",
",",
"$",
"oldJournalId",
",",
"$",
"userImporter",
")",
"{",
"$",
"this",
"->",
"em",
"->",
"clear",
"(",
")",
";",
"$",
"journal",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'VipaJournalBundle:Journal'",
")",
"->",
"find",
"(",
"$",
"newJournalId",
")",
";",
"$",
"roleMap",
"=",
"[",
"'1'",
"=>",
"\"ROLE_ADMIN\"",
",",
"'2'",
"=>",
"\"ROLE_USER\"",
",",
"'10'",
"=>",
"\"ROLE_JOURNAL_MANAGER\"",
",",
"'100'",
"=>",
"\"ROLE_EDITOR\"",
",",
"'200'",
"=>",
"'ROLE_SECTION_EDITOR'",
",",
"'300'",
"=>",
"'ROLE_LAYOUT_EDITOR'",
",",
"'1000'",
"=>",
"\"ROLE_REVIEWER\"",
",",
"'2000'",
"=>",
"'ROLE_COPYEDITOR'",
",",
"'3000'",
"=>",
"\"ROLE_PROOFREADER\"",
",",
"'10000'",
"=>",
"\"ROLE_AUTHOR\"",
",",
"'100000'",
"=>",
"'ROLE_READER'",
",",
"'200000'",
"=>",
"\"ROLE_SUBSCRIPTION_MANAGER\"",
",",
"]",
";",
"// Replace role names with role entities",
"foreach",
"(",
"$",
"roleMap",
"as",
"$",
"id",
"=>",
"$",
"name",
")",
"{",
"$",
"role",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'VipaUserBundle:Role'",
")",
"->",
"findOneBy",
"(",
"[",
"'role'",
"=>",
"$",
"name",
"]",
")",
";",
"if",
"(",
"!",
"$",
"role",
")",
"{",
"$",
"role",
"=",
"new",
"Role",
"(",
")",
";",
"$",
"role",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"$",
"role",
"->",
"setRole",
"(",
"$",
"name",
")",
";",
"}",
"$",
"roleMap",
"[",
"$",
"id",
"]",
"=",
"$",
"role",
";",
"}",
"$",
"roleStatement",
"=",
"$",
"this",
"->",
"dbalConnection",
"->",
"prepare",
"(",
"\"SELECT roles.journal_id, roles.user_id, roles.role_id, users.email FROM \"",
".",
"\"roles JOIN users ON roles.user_id = users.user_id WHERE roles.journal_id\"",
".",
"\"= :id \"",
".",
"ImportHelper",
"::",
"spamUsersFilterSql",
"(",
")",
")",
";",
"$",
"roleStatement",
"->",
"bindValue",
"(",
"'id'",
",",
"$",
"oldJournalId",
")",
";",
"$",
"roleStatement",
"->",
"execute",
"(",
")",
";",
"$",
"roles",
"=",
"$",
"roleStatement",
"->",
"fetchAll",
"(",
")",
";",
"$",
"cache",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"$",
"email",
"=",
"$",
"role",
"[",
"'email'",
"]",
";",
"// Put the user from DB to cache",
"if",
"(",
"empty",
"(",
"$",
"cache",
"[",
"$",
"email",
"]",
"[",
"'user'",
"]",
")",
")",
"{",
"$",
"cache",
"[",
"$",
"email",
"]",
"[",
"'user'",
"]",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'VipaUserBundle:User'",
")",
"->",
"findOneBy",
"(",
"[",
"'email'",
"=>",
"$",
"email",
"]",
")",
";",
"}",
"// Create the user and put it to cache",
"if",
"(",
"empty",
"(",
"$",
"cache",
"[",
"$",
"email",
"]",
"[",
"'user'",
"]",
")",
")",
"{",
"$",
"cache",
"[",
"$",
"email",
"]",
"[",
"'user'",
"]",
"=",
"$",
"userImporter",
"->",
"importUser",
"(",
"$",
"role",
"[",
"'user_id'",
"]",
",",
"false",
")",
";",
"}",
"/** @var JournalUser $journalUser */",
"$",
"journalUser",
"=",
"$",
"this",
"->",
"getJournalUser",
"(",
"$",
"cache",
",",
"$",
"email",
",",
"$",
"journal",
")",
";",
"$",
"journalUser",
"->",
"addRole",
"(",
"$",
"roleMap",
"[",
"dechex",
"(",
"$",
"role",
"[",
"'role_id'",
"]",
")",
"]",
")",
";",
"}",
"$",
"this",
"->",
"consoleOutput",
"->",
"writeln",
"(",
"\"Writing data...\"",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"consoleOutput",
"->",
"writeln",
"(",
"\"Imported users.\"",
")",
";",
"}"
] | Imports users of the given journal
@param int $newJournalId New journal's ID
@param int $oldJournalId Old journal's ID
@param UserImporter $userImporter User importer class
@throws \Doctrine\DBAL\DBALException | [
"Imports",
"users",
"of",
"the",
"given",
"journal"
] | cee7d9e51613706a4fd6e2eade44041ce1af9ad3 | https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/JournalUserImporter.php#L21-L90 |
11,208 | academic/VipaImportBundle | Importer/PKP/JournalUserImporter.php | JournalUserImporter.getJournalUser | private function getJournalUser(&$cache, $email, $journal)
{
if (!empty($cache[$email]['journal_user'])) {
return $cache[$email]['journal_user'];
}
$journalUser = $this->em
->getRepository('VipaJournalBundle:JournalUser')
->findOneBy(['journal' => $journal, 'user' => $cache[$email]['user']]);
if ($journalUser === null) {
$journalUser = new JournalUser();
$journalUser->setUser($cache[$email]['user']);
$journalUser->setJournal($journal);
$this->em->persist($journalUser);
}
$cache[$email]['journal_user'] = $journalUser;
return $cache[$email]['journal_user'];
} | php | private function getJournalUser(&$cache, $email, $journal)
{
if (!empty($cache[$email]['journal_user'])) {
return $cache[$email]['journal_user'];
}
$journalUser = $this->em
->getRepository('VipaJournalBundle:JournalUser')
->findOneBy(['journal' => $journal, 'user' => $cache[$email]['user']]);
if ($journalUser === null) {
$journalUser = new JournalUser();
$journalUser->setUser($cache[$email]['user']);
$journalUser->setJournal($journal);
$this->em->persist($journalUser);
}
$cache[$email]['journal_user'] = $journalUser;
return $cache[$email]['journal_user'];
} | [
"private",
"function",
"getJournalUser",
"(",
"&",
"$",
"cache",
",",
"$",
"email",
",",
"$",
"journal",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"cache",
"[",
"$",
"email",
"]",
"[",
"'journal_user'",
"]",
")",
")",
"{",
"return",
"$",
"cache",
"[",
"$",
"email",
"]",
"[",
"'journal_user'",
"]",
";",
"}",
"$",
"journalUser",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'VipaJournalBundle:JournalUser'",
")",
"->",
"findOneBy",
"(",
"[",
"'journal'",
"=>",
"$",
"journal",
",",
"'user'",
"=>",
"$",
"cache",
"[",
"$",
"email",
"]",
"[",
"'user'",
"]",
"]",
")",
";",
"if",
"(",
"$",
"journalUser",
"===",
"null",
")",
"{",
"$",
"journalUser",
"=",
"new",
"JournalUser",
"(",
")",
";",
"$",
"journalUser",
"->",
"setUser",
"(",
"$",
"cache",
"[",
"$",
"email",
"]",
"[",
"'user'",
"]",
")",
";",
"$",
"journalUser",
"->",
"setJournal",
"(",
"$",
"journal",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"journalUser",
")",
";",
"}",
"$",
"cache",
"[",
"$",
"email",
"]",
"[",
"'journal_user'",
"]",
"=",
"$",
"journalUser",
";",
"return",
"$",
"cache",
"[",
"$",
"email",
"]",
"[",
"'journal_user'",
"]",
";",
"}"
] | Fetches the journal user
@param array $cache User cache
@param String $email User's email
@param Journal $journal Journal
@return JournalUser Imported or retrieved JournalUser | [
"Fetches",
"the",
"journal",
"user"
] | cee7d9e51613706a4fd6e2eade44041ce1af9ad3 | https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/JournalUserImporter.php#L99-L118 |
11,209 | spipremix/facteur | phpmailer-php5/extras/EasyPeasyICS.php | EasyPeasyICS.addEvent | public function addEvent($start, $end, $summary = '', $description = '', $url = '', $uid = '')
{
if (empty($uid)) {
$uid = md5(uniqid(mt_rand(), true)) . '@EasyPeasyICS';
}
$event = array(
'start' => gmdate('Ymd', $start) . 'T' . gmdate('His', $start) . 'Z',
'end' => gmdate('Ymd', $end) . 'T' . gmdate('His', $end) . 'Z',
'summary' => $summary,
'description' => $description,
'url' => $url,
'uid' => $uid
);
$this->events[] = $event;
return $event;
} | php | public function addEvent($start, $end, $summary = '', $description = '', $url = '', $uid = '')
{
if (empty($uid)) {
$uid = md5(uniqid(mt_rand(), true)) . '@EasyPeasyICS';
}
$event = array(
'start' => gmdate('Ymd', $start) . 'T' . gmdate('His', $start) . 'Z',
'end' => gmdate('Ymd', $end) . 'T' . gmdate('His', $end) . 'Z',
'summary' => $summary,
'description' => $description,
'url' => $url,
'uid' => $uid
);
$this->events[] = $event;
return $event;
} | [
"public",
"function",
"addEvent",
"(",
"$",
"start",
",",
"$",
"end",
",",
"$",
"summary",
"=",
"''",
",",
"$",
"description",
"=",
"''",
",",
"$",
"url",
"=",
"''",
",",
"$",
"uid",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"uid",
")",
")",
"{",
"$",
"uid",
"=",
"md5",
"(",
"uniqid",
"(",
"mt_rand",
"(",
")",
",",
"true",
")",
")",
".",
"'@EasyPeasyICS'",
";",
"}",
"$",
"event",
"=",
"array",
"(",
"'start'",
"=>",
"gmdate",
"(",
"'Ymd'",
",",
"$",
"start",
")",
".",
"'T'",
".",
"gmdate",
"(",
"'His'",
",",
"$",
"start",
")",
".",
"'Z'",
",",
"'end'",
"=>",
"gmdate",
"(",
"'Ymd'",
",",
"$",
"end",
")",
".",
"'T'",
".",
"gmdate",
"(",
"'His'",
",",
"$",
"end",
")",
".",
"'Z'",
",",
"'summary'",
"=>",
"$",
"summary",
",",
"'description'",
"=>",
"$",
"description",
",",
"'url'",
"=>",
"$",
"url",
",",
"'uid'",
"=>",
"$",
"uid",
")",
";",
"$",
"this",
"->",
"events",
"[",
"]",
"=",
"$",
"event",
";",
"return",
"$",
"event",
";",
"}"
] | Add an event to this calendar.
@param string $start The start date and time as a unix timestamp
@param string $end The end date and time as a unix timestamp
@param string $summary A summary or title for the event
@param string $description A description of the event
@param string $url A URL for the event
@param string $uid A unique identifier for the event - generated automatically if not provided
@return array An array of event details, including any generated UID | [
"Add",
"an",
"event",
"to",
"this",
"calendar",
"."
] | 9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca | https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/phpmailer-php5/extras/EasyPeasyICS.php#L52-L67 |
11,210 | spipremix/facteur | phpmailer-php5/extras/EasyPeasyICS.php | EasyPeasyICS.render | public function render($output = true)
{
//Add header
$ics = 'BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
X-WR-CALNAME:' . $this->calendarName . '
PRODID:-//hacksw/handcal//NONSGML v1.0//EN';
//Add events
foreach ($this->events as $event) {
$ics .= '
BEGIN:VEVENT
UID:' . $event['uid'] . '
DTSTAMP:' . gmdate('Ymd') . 'T' . gmdate('His') . 'Z
DTSTART:' . $event['start'] . '
DTEND:' . $event['end'] . '
SUMMARY:' . str_replace("\n", "\\n", $event['summary']) . '
DESCRIPTION:' . str_replace("\n", "\\n", $event['description']) . '
URL;VALUE=URI:' . $event['url'] . '
END:VEVENT';
}
//Add footer
$ics .= '
END:VCALENDAR';
if ($output) {
//Output
$filename = $this->calendarName;
//Filename needs quoting if it contains spaces
if (strpos($filename, ' ') !== false) {
$filename = '"'.$filename.'"';
}
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=' . $filename . '.ics');
echo $ics;
}
return $ics;
} | php | public function render($output = true)
{
//Add header
$ics = 'BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
X-WR-CALNAME:' . $this->calendarName . '
PRODID:-//hacksw/handcal//NONSGML v1.0//EN';
//Add events
foreach ($this->events as $event) {
$ics .= '
BEGIN:VEVENT
UID:' . $event['uid'] . '
DTSTAMP:' . gmdate('Ymd') . 'T' . gmdate('His') . 'Z
DTSTART:' . $event['start'] . '
DTEND:' . $event['end'] . '
SUMMARY:' . str_replace("\n", "\\n", $event['summary']) . '
DESCRIPTION:' . str_replace("\n", "\\n", $event['description']) . '
URL;VALUE=URI:' . $event['url'] . '
END:VEVENT';
}
//Add footer
$ics .= '
END:VCALENDAR';
if ($output) {
//Output
$filename = $this->calendarName;
//Filename needs quoting if it contains spaces
if (strpos($filename, ' ') !== false) {
$filename = '"'.$filename.'"';
}
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=' . $filename . '.ics');
echo $ics;
}
return $ics;
} | [
"public",
"function",
"render",
"(",
"$",
"output",
"=",
"true",
")",
"{",
"//Add header",
"$",
"ics",
"=",
"'BEGIN:VCALENDAR\nMETHOD:PUBLISH\nVERSION:2.0\nX-WR-CALNAME:'",
".",
"$",
"this",
"->",
"calendarName",
".",
"'\nPRODID:-//hacksw/handcal//NONSGML v1.0//EN'",
";",
"//Add events",
"foreach",
"(",
"$",
"this",
"->",
"events",
"as",
"$",
"event",
")",
"{",
"$",
"ics",
".=",
"'\nBEGIN:VEVENT\nUID:'",
".",
"$",
"event",
"[",
"'uid'",
"]",
".",
"'\nDTSTAMP:'",
".",
"gmdate",
"(",
"'Ymd'",
")",
".",
"'T'",
".",
"gmdate",
"(",
"'His'",
")",
".",
"'Z\nDTSTART:'",
".",
"$",
"event",
"[",
"'start'",
"]",
".",
"'\nDTEND:'",
".",
"$",
"event",
"[",
"'end'",
"]",
".",
"'\nSUMMARY:'",
".",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\\\n\"",
",",
"$",
"event",
"[",
"'summary'",
"]",
")",
".",
"'\nDESCRIPTION:'",
".",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\\\n\"",
",",
"$",
"event",
"[",
"'description'",
"]",
")",
".",
"'\nURL;VALUE=URI:'",
".",
"$",
"event",
"[",
"'url'",
"]",
".",
"'\nEND:VEVENT'",
";",
"}",
"//Add footer",
"$",
"ics",
".=",
"'\nEND:VCALENDAR'",
";",
"if",
"(",
"$",
"output",
")",
"{",
"//Output",
"$",
"filename",
"=",
"$",
"this",
"->",
"calendarName",
";",
"//Filename needs quoting if it contains spaces",
"if",
"(",
"strpos",
"(",
"$",
"filename",
",",
"' '",
")",
"!==",
"false",
")",
"{",
"$",
"filename",
"=",
"'\"'",
".",
"$",
"filename",
".",
"'\"'",
";",
"}",
"header",
"(",
"'Content-type: text/calendar; charset=utf-8'",
")",
";",
"header",
"(",
"'Content-Disposition: inline; filename='",
".",
"$",
"filename",
".",
"'.ics'",
")",
";",
"echo",
"$",
"ics",
";",
"}",
"return",
"$",
"ics",
";",
"}"
] | Render and optionally output a vcal string.
@param bool $output Whether to output the calendar data directly (the default).
@return string The complete rendered vlal | [
"Render",
"and",
"optionally",
"output",
"a",
"vcal",
"string",
"."
] | 9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca | https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/phpmailer-php5/extras/EasyPeasyICS.php#L108-L147 |
11,211 | nsrosenqvist/blade-compiler | src/Compiler.php | Compiler.compile | public function compile(string $path, array $data = [])
{
// If the file can't be found it's probably supplied as a template within
// one of the base directories
$path = $this->find($path);
// Make sure that we use the right resolver for the initial file
$engine = $this->factory->getEngineFromPath($path);
// this path needs to be string
return $view = new View(
$this->factory,
$engine,
$path, // view (not sure what it does)
$path,
$data
);
} | php | public function compile(string $path, array $data = [])
{
// If the file can't be found it's probably supplied as a template within
// one of the base directories
$path = $this->find($path);
// Make sure that we use the right resolver for the initial file
$engine = $this->factory->getEngineFromPath($path);
// this path needs to be string
return $view = new View(
$this->factory,
$engine,
$path, // view (not sure what it does)
$path,
$data
);
} | [
"public",
"function",
"compile",
"(",
"string",
"$",
"path",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"// If the file can't be found it's probably supplied as a template within",
"// one of the base directories",
"$",
"path",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"path",
")",
";",
"// Make sure that we use the right resolver for the initial file",
"$",
"engine",
"=",
"$",
"this",
"->",
"factory",
"->",
"getEngineFromPath",
"(",
"$",
"path",
")",
";",
"// this path needs to be string",
"return",
"$",
"view",
"=",
"new",
"View",
"(",
"$",
"this",
"->",
"factory",
",",
"$",
"engine",
",",
"$",
"path",
",",
"// view (not sure what it does)",
"$",
"path",
",",
"$",
"data",
")",
";",
"}"
] | Compile a specific Blade file
@param string $path Path to file to compile
@param array $data An associative array of data to be passed to the view
@return \Illuminate\View\View Returns the blade view | [
"Compile",
"a",
"specific",
"Blade",
"file"
] | 3e20deb8eca4e3773f8c26eb3740e442729efb27 | https://github.com/nsrosenqvist/blade-compiler/blob/3e20deb8eca4e3773f8c26eb3740e442729efb27/src/Compiler.php#L128-L145 |
11,212 | nsrosenqvist/blade-compiler | src/Compiler.php | Compiler.find | public function find(string $path)
{
if (! file_exists($path)) {
$path = $this->viewFinder->find($path);
}
return $path;
} | php | public function find(string $path)
{
if (! file_exists($path)) {
$path = $this->viewFinder->find($path);
}
return $path;
} | [
"public",
"function",
"find",
"(",
"string",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"viewFinder",
"->",
"find",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Searches the viewFinder for the path provided
@param string $path Path to search for
@return string If absolute provided and exists, return it, otherwise return result from viewFinder | [
"Searches",
"the",
"viewFinder",
"for",
"the",
"path",
"provided"
] | 3e20deb8eca4e3773f8c26eb3740e442729efb27 | https://github.com/nsrosenqvist/blade-compiler/blob/3e20deb8eca4e3773f8c26eb3740e442729efb27/src/Compiler.php#L162-L169 |
11,213 | GrupaZero/core | src/Gzero/Core/Parsers/DateParser.php | DateParser.checkValue | protected function checkValue(): void
{
if ((!is_string($this->value) && !is_numeric($this->value)) || strtotime($this->value) === false) {
throw new InvalidArgumentException('DateParser: Value must be a valid date');
}
} | php | protected function checkValue(): void
{
if ((!is_string($this->value) && !is_numeric($this->value)) || strtotime($this->value) === false) {
throw new InvalidArgumentException('DateParser: Value must be a valid date');
}
} | [
"protected",
"function",
"checkValue",
"(",
")",
":",
"void",
"{",
"if",
"(",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"this",
"->",
"value",
")",
")",
"||",
"strtotime",
"(",
"$",
"this",
"->",
"value",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'DateParser: Value must be a valid date'",
")",
";",
"}",
"}"
] | Check if value is a valid date.
@throws InvalidArgumentException
@return void | [
"Check",
"if",
"value",
"is",
"a",
"valid",
"date",
"."
] | 093e515234fa0385b259ba4d8bc7832174a44eab | https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Parsers/DateParser.php#L149-L154 |
11,214 | jamiehannaford/php-opencloud-zf2 | src/Helper/CloudFiles/DataObject.php | DataObject.render | public function render(array $attrs, $urlType)
{
return HtmlRenderer::factory($this->renderer, $this->dataObject, $urlType, $attrs);
} | php | public function render(array $attrs, $urlType)
{
return HtmlRenderer::factory($this->renderer, $this->dataObject, $urlType, $attrs);
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"attrs",
",",
"$",
"urlType",
")",
"{",
"return",
"HtmlRenderer",
"::",
"factory",
"(",
"$",
"this",
"->",
"renderer",
",",
"$",
"this",
"->",
"dataObject",
",",
"$",
"urlType",
",",
"$",
"attrs",
")",
";",
"}"
] | Render the data object into valid HTML markup
@param $urlType The connection type
@return mixed | [
"Render",
"the",
"data",
"object",
"into",
"valid",
"HTML",
"markup"
] | 74140adaffc0b46d7bbe1d7b3441c61f2cf6a656 | https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Helper/CloudFiles/DataObject.php#L38-L41 |
11,215 | praxigento/mobi_mod_wallet | Setup/UpgradeSchema/A/V0_1_1.php | V0_1_1.upgradeTblQuote | private function upgradeTblQuote($setup)
{
$conn = $setup->getConnection();
$table = $setup->getTable(EPartQuote::ENTITY_NAME);
/* add columns */
$conn->addColumn(
$table,
EPartQuote::A_BASE_CURRENCY,
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 3,
'nullable' => false,
'after' => EPartQuote::A_BASE_PARTIAL_AMOUNT,
'comment' => 'Currency code for base amount (stock/warehouse currency).'
]
);
$conn->addColumn(
$table,
EPartQuote::A_CURRENCY,
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 3,
'nullable' => false,
'after' => EPartQuote::A_PARTIAL_AMOUNT,
'comment' => 'Currency code for amount (payment??? currency).'
]
);
} | php | private function upgradeTblQuote($setup)
{
$conn = $setup->getConnection();
$table = $setup->getTable(EPartQuote::ENTITY_NAME);
/* add columns */
$conn->addColumn(
$table,
EPartQuote::A_BASE_CURRENCY,
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 3,
'nullable' => false,
'after' => EPartQuote::A_BASE_PARTIAL_AMOUNT,
'comment' => 'Currency code for base amount (stock/warehouse currency).'
]
);
$conn->addColumn(
$table,
EPartQuote::A_CURRENCY,
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 3,
'nullable' => false,
'after' => EPartQuote::A_PARTIAL_AMOUNT,
'comment' => 'Currency code for amount (payment??? currency).'
]
);
} | [
"private",
"function",
"upgradeTblQuote",
"(",
"$",
"setup",
")",
"{",
"$",
"conn",
"=",
"$",
"setup",
"->",
"getConnection",
"(",
")",
";",
"$",
"table",
"=",
"$",
"setup",
"->",
"getTable",
"(",
"EPartQuote",
"::",
"ENTITY_NAME",
")",
";",
"/* add columns */",
"$",
"conn",
"->",
"addColumn",
"(",
"$",
"table",
",",
"EPartQuote",
"::",
"A_BASE_CURRENCY",
",",
"[",
"'type'",
"=>",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"DB",
"\\",
"Ddl",
"\\",
"Table",
"::",
"TYPE_TEXT",
",",
"'length'",
"=>",
"3",
",",
"'nullable'",
"=>",
"false",
",",
"'after'",
"=>",
"EPartQuote",
"::",
"A_BASE_PARTIAL_AMOUNT",
",",
"'comment'",
"=>",
"'Currency code for base amount (stock/warehouse currency).'",
"]",
")",
";",
"$",
"conn",
"->",
"addColumn",
"(",
"$",
"table",
",",
"EPartQuote",
"::",
"A_CURRENCY",
",",
"[",
"'type'",
"=>",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"DB",
"\\",
"Ddl",
"\\",
"Table",
"::",
"TYPE_TEXT",
",",
"'length'",
"=>",
"3",
",",
"'nullable'",
"=>",
"false",
",",
"'after'",
"=>",
"EPartQuote",
"::",
"A_PARTIAL_AMOUNT",
",",
"'comment'",
"=>",
"'Currency code for amount (payment??? currency).'",
"]",
")",
";",
"}"
] | Upgrade table "prxgt_wallet_partial_quote". Add currencies fields.
@param \Magento\Framework\Setup\SchemaSetupInterface $setup | [
"Upgrade",
"table",
"prxgt_wallet_partial_quote",
".",
"Add",
"currencies",
"fields",
"."
] | 8f4789645f2e3c95b1323984aa67215b1647fa39 | https://github.com/praxigento/mobi_mod_wallet/blob/8f4789645f2e3c95b1323984aa67215b1647fa39/Setup/UpgradeSchema/A/V0_1_1.php#L30-L58 |
11,216 | praxigento/mobi_mod_wallet | Setup/UpgradeSchema/A/V0_1_1.php | V0_1_1.upgradeTblSale | private function upgradeTblSale($setup)
{
$conn = $setup->getConnection();
$table = $setup->getTable(EPartSale::ENTITY_NAME);
/* add columns */
$conn->addColumn(
$table,
EPartSale::A_TRANS_REF,
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
'length' => null,
'unsigned' => true,
'nullable' => false,
'after' => EPartSale::A_SALE_ORDER_REF,
'comment' => 'Transaction Reference.'
]
);
$conn->addColumn(
$table,
EPartSale::A_BASE_CURRENCY,
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 3,
'nullable' => false,
'after' => EPartSale::A_BASE_PARTIAL_AMOUNT,
'comment' => 'Currency code for base amount (stock/warehouse currency).'
]
);
$conn->addColumn(
$table,
EPartSale::A_CURRENCY,
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 3,
'nullable' => false,
'after' => EPartSale::A_PARTIAL_AMOUNT,
'comment' => 'Currency code for amount (payment??? currency).'
]
);
/* add foreign keys */
$tbl = $setup->getTable(EPartSale::ENTITY_NAME);
$tblRef = $setup->getTable(EAccTran::ENTITY_NAME);
$fkName = $setup->getFkName($tbl, $tblRef, EPartSale::A_TRANS_REF, EAccTran::A_ID);
$conn->addForeignKey($fkName, $tbl, EPartSale::A_TRANS_REF, $tblRef, EAccTran::A_ID);
} | php | private function upgradeTblSale($setup)
{
$conn = $setup->getConnection();
$table = $setup->getTable(EPartSale::ENTITY_NAME);
/* add columns */
$conn->addColumn(
$table,
EPartSale::A_TRANS_REF,
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
'length' => null,
'unsigned' => true,
'nullable' => false,
'after' => EPartSale::A_SALE_ORDER_REF,
'comment' => 'Transaction Reference.'
]
);
$conn->addColumn(
$table,
EPartSale::A_BASE_CURRENCY,
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 3,
'nullable' => false,
'after' => EPartSale::A_BASE_PARTIAL_AMOUNT,
'comment' => 'Currency code for base amount (stock/warehouse currency).'
]
);
$conn->addColumn(
$table,
EPartSale::A_CURRENCY,
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 3,
'nullable' => false,
'after' => EPartSale::A_PARTIAL_AMOUNT,
'comment' => 'Currency code for amount (payment??? currency).'
]
);
/* add foreign keys */
$tbl = $setup->getTable(EPartSale::ENTITY_NAME);
$tblRef = $setup->getTable(EAccTran::ENTITY_NAME);
$fkName = $setup->getFkName($tbl, $tblRef, EPartSale::A_TRANS_REF, EAccTran::A_ID);
$conn->addForeignKey($fkName, $tbl, EPartSale::A_TRANS_REF, $tblRef, EAccTran::A_ID);
} | [
"private",
"function",
"upgradeTblSale",
"(",
"$",
"setup",
")",
"{",
"$",
"conn",
"=",
"$",
"setup",
"->",
"getConnection",
"(",
")",
";",
"$",
"table",
"=",
"$",
"setup",
"->",
"getTable",
"(",
"EPartSale",
"::",
"ENTITY_NAME",
")",
";",
"/* add columns */",
"$",
"conn",
"->",
"addColumn",
"(",
"$",
"table",
",",
"EPartSale",
"::",
"A_TRANS_REF",
",",
"[",
"'type'",
"=>",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"DB",
"\\",
"Ddl",
"\\",
"Table",
"::",
"TYPE_INTEGER",
",",
"'length'",
"=>",
"null",
",",
"'unsigned'",
"=>",
"true",
",",
"'nullable'",
"=>",
"false",
",",
"'after'",
"=>",
"EPartSale",
"::",
"A_SALE_ORDER_REF",
",",
"'comment'",
"=>",
"'Transaction Reference.'",
"]",
")",
";",
"$",
"conn",
"->",
"addColumn",
"(",
"$",
"table",
",",
"EPartSale",
"::",
"A_BASE_CURRENCY",
",",
"[",
"'type'",
"=>",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"DB",
"\\",
"Ddl",
"\\",
"Table",
"::",
"TYPE_TEXT",
",",
"'length'",
"=>",
"3",
",",
"'nullable'",
"=>",
"false",
",",
"'after'",
"=>",
"EPartSale",
"::",
"A_BASE_PARTIAL_AMOUNT",
",",
"'comment'",
"=>",
"'Currency code for base amount (stock/warehouse currency).'",
"]",
")",
";",
"$",
"conn",
"->",
"addColumn",
"(",
"$",
"table",
",",
"EPartSale",
"::",
"A_CURRENCY",
",",
"[",
"'type'",
"=>",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"DB",
"\\",
"Ddl",
"\\",
"Table",
"::",
"TYPE_TEXT",
",",
"'length'",
"=>",
"3",
",",
"'nullable'",
"=>",
"false",
",",
"'after'",
"=>",
"EPartSale",
"::",
"A_PARTIAL_AMOUNT",
",",
"'comment'",
"=>",
"'Currency code for amount (payment??? currency).'",
"]",
")",
";",
"/* add foreign keys */",
"$",
"tbl",
"=",
"$",
"setup",
"->",
"getTable",
"(",
"EPartSale",
"::",
"ENTITY_NAME",
")",
";",
"$",
"tblRef",
"=",
"$",
"setup",
"->",
"getTable",
"(",
"EAccTran",
"::",
"ENTITY_NAME",
")",
";",
"$",
"fkName",
"=",
"$",
"setup",
"->",
"getFkName",
"(",
"$",
"tbl",
",",
"$",
"tblRef",
",",
"EPartSale",
"::",
"A_TRANS_REF",
",",
"EAccTran",
"::",
"A_ID",
")",
";",
"$",
"conn",
"->",
"addForeignKey",
"(",
"$",
"fkName",
",",
"$",
"tbl",
",",
"EPartSale",
"::",
"A_TRANS_REF",
",",
"$",
"tblRef",
",",
"EAccTran",
"::",
"A_ID",
")",
";",
"}"
] | Upgrade table "prxgt_wallet_partial_sale".
Add currencies fields and transaction reference.
@param \Magento\Framework\Setup\SchemaSetupInterface $setup | [
"Upgrade",
"table",
"prxgt_wallet_partial_sale",
".",
"Add",
"currencies",
"fields",
"and",
"transaction",
"reference",
"."
] | 8f4789645f2e3c95b1323984aa67215b1647fa39 | https://github.com/praxigento/mobi_mod_wallet/blob/8f4789645f2e3c95b1323984aa67215b1647fa39/Setup/UpgradeSchema/A/V0_1_1.php#L66-L112 |
11,217 | codebobbly/dvoconnector | Classes/Service/Url/AbstractRealUrl.php | AbstractRealUrl.cleanUrl | protected function cleanUrl($alias)
{
if ($this->isOldRealUrlVersion()) {
/** @var \tx_realurl_advanced $realUrl */
$realUrl = GeneralUtility::makeInstance('tx_realurl_advanced');
$configuration = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['pagePath'];
if (\is_array($configuration)) {
ObjectAccess::setProperty($realUrl, 'conf', $configuration, true);
}
$processedTitle = $realUrl->encodeTitle($alias);
} else {
$configuration = GeneralUtility::makeInstance(ConfigurationReader::class, ConfigurationReader::MODE_ENCODE);
// Init the internal utility by ObjectAccess because the property is
// set by a protected method only. :( Perhaps this could be part of the construct (in realurl)
$utility = GeneralUtility::makeInstance(Utility::class, $configuration);
$processedTitle = $utility->convertToSafeString($alias);
}
return $processedTitle;
} | php | protected function cleanUrl($alias)
{
if ($this->isOldRealUrlVersion()) {
/** @var \tx_realurl_advanced $realUrl */
$realUrl = GeneralUtility::makeInstance('tx_realurl_advanced');
$configuration = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['pagePath'];
if (\is_array($configuration)) {
ObjectAccess::setProperty($realUrl, 'conf', $configuration, true);
}
$processedTitle = $realUrl->encodeTitle($alias);
} else {
$configuration = GeneralUtility::makeInstance(ConfigurationReader::class, ConfigurationReader::MODE_ENCODE);
// Init the internal utility by ObjectAccess because the property is
// set by a protected method only. :( Perhaps this could be part of the construct (in realurl)
$utility = GeneralUtility::makeInstance(Utility::class, $configuration);
$processedTitle = $utility->convertToSafeString($alias);
}
return $processedTitle;
} | [
"protected",
"function",
"cleanUrl",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOldRealUrlVersion",
"(",
")",
")",
"{",
"/** @var \\tx_realurl_advanced $realUrl */",
"$",
"realUrl",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"'tx_realurl_advanced'",
")",
";",
"$",
"configuration",
"=",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'EXTCONF'",
"]",
"[",
"'realurl'",
"]",
"[",
"'_DEFAULT'",
"]",
"[",
"'pagePath'",
"]",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"configuration",
")",
")",
"{",
"ObjectAccess",
"::",
"setProperty",
"(",
"$",
"realUrl",
",",
"'conf'",
",",
"$",
"configuration",
",",
"true",
")",
";",
"}",
"$",
"processedTitle",
"=",
"$",
"realUrl",
"->",
"encodeTitle",
"(",
"$",
"alias",
")",
";",
"}",
"else",
"{",
"$",
"configuration",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ConfigurationReader",
"::",
"class",
",",
"ConfigurationReader",
"::",
"MODE_ENCODE",
")",
";",
"// Init the internal utility by ObjectAccess because the property is",
"// set by a protected method only. :( Perhaps this could be part of the construct (in realurl)",
"$",
"utility",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"Utility",
"::",
"class",
",",
"$",
"configuration",
")",
";",
"$",
"processedTitle",
"=",
"$",
"utility",
"->",
"convertToSafeString",
"(",
"$",
"alias",
")",
";",
"}",
"return",
"$",
"processedTitle",
";",
"}"
] | Generate the realurl part.
@param string $alias
@return string | [
"Generate",
"the",
"realurl",
"part",
"."
] | 9b63790d2fc9fd21bf415b4a5757678895b73bbc | https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/Url/AbstractRealUrl.php#L103-L123 |
11,218 | encorephp/kernel | src/Composer/Script.php | Script.init | public static function init()
{
// Instantiate the application
$app = Application::fromCwd();
// Give proxies an instance of the application
$app->initializeProxies();
// Boot the app
$app->boot();
static::$appPath = \App::appPath();
static::$vendorPath = \App::vendorPath();
if (defined('COMPILING')) {
static::$appPath = BUILD_PATH.'/app';
static::$vendorPath = BUILD_PATH.'/vendor';
}
} | php | public static function init()
{
// Instantiate the application
$app = Application::fromCwd();
// Give proxies an instance of the application
$app->initializeProxies();
// Boot the app
$app->boot();
static::$appPath = \App::appPath();
static::$vendorPath = \App::vendorPath();
if (defined('COMPILING')) {
static::$appPath = BUILD_PATH.'/app';
static::$vendorPath = BUILD_PATH.'/vendor';
}
} | [
"public",
"static",
"function",
"init",
"(",
")",
"{",
"// Instantiate the application",
"$",
"app",
"=",
"Application",
"::",
"fromCwd",
"(",
")",
";",
"// Give proxies an instance of the application",
"$",
"app",
"->",
"initializeProxies",
"(",
")",
";",
"// Boot the app",
"$",
"app",
"->",
"boot",
"(",
")",
";",
"static",
"::",
"$",
"appPath",
"=",
"\\",
"App",
"::",
"appPath",
"(",
")",
";",
"static",
"::",
"$",
"vendorPath",
"=",
"\\",
"App",
"::",
"vendorPath",
"(",
")",
";",
"if",
"(",
"defined",
"(",
"'COMPILING'",
")",
")",
"{",
"static",
"::",
"$",
"appPath",
"=",
"BUILD_PATH",
".",
"'/app'",
";",
"static",
"::",
"$",
"vendorPath",
"=",
"BUILD_PATH",
".",
"'/vendor'",
";",
"}",
"}"
] | Initialise the application
@return void | [
"Initialise",
"the",
"application"
] | 3a1980a8aab0ac6d4298f0368f319620ddb1e644 | https://github.com/encorephp/kernel/blob/3a1980a8aab0ac6d4298f0368f319620ddb1e644/src/Composer/Script.php#L22-L40 |
11,219 | encorephp/kernel | src/Composer/Script.php | Script.postInstall | public static function postInstall(Event $event)
{
static::init();
$event->getIO()->write('<info>Writing resources.lock file</info>');
$installed = json_decode(file_get_contents(static::$vendorPath.'/composer/installed.json'));
$data = [];
$finder = (new Finder)
->directories()
->ignoreVCS(true)
->in(static::$resourcesPath.'/packages');
foreach ($installed as $package) {
if ( ! property_exists($package, 'extra')) continue;
$extra = $package->extra;
if ( ! property_exists($extra, 'resources')) continue;
$resources = $extra->resources;
foreach ($resources as $resource => $namespaces) {
foreach ($namespaces as $namespace => $path) {
$finder->exclude($namespace);
$data[$resource][$namespace] = $path;
}
}
}
// We turn the iterator to an array to
// prevent an exception when we delete the directorys
foreach (iterator_to_array($finder) as $file) {
\Filesystem::deleteDirectory($file->getPathname());
}
file_put_contents(static::$resourcesPath.'/resources.lock', json_encode($data, JSON_PRETTY_PRINT));
} | php | public static function postInstall(Event $event)
{
static::init();
$event->getIO()->write('<info>Writing resources.lock file</info>');
$installed = json_decode(file_get_contents(static::$vendorPath.'/composer/installed.json'));
$data = [];
$finder = (new Finder)
->directories()
->ignoreVCS(true)
->in(static::$resourcesPath.'/packages');
foreach ($installed as $package) {
if ( ! property_exists($package, 'extra')) continue;
$extra = $package->extra;
if ( ! property_exists($extra, 'resources')) continue;
$resources = $extra->resources;
foreach ($resources as $resource => $namespaces) {
foreach ($namespaces as $namespace => $path) {
$finder->exclude($namespace);
$data[$resource][$namespace] = $path;
}
}
}
// We turn the iterator to an array to
// prevent an exception when we delete the directorys
foreach (iterator_to_array($finder) as $file) {
\Filesystem::deleteDirectory($file->getPathname());
}
file_put_contents(static::$resourcesPath.'/resources.lock', json_encode($data, JSON_PRETTY_PRINT));
} | [
"public",
"static",
"function",
"postInstall",
"(",
"Event",
"$",
"event",
")",
"{",
"static",
"::",
"init",
"(",
")",
";",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"'<info>Writing resources.lock file</info>'",
")",
";",
"$",
"installed",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"static",
"::",
"$",
"vendorPath",
".",
"'/composer/installed.json'",
")",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"finder",
"=",
"(",
"new",
"Finder",
")",
"->",
"directories",
"(",
")",
"->",
"ignoreVCS",
"(",
"true",
")",
"->",
"in",
"(",
"static",
"::",
"$",
"resourcesPath",
".",
"'/packages'",
")",
";",
"foreach",
"(",
"$",
"installed",
"as",
"$",
"package",
")",
"{",
"if",
"(",
"!",
"property_exists",
"(",
"$",
"package",
",",
"'extra'",
")",
")",
"continue",
";",
"$",
"extra",
"=",
"$",
"package",
"->",
"extra",
";",
"if",
"(",
"!",
"property_exists",
"(",
"$",
"extra",
",",
"'resources'",
")",
")",
"continue",
";",
"$",
"resources",
"=",
"$",
"extra",
"->",
"resources",
";",
"foreach",
"(",
"$",
"resources",
"as",
"$",
"resource",
"=>",
"$",
"namespaces",
")",
"{",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"namespace",
"=>",
"$",
"path",
")",
"{",
"$",
"finder",
"->",
"exclude",
"(",
"$",
"namespace",
")",
";",
"$",
"data",
"[",
"$",
"resource",
"]",
"[",
"$",
"namespace",
"]",
"=",
"$",
"path",
";",
"}",
"}",
"}",
"// We turn the iterator to an array to",
"// prevent an exception when we delete the directorys",
"foreach",
"(",
"iterator_to_array",
"(",
"$",
"finder",
")",
"as",
"$",
"file",
")",
"{",
"\\",
"Filesystem",
"::",
"deleteDirectory",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"}",
"file_put_contents",
"(",
"static",
"::",
"$",
"resourcesPath",
".",
"'/resources.lock'",
",",
"json_encode",
"(",
"$",
"data",
",",
"JSON_PRETTY_PRINT",
")",
")",
";",
"}"
] | Run composer post-install script
@param Event $event
@return void | [
"Run",
"composer",
"post",
"-",
"install",
"script"
] | 3a1980a8aab0ac6d4298f0368f319620ddb1e644 | https://github.com/encorephp/kernel/blob/3a1980a8aab0ac6d4298f0368f319620ddb1e644/src/Composer/Script.php#L48-L88 |
11,220 | K-Phoen/NegotiationServiceProvider | src/KPhoen/Provider/NegotiationServiceProvider.php | NegotiationServiceProvider.register | public function register(Application $app)
{
$this->app = $app;
$app['negotiator'] = $app->share(function ($app) {
return new \Negotiation\Negotiator();
});
$app['language.negotiator'] = $app->share(function ($app) {
return new \Negotiation\LanguageNegotiator();
});
$customFormats = $this->customFormats;
$app['format.negotiator'] = $app->share(function ($app) use($customFormats) {
$negotiator = new \Negotiation\FormatNegotiator();
// add new formats
foreach ($customFormats as $name => $mimeTypes) {
$negotiator->registerFormat($name, $mimeTypes, true);
}
return $negotiator;
});
} | php | public function register(Application $app)
{
$this->app = $app;
$app['negotiator'] = $app->share(function ($app) {
return new \Negotiation\Negotiator();
});
$app['language.negotiator'] = $app->share(function ($app) {
return new \Negotiation\LanguageNegotiator();
});
$customFormats = $this->customFormats;
$app['format.negotiator'] = $app->share(function ($app) use($customFormats) {
$negotiator = new \Negotiation\FormatNegotiator();
// add new formats
foreach ($customFormats as $name => $mimeTypes) {
$negotiator->registerFormat($name, $mimeTypes, true);
}
return $negotiator;
});
} | [
"public",
"function",
"register",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"app",
"=",
"$",
"app",
";",
"$",
"app",
"[",
"'negotiator'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"\\",
"Negotiation",
"\\",
"Negotiator",
"(",
")",
";",
"}",
")",
";",
"$",
"app",
"[",
"'language.negotiator'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"\\",
"Negotiation",
"\\",
"LanguageNegotiator",
"(",
")",
";",
"}",
")",
";",
"$",
"customFormats",
"=",
"$",
"this",
"->",
"customFormats",
";",
"$",
"app",
"[",
"'format.negotiator'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"use",
"(",
"$",
"customFormats",
")",
"{",
"$",
"negotiator",
"=",
"new",
"\\",
"Negotiation",
"\\",
"FormatNegotiator",
"(",
")",
";",
"// add new formats",
"foreach",
"(",
"$",
"customFormats",
"as",
"$",
"name",
"=>",
"$",
"mimeTypes",
")",
"{",
"$",
"negotiator",
"->",
"registerFormat",
"(",
"$",
"name",
",",
"$",
"mimeTypes",
",",
"true",
")",
";",
"}",
"return",
"$",
"negotiator",
";",
"}",
")",
";",
"}"
] | Register the services in the application.
@param Application $app The application. | [
"Register",
"the",
"services",
"in",
"the",
"application",
"."
] | 10789b4041aa593f79f14519c6c7078c570c5fcd | https://github.com/K-Phoen/NegotiationServiceProvider/blob/10789b4041aa593f79f14519c6c7078c570c5fcd/src/KPhoen/Provider/NegotiationServiceProvider.php#L42-L66 |
11,221 | K-Phoen/NegotiationServiceProvider | src/KPhoen/Provider/NegotiationServiceProvider.php | NegotiationServiceProvider.onEarlyKernelRequest | public function onEarlyKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
foreach ($this->customFormats as $name => $mimeTypes) {
$request->setFormat($name, $mimeTypes);
}
} | php | public function onEarlyKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
foreach ($this->customFormats as $name => $mimeTypes) {
$request->setFormat($name, $mimeTypes);
}
} | [
"public",
"function",
"onEarlyKernelRequest",
"(",
"GetResponseEvent",
"$",
"event",
")",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"customFormats",
"as",
"$",
"name",
"=>",
"$",
"mimeTypes",
")",
"{",
"$",
"request",
"->",
"setFormat",
"(",
"$",
"name",
",",
"$",
"mimeTypes",
")",
";",
"}",
"}"
] | Update the request with the given custom formats.
@param GetResponseEvent $event The event. | [
"Update",
"the",
"request",
"with",
"the",
"given",
"custom",
"formats",
"."
] | 10789b4041aa593f79f14519c6c7078c570c5fcd | https://github.com/K-Phoen/NegotiationServiceProvider/blob/10789b4041aa593f79f14519c6c7078c570c5fcd/src/KPhoen/Provider/NegotiationServiceProvider.php#L84-L90 |
11,222 | quantaphp/exceptions | src/ReturnTypeErrorMessage.php | ReturnTypeErrorMessage.tpl | private function tpl(): string
{
if (interface_exists($this->type)) {
return 'Return value of %s must implement interface %s, %s returned';
}
if (class_exists($this->type)) {
return 'Return value of %s must be an instance of %s, %s returned';
}
if ($this->type == 'callable') {
return 'Return value of %s must be %s, %s returned';
}
return 'Return value of %s must be of the type %s, %s returned';
} | php | private function tpl(): string
{
if (interface_exists($this->type)) {
return 'Return value of %s must implement interface %s, %s returned';
}
if (class_exists($this->type)) {
return 'Return value of %s must be an instance of %s, %s returned';
}
if ($this->type == 'callable') {
return 'Return value of %s must be %s, %s returned';
}
return 'Return value of %s must be of the type %s, %s returned';
} | [
"private",
"function",
"tpl",
"(",
")",
":",
"string",
"{",
"if",
"(",
"interface_exists",
"(",
"$",
"this",
"->",
"type",
")",
")",
"{",
"return",
"'Return value of %s must implement interface %s, %s returned'",
";",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"this",
"->",
"type",
")",
")",
"{",
"return",
"'Return value of %s must be an instance of %s, %s returned'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"'callable'",
")",
"{",
"return",
"'Return value of %s must be %s, %s returned'",
";",
"}",
"return",
"'Return value of %s must be of the type %s, %s returned'",
";",
"}"
] | Return the template of the error message accoring to the expected type.
@return string | [
"Return",
"the",
"template",
"of",
"the",
"error",
"message",
"accoring",
"to",
"the",
"expected",
"type",
"."
] | b1cde0096fe0c31eb550e53dd373820629a521fd | https://github.com/quantaphp/exceptions/blob/b1cde0096fe0c31eb550e53dd373820629a521fd/src/ReturnTypeErrorMessage.php#L63-L78 |
11,223 | budkit/budkit-framework | src/Budkit/Datastore/Model/Graph.php | Graph.getInstance | public static function getInstance($graphUID = NULL, $nodes = array(), $edges = array(), $directed = FALSE)
{
if (is_object(static::$instance[$graphUID]) && is_a(static::$instance[$graphUID], 'Graph'))
return static::$instance[$graphUID];
$graph = new self($nodes, $edges, $directed, $graphUID);
if (!empty($graphUID)) {
static::$instance[$graphUID] = &$graph;
}
return $graph;
} | php | public static function getInstance($graphUID = NULL, $nodes = array(), $edges = array(), $directed = FALSE)
{
if (is_object(static::$instance[$graphUID]) && is_a(static::$instance[$graphUID], 'Graph'))
return static::$instance[$graphUID];
$graph = new self($nodes, $edges, $directed, $graphUID);
if (!empty($graphUID)) {
static::$instance[$graphUID] = &$graph;
}
return $graph;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"graphUID",
"=",
"NULL",
",",
"$",
"nodes",
"=",
"array",
"(",
")",
",",
"$",
"edges",
"=",
"array",
"(",
")",
",",
"$",
"directed",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_object",
"(",
"static",
"::",
"$",
"instance",
"[",
"$",
"graphUID",
"]",
")",
"&&",
"is_a",
"(",
"static",
"::",
"$",
"instance",
"[",
"$",
"graphUID",
"]",
",",
"'Graph'",
")",
")",
"return",
"static",
"::",
"$",
"instance",
"[",
"$",
"graphUID",
"]",
";",
"$",
"graph",
"=",
"new",
"self",
"(",
"$",
"nodes",
",",
"$",
"edges",
",",
"$",
"directed",
",",
"$",
"graphUID",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"graphUID",
")",
")",
"{",
"static",
"::",
"$",
"instance",
"[",
"$",
"graphUID",
"]",
"=",
"&",
"$",
"graph",
";",
"}",
"return",
"$",
"graph",
";",
"}"
] | Returns and instantiated Instance of the graph class
NOTE: As of PHP5.3 it is vital that you include constructors in your class
especially if they are defined under a namespace. A method with the same
name as the class is no longer considered to be its constructor
@staticvar object $instance
@property-read object $instance To determine if class was previously instantiated
@property-write object $instance
@return object graph | [
"Returns",
"and",
"instantiated",
"Instance",
"of",
"the",
"graph",
"class"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Graph.php#L105-L114 |
11,224 | budkit/budkit-framework | src/Budkit/Datastore/Model/Graph.php | Graph.getNode | public function getNode($nodeId)
{
static $instance = array();
if (isset($instance[$nodeId]))
return $instance[$nodeId];
$nodes = $this->nodeSet;
if (empty($nodes))
return NULL;
foreach ($nodes as $node):
if ($node->getId() == $nodeId):
$instance[$nodeId] = &$node;
break;
endif;
endforeach;
return NULL;
} | php | public function getNode($nodeId)
{
static $instance = array();
if (isset($instance[$nodeId]))
return $instance[$nodeId];
$nodes = $this->nodeSet;
if (empty($nodes))
return NULL;
foreach ($nodes as $node):
if ($node->getId() == $nodeId):
$instance[$nodeId] = &$node;
break;
endif;
endforeach;
return NULL;
} | [
"public",
"function",
"getNode",
"(",
"$",
"nodeId",
")",
"{",
"static",
"$",
"instance",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"instance",
"[",
"$",
"nodeId",
"]",
")",
")",
"return",
"$",
"instance",
"[",
"$",
"nodeId",
"]",
";",
"$",
"nodes",
"=",
"$",
"this",
"->",
"nodeSet",
";",
"if",
"(",
"empty",
"(",
"$",
"nodes",
")",
")",
"return",
"NULL",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
":",
"if",
"(",
"$",
"node",
"->",
"getId",
"(",
")",
"==",
"$",
"nodeId",
")",
":",
"$",
"instance",
"[",
"$",
"nodeId",
"]",
"=",
"&",
"$",
"node",
";",
"break",
";",
"endif",
";",
"endforeach",
";",
"return",
"NULL",
";",
"}"
] | Returns a node object if exists in graph
@param type $nodeId case sensitive ID of the node requested
@return object $node if found; | [
"Returns",
"a",
"node",
"object",
"if",
"exists",
"in",
"graph"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Graph.php#L238-L253 |
11,225 | budkit/budkit-framework | src/Budkit/Datastore/Model/Graph.php | Graph.addEdge | public function addEdge(&$nodeA, &$nodeB, $name = NULL, $directed = TRUE, $data = array(), $weight = 0)
{
$edge = new Graph\Edge($nodeA, $name, $nodeB, $data, $directed, $weight); //Will need to decide whether to use nodeAId-nodeBId as edgeId
$edgeId = $edge->getId();
//Directed edges have their Id's referenced in arcSet
if ($directed && !in_array($edgeId, $this->arcSet))
$this->arcSet[] = $edgeId;
//@TODO This is not the ideal way to set parrallel edges, Parralel edges connect the same pair of nodes
//If edge already exists, increment the weight;
if (isset($this->edgeSet[$edgeId])) {
$this->edgeSet[$edgeId]->weight++;
$edgeData = $this->edgeSet[$edgeId]->getData();
$data = array_merge($edgeData, $data);
//Makeing a directed array undirected
if (!$directed && in_array($edgeId, $this->arcSet))
$this->arcSet = array_diff($this->arcSet, array($edgeId));
return true;
}
//array_merge edge data
if (!isset($this->edgeSet[$edgeId]))
$this->edgeSet[$edgeId] = &$edge;
//If directed, use edgeIsArc to indicate;
return true;
} | php | public function addEdge(&$nodeA, &$nodeB, $name = NULL, $directed = TRUE, $data = array(), $weight = 0)
{
$edge = new Graph\Edge($nodeA, $name, $nodeB, $data, $directed, $weight); //Will need to decide whether to use nodeAId-nodeBId as edgeId
$edgeId = $edge->getId();
//Directed edges have their Id's referenced in arcSet
if ($directed && !in_array($edgeId, $this->arcSet))
$this->arcSet[] = $edgeId;
//@TODO This is not the ideal way to set parrallel edges, Parralel edges connect the same pair of nodes
//If edge already exists, increment the weight;
if (isset($this->edgeSet[$edgeId])) {
$this->edgeSet[$edgeId]->weight++;
$edgeData = $this->edgeSet[$edgeId]->getData();
$data = array_merge($edgeData, $data);
//Makeing a directed array undirected
if (!$directed && in_array($edgeId, $this->arcSet))
$this->arcSet = array_diff($this->arcSet, array($edgeId));
return true;
}
//array_merge edge data
if (!isset($this->edgeSet[$edgeId]))
$this->edgeSet[$edgeId] = &$edge;
//If directed, use edgeIsArc to indicate;
return true;
} | [
"public",
"function",
"addEdge",
"(",
"&",
"$",
"nodeA",
",",
"&",
"$",
"nodeB",
",",
"$",
"name",
"=",
"NULL",
",",
"$",
"directed",
"=",
"TRUE",
",",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"weight",
"=",
"0",
")",
"{",
"$",
"edge",
"=",
"new",
"Graph",
"\\",
"Edge",
"(",
"$",
"nodeA",
",",
"$",
"name",
",",
"$",
"nodeB",
",",
"$",
"data",
",",
"$",
"directed",
",",
"$",
"weight",
")",
";",
"//Will need to decide whether to use nodeAId-nodeBId as edgeId",
"$",
"edgeId",
"=",
"$",
"edge",
"->",
"getId",
"(",
")",
";",
"//Directed edges have their Id's referenced in arcSet",
"if",
"(",
"$",
"directed",
"&&",
"!",
"in_array",
"(",
"$",
"edgeId",
",",
"$",
"this",
"->",
"arcSet",
")",
")",
"$",
"this",
"->",
"arcSet",
"[",
"]",
"=",
"$",
"edgeId",
";",
"//@TODO This is not the ideal way to set parrallel edges, Parralel edges connect the same pair of nodes",
"//If edge already exists, increment the weight;",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"edgeSet",
"[",
"$",
"edgeId",
"]",
")",
")",
"{",
"$",
"this",
"->",
"edgeSet",
"[",
"$",
"edgeId",
"]",
"->",
"weight",
"++",
";",
"$",
"edgeData",
"=",
"$",
"this",
"->",
"edgeSet",
"[",
"$",
"edgeId",
"]",
"->",
"getData",
"(",
")",
";",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"edgeData",
",",
"$",
"data",
")",
";",
"//Makeing a directed array undirected",
"if",
"(",
"!",
"$",
"directed",
"&&",
"in_array",
"(",
"$",
"edgeId",
",",
"$",
"this",
"->",
"arcSet",
")",
")",
"$",
"this",
"->",
"arcSet",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"arcSet",
",",
"array",
"(",
"$",
"edgeId",
")",
")",
";",
"return",
"true",
";",
"}",
"//array_merge edge data",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"edgeSet",
"[",
"$",
"edgeId",
"]",
")",
")",
"$",
"this",
"->",
"edgeSet",
"[",
"$",
"edgeId",
"]",
"=",
"&",
"$",
"edge",
";",
"//If directed, use edgeIsArc to indicate;",
"return",
"true",
";",
"}"
] | Adds an edge between two node endpoints.
@param type $nodeA
@param type $nodeB
@param type $name
@param type $data
@param type $directed
@param type $weight
@return boolean | [
"Adds",
"an",
"edge",
"between",
"two",
"node",
"endpoints",
"."
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Graph.php#L266-L293 |
11,226 | budkit/budkit-framework | src/Budkit/Datastore/Model/Graph.php | Graph.removeNode | public function removeNode($nodeId)
{
if (isset($this->nodeSet[$nodeId]))
unset($this->nodeSet[$nodeId]);
return true;
} | php | public function removeNode($nodeId)
{
if (isset($this->nodeSet[$nodeId]))
unset($this->nodeSet[$nodeId]);
return true;
} | [
"public",
"function",
"removeNode",
"(",
"$",
"nodeId",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"nodeSet",
"[",
"$",
"nodeId",
"]",
")",
")",
"unset",
"(",
"$",
"this",
"->",
"nodeSet",
"[",
"$",
"nodeId",
"]",
")",
";",
"return",
"true",
";",
"}"
] | Removes a node from the graph
@param type $nodeId | [
"Removes",
"a",
"node",
"from",
"the",
"graph"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Graph.php#L300-L305 |
11,227 | budkit/budkit-framework | src/Budkit/Datastore/Model/Graph.php | Graph.removeEdge | public function removeEdge(&$head, &$tail, $directed = TRUE)
{
if (!is_a($head, "\Platform\Graph\Node") || !is_a($tail, "\Platform\Graph\Node")) {
throw new \Platform\Exception("Nodes used to create a new Edge must be instances of \Platform\Graph\Node", PLATFORM_ERROR);
}
$_nodeIds = array($head->getId(), $tail->getId());
$edges = $this->edgeSet;
//find all edges with these two nodes incident
foreach ($edges as $edge):
echo $edge->getId() . "<br />";
if (in_array($edge->getHead()->getId(), $_nodeIds) && in_array($edge->getTail()->getId(), $_nodeIds)):
if (!$directed):
unset($this->edgeSet[$edge->getId()]);
elseif ($edge->getHead()->getId() == reset($_nodeIds) && $edge->getTail()->getId() == end($_nodeIds)):
//Remove the value from the arcSet array
$this->arcSet = array_diff($this->arcSet, array($edge->getId()));
unset($this->edgeSet[$edge->getId()]);
endif;
endif;
endforeach;
return true;
} | php | public function removeEdge(&$head, &$tail, $directed = TRUE)
{
if (!is_a($head, "\Platform\Graph\Node") || !is_a($tail, "\Platform\Graph\Node")) {
throw new \Platform\Exception("Nodes used to create a new Edge must be instances of \Platform\Graph\Node", PLATFORM_ERROR);
}
$_nodeIds = array($head->getId(), $tail->getId());
$edges = $this->edgeSet;
//find all edges with these two nodes incident
foreach ($edges as $edge):
echo $edge->getId() . "<br />";
if (in_array($edge->getHead()->getId(), $_nodeIds) && in_array($edge->getTail()->getId(), $_nodeIds)):
if (!$directed):
unset($this->edgeSet[$edge->getId()]);
elseif ($edge->getHead()->getId() == reset($_nodeIds) && $edge->getTail()->getId() == end($_nodeIds)):
//Remove the value from the arcSet array
$this->arcSet = array_diff($this->arcSet, array($edge->getId()));
unset($this->edgeSet[$edge->getId()]);
endif;
endif;
endforeach;
return true;
} | [
"public",
"function",
"removeEdge",
"(",
"&",
"$",
"head",
",",
"&",
"$",
"tail",
",",
"$",
"directed",
"=",
"TRUE",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"head",
",",
"\"\\Platform\\Graph\\Node\"",
")",
"||",
"!",
"is_a",
"(",
"$",
"tail",
",",
"\"\\Platform\\Graph\\Node\"",
")",
")",
"{",
"throw",
"new",
"\\",
"Platform",
"\\",
"Exception",
"(",
"\"Nodes used to create a new Edge must be instances of \\Platform\\Graph\\Node\"",
",",
"PLATFORM_ERROR",
")",
";",
"}",
"$",
"_nodeIds",
"=",
"array",
"(",
"$",
"head",
"->",
"getId",
"(",
")",
",",
"$",
"tail",
"->",
"getId",
"(",
")",
")",
";",
"$",
"edges",
"=",
"$",
"this",
"->",
"edgeSet",
";",
"//find all edges with these two nodes incident",
"foreach",
"(",
"$",
"edges",
"as",
"$",
"edge",
")",
":",
"echo",
"$",
"edge",
"->",
"getId",
"(",
")",
".",
"\"<br />\"",
";",
"if",
"(",
"in_array",
"(",
"$",
"edge",
"->",
"getHead",
"(",
")",
"->",
"getId",
"(",
")",
",",
"$",
"_nodeIds",
")",
"&&",
"in_array",
"(",
"$",
"edge",
"->",
"getTail",
"(",
")",
"->",
"getId",
"(",
")",
",",
"$",
"_nodeIds",
")",
")",
":",
"if",
"(",
"!",
"$",
"directed",
")",
":",
"unset",
"(",
"$",
"this",
"->",
"edgeSet",
"[",
"$",
"edge",
"->",
"getId",
"(",
")",
"]",
")",
";",
"elseif",
"(",
"$",
"edge",
"->",
"getHead",
"(",
")",
"->",
"getId",
"(",
")",
"==",
"reset",
"(",
"$",
"_nodeIds",
")",
"&&",
"$",
"edge",
"->",
"getTail",
"(",
")",
"->",
"getId",
"(",
")",
"==",
"end",
"(",
"$",
"_nodeIds",
")",
")",
":",
"//Remove the value from the arcSet array",
"$",
"this",
"->",
"arcSet",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"arcSet",
",",
"array",
"(",
"$",
"edge",
"->",
"getId",
"(",
")",
")",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"edgeSet",
"[",
"$",
"edge",
"->",
"getId",
"(",
")",
"]",
")",
";",
"endif",
";",
"endif",
";",
"endforeach",
";",
"return",
"true",
";",
"}"
] | Removes an Edge from the graph. Use removeArc to remove directed edges
@param type $head
@param type $tail
@param type $directed if false, will remove all incident edges of the kind head-tail or tail-head
@return boolean
@throws \Platform\Exception | [
"Removes",
"an",
"Edge",
"from",
"the",
"graph",
".",
"Use",
"removeArc",
"to",
"remove",
"directed",
"edges"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Graph.php#L316-L339 |
11,228 | budkit/budkit-framework | src/Budkit/Datastore/Model/Graph.php | Graph.createNode | public function createNode($nodeId, $data = array())
{
$node = new Graph\Node($nodeId, $data);
$node->setGraph($this);
$this->addNode($node);
return $node;
} | php | public function createNode($nodeId, $data = array())
{
$node = new Graph\Node($nodeId, $data);
$node->setGraph($this);
$this->addNode($node);
return $node;
} | [
"public",
"function",
"createNode",
"(",
"$",
"nodeId",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"node",
"=",
"new",
"Graph",
"\\",
"Node",
"(",
"$",
"nodeId",
",",
"$",
"data",
")",
";",
"$",
"node",
"->",
"setGraph",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"addNode",
"(",
"$",
"node",
")",
";",
"return",
"$",
"node",
";",
"}"
] | Creates and adds a Node to the graph if none, already exists
@param type $nodeId
@param type $data | [
"Creates",
"and",
"adds",
"a",
"Node",
"to",
"the",
"graph",
"if",
"none",
"already",
"exists"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Graph.php#L361-L369 |
11,229 | budkit/budkit-framework | src/Budkit/Datastore/Model/Graph.php | Graph.addNode | public function addNode(&$node)
{
//Nodes must be an instance graph Node;
if (!$this->isNode($node)) {
throw new \Exception("Node must be an instance of Graph\Node", PLATFORM_ERROR);
}
$nodedId = $node->getId();
if (!empty($nodedId) && !isset($this->nodeSet[$node->getId()])) {
$this->nodeSet[$node->getId()] = &$node;
}
return $this;
} | php | public function addNode(&$node)
{
//Nodes must be an instance graph Node;
if (!$this->isNode($node)) {
throw new \Exception("Node must be an instance of Graph\Node", PLATFORM_ERROR);
}
$nodedId = $node->getId();
if (!empty($nodedId) && !isset($this->nodeSet[$node->getId()])) {
$this->nodeSet[$node->getId()] = &$node;
}
return $this;
} | [
"public",
"function",
"addNode",
"(",
"&",
"$",
"node",
")",
"{",
"//Nodes must be an instance graph Node;",
"if",
"(",
"!",
"$",
"this",
"->",
"isNode",
"(",
"$",
"node",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Node must be an instance of Graph\\Node\"",
",",
"PLATFORM_ERROR",
")",
";",
"}",
"$",
"nodedId",
"=",
"$",
"node",
"->",
"getId",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"nodedId",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"nodeSet",
"[",
"$",
"node",
"->",
"getId",
"(",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"nodeSet",
"[",
"$",
"node",
"->",
"getId",
"(",
")",
"]",
"=",
"&",
"$",
"node",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a node to the current graph
@param type $node | [
"Adds",
"a",
"node",
"to",
"the",
"current",
"graph"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Graph.php#L376-L387 |
11,230 | fabsgc/framework | Core/Cache/Cache.php | Cache.destroy | public function destroy() {
if (file_exists($this->_fileName)) {
if (unlink($this->_fileName)) {
return true;
}
else {
return false;
}
}
else {
return true;
}
} | php | public function destroy() {
if (file_exists($this->_fileName)) {
if (unlink($this->_fileName)) {
return true;
}
else {
return false;
}
}
else {
return true;
}
} | [
"public",
"function",
"destroy",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"_fileName",
")",
")",
"{",
"if",
"(",
"unlink",
"(",
"$",
"this",
"->",
"_fileName",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | destroy a cache file
@access public
@return boolean
@since 3.0
@package Gcs\Framework\Core\Cache | [
"destroy",
"a",
"cache",
"file"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Cache/Cache.php#L105-L117 |
11,231 | fabsgc/framework | Core/Cache/Cache.php | Cache.getCache | public function getCache() {
if (!file_exists($this->_fileName)) {
$this->setCache();
}
return unserialize(($this->_uncompress(file_get_contents($this->_fileName))));
} | php | public function getCache() {
if (!file_exists($this->_fileName)) {
$this->setCache();
}
return unserialize(($this->_uncompress(file_get_contents($this->_fileName))));
} | [
"public",
"function",
"getCache",
"(",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"_fileName",
")",
")",
"{",
"$",
"this",
"->",
"setCache",
"(",
")",
";",
"}",
"return",
"unserialize",
"(",
"(",
"$",
"this",
"->",
"_uncompress",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"_fileName",
")",
")",
")",
")",
";",
"}"
] | get cache content
@access public
@return mixed
@since 3.0
@package Gcs\Framework\Core\Cache | [
"get",
"cache",
"content"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Cache/Cache.php#L127-L133 |
11,232 | fabsgc/framework | Core/Cache/Cache.php | Cache.setCache | public function setCache() {
if (!file_exists($this->_fileName)) {
file_put_contents($this->_fileName, $this->_compress(serialize($this->_content)));
}
$timeAgo = time() - filemtime($this->_fileName);
if ($timeAgo > $this->_time) {
file_put_contents($this->_fileName, $this->_compress(serialize($this->_content)));
}
} | php | public function setCache() {
if (!file_exists($this->_fileName)) {
file_put_contents($this->_fileName, $this->_compress(serialize($this->_content)));
}
$timeAgo = time() - filemtime($this->_fileName);
if ($timeAgo > $this->_time) {
file_put_contents($this->_fileName, $this->_compress(serialize($this->_content)));
}
} | [
"public",
"function",
"setCache",
"(",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"_fileName",
")",
")",
"{",
"file_put_contents",
"(",
"$",
"this",
"->",
"_fileName",
",",
"$",
"this",
"->",
"_compress",
"(",
"serialize",
"(",
"$",
"this",
"->",
"_content",
")",
")",
")",
";",
"}",
"$",
"timeAgo",
"=",
"time",
"(",
")",
"-",
"filemtime",
"(",
"$",
"this",
"->",
"_fileName",
")",
";",
"if",
"(",
"$",
"timeAgo",
">",
"$",
"this",
"->",
"_time",
")",
"{",
"file_put_contents",
"(",
"$",
"this",
"->",
"_fileName",
",",
"$",
"this",
"->",
"_compress",
"(",
"serialize",
"(",
"$",
"this",
"->",
"_content",
")",
")",
")",
";",
"}",
"}"
] | create the file cache
@access public
@return void
@since 3.0
@package Gcs\Framework\Core\Cache | [
"create",
"the",
"file",
"cache"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Cache/Cache.php#L156-L166 |
11,233 | fabsgc/framework | Core/Cache/Cache.php | Cache.isDie | public function isDie() {
if ($this->_time > 0) {
$die = false;
if (!file_exists($this->_fileName)) {
$die = true;
}
else {
$timeAgo = time() - filemtime($this->_fileName);
if ($timeAgo > $this->_time) {
$die = true;
}
}
return $die;
}
else {
return true;
}
} | php | public function isDie() {
if ($this->_time > 0) {
$die = false;
if (!file_exists($this->_fileName)) {
$die = true;
}
else {
$timeAgo = time() - filemtime($this->_fileName);
if ($timeAgo > $this->_time) {
$die = true;
}
}
return $die;
}
else {
return true;
}
} | [
"public",
"function",
"isDie",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_time",
">",
"0",
")",
"{",
"$",
"die",
"=",
"false",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"_fileName",
")",
")",
"{",
"$",
"die",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"timeAgo",
"=",
"time",
"(",
")",
"-",
"filemtime",
"(",
"$",
"this",
"->",
"_fileName",
")",
";",
"if",
"(",
"$",
"timeAgo",
">",
"$",
"this",
"->",
"_time",
")",
"{",
"$",
"die",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"die",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | return true if the cache is too old
@access public
@return string
@since 3.0
@package Gcs\Framework\Core\Cache | [
"return",
"true",
"if",
"the",
"cache",
"is",
"too",
"old"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Cache/Cache.php#L189-L208 |
11,234 | osflab/generator | AbstractBuilder.php | AbstractBuilder.get | public static function get(string $name, array $args = [], $persistant = false)
{
if (!is_array(static::$classes)) {
throw new ArchException('A static property $classes with an array of classes must be declared in class [' . __CLASS__ . ']');
}
if (!array_key_exists($name, static::$classes)) {
throw new ArchException('Unknown object [' . $name . ']');
}
return self::buildClass(static::$classes[$name], $args, $persistant);
} | php | public static function get(string $name, array $args = [], $persistant = false)
{
if (!is_array(static::$classes)) {
throw new ArchException('A static property $classes with an array of classes must be declared in class [' . __CLASS__ . ']');
}
if (!array_key_exists($name, static::$classes)) {
throw new ArchException('Unknown object [' . $name . ']');
}
return self::buildClass(static::$classes[$name], $args, $persistant);
} | [
"public",
"static",
"function",
"get",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"persistant",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"static",
"::",
"$",
"classes",
")",
")",
"{",
"throw",
"new",
"ArchException",
"(",
"'A static property $classes with an array of classes must be declared in class ['",
".",
"__CLASS__",
".",
"']'",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"static",
"::",
"$",
"classes",
")",
")",
"{",
"throw",
"new",
"ArchException",
"(",
"'Unknown object ['",
".",
"$",
"name",
".",
"']'",
")",
";",
"}",
"return",
"self",
"::",
"buildClass",
"(",
"static",
"::",
"$",
"classes",
"[",
"$",
"name",
"]",
",",
"$",
"args",
",",
"$",
"persistant",
")",
";",
"}"
] | Return an instance of corresponding object
@param string $name
@param array $args
@param type $persistant
@throws \Osf\Exception\ArchException | [
"Return",
"an",
"instance",
"of",
"corresponding",
"object"
] | 60bc0bcf466898fe3676434f995a18d493c5c31a | https://github.com/osflab/generator/blob/60bc0bcf466898fe3676434f995a18d493c5c31a/AbstractBuilder.php#L52-L61 |
11,235 | osflab/generator | AbstractBuilder.php | AbstractBuilder.getClass | public static function getClass(string $name)
{
if (!isset(static::$classes[$name])) {
throw new ArchException('Unable to find class from key [' . $name . ']');
}
return static::$classes[$name];
} | php | public static function getClass(string $name)
{
if (!isset(static::$classes[$name])) {
throw new ArchException('Unable to find class from key [' . $name . ']');
}
return static::$classes[$name];
} | [
"public",
"static",
"function",
"getClass",
"(",
"string",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"classes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"ArchException",
"(",
"'Unable to find class from key ['",
".",
"$",
"name",
".",
"']'",
")",
";",
"}",
"return",
"static",
"::",
"$",
"classes",
"[",
"$",
"name",
"]",
";",
"}"
] | Get full class name from key
@param string $name
@return string
@throws \Osf\Exception\ArchException | [
"Get",
"full",
"class",
"name",
"from",
"key"
] | 60bc0bcf466898fe3676434f995a18d493c5c31a | https://github.com/osflab/generator/blob/60bc0bcf466898fe3676434f995a18d493c5c31a/AbstractBuilder.php#L69-L75 |
11,236 | osflab/generator | AbstractBuilder.php | AbstractBuilder.newObject | public static function newObject(string $class, array $args = [], $callGetClass = false)
{
$class = $callGetClass ? static::getClass($class) : $class;
$rc = new \ReflectionClass($class);
return $rc->newInstanceArgs($args);
} | php | public static function newObject(string $class, array $args = [], $callGetClass = false)
{
$class = $callGetClass ? static::getClass($class) : $class;
$rc = new \ReflectionClass($class);
return $rc->newInstanceArgs($args);
} | [
"public",
"static",
"function",
"newObject",
"(",
"string",
"$",
"class",
",",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"callGetClass",
"=",
"false",
")",
"{",
"$",
"class",
"=",
"$",
"callGetClass",
"?",
"static",
"::",
"getClass",
"(",
"$",
"class",
")",
":",
"$",
"class",
";",
"$",
"rc",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"return",
"$",
"rc",
"->",
"newInstanceArgs",
"(",
"$",
"args",
")",
";",
"}"
] | Instanciate a class dynamically
@param string $class
@param array $args
@return stdClass | [
"Instanciate",
"a",
"class",
"dynamically"
] | 60bc0bcf466898fe3676434f995a18d493c5c31a | https://github.com/osflab/generator/blob/60bc0bcf466898fe3676434f995a18d493c5c31a/AbstractBuilder.php#L83-L88 |
11,237 | jaredtking/jaqb | src/Statement/ValuesStatement.php | ValuesStatement.addValues | public function addValues(array $values)
{
// Check if this is a multi-dimensional array
$isMultiDimensional = 0 == count($values) || (isset($values[0]) && is_array($values[0]));
if ($isMultiDimensional) {
$this->insertRows = array_merge($this->insertRows, $values);
} else {
// If a single row is provided then it is added
// to the last row, or a new row if there are none.
// This is done to maintain BC
if (count($this->insertRows) > 0) {
$k = count($this->insertRows) - 1;
$this->insertRows[$k] = array_replace($this->insertRows[$k], $values);
} else {
$this->insertRows = [$values];
}
}
return $this;
} | php | public function addValues(array $values)
{
// Check if this is a multi-dimensional array
$isMultiDimensional = 0 == count($values) || (isset($values[0]) && is_array($values[0]));
if ($isMultiDimensional) {
$this->insertRows = array_merge($this->insertRows, $values);
} else {
// If a single row is provided then it is added
// to the last row, or a new row if there are none.
// This is done to maintain BC
if (count($this->insertRows) > 0) {
$k = count($this->insertRows) - 1;
$this->insertRows[$k] = array_replace($this->insertRows[$k], $values);
} else {
$this->insertRows = [$values];
}
}
return $this;
} | [
"public",
"function",
"addValues",
"(",
"array",
"$",
"values",
")",
"{",
"// Check if this is a multi-dimensional array",
"$",
"isMultiDimensional",
"=",
"0",
"==",
"count",
"(",
"$",
"values",
")",
"||",
"(",
"isset",
"(",
"$",
"values",
"[",
"0",
"]",
")",
"&&",
"is_array",
"(",
"$",
"values",
"[",
"0",
"]",
")",
")",
";",
"if",
"(",
"$",
"isMultiDimensional",
")",
"{",
"$",
"this",
"->",
"insertRows",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"insertRows",
",",
"$",
"values",
")",
";",
"}",
"else",
"{",
"// If a single row is provided then it is added",
"// to the last row, or a new row if there are none.",
"// This is done to maintain BC",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"insertRows",
")",
">",
"0",
")",
"{",
"$",
"k",
"=",
"count",
"(",
"$",
"this",
"->",
"insertRows",
")",
"-",
"1",
";",
"$",
"this",
"->",
"insertRows",
"[",
"$",
"k",
"]",
"=",
"array_replace",
"(",
"$",
"this",
"->",
"insertRows",
"[",
"$",
"k",
"]",
",",
"$",
"values",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"insertRows",
"=",
"[",
"$",
"values",
"]",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds values to the statement.
@return self | [
"Adds",
"values",
"to",
"the",
"statement",
"."
] | 04a853b530fcc12a9863349d3d0da6377d1b9995 | https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/ValuesStatement.php#L26-L46 |
11,238 | PaymentSuite/PaymillBundle | Services/Wrapper/PaymillTransactionWrapper.php | PaymillTransactionWrapper.create | public function create($amount, $currency, $token, $description = "")
{
$service = new Request($this->apiKey);
$transaction = new RequestTransaction();
$transaction
->setAmount($amount)
->setCurrency($currency)
->setToken($token)
->setDescription($description);
/**
* @var \Paymill\Models\Response\Base $response
*/
$response = $service->create($transaction);
return $response;
} | php | public function create($amount, $currency, $token, $description = "")
{
$service = new Request($this->apiKey);
$transaction = new RequestTransaction();
$transaction
->setAmount($amount)
->setCurrency($currency)
->setToken($token)
->setDescription($description);
/**
* @var \Paymill\Models\Response\Base $response
*/
$response = $service->create($transaction);
return $response;
} | [
"public",
"function",
"create",
"(",
"$",
"amount",
",",
"$",
"currency",
",",
"$",
"token",
",",
"$",
"description",
"=",
"\"\"",
")",
"{",
"$",
"service",
"=",
"new",
"Request",
"(",
"$",
"this",
"->",
"apiKey",
")",
";",
"$",
"transaction",
"=",
"new",
"RequestTransaction",
"(",
")",
";",
"$",
"transaction",
"->",
"setAmount",
"(",
"$",
"amount",
")",
"->",
"setCurrency",
"(",
"$",
"currency",
")",
"->",
"setToken",
"(",
"$",
"token",
")",
"->",
"setDescription",
"(",
"$",
"description",
")",
";",
"/**\n * @var \\Paymill\\Models\\Response\\Base $response\n */",
"$",
"response",
"=",
"$",
"service",
"->",
"create",
"(",
"$",
"transaction",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Create new Transaction with a set of params
@param string $amount amount as int (ex: 4200 for 42.00)
@param string $currency currency code (EUR, USD...)
@param string $token transaction token
@param string $description transaction description (optional, default "")
@return \Paymill\Models\Response\Base
@throws PaymillException if transaction creation fails | [
"Create",
"new",
"Transaction",
"with",
"a",
"set",
"of",
"params"
] | 78aa85daaab8cf08e4971b10d86abd429ac7f6cd | https://github.com/PaymentSuite/PaymillBundle/blob/78aa85daaab8cf08e4971b10d86abd429ac7f6cd/Services/Wrapper/PaymillTransactionWrapper.php#L52-L68 |
11,239 | joffreydemetz/utilities | src/Xml.php | Xml.populateXml | public static function populateXml($data)
{
$isFile = ( is_file($data) );
libxml_use_internal_errors(true);
if ( $isFile === true ){
$xml = simplexml_load_file($data, '\SimpleXMLElement');
}
else {
$xml = simplexml_load_string($data, '\SimpleXMLElement');
}
if ( empty($xml) ){
$errors=[];
if ( $isFile === true ){
$errors[] = $data;
}
foreach(libxml_get_errors() as $error){
$errors[] = 'XML: '.$error->message;
}
throw new Exception('XML file could not be loaded : '."\n".implode("\n", $errors));
}
return $xml;
} | php | public static function populateXml($data)
{
$isFile = ( is_file($data) );
libxml_use_internal_errors(true);
if ( $isFile === true ){
$xml = simplexml_load_file($data, '\SimpleXMLElement');
}
else {
$xml = simplexml_load_string($data, '\SimpleXMLElement');
}
if ( empty($xml) ){
$errors=[];
if ( $isFile === true ){
$errors[] = $data;
}
foreach(libxml_get_errors() as $error){
$errors[] = 'XML: '.$error->message;
}
throw new Exception('XML file could not be loaded : '."\n".implode("\n", $errors));
}
return $xml;
} | [
"public",
"static",
"function",
"populateXml",
"(",
"$",
"data",
")",
"{",
"$",
"isFile",
"=",
"(",
"is_file",
"(",
"$",
"data",
")",
")",
";",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"if",
"(",
"$",
"isFile",
"===",
"true",
")",
"{",
"$",
"xml",
"=",
"simplexml_load_file",
"(",
"$",
"data",
",",
"'\\SimpleXMLElement'",
")",
";",
"}",
"else",
"{",
"$",
"xml",
"=",
"simplexml_load_string",
"(",
"$",
"data",
",",
"'\\SimpleXMLElement'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"xml",
")",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"isFile",
"===",
"true",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"foreach",
"(",
"libxml_get_errors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"'XML: '",
".",
"$",
"error",
"->",
"message",
";",
"}",
"throw",
"new",
"Exception",
"(",
"'XML file could not be loaded : '",
".",
"\"\\n\"",
".",
"implode",
"(",
"\"\\n\"",
",",
"$",
"errors",
")",
")",
";",
"}",
"return",
"$",
"xml",
";",
"}"
] | Reads a XML file
@param string $data XML path or XML string
@return SimpleXMLElement Xml element
@throws Exception
@see SimpleXMLElement | [
"Reads",
"a",
"XML",
"file"
] | aa62a178bc463c10067a2ff2992d39c6f0037b9f | https://github.com/joffreydemetz/utilities/blob/aa62a178bc463c10067a2ff2992d39c6f0037b9f/src/Xml.php#L28-L55 |
11,240 | unclecheese/silverstripe-green | code/Green.php | Green.getDesignModules | public function getDesignModules()
{
$iterator = $this->createFinder()
->in($this->getAbsoluteDesignFolder())
->directories();
$modules = [];
foreach ($iterator as $file) {
if(file_exists($file->getRealPath().'/index.ss')) {
$modules[] = new DesignModule($file->getRealPath());
}
}
return $modules;
} | php | public function getDesignModules()
{
$iterator = $this->createFinder()
->in($this->getAbsoluteDesignFolder())
->directories();
$modules = [];
foreach ($iterator as $file) {
if(file_exists($file->getRealPath().'/index.ss')) {
$modules[] = new DesignModule($file->getRealPath());
}
}
return $modules;
} | [
"public",
"function",
"getDesignModules",
"(",
")",
"{",
"$",
"iterator",
"=",
"$",
"this",
"->",
"createFinder",
"(",
")",
"->",
"in",
"(",
"$",
"this",
"->",
"getAbsoluteDesignFolder",
"(",
")",
")",
"->",
"directories",
"(",
")",
";",
"$",
"modules",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
".",
"'/index.ss'",
")",
")",
"{",
"$",
"modules",
"[",
"]",
"=",
"new",
"DesignModule",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"modules",
";",
"}"
] | Gets all of the design modules as objects
@return array | [
"Gets",
"all",
"of",
"the",
"design",
"modules",
"as",
"objects"
] | 4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4 | https://github.com/unclecheese/silverstripe-green/blob/4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4/code/Green.php#L89-L103 |
11,241 | unclecheese/silverstripe-green | code/Green.php | Green.getDesignModule | public function getDesignModule($name)
{
foreach ($this->getDesignModules() as $module) {
if ($module->getName() == $name) {
return $module;
}
}
return false;
} | php | public function getDesignModule($name)
{
foreach ($this->getDesignModules() as $module) {
if ($module->getName() == $name) {
return $module;
}
}
return false;
} | [
"public",
"function",
"getDesignModule",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getDesignModules",
"(",
")",
"as",
"$",
"module",
")",
"{",
"if",
"(",
"$",
"module",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"return",
"$",
"module",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Gets a specific design module as an object by its name
@param string $name
@return bool|mixed | [
"Gets",
"a",
"specific",
"design",
"module",
"as",
"an",
"object",
"by",
"its",
"name"
] | 4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4 | https://github.com/unclecheese/silverstripe-green/blob/4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4/code/Green.php#L111-L120 |
11,242 | pitsolu/strukt-router | src/Strukt/Router/Matcher.php | Matcher.isMatch | public function isMatch($url){
$url = trim($url);
if($url == $this->pattern)
return true;
$parts = explode("/", trim($url, "/"));
$pattern = explode("/", trim($this->pattern, "/"));
if(count($parts) != count($pattern))
return false;
// print_r($pattern);
$regex = array();
foreach($pattern as $key=>$url_item){
if(preg_match_all("|{(.*):(.*)}|", $url_item, $matches)){
if(in_array(reset($matches[2]), array("int", "bool", "alpha", "float", "date"))){
switch(reset($matches[2])){
case "int":
$regex[] = "[0-9]+";
break;
case "bool":
$regex[] = "(true|false)";
break;
case "alpha":
$regex[] = "[A-Za-z]+";
break;
case "float":
$regex[] = "[+-]?\d+(\.\d+)?";
break;
case "date"://yyyy-mm-dd
$regex[] = "(19?[0-9]{2}|20[0-1][0-4])-(0?[1-9]|1[0-2])-([0-2]?[0-9]|3[0-1])";
break;
}
$this->params[reset($matches[1])] = $parts[$key];
}
}
elseif(preg_match_all("|{(.*)}|", $url_item, $matches)){
$regex[] = ".*";
$this->params[reset($matches[1])] = $parts[$key];
}
else $regex[] = $url_item;
}
return (bool)preg_match(sprintf("/^%s$/", implode("\/", $regex)), trim($url, "/"));
} | php | public function isMatch($url){
$url = trim($url);
if($url == $this->pattern)
return true;
$parts = explode("/", trim($url, "/"));
$pattern = explode("/", trim($this->pattern, "/"));
if(count($parts) != count($pattern))
return false;
// print_r($pattern);
$regex = array();
foreach($pattern as $key=>$url_item){
if(preg_match_all("|{(.*):(.*)}|", $url_item, $matches)){
if(in_array(reset($matches[2]), array("int", "bool", "alpha", "float", "date"))){
switch(reset($matches[2])){
case "int":
$regex[] = "[0-9]+";
break;
case "bool":
$regex[] = "(true|false)";
break;
case "alpha":
$regex[] = "[A-Za-z]+";
break;
case "float":
$regex[] = "[+-]?\d+(\.\d+)?";
break;
case "date"://yyyy-mm-dd
$regex[] = "(19?[0-9]{2}|20[0-1][0-4])-(0?[1-9]|1[0-2])-([0-2]?[0-9]|3[0-1])";
break;
}
$this->params[reset($matches[1])] = $parts[$key];
}
}
elseif(preg_match_all("|{(.*)}|", $url_item, $matches)){
$regex[] = ".*";
$this->params[reset($matches[1])] = $parts[$key];
}
else $regex[] = $url_item;
}
return (bool)preg_match(sprintf("/^%s$/", implode("\/", $regex)), trim($url, "/"));
} | [
"public",
"function",
"isMatch",
"(",
"$",
"url",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"url",
"==",
"$",
"this",
"->",
"pattern",
")",
"return",
"true",
";",
"$",
"parts",
"=",
"explode",
"(",
"\"/\"",
",",
"trim",
"(",
"$",
"url",
",",
"\"/\"",
")",
")",
";",
"$",
"pattern",
"=",
"explode",
"(",
"\"/\"",
",",
"trim",
"(",
"$",
"this",
"->",
"pattern",
",",
"\"/\"",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"!=",
"count",
"(",
"$",
"pattern",
")",
")",
"return",
"false",
";",
"// print_r($pattern);",
"$",
"regex",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"pattern",
"as",
"$",
"key",
"=>",
"$",
"url_item",
")",
"{",
"if",
"(",
"preg_match_all",
"(",
"\"|{(.*):(.*)}|\"",
",",
"$",
"url_item",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"reset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
",",
"array",
"(",
"\"int\"",
",",
"\"bool\"",
",",
"\"alpha\"",
",",
"\"float\"",
",",
"\"date\"",
")",
")",
")",
"{",
"switch",
"(",
"reset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
")",
"{",
"case",
"\"int\"",
":",
"$",
"regex",
"[",
"]",
"=",
"\"[0-9]+\"",
";",
"break",
";",
"case",
"\"bool\"",
":",
"$",
"regex",
"[",
"]",
"=",
"\"(true|false)\"",
";",
"break",
";",
"case",
"\"alpha\"",
":",
"$",
"regex",
"[",
"]",
"=",
"\"[A-Za-z]+\"",
";",
"break",
";",
"case",
"\"float\"",
":",
"$",
"regex",
"[",
"]",
"=",
"\"[+-]?\\d+(\\.\\d+)?\"",
";",
"break",
";",
"case",
"\"date\"",
":",
"//yyyy-mm-dd",
"$",
"regex",
"[",
"]",
"=",
"\"(19?[0-9]{2}|20[0-1][0-4])-(0?[1-9]|1[0-2])-([0-2]?[0-9]|3[0-1])\"",
";",
"break",
";",
"}",
"$",
"this",
"->",
"params",
"[",
"reset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
"]",
"=",
"$",
"parts",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"elseif",
"(",
"preg_match_all",
"(",
"\"|{(.*)}|\"",
",",
"$",
"url_item",
",",
"$",
"matches",
")",
")",
"{",
"$",
"regex",
"[",
"]",
"=",
"\".*\"",
";",
"$",
"this",
"->",
"params",
"[",
"reset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
"]",
"=",
"$",
"parts",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"$",
"regex",
"[",
"]",
"=",
"$",
"url_item",
";",
"}",
"return",
"(",
"bool",
")",
"preg_match",
"(",
"sprintf",
"(",
"\"/^%s$/\"",
",",
"implode",
"(",
"\"\\/\"",
",",
"$",
"regex",
")",
")",
",",
"trim",
"(",
"$",
"url",
",",
"\"/\"",
")",
")",
";",
"}"
] | Match url to specific url pattern
@param string $url route
@return boolean | [
"Match",
"url",
"to",
"specific",
"url",
"pattern"
] | ae6b91b5215edd4598d07b3dec2eed09337283d2 | https://github.com/pitsolu/strukt-router/blob/ae6b91b5215edd4598d07b3dec2eed09337283d2/src/Strukt/Router/Matcher.php#L45-L97 |
11,243 | ItinerisLtd/preflight-command | src/ConfigCollection.php | ConfigCollection.getConfig | public function getConfig(string $id): Config
{
// TODO: Use null coalescing assignment operator.
$this->configs[$id] = $this->configs[$id] ?? $this->registerConfig($id);
return $this->configs[$id];
} | php | public function getConfig(string $id): Config
{
// TODO: Use null coalescing assignment operator.
$this->configs[$id] = $this->configs[$id] ?? $this->registerConfig($id);
return $this->configs[$id];
} | [
"public",
"function",
"getConfig",
"(",
"string",
"$",
"id",
")",
":",
"Config",
"{",
"// TODO: Use null coalescing assignment operator.",
"$",
"this",
"->",
"configs",
"[",
"$",
"id",
"]",
"=",
"$",
"this",
"->",
"configs",
"[",
"$",
"id",
"]",
"??",
"$",
"this",
"->",
"registerConfig",
"(",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"configs",
"[",
"$",
"id",
"]",
";",
"}"
] | Returns a Config instance for specific checker.
Instantiate if necessary.
@param string $id Id of the checker.
@return Config | [
"Returns",
"a",
"Config",
"instance",
"for",
"specific",
"checker",
".",
"Instantiate",
"if",
"necessary",
"."
] | d1c1360ea8d7de0312b5c0c09c9c486949594049 | https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/ConfigCollection.php#L41-L47 |
11,244 | ItinerisLtd/preflight-command | src/ConfigCollection.php | ConfigCollection.registerConfig | protected function registerConfig(string $id): Config
{
$definition = $this->definitions[$id] ?? [];
$config = new Config($definition);
return apply_filters(static::HOOK, $config, $definition, $id);
} | php | protected function registerConfig(string $id): Config
{
$definition = $this->definitions[$id] ?? [];
$config = new Config($definition);
return apply_filters(static::HOOK, $config, $definition, $id);
} | [
"protected",
"function",
"registerConfig",
"(",
"string",
"$",
"id",
")",
":",
"Config",
"{",
"$",
"definition",
"=",
"$",
"this",
"->",
"definitions",
"[",
"$",
"id",
"]",
"??",
"[",
"]",
";",
"$",
"config",
"=",
"new",
"Config",
"(",
"$",
"definition",
")",
";",
"return",
"apply_filters",
"(",
"static",
"::",
"HOOK",
",",
"$",
"config",
",",
"$",
"definition",
",",
"$",
"id",
")",
";",
"}"
] | Instantiate a Config instance for specific checker.
@param string $id Id of the checker.
@return Config | [
"Instantiate",
"a",
"Config",
"instance",
"for",
"specific",
"checker",
"."
] | d1c1360ea8d7de0312b5c0c09c9c486949594049 | https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/ConfigCollection.php#L56-L62 |
11,245 | agalbourdin/agl-core | src/Url/Url.php | Url.get | public static function get($pUrl, $pParams = array(), $pRelative = true)
{
if (strpos($pUrl, '*/') !== false) {
if (self::$_request === NULL) {
self::setRequest();
}
$pUrl = str_replace('*/*/', self::$_request->getModule() . DS . self::$_request->getView(), $pUrl);
$pUrl = str_replace('*/', self::$_request->getModule() . DS, $pUrl);
}
if (Agl::isModuleLoaded(Agl::AGL_MORE_POOL . '/locale/locale')) {
return Agl::getSingleton(Agl::AGL_MORE_POOL . '/locale')->getUrl($pUrl, $pParams, $pRelative);
}
if (! $pUrl) {
if ($pRelative) {
return ROOT;
}
return self::getHost(ROOT);
}
if (strpos($pUrl, Agl::APP_PUBLIC_DIR) === false) {
if (is_array($pParams) and ! empty($pParams)) {
$params = array();
foreach ($pParams as $key => $value) {
$params[] = $key . DS . $value;
}
$url = $pUrl . DS . implode(DS, $params) . DS;
} else if (is_string($pParams) and $pParams) {
$url = $pUrl . DS . $pParams . DS;
} else {
$url = $pUrl . DS;
}
if ($pRelative) {
return ROOT . $url;
}
return self::getHost(ROOT . $url);
}
if ($pRelative) {
return ROOT . $pUrl;
}
return self::getHost(ROOT . $pUrl);
} | php | public static function get($pUrl, $pParams = array(), $pRelative = true)
{
if (strpos($pUrl, '*/') !== false) {
if (self::$_request === NULL) {
self::setRequest();
}
$pUrl = str_replace('*/*/', self::$_request->getModule() . DS . self::$_request->getView(), $pUrl);
$pUrl = str_replace('*/', self::$_request->getModule() . DS, $pUrl);
}
if (Agl::isModuleLoaded(Agl::AGL_MORE_POOL . '/locale/locale')) {
return Agl::getSingleton(Agl::AGL_MORE_POOL . '/locale')->getUrl($pUrl, $pParams, $pRelative);
}
if (! $pUrl) {
if ($pRelative) {
return ROOT;
}
return self::getHost(ROOT);
}
if (strpos($pUrl, Agl::APP_PUBLIC_DIR) === false) {
if (is_array($pParams) and ! empty($pParams)) {
$params = array();
foreach ($pParams as $key => $value) {
$params[] = $key . DS . $value;
}
$url = $pUrl . DS . implode(DS, $params) . DS;
} else if (is_string($pParams) and $pParams) {
$url = $pUrl . DS . $pParams . DS;
} else {
$url = $pUrl . DS;
}
if ($pRelative) {
return ROOT . $url;
}
return self::getHost(ROOT . $url);
}
if ($pRelative) {
return ROOT . $pUrl;
}
return self::getHost(ROOT . $pUrl);
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"pUrl",
",",
"$",
"pParams",
"=",
"array",
"(",
")",
",",
"$",
"pRelative",
"=",
"true",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"pUrl",
",",
"'*/'",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_request",
"===",
"NULL",
")",
"{",
"self",
"::",
"setRequest",
"(",
")",
";",
"}",
"$",
"pUrl",
"=",
"str_replace",
"(",
"'*/*/'",
",",
"self",
"::",
"$",
"_request",
"->",
"getModule",
"(",
")",
".",
"DS",
".",
"self",
"::",
"$",
"_request",
"->",
"getView",
"(",
")",
",",
"$",
"pUrl",
")",
";",
"$",
"pUrl",
"=",
"str_replace",
"(",
"'*/'",
",",
"self",
"::",
"$",
"_request",
"->",
"getModule",
"(",
")",
".",
"DS",
",",
"$",
"pUrl",
")",
";",
"}",
"if",
"(",
"Agl",
"::",
"isModuleLoaded",
"(",
"Agl",
"::",
"AGL_MORE_POOL",
".",
"'/locale/locale'",
")",
")",
"{",
"return",
"Agl",
"::",
"getSingleton",
"(",
"Agl",
"::",
"AGL_MORE_POOL",
".",
"'/locale'",
")",
"->",
"getUrl",
"(",
"$",
"pUrl",
",",
"$",
"pParams",
",",
"$",
"pRelative",
")",
";",
"}",
"if",
"(",
"!",
"$",
"pUrl",
")",
"{",
"if",
"(",
"$",
"pRelative",
")",
"{",
"return",
"ROOT",
";",
"}",
"return",
"self",
"::",
"getHost",
"(",
"ROOT",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"pUrl",
",",
"Agl",
"::",
"APP_PUBLIC_DIR",
")",
"===",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"pParams",
")",
"and",
"!",
"empty",
"(",
"$",
"pParams",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"pParams",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"key",
".",
"DS",
".",
"$",
"value",
";",
"}",
"$",
"url",
"=",
"$",
"pUrl",
".",
"DS",
".",
"implode",
"(",
"DS",
",",
"$",
"params",
")",
".",
"DS",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"pParams",
")",
"and",
"$",
"pParams",
")",
"{",
"$",
"url",
"=",
"$",
"pUrl",
".",
"DS",
".",
"$",
"pParams",
".",
"DS",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"$",
"pUrl",
".",
"DS",
";",
"}",
"if",
"(",
"$",
"pRelative",
")",
"{",
"return",
"ROOT",
".",
"$",
"url",
";",
"}",
"return",
"self",
"::",
"getHost",
"(",
"ROOT",
".",
"$",
"url",
")",
";",
"}",
"if",
"(",
"$",
"pRelative",
")",
"{",
"return",
"ROOT",
".",
"$",
"pUrl",
";",
"}",
"return",
"self",
"::",
"getHost",
"(",
"ROOT",
".",
"$",
"pUrl",
")",
";",
"}"
] | Return a formated URL with module, view, action and parameters.
@param string $pUrl URL to get (module/view)
@param string|array $pParams Parameters to include into the request
@param bool $pRelative Create a relative URL
@return string | [
"Return",
"a",
"formated",
"URL",
"with",
"module",
"view",
"action",
"and",
"parameters",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Url/Url.php#L39-L86 |
11,246 | agalbourdin/agl-core | src/Url/Url.php | Url.getCurrent | public static function getCurrent($pRelative = true, array $pNewParams = array())
{
if (self::$_request === NULL) {
self::setRequest();
}
$request = self::$_request;
$module = $request->getModule();
$view = $request->getView();
$params = str_replace($module . DS . $view, '', $request->getReq());
if (! empty($pNewParams)) {
$newParams = array();
foreach ($pNewParams as $key => $value) {
$newParams[] = $key . DS . $value;
}
$params .= DS . implode(DS, $newParams);
}
$params = trim($params, DS);
if ($module == $request::DEFAULT_MODULE and $view == $request::DEFAULT_VIEW and ! $params) {
return self::get('', $params, $pRelative);
}
return self::get($module . DS . $view, $params, $pRelative);
} | php | public static function getCurrent($pRelative = true, array $pNewParams = array())
{
if (self::$_request === NULL) {
self::setRequest();
}
$request = self::$_request;
$module = $request->getModule();
$view = $request->getView();
$params = str_replace($module . DS . $view, '', $request->getReq());
if (! empty($pNewParams)) {
$newParams = array();
foreach ($pNewParams as $key => $value) {
$newParams[] = $key . DS . $value;
}
$params .= DS . implode(DS, $newParams);
}
$params = trim($params, DS);
if ($module == $request::DEFAULT_MODULE and $view == $request::DEFAULT_VIEW and ! $params) {
return self::get('', $params, $pRelative);
}
return self::get($module . DS . $view, $params, $pRelative);
} | [
"public",
"static",
"function",
"getCurrent",
"(",
"$",
"pRelative",
"=",
"true",
",",
"array",
"$",
"pNewParams",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_request",
"===",
"NULL",
")",
"{",
"self",
"::",
"setRequest",
"(",
")",
";",
"}",
"$",
"request",
"=",
"self",
"::",
"$",
"_request",
";",
"$",
"module",
"=",
"$",
"request",
"->",
"getModule",
"(",
")",
";",
"$",
"view",
"=",
"$",
"request",
"->",
"getView",
"(",
")",
";",
"$",
"params",
"=",
"str_replace",
"(",
"$",
"module",
".",
"DS",
".",
"$",
"view",
",",
"''",
",",
"$",
"request",
"->",
"getReq",
"(",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"pNewParams",
")",
")",
"{",
"$",
"newParams",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"pNewParams",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"newParams",
"[",
"]",
"=",
"$",
"key",
".",
"DS",
".",
"$",
"value",
";",
"}",
"$",
"params",
".=",
"DS",
".",
"implode",
"(",
"DS",
",",
"$",
"newParams",
")",
";",
"}",
"$",
"params",
"=",
"trim",
"(",
"$",
"params",
",",
"DS",
")",
";",
"if",
"(",
"$",
"module",
"==",
"$",
"request",
"::",
"DEFAULT_MODULE",
"and",
"$",
"view",
"==",
"$",
"request",
"::",
"DEFAULT_VIEW",
"and",
"!",
"$",
"params",
")",
"{",
"return",
"self",
"::",
"get",
"(",
"''",
",",
"$",
"params",
",",
"$",
"pRelative",
")",
";",
"}",
"return",
"self",
"::",
"get",
"(",
"$",
"module",
".",
"DS",
".",
"$",
"view",
",",
"$",
"params",
",",
"$",
"pRelative",
")",
";",
"}"
] | Return the current URL with optional additional params.
@param bool $pRelative Return a relative URL or a full HTTP URL.
@param array $pNewParams Parameters to add to the request (additional)
@return string | [
"Return",
"the",
"current",
"URL",
"with",
"optional",
"additional",
"params",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Url/Url.php#L95-L123 |
11,247 | agalbourdin/agl-core | src/Url/Url.php | Url.getSkin | public static function getSkin($pUrl, $pRelative = true)
{
$url = Agl::APP_PUBLIC_DIR
. ViewInterface::APP_HTTP_SKIN_DIR
. DS
. $pUrl;
if ($pRelative) {
return ROOT . $url;
}
return self::getHost(ROOT . $url);
} | php | public static function getSkin($pUrl, $pRelative = true)
{
$url = Agl::APP_PUBLIC_DIR
. ViewInterface::APP_HTTP_SKIN_DIR
. DS
. $pUrl;
if ($pRelative) {
return ROOT . $url;
}
return self::getHost(ROOT . $url);
} | [
"public",
"static",
"function",
"getSkin",
"(",
"$",
"pUrl",
",",
"$",
"pRelative",
"=",
"true",
")",
"{",
"$",
"url",
"=",
"Agl",
"::",
"APP_PUBLIC_DIR",
".",
"ViewInterface",
"::",
"APP_HTTP_SKIN_DIR",
".",
"DS",
".",
"$",
"pUrl",
";",
"if",
"(",
"$",
"pRelative",
")",
"{",
"return",
"ROOT",
".",
"$",
"url",
";",
"}",
"return",
"self",
"::",
"getHost",
"(",
"ROOT",
".",
"$",
"url",
")",
";",
"}"
] | Get the skin base URL.
@param string $pUrl Relative URL inside the skin directory
@param bool $pRelative Create a relative URL
@return string | [
"Get",
"the",
"skin",
"base",
"URL",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Url/Url.php#L143-L155 |
11,248 | agalbourdin/agl-core | src/Url/Url.php | Url.getPublic | public static function getPublic($pUrl, $pRelative = true)
{
$url = Agl::APP_PUBLIC_DIR
. $pUrl;
if ($pRelative) {
return ROOT . $url;
}
return self::getHost(ROOT . $url);
} | php | public static function getPublic($pUrl, $pRelative = true)
{
$url = Agl::APP_PUBLIC_DIR
. $pUrl;
if ($pRelative) {
return ROOT . $url;
}
return self::getHost(ROOT . $url);
} | [
"public",
"static",
"function",
"getPublic",
"(",
"$",
"pUrl",
",",
"$",
"pRelative",
"=",
"true",
")",
"{",
"$",
"url",
"=",
"Agl",
"::",
"APP_PUBLIC_DIR",
".",
"$",
"pUrl",
";",
"if",
"(",
"$",
"pRelative",
")",
"{",
"return",
"ROOT",
".",
"$",
"url",
";",
"}",
"return",
"self",
"::",
"getHost",
"(",
"ROOT",
".",
"$",
"url",
")",
";",
"}"
] | Get the public base URL.
@param string $pUrl Relative URL inside the public directory
@param bool $pRelative Create a relative URL
@return string | [
"Get",
"the",
"public",
"base",
"URL",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Url/Url.php#L164-L174 |
11,249 | agalbourdin/agl-core | src/Url/Url.php | Url.getHost | public static function getHost($pPath = '', $pHost = '')
{
if (! $pHost) {
$pHost = $_SERVER['HTTP_HOST'];
}
return self::getProtocol() . $pHost . $pPath;
} | php | public static function getHost($pPath = '', $pHost = '')
{
if (! $pHost) {
$pHost = $_SERVER['HTTP_HOST'];
}
return self::getProtocol() . $pHost . $pPath;
} | [
"public",
"static",
"function",
"getHost",
"(",
"$",
"pPath",
"=",
"''",
",",
"$",
"pHost",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"pHost",
")",
"{",
"$",
"pHost",
"=",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
";",
"}",
"return",
"self",
"::",
"getProtocol",
"(",
")",
".",
"$",
"pHost",
".",
"$",
"pPath",
";",
"}"
] | Get the base URL with host name and protocol.
@return string | [
"Get",
"the",
"base",
"URL",
"with",
"host",
"name",
"and",
"protocol",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Url/Url.php#L181-L188 |
11,250 | cityware/city-wmi | src/Processors/HardDisks.php | HardDisks.get | public function get()
{
$disks = [];
$result = $this->connection->newQuery()->from(Classes::WIN32_LOGICALDISK)->get();
foreach($result as $disk) {
$disks[] = new HardDisk($disk);
}
return $disks;
} | php | public function get()
{
$disks = [];
$result = $this->connection->newQuery()->from(Classes::WIN32_LOGICALDISK)->get();
foreach($result as $disk) {
$disks[] = new HardDisk($disk);
}
return $disks;
} | [
"public",
"function",
"get",
"(",
")",
"{",
"$",
"disks",
"=",
"[",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"connection",
"->",
"newQuery",
"(",
")",
"->",
"from",
"(",
"Classes",
"::",
"WIN32_LOGICALDISK",
")",
"->",
"get",
"(",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"disk",
")",
"{",
"$",
"disks",
"[",
"]",
"=",
"new",
"HardDisk",
"(",
"$",
"disk",
")",
";",
"}",
"return",
"$",
"disks",
";",
"}"
] | Returns an array of all hard disks on the computer.
@return array | [
"Returns",
"an",
"array",
"of",
"all",
"hard",
"disks",
"on",
"the",
"computer",
"."
] | c7296e6855b6719f537ff5c2dc19d521ce1415d8 | https://github.com/cityware/city-wmi/blob/c7296e6855b6719f537ff5c2dc19d521ce1415d8/src/Processors/HardDisks.php#L15-L26 |
11,251 | sgtlambda/jvwp | src/widgets/StockWidgets.php | StockWidgets.getStockWidgets | private static function getStockWidgets ()
{
$reflectionClass = new \ReflectionClass(get_class());
$classNames = array();
foreach ($reflectionClass->getConstants() as $name => $value)
if (preg_match('/^STOCK_WP/', $name))
$classNames[] = $value;
return $classNames;
} | php | private static function getStockWidgets ()
{
$reflectionClass = new \ReflectionClass(get_class());
$classNames = array();
foreach ($reflectionClass->getConstants() as $name => $value)
if (preg_match('/^STOCK_WP/', $name))
$classNames[] = $value;
return $classNames;
} | [
"private",
"static",
"function",
"getStockWidgets",
"(",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"get_class",
"(",
")",
")",
";",
"$",
"classNames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"reflectionClass",
"->",
"getConstants",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"if",
"(",
"preg_match",
"(",
"'/^STOCK_WP/'",
",",
"$",
"name",
")",
")",
"$",
"classNames",
"[",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"classNames",
";",
"}"
] | By means of class reflection, gets a list of all the classnames of the stock widgets
@return string[] | [
"By",
"means",
"of",
"class",
"reflection",
"gets",
"a",
"list",
"of",
"all",
"the",
"classnames",
"of",
"the",
"stock",
"widgets"
] | 85dba59281216ccb9cff580d26063d304350bbe0 | https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/widgets/StockWidgets.php#L30-L38 |
11,252 | AnonymPHP/Anonym-Library | src/Anonym/Cron/Schedule/Schedule.php | Schedule.spliceIntoPosition | protected function spliceIntoPosition($position, $value)
{
$segments = explode(' ', $this->pattern);
$segments[$position - 1] = $value;
return $this->cron(implode(' ', $segments));
} | php | protected function spliceIntoPosition($position, $value)
{
$segments = explode(' ', $this->pattern);
$segments[$position - 1] = $value;
return $this->cron(implode(' ', $segments));
} | [
"protected",
"function",
"spliceIntoPosition",
"(",
"$",
"position",
",",
"$",
"value",
")",
"{",
"$",
"segments",
"=",
"explode",
"(",
"' '",
",",
"$",
"this",
"->",
"pattern",
")",
";",
"$",
"segments",
"[",
"$",
"position",
"-",
"1",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
"->",
"cron",
"(",
"implode",
"(",
"' '",
",",
"$",
"segments",
")",
")",
";",
"}"
] | Splice the given value into the given position of the expression.
@param int $position
@param string $value
@return $this | [
"Splice",
"the",
"given",
"value",
"into",
"the",
"given",
"position",
"of",
"the",
"expression",
"."
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Cron/Schedule/Schedule.php#L267-L273 |
11,253 | AnonymPHP/Anonym-Library | src/Anonym/Cron/Schedule/Schedule.php | Schedule.createPatternWithVariables | private function createPatternWithVariables()
{
$variables = [
$this->getMinute(),
$this->getHour(),
$this->getDayOfMounth(),
$this->getMounth(),
$this->getDayOfWeek(),
$this->getYear(),
];
return join(' ', $variables);
} | php | private function createPatternWithVariables()
{
$variables = [
$this->getMinute(),
$this->getHour(),
$this->getDayOfMounth(),
$this->getMounth(),
$this->getDayOfWeek(),
$this->getYear(),
];
return join(' ', $variables);
} | [
"private",
"function",
"createPatternWithVariables",
"(",
")",
"{",
"$",
"variables",
"=",
"[",
"$",
"this",
"->",
"getMinute",
"(",
")",
",",
"$",
"this",
"->",
"getHour",
"(",
")",
",",
"$",
"this",
"->",
"getDayOfMounth",
"(",
")",
",",
"$",
"this",
"->",
"getMounth",
"(",
")",
",",
"$",
"this",
"->",
"getDayOfWeek",
"(",
")",
",",
"$",
"this",
"->",
"getYear",
"(",
")",
",",
"]",
";",
"return",
"join",
"(",
"' '",
",",
"$",
"variables",
")",
";",
"}"
] | if pattern is null, create patten with private variables
@return string | [
"if",
"pattern",
"is",
"null",
"create",
"patten",
"with",
"private",
"variables"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Cron/Schedule/Schedule.php#L530-L542 |
11,254 | vinala/kernel | src/Foundation/Fetcher.php | Fetcher.run | public static function run($routes)
{
self::setAppPath();
self::setFrameworkPath();
//
self::exception();
self::events();
self::model();
self::controller();
self::link();
if (Component::isOn('database')) {
self::seed();
}
self::filtes();
self::alias();
Environment::ini();
self::mails();
//
self::routes($routes);
self::commands();
} | php | public static function run($routes)
{
self::setAppPath();
self::setFrameworkPath();
//
self::exception();
self::events();
self::model();
self::controller();
self::link();
if (Component::isOn('database')) {
self::seed();
}
self::filtes();
self::alias();
Environment::ini();
self::mails();
//
self::routes($routes);
self::commands();
} | [
"public",
"static",
"function",
"run",
"(",
"$",
"routes",
")",
"{",
"self",
"::",
"setAppPath",
"(",
")",
";",
"self",
"::",
"setFrameworkPath",
"(",
")",
";",
"//",
"self",
"::",
"exception",
"(",
")",
";",
"self",
"::",
"events",
"(",
")",
";",
"self",
"::",
"model",
"(",
")",
";",
"self",
"::",
"controller",
"(",
")",
";",
"self",
"::",
"link",
"(",
")",
";",
"if",
"(",
"Component",
"::",
"isOn",
"(",
"'database'",
")",
")",
"{",
"self",
"::",
"seed",
"(",
")",
";",
"}",
"self",
"::",
"filtes",
"(",
")",
";",
"self",
"::",
"alias",
"(",
")",
";",
"Environment",
"::",
"ini",
"(",
")",
";",
"self",
"::",
"mails",
"(",
")",
";",
"//",
"self",
"::",
"routes",
"(",
"$",
"routes",
")",
";",
"self",
"::",
"commands",
"(",
")",
";",
"}"
] | Get all required App files. | [
"Get",
"all",
"required",
"App",
"files",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Fetcher.php#L30-L50 |
11,255 | vinala/kernel | src/Foundation/Fetcher.php | Fetcher.fetch | protected static function fetch($pattern, $app = true)
{
if ($app) {
return glob(self::$appPath.$pattern.'/*.php');
} else {
return glob(self::$frameworkPath.$pattern.'/*.php');
}
} | php | protected static function fetch($pattern, $app = true)
{
if ($app) {
return glob(self::$appPath.$pattern.'/*.php');
} else {
return glob(self::$frameworkPath.$pattern.'/*.php');
}
} | [
"protected",
"static",
"function",
"fetch",
"(",
"$",
"pattern",
",",
"$",
"app",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"app",
")",
"{",
"return",
"glob",
"(",
"self",
"::",
"$",
"appPath",
".",
"$",
"pattern",
".",
"'/*.php'",
")",
";",
"}",
"else",
"{",
"return",
"glob",
"(",
"self",
"::",
"$",
"frameworkPath",
".",
"$",
"pattern",
".",
"'/*.php'",
")",
";",
"}",
"}"
] | Fetch files of folder. | [
"Fetch",
"files",
"of",
"folder",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Fetcher.php#L75-L82 |
11,256 | vinala/kernel | src/Foundation/Fetcher.php | Fetcher.middleware | protected static function middleware()
{
foreach (self::fetch('http/middleware') as $file) {
Bus::need($file);
}
Middleware::ini();
} | php | protected static function middleware()
{
foreach (self::fetch('http/middleware') as $file) {
Bus::need($file);
}
Middleware::ini();
} | [
"protected",
"static",
"function",
"middleware",
"(",
")",
"{",
"foreach",
"(",
"self",
"::",
"fetch",
"(",
"'http/middleware'",
")",
"as",
"$",
"file",
")",
"{",
"Bus",
"::",
"need",
"(",
"$",
"file",
")",
";",
"}",
"Middleware",
"::",
"ini",
"(",
")",
";",
"}"
] | Require and call middleware classes.
@return null | [
"Require",
"and",
"call",
"middleware",
"classes",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Fetcher.php#L160-L167 |
11,257 | vinala/kernel | src/Foundation/Fetcher.php | Fetcher.routes | protected static function routes($routes)
{
if ($routes) {
self::middleware();
Bus::need(self::$appPath.'http/Routes.php');
Routes::run();
}
} | php | protected static function routes($routes)
{
if ($routes) {
self::middleware();
Bus::need(self::$appPath.'http/Routes.php');
Routes::run();
}
} | [
"protected",
"static",
"function",
"routes",
"(",
"$",
"routes",
")",
"{",
"if",
"(",
"$",
"routes",
")",
"{",
"self",
"::",
"middleware",
"(",
")",
";",
"Bus",
"::",
"need",
"(",
"self",
"::",
"$",
"appPath",
".",
"'http/Routes.php'",
")",
";",
"Routes",
"::",
"run",
"(",
")",
";",
"}",
"}"
] | Require files of Routes. | [
"Require",
"files",
"of",
"Routes",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Fetcher.php#L172-L180 |
11,258 | vinala/kernel | src/Foundation/Fetcher.php | Fetcher.events | protected static function events()
{
foreach (self::fetch('app/events', false) as $file) {
Bus::need($file);
}
//
Event::register();
} | php | protected static function events()
{
foreach (self::fetch('app/events', false) as $file) {
Bus::need($file);
}
//
Event::register();
} | [
"protected",
"static",
"function",
"events",
"(",
")",
"{",
"foreach",
"(",
"self",
"::",
"fetch",
"(",
"'app/events'",
",",
"false",
")",
"as",
"$",
"file",
")",
"{",
"Bus",
"::",
"need",
"(",
"$",
"file",
")",
";",
"}",
"//",
"Event",
"::",
"register",
"(",
")",
";",
"}"
] | Require files of Console. | [
"Require",
"files",
"of",
"Console",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Fetcher.php#L195-L202 |
11,259 | vinala/kernel | src/Foundation/Fetcher.php | Fetcher.mails | protected static function mails()
{
if (is_dir(root().'app/mails')) {
foreach (self::fetch('app/mails', false) as $file) {
need($file);
}
}
} | php | protected static function mails()
{
if (is_dir(root().'app/mails')) {
foreach (self::fetch('app/mails', false) as $file) {
need($file);
}
}
} | [
"protected",
"static",
"function",
"mails",
"(",
")",
"{",
"if",
"(",
"is_dir",
"(",
"root",
"(",
")",
".",
"'app/mails'",
")",
")",
"{",
"foreach",
"(",
"self",
"::",
"fetch",
"(",
"'app/mails'",
",",
"false",
")",
"as",
"$",
"file",
")",
"{",
"need",
"(",
"$",
"file",
")",
";",
"}",
"}",
"}"
] | Require files of Mail if exists.
@return null | [
"Require",
"files",
"of",
"Mail",
"if",
"exists",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Fetcher.php#L209-L216 |
11,260 | mvlabs/MvlabsLumber | src/MvlabsLumber/Service/LoggerFactory.php | LoggerFactory.getOptionalParam | private function getOptionalParam($s_paramName, $am_writerConf) {
$m_paramValue = null;
if (array_key_exists($s_paramName, $am_writerConf)) {
$m_paramValue = $am_writerConf[$s_paramName];
}
return $m_paramValue;
} | php | private function getOptionalParam($s_paramName, $am_writerConf) {
$m_paramValue = null;
if (array_key_exists($s_paramName, $am_writerConf)) {
$m_paramValue = $am_writerConf[$s_paramName];
}
return $m_paramValue;
} | [
"private",
"function",
"getOptionalParam",
"(",
"$",
"s_paramName",
",",
"$",
"am_writerConf",
")",
"{",
"$",
"m_paramValue",
"=",
"null",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"s_paramName",
",",
"$",
"am_writerConf",
")",
")",
"{",
"$",
"m_paramValue",
"=",
"$",
"am_writerConf",
"[",
"$",
"s_paramName",
"]",
";",
"}",
"return",
"$",
"m_paramValue",
";",
"}"
] | Returns value of a parameter if present, null otherwise
@param string $s_paramName parameter name
@param array $am_writerConf configuration array
@return mixed parameter value | [
"Returns",
"value",
"of",
"a",
"parameter",
"if",
"present",
"null",
"otherwise"
] | b9491b5b6f3a68ed18018408243cdd594424c5e2 | https://github.com/mvlabs/MvlabsLumber/blob/b9491b5b6f3a68ed18018408243cdd594424c5e2/src/MvlabsLumber/Service/LoggerFactory.php#L286-L296 |
11,261 | sheychen290/inutils | src/Storage/ArrayCollection.php | ArrayCollection.add | public function add(string $key, $value)
{
$current = $this->get($key, []);
$adds = is_array($value) ? $value : [$value];
$this->set($key, array_merge($current, array_values($adds)));
} | php | public function add(string $key, $value)
{
$current = $this->get($key, []);
$adds = is_array($value) ? $value : [$value];
$this->set($key, array_merge($current, array_values($adds)));
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
",",
"[",
"]",
")",
";",
"$",
"adds",
"=",
"is_array",
"(",
"$",
"value",
")",
"?",
"$",
"value",
":",
"[",
"$",
"value",
"]",
";",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"array_merge",
"(",
"$",
"current",
",",
"array_values",
"(",
"$",
"adds",
")",
")",
")",
";",
"}"
] | Add Values To Key Array | [
"Add",
"Values",
"To",
"Key",
"Array"
] | 43cae2967faa1df57ec9bbf9596b45c0762081a6 | https://github.com/sheychen290/inutils/blob/43cae2967faa1df57ec9bbf9596b45c0762081a6/src/Storage/ArrayCollection.php#L18-L23 |
11,262 | flavorzyb/wechat | src/Event/Parser.php | Parser.createLocationEvent | protected function createLocationEvent(array $data)
{
$result = new WxReceiveLocationEvent();
$this->initReceive($result, $data);
$result->setLatitude($data['Latitude']);
$result->setLongitude($data['Longitude']);
$result->setPrecision($data['Precision']);
return $result;
} | php | protected function createLocationEvent(array $data)
{
$result = new WxReceiveLocationEvent();
$this->initReceive($result, $data);
$result->setLatitude($data['Latitude']);
$result->setLongitude($data['Longitude']);
$result->setPrecision($data['Precision']);
return $result;
} | [
"protected",
"function",
"createLocationEvent",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"result",
"=",
"new",
"WxReceiveLocationEvent",
"(",
")",
";",
"$",
"this",
"->",
"initReceive",
"(",
"$",
"result",
",",
"$",
"data",
")",
";",
"$",
"result",
"->",
"setLatitude",
"(",
"$",
"data",
"[",
"'Latitude'",
"]",
")",
";",
"$",
"result",
"->",
"setLongitude",
"(",
"$",
"data",
"[",
"'Longitude'",
"]",
")",
";",
"$",
"result",
"->",
"setPrecision",
"(",
"$",
"data",
"[",
"'Precision'",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
] | create WxReceiveLocationEvent instance
@param array $data
@return WxReceiveLocationEvent | [
"create",
"WxReceiveLocationEvent",
"instance"
] | e7854a193c4d23cc9b84afa465f4706c09e7e7c5 | https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Event/Parser.php#L48-L58 |
11,263 | flavorzyb/wechat | src/Event/Parser.php | Parser.createViewEvent | protected function createViewEvent(array $data)
{
$result = new WxReceiveViewEvent();
$this->initReceive($result, $data);
$result->setEventKey($data['EventKey']);
return $result;
} | php | protected function createViewEvent(array $data)
{
$result = new WxReceiveViewEvent();
$this->initReceive($result, $data);
$result->setEventKey($data['EventKey']);
return $result;
} | [
"protected",
"function",
"createViewEvent",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"result",
"=",
"new",
"WxReceiveViewEvent",
"(",
")",
";",
"$",
"this",
"->",
"initReceive",
"(",
"$",
"result",
",",
"$",
"data",
")",
";",
"$",
"result",
"->",
"setEventKey",
"(",
"$",
"data",
"[",
"'EventKey'",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
] | create WxReceiveViewEvent instance
@param array $data
@return WxReceiveViewEvent | [
"create",
"WxReceiveViewEvent",
"instance"
] | e7854a193c4d23cc9b84afa465f4706c09e7e7c5 | https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Event/Parser.php#L66-L74 |
11,264 | flavorzyb/wechat | src/Event/Parser.php | Parser.createClickEvent | protected function createClickEvent(array $data)
{
$result = new WxReceiveClickEvent();
$this->initReceive($result, $data);
$result->setEventKey($data['EventKey']);
return $result;
} | php | protected function createClickEvent(array $data)
{
$result = new WxReceiveClickEvent();
$this->initReceive($result, $data);
$result->setEventKey($data['EventKey']);
return $result;
} | [
"protected",
"function",
"createClickEvent",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"result",
"=",
"new",
"WxReceiveClickEvent",
"(",
")",
";",
"$",
"this",
"->",
"initReceive",
"(",
"$",
"result",
",",
"$",
"data",
")",
";",
"$",
"result",
"->",
"setEventKey",
"(",
"$",
"data",
"[",
"'EventKey'",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
] | create WxReceiveClickEvent instance
@param array $data
@return WxReceiveClickEvent | [
"create",
"WxReceiveClickEvent",
"instance"
] | e7854a193c4d23cc9b84afa465f4706c09e7e7c5 | https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Event/Parser.php#L82-L90 |
11,265 | flavorzyb/wechat | src/Event/Parser.php | Parser.createScanEvent | protected function createScanEvent(array $data)
{
$result = new WxReceiveScanEvent();
$this->initReceive($result, $data);
$result->setEvent($data['Event']);
$result->setEventKey($data['EventKey']);
$result->setTicket($data['Ticket']);
return $result;
} | php | protected function createScanEvent(array $data)
{
$result = new WxReceiveScanEvent();
$this->initReceive($result, $data);
$result->setEvent($data['Event']);
$result->setEventKey($data['EventKey']);
$result->setTicket($data['Ticket']);
return $result;
} | [
"protected",
"function",
"createScanEvent",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"result",
"=",
"new",
"WxReceiveScanEvent",
"(",
")",
";",
"$",
"this",
"->",
"initReceive",
"(",
"$",
"result",
",",
"$",
"data",
")",
";",
"$",
"result",
"->",
"setEvent",
"(",
"$",
"data",
"[",
"'Event'",
"]",
")",
";",
"$",
"result",
"->",
"setEventKey",
"(",
"$",
"data",
"[",
"'EventKey'",
"]",
")",
";",
"$",
"result",
"->",
"setTicket",
"(",
"$",
"data",
"[",
"'Ticket'",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
] | create WxReceiveScanEvent instance
@param array $data
@return WxReceiveScanEvent | [
"create",
"WxReceiveScanEvent",
"instance"
] | e7854a193c4d23cc9b84afa465f4706c09e7e7c5 | https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Event/Parser.php#L97-L107 |
11,266 | flavorzyb/wechat | src/Event/Parser.php | Parser.createSubscribeEvent | protected function createSubscribeEvent(array $data)
{
if (isset($data['EventKey']) && isset($data['Ticket']) && (WxReceiveEvent::EVENT_TYPE_SUBSCRIBE == $data['Event'])) {
return $this->createScanEvent($data);
}
$result = new WxReceiveSubscribeEvent();
$this->initReceive($result, $data);
$result->setEvent($data['Event']);
return $result;
} | php | protected function createSubscribeEvent(array $data)
{
if (isset($data['EventKey']) && isset($data['Ticket']) && (WxReceiveEvent::EVENT_TYPE_SUBSCRIBE == $data['Event'])) {
return $this->createScanEvent($data);
}
$result = new WxReceiveSubscribeEvent();
$this->initReceive($result, $data);
$result->setEvent($data['Event']);
return $result;
} | [
"protected",
"function",
"createSubscribeEvent",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'EventKey'",
"]",
")",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'Ticket'",
"]",
")",
"&&",
"(",
"WxReceiveEvent",
"::",
"EVENT_TYPE_SUBSCRIBE",
"==",
"$",
"data",
"[",
"'Event'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createScanEvent",
"(",
"$",
"data",
")",
";",
"}",
"$",
"result",
"=",
"new",
"WxReceiveSubscribeEvent",
"(",
")",
";",
"$",
"this",
"->",
"initReceive",
"(",
"$",
"result",
",",
"$",
"data",
")",
";",
"$",
"result",
"->",
"setEvent",
"(",
"$",
"data",
"[",
"'Event'",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
] | create WxReceiveEvent instance
@param array $data
@return WxReceiveEvent | [
"create",
"WxReceiveEvent",
"instance"
] | e7854a193c4d23cc9b84afa465f4706c09e7e7c5 | https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Event/Parser.php#L114-L125 |
11,267 | michaelKaefer/user | src/Factory/UserFactory.php | UserFactory.createFromFileOwner | public static function createFromFileOwner($filename)
{
if (!file_exists($filename)) {
throw new \InvalidArgumentException('Invalid file name provided.');
}
if (!function_exists('posix_getuid')) {
throw new PosixNotAvailableException(
'Could not retrieve information about the operating system user because POSIX functions '
. 'are not available to your PHP executable.'
);
}
if (false === $uid = \fileowner($filename)) {
throw new \Exception('Could not get the owner of the file "' . $filename . '".');
}
return new User($uid);
} | php | public static function createFromFileOwner($filename)
{
if (!file_exists($filename)) {
throw new \InvalidArgumentException('Invalid file name provided.');
}
if (!function_exists('posix_getuid')) {
throw new PosixNotAvailableException(
'Could not retrieve information about the operating system user because POSIX functions '
. 'are not available to your PHP executable.'
);
}
if (false === $uid = \fileowner($filename)) {
throw new \Exception('Could not get the owner of the file "' . $filename . '".');
}
return new User($uid);
} | [
"public",
"static",
"function",
"createFromFileOwner",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid file name provided.'",
")",
";",
"}",
"if",
"(",
"!",
"function_exists",
"(",
"'posix_getuid'",
")",
")",
"{",
"throw",
"new",
"PosixNotAvailableException",
"(",
"'Could not retrieve information about the operating system user because POSIX functions '",
".",
"'are not available to your PHP executable.'",
")",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"uid",
"=",
"\\",
"fileowner",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Could not get the owner of the file \"'",
".",
"$",
"filename",
".",
"'\".'",
")",
";",
"}",
"return",
"new",
"User",
"(",
"$",
"uid",
")",
";",
"}"
] | Factory method to get the owner of a file.
@param string $filename
@return User
@throws PosixNotAvailableException
@throws \Exception | [
"Factory",
"method",
"to",
"get",
"the",
"owner",
"of",
"a",
"file",
"."
] | 58f3eb2fcecbdf8c450c9905d9bd6fd03bc23a72 | https://github.com/michaelKaefer/user/blob/58f3eb2fcecbdf8c450c9905d9bd6fd03bc23a72/src/Factory/UserFactory.php#L80-L95 |
11,268 | apnet/AsseticImporterBundle | src/Apnet/AsseticImporterBundle/Factory/Importer/PathImporter.php | PathImporter.load | public function load($sourcePath, $targetPath)
{
$mapper = new AssetMapper();
$mapper->map($sourcePath, $targetPath);
return $mapper;
} | php | public function load($sourcePath, $targetPath)
{
$mapper = new AssetMapper();
$mapper->map($sourcePath, $targetPath);
return $mapper;
} | [
"public",
"function",
"load",
"(",
"$",
"sourcePath",
",",
"$",
"targetPath",
")",
"{",
"$",
"mapper",
"=",
"new",
"AssetMapper",
"(",
")",
";",
"$",
"mapper",
"->",
"map",
"(",
"$",
"sourcePath",
",",
"$",
"targetPath",
")",
";",
"return",
"$",
"mapper",
";",
"}"
] | Add asset mapper from file or directory path
@param string $sourcePath File or directory path
@param string $targetPath Target path
@return AssetMapper | [
"Add",
"asset",
"mapper",
"from",
"file",
"or",
"directory",
"path"
] | 104ad3593795c016a5b89ecc8c240d4d96d3de45 | https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticImporterBundle/Factory/Importer/PathImporter.php#L27-L33 |
11,269 | xloit/xloit-bridge-zend-filter | src/CarriageReturnToHtml.php | CarriageReturnToHtml.filter | public function filter($value)
{
if (!is_string($value)) {
return $value;
}
// Strip unicode bombs, and make sure all newlines are UNIX newlines.
$value = preg_replace('{^\xEF\xBB\xBF|\x1A}', '', $value);
$value = preg_replace('{\r\n?}', "\n", $value);
$lambda = function($text) {
$text = htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
/** @noinspection NotOptimalRegularExpressionsInspection */
$text = preg_replace('/--/', '—', $text);
$text = nl2br($text, false);
$text = sprintf('<p>%s</p>', $text);
return $text;
};
$paragraphs = preg_split('/\n{2,}/', $value, -1, PREG_SPLIT_NO_EMPTY);
$paragraphs = array_map($lambda, $paragraphs);
return implode("\n\n", $paragraphs);
} | php | public function filter($value)
{
if (!is_string($value)) {
return $value;
}
// Strip unicode bombs, and make sure all newlines are UNIX newlines.
$value = preg_replace('{^\xEF\xBB\xBF|\x1A}', '', $value);
$value = preg_replace('{\r\n?}', "\n", $value);
$lambda = function($text) {
$text = htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
/** @noinspection NotOptimalRegularExpressionsInspection */
$text = preg_replace('/--/', '—', $text);
$text = nl2br($text, false);
$text = sprintf('<p>%s</p>', $text);
return $text;
};
$paragraphs = preg_split('/\n{2,}/', $value, -1, PREG_SPLIT_NO_EMPTY);
$paragraphs = array_map($lambda, $paragraphs);
return implode("\n\n", $paragraphs);
} | [
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"// Strip unicode bombs, and make sure all newlines are UNIX newlines.",
"$",
"value",
"=",
"preg_replace",
"(",
"'{^\\xEF\\xBB\\xBF|\\x1A}'",
",",
"''",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"'{\\r\\n?}'",
",",
"\"\\n\"",
",",
"$",
"value",
")",
";",
"$",
"lambda",
"=",
"function",
"(",
"$",
"text",
")",
"{",
"$",
"text",
"=",
"htmlspecialchars",
"(",
"$",
"text",
",",
"ENT_COMPAT",
",",
"'UTF-8'",
")",
";",
"/** @noinspection NotOptimalRegularExpressionsInspection */",
"$",
"text",
"=",
"preg_replace",
"(",
"'/--/'",
",",
"'—'",
",",
"$",
"text",
")",
";",
"$",
"text",
"=",
"nl2br",
"(",
"$",
"text",
",",
"false",
")",
";",
"$",
"text",
"=",
"sprintf",
"(",
"'<p>%s</p>'",
",",
"$",
"text",
")",
";",
"return",
"$",
"text",
";",
"}",
";",
"$",
"paragraphs",
"=",
"preg_split",
"(",
"'/\\n{2,}/'",
",",
"$",
"value",
",",
"-",
"1",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"$",
"paragraphs",
"=",
"array_map",
"(",
"$",
"lambda",
",",
"$",
"paragraphs",
")",
";",
"return",
"implode",
"(",
"\"\\n\\n\"",
",",
"$",
"paragraphs",
")",
";",
"}"
] | Convert paragraphs of text into filtered HTML.
@param mixed $value
@return string | [
"Convert",
"paragraphs",
"of",
"text",
"into",
"filtered",
"HTML",
"."
] | 2bce36194cd8636484f1b06ad13f33d953f477e0 | https://github.com/xloit/xloit-bridge-zend-filter/blob/2bce36194cd8636484f1b06ad13f33d953f477e0/src/CarriageReturnToHtml.php#L36-L60 |
11,270 | GovTribe/laravel-kinvey | src/GovTribe/LaravelKinvey/Client/Exception/KinveyResponseExceptionFactory.php | KinveyResponseExceptionFactory.fromResponse | public function fromResponse(RequestInterface $request, Response $response)
{
$message = $response->json();
$parts = array(
'type' => isset($message['error']) ? $message['error'] : null,
'description' => isset($message['description']) ? $message['description'] : null,
'request_id' => $response->getHeaders()->get('x-kinvey-request-id'),
'debug' => isset($message['debug']) && !empty($message['debug']) ? $message['debug'] : null,
);
return $this->createException($request, $response, $parts);
} | php | public function fromResponse(RequestInterface $request, Response $response)
{
$message = $response->json();
$parts = array(
'type' => isset($message['error']) ? $message['error'] : null,
'description' => isset($message['description']) ? $message['description'] : null,
'request_id' => $response->getHeaders()->get('x-kinvey-request-id'),
'debug' => isset($message['debug']) && !empty($message['debug']) ? $message['debug'] : null,
);
return $this->createException($request, $response, $parts);
} | [
"public",
"function",
"fromResponse",
"(",
"RequestInterface",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"message",
"=",
"$",
"response",
"->",
"json",
"(",
")",
";",
"$",
"parts",
"=",
"array",
"(",
"'type'",
"=>",
"isset",
"(",
"$",
"message",
"[",
"'error'",
"]",
")",
"?",
"$",
"message",
"[",
"'error'",
"]",
":",
"null",
",",
"'description'",
"=>",
"isset",
"(",
"$",
"message",
"[",
"'description'",
"]",
")",
"?",
"$",
"message",
"[",
"'description'",
"]",
":",
"null",
",",
"'request_id'",
"=>",
"$",
"response",
"->",
"getHeaders",
"(",
")",
"->",
"get",
"(",
"'x-kinvey-request-id'",
")",
",",
"'debug'",
"=>",
"isset",
"(",
"$",
"message",
"[",
"'debug'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"message",
"[",
"'debug'",
"]",
")",
"?",
"$",
"message",
"[",
"'debug'",
"]",
":",
"null",
",",
")",
";",
"return",
"$",
"this",
"->",
"createException",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"parts",
")",
";",
"}"
] | Returns a Kinvey service specific exception
@param RequestInterface $request Unsuccessful request
@param Response $response Unsuccessful response that was encountered
@return Exception | [
"Returns",
"a",
"Kinvey",
"service",
"specific",
"exception"
] | 8a25dafdf80a933384dfcfe8b70b0a7663fe9289 | https://github.com/GovTribe/laravel-kinvey/blob/8a25dafdf80a933384dfcfe8b70b0a7663fe9289/src/GovTribe/LaravelKinvey/Client/Exception/KinveyResponseExceptionFactory.php#L16-L28 |
11,271 | GovTribe/laravel-kinvey | src/GovTribe/LaravelKinvey/Client/Exception/KinveyResponseExceptionFactory.php | KinveyResponseExceptionFactory.createException | protected function createException(RequestInterface $request, Response $response, array $parts)
{
$message = 'Status Code: ' . $response->getStatusCode() . PHP_EOL
. 'Kinvey Request ID: ' . $parts['request_id'] . PHP_EOL
. 'Kinvey Exception Type: ' . $parts['type'] . PHP_EOL
. 'Kinvey Error Message: ' . $parts['description'] . PHP_EOL
. 'Kinvey Debug: ' . $parts['debug'];
$class = new KinveyResponseException($message);
$class->setExceptionType($parts['type']);
$class->setResponse($response);
$class->setRequest($request);
$class->setRequestId($parts['request_id']);
$class->setDebug($parts['debug']);
return $class;
} | php | protected function createException(RequestInterface $request, Response $response, array $parts)
{
$message = 'Status Code: ' . $response->getStatusCode() . PHP_EOL
. 'Kinvey Request ID: ' . $parts['request_id'] . PHP_EOL
. 'Kinvey Exception Type: ' . $parts['type'] . PHP_EOL
. 'Kinvey Error Message: ' . $parts['description'] . PHP_EOL
. 'Kinvey Debug: ' . $parts['debug'];
$class = new KinveyResponseException($message);
$class->setExceptionType($parts['type']);
$class->setResponse($response);
$class->setRequest($request);
$class->setRequestId($parts['request_id']);
$class->setDebug($parts['debug']);
return $class;
} | [
"protected",
"function",
"createException",
"(",
"RequestInterface",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"array",
"$",
"parts",
")",
"{",
"$",
"message",
"=",
"'Status Code: '",
".",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
".",
"PHP_EOL",
".",
"'Kinvey Request ID: '",
".",
"$",
"parts",
"[",
"'request_id'",
"]",
".",
"PHP_EOL",
".",
"'Kinvey Exception Type: '",
".",
"$",
"parts",
"[",
"'type'",
"]",
".",
"PHP_EOL",
".",
"'Kinvey Error Message: '",
".",
"$",
"parts",
"[",
"'description'",
"]",
".",
"PHP_EOL",
".",
"'Kinvey Debug: '",
".",
"$",
"parts",
"[",
"'debug'",
"]",
";",
"$",
"class",
"=",
"new",
"KinveyResponseException",
"(",
"$",
"message",
")",
";",
"$",
"class",
"->",
"setExceptionType",
"(",
"$",
"parts",
"[",
"'type'",
"]",
")",
";",
"$",
"class",
"->",
"setResponse",
"(",
"$",
"response",
")",
";",
"$",
"class",
"->",
"setRequest",
"(",
"$",
"request",
")",
";",
"$",
"class",
"->",
"setRequestId",
"(",
"$",
"parts",
"[",
"'request_id'",
"]",
")",
";",
"$",
"class",
"->",
"setDebug",
"(",
"$",
"parts",
"[",
"'debug'",
"]",
")",
";",
"return",
"$",
"class",
";",
"}"
] | Create an prepare an exception object
@param RequestInterface $request Request
@param Response $response Response received
@param array $parts Parsed exception data
@return \Exception | [
"Create",
"an",
"prepare",
"an",
"exception",
"object"
] | 8a25dafdf80a933384dfcfe8b70b0a7663fe9289 | https://github.com/GovTribe/laravel-kinvey/blob/8a25dafdf80a933384dfcfe8b70b0a7663fe9289/src/GovTribe/LaravelKinvey/Client/Exception/KinveyResponseExceptionFactory.php#L39-L54 |
11,272 | jails/li3_behaviors | data/model/Behaviors.php | Behaviors._init | protected function _init() {
$self = static::_object();
if (!isset($self->_actsAs)) {
$self->_actsAs = [];
}
foreach ($self->_actsAs as $name => $config) {
if (is_string($config)) {
$name = $config;
$config = [];
}
static::actsAs($name, $config);
}
} | php | protected function _init() {
$self = static::_object();
if (!isset($self->_actsAs)) {
$self->_actsAs = [];
}
foreach ($self->_actsAs as $name => $config) {
if (is_string($config)) {
$name = $config;
$config = [];
}
static::actsAs($name, $config);
}
} | [
"protected",
"function",
"_init",
"(",
")",
"{",
"$",
"self",
"=",
"static",
"::",
"_object",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"self",
"->",
"_actsAs",
")",
")",
"{",
"$",
"self",
"->",
"_actsAs",
"=",
"[",
"]",
";",
"}",
"foreach",
"(",
"$",
"self",
"->",
"_actsAs",
"as",
"$",
"name",
"=>",
"$",
"config",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"config",
")",
")",
"{",
"$",
"name",
"=",
"$",
"config",
";",
"$",
"config",
"=",
"[",
"]",
";",
"}",
"static",
"::",
"actsAs",
"(",
"$",
"name",
",",
"$",
"config",
")",
";",
"}",
"}"
] | Initializer function called just after the model instanciation.
Example to disable the `_init()` call use the following before any access to the model:
{{{
Posts::config(['init' => false]);
}}} | [
"Initializer",
"function",
"called",
"just",
"after",
"the",
"model",
"instanciation",
"."
] | 4d2f13c7c893ad1084dfd25f96370afd6238a7e3 | https://github.com/jails/li3_behaviors/blob/4d2f13c7c893ad1084dfd25f96370afd6238a7e3/data/model/Behaviors.php#L56-L68 |
11,273 | jails/li3_behaviors | data/model/Behaviors.php | Behaviors.actsAs | public static function actsAs($name, $config = [], $entry = null) {
$self = static::_object();
$class = Libraries::locate('behavior', $name);
if ($config === true) {
if (isset($self->_behaviors[$class])) {
return $self->_behaviors[$class]->config($entry);
}
throw new RuntimeException("Unexisting Behavior named `{$class}`.");
}
if ($config === false) {
unset($self->_behaviors[$class]);
return true;
}
$model = get_called_class();
if (isset($self->_behaviors[$class])) {
$self->_behaviors[$class]->config($config + compact('model'));
return true;
} else {
$object = new $class($config + compact('model'));
if ($object) {
$self->_behaviors[$class] = $object;
return true;
}
}
return false;
} | php | public static function actsAs($name, $config = [], $entry = null) {
$self = static::_object();
$class = Libraries::locate('behavior', $name);
if ($config === true) {
if (isset($self->_behaviors[$class])) {
return $self->_behaviors[$class]->config($entry);
}
throw new RuntimeException("Unexisting Behavior named `{$class}`.");
}
if ($config === false) {
unset($self->_behaviors[$class]);
return true;
}
$model = get_called_class();
if (isset($self->_behaviors[$class])) {
$self->_behaviors[$class]->config($config + compact('model'));
return true;
} else {
$object = new $class($config + compact('model'));
if ($object) {
$self->_behaviors[$class] = $object;
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"actsAs",
"(",
"$",
"name",
",",
"$",
"config",
"=",
"[",
"]",
",",
"$",
"entry",
"=",
"null",
")",
"{",
"$",
"self",
"=",
"static",
"::",
"_object",
"(",
")",
";",
"$",
"class",
"=",
"Libraries",
"::",
"locate",
"(",
"'behavior'",
",",
"$",
"name",
")",
";",
"if",
"(",
"$",
"config",
"===",
"true",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"self",
"->",
"_behaviors",
"[",
"$",
"class",
"]",
")",
")",
"{",
"return",
"$",
"self",
"->",
"_behaviors",
"[",
"$",
"class",
"]",
"->",
"config",
"(",
"$",
"entry",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexisting Behavior named `{$class}`.\"",
")",
";",
"}",
"if",
"(",
"$",
"config",
"===",
"false",
")",
"{",
"unset",
"(",
"$",
"self",
"->",
"_behaviors",
"[",
"$",
"class",
"]",
")",
";",
"return",
"true",
";",
"}",
"$",
"model",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"self",
"->",
"_behaviors",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"self",
"->",
"_behaviors",
"[",
"$",
"class",
"]",
"->",
"config",
"(",
"$",
"config",
"+",
"compact",
"(",
"'model'",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"$",
"object",
"=",
"new",
"$",
"class",
"(",
"$",
"config",
"+",
"compact",
"(",
"'model'",
")",
")",
";",
"if",
"(",
"$",
"object",
")",
"{",
"$",
"self",
"->",
"_behaviors",
"[",
"$",
"class",
"]",
"=",
"$",
"object",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Bind a behavior class to the current model
@param string $name The name of the behavior
@param string $config If `$config === true` returns some configurations of the behavior,
if `$config === false` unbind the behavior, otherwise `$config` stands for
the configuration array to set for the behavior.
@param string $entry The name of the configuration option to get. If `null` all
configuration options will be returned.
(this parameter is only applicable if `$config === true`)
@return boolean `true` on success, `false` otherwise | [
"Bind",
"a",
"behavior",
"class",
"to",
"the",
"current",
"model"
] | 4d2f13c7c893ad1084dfd25f96370afd6238a7e3 | https://github.com/jails/li3_behaviors/blob/4d2f13c7c893ad1084dfd25f96370afd6238a7e3/data/model/Behaviors.php#L118-L146 |
11,274 | skimia/api-fusion | src/Domain/Traits/CheckableTrait.php | CheckableTrait.runChecks | protected function runChecks($action, $input = [], $original = [])
{
// Perform a basic check to see if the current action is authorised
// to be performed on this resource
$this->checkAuthorisation($action);
// If input data is given
if (! empty($input)) {
// Run input validation on the input data
$filtered = $this->applyValidationRules($action, $input);
// Run business rule validation on the input data
$this->applyDomainRules($action, $input, $original);
return $filtered;
}
} | php | protected function runChecks($action, $input = [], $original = [])
{
// Perform a basic check to see if the current action is authorised
// to be performed on this resource
$this->checkAuthorisation($action);
// If input data is given
if (! empty($input)) {
// Run input validation on the input data
$filtered = $this->applyValidationRules($action, $input);
// Run business rule validation on the input data
$this->applyDomainRules($action, $input, $original);
return $filtered;
}
} | [
"protected",
"function",
"runChecks",
"(",
"$",
"action",
",",
"$",
"input",
"=",
"[",
"]",
",",
"$",
"original",
"=",
"[",
"]",
")",
"{",
"// Perform a basic check to see if the current action is authorised",
"// to be performed on this resource",
"$",
"this",
"->",
"checkAuthorisation",
"(",
"$",
"action",
")",
";",
"// If input data is given",
"if",
"(",
"!",
"empty",
"(",
"$",
"input",
")",
")",
"{",
"// Run input validation on the input data",
"$",
"filtered",
"=",
"$",
"this",
"->",
"applyValidationRules",
"(",
"$",
"action",
",",
"$",
"input",
")",
";",
"// Run business rule validation on the input data",
"$",
"this",
"->",
"applyDomainRules",
"(",
"$",
"action",
",",
"$",
"input",
",",
"$",
"original",
")",
";",
"return",
"$",
"filtered",
";",
"}",
"}"
] | Run required checks for given action.
@param string $action Requested action to check
@param array $input Input data relevant to checks
@param array $original Original data from the model
@return array InputFilteredData if $input is provided | [
"Run",
"required",
"checks",
"for",
"given",
"action",
"."
] | f904a3c171a42a37a2f84ed8c7b74e947f860910 | https://github.com/skimia/api-fusion/blob/f904a3c171a42a37a2f84ed8c7b74e947f860910/src/Domain/Traits/CheckableTrait.php#L35-L51 |
11,275 | skimia/api-fusion | src/Domain/Traits/CheckableTrait.php | CheckableTrait.applyValidationRules | protected function applyValidationRules($action, $input = [])
{
if ($action == 'read' or $action == 'destroy') {
return;
}
if (! $this->inputValidator) {
throw new RequiredInputValidatorException('You must provide an inputValidator to perform a data modification / creation');
}
$validation = $this->inputValidator->make($input);
$validation->scope([$action]);
$validation->bind($validation->getInputs()); // provide all input data for use in rule definitions
if ($validation->fails()) {
throw new ValidationException('Validation failed', $validation->errors()->all());
} else {
return $validation->getInputs();
}
} | php | protected function applyValidationRules($action, $input = [])
{
if ($action == 'read' or $action == 'destroy') {
return;
}
if (! $this->inputValidator) {
throw new RequiredInputValidatorException('You must provide an inputValidator to perform a data modification / creation');
}
$validation = $this->inputValidator->make($input);
$validation->scope([$action]);
$validation->bind($validation->getInputs()); // provide all input data for use in rule definitions
if ($validation->fails()) {
throw new ValidationException('Validation failed', $validation->errors()->all());
} else {
return $validation->getInputs();
}
} | [
"protected",
"function",
"applyValidationRules",
"(",
"$",
"action",
",",
"$",
"input",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"action",
"==",
"'read'",
"or",
"$",
"action",
"==",
"'destroy'",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"inputValidator",
")",
"{",
"throw",
"new",
"RequiredInputValidatorException",
"(",
"'You must provide an inputValidator to perform a data modification / creation'",
")",
";",
"}",
"$",
"validation",
"=",
"$",
"this",
"->",
"inputValidator",
"->",
"make",
"(",
"$",
"input",
")",
";",
"$",
"validation",
"->",
"scope",
"(",
"[",
"$",
"action",
"]",
")",
";",
"$",
"validation",
"->",
"bind",
"(",
"$",
"validation",
"->",
"getInputs",
"(",
")",
")",
";",
"// provide all input data for use in rule definitions",
"if",
"(",
"$",
"validation",
"->",
"fails",
"(",
")",
")",
"{",
"throw",
"new",
"ValidationException",
"(",
"'Validation failed'",
",",
"$",
"validation",
"->",
"errors",
"(",
")",
"->",
"all",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"validation",
"->",
"getInputs",
"(",
")",
";",
"}",
"}"
] | Apply validation rules.
@param string $action Requested action to check
@param array $input Input data
@throws ValidationException If input validation fails
@throws RequiredInputValidatorException If inputValidator is not proivide on a data modification / creation
@return array InputFilteredData | [
"Apply",
"validation",
"rules",
"."
] | f904a3c171a42a37a2f84ed8c7b74e947f860910 | https://github.com/skimia/api-fusion/blob/f904a3c171a42a37a2f84ed8c7b74e947f860910/src/Domain/Traits/CheckableTrait.php#L75-L96 |
11,276 | skimia/api-fusion | src/Domain/Traits/CheckableTrait.php | CheckableTrait.applyDomainRules | protected function applyDomainRules($action, $input = [], $original = [])
{
$domainRulesMethod = 'domainRulesOn'.ucfirst($action);
// Pass in original model if we are updating
if ($action = 'update') {
$this->{ $domainRulesMethod }($input, $original);
} else {
$this->{ $domainRulesMethod }($input);
}
} | php | protected function applyDomainRules($action, $input = [], $original = [])
{
$domainRulesMethod = 'domainRulesOn'.ucfirst($action);
// Pass in original model if we are updating
if ($action = 'update') {
$this->{ $domainRulesMethod }($input, $original);
} else {
$this->{ $domainRulesMethod }($input);
}
} | [
"protected",
"function",
"applyDomainRules",
"(",
"$",
"action",
",",
"$",
"input",
"=",
"[",
"]",
",",
"$",
"original",
"=",
"[",
"]",
")",
"{",
"$",
"domainRulesMethod",
"=",
"'domainRulesOn'",
".",
"ucfirst",
"(",
"$",
"action",
")",
";",
"// Pass in original model if we are updating",
"if",
"(",
"$",
"action",
"=",
"'update'",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"domainRulesMethod",
"}",
"(",
"$",
"input",
",",
"$",
"original",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"{",
"$",
"domainRulesMethod",
"}",
"(",
"$",
"input",
")",
";",
"}",
"}"
] | Apply domain rules.
@param string $action Requested action to check
@param array $input Input data
@param array $original Original item before modification | [
"Apply",
"domain",
"rules",
"."
] | f904a3c171a42a37a2f84ed8c7b74e947f860910 | https://github.com/skimia/api-fusion/blob/f904a3c171a42a37a2f84ed8c7b74e947f860910/src/Domain/Traits/CheckableTrait.php#L104-L114 |
11,277 | mszewcz/php-light-framework | src/Db/MySQL/Query/Delete.php | Delete.from | public function from(string $table = null): Delete
{
$this->from = [];
if (!\is_string($table) && !\is_array($table)) {
throw new InvalidArgumentException('$table has to be an array or a string');
}
$this->from = $this->namesClass->parse($table, true);
return $this;
} | php | public function from(string $table = null): Delete
{
$this->from = [];
if (!\is_string($table) && !\is_array($table)) {
throw new InvalidArgumentException('$table has to be an array or a string');
}
$this->from = $this->namesClass->parse($table, true);
return $this;
} | [
"public",
"function",
"from",
"(",
"string",
"$",
"table",
"=",
"null",
")",
":",
"Delete",
"{",
"$",
"this",
"->",
"from",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"table",
")",
"&&",
"!",
"\\",
"is_array",
"(",
"$",
"table",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'$table has to be an array or a string'",
")",
";",
"}",
"$",
"this",
"->",
"from",
"=",
"$",
"this",
"->",
"namesClass",
"->",
"parse",
"(",
"$",
"table",
",",
"true",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds table names for delete
@param string|null $table
@return Delete | [
"Adds",
"table",
"names",
"for",
"delete"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL/Query/Delete.php#L45-L54 |
11,278 | lasallecrm/lasallecrm-l5-lasallecrmcontact-pkg | src/Http/Controllers/LasallecrmcontactController.php | LasallecrmcontactController.show | public function show($id) {
// $id can be an integer -- the actual ID of the PEOPLES table; or,
// $id can be a string, in the format "Firstname@Lastname"
$peopleID = $this->helpers->determinePeopleID($id);
if (!$this->helpers->isAllowedPeopleIdSingleContactDisplay($peopleID)) {
return redirect()->back();
}
$people = $this->peopleRepository->getFind($peopleID);
$email = $this->peopleRepository->getFirstWorkEmail($peopleID);
$telephone = $this->peopleRepository->getFirstWorkTelephone($peopleID);
return view('lasallecrmcontact::single_crmcontact_basic', [
'people' => $people,
'email' => $email,
'telephone' => $telephone,
'single_contact_display_contact_form' => Config::get('lasallecrmcontact.single_contact_display_contact_form'),
'Config' => Config::class,
]);
} | php | public function show($id) {
// $id can be an integer -- the actual ID of the PEOPLES table; or,
// $id can be a string, in the format "Firstname@Lastname"
$peopleID = $this->helpers->determinePeopleID($id);
if (!$this->helpers->isAllowedPeopleIdSingleContactDisplay($peopleID)) {
return redirect()->back();
}
$people = $this->peopleRepository->getFind($peopleID);
$email = $this->peopleRepository->getFirstWorkEmail($peopleID);
$telephone = $this->peopleRepository->getFirstWorkTelephone($peopleID);
return view('lasallecrmcontact::single_crmcontact_basic', [
'people' => $people,
'email' => $email,
'telephone' => $telephone,
'single_contact_display_contact_form' => Config::get('lasallecrmcontact.single_contact_display_contact_form'),
'Config' => Config::class,
]);
} | [
"public",
"function",
"show",
"(",
"$",
"id",
")",
"{",
"// $id can be an integer -- the actual ID of the PEOPLES table; or,",
"// $id can be a string, in the format \"Firstname@Lastname\"",
"$",
"peopleID",
"=",
"$",
"this",
"->",
"helpers",
"->",
"determinePeopleID",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"helpers",
"->",
"isAllowedPeopleIdSingleContactDisplay",
"(",
"$",
"peopleID",
")",
")",
"{",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
";",
"}",
"$",
"people",
"=",
"$",
"this",
"->",
"peopleRepository",
"->",
"getFind",
"(",
"$",
"peopleID",
")",
";",
"$",
"email",
"=",
"$",
"this",
"->",
"peopleRepository",
"->",
"getFirstWorkEmail",
"(",
"$",
"peopleID",
")",
";",
"$",
"telephone",
"=",
"$",
"this",
"->",
"peopleRepository",
"->",
"getFirstWorkTelephone",
"(",
"$",
"peopleID",
")",
";",
"return",
"view",
"(",
"'lasallecrmcontact::single_crmcontact_basic'",
",",
"[",
"'people'",
"=>",
"$",
"people",
",",
"'email'",
"=>",
"$",
"email",
",",
"'telephone'",
"=>",
"$",
"telephone",
",",
"'single_contact_display_contact_form'",
"=>",
"Config",
"::",
"get",
"(",
"'lasallecrmcontact.single_contact_display_contact_form'",
")",
",",
"'Config'",
"=>",
"Config",
"::",
"class",
",",
"]",
")",
";",
"}"
] | Display a single contact from the LaSalleCRM database
@param mixed $id LaSalleCRM people ID (int) or "Firstname@Lastname" (text)
@return response | [
"Display",
"a",
"single",
"contact",
"from",
"the",
"LaSalleCRM",
"database"
] | d0a66b457a0e544636d82d4f0e71a0859dd85ee6 | https://github.com/lasallecrm/lasallecrm-l5-lasallecrmcontact-pkg/blob/d0a66b457a0e544636d82d4f0e71a0859dd85ee6/src/Http/Controllers/LasallecrmcontactController.php#L78-L99 |
11,279 | lasallecrm/lasallecrm-l5-lasallecrmcontact-pkg | src/Http/Controllers/LasallecrmcontactController.php | LasallecrmcontactController.multipleshow | public function multipleshow() {
$displayTheseIDs = Config::get('lasallecrmcontact.multiple_contact_display_people_ids');
$contacts = [];
$i = 0;
foreach ($displayTheseIDs as $displayThisID) {
$people = $this->peopleRepository->getFind($displayThisID);
$email = $this->peopleRepository->getFirstWorkEmail($displayThisID);
$telephone = $this->peopleRepository->getFirstWorkTelephone($displayThisID);
$contacts[$i]['first_name'] = $people->first_name;
$contacts[$i]['middle_name'] = $people->middle_name;
$contacts[$i]['surname'] = $people->surname;
$contacts[$i]['link'] = $people->first_name.'@'.$people->middle_name.'@'.$people->surname;
$contacts[$i]['position'] = $people->position;
$contacts[$i]['featured_image'] = $people->featured_image;
$contacts[$i]['email'] = $email ;
$contacts[$i]['telephone'] = $telephone;
$i++;
}
return view('lasallecrmcontact::multiple_crmcontact_basic', [
'contacts' => $contacts,
'Config' => Config::class,
]);
} | php | public function multipleshow() {
$displayTheseIDs = Config::get('lasallecrmcontact.multiple_contact_display_people_ids');
$contacts = [];
$i = 0;
foreach ($displayTheseIDs as $displayThisID) {
$people = $this->peopleRepository->getFind($displayThisID);
$email = $this->peopleRepository->getFirstWorkEmail($displayThisID);
$telephone = $this->peopleRepository->getFirstWorkTelephone($displayThisID);
$contacts[$i]['first_name'] = $people->first_name;
$contacts[$i]['middle_name'] = $people->middle_name;
$contacts[$i]['surname'] = $people->surname;
$contacts[$i]['link'] = $people->first_name.'@'.$people->middle_name.'@'.$people->surname;
$contacts[$i]['position'] = $people->position;
$contacts[$i]['featured_image'] = $people->featured_image;
$contacts[$i]['email'] = $email ;
$contacts[$i]['telephone'] = $telephone;
$i++;
}
return view('lasallecrmcontact::multiple_crmcontact_basic', [
'contacts' => $contacts,
'Config' => Config::class,
]);
} | [
"public",
"function",
"multipleshow",
"(",
")",
"{",
"$",
"displayTheseIDs",
"=",
"Config",
"::",
"get",
"(",
"'lasallecrmcontact.multiple_contact_display_people_ids'",
")",
";",
"$",
"contacts",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"displayTheseIDs",
"as",
"$",
"displayThisID",
")",
"{",
"$",
"people",
"=",
"$",
"this",
"->",
"peopleRepository",
"->",
"getFind",
"(",
"$",
"displayThisID",
")",
";",
"$",
"email",
"=",
"$",
"this",
"->",
"peopleRepository",
"->",
"getFirstWorkEmail",
"(",
"$",
"displayThisID",
")",
";",
"$",
"telephone",
"=",
"$",
"this",
"->",
"peopleRepository",
"->",
"getFirstWorkTelephone",
"(",
"$",
"displayThisID",
")",
";",
"$",
"contacts",
"[",
"$",
"i",
"]",
"[",
"'first_name'",
"]",
"=",
"$",
"people",
"->",
"first_name",
";",
"$",
"contacts",
"[",
"$",
"i",
"]",
"[",
"'middle_name'",
"]",
"=",
"$",
"people",
"->",
"middle_name",
";",
"$",
"contacts",
"[",
"$",
"i",
"]",
"[",
"'surname'",
"]",
"=",
"$",
"people",
"->",
"surname",
";",
"$",
"contacts",
"[",
"$",
"i",
"]",
"[",
"'link'",
"]",
"=",
"$",
"people",
"->",
"first_name",
".",
"'@'",
".",
"$",
"people",
"->",
"middle_name",
".",
"'@'",
".",
"$",
"people",
"->",
"surname",
";",
"$",
"contacts",
"[",
"$",
"i",
"]",
"[",
"'position'",
"]",
"=",
"$",
"people",
"->",
"position",
";",
"$",
"contacts",
"[",
"$",
"i",
"]",
"[",
"'featured_image'",
"]",
"=",
"$",
"people",
"->",
"featured_image",
";",
"$",
"contacts",
"[",
"$",
"i",
"]",
"[",
"'email'",
"]",
"=",
"$",
"email",
";",
"$",
"contacts",
"[",
"$",
"i",
"]",
"[",
"'telephone'",
"]",
"=",
"$",
"telephone",
";",
"$",
"i",
"++",
";",
"}",
"return",
"view",
"(",
"'lasallecrmcontact::multiple_crmcontact_basic'",
",",
"[",
"'contacts'",
"=>",
"$",
"contacts",
",",
"'Config'",
"=>",
"Config",
"::",
"class",
",",
"]",
")",
";",
"}"
] | Display multiple contacts from the LaSalleCRM database
@return response | [
"Display",
"multiple",
"contacts",
"from",
"the",
"LaSalleCRM",
"database"
] | d0a66b457a0e544636d82d4f0e71a0859dd85ee6 | https://github.com/lasallecrm/lasallecrm-l5-lasallecrmcontact-pkg/blob/d0a66b457a0e544636d82d4f0e71a0859dd85ee6/src/Http/Controllers/LasallecrmcontactController.php#L107-L136 |
11,280 | tonjoo/tiga-framework | src/Template/h2o/context.php | H2o_Context.resolve | public function resolve($var)
{
# if $var is array - it contains filters to apply
$filters = array();
if (is_array($var)) {
$name = array_shift($var);
$filters = isset($var['filters']) ? $var['filters'] : array();
} else {
$name = $var;
}
$result = null;
# Lookup basic types, null, boolean, numeric and string
# Variable starts with : (:users.name) to short-circuit lookup
if ($name[0] === ':') {
$object = $this->getVariable(substr($name, 1));
if (!is_null($object)) {
$result = $object;
}
} else {
if ($name === 'true') {
$result = true;
} elseif ($name === 'false') {
$result = false;
} elseif (preg_match('/^-?\d+(\.\d+)?$/', $name, $matches)) {
$result = isset($matches[1]) ? floatval($name) : intval($name);
} elseif (preg_match('/^"([^"\\\\]*(?:\\.[^"\\\\]*)*)"|'.
'\'([^\'\\\\]*(?:\\.[^\'\\\\]*)*)\'$/', $name)) {
$result = stripcslashes(substr($name, 1, -1));
}
}
if (!empty(self::$lookupTable) && $result == null) {
$result = $this->externalLookup($name);
}
$result = $this->applyFilters($result, $filters);
return $result;
} | php | public function resolve($var)
{
# if $var is array - it contains filters to apply
$filters = array();
if (is_array($var)) {
$name = array_shift($var);
$filters = isset($var['filters']) ? $var['filters'] : array();
} else {
$name = $var;
}
$result = null;
# Lookup basic types, null, boolean, numeric and string
# Variable starts with : (:users.name) to short-circuit lookup
if ($name[0] === ':') {
$object = $this->getVariable(substr($name, 1));
if (!is_null($object)) {
$result = $object;
}
} else {
if ($name === 'true') {
$result = true;
} elseif ($name === 'false') {
$result = false;
} elseif (preg_match('/^-?\d+(\.\d+)?$/', $name, $matches)) {
$result = isset($matches[1]) ? floatval($name) : intval($name);
} elseif (preg_match('/^"([^"\\\\]*(?:\\.[^"\\\\]*)*)"|'.
'\'([^\'\\\\]*(?:\\.[^\'\\\\]*)*)\'$/', $name)) {
$result = stripcslashes(substr($name, 1, -1));
}
}
if (!empty(self::$lookupTable) && $result == null) {
$result = $this->externalLookup($name);
}
$result = $this->applyFilters($result, $filters);
return $result;
} | [
"public",
"function",
"resolve",
"(",
"$",
"var",
")",
"{",
"# if $var is array - it contains filters to apply",
"$",
"filters",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"var",
")",
")",
"{",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"var",
")",
";",
"$",
"filters",
"=",
"isset",
"(",
"$",
"var",
"[",
"'filters'",
"]",
")",
"?",
"$",
"var",
"[",
"'filters'",
"]",
":",
"array",
"(",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"var",
";",
"}",
"$",
"result",
"=",
"null",
";",
"# Lookup basic types, null, boolean, numeric and string",
"# Variable starts with : (:users.name) to short-circuit lookup",
"if",
"(",
"$",
"name",
"[",
"0",
"]",
"===",
"':'",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"getVariable",
"(",
"substr",
"(",
"$",
"name",
",",
"1",
")",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"object",
")",
")",
"{",
"$",
"result",
"=",
"$",
"object",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"name",
"===",
"'true'",
")",
"{",
"$",
"result",
"=",
"true",
";",
"}",
"elseif",
"(",
"$",
"name",
"===",
"'false'",
")",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^-?\\d+(\\.\\d+)?$/'",
",",
"$",
"name",
",",
"$",
"matches",
")",
")",
"{",
"$",
"result",
"=",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
"?",
"floatval",
"(",
"$",
"name",
")",
":",
"intval",
"(",
"$",
"name",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^\"([^\"\\\\\\\\]*(?:\\\\.[^\"\\\\\\\\]*)*)\"|'",
".",
"'\\'([^\\'\\\\\\\\]*(?:\\\\.[^\\'\\\\\\\\]*)*)\\'$/'",
",",
"$",
"name",
")",
")",
"{",
"$",
"result",
"=",
"stripcslashes",
"(",
"substr",
"(",
"$",
"name",
",",
"1",
",",
"-",
"1",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"self",
"::",
"$",
"lookupTable",
")",
"&&",
"$",
"result",
"==",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"externalLookup",
"(",
"$",
"name",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"applyFilters",
"(",
"$",
"result",
",",
"$",
"filters",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Variable name.
@param $var variable name or array(0 => variable name, 'filters' => filters array)
@return unknown_type | [
"Variable",
"name",
"."
] | 3c2eebd3bc616106fa1bba3e43f1791aff75eec5 | https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Template/h2o/context.php#L118-L157 |
11,281 | slickframework/console | src/CommandFactory.php | CommandFactory.loadCommands | public function loadCommands()
{
$slickModules = $this->filterSlickModules();
$classes = $this->getCommandClasses($slickModules);
foreach ($classes as $class) {
if (is_subclass_of($class, Command::class)) {
$this->application->add(new $class());
}
}
} | php | public function loadCommands()
{
$slickModules = $this->filterSlickModules();
$classes = $this->getCommandClasses($slickModules);
foreach ($classes as $class) {
if (is_subclass_of($class, Command::class)) {
$this->application->add(new $class());
}
}
} | [
"public",
"function",
"loadCommands",
"(",
")",
"{",
"$",
"slickModules",
"=",
"$",
"this",
"->",
"filterSlickModules",
"(",
")",
";",
"$",
"classes",
"=",
"$",
"this",
"->",
"getCommandClasses",
"(",
"$",
"slickModules",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"is_subclass_of",
"(",
"$",
"class",
",",
"Command",
"::",
"class",
")",
")",
"{",
"$",
"this",
"->",
"application",
"->",
"add",
"(",
"new",
"$",
"class",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Load all slick commands | [
"Load",
"all",
"slick",
"commands"
] | d354a0ab6fd5e8a2d7ad9e2bb03d8423369de2a6 | https://github.com/slickframework/console/blob/d354a0ab6fd5e8a2d7ad9e2bb03d8423369de2a6/src/CommandFactory.php#L48-L57 |
11,282 | slickframework/console | src/CommandFactory.php | CommandFactory.filterSlickModules | protected function filterSlickModules()
{
$iterator = new \ArrayIterator($this->psr4Data);
$modules = [];
foreach ($iterator as $nameSpace => $path) {
if (preg_match('/^Slick\\\[a-z_]*\\\$/i', $nameSpace)) {
$modules[$nameSpace] = reset($path);
}
}
return $modules;
} | php | protected function filterSlickModules()
{
$iterator = new \ArrayIterator($this->psr4Data);
$modules = [];
foreach ($iterator as $nameSpace => $path) {
if (preg_match('/^Slick\\\[a-z_]*\\\$/i', $nameSpace)) {
$modules[$nameSpace] = reset($path);
}
}
return $modules;
} | [
"protected",
"function",
"filterSlickModules",
"(",
")",
"{",
"$",
"iterator",
"=",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"this",
"->",
"psr4Data",
")",
";",
"$",
"modules",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"nameSpace",
"=>",
"$",
"path",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^Slick\\\\\\[a-z_]*\\\\\\$/i'",
",",
"$",
"nameSpace",
")",
")",
"{",
"$",
"modules",
"[",
"$",
"nameSpace",
"]",
"=",
"reset",
"(",
"$",
"path",
")",
";",
"}",
"}",
"return",
"$",
"modules",
";",
"}"
] | Retrieves all Slick modules installed from composer
@return array | [
"Retrieves",
"all",
"Slick",
"modules",
"installed",
"from",
"composer"
] | d354a0ab6fd5e8a2d7ad9e2bb03d8423369de2a6 | https://github.com/slickframework/console/blob/d354a0ab6fd5e8a2d7ad9e2bb03d8423369de2a6/src/CommandFactory.php#L64-L74 |
11,283 | slickframework/console | src/CommandFactory.php | CommandFactory.getCommandClasses | protected function getCommandClasses(array $modules)
{
$classes = [];
foreach ($modules as $nameSpace => $path) {
$classes = array_merge($classes, $this->getClasses($nameSpace, $path));
}
return $classes;
} | php | protected function getCommandClasses(array $modules)
{
$classes = [];
foreach ($modules as $nameSpace => $path) {
$classes = array_merge($classes, $this->getClasses($nameSpace, $path));
}
return $classes;
} | [
"protected",
"function",
"getCommandClasses",
"(",
"array",
"$",
"modules",
")",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"nameSpace",
"=>",
"$",
"path",
")",
"{",
"$",
"classes",
"=",
"array_merge",
"(",
"$",
"classes",
",",
"$",
"this",
"->",
"getClasses",
"(",
"$",
"nameSpace",
",",
"$",
"path",
")",
")",
";",
"}",
"return",
"$",
"classes",
";",
"}"
] | Get user defined classes in "Console\Command" name space of each module
@param array $modules
@return array | [
"Get",
"user",
"defined",
"classes",
"in",
"Console",
"\\",
"Command",
"name",
"space",
"of",
"each",
"module"
] | d354a0ab6fd5e8a2d7ad9e2bb03d8423369de2a6 | https://github.com/slickframework/console/blob/d354a0ab6fd5e8a2d7ad9e2bb03d8423369de2a6/src/CommandFactory.php#L82-L89 |
11,284 | slickframework/console | src/CommandFactory.php | CommandFactory.getClasses | protected function getClasses($namespace, $path)
{
$classes = [];
$path = "$path/Console/Command";
if (!is_dir($path)) {
return $classes;
}
$dir = new \DirectoryIterator($path);
$classFiles = new \RegexIterator($dir, '/[a-z_]*\.php/i');
foreach ($classFiles as $file) {
$classes[] = str_replace('.php', '', "{$namespace}Console\\Command\\{$file}");
}
return $classes;
} | php | protected function getClasses($namespace, $path)
{
$classes = [];
$path = "$path/Console/Command";
if (!is_dir($path)) {
return $classes;
}
$dir = new \DirectoryIterator($path);
$classFiles = new \RegexIterator($dir, '/[a-z_]*\.php/i');
foreach ($classFiles as $file) {
$classes[] = str_replace('.php', '', "{$namespace}Console\\Command\\{$file}");
}
return $classes;
} | [
"protected",
"function",
"getClasses",
"(",
"$",
"namespace",
",",
"$",
"path",
")",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"$",
"path",
"=",
"\"$path/Console/Command\"",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"classes",
";",
"}",
"$",
"dir",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"path",
")",
";",
"$",
"classFiles",
"=",
"new",
"\\",
"RegexIterator",
"(",
"$",
"dir",
",",
"'/[a-z_]*\\.php/i'",
")",
";",
"foreach",
"(",
"$",
"classFiles",
"as",
"$",
"file",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"\"{$namespace}Console\\\\Command\\\\{$file}\"",
")",
";",
"}",
"return",
"$",
"classes",
";",
"}"
] | Get classes that implements the Command interface
@param string $namespace
@param string $path
@return array | [
"Get",
"classes",
"that",
"implements",
"the",
"Command",
"interface"
] | d354a0ab6fd5e8a2d7ad9e2bb03d8423369de2a6 | https://github.com/slickframework/console/blob/d354a0ab6fd5e8a2d7ad9e2bb03d8423369de2a6/src/CommandFactory.php#L99-L113 |
11,285 | tekkla/core-html | Core/Html/Controls/Group.php | Group.setHeading | public function setHeading($heading_text, $heading_size = 2)
{
$this->heading_text = $heading_text;
$this->heading_size = is_int($heading_size) ? $heading_size : 2;
return $this;
} | php | public function setHeading($heading_text, $heading_size = 2)
{
$this->heading_text = $heading_text;
$this->heading_size = is_int($heading_size) ? $heading_size : 2;
return $this;
} | [
"public",
"function",
"setHeading",
"(",
"$",
"heading_text",
",",
"$",
"heading_size",
"=",
"2",
")",
"{",
"$",
"this",
"->",
"heading_text",
"=",
"$",
"heading_text",
";",
"$",
"this",
"->",
"heading_size",
"=",
"is_int",
"(",
"$",
"heading_size",
")",
"?",
"$",
"heading_size",
":",
"2",
";",
"return",
"$",
"this",
";",
"}"
] | Set heading text and size
@param string $heading_text
@param number $heading_size
@return \Core\Html\Controls\Group | [
"Set",
"heading",
"text",
"and",
"size"
] | 00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3 | https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Controls/Group.php#L91-L97 |
11,286 | wollanup/php-api-rest | src/Service/Router/Route.php | Route.setSuccessStatus | public function setSuccessStatus(int $status, string $description = ""): RouteInterface
{
$this->statuses[$status] = HttpStatus::create()
->setStatus($status)
->setDescription($description)
->setMainSuccess(true);
/**
* This middleware is an "AFTER" middleware, so add it first to be run last...
*/
return $this->addFirst(new SuccessStatusMiddleware($status));
} | php | public function setSuccessStatus(int $status, string $description = ""): RouteInterface
{
$this->statuses[$status] = HttpStatus::create()
->setStatus($status)
->setDescription($description)
->setMainSuccess(true);
/**
* This middleware is an "AFTER" middleware, so add it first to be run last...
*/
return $this->addFirst(new SuccessStatusMiddleware($status));
} | [
"public",
"function",
"setSuccessStatus",
"(",
"int",
"$",
"status",
",",
"string",
"$",
"description",
"=",
"\"\"",
")",
":",
"RouteInterface",
"{",
"$",
"this",
"->",
"statuses",
"[",
"$",
"status",
"]",
"=",
"HttpStatus",
"::",
"create",
"(",
")",
"->",
"setStatus",
"(",
"$",
"status",
")",
"->",
"setDescription",
"(",
"$",
"description",
")",
"->",
"setMainSuccess",
"(",
"true",
")",
";",
"/**\n * This middleware is an \"AFTER\" middleware, so add it first to be run last...\n */",
"return",
"$",
"this",
"->",
"addFirst",
"(",
"new",
"SuccessStatusMiddleware",
"(",
"$",
"status",
")",
")",
";",
"}"
] | Set status code in case of success response
@param int $status
@param string $description
@return RouteInterface | [
"Set",
"status",
"code",
"in",
"case",
"of",
"success",
"response"
] | 185eac8a8412e5997d8e292ebd0e38787ae4b949 | https://github.com/wollanup/php-api-rest/blob/185eac8a8412e5997d8e292ebd0e38787ae4b949/src/Service/Router/Route.php#L583-L594 |
11,287 | wollanup/php-api-rest | src/Service/Router/Route.php | Route.setSuccessLocationHeader | public function setSuccessLocationHeader(
string $location,
EntityFactoryConfig $config,
int $status = 302
): RouteInterface {
return $this->addFirst(new SuccessHeaderLocationMiddleware($location, $config, $status));
} | php | public function setSuccessLocationHeader(
string $location,
EntityFactoryConfig $config,
int $status = 302
): RouteInterface {
return $this->addFirst(new SuccessHeaderLocationMiddleware($location, $config, $status));
} | [
"public",
"function",
"setSuccessLocationHeader",
"(",
"string",
"$",
"location",
",",
"EntityFactoryConfig",
"$",
"config",
",",
"int",
"$",
"status",
"=",
"302",
")",
":",
"RouteInterface",
"{",
"return",
"$",
"this",
"->",
"addFirst",
"(",
"new",
"SuccessHeaderLocationMiddleware",
"(",
"$",
"location",
",",
"$",
"config",
",",
"$",
"status",
")",
")",
";",
"}"
] | Add a Location header to the response
Can take a placeholder to replace a variable by an entity getter
e.g.
```php
'/resource/{id}'
```
will be replaced by
```php
'/resource/' . $entity->getId()
```
@param string $location
@param EntityFactoryConfig $config
@param int $status
@return RouteInterface | [
"Add",
"a",
"Location",
"header",
"to",
"the",
"response"
] | 185eac8a8412e5997d8e292ebd0e38787ae4b949 | https://github.com/wollanup/php-api-rest/blob/185eac8a8412e5997d8e292ebd0e38787ae4b949/src/Service/Router/Route.php#L633-L639 |
11,288 | subugoe/typo3-pazpar2 | Classes/Service/Flexform.php | tx_Pazpar2_Service_Flexform.buildMenu | public function buildMenu($config)
{
$rootNodes = $this->queryForChildrenOf('NE');
$options = [['', '']];
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($rootNodes)) {
$optionTitle = $row['descr'];
$optionValue = $row['ppn'];
$options[] = [$optionTitle , $optionValue];
}
$config['items'] = array_merge($config['items'], $options);
return $config;
} | php | public function buildMenu($config)
{
$rootNodes = $this->queryForChildrenOf('NE');
$options = [['', '']];
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($rootNodes)) {
$optionTitle = $row['descr'];
$optionValue = $row['ppn'];
$options[] = [$optionTitle , $optionValue];
}
$config['items'] = array_merge($config['items'], $options);
return $config;
} | [
"public",
"function",
"buildMenu",
"(",
"$",
"config",
")",
"{",
"$",
"rootNodes",
"=",
"$",
"this",
"->",
"queryForChildrenOf",
"(",
"'NE'",
")",
";",
"$",
"options",
"=",
"[",
"[",
"''",
",",
"''",
"]",
"]",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"GLOBALS",
"[",
"'TYPO3_DB'",
"]",
"->",
"sql_fetch_assoc",
"(",
"$",
"rootNodes",
")",
")",
"{",
"$",
"optionTitle",
"=",
"$",
"row",
"[",
"'descr'",
"]",
";",
"$",
"optionValue",
"=",
"$",
"row",
"[",
"'ppn'",
"]",
";",
"$",
"options",
"[",
"]",
"=",
"[",
"$",
"optionTitle",
",",
"$",
"optionValue",
"]",
";",
"}",
"$",
"config",
"[",
"'items'",
"]",
"=",
"array_merge",
"(",
"$",
"config",
"[",
"'items'",
"]",
",",
"$",
"options",
")",
";",
"return",
"$",
"config",
";",
"}"
] | Called from Flexform to provide menu items with Neuerwerbungen subjects.
@param array $config
@return array | [
"Called",
"from",
"Flexform",
"to",
"provide",
"menu",
"items",
"with",
"Neuerwerbungen",
"subjects",
"."
] | 3da8c483e24228d92dbb9fff034f0ff50ac937ef | https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/Service/Flexform.php#L36-L49 |
11,289 | bishopb/vanilla | library/core/class.module.php | Gdn_Module.FetchView | public function FetchView() {
$ViewPath = $this->FetchViewLocation();
$String = '';
ob_start();
if(is_object($this->_Sender) && isset($this->_Sender->Data)) {
$Data = $this->_Sender->Data;
} else {
$Data = array();
}
include ($ViewPath);
$String = ob_get_contents();
@ob_end_clean();
return $String;
} | php | public function FetchView() {
$ViewPath = $this->FetchViewLocation();
$String = '';
ob_start();
if(is_object($this->_Sender) && isset($this->_Sender->Data)) {
$Data = $this->_Sender->Data;
} else {
$Data = array();
}
include ($ViewPath);
$String = ob_get_contents();
@ob_end_clean();
return $String;
} | [
"public",
"function",
"FetchView",
"(",
")",
"{",
"$",
"ViewPath",
"=",
"$",
"this",
"->",
"FetchViewLocation",
"(",
")",
";",
"$",
"String",
"=",
"''",
";",
"ob_start",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"_Sender",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"_Sender",
"->",
"Data",
")",
")",
"{",
"$",
"Data",
"=",
"$",
"this",
"->",
"_Sender",
"->",
"Data",
";",
"}",
"else",
"{",
"$",
"Data",
"=",
"array",
"(",
")",
";",
"}",
"include",
"(",
"$",
"ViewPath",
")",
";",
"$",
"String",
"=",
"ob_get_contents",
"(",
")",
";",
"@",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"String",
";",
"}"
] | Returns the xhtml for this module as a fully parsed and rendered string.
@return string | [
"Returns",
"the",
"xhtml",
"for",
"this",
"module",
"as",
"a",
"fully",
"parsed",
"and",
"rendered",
"string",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.module.php#L105-L118 |
11,290 | bishopb/vanilla | library/core/class.module.php | Gdn_Module.FetchViewLocation | public function FetchViewLocation($View = '', $ApplicationFolder = '') {
if ($View == '')
$View = strtolower($this->Name());
if (substr($View, -6) == 'module')
$View = substr($View, 0, -6);
if (substr($View, 0, 4) == 'gdn_')
$View = substr($View, 4);
if ($ApplicationFolder == '')
$ApplicationFolder = strpos($this->_ApplicationFolder, '/') ? $this->_ApplicationFolder : strtolower($this->_ApplicationFolder);
$ThemeFolder = $this->_ThemeFolder;
$ViewPath = NULL;
// Try to use Gdn_Controller's FetchViewLocation
if (Gdn::Controller() instanceof Gdn_Controller) {
try {
$ViewPath = Gdn::Controller()->FetchViewLocation($View, 'modules', $ApplicationFolder);
} catch (Exception $Ex) {}
}
if (!$ViewPath) {
$ViewPaths = array();
// 1. An explicitly defined path to a view
if (strpos($View, '/') !== FALSE)
$ViewPaths[] = $View;
// 2. A theme
if ($ThemeFolder != '') {
// a. Application-specific theme view. eg. /path/to/application/themes/theme_name/app_name/views/modules/
$ViewPaths[] = CombinePaths(array(PATH_THEMES, $ThemeFolder, $ApplicationFolder, 'views', 'modules', $View . '.php'));
// b. Garden-wide theme view. eg. /path/to/application/themes/theme_name/views/modules/
$ViewPaths[] = CombinePaths(array(PATH_THEMES, $ThemeFolder, 'views', 'modules', $View . '.php'));
}
// 3. Application default. eg. /path/to/application/app_name/views/controller_name/
if ($this->_ApplicationFolder)
$ViewPaths[] = CombinePaths(array(PATH_APPLICATIONS, $ApplicationFolder, 'views', 'modules', $View . '.php'));
else
$ViewPaths[] = dirname($this->Path())."/../views/modules/$View.php";
// 4. Garden default. eg. /path/to/application/dashboard/views/modules/
$ViewPaths[] = CombinePaths(array(PATH_APPLICATIONS, 'dashboard', 'views', 'modules', $View . '.php'));
$ViewPath = Gdn_FileSystem::Exists($ViewPaths);
}
if ($ViewPath === FALSE)
throw new Exception(ErrorMessage('Could not find a `' . $View . '` view for the `' . $this->Name() . '` module in the `' . $ApplicationFolder . '` application.', get_class($this), 'FetchView'), E_USER_ERROR);
return $ViewPath;
} | php | public function FetchViewLocation($View = '', $ApplicationFolder = '') {
if ($View == '')
$View = strtolower($this->Name());
if (substr($View, -6) == 'module')
$View = substr($View, 0, -6);
if (substr($View, 0, 4) == 'gdn_')
$View = substr($View, 4);
if ($ApplicationFolder == '')
$ApplicationFolder = strpos($this->_ApplicationFolder, '/') ? $this->_ApplicationFolder : strtolower($this->_ApplicationFolder);
$ThemeFolder = $this->_ThemeFolder;
$ViewPath = NULL;
// Try to use Gdn_Controller's FetchViewLocation
if (Gdn::Controller() instanceof Gdn_Controller) {
try {
$ViewPath = Gdn::Controller()->FetchViewLocation($View, 'modules', $ApplicationFolder);
} catch (Exception $Ex) {}
}
if (!$ViewPath) {
$ViewPaths = array();
// 1. An explicitly defined path to a view
if (strpos($View, '/') !== FALSE)
$ViewPaths[] = $View;
// 2. A theme
if ($ThemeFolder != '') {
// a. Application-specific theme view. eg. /path/to/application/themes/theme_name/app_name/views/modules/
$ViewPaths[] = CombinePaths(array(PATH_THEMES, $ThemeFolder, $ApplicationFolder, 'views', 'modules', $View . '.php'));
// b. Garden-wide theme view. eg. /path/to/application/themes/theme_name/views/modules/
$ViewPaths[] = CombinePaths(array(PATH_THEMES, $ThemeFolder, 'views', 'modules', $View . '.php'));
}
// 3. Application default. eg. /path/to/application/app_name/views/controller_name/
if ($this->_ApplicationFolder)
$ViewPaths[] = CombinePaths(array(PATH_APPLICATIONS, $ApplicationFolder, 'views', 'modules', $View . '.php'));
else
$ViewPaths[] = dirname($this->Path())."/../views/modules/$View.php";
// 4. Garden default. eg. /path/to/application/dashboard/views/modules/
$ViewPaths[] = CombinePaths(array(PATH_APPLICATIONS, 'dashboard', 'views', 'modules', $View . '.php'));
$ViewPath = Gdn_FileSystem::Exists($ViewPaths);
}
if ($ViewPath === FALSE)
throw new Exception(ErrorMessage('Could not find a `' . $View . '` view for the `' . $this->Name() . '` module in the `' . $ApplicationFolder . '` application.', get_class($this), 'FetchView'), E_USER_ERROR);
return $ViewPath;
} | [
"public",
"function",
"FetchViewLocation",
"(",
"$",
"View",
"=",
"''",
",",
"$",
"ApplicationFolder",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"View",
"==",
"''",
")",
"$",
"View",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"Name",
"(",
")",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"View",
",",
"-",
"6",
")",
"==",
"'module'",
")",
"$",
"View",
"=",
"substr",
"(",
"$",
"View",
",",
"0",
",",
"-",
"6",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"View",
",",
"0",
",",
"4",
")",
"==",
"'gdn_'",
")",
"$",
"View",
"=",
"substr",
"(",
"$",
"View",
",",
"4",
")",
";",
"if",
"(",
"$",
"ApplicationFolder",
"==",
"''",
")",
"$",
"ApplicationFolder",
"=",
"strpos",
"(",
"$",
"this",
"->",
"_ApplicationFolder",
",",
"'/'",
")",
"?",
"$",
"this",
"->",
"_ApplicationFolder",
":",
"strtolower",
"(",
"$",
"this",
"->",
"_ApplicationFolder",
")",
";",
"$",
"ThemeFolder",
"=",
"$",
"this",
"->",
"_ThemeFolder",
";",
"$",
"ViewPath",
"=",
"NULL",
";",
"// Try to use Gdn_Controller's FetchViewLocation",
"if",
"(",
"Gdn",
"::",
"Controller",
"(",
")",
"instanceof",
"Gdn_Controller",
")",
"{",
"try",
"{",
"$",
"ViewPath",
"=",
"Gdn",
"::",
"Controller",
"(",
")",
"->",
"FetchViewLocation",
"(",
"$",
"View",
",",
"'modules'",
",",
"$",
"ApplicationFolder",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"Ex",
")",
"{",
"}",
"}",
"if",
"(",
"!",
"$",
"ViewPath",
")",
"{",
"$",
"ViewPaths",
"=",
"array",
"(",
")",
";",
"// 1. An explicitly defined path to a view",
"if",
"(",
"strpos",
"(",
"$",
"View",
",",
"'/'",
")",
"!==",
"FALSE",
")",
"$",
"ViewPaths",
"[",
"]",
"=",
"$",
"View",
";",
"// 2. A theme",
"if",
"(",
"$",
"ThemeFolder",
"!=",
"''",
")",
"{",
"// a. Application-specific theme view. eg. /path/to/application/themes/theme_name/app_name/views/modules/",
"$",
"ViewPaths",
"[",
"]",
"=",
"CombinePaths",
"(",
"array",
"(",
"PATH_THEMES",
",",
"$",
"ThemeFolder",
",",
"$",
"ApplicationFolder",
",",
"'views'",
",",
"'modules'",
",",
"$",
"View",
".",
"'.php'",
")",
")",
";",
"// b. Garden-wide theme view. eg. /path/to/application/themes/theme_name/views/modules/",
"$",
"ViewPaths",
"[",
"]",
"=",
"CombinePaths",
"(",
"array",
"(",
"PATH_THEMES",
",",
"$",
"ThemeFolder",
",",
"'views'",
",",
"'modules'",
",",
"$",
"View",
".",
"'.php'",
")",
")",
";",
"}",
"// 3. Application default. eg. /path/to/application/app_name/views/controller_name/",
"if",
"(",
"$",
"this",
"->",
"_ApplicationFolder",
")",
"$",
"ViewPaths",
"[",
"]",
"=",
"CombinePaths",
"(",
"array",
"(",
"PATH_APPLICATIONS",
",",
"$",
"ApplicationFolder",
",",
"'views'",
",",
"'modules'",
",",
"$",
"View",
".",
"'.php'",
")",
")",
";",
"else",
"$",
"ViewPaths",
"[",
"]",
"=",
"dirname",
"(",
"$",
"this",
"->",
"Path",
"(",
")",
")",
".",
"\"/../views/modules/$View.php\"",
";",
"// 4. Garden default. eg. /path/to/application/dashboard/views/modules/",
"$",
"ViewPaths",
"[",
"]",
"=",
"CombinePaths",
"(",
"array",
"(",
"PATH_APPLICATIONS",
",",
"'dashboard'",
",",
"'views'",
",",
"'modules'",
",",
"$",
"View",
".",
"'.php'",
")",
")",
";",
"$",
"ViewPath",
"=",
"Gdn_FileSystem",
"::",
"Exists",
"(",
"$",
"ViewPaths",
")",
";",
"}",
"if",
"(",
"$",
"ViewPath",
"===",
"FALSE",
")",
"throw",
"new",
"Exception",
"(",
"ErrorMessage",
"(",
"'Could not find a `'",
".",
"$",
"View",
".",
"'` view for the `'",
".",
"$",
"this",
"->",
"Name",
"(",
")",
".",
"'` module in the `'",
".",
"$",
"ApplicationFolder",
".",
"'` application.'",
",",
"get_class",
"(",
"$",
"this",
")",
",",
"'FetchView'",
")",
",",
"E_USER_ERROR",
")",
";",
"return",
"$",
"ViewPath",
";",
"}"
] | Returns the location of the view for this module in the filesystem.
@param string $View
@param string $ApplicationFolder
@return array | [
"Returns",
"the",
"location",
"of",
"the",
"view",
"for",
"this",
"module",
"in",
"the",
"filesystem",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.module.php#L128-L184 |
11,291 | ellipsephp/validation | src/Translator.php | Translator.withLabels | public function withLabels(array $labels = []): Translator
{
$labels = array_merge($this->labels, $labels);
return new Translator($labels, $this->templates);
} | php | public function withLabels(array $labels = []): Translator
{
$labels = array_merge($this->labels, $labels);
return new Translator($labels, $this->templates);
} | [
"public",
"function",
"withLabels",
"(",
"array",
"$",
"labels",
"=",
"[",
"]",
")",
":",
"Translator",
"{",
"$",
"labels",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"labels",
",",
"$",
"labels",
")",
";",
"return",
"new",
"Translator",
"(",
"$",
"labels",
",",
"$",
"this",
"->",
"templates",
")",
";",
"}"
] | Return a new translator with an additional list of labels.
@param array $labels
@return \Ellipse\Validation\Translator | [
"Return",
"a",
"new",
"translator",
"with",
"an",
"additional",
"list",
"of",
"labels",
"."
] | 5a7e11807099165ff6217bf8c38df4b21d99599d | https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/Translator.php#L54-L59 |
11,292 | ellipsephp/validation | src/Translator.php | Translator.withTemplates | public function withTemplates(array $templates = []): Translator
{
$templates = array_merge($this->templates, $templates);
return new Translator($this->labels, $templates);
} | php | public function withTemplates(array $templates = []): Translator
{
$templates = array_merge($this->templates, $templates);
return new Translator($this->labels, $templates);
} | [
"public",
"function",
"withTemplates",
"(",
"array",
"$",
"templates",
"=",
"[",
"]",
")",
":",
"Translator",
"{",
"$",
"templates",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"templates",
",",
"$",
"templates",
")",
";",
"return",
"new",
"Translator",
"(",
"$",
"this",
"->",
"labels",
",",
"$",
"templates",
")",
";",
"}"
] | Return a new translator with an additional list of templates.
@param array $templates
@return \Ellipse\Validation\Translator | [
"Return",
"a",
"new",
"translator",
"with",
"an",
"additional",
"list",
"of",
"templates",
"."
] | 5a7e11807099165ff6217bf8c38df4b21d99599d | https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/Translator.php#L67-L72 |
11,293 | ellipsephp/validation | src/Translator.php | Translator.getMessages | public function getMessages(string $key, array $errors = []): array
{
// when there is a template for the given key, return only this message.
if (array_key_exists($key, $this->templates)) {
return [$this->translate($this->templates[$key], ['attribute' => $key])];
}
// return one message for each rule which failed.
return array_reduce($errors, function ($messages, $error) use ($key) {
$rule = $error->getRule();
$parameters = $error->getParameters();
$template = $this->getTemplate($key, $rule);
$message = $this->translate($template, array_merge($parameters, [
'attribute' => $key,
]));
return array_merge($messages, [$message]);
}, []);
} | php | public function getMessages(string $key, array $errors = []): array
{
// when there is a template for the given key, return only this message.
if (array_key_exists($key, $this->templates)) {
return [$this->translate($this->templates[$key], ['attribute' => $key])];
}
// return one message for each rule which failed.
return array_reduce($errors, function ($messages, $error) use ($key) {
$rule = $error->getRule();
$parameters = $error->getParameters();
$template = $this->getTemplate($key, $rule);
$message = $this->translate($template, array_merge($parameters, [
'attribute' => $key,
]));
return array_merge($messages, [$message]);
}, []);
} | [
"public",
"function",
"getMessages",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"errors",
"=",
"[",
"]",
")",
":",
"array",
"{",
"// when there is a template for the given key, return only this message.",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"templates",
")",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"translate",
"(",
"$",
"this",
"->",
"templates",
"[",
"$",
"key",
"]",
",",
"[",
"'attribute'",
"=>",
"$",
"key",
"]",
")",
"]",
";",
"}",
"// return one message for each rule which failed.",
"return",
"array_reduce",
"(",
"$",
"errors",
",",
"function",
"(",
"$",
"messages",
",",
"$",
"error",
")",
"use",
"(",
"$",
"key",
")",
"{",
"$",
"rule",
"=",
"$",
"error",
"->",
"getRule",
"(",
")",
";",
"$",
"parameters",
"=",
"$",
"error",
"->",
"getParameters",
"(",
")",
";",
"$",
"template",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"key",
",",
"$",
"rule",
")",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"translate",
"(",
"$",
"template",
",",
"array_merge",
"(",
"$",
"parameters",
",",
"[",
"'attribute'",
"=>",
"$",
"key",
",",
"]",
")",
")",
";",
"return",
"array_merge",
"(",
"$",
"messages",
",",
"[",
"$",
"message",
"]",
")",
";",
"}",
",",
"[",
"]",
")",
";",
"}"
] | Return a list of messages from a rule key and its list of errors.
@param string $key
@param array $errors
@return array | [
"Return",
"a",
"list",
"of",
"messages",
"from",
"a",
"rule",
"key",
"and",
"its",
"list",
"of",
"errors",
"."
] | 5a7e11807099165ff6217bf8c38df4b21d99599d | https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/Translator.php#L81-L105 |
11,294 | ellipsephp/validation | src/Translator.php | Translator.getTemplate | private function getTemplate(string $key, string $rule): string
{
$keyrule = implode('.', [$key, $rule]);
if (array_key_exists($keyrule, $this->templates)) {
return $this->templates[$keyrule];
}
if (array_key_exists($rule, $this->templates)) {
return $this->templates[$rule];
}
if (array_key_exists(self::DEFAULT_TEMPLATE_KEY, $this->templates)) {
return $this->templates[self::DEFAULT_TEMPLATE_KEY];
}
return self::FALLBACK_TEMPLATE;
} | php | private function getTemplate(string $key, string $rule): string
{
$keyrule = implode('.', [$key, $rule]);
if (array_key_exists($keyrule, $this->templates)) {
return $this->templates[$keyrule];
}
if (array_key_exists($rule, $this->templates)) {
return $this->templates[$rule];
}
if (array_key_exists(self::DEFAULT_TEMPLATE_KEY, $this->templates)) {
return $this->templates[self::DEFAULT_TEMPLATE_KEY];
}
return self::FALLBACK_TEMPLATE;
} | [
"private",
"function",
"getTemplate",
"(",
"string",
"$",
"key",
",",
"string",
"$",
"rule",
")",
":",
"string",
"{",
"$",
"keyrule",
"=",
"implode",
"(",
"'.'",
",",
"[",
"$",
"key",
",",
"$",
"rule",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keyrule",
",",
"$",
"this",
"->",
"templates",
")",
")",
"{",
"return",
"$",
"this",
"->",
"templates",
"[",
"$",
"keyrule",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"rule",
",",
"$",
"this",
"->",
"templates",
")",
")",
"{",
"return",
"$",
"this",
"->",
"templates",
"[",
"$",
"rule",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"DEFAULT_TEMPLATE_KEY",
",",
"$",
"this",
"->",
"templates",
")",
")",
"{",
"return",
"$",
"this",
"->",
"templates",
"[",
"self",
"::",
"DEFAULT_TEMPLATE_KEY",
"]",
";",
"}",
"return",
"self",
"::",
"FALLBACK_TEMPLATE",
";",
"}"
] | Return a template from a rule key and a rule name. First look for a
'key.rule' template, then for a 'rule' template,then for a 'default'
template and finally return the fallback template when none was found.
@param string $key
@param string $rule
@return string | [
"Return",
"a",
"template",
"from",
"a",
"rule",
"key",
"and",
"a",
"rule",
"name",
".",
"First",
"look",
"for",
"a",
"key",
".",
"rule",
"template",
"then",
"for",
"a",
"rule",
"template",
"then",
"for",
"a",
"default",
"template",
"and",
"finally",
"return",
"the",
"fallback",
"template",
"when",
"none",
"was",
"found",
"."
] | 5a7e11807099165ff6217bf8c38df4b21d99599d | https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/Translator.php#L116-L139 |
11,295 | ellipsephp/validation | src/Translator.php | Translator.translate | private function translate(string $template, array $parameters): string
{
$placeholders = array_map([$this, 'getPlaceholder'], array_keys($parameters));
$replacements = array_map([$this, 'getTranslatedValue'], array_values($parameters));
return str_replace($placeholders, $replacements, $template);
} | php | private function translate(string $template, array $parameters): string
{
$placeholders = array_map([$this, 'getPlaceholder'], array_keys($parameters));
$replacements = array_map([$this, 'getTranslatedValue'], array_values($parameters));
return str_replace($placeholders, $replacements, $template);
} | [
"private",
"function",
"translate",
"(",
"string",
"$",
"template",
",",
"array",
"$",
"parameters",
")",
":",
"string",
"{",
"$",
"placeholders",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'getPlaceholder'",
"]",
",",
"array_keys",
"(",
"$",
"parameters",
")",
")",
";",
"$",
"replacements",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'getTranslatedValue'",
"]",
",",
"array_values",
"(",
"$",
"parameters",
")",
")",
";",
"return",
"str_replace",
"(",
"$",
"placeholders",
",",
"$",
"replacements",
",",
"$",
"template",
")",
";",
"}"
] | Return a template with placeholders replaced by translated parameters
values.
@param string $template
@param array $parameters
@return string | [
"Return",
"a",
"template",
"with",
"placeholders",
"replaced",
"by",
"translated",
"parameters",
"values",
"."
] | 5a7e11807099165ff6217bf8c38df4b21d99599d | https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/Translator.php#L149-L155 |
11,296 | try-php/predict-is | src/PredictIsTrait.php | PredictIsTrait.is | public function is($actual, $expected)
{
if (!is_scalar($actual) || !is_scalar($expected)) {
throw new \Exception("'try/predict-is' can only compare scalar values. 'try/predict' for complex predictions.");
}
if ($actual !== $expected) {
throw new \Exception("Expected '$expected', but got '$actual'.");
}
} | php | public function is($actual, $expected)
{
if (!is_scalar($actual) || !is_scalar($expected)) {
throw new \Exception("'try/predict-is' can only compare scalar values. 'try/predict' for complex predictions.");
}
if ($actual !== $expected) {
throw new \Exception("Expected '$expected', but got '$actual'.");
}
} | [
"public",
"function",
"is",
"(",
"$",
"actual",
",",
"$",
"expected",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"actual",
")",
"||",
"!",
"is_scalar",
"(",
"$",
"expected",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"'try/predict-is' can only compare scalar values. 'try/predict' for complex predictions.\"",
")",
";",
"}",
"if",
"(",
"$",
"actual",
"!==",
"$",
"expected",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Expected '$expected', but got '$actual'.\"",
")",
";",
"}",
"}"
] | Method to test scalar values if they equal one another
@param mixed $actual
@param mixed $expected
@throws \Exception | [
"Method",
"to",
"test",
"scalar",
"values",
"if",
"they",
"equal",
"one",
"another"
] | 2c2b0652712b2a62afb8a282b6d90a48493de96d | https://github.com/try-php/predict-is/blob/2c2b0652712b2a62afb8a282b6d90a48493de96d/src/PredictIsTrait.php#L12-L21 |
11,297 | FrenzelGmbH/appcommon | commands/SeedController.php | SeedController.actionSeed | public function actionSeed()
{
$tx = $this->db->beginTransaction();
try
{
$this->seed();
$tx->commit();
}
catch (Exception $e)
{
throw new Exception($e->getMessage());
$tx->rollback();
}
} | php | public function actionSeed()
{
$tx = $this->db->beginTransaction();
try
{
$this->seed();
$tx->commit();
}
catch (Exception $e)
{
throw new Exception($e->getMessage());
$tx->rollback();
}
} | [
"public",
"function",
"actionSeed",
"(",
")",
"{",
"$",
"tx",
"=",
"$",
"this",
"->",
"db",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"seed",
"(",
")",
";",
"$",
"tx",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"tx",
"->",
"rollback",
"(",
")",
";",
"}",
"}"
] | This command is used when typing yiic seed. Demo data should be created here | [
"This",
"command",
"is",
"used",
"when",
"typing",
"yiic",
"seed",
".",
"Demo",
"data",
"should",
"be",
"created",
"here"
] | d6d137b4c92b53832ce4b2e517644ed9fb545b7a | https://github.com/FrenzelGmbH/appcommon/blob/d6d137b4c92b53832ce4b2e517644ed9fb545b7a/commands/SeedController.php#L65-L78 |
11,298 | FiveLab/Resource | src/Serializer/Context/MutableSerializationContext.php | MutableSerializationContext.set | public function set(string $key, $value): MutableSerializationContext
{
$cloned = clone $this;
$cloned->payload[$key] = $value;
return $cloned;
} | php | public function set(string $key, $value): MutableSerializationContext
{
$cloned = clone $this;
$cloned->payload[$key] = $value;
return $cloned;
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"MutableSerializationContext",
"{",
"$",
"cloned",
"=",
"clone",
"$",
"this",
";",
"$",
"cloned",
"->",
"payload",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"cloned",
";",
"}"
] | Set the new key-value to context
@param string $key
@param mixed $value
@return MutableSerializationContext | [
"Set",
"the",
"new",
"key",
"-",
"value",
"to",
"context"
] | f2864924212dd4e2d1a3e7a1ad8a863d9db26127 | https://github.com/FiveLab/Resource/blob/f2864924212dd4e2d1a3e7a1ad8a863d9db26127/src/Serializer/Context/MutableSerializationContext.php#L31-L38 |
11,299 | FiveLab/Resource | src/Serializer/Context/MutableSerializationContext.php | MutableSerializationContext.merge | public function merge(ResourceSerializationContext $context): MutableSerializationContext
{
$cloned = clone $this;
$cloned->payload = array_merge($cloned->payload, $context->payload);
return $cloned;
} | php | public function merge(ResourceSerializationContext $context): MutableSerializationContext
{
$cloned = clone $this;
$cloned->payload = array_merge($cloned->payload, $context->payload);
return $cloned;
} | [
"public",
"function",
"merge",
"(",
"ResourceSerializationContext",
"$",
"context",
")",
":",
"MutableSerializationContext",
"{",
"$",
"cloned",
"=",
"clone",
"$",
"this",
";",
"$",
"cloned",
"->",
"payload",
"=",
"array_merge",
"(",
"$",
"cloned",
"->",
"payload",
",",
"$",
"context",
"->",
"payload",
")",
";",
"return",
"$",
"cloned",
";",
"}"
] | Merge serialization context
@param ResourceSerializationContext $context
@return MutableSerializationContext | [
"Merge",
"serialization",
"context"
] | f2864924212dd4e2d1a3e7a1ad8a863d9db26127 | https://github.com/FiveLab/Resource/blob/f2864924212dd4e2d1a3e7a1ad8a863d9db26127/src/Serializer/Context/MutableSerializationContext.php#L47-L54 |
Subsets and Splits