id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
21,900
|
giftcards/Encryption
|
CipherText/Rotator/Store/StoreRegistryBuilder.php
|
StoreRegistryBuilder.addStoreToBuildQueue
|
private function addStoreToBuildQueue($storeName, $builderName, array $options)
{
if (!$this->factory->getRegistry()->has($builderName)) {
throw new \DomainException(sprintf("Unknown builder: %s", $builderName));
}
$this->buildQueue[$storeName] = array($builderName, $options);
return $this;
}
|
php
|
private function addStoreToBuildQueue($storeName, $builderName, array $options)
{
if (!$this->factory->getRegistry()->has($builderName)) {
throw new \DomainException(sprintf("Unknown builder: %s", $builderName));
}
$this->buildQueue[$storeName] = array($builderName, $options);
return $this;
}
|
[
"private",
"function",
"addStoreToBuildQueue",
"(",
"$",
"storeName",
",",
"$",
"builderName",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"factory",
"->",
"getRegistry",
"(",
")",
"->",
"has",
"(",
"$",
"builderName",
")",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"sprintf",
"(",
"\"Unknown builder: %s\"",
",",
"$",
"builderName",
")",
")",
";",
"}",
"$",
"this",
"->",
"buildQueue",
"[",
"$",
"storeName",
"]",
"=",
"array",
"(",
"$",
"builderName",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Queues a store to be built
@param string $storeName
@param $builderName
@param array $options
@return StoreRegistryBuilder
|
[
"Queues",
"a",
"store",
"to",
"be",
"built"
] |
a48f92408538e2ffe1c8603f168d57803aad7100
|
https://github.com/giftcards/Encryption/blob/a48f92408538e2ffe1c8603f168d57803aad7100/CipherText/Rotator/Store/StoreRegistryBuilder.php#L90-L97
|
21,901
|
j-d/draggy
|
src/Draggy/Loader.php
|
Loader.getProjectProperties
|
private function getProjectProperties()
{
$r = '';
$projectOptions = (array)$this->xml->xpath('/draggy/project');
$projectOptions = (array)$projectOptions[0];
$this->checkMandatoryAttributes('Project', $projectOptions, ['language', 'description', 'orm', 'framework']);
$r .= 'Draggy.prototype.setLanguage(\'' . $projectOptions['language'] . '\');' . PHP_EOL;
$r .= 'Draggy.prototype.setDescription(\'' . str_replace('\'', '\\\'', $projectOptions['description']) . '\');' . PHP_EOL;
$r .= 'Draggy.prototype.setORM(\'' . $projectOptions['orm'] . '\');' . PHP_EOL;
$r .= 'Draggy.prototype.setFramework(\'' . $projectOptions['framework'] . '\');' . PHP_EOL;
$r .= 'Draggy.prototype.updateConfiguration();' . PHP_EOL;
return $r;
}
|
php
|
private function getProjectProperties()
{
$r = '';
$projectOptions = (array)$this->xml->xpath('/draggy/project');
$projectOptions = (array)$projectOptions[0];
$this->checkMandatoryAttributes('Project', $projectOptions, ['language', 'description', 'orm', 'framework']);
$r .= 'Draggy.prototype.setLanguage(\'' . $projectOptions['language'] . '\');' . PHP_EOL;
$r .= 'Draggy.prototype.setDescription(\'' . str_replace('\'', '\\\'', $projectOptions['description']) . '\');' . PHP_EOL;
$r .= 'Draggy.prototype.setORM(\'' . $projectOptions['orm'] . '\');' . PHP_EOL;
$r .= 'Draggy.prototype.setFramework(\'' . $projectOptions['framework'] . '\');' . PHP_EOL;
$r .= 'Draggy.prototype.updateConfiguration();' . PHP_EOL;
return $r;
}
|
[
"private",
"function",
"getProjectProperties",
"(",
")",
"{",
"$",
"r",
"=",
"''",
";",
"$",
"projectOptions",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"xml",
"->",
"xpath",
"(",
"'/draggy/project'",
")",
";",
"$",
"projectOptions",
"=",
"(",
"array",
")",
"$",
"projectOptions",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"checkMandatoryAttributes",
"(",
"'Project'",
",",
"$",
"projectOptions",
",",
"[",
"'language'",
",",
"'description'",
",",
"'orm'",
",",
"'framework'",
"]",
")",
";",
"$",
"r",
".=",
"'Draggy.prototype.setLanguage(\\''",
".",
"$",
"projectOptions",
"[",
"'language'",
"]",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"'Draggy.prototype.setDescription(\\''",
".",
"str_replace",
"(",
"'\\''",
",",
"'\\\\\\''",
",",
"$",
"projectOptions",
"[",
"'description'",
"]",
")",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"'Draggy.prototype.setORM(\\''",
".",
"$",
"projectOptions",
"[",
"'orm'",
"]",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"'Draggy.prototype.setFramework(\\''",
".",
"$",
"projectOptions",
"[",
"'framework'",
"]",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"'Draggy.prototype.updateConfiguration();'",
".",
"PHP_EOL",
";",
"return",
"$",
"r",
";",
"}"
] |
Get the project properties from the saved file
@return string
|
[
"Get",
"the",
"project",
"properties",
"from",
"the",
"saved",
"file"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L91-L107
|
21,902
|
j-d/draggy
|
src/Draggy/Loader.php
|
Loader.getAutocodeProperties
|
private function getAutocodeProperties()
{
$r = '';
$autocode = (array)$this->xml->xpath('/draggy/autocode');
$autocode = (array)$autocode[0];
$autocodeProperties = (array)$autocode['properties'];
$autocodeConfigurations = (array)$autocode['configurations'];
$autocodeTemplates = (array)$autocode['templates'];
foreach ($autocodeProperties as $propertyName => $propertyValue) {
$r .= 'Autocode.prototype.setProperty(\'' . $propertyName . '\', true === ' . $propertyValue . ');' . PHP_EOL;
}
foreach ($autocodeConfigurations as $configurationName => $configurationValue) {
$r .= 'Autocode.prototype.setConfiguration(\'' . $configurationName . '\', \'' . str_replace('\\', '\\\\', $configurationValue) . '\');' . PHP_EOL;
}
foreach ($autocodeTemplates as $templateName => $templateValue) {
$r .= 'Autocode.prototype.setTemplate(\'' . $templateName . '\', "' . str_replace('\\', '\\\\', $templateValue) . '");' . PHP_EOL;
}
return $r;
}
|
php
|
private function getAutocodeProperties()
{
$r = '';
$autocode = (array)$this->xml->xpath('/draggy/autocode');
$autocode = (array)$autocode[0];
$autocodeProperties = (array)$autocode['properties'];
$autocodeConfigurations = (array)$autocode['configurations'];
$autocodeTemplates = (array)$autocode['templates'];
foreach ($autocodeProperties as $propertyName => $propertyValue) {
$r .= 'Autocode.prototype.setProperty(\'' . $propertyName . '\', true === ' . $propertyValue . ');' . PHP_EOL;
}
foreach ($autocodeConfigurations as $configurationName => $configurationValue) {
$r .= 'Autocode.prototype.setConfiguration(\'' . $configurationName . '\', \'' . str_replace('\\', '\\\\', $configurationValue) . '\');' . PHP_EOL;
}
foreach ($autocodeTemplates as $templateName => $templateValue) {
$r .= 'Autocode.prototype.setTemplate(\'' . $templateName . '\', "' . str_replace('\\', '\\\\', $templateValue) . '");' . PHP_EOL;
}
return $r;
}
|
[
"private",
"function",
"getAutocodeProperties",
"(",
")",
"{",
"$",
"r",
"=",
"''",
";",
"$",
"autocode",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"xml",
"->",
"xpath",
"(",
"'/draggy/autocode'",
")",
";",
"$",
"autocode",
"=",
"(",
"array",
")",
"$",
"autocode",
"[",
"0",
"]",
";",
"$",
"autocodeProperties",
"=",
"(",
"array",
")",
"$",
"autocode",
"[",
"'properties'",
"]",
";",
"$",
"autocodeConfigurations",
"=",
"(",
"array",
")",
"$",
"autocode",
"[",
"'configurations'",
"]",
";",
"$",
"autocodeTemplates",
"=",
"(",
"array",
")",
"$",
"autocode",
"[",
"'templates'",
"]",
";",
"foreach",
"(",
"$",
"autocodeProperties",
"as",
"$",
"propertyName",
"=>",
"$",
"propertyValue",
")",
"{",
"$",
"r",
".=",
"'Autocode.prototype.setProperty(\\''",
".",
"$",
"propertyName",
".",
"'\\', true === '",
".",
"$",
"propertyValue",
".",
"');'",
".",
"PHP_EOL",
";",
"}",
"foreach",
"(",
"$",
"autocodeConfigurations",
"as",
"$",
"configurationName",
"=>",
"$",
"configurationValue",
")",
"{",
"$",
"r",
".=",
"'Autocode.prototype.setConfiguration(\\''",
".",
"$",
"configurationName",
".",
"'\\', \\''",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
",",
"$",
"configurationValue",
")",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"}",
"foreach",
"(",
"$",
"autocodeTemplates",
"as",
"$",
"templateName",
"=>",
"$",
"templateValue",
")",
"{",
"$",
"r",
".=",
"'Autocode.prototype.setTemplate(\\''",
".",
"$",
"templateName",
".",
"'\\', \"'",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
",",
"$",
"templateValue",
")",
".",
"'\");'",
".",
"PHP_EOL",
";",
"}",
"return",
"$",
"r",
";",
"}"
] |
Get the project autocode properties from the saved file
@return string
|
[
"Get",
"the",
"project",
"autocode",
"properties",
"from",
"the",
"saved",
"file"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L114-L138
|
21,903
|
j-d/draggy
|
src/Draggy/Loader.php
|
Loader.getModules
|
private function getModules()
{
$modules = (array)$this->xml->xpath('/draggy/module');
$r = '';
foreach ($modules as $module) {
$moduleAttributes = (array)$module;
$moduleAttributes = (array)$moduleAttributes['@attributes'];
$this->checkMandatoryAttributes('Modules', $moduleAttributes, ['name', 'left', 'top', 'width', 'height']);
$moduleName = $moduleAttributes['name'];
$r .= 'var o = new Container(\'' . str_replace('\\', '\\\\', $moduleName) . '\');' . PHP_EOL;
$r .= 'o.moveTo(\'' . ( $moduleAttributes['left'] - 1 ) . 'px\',\'' . ( $moduleAttributes['top'] - 1 ) . 'px\',\'' . $moduleAttributes['width'] . 'px\',\'' . $moduleAttributes['height'] . 'px\')' . PHP_EOL;
$this->modules[] = $moduleName;
$this->insideClasses[$moduleName] = [];
$this->insideAbstracts[$moduleName] = [];
}
return $r;
}
|
php
|
private function getModules()
{
$modules = (array)$this->xml->xpath('/draggy/module');
$r = '';
foreach ($modules as $module) {
$moduleAttributes = (array)$module;
$moduleAttributes = (array)$moduleAttributes['@attributes'];
$this->checkMandatoryAttributes('Modules', $moduleAttributes, ['name', 'left', 'top', 'width', 'height']);
$moduleName = $moduleAttributes['name'];
$r .= 'var o = new Container(\'' . str_replace('\\', '\\\\', $moduleName) . '\');' . PHP_EOL;
$r .= 'o.moveTo(\'' . ( $moduleAttributes['left'] - 1 ) . 'px\',\'' . ( $moduleAttributes['top'] - 1 ) . 'px\',\'' . $moduleAttributes['width'] . 'px\',\'' . $moduleAttributes['height'] . 'px\')' . PHP_EOL;
$this->modules[] = $moduleName;
$this->insideClasses[$moduleName] = [];
$this->insideAbstracts[$moduleName] = [];
}
return $r;
}
|
[
"private",
"function",
"getModules",
"(",
")",
"{",
"$",
"modules",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"xml",
"->",
"xpath",
"(",
"'/draggy/module'",
")",
";",
"$",
"r",
"=",
"''",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"moduleAttributes",
"=",
"(",
"array",
")",
"$",
"module",
";",
"$",
"moduleAttributes",
"=",
"(",
"array",
")",
"$",
"moduleAttributes",
"[",
"'@attributes'",
"]",
";",
"$",
"this",
"->",
"checkMandatoryAttributes",
"(",
"'Modules'",
",",
"$",
"moduleAttributes",
",",
"[",
"'name'",
",",
"'left'",
",",
"'top'",
",",
"'width'",
",",
"'height'",
"]",
")",
";",
"$",
"moduleName",
"=",
"$",
"moduleAttributes",
"[",
"'name'",
"]",
";",
"$",
"r",
".=",
"'var o = new Container(\\''",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
",",
"$",
"moduleName",
")",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"'o.moveTo(\\''",
".",
"(",
"$",
"moduleAttributes",
"[",
"'left'",
"]",
"-",
"1",
")",
".",
"'px\\',\\''",
".",
"(",
"$",
"moduleAttributes",
"[",
"'top'",
"]",
"-",
"1",
")",
".",
"'px\\',\\''",
".",
"$",
"moduleAttributes",
"[",
"'width'",
"]",
".",
"'px\\',\\''",
".",
"$",
"moduleAttributes",
"[",
"'height'",
"]",
".",
"'px\\')'",
".",
"PHP_EOL",
";",
"$",
"this",
"->",
"modules",
"[",
"]",
"=",
"$",
"moduleName",
";",
"$",
"this",
"->",
"insideClasses",
"[",
"$",
"moduleName",
"]",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"insideAbstracts",
"[",
"$",
"moduleName",
"]",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"r",
";",
"}"
] |
Get the project modules
@return string
|
[
"Get",
"the",
"project",
"modules"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L145-L168
|
21,904
|
j-d/draggy
|
src/Draggy/Loader.php
|
Loader.getInterfaces
|
private function getInterfaces()
{
$r = '';
// Inside interfaces
foreach ($this->modules as $module) {
$interfaces = (array)$this->xml->xpath('/draggy/module[@name=\'' . $module . '\']/interface');
foreach ($interfaces as $interface) {
$interfaceAttributes = (array)$interface;
$interfaceAttributes = $interfaceAttributes['@attributes'];
$this->checkMandatoryAttributes('Interface in module ' . $module, $interfaceAttributes, ['name']);
$className = $interfaceAttributes['name'];
$this->checkMandatoryAttributes(
'Interface ' . $className . ' in module ' . $module,
$interfaceAttributes,
['left', 'top']
);
$r .= 'var i = new Interface(\'' . $interfaceAttributes['name'] . '\',\'' . str_replace(
'\\',
'\\\\',
$module
) . '\');' . PHP_EOL;
$r .= 'i.moveTo(\'' . ( $interfaceAttributes['left'] /*- 1*/ ) . 'px\',\'' . ( $interfaceAttributes['top'] /*- 1*/ ) . 'px\');' . PHP_EOL;
$r .= $this->getInterfaceProperties($interfaceAttributes, 'i');
$r .= 'i.setModule(Container.prototype.getContainerByName(\'' . str_replace(
'\\',
'\\\\',
$module
) . '\').getId());' . PHP_EOL;
}
}
// Outside interfaces
$interfaces = (array)$this->xml->xpath('/draggy/loose/interface');
foreach ($interfaces as $interface) {
$interfaceAttributes = (array)$interface;
$interfaceAttributes = $interfaceAttributes['@attributes'];
$this->checkMandatoryAttributes('Loose interface', $interfaceAttributes, ['name']);
$className = $interfaceAttributes['name'];
$this->checkMandatoryAttributes('Loose interface ' . $className, $interfaceAttributes, ['left', 'top']);
$r .= 'var i = new Interface(\'' . $className . '\');' . PHP_EOL;
$r .= 'i.moveTo(\'' . ( $interfaceAttributes['left'] ) . 'px\',\'' . ( $interfaceAttributes['top'] ) . 'px\');' . PHP_EOL;
$r .= $this->getInterfaceProperties($interfaceAttributes, 'i');
}
return $r;
}
|
php
|
private function getInterfaces()
{
$r = '';
// Inside interfaces
foreach ($this->modules as $module) {
$interfaces = (array)$this->xml->xpath('/draggy/module[@name=\'' . $module . '\']/interface');
foreach ($interfaces as $interface) {
$interfaceAttributes = (array)$interface;
$interfaceAttributes = $interfaceAttributes['@attributes'];
$this->checkMandatoryAttributes('Interface in module ' . $module, $interfaceAttributes, ['name']);
$className = $interfaceAttributes['name'];
$this->checkMandatoryAttributes(
'Interface ' . $className . ' in module ' . $module,
$interfaceAttributes,
['left', 'top']
);
$r .= 'var i = new Interface(\'' . $interfaceAttributes['name'] . '\',\'' . str_replace(
'\\',
'\\\\',
$module
) . '\');' . PHP_EOL;
$r .= 'i.moveTo(\'' . ( $interfaceAttributes['left'] /*- 1*/ ) . 'px\',\'' . ( $interfaceAttributes['top'] /*- 1*/ ) . 'px\');' . PHP_EOL;
$r .= $this->getInterfaceProperties($interfaceAttributes, 'i');
$r .= 'i.setModule(Container.prototype.getContainerByName(\'' . str_replace(
'\\',
'\\\\',
$module
) . '\').getId());' . PHP_EOL;
}
}
// Outside interfaces
$interfaces = (array)$this->xml->xpath('/draggy/loose/interface');
foreach ($interfaces as $interface) {
$interfaceAttributes = (array)$interface;
$interfaceAttributes = $interfaceAttributes['@attributes'];
$this->checkMandatoryAttributes('Loose interface', $interfaceAttributes, ['name']);
$className = $interfaceAttributes['name'];
$this->checkMandatoryAttributes('Loose interface ' . $className, $interfaceAttributes, ['left', 'top']);
$r .= 'var i = new Interface(\'' . $className . '\');' . PHP_EOL;
$r .= 'i.moveTo(\'' . ( $interfaceAttributes['left'] ) . 'px\',\'' . ( $interfaceAttributes['top'] ) . 'px\');' . PHP_EOL;
$r .= $this->getInterfaceProperties($interfaceAttributes, 'i');
}
return $r;
}
|
[
"private",
"function",
"getInterfaces",
"(",
")",
"{",
"$",
"r",
"=",
"''",
";",
"// Inside interfaces",
"foreach",
"(",
"$",
"this",
"->",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"interfaces",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"xml",
"->",
"xpath",
"(",
"'/draggy/module[@name=\\''",
".",
"$",
"module",
".",
"'\\']/interface'",
")",
";",
"foreach",
"(",
"$",
"interfaces",
"as",
"$",
"interface",
")",
"{",
"$",
"interfaceAttributes",
"=",
"(",
"array",
")",
"$",
"interface",
";",
"$",
"interfaceAttributes",
"=",
"$",
"interfaceAttributes",
"[",
"'@attributes'",
"]",
";",
"$",
"this",
"->",
"checkMandatoryAttributes",
"(",
"'Interface in module '",
".",
"$",
"module",
",",
"$",
"interfaceAttributes",
",",
"[",
"'name'",
"]",
")",
";",
"$",
"className",
"=",
"$",
"interfaceAttributes",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"checkMandatoryAttributes",
"(",
"'Interface '",
".",
"$",
"className",
".",
"' in module '",
".",
"$",
"module",
",",
"$",
"interfaceAttributes",
",",
"[",
"'left'",
",",
"'top'",
"]",
")",
";",
"$",
"r",
".=",
"'var i = new Interface(\\''",
".",
"$",
"interfaceAttributes",
"[",
"'name'",
"]",
".",
"'\\',\\''",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
",",
"$",
"module",
")",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"'i.moveTo(\\''",
".",
"(",
"$",
"interfaceAttributes",
"[",
"'left'",
"]",
"/*- 1*/",
")",
".",
"'px\\',\\''",
".",
"(",
"$",
"interfaceAttributes",
"[",
"'top'",
"]",
"/*- 1*/",
")",
".",
"'px\\');'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"$",
"this",
"->",
"getInterfaceProperties",
"(",
"$",
"interfaceAttributes",
",",
"'i'",
")",
";",
"$",
"r",
".=",
"'i.setModule(Container.prototype.getContainerByName(\\''",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
",",
"$",
"module",
")",
".",
"'\\').getId());'",
".",
"PHP_EOL",
";",
"}",
"}",
"// Outside interfaces",
"$",
"interfaces",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"xml",
"->",
"xpath",
"(",
"'/draggy/loose/interface'",
")",
";",
"foreach",
"(",
"$",
"interfaces",
"as",
"$",
"interface",
")",
"{",
"$",
"interfaceAttributes",
"=",
"(",
"array",
")",
"$",
"interface",
";",
"$",
"interfaceAttributes",
"=",
"$",
"interfaceAttributes",
"[",
"'@attributes'",
"]",
";",
"$",
"this",
"->",
"checkMandatoryAttributes",
"(",
"'Loose interface'",
",",
"$",
"interfaceAttributes",
",",
"[",
"'name'",
"]",
")",
";",
"$",
"className",
"=",
"$",
"interfaceAttributes",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"checkMandatoryAttributes",
"(",
"'Loose interface '",
".",
"$",
"className",
",",
"$",
"interfaceAttributes",
",",
"[",
"'left'",
",",
"'top'",
"]",
")",
";",
"$",
"r",
".=",
"'var i = new Interface(\\''",
".",
"$",
"className",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"'i.moveTo(\\''",
".",
"(",
"$",
"interfaceAttributes",
"[",
"'left'",
"]",
")",
".",
"'px\\',\\''",
".",
"(",
"$",
"interfaceAttributes",
"[",
"'top'",
"]",
")",
".",
"'px\\');'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"$",
"this",
"->",
"getInterfaceProperties",
"(",
"$",
"interfaceAttributes",
",",
"'i'",
")",
";",
"}",
"return",
"$",
"r",
";",
"}"
] |
Get the project interfaces
@return string
|
[
"Get",
"the",
"project",
"interfaces"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L381-L440
|
21,905
|
j-d/draggy
|
src/Draggy/Loader.php
|
Loader.getLoaderJS
|
public function getLoaderJS()
{
if ($this->newFile) {
return '';
}
$r = '';
$r .= $this->getProjectProperties();
// FIRST STEP: Load all modules and entities
$r .= $this->getModules();
$r .= $this->getClasses();
$r .= $this->getAbstracts();
$r .= $this->getInterfaces();
// SECOND STEP: Add the attributes
$r .= $this->getAttributes();
// THIRD STEP: After attributes entity properties
$r .= $this->getClassLikeAfterAttributesProperties();
// FOURTH STEP: Relationships
$r .= $this->getRelationships();
$r .= $this->getAutocodeProperties();
// Finalise
$r .= 'for (var i in Connectable.prototype.connectables) Connectable.prototype.connectables[i].reDraw();' . PHP_EOL;
$r .= 'Link.prototype.reDrawLinks();' . PHP_EOL;
$r .= 'System.prototype.runtime = true;' . PHP_EOL;
return $r;
}
|
php
|
public function getLoaderJS()
{
if ($this->newFile) {
return '';
}
$r = '';
$r .= $this->getProjectProperties();
// FIRST STEP: Load all modules and entities
$r .= $this->getModules();
$r .= $this->getClasses();
$r .= $this->getAbstracts();
$r .= $this->getInterfaces();
// SECOND STEP: Add the attributes
$r .= $this->getAttributes();
// THIRD STEP: After attributes entity properties
$r .= $this->getClassLikeAfterAttributesProperties();
// FOURTH STEP: Relationships
$r .= $this->getRelationships();
$r .= $this->getAutocodeProperties();
// Finalise
$r .= 'for (var i in Connectable.prototype.connectables) Connectable.prototype.connectables[i].reDraw();' . PHP_EOL;
$r .= 'Link.prototype.reDrawLinks();' . PHP_EOL;
$r .= 'System.prototype.runtime = true;' . PHP_EOL;
return $r;
}
|
[
"public",
"function",
"getLoaderJS",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"newFile",
")",
"{",
"return",
"''",
";",
"}",
"$",
"r",
"=",
"''",
";",
"$",
"r",
".=",
"$",
"this",
"->",
"getProjectProperties",
"(",
")",
";",
"// FIRST STEP: Load all modules and entities",
"$",
"r",
".=",
"$",
"this",
"->",
"getModules",
"(",
")",
";",
"$",
"r",
".=",
"$",
"this",
"->",
"getClasses",
"(",
")",
";",
"$",
"r",
".=",
"$",
"this",
"->",
"getAbstracts",
"(",
")",
";",
"$",
"r",
".=",
"$",
"this",
"->",
"getInterfaces",
"(",
")",
";",
"// SECOND STEP: Add the attributes",
"$",
"r",
".=",
"$",
"this",
"->",
"getAttributes",
"(",
")",
";",
"// THIRD STEP: After attributes entity properties",
"$",
"r",
".=",
"$",
"this",
"->",
"getClassLikeAfterAttributesProperties",
"(",
")",
";",
"// FOURTH STEP: Relationships",
"$",
"r",
".=",
"$",
"this",
"->",
"getRelationships",
"(",
")",
";",
"$",
"r",
".=",
"$",
"this",
"->",
"getAutocodeProperties",
"(",
")",
";",
"// Finalise",
"$",
"r",
".=",
"'for (var i in Connectable.prototype.connectables) Connectable.prototype.connectables[i].reDraw();'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"'Link.prototype.reDrawLinks();'",
".",
"PHP_EOL",
";",
"$",
"r",
".=",
"'System.prototype.runtime = true;'",
".",
"PHP_EOL",
";",
"return",
"$",
"r",
";",
"}"
] |
Returns all the JS code to load the project
@return string
|
[
"Returns",
"all",
"the",
"JS",
"code",
"to",
"load",
"the",
"project"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L756-L789
|
21,906
|
surebert/surebert-framework
|
src/sb/Excel/Reader.php
|
Reader.toArray
|
public function toArray($sheet = 0)
{
$arr = array();
for ($row = 1; $row <= $this->rowcount($sheet); $row++) {
for ($col = 1; $col <= $this->colcount($sheet); $col++) {
$arr[$row][$col] = $this->val($row, $col, $sheet);
}
}
return $arr;
}
|
php
|
public function toArray($sheet = 0)
{
$arr = array();
for ($row = 1; $row <= $this->rowcount($sheet); $row++) {
for ($col = 1; $col <= $this->colcount($sheet); $col++) {
$arr[$row][$col] = $this->val($row, $col, $sheet);
}
}
return $arr;
}
|
[
"public",
"function",
"toArray",
"(",
"$",
"sheet",
"=",
"0",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"row",
"=",
"1",
";",
"$",
"row",
"<=",
"$",
"this",
"->",
"rowcount",
"(",
"$",
"sheet",
")",
";",
"$",
"row",
"++",
")",
"{",
"for",
"(",
"$",
"col",
"=",
"1",
";",
"$",
"col",
"<=",
"$",
"this",
"->",
"colcount",
"(",
"$",
"sheet",
")",
";",
"$",
"col",
"++",
")",
"{",
"$",
"arr",
"[",
"$",
"row",
"]",
"[",
"$",
"col",
"]",
"=",
"$",
"this",
"->",
"val",
"(",
"$",
"row",
",",
"$",
"col",
",",
"$",
"sheet",
")",
";",
"}",
"}",
"return",
"$",
"arr",
";",
"}"
] |
export to multi dimensional array
@param integer $sheet
@return array
|
[
"export",
"to",
"multi",
"dimensional",
"array"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Reader.php#L86-L96
|
21,907
|
surebert/surebert-framework
|
src/sb/Excel/Reader.php
|
Reader.info
|
public function info($row, $col, $type = '', $sheet = 0)
{
$col = $this->getCol($col);
if (array_key_exists('cellsInfo', $this->sheets[$sheet])
&& array_key_exists($row, $this->sheets[$sheet]['cellsInfo'])
&& array_key_exists($col, $this->sheets[$sheet]['cellsInfo'][$row])
&& array_key_exists($type, $this->sheets[$sheet]['cellsInfo'][$row][$col])) {
return $this->sheets[$sheet]['cellsInfo'][$row][$col][$type];
}
return "";
}
|
php
|
public function info($row, $col, $type = '', $sheet = 0)
{
$col = $this->getCol($col);
if (array_key_exists('cellsInfo', $this->sheets[$sheet])
&& array_key_exists($row, $this->sheets[$sheet]['cellsInfo'])
&& array_key_exists($col, $this->sheets[$sheet]['cellsInfo'][$row])
&& array_key_exists($type, $this->sheets[$sheet]['cellsInfo'][$row][$col])) {
return $this->sheets[$sheet]['cellsInfo'][$row][$col][$type];
}
return "";
}
|
[
"public",
"function",
"info",
"(",
"$",
"row",
",",
"$",
"col",
",",
"$",
"type",
"=",
"''",
",",
"$",
"sheet",
"=",
"0",
")",
"{",
"$",
"col",
"=",
"$",
"this",
"->",
"getCol",
"(",
"$",
"col",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'cellsInfo'",
",",
"$",
"this",
"->",
"sheets",
"[",
"$",
"sheet",
"]",
")",
"&&",
"array_key_exists",
"(",
"$",
"row",
",",
"$",
"this",
"->",
"sheets",
"[",
"$",
"sheet",
"]",
"[",
"'cellsInfo'",
"]",
")",
"&&",
"array_key_exists",
"(",
"$",
"col",
",",
"$",
"this",
"->",
"sheets",
"[",
"$",
"sheet",
"]",
"[",
"'cellsInfo'",
"]",
"[",
"$",
"row",
"]",
")",
"&&",
"array_key_exists",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"sheets",
"[",
"$",
"sheet",
"]",
"[",
"'cellsInfo'",
"]",
"[",
"$",
"row",
"]",
"[",
"$",
"col",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sheets",
"[",
"$",
"sheet",
"]",
"[",
"'cellsInfo'",
"]",
"[",
"$",
"row",
"]",
"[",
"$",
"col",
"]",
"[",
"$",
"type",
"]",
";",
"}",
"return",
"\"\"",
";",
"}"
] |
Gets info for a specifc cell of a specific sheet
@param int $row
@param int $col
@param string $type
@param int $sheet
@return string
|
[
"Gets",
"info",
"for",
"a",
"specifc",
"cell",
"of",
"a",
"specific",
"sheet"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Reader.php#L106-L116
|
21,908
|
alevilar/ristorantino-vendor
|
Mesa/Model/Mozo.php
|
Mozo.mesasAbiertas
|
public function mesasAbiertas($mozo_id = null, $lastAccess = null){
$conditions = array();
// si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo
if ( !empty($mozo_id) ){
$conditions['Mozo.id'] = $mozo_id;
} else {
// todos los mozos activos
$conditions['Mozo.activo'] = 1;
}
// condiciones para traer mesas abiertas y pendientes de cobro
if ( Configure::read('Site.type') == SITE_TYPE_HOTEL ) {
// si es hotel
$conditionsMesa = array(
'Mesa.deleted' => 0,
'Mesa.checkin >' => date('Y-m-d', strtotime('-1 month')),
);
} else {
// es restaurante u otros comercios
$conditionsMesa = array(
"Mesa.estado_id" => array( MESA_ABIERTA, MESA_CERRADA, MESA_COBRADA),
'Mesa.deleted' => 0,
);
}
// si vino el parametro lastAccess, traer solo las mesas actualizadas luego del ultimo pedido
if ( !empty($lastAccess) ) {
$conditionsMesa['Mesa.modified >='] = $lastAccess;
}
$contain = $this->Mesa->defaultContain;
$contain['conditions'] = $conditionsMesa;
unset($contain[0]);
$optionsCreated = array(
'contain' => array('Mesa' => $contain),
'conditions'=> $conditions,
);
$mesasABM = $this->find('all', $optionsCreated);
$mozosMesa = array();
foreach ( $mesasABM as $abmMesas ) {
// traer todos los mozos, con su array de mesas
$abmMesas['Mozo']['mesas'] = $abmMesas['Mesa'];
if ( !empty($lastAccess) ) {
// enviar solo los que tienen mesas modificadas
if (!empty($abmMesas['Mesa']) ) {
$mozosMesa['mozos'][] = $abmMesas['Mozo'];
}
} else {
// enviar a todos
$mozosMesa['mozos'][] = $abmMesas['Mozo'];
}
}
return $mozosMesa;
}
|
php
|
public function mesasAbiertas($mozo_id = null, $lastAccess = null){
$conditions = array();
// si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo
if ( !empty($mozo_id) ){
$conditions['Mozo.id'] = $mozo_id;
} else {
// todos los mozos activos
$conditions['Mozo.activo'] = 1;
}
// condiciones para traer mesas abiertas y pendientes de cobro
if ( Configure::read('Site.type') == SITE_TYPE_HOTEL ) {
// si es hotel
$conditionsMesa = array(
'Mesa.deleted' => 0,
'Mesa.checkin >' => date('Y-m-d', strtotime('-1 month')),
);
} else {
// es restaurante u otros comercios
$conditionsMesa = array(
"Mesa.estado_id" => array( MESA_ABIERTA, MESA_CERRADA, MESA_COBRADA),
'Mesa.deleted' => 0,
);
}
// si vino el parametro lastAccess, traer solo las mesas actualizadas luego del ultimo pedido
if ( !empty($lastAccess) ) {
$conditionsMesa['Mesa.modified >='] = $lastAccess;
}
$contain = $this->Mesa->defaultContain;
$contain['conditions'] = $conditionsMesa;
unset($contain[0]);
$optionsCreated = array(
'contain' => array('Mesa' => $contain),
'conditions'=> $conditions,
);
$mesasABM = $this->find('all', $optionsCreated);
$mozosMesa = array();
foreach ( $mesasABM as $abmMesas ) {
// traer todos los mozos, con su array de mesas
$abmMesas['Mozo']['mesas'] = $abmMesas['Mesa'];
if ( !empty($lastAccess) ) {
// enviar solo los que tienen mesas modificadas
if (!empty($abmMesas['Mesa']) ) {
$mozosMesa['mozos'][] = $abmMesas['Mozo'];
}
} else {
// enviar a todos
$mozosMesa['mozos'][] = $abmMesas['Mozo'];
}
}
return $mozosMesa;
}
|
[
"public",
"function",
"mesasAbiertas",
"(",
"$",
"mozo_id",
"=",
"null",
",",
"$",
"lastAccess",
"=",
"null",
")",
"{",
"$",
"conditions",
"=",
"array",
"(",
")",
";",
"// si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo",
"if",
"(",
"!",
"empty",
"(",
"$",
"mozo_id",
")",
")",
"{",
"$",
"conditions",
"[",
"'Mozo.id'",
"]",
"=",
"$",
"mozo_id",
";",
"}",
"else",
"{",
"// todos los mozos activos",
"$",
"conditions",
"[",
"'Mozo.activo'",
"]",
"=",
"1",
";",
"}",
"// condiciones para traer mesas abiertas y pendientes de cobro",
"if",
"(",
"Configure",
"::",
"read",
"(",
"'Site.type'",
")",
"==",
"SITE_TYPE_HOTEL",
")",
"{",
"// si es hotel",
"$",
"conditionsMesa",
"=",
"array",
"(",
"'Mesa.deleted'",
"=>",
"0",
",",
"'Mesa.checkin >'",
"=>",
"date",
"(",
"'Y-m-d'",
",",
"strtotime",
"(",
"'-1 month'",
")",
")",
",",
")",
";",
"}",
"else",
"{",
"// es restaurante u otros comercios",
"$",
"conditionsMesa",
"=",
"array",
"(",
"\"Mesa.estado_id\"",
"=>",
"array",
"(",
"MESA_ABIERTA",
",",
"MESA_CERRADA",
",",
"MESA_COBRADA",
")",
",",
"'Mesa.deleted'",
"=>",
"0",
",",
")",
";",
"}",
"// si vino el parametro lastAccess, traer solo las mesas actualizadas luego del ultimo pedido",
"if",
"(",
"!",
"empty",
"(",
"$",
"lastAccess",
")",
")",
"{",
"$",
"conditionsMesa",
"[",
"'Mesa.modified >='",
"]",
"=",
"$",
"lastAccess",
";",
"}",
"$",
"contain",
"=",
"$",
"this",
"->",
"Mesa",
"->",
"defaultContain",
";",
"$",
"contain",
"[",
"'conditions'",
"]",
"=",
"$",
"conditionsMesa",
";",
"unset",
"(",
"$",
"contain",
"[",
"0",
"]",
")",
";",
"$",
"optionsCreated",
"=",
"array",
"(",
"'contain'",
"=>",
"array",
"(",
"'Mesa'",
"=>",
"$",
"contain",
")",
",",
"'conditions'",
"=>",
"$",
"conditions",
",",
")",
";",
"$",
"mesasABM",
"=",
"$",
"this",
"->",
"find",
"(",
"'all'",
",",
"$",
"optionsCreated",
")",
";",
"$",
"mozosMesa",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"mesasABM",
"as",
"$",
"abmMesas",
")",
"{",
"// traer todos los mozos, con su array de mesas",
"$",
"abmMesas",
"[",
"'Mozo'",
"]",
"[",
"'mesas'",
"]",
"=",
"$",
"abmMesas",
"[",
"'Mesa'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"lastAccess",
")",
")",
"{",
"// enviar solo los que tienen mesas modificadas",
"if",
"(",
"!",
"empty",
"(",
"$",
"abmMesas",
"[",
"'Mesa'",
"]",
")",
")",
"{",
"$",
"mozosMesa",
"[",
"'mozos'",
"]",
"[",
"]",
"=",
"$",
"abmMesas",
"[",
"'Mozo'",
"]",
";",
"}",
"}",
"else",
"{",
"// enviar a todos",
"$",
"mozosMesa",
"[",
"'mozos'",
"]",
"[",
"]",
"=",
"$",
"abmMesas",
"[",
"'Mozo'",
"]",
";",
"}",
"}",
"return",
"$",
"mozosMesa",
";",
"}"
] |
Para todos los mozos activos, me trae sus mesas abiertas
@param int $mozo_id id del mozo, en caso de que no le pase ninguno, me busca todos
@return array Mozos con sus mesas, Comandas, detalleComanda, productos y sabores
|
[
"Para",
"todos",
"los",
"mozos",
"activos",
"me",
"trae",
"sus",
"mesas",
"abiertas"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Model/Mozo.php#L103-L161
|
21,909
|
alevilar/ristorantino-vendor
|
Mesa/Model/Mozo.php
|
Mozo.mesasBorradas
|
public function mesasBorradas($mozo_id = null, $lastAccess = null){
if ( empty($lastAccess) ) {
return array();
}
$conditions = array();
// si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo
if ( !empty($mozo_id) ){
$conditions['Mozo.id'] = $mozo_id;
} else {
// todos los mozos activos
$conditions['Mozo.activo'] = 1;
}
// traer solo las mesas actualizadas luego del ultimo pedido
$conditionsMesa = array(
'OR' => array (
array(
'Mesa.deleted' => 1,
'Mesa.deleted_date >=' => $lastAccess,
),
array(
'Mesa.estado_id' => MESA_CHECKOUT,
'Mesa.checkout >=' => $lastAccess,
)
)
);
$contain = $this->Mesa->defaultContain;
$contain['conditions'] = $conditionsMesa;
unset($contain[0]); // saco al Mozo del contain
$optionsCreated = array(
'contain' => array('Mesa' => $contain),
'conditions'=> $conditions,
);
$mesasABM = $this->find('all', $optionsCreated);
$mozosMesa = array();
foreach ( $mesasABM as $abmMesas ) {
// traer todos los mozos, con su array de mesas
$abmMesas['Mozo']['mesas'] = $abmMesas['Mesa'];
// enviar solo los que tienen mesas borradas
if (!empty($abmMesas['Mesa']) ) {
$mozosMesa['mozos'][] = $abmMesas['Mozo'];
}
}
return $mozosMesa;
}
|
php
|
public function mesasBorradas($mozo_id = null, $lastAccess = null){
if ( empty($lastAccess) ) {
return array();
}
$conditions = array();
// si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo
if ( !empty($mozo_id) ){
$conditions['Mozo.id'] = $mozo_id;
} else {
// todos los mozos activos
$conditions['Mozo.activo'] = 1;
}
// traer solo las mesas actualizadas luego del ultimo pedido
$conditionsMesa = array(
'OR' => array (
array(
'Mesa.deleted' => 1,
'Mesa.deleted_date >=' => $lastAccess,
),
array(
'Mesa.estado_id' => MESA_CHECKOUT,
'Mesa.checkout >=' => $lastAccess,
)
)
);
$contain = $this->Mesa->defaultContain;
$contain['conditions'] = $conditionsMesa;
unset($contain[0]); // saco al Mozo del contain
$optionsCreated = array(
'contain' => array('Mesa' => $contain),
'conditions'=> $conditions,
);
$mesasABM = $this->find('all', $optionsCreated);
$mozosMesa = array();
foreach ( $mesasABM as $abmMesas ) {
// traer todos los mozos, con su array de mesas
$abmMesas['Mozo']['mesas'] = $abmMesas['Mesa'];
// enviar solo los que tienen mesas borradas
if (!empty($abmMesas['Mesa']) ) {
$mozosMesa['mozos'][] = $abmMesas['Mozo'];
}
}
return $mozosMesa;
}
|
[
"public",
"function",
"mesasBorradas",
"(",
"$",
"mozo_id",
"=",
"null",
",",
"$",
"lastAccess",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"lastAccess",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"conditions",
"=",
"array",
"(",
")",
";",
"// si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo",
"if",
"(",
"!",
"empty",
"(",
"$",
"mozo_id",
")",
")",
"{",
"$",
"conditions",
"[",
"'Mozo.id'",
"]",
"=",
"$",
"mozo_id",
";",
"}",
"else",
"{",
"// todos los mozos activos",
"$",
"conditions",
"[",
"'Mozo.activo'",
"]",
"=",
"1",
";",
"}",
"// traer solo las mesas actualizadas luego del ultimo pedido",
"$",
"conditionsMesa",
"=",
"array",
"(",
"'OR'",
"=>",
"array",
"(",
"array",
"(",
"'Mesa.deleted'",
"=>",
"1",
",",
"'Mesa.deleted_date >='",
"=>",
"$",
"lastAccess",
",",
")",
",",
"array",
"(",
"'Mesa.estado_id'",
"=>",
"MESA_CHECKOUT",
",",
"'Mesa.checkout >='",
"=>",
"$",
"lastAccess",
",",
")",
")",
")",
";",
"$",
"contain",
"=",
"$",
"this",
"->",
"Mesa",
"->",
"defaultContain",
";",
"$",
"contain",
"[",
"'conditions'",
"]",
"=",
"$",
"conditionsMesa",
";",
"unset",
"(",
"$",
"contain",
"[",
"0",
"]",
")",
";",
"// saco al Mozo del contain",
"$",
"optionsCreated",
"=",
"array",
"(",
"'contain'",
"=>",
"array",
"(",
"'Mesa'",
"=>",
"$",
"contain",
")",
",",
"'conditions'",
"=>",
"$",
"conditions",
",",
")",
";",
"$",
"mesasABM",
"=",
"$",
"this",
"->",
"find",
"(",
"'all'",
",",
"$",
"optionsCreated",
")",
";",
"$",
"mozosMesa",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"mesasABM",
"as",
"$",
"abmMesas",
")",
"{",
"// traer todos los mozos, con su array de mesas",
"$",
"abmMesas",
"[",
"'Mozo'",
"]",
"[",
"'mesas'",
"]",
"=",
"$",
"abmMesas",
"[",
"'Mesa'",
"]",
";",
"// enviar solo los que tienen mesas borradas",
"if",
"(",
"!",
"empty",
"(",
"$",
"abmMesas",
"[",
"'Mesa'",
"]",
")",
")",
"{",
"$",
"mozosMesa",
"[",
"'mozos'",
"]",
"[",
"]",
"=",
"$",
"abmMesas",
"[",
"'Mozo'",
"]",
";",
"}",
"}",
"return",
"$",
"mozosMesa",
";",
"}"
] |
Para todos los mozos activos, me trae sus mesas eliminadas entre cada actualizacion de datos
@param int $mozo_id id del mozo, en caso de que no le pase ninguno, me busca todos
@return array Mozos con sus mesas, Comandas, detalleComanda, productos y sabores
|
[
"Para",
"todos",
"los",
"mozos",
"activos",
"me",
"trae",
"sus",
"mesas",
"eliminadas",
"entre",
"cada",
"actualizacion",
"de",
"datos"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Model/Mozo.php#L171-L223
|
21,910
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php
|
DocBlockConverter.addInheritedFromTag
|
protected function addInheritedFromTag(\DOMElement $docBlock, $descriptor)
{
$parentElement = $descriptor->getInheritedElement();
if (! $parentElement instanceof $descriptor) {
return;
}
$child = new \DOMElement('tag');
$docBlock->appendChild($child);
$rule = $this->router->match($parentElement);
$child->setAttribute('name', 'inherited_from');
$child->setAttribute('description', $parentElement->getFullyQualifiedStructuralElementName());
$child->setAttribute('refers', $parentElement->getFullyQualifiedStructuralElementName());
$child->setAttribute('link', $rule ? $rule->generate($parentElement) : '');
}
|
php
|
protected function addInheritedFromTag(\DOMElement $docBlock, $descriptor)
{
$parentElement = $descriptor->getInheritedElement();
if (! $parentElement instanceof $descriptor) {
return;
}
$child = new \DOMElement('tag');
$docBlock->appendChild($child);
$rule = $this->router->match($parentElement);
$child->setAttribute('name', 'inherited_from');
$child->setAttribute('description', $parentElement->getFullyQualifiedStructuralElementName());
$child->setAttribute('refers', $parentElement->getFullyQualifiedStructuralElementName());
$child->setAttribute('link', $rule ? $rule->generate($parentElement) : '');
}
|
[
"protected",
"function",
"addInheritedFromTag",
"(",
"\\",
"DOMElement",
"$",
"docBlock",
",",
"$",
"descriptor",
")",
"{",
"$",
"parentElement",
"=",
"$",
"descriptor",
"->",
"getInheritedElement",
"(",
")",
";",
"if",
"(",
"!",
"$",
"parentElement",
"instanceof",
"$",
"descriptor",
")",
"{",
"return",
";",
"}",
"$",
"child",
"=",
"new",
"\\",
"DOMElement",
"(",
"'tag'",
")",
";",
"$",
"docBlock",
"->",
"appendChild",
"(",
"$",
"child",
")",
";",
"$",
"rule",
"=",
"$",
"this",
"->",
"router",
"->",
"match",
"(",
"$",
"parentElement",
")",
";",
"$",
"child",
"->",
"setAttribute",
"(",
"'name'",
",",
"'inherited_from'",
")",
";",
"$",
"child",
"->",
"setAttribute",
"(",
"'description'",
",",
"$",
"parentElement",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
")",
";",
"$",
"child",
"->",
"setAttribute",
"(",
"'refers'",
",",
"$",
"parentElement",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
")",
";",
"$",
"child",
"->",
"setAttribute",
"(",
"'link'",
",",
"$",
"rule",
"?",
"$",
"rule",
"->",
"generate",
"(",
"$",
"parentElement",
")",
":",
"''",
")",
";",
"}"
] |
Adds the 'inherited_from' tag when a Descriptor inherits from another Descriptor.
@param \DOMElement $docBlock
@param DescriptorAbstract $descriptor
@return void
|
[
"Adds",
"the",
"inherited_from",
"tag",
"when",
"a",
"Descriptor",
"inherits",
"from",
"another",
"Descriptor",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php#L137-L153
|
21,911
|
frdl/webfan
|
.ApplicationComposer/lib/webdof/valFormats.php
|
valFormats._isuuidversion
|
protected function _isuuidversion($in, $strict = true)
{
if(false !== $strict)
{
$in = strtolower($in );
$alphanums = "a-f";
}else{
$alphanums = "a-z";
}
if(!preg_match("/^[0-9$alphanums]{8}-[0-9$alphanums]{4}-(?<version>[0-9$alphanums]{1})[0-9$alphanums]{3}-[0-9$alphanums]{4}-[0-9$alphanums]{12}$/i",$in, $matches) )return false;
$version = $matches['version'];
if(false !== $strict && (empty($version) || !$this->_isint($version) || intval($version)<1 || intval($version)> 6))return false;
return $version;
}
|
php
|
protected function _isuuidversion($in, $strict = true)
{
if(false !== $strict)
{
$in = strtolower($in );
$alphanums = "a-f";
}else{
$alphanums = "a-z";
}
if(!preg_match("/^[0-9$alphanums]{8}-[0-9$alphanums]{4}-(?<version>[0-9$alphanums]{1})[0-9$alphanums]{3}-[0-9$alphanums]{4}-[0-9$alphanums]{12}$/i",$in, $matches) )return false;
$version = $matches['version'];
if(false !== $strict && (empty($version) || !$this->_isint($version) || intval($version)<1 || intval($version)> 6))return false;
return $version;
}
|
[
"protected",
"function",
"_isuuidversion",
"(",
"$",
"in",
",",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"strict",
")",
"{",
"$",
"in",
"=",
"strtolower",
"(",
"$",
"in",
")",
";",
"$",
"alphanums",
"=",
"\"a-f\"",
";",
"}",
"else",
"{",
"$",
"alphanums",
"=",
"\"a-z\"",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"\"/^[0-9$alphanums]{8}-[0-9$alphanums]{4}-(?<version>[0-9$alphanums]{1})[0-9$alphanums]{3}-[0-9$alphanums]{4}-[0-9$alphanums]{12}$/i\"",
",",
"$",
"in",
",",
"$",
"matches",
")",
")",
"return",
"false",
";",
"$",
"version",
"=",
"$",
"matches",
"[",
"'version'",
"]",
";",
"if",
"(",
"false",
"!==",
"$",
"strict",
"&&",
"(",
"empty",
"(",
"$",
"version",
")",
"||",
"!",
"$",
"this",
"->",
"_isint",
"(",
"$",
"version",
")",
"||",
"intval",
"(",
"$",
"version",
")",
"<",
"1",
"||",
"intval",
"(",
"$",
"version",
")",
">",
"6",
")",
")",
"return",
"false",
";",
"return",
"$",
"version",
";",
"}"
] |
returns UUID version or FALSE if no UUID format
|
[
"returns",
"UUID",
"version",
"or",
"FALSE",
"if",
"no",
"UUID",
"format"
] |
84d270377685224e891cd9d571b103b36f05b845
|
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/webdof/valFormats.php#L892-L909
|
21,912
|
frdl/webfan
|
.ApplicationComposer/lib/webdof/valFormats.php
|
valFormats._ip2long
|
protected function _ip2long($ip, $getVersion = TRUE)
{
$version = $this->_isip($ip);
if($getVersion === FALSE && $version === FALSE)return FALSE;
if($getVersion === FALSE && $version === 'ipv4')return $this->_ip2long_v4($ip);
if($getVersion === FALSE && $version === 'ipv6')return $this->_ip2long_v6($ip);
if($getVersion === TRUE && $version === FALSE)return array('version' => FALSE, 'int' => FALSE);
if($getVersion === TRUE && $version === 'ipv4')return array('version' => $version, 'int' => $this->_ip2long_v4($ip));
if($getVersion === TRUE && $version === 'ipv6')return array('version' => $version, 'int' => $this->_ip2long_v6($ip));
return trigger_error('inalid argument getVersion in ipFormat::ip2long()!', E_USER_ERROR);
}
|
php
|
protected function _ip2long($ip, $getVersion = TRUE)
{
$version = $this->_isip($ip);
if($getVersion === FALSE && $version === FALSE)return FALSE;
if($getVersion === FALSE && $version === 'ipv4')return $this->_ip2long_v4($ip);
if($getVersion === FALSE && $version === 'ipv6')return $this->_ip2long_v6($ip);
if($getVersion === TRUE && $version === FALSE)return array('version' => FALSE, 'int' => FALSE);
if($getVersion === TRUE && $version === 'ipv4')return array('version' => $version, 'int' => $this->_ip2long_v4($ip));
if($getVersion === TRUE && $version === 'ipv6')return array('version' => $version, 'int' => $this->_ip2long_v6($ip));
return trigger_error('inalid argument getVersion in ipFormat::ip2long()!', E_USER_ERROR);
}
|
[
"protected",
"function",
"_ip2long",
"(",
"$",
"ip",
",",
"$",
"getVersion",
"=",
"TRUE",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"_isip",
"(",
"$",
"ip",
")",
";",
"if",
"(",
"$",
"getVersion",
"===",
"FALSE",
"&&",
"$",
"version",
"===",
"FALSE",
")",
"return",
"FALSE",
";",
"if",
"(",
"$",
"getVersion",
"===",
"FALSE",
"&&",
"$",
"version",
"===",
"'ipv4'",
")",
"return",
"$",
"this",
"->",
"_ip2long_v4",
"(",
"$",
"ip",
")",
";",
"if",
"(",
"$",
"getVersion",
"===",
"FALSE",
"&&",
"$",
"version",
"===",
"'ipv6'",
")",
"return",
"$",
"this",
"->",
"_ip2long_v6",
"(",
"$",
"ip",
")",
";",
"if",
"(",
"$",
"getVersion",
"===",
"TRUE",
"&&",
"$",
"version",
"===",
"FALSE",
")",
"return",
"array",
"(",
"'version'",
"=>",
"FALSE",
",",
"'int'",
"=>",
"FALSE",
")",
";",
"if",
"(",
"$",
"getVersion",
"===",
"TRUE",
"&&",
"$",
"version",
"===",
"'ipv4'",
")",
"return",
"array",
"(",
"'version'",
"=>",
"$",
"version",
",",
"'int'",
"=>",
"$",
"this",
"->",
"_ip2long_v4",
"(",
"$",
"ip",
")",
")",
";",
"if",
"(",
"$",
"getVersion",
"===",
"TRUE",
"&&",
"$",
"version",
"===",
"'ipv6'",
")",
"return",
"array",
"(",
"'version'",
"=>",
"$",
"version",
",",
"'int'",
"=>",
"$",
"this",
"->",
"_ip2long_v6",
"(",
"$",
"ip",
")",
")",
";",
"return",
"trigger_error",
"(",
"'inalid argument getVersion in ipFormat::ip2long()!'",
",",
"E_USER_ERROR",
")",
";",
"}"
] |
IP Addresses...
- php.net
|
[
"IP",
"Addresses",
"...",
"-",
"php",
".",
"net"
] |
84d270377685224e891cd9d571b103b36f05b845
|
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/webdof/valFormats.php#L1038-L1050
|
21,913
|
Josantonius/WP_Image
|
src/class-wp-image.php
|
WP_Image.save
|
public static function save( $url, $post_ID, $featured = false ) {
$url = filter_var( $url, FILTER_VALIDATE_URL );
if ( false === $url || false === get_post_status( $post_ID ) ) {
return false;
}
$filename = basename( $url );
$filepath = self::upload( $url, $filename );
$attachment = [
'post_mime_type' => wp_check_filetype( $filename, null )['type'],
'post_title' => sanitize_file_name( $filename ),
'post_content' => '',
'post_status' => 'inherit',
];
$attach_id = wp_insert_attachment( $attachment, $filepath, $post_ID );
require_once( ABSPATH . 'wp-admin/includes/image.php' );
$attach_data = wp_generate_attachment_metadata( $attach_id, $filepath );
wp_update_attachment_metadata( $attach_id, $attach_data );
if ( $featured ) {
set_post_thumbnail( $post_ID, $attach_id );
}
return wp_get_attachment_url( $attach_id );
}
|
php
|
public static function save( $url, $post_ID, $featured = false ) {
$url = filter_var( $url, FILTER_VALIDATE_URL );
if ( false === $url || false === get_post_status( $post_ID ) ) {
return false;
}
$filename = basename( $url );
$filepath = self::upload( $url, $filename );
$attachment = [
'post_mime_type' => wp_check_filetype( $filename, null )['type'],
'post_title' => sanitize_file_name( $filename ),
'post_content' => '',
'post_status' => 'inherit',
];
$attach_id = wp_insert_attachment( $attachment, $filepath, $post_ID );
require_once( ABSPATH . 'wp-admin/includes/image.php' );
$attach_data = wp_generate_attachment_metadata( $attach_id, $filepath );
wp_update_attachment_metadata( $attach_id, $attach_data );
if ( $featured ) {
set_post_thumbnail( $post_ID, $attach_id );
}
return wp_get_attachment_url( $attach_id );
}
|
[
"public",
"static",
"function",
"save",
"(",
"$",
"url",
",",
"$",
"post_ID",
",",
"$",
"featured",
"=",
"false",
")",
"{",
"$",
"url",
"=",
"filter_var",
"(",
"$",
"url",
",",
"FILTER_VALIDATE_URL",
")",
";",
"if",
"(",
"false",
"===",
"$",
"url",
"||",
"false",
"===",
"get_post_status",
"(",
"$",
"post_ID",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"filename",
"=",
"basename",
"(",
"$",
"url",
")",
";",
"$",
"filepath",
"=",
"self",
"::",
"upload",
"(",
"$",
"url",
",",
"$",
"filename",
")",
";",
"$",
"attachment",
"=",
"[",
"'post_mime_type'",
"=>",
"wp_check_filetype",
"(",
"$",
"filename",
",",
"null",
")",
"[",
"'type'",
"]",
",",
"'post_title'",
"=>",
"sanitize_file_name",
"(",
"$",
"filename",
")",
",",
"'post_content'",
"=>",
"''",
",",
"'post_status'",
"=>",
"'inherit'",
",",
"]",
";",
"$",
"attach_id",
"=",
"wp_insert_attachment",
"(",
"$",
"attachment",
",",
"$",
"filepath",
",",
"$",
"post_ID",
")",
";",
"require_once",
"(",
"ABSPATH",
".",
"'wp-admin/includes/image.php'",
")",
";",
"$",
"attach_data",
"=",
"wp_generate_attachment_metadata",
"(",
"$",
"attach_id",
",",
"$",
"filepath",
")",
";",
"wp_update_attachment_metadata",
"(",
"$",
"attach_id",
",",
"$",
"attach_data",
")",
";",
"if",
"(",
"$",
"featured",
")",
"{",
"set_post_thumbnail",
"(",
"$",
"post_ID",
",",
"$",
"attach_id",
")",
";",
"}",
"return",
"wp_get_attachment_url",
"(",
"$",
"attach_id",
")",
";",
"}"
] |
Save image and associate it with a specific post.
@param string $url → external url image.
@param int $post_ID → post id.
@param boolean $featured → if image is featured.
@return string|false → URI for an attachment file or false on failure.
|
[
"Save",
"image",
"and",
"associate",
"it",
"with",
"a",
"specific",
"post",
"."
] |
59a2b7bb79db81e70d7b6c3eb3a5ce603c20e204
|
https://github.com/Josantonius/WP_Image/blob/59a2b7bb79db81e70d7b6c3eb3a5ce603c20e204/src/class-wp-image.php#L31-L62
|
21,914
|
Josantonius/WP_Image
|
src/class-wp-image.php
|
WP_Image.upload
|
public static function upload( $url, $filename ) {
$dir = wp_upload_dir();
if ( ! isset( $dir['path'], $dir['basedir'] ) ) {
return false;
}
$path = wp_mkdir_p( $dir['path'] ) ? $dir['path'] : $dir['basedir'];
$path = rtrim( $path, '/' ) . '/';
$image_data = @file_get_contents( $url );
if ( $image_data ) {
$state = @file_put_contents( $path . $filename, $image_data );
}
return ( isset( $state ) && $state ) ? $path . $filename : false;
}
|
php
|
public static function upload( $url, $filename ) {
$dir = wp_upload_dir();
if ( ! isset( $dir['path'], $dir['basedir'] ) ) {
return false;
}
$path = wp_mkdir_p( $dir['path'] ) ? $dir['path'] : $dir['basedir'];
$path = rtrim( $path, '/' ) . '/';
$image_data = @file_get_contents( $url );
if ( $image_data ) {
$state = @file_put_contents( $path . $filename, $image_data );
}
return ( isset( $state ) && $state ) ? $path . $filename : false;
}
|
[
"public",
"static",
"function",
"upload",
"(",
"$",
"url",
",",
"$",
"filename",
")",
"{",
"$",
"dir",
"=",
"wp_upload_dir",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"dir",
"[",
"'path'",
"]",
",",
"$",
"dir",
"[",
"'basedir'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"path",
"=",
"wp_mkdir_p",
"(",
"$",
"dir",
"[",
"'path'",
"]",
")",
"?",
"$",
"dir",
"[",
"'path'",
"]",
":",
"$",
"dir",
"[",
"'basedir'",
"]",
";",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
".",
"'/'",
";",
"$",
"image_data",
"=",
"@",
"file_get_contents",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"image_data",
")",
"{",
"$",
"state",
"=",
"@",
"file_put_contents",
"(",
"$",
"path",
".",
"$",
"filename",
",",
"$",
"image_data",
")",
";",
"}",
"return",
"(",
"isset",
"(",
"$",
"state",
")",
"&&",
"$",
"state",
")",
"?",
"$",
"path",
".",
"$",
"filename",
":",
"false",
";",
"}"
] |
Upload image to WordPress upload directory.
@since 1.0.2
@param string $url → external url image.
@param string $filename → filename.
@return string|false → path to upload image or false on failure.
|
[
"Upload",
"image",
"to",
"WordPress",
"upload",
"directory",
"."
] |
59a2b7bb79db81e70d7b6c3eb3a5ce603c20e204
|
https://github.com/Josantonius/WP_Image/blob/59a2b7bb79db81e70d7b6c3eb3a5ce603c20e204/src/class-wp-image.php#L74-L92
|
21,915
|
Josantonius/WP_Image
|
src/class-wp-image.php
|
WP_Image.delete_all_attachment
|
public static function delete_all_attachment( $post_ID, $force = false ) {
if ( get_post_status( $post_ID ) === false ) {
return false;
}
$counter = 0;
$attachments = get_posts(
[
'post_type' => 'attachment',
'posts_per_page' => 100,
'post_status' => 'any',
'post_mime_type' => 'image/jpeg, image/png, image/gif',
'post_parent' => $post_ID,
]
);
foreach ( $attachments as $attachment ) {
if ( wp_delete_attachment( $attachment->ID, $force ) !== false ) {
$counter++;
}
}
return $counter;
}
|
php
|
public static function delete_all_attachment( $post_ID, $force = false ) {
if ( get_post_status( $post_ID ) === false ) {
return false;
}
$counter = 0;
$attachments = get_posts(
[
'post_type' => 'attachment',
'posts_per_page' => 100,
'post_status' => 'any',
'post_mime_type' => 'image/jpeg, image/png, image/gif',
'post_parent' => $post_ID,
]
);
foreach ( $attachments as $attachment ) {
if ( wp_delete_attachment( $attachment->ID, $force ) !== false ) {
$counter++;
}
}
return $counter;
}
|
[
"public",
"static",
"function",
"delete_all_attachment",
"(",
"$",
"post_ID",
",",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"get_post_status",
"(",
"$",
"post_ID",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"counter",
"=",
"0",
";",
"$",
"attachments",
"=",
"get_posts",
"(",
"[",
"'post_type'",
"=>",
"'attachment'",
",",
"'posts_per_page'",
"=>",
"100",
",",
"'post_status'",
"=>",
"'any'",
",",
"'post_mime_type'",
"=>",
"'image/jpeg, image/png, image/gif'",
",",
"'post_parent'",
"=>",
"$",
"post_ID",
",",
"]",
")",
";",
"foreach",
"(",
"$",
"attachments",
"as",
"$",
"attachment",
")",
"{",
"if",
"(",
"wp_delete_attachment",
"(",
"$",
"attachment",
"->",
"ID",
",",
"$",
"force",
")",
"!==",
"false",
")",
"{",
"$",
"counter",
"++",
";",
"}",
"}",
"return",
"$",
"counter",
";",
"}"
] |
Deletes an attachment and all of its derivatives.
@since 1.0.3
@param int $post_ID → post id.
@param boolean $force → force deletion.
@return int|false → attachments deleted.
|
[
"Deletes",
"an",
"attachment",
"and",
"all",
"of",
"its",
"derivatives",
"."
] |
59a2b7bb79db81e70d7b6c3eb3a5ce603c20e204
|
https://github.com/Josantonius/WP_Image/blob/59a2b7bb79db81e70d7b6c3eb3a5ce603c20e204/src/class-wp-image.php#L104-L129
|
21,916
|
caffeinated/beverage
|
src/Repositories/AbstractEloquentRepository.php
|
AbstractEloquentRepository.delete
|
public function delete($id)
{
$this->fireEvent('deleting', [$id]);
$deleted = $this->model->destroy($id);
$this->fireEvent('deleted', [$id, $deleted]);
return $deleted;
}
|
php
|
public function delete($id)
{
$this->fireEvent('deleting', [$id]);
$deleted = $this->model->destroy($id);
$this->fireEvent('deleted', [$id, $deleted]);
return $deleted;
}
|
[
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"fireEvent",
"(",
"'deleting'",
",",
"[",
"$",
"id",
"]",
")",
";",
"$",
"deleted",
"=",
"$",
"this",
"->",
"model",
"->",
"destroy",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"fireEvent",
"(",
"'deleted'",
",",
"[",
"$",
"id",
",",
"$",
"deleted",
"]",
")",
";",
"return",
"$",
"deleted",
";",
"}"
] |
Find and delete a resource by ID.
@param int $id
@return bool
|
[
"Find",
"and",
"delete",
"a",
"resource",
"by",
"ID",
"."
] |
c7d612a1d3bc1baddc97fec60ab17224550efaf3
|
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L68-L77
|
21,917
|
caffeinated/beverage
|
src/Repositories/AbstractEloquentRepository.php
|
AbstractEloquentRepository.store
|
public function store($request)
{
$this->fireEvent('creating', [$request]);
$created = $this->model->create($request);
$this->fireEvent('created', [$created]);
return $created;
}
|
php
|
public function store($request)
{
$this->fireEvent('creating', [$request]);
$created = $this->model->create($request);
$this->fireEvent('created', [$created]);
return $created;
}
|
[
"public",
"function",
"store",
"(",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"fireEvent",
"(",
"'creating'",
",",
"[",
"$",
"request",
"]",
")",
";",
"$",
"created",
"=",
"$",
"this",
"->",
"model",
"->",
"create",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"fireEvent",
"(",
"'created'",
",",
"[",
"$",
"created",
"]",
")",
";",
"return",
"$",
"created",
";",
"}"
] |
Store a new resource.
@param mixed $request
@return mixed
|
[
"Store",
"a",
"new",
"resource",
"."
] |
c7d612a1d3bc1baddc97fec60ab17224550efaf3
|
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L143-L152
|
21,918
|
caffeinated/beverage
|
src/Repositories/AbstractEloquentRepository.php
|
AbstractEloquentRepository.with
|
public function with($relationships)
{
if (! is_array($relationships)) {
$relationships = explode(', ', $relationships);
}
if (! in_array($relationships, $this->withRelationships)) {
foreach ($relationships as $with) {
$this->withRelationships[] = $with;
}
}
return $this;
}
|
php
|
public function with($relationships)
{
if (! is_array($relationships)) {
$relationships = explode(', ', $relationships);
}
if (! in_array($relationships, $this->withRelationships)) {
foreach ($relationships as $with) {
$this->withRelationships[] = $with;
}
}
return $this;
}
|
[
"public",
"function",
"with",
"(",
"$",
"relationships",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"relationships",
")",
")",
"{",
"$",
"relationships",
"=",
"explode",
"(",
"', '",
",",
"$",
"relationships",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"relationships",
",",
"$",
"this",
"->",
"withRelationships",
")",
")",
"{",
"foreach",
"(",
"$",
"relationships",
"as",
"$",
"with",
")",
"{",
"$",
"this",
"->",
"withRelationships",
"[",
"]",
"=",
"$",
"with",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Assign eager loading relationships.
@param string|array $relationships
@return AbstractEloquentRepository
|
[
"Assign",
"eager",
"loading",
"relationships",
"."
] |
c7d612a1d3bc1baddc97fec60ab17224550efaf3
|
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L178-L191
|
21,919
|
caffeinated/beverage
|
src/Repositories/AbstractEloquentRepository.php
|
AbstractEloquentRepository.newQuery
|
protected function newQuery()
{
$query = $this->model->newQuery();
foreach ($this->withRelationships as $relationship) {
$query->with($relationship);
}
return $query;
}
|
php
|
protected function newQuery()
{
$query = $this->model->newQuery();
foreach ($this->withRelationships as $relationship) {
$query->with($relationship);
}
return $query;
}
|
[
"protected",
"function",
"newQuery",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"model",
"->",
"newQuery",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"withRelationships",
"as",
"$",
"relationship",
")",
"{",
"$",
"query",
"->",
"with",
"(",
"$",
"relationship",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Create a new newQuery instance with eager loaded relationships.
@return newQuery
|
[
"Create",
"a",
"new",
"newQuery",
"instance",
"with",
"eager",
"loaded",
"relationships",
"."
] |
c7d612a1d3bc1baddc97fec60ab17224550efaf3
|
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L232-L241
|
21,920
|
caffeinated/beverage
|
src/Repositories/AbstractEloquentRepository.php
|
AbstractEloquentRepository.fireEvent
|
protected function fireEvent($event, $data)
{
$fireableEvent = isset($this->fireEvents[$event]) ? $this->fireEvents[$event] : null;
if (! is_null($fireableEvent)) {
return $this->event->fire($fireableEvent, $data);
}
return null;
}
|
php
|
protected function fireEvent($event, $data)
{
$fireableEvent = isset($this->fireEvents[$event]) ? $this->fireEvents[$event] : null;
if (! is_null($fireableEvent)) {
return $this->event->fire($fireableEvent, $data);
}
return null;
}
|
[
"protected",
"function",
"fireEvent",
"(",
"$",
"event",
",",
"$",
"data",
")",
"{",
"$",
"fireableEvent",
"=",
"isset",
"(",
"$",
"this",
"->",
"fireEvents",
"[",
"$",
"event",
"]",
")",
"?",
"$",
"this",
"->",
"fireEvents",
"[",
"$",
"event",
"]",
":",
"null",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"fireableEvent",
")",
")",
"{",
"return",
"$",
"this",
"->",
"event",
"->",
"fire",
"(",
"$",
"fireableEvent",
",",
"$",
"data",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Fire off an event if one is defined.
@param string $event
@param array $data
@return mixed
|
[
"Fire",
"off",
"an",
"event",
"if",
"one",
"is",
"defined",
"."
] |
c7d612a1d3bc1baddc97fec60ab17224550efaf3
|
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L250-L259
|
21,921
|
bpolaszek/simple-dbal
|
src/Model/Adapter/Mysqli/MysqliAsync.php
|
MysqliAsync.wait
|
private function wait()
{
do {
if (empty($this->queries)) {
break;
}
$links = $errors = $reject = [];
foreach ($this->queries as $link) {
$links[] = $errors[] = $reject[] = $link['l'];
}
if (!mysqli_poll($links, $errors, $reject, self::$sleep, self::$usleep)) {
continue;
}
foreach ($this->queries as $l => $link) {
$promise = $this->getPromise($link);
$cnx = $this->getConnection($link);
try {
$result = $cnx->reap_async_query();
if ($result instanceof mysqli_result) {
$promise->resolve($result);
} else {
$errNo = mysqli_errno($cnx);
$errStr = mysqli_error($cnx);
if (0 !== $errNo || 0 !== strlen($errStr)) {
throw new mysqli_sql_exception($errStr, $errNo);
} else {
$promise->resolve($cnx);
}
}
} catch (mysqli_sql_exception $e) {
$promise->reject($e);
}
$this->processed++;
unset($this->queries[$l]);
}
} while ($this->processed < count($this->queries));
$this->reset();
}
|
php
|
private function wait()
{
do {
if (empty($this->queries)) {
break;
}
$links = $errors = $reject = [];
foreach ($this->queries as $link) {
$links[] = $errors[] = $reject[] = $link['l'];
}
if (!mysqli_poll($links, $errors, $reject, self::$sleep, self::$usleep)) {
continue;
}
foreach ($this->queries as $l => $link) {
$promise = $this->getPromise($link);
$cnx = $this->getConnection($link);
try {
$result = $cnx->reap_async_query();
if ($result instanceof mysqli_result) {
$promise->resolve($result);
} else {
$errNo = mysqli_errno($cnx);
$errStr = mysqli_error($cnx);
if (0 !== $errNo || 0 !== strlen($errStr)) {
throw new mysqli_sql_exception($errStr, $errNo);
} else {
$promise->resolve($cnx);
}
}
} catch (mysqli_sql_exception $e) {
$promise->reject($e);
}
$this->processed++;
unset($this->queries[$l]);
}
} while ($this->processed < count($this->queries));
$this->reset();
}
|
[
"private",
"function",
"wait",
"(",
")",
"{",
"do",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"queries",
")",
")",
"{",
"break",
";",
"}",
"$",
"links",
"=",
"$",
"errors",
"=",
"$",
"reject",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"queries",
"as",
"$",
"link",
")",
"{",
"$",
"links",
"[",
"]",
"=",
"$",
"errors",
"[",
"]",
"=",
"$",
"reject",
"[",
"]",
"=",
"$",
"link",
"[",
"'l'",
"]",
";",
"}",
"if",
"(",
"!",
"mysqli_poll",
"(",
"$",
"links",
",",
"$",
"errors",
",",
"$",
"reject",
",",
"self",
"::",
"$",
"sleep",
",",
"self",
"::",
"$",
"usleep",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"queries",
"as",
"$",
"l",
"=>",
"$",
"link",
")",
"{",
"$",
"promise",
"=",
"$",
"this",
"->",
"getPromise",
"(",
"$",
"link",
")",
";",
"$",
"cnx",
"=",
"$",
"this",
"->",
"getConnection",
"(",
"$",
"link",
")",
";",
"try",
"{",
"$",
"result",
"=",
"$",
"cnx",
"->",
"reap_async_query",
"(",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"mysqli_result",
")",
"{",
"$",
"promise",
"->",
"resolve",
"(",
"$",
"result",
")",
";",
"}",
"else",
"{",
"$",
"errNo",
"=",
"mysqli_errno",
"(",
"$",
"cnx",
")",
";",
"$",
"errStr",
"=",
"mysqli_error",
"(",
"$",
"cnx",
")",
";",
"if",
"(",
"0",
"!==",
"$",
"errNo",
"||",
"0",
"!==",
"strlen",
"(",
"$",
"errStr",
")",
")",
"{",
"throw",
"new",
"mysqli_sql_exception",
"(",
"$",
"errStr",
",",
"$",
"errNo",
")",
";",
"}",
"else",
"{",
"$",
"promise",
"->",
"resolve",
"(",
"$",
"cnx",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"mysqli_sql_exception",
"$",
"e",
")",
"{",
"$",
"promise",
"->",
"reject",
"(",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"processed",
"++",
";",
"unset",
"(",
"$",
"this",
"->",
"queries",
"[",
"$",
"l",
"]",
")",
";",
"}",
"}",
"while",
"(",
"$",
"this",
"->",
"processed",
"<",
"count",
"(",
"$",
"this",
"->",
"queries",
")",
")",
";",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"}"
] |
Wait for pending queries to complete.
|
[
"Wait",
"for",
"pending",
"queries",
"to",
"complete",
"."
] |
52cb50d326ba5854191814b470f5e84950ebb6e6
|
https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/Mysqli/MysqliAsync.php#L106-L143
|
21,922
|
letyii/yii2-mongo-nested-set
|
NestedSetsBehavior.php
|
NestedSetsBehavior.makeRoot
|
public function makeRoot($runValidation = true, $attributes = null) {
$this->operation = self::OPERATION_MAKE_ROOT;
return $this->owner->save($runValidation, $attributes);
}
|
php
|
public function makeRoot($runValidation = true, $attributes = null) {
$this->operation = self::OPERATION_MAKE_ROOT;
return $this->owner->save($runValidation, $attributes);
}
|
[
"public",
"function",
"makeRoot",
"(",
"$",
"runValidation",
"=",
"true",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"operation",
"=",
"self",
"::",
"OPERATION_MAKE_ROOT",
";",
"return",
"$",
"this",
"->",
"owner",
"->",
"save",
"(",
"$",
"runValidation",
",",
"$",
"attributes",
")",
";",
"}"
] |
Creates the root node if the active record is new or moves it
as the root node.
@param boolean $runValidation
@param array $attributes
@return boolean
|
[
"Creates",
"the",
"root",
"node",
"if",
"the",
"active",
"record",
"is",
"new",
"or",
"moves",
"it",
"as",
"the",
"root",
"node",
"."
] |
cb88a2e8665c62192a013cd7b1cbcd53148f0ec5
|
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L88-L92
|
21,923
|
letyii/yii2-mongo-nested-set
|
NestedSetsBehavior.php
|
NestedSetsBehavior.prependTo
|
public function prependTo($node, $runValidation = true, $attributes = null) {
$this->operation = self::OPERATION_PREPEND_TO;
$this->node = $node;
return $this->owner->save($runValidation, $attributes);
}
|
php
|
public function prependTo($node, $runValidation = true, $attributes = null) {
$this->operation = self::OPERATION_PREPEND_TO;
$this->node = $node;
return $this->owner->save($runValidation, $attributes);
}
|
[
"public",
"function",
"prependTo",
"(",
"$",
"node",
",",
"$",
"runValidation",
"=",
"true",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"operation",
"=",
"self",
"::",
"OPERATION_PREPEND_TO",
";",
"$",
"this",
"->",
"node",
"=",
"$",
"node",
";",
"return",
"$",
"this",
"->",
"owner",
"->",
"save",
"(",
"$",
"runValidation",
",",
"$",
"attributes",
")",
";",
"}"
] |
Creates a node as the first child of the target node if the active
record is new or moves it as the first child of the target node.
@param ActiveRecord $node
@param boolean $runValidation
@param array $attributes
@return boolean
|
[
"Creates",
"a",
"node",
"as",
"the",
"first",
"child",
"of",
"the",
"target",
"node",
"if",
"the",
"active",
"record",
"is",
"new",
"or",
"moves",
"it",
"as",
"the",
"first",
"child",
"of",
"the",
"target",
"node",
"."
] |
cb88a2e8665c62192a013cd7b1cbcd53148f0ec5
|
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L102-L107
|
21,924
|
letyii/yii2-mongo-nested-set
|
NestedSetsBehavior.php
|
NestedSetsBehavior.appendTo
|
public function appendTo($node, $runValidation = true, $attributes = null) {
$this->operation = self::OPERATION_APPEND_TO;
$this->node = $node;
return $this->owner->save($runValidation, $attributes);
}
|
php
|
public function appendTo($node, $runValidation = true, $attributes = null) {
$this->operation = self::OPERATION_APPEND_TO;
$this->node = $node;
return $this->owner->save($runValidation, $attributes);
}
|
[
"public",
"function",
"appendTo",
"(",
"$",
"node",
",",
"$",
"runValidation",
"=",
"true",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"operation",
"=",
"self",
"::",
"OPERATION_APPEND_TO",
";",
"$",
"this",
"->",
"node",
"=",
"$",
"node",
";",
"return",
"$",
"this",
"->",
"owner",
"->",
"save",
"(",
"$",
"runValidation",
",",
"$",
"attributes",
")",
";",
"}"
] |
Creates a node as the last child of the target node if the active
record is new or moves it as the last child of the target node.
@param ActiveRecord $node
@param boolean $runValidation
@param array $attributes
@return boolean
|
[
"Creates",
"a",
"node",
"as",
"the",
"last",
"child",
"of",
"the",
"target",
"node",
"if",
"the",
"active",
"record",
"is",
"new",
"or",
"moves",
"it",
"as",
"the",
"last",
"child",
"of",
"the",
"target",
"node",
"."
] |
cb88a2e8665c62192a013cd7b1cbcd53148f0ec5
|
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L117-L122
|
21,925
|
letyii/yii2-mongo-nested-set
|
NestedSetsBehavior.php
|
NestedSetsBehavior.insertBefore
|
public function insertBefore($node, $runValidation = true, $attributes = null) {
$this->operation = self::OPERATION_INSERT_BEFORE;
$this->node = $node;
return $this->owner->save($runValidation, $attributes);
}
|
php
|
public function insertBefore($node, $runValidation = true, $attributes = null) {
$this->operation = self::OPERATION_INSERT_BEFORE;
$this->node = $node;
return $this->owner->save($runValidation, $attributes);
}
|
[
"public",
"function",
"insertBefore",
"(",
"$",
"node",
",",
"$",
"runValidation",
"=",
"true",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"operation",
"=",
"self",
"::",
"OPERATION_INSERT_BEFORE",
";",
"$",
"this",
"->",
"node",
"=",
"$",
"node",
";",
"return",
"$",
"this",
"->",
"owner",
"->",
"save",
"(",
"$",
"runValidation",
",",
"$",
"attributes",
")",
";",
"}"
] |
Creates a node as the previous sibling of the target node if the active
record is new or moves it as the previous sibling of the target node.
@param ActiveRecord $node
@param boolean $runValidation
@param array $attributes
@return boolean
|
[
"Creates",
"a",
"node",
"as",
"the",
"previous",
"sibling",
"of",
"the",
"target",
"node",
"if",
"the",
"active",
"record",
"is",
"new",
"or",
"moves",
"it",
"as",
"the",
"previous",
"sibling",
"of",
"the",
"target",
"node",
"."
] |
cb88a2e8665c62192a013cd7b1cbcd53148f0ec5
|
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L132-L137
|
21,926
|
letyii/yii2-mongo-nested-set
|
NestedSetsBehavior.php
|
NestedSetsBehavior.insertAfter
|
public function insertAfter($node, $runValidation = true, $attributes = null) {
$this->operation = self::OPERATION_INSERT_AFTER;
$this->node = $node;
return $this->owner->save($runValidation, $attributes);
}
|
php
|
public function insertAfter($node, $runValidation = true, $attributes = null) {
$this->operation = self::OPERATION_INSERT_AFTER;
$this->node = $node;
return $this->owner->save($runValidation, $attributes);
}
|
[
"public",
"function",
"insertAfter",
"(",
"$",
"node",
",",
"$",
"runValidation",
"=",
"true",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"operation",
"=",
"self",
"::",
"OPERATION_INSERT_AFTER",
";",
"$",
"this",
"->",
"node",
"=",
"$",
"node",
";",
"return",
"$",
"this",
"->",
"owner",
"->",
"save",
"(",
"$",
"runValidation",
",",
"$",
"attributes",
")",
";",
"}"
] |
Creates a node as the next sibling of the target node if the active
record is new or moves it as the next sibling of the target node.
@param ActiveRecord $node
@param boolean $runValidation
@param array $attributes
@return boolean
|
[
"Creates",
"a",
"node",
"as",
"the",
"next",
"sibling",
"of",
"the",
"target",
"node",
"if",
"the",
"active",
"record",
"is",
"new",
"or",
"moves",
"it",
"as",
"the",
"next",
"sibling",
"of",
"the",
"target",
"node",
"."
] |
cb88a2e8665c62192a013cd7b1cbcd53148f0ec5
|
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L147-L152
|
21,927
|
letyii/yii2-mongo-nested-set
|
NestedSetsBehavior.php
|
NestedSetsBehavior.parents
|
public function parents($depth = null) {
$condition = [
'and',
[$this->leftAttribute => ['$lt' => $this->owner->getAttribute($this->leftAttribute)]],
[$this->rightAttribute => ['$gt' => $this->owner->getAttribute($this->rightAttribute)]],
];
if ($depth !== null) {
$condition[] = [$this->depthAttribute => ['$gte' => $this->owner->getAttribute($this->depthAttribute) - $depth]];
}
$this->applyTreeAttributeCondition($condition);
return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]);
}
|
php
|
public function parents($depth = null) {
$condition = [
'and',
[$this->leftAttribute => ['$lt' => $this->owner->getAttribute($this->leftAttribute)]],
[$this->rightAttribute => ['$gt' => $this->owner->getAttribute($this->rightAttribute)]],
];
if ($depth !== null) {
$condition[] = [$this->depthAttribute => ['$gte' => $this->owner->getAttribute($this->depthAttribute) - $depth]];
}
$this->applyTreeAttributeCondition($condition);
return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]);
}
|
[
"public",
"function",
"parents",
"(",
"$",
"depth",
"=",
"null",
")",
"{",
"$",
"condition",
"=",
"[",
"'and'",
",",
"[",
"$",
"this",
"->",
"leftAttribute",
"=>",
"[",
"'$lt'",
"=>",
"$",
"this",
"->",
"owner",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"leftAttribute",
")",
"]",
"]",
",",
"[",
"$",
"this",
"->",
"rightAttribute",
"=>",
"[",
"'$gt'",
"=>",
"$",
"this",
"->",
"owner",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"rightAttribute",
")",
"]",
"]",
",",
"]",
";",
"if",
"(",
"$",
"depth",
"!==",
"null",
")",
"{",
"$",
"condition",
"[",
"]",
"=",
"[",
"$",
"this",
"->",
"depthAttribute",
"=>",
"[",
"'$gte'",
"=>",
"$",
"this",
"->",
"owner",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"depthAttribute",
")",
"-",
"$",
"depth",
"]",
"]",
";",
"}",
"$",
"this",
"->",
"applyTreeAttributeCondition",
"(",
"$",
"condition",
")",
";",
"return",
"$",
"this",
"->",
"owner",
"->",
"find",
"(",
")",
"->",
"andWhere",
"(",
"$",
"condition",
")",
"->",
"addOrderBy",
"(",
"[",
"$",
"this",
"->",
"leftAttribute",
"=>",
"SORT_ASC",
"]",
")",
";",
"}"
] |
Gets the parents of the node.
@param integer|null $depth the depth
@return \yii\db\ActiveQuery
|
[
"Gets",
"the",
"parents",
"of",
"the",
"node",
"."
] |
cb88a2e8665c62192a013cd7b1cbcd53148f0ec5
|
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L223-L237
|
21,928
|
letyii/yii2-mongo-nested-set
|
NestedSetsBehavior.php
|
NestedSetsBehavior.leaves
|
public function leaves() {
$condition = [
'and',
[$this->leftAttribute => ['$gt' => $this->owner->getAttribute($this->leftAttribute)]],
[$this->rightAttribute => ['$lt' => $this->owner->getAttribute($this->rightAttribute)]],
['$where' => "this.{$this->rightAttribute} = this.{$this->leftAttribute} + 1"]
];
$this->applyTreeAttributeCondition($condition);
return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]);
}
|
php
|
public function leaves() {
$condition = [
'and',
[$this->leftAttribute => ['$gt' => $this->owner->getAttribute($this->leftAttribute)]],
[$this->rightAttribute => ['$lt' => $this->owner->getAttribute($this->rightAttribute)]],
['$where' => "this.{$this->rightAttribute} = this.{$this->leftAttribute} + 1"]
];
$this->applyTreeAttributeCondition($condition);
return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]);
}
|
[
"public",
"function",
"leaves",
"(",
")",
"{",
"$",
"condition",
"=",
"[",
"'and'",
",",
"[",
"$",
"this",
"->",
"leftAttribute",
"=>",
"[",
"'$gt'",
"=>",
"$",
"this",
"->",
"owner",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"leftAttribute",
")",
"]",
"]",
",",
"[",
"$",
"this",
"->",
"rightAttribute",
"=>",
"[",
"'$lt'",
"=>",
"$",
"this",
"->",
"owner",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"rightAttribute",
")",
"]",
"]",
",",
"[",
"'$where'",
"=>",
"\"this.{$this->rightAttribute} = this.{$this->leftAttribute} + 1\"",
"]",
"]",
";",
"$",
"this",
"->",
"applyTreeAttributeCondition",
"(",
"$",
"condition",
")",
";",
"return",
"$",
"this",
"->",
"owner",
"->",
"find",
"(",
")",
"->",
"andWhere",
"(",
"$",
"condition",
")",
"->",
"addOrderBy",
"(",
"[",
"$",
"this",
"->",
"leftAttribute",
"=>",
"SORT_ASC",
"]",
")",
";",
"}"
] |
Gets the leaves of the node.
@return \yii\db\ActiveQuery
|
[
"Gets",
"the",
"leaves",
"of",
"the",
"node",
"."
] |
cb88a2e8665c62192a013cd7b1cbcd53148f0ec5
|
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L264-L275
|
21,929
|
letyii/yii2-mongo-nested-set
|
NestedSetsBehavior.php
|
NestedSetsBehavior.prev
|
public function prev() {
$condition = [$this->rightAttribute => $this->owner->getAttribute($this->leftAttribute) - 1];
$this->applyTreeAttributeCondition($condition);
return $this->owner->find()->andWhere($condition);
}
|
php
|
public function prev() {
$condition = [$this->rightAttribute => $this->owner->getAttribute($this->leftAttribute) - 1];
$this->applyTreeAttributeCondition($condition);
return $this->owner->find()->andWhere($condition);
}
|
[
"public",
"function",
"prev",
"(",
")",
"{",
"$",
"condition",
"=",
"[",
"$",
"this",
"->",
"rightAttribute",
"=>",
"$",
"this",
"->",
"owner",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"leftAttribute",
")",
"-",
"1",
"]",
";",
"$",
"this",
"->",
"applyTreeAttributeCondition",
"(",
"$",
"condition",
")",
";",
"return",
"$",
"this",
"->",
"owner",
"->",
"find",
"(",
")",
"->",
"andWhere",
"(",
"$",
"condition",
")",
";",
"}"
] |
Gets the previous sibling of the node.
@return \yii\db\ActiveQuery
|
[
"Gets",
"the",
"previous",
"sibling",
"of",
"the",
"node",
"."
] |
cb88a2e8665c62192a013cd7b1cbcd53148f0ec5
|
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L281-L286
|
21,930
|
letyii/yii2-mongo-nested-set
|
NestedSetsBehavior.php
|
NestedSetsBehavior.isChildOf
|
public function isChildOf($node) {
$result = $this->owner->getAttribute($this->leftAttribute) > $node->getAttribute($this->leftAttribute) && $this->owner->getAttribute($this->rightAttribute) < $node->getAttribute($this->rightAttribute);
if ($result && $this->treeAttribute !== false) {
$result = $this->owner->getAttribute($this->treeAttribute) === $node->getAttribute($this->treeAttribute);
}
return $result;
}
|
php
|
public function isChildOf($node) {
$result = $this->owner->getAttribute($this->leftAttribute) > $node->getAttribute($this->leftAttribute) && $this->owner->getAttribute($this->rightAttribute) < $node->getAttribute($this->rightAttribute);
if ($result && $this->treeAttribute !== false) {
$result = $this->owner->getAttribute($this->treeAttribute) === $node->getAttribute($this->treeAttribute);
}
return $result;
}
|
[
"public",
"function",
"isChildOf",
"(",
"$",
"node",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"owner",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"leftAttribute",
")",
">",
"$",
"node",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"leftAttribute",
")",
"&&",
"$",
"this",
"->",
"owner",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"rightAttribute",
")",
"<",
"$",
"node",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"rightAttribute",
")",
";",
"if",
"(",
"$",
"result",
"&&",
"$",
"this",
"->",
"treeAttribute",
"!==",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"owner",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"treeAttribute",
")",
"===",
"$",
"node",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"treeAttribute",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Determines whether the node is child of the parent node.
@param ActiveRecord $node the parent node
@return boolean whether the node is child of the parent node
|
[
"Determines",
"whether",
"the",
"node",
"is",
"child",
"of",
"the",
"parent",
"node",
"."
] |
cb88a2e8665c62192a013cd7b1cbcd53148f0ec5
|
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L312-L320
|
21,931
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php
|
ezcCacheStorageFileApcArray.fetchObject
|
protected function fetchObject( $filename )
{
$data = $this->backend->fetch( $filename );
return ( is_object( $data ) ) ? $data : false;
}
|
php
|
protected function fetchObject( $filename )
{
$data = $this->backend->fetch( $filename );
return ( is_object( $data ) ) ? $data : false;
}
|
[
"protected",
"function",
"fetchObject",
"(",
"$",
"filename",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"backend",
"->",
"fetch",
"(",
"$",
"filename",
")",
";",
"return",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"?",
"$",
"data",
":",
"false",
";",
"}"
] |
Fetches the object from the cache.
@param string $filename The ID/filename from where to fetch the data
@return mixed The fetched object or false on failure
|
[
"Fetches",
"the",
"object",
"from",
"the",
"cache",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php#L75-L79
|
21,932
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php
|
ezcCacheStorageFileApcArray.store
|
public function store( $id, $data, $attributes = array() )
{
// Generates the identifier
$filename = $this->properties['location'] . $this->generateIdentifier( $id, $attributes );
// Purges the Registry Cache
if ( isset( $this->registry[$filename] ) )
{
unset( $this->registry[$filename] );
}
// Deletes the files if it already exists on the filesystem
if ( file_exists( $filename ) )
{
if ( unlink( $filename ) === false )
{
throw new ezcBaseFilePermissionException( $filename, ezcBaseFileException::WRITE, 'Could not delete existing cache file.' );
}
}
// Deletes the data from APC if it already exists
$this->backend->delete( $filename );
// Prepares the data for filesystem storage
$dataStr = $this->prepareData( $data );
// Tries to create the directory on the filesystem
$dirname = dirname( $filename );
if ( !is_dir( $dirname )
&& !mkdir( $dirname, 0777, true ) )
{
throw new ezcBaseFilePermissionException( $dirname, ezcBaseFileException::WRITE, 'Could not create directory to store cache file.' );
}
// Tries to write the file the filesystem
if ( @file_put_contents( $filename, $dataStr ) !== strlen( $dataStr ) )
{
throw new ezcBaseFileIoException( $filename, ezcBaseFileException::WRITE, 'Could not write data to cache file.' );
}
// Tries to set the file permissions
if ( ezcBaseFeatures::os() !== "Windows" )
{
chmod( $filename, $this->options->permissions );
}
// Prepares the data for APC storage
$dataObj = $this->prepareData( $data, true );
$dataObj->mtime = @filemtime( $filename );
$dataObj->atime = time();
// Stores it in APC
$this->registerIdentifier( $id, $attributes, $filename );
if ( !$this->backend->store( $filename, $dataObj, $this->properties['options']['ttl'] ) )
{
throw new ezcCacheApcException( "APC store failed." );
}
// Returns the ID for no good reason
return $id;
}
|
php
|
public function store( $id, $data, $attributes = array() )
{
// Generates the identifier
$filename = $this->properties['location'] . $this->generateIdentifier( $id, $attributes );
// Purges the Registry Cache
if ( isset( $this->registry[$filename] ) )
{
unset( $this->registry[$filename] );
}
// Deletes the files if it already exists on the filesystem
if ( file_exists( $filename ) )
{
if ( unlink( $filename ) === false )
{
throw new ezcBaseFilePermissionException( $filename, ezcBaseFileException::WRITE, 'Could not delete existing cache file.' );
}
}
// Deletes the data from APC if it already exists
$this->backend->delete( $filename );
// Prepares the data for filesystem storage
$dataStr = $this->prepareData( $data );
// Tries to create the directory on the filesystem
$dirname = dirname( $filename );
if ( !is_dir( $dirname )
&& !mkdir( $dirname, 0777, true ) )
{
throw new ezcBaseFilePermissionException( $dirname, ezcBaseFileException::WRITE, 'Could not create directory to store cache file.' );
}
// Tries to write the file the filesystem
if ( @file_put_contents( $filename, $dataStr ) !== strlen( $dataStr ) )
{
throw new ezcBaseFileIoException( $filename, ezcBaseFileException::WRITE, 'Could not write data to cache file.' );
}
// Tries to set the file permissions
if ( ezcBaseFeatures::os() !== "Windows" )
{
chmod( $filename, $this->options->permissions );
}
// Prepares the data for APC storage
$dataObj = $this->prepareData( $data, true );
$dataObj->mtime = @filemtime( $filename );
$dataObj->atime = time();
// Stores it in APC
$this->registerIdentifier( $id, $attributes, $filename );
if ( !$this->backend->store( $filename, $dataObj, $this->properties['options']['ttl'] ) )
{
throw new ezcCacheApcException( "APC store failed." );
}
// Returns the ID for no good reason
return $id;
}
|
[
"public",
"function",
"store",
"(",
"$",
"id",
",",
"$",
"data",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"// Generates the identifier",
"$",
"filename",
"=",
"$",
"this",
"->",
"properties",
"[",
"'location'",
"]",
".",
"$",
"this",
"->",
"generateIdentifier",
"(",
"$",
"id",
",",
"$",
"attributes",
")",
";",
"// Purges the Registry Cache",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"filename",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"filename",
"]",
")",
";",
"}",
"// Deletes the files if it already exists on the filesystem",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"if",
"(",
"unlink",
"(",
"$",
"filename",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"ezcBaseFilePermissionException",
"(",
"$",
"filename",
",",
"ezcBaseFileException",
"::",
"WRITE",
",",
"'Could not delete existing cache file.'",
")",
";",
"}",
"}",
"// Deletes the data from APC if it already exists",
"$",
"this",
"->",
"backend",
"->",
"delete",
"(",
"$",
"filename",
")",
";",
"// Prepares the data for filesystem storage",
"$",
"dataStr",
"=",
"$",
"this",
"->",
"prepareData",
"(",
"$",
"data",
")",
";",
"// Tries to create the directory on the filesystem",
"$",
"dirname",
"=",
"dirname",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dirname",
")",
"&&",
"!",
"mkdir",
"(",
"$",
"dirname",
",",
"0777",
",",
"true",
")",
")",
"{",
"throw",
"new",
"ezcBaseFilePermissionException",
"(",
"$",
"dirname",
",",
"ezcBaseFileException",
"::",
"WRITE",
",",
"'Could not create directory to store cache file.'",
")",
";",
"}",
"// Tries to write the file the filesystem",
"if",
"(",
"@",
"file_put_contents",
"(",
"$",
"filename",
",",
"$",
"dataStr",
")",
"!==",
"strlen",
"(",
"$",
"dataStr",
")",
")",
"{",
"throw",
"new",
"ezcBaseFileIoException",
"(",
"$",
"filename",
",",
"ezcBaseFileException",
"::",
"WRITE",
",",
"'Could not write data to cache file.'",
")",
";",
"}",
"// Tries to set the file permissions",
"if",
"(",
"ezcBaseFeatures",
"::",
"os",
"(",
")",
"!==",
"\"Windows\"",
")",
"{",
"chmod",
"(",
"$",
"filename",
",",
"$",
"this",
"->",
"options",
"->",
"permissions",
")",
";",
"}",
"// Prepares the data for APC storage",
"$",
"dataObj",
"=",
"$",
"this",
"->",
"prepareData",
"(",
"$",
"data",
",",
"true",
")",
";",
"$",
"dataObj",
"->",
"mtime",
"=",
"@",
"filemtime",
"(",
"$",
"filename",
")",
";",
"$",
"dataObj",
"->",
"atime",
"=",
"time",
"(",
")",
";",
"// Stores it in APC",
"$",
"this",
"->",
"registerIdentifier",
"(",
"$",
"id",
",",
"$",
"attributes",
",",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"backend",
"->",
"store",
"(",
"$",
"filename",
",",
"$",
"dataObj",
",",
"$",
"this",
"->",
"properties",
"[",
"'options'",
"]",
"[",
"'ttl'",
"]",
")",
")",
"{",
"throw",
"new",
"ezcCacheApcException",
"(",
"\"APC store failed.\"",
")",
";",
"}",
"// Returns the ID for no good reason",
"return",
"$",
"id",
";",
"}"
] |
Stores data to the cache storage.
@throws ezcBaseFilePermissionException
If the directory to store the cache file could not be created.
This exception means most likely that your cache directory
has been corrupted by external influences (file permission
change).
@throws ezcBaseFileIoException
If an error occured while writing the data to the cache. If this
exception occurs, a serious error occured and your storage might
be corruped (e.g. broken network connection, file system broken,
...).
@throws ezcCacheInvalidDataException
If the data submitted can not be handled by the implementation
of {@link ezcCacheStorageFile}. Most implementations can not
handle objects and resources.
@throws ezcCacheApcException
If the data could not be stored in APC.
@param string $id Unique identifier
@param mixed $data The data to store
@param array(string=>string) $attributes Attributes describing the cached data
@return string The ID string of the newly cached data
|
[
"Stores",
"data",
"to",
"the",
"cache",
"storage",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php#L139-L199
|
21,933
|
GreenCape/joomla-cli
|
src/GreenCape/JoomlaCLI/Command.php
|
Command.handleBasePath
|
protected function handleBasePath(InputInterface $input, OutputInterface $output)
{
$path = realpath($input->getOption('basepath'));
$this->writeln($output, 'Joomla! installation expected in ' . $path, OutputInterface::VERBOSITY_DEBUG);
return $path;
}
|
php
|
protected function handleBasePath(InputInterface $input, OutputInterface $output)
{
$path = realpath($input->getOption('basepath'));
$this->writeln($output, 'Joomla! installation expected in ' . $path, OutputInterface::VERBOSITY_DEBUG);
return $path;
}
|
[
"protected",
"function",
"handleBasePath",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"path",
"=",
"realpath",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'basepath'",
")",
")",
";",
"$",
"this",
"->",
"writeln",
"(",
"$",
"output",
",",
"'Joomla! installation expected in '",
".",
"$",
"path",
",",
"OutputInterface",
"::",
"VERBOSITY_DEBUG",
")",
";",
"return",
"$",
"path",
";",
"}"
] |
Read the base path from the options
@param InputInterface $input An InputInterface instance
@param OutputInterface $output An OutputInterface instance
@return string The base path
|
[
"Read",
"the",
"base",
"path",
"from",
"the",
"options"
] |
74a6940f27b1f66c99330d4f9e2c5ac314cdd369
|
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Command.php#L106-L112
|
21,934
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.ffprobe
|
private function ffprobe($binary = null)
{
if (is_null($binary))
{
$binary = static::$ffprobe;
}
if (!isset($this->metadata))
{
$cmd = "{$binary} -v quiet -print_format json -show_format -show_streams {$this->file}";
exec($cmd, $output, $returnvalue);
$json = json_decode( implode("\n", $output), true );
if (!is_array($json))
{
$json = false;
}
$this->metadata = $json;
if ($this->ffprobeHasFormat())
{
$this->formats = array_filter(explode(",", $json['format']['format_name']));
}
}
}
|
php
|
private function ffprobe($binary = null)
{
if (is_null($binary))
{
$binary = static::$ffprobe;
}
if (!isset($this->metadata))
{
$cmd = "{$binary} -v quiet -print_format json -show_format -show_streams {$this->file}";
exec($cmd, $output, $returnvalue);
$json = json_decode( implode("\n", $output), true );
if (!is_array($json))
{
$json = false;
}
$this->metadata = $json;
if ($this->ffprobeHasFormat())
{
$this->formats = array_filter(explode(",", $json['format']['format_name']));
}
}
}
|
[
"private",
"function",
"ffprobe",
"(",
"$",
"binary",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"binary",
")",
")",
"{",
"$",
"binary",
"=",
"static",
"::",
"$",
"ffprobe",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"metadata",
")",
")",
"{",
"$",
"cmd",
"=",
"\"{$binary} -v quiet -print_format json -show_format -show_streams {$this->file}\"",
";",
"exec",
"(",
"$",
"cmd",
",",
"$",
"output",
",",
"$",
"returnvalue",
")",
";",
"$",
"json",
"=",
"json_decode",
"(",
"implode",
"(",
"\"\\n\"",
",",
"$",
"output",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"json",
")",
")",
"{",
"$",
"json",
"=",
"false",
";",
"}",
"$",
"this",
"->",
"metadata",
"=",
"$",
"json",
";",
"if",
"(",
"$",
"this",
"->",
"ffprobeHasFormat",
"(",
")",
")",
"{",
"$",
"this",
"->",
"formats",
"=",
"array_filter",
"(",
"explode",
"(",
"\",\"",
",",
"$",
"json",
"[",
"'format'",
"]",
"[",
"'format_name'",
"]",
")",
")",
";",
"}",
"}",
"}"
] |
Runs an ffprobe on the file or returns cached information.
@return array|false
|
[
"Runs",
"an",
"ffprobe",
"on",
"the",
"file",
"or",
"returns",
"cached",
"information",
"."
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L36-L63
|
21,935
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.ffprobeFormat
|
private function ffprobeFormat($format)
{
$this->ffprobe();
if (count($this->formats) > 0)
{
$args = func_get_args();
foreach ($args as $arg)
{
if (in_array($arg, $this->formats))
{
return true;
}
}
return null;
}
return false;
}
|
php
|
private function ffprobeFormat($format)
{
$this->ffprobe();
if (count($this->formats) > 0)
{
$args = func_get_args();
foreach ($args as $arg)
{
if (in_array($arg, $this->formats))
{
return true;
}
}
return null;
}
return false;
}
|
[
"private",
"function",
"ffprobeFormat",
"(",
"$",
"format",
")",
"{",
"$",
"this",
"->",
"ffprobe",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"formats",
")",
">",
"0",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"arg",
",",
"$",
"this",
"->",
"formats",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"null",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks requested format against what formats ffprobe returned.
@param string $format The format extenson to check for.
@param string|null $format Option number of additional formats.
@return boolean|null
|
[
"Checks",
"requested",
"format",
"against",
"what",
"formats",
"ffprobe",
"returned",
"."
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L72-L92
|
21,936
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.ffprobeHasVideo
|
private function ffprobeHasVideo()
{
if (isset($this->metadata['streams']))
{
foreach ($this->metadata['streams'] as $streamIndex => $stream)
{
if (isset($stream['codec_type']) && $stream['codec_type'] === "video" && $stream['disposition']['attached_pic'] !== 1)
{
return $streamIndex;
}
}
}
return false;
}
|
php
|
private function ffprobeHasVideo()
{
if (isset($this->metadata['streams']))
{
foreach ($this->metadata['streams'] as $streamIndex => $stream)
{
if (isset($stream['codec_type']) && $stream['codec_type'] === "video" && $stream['disposition']['attached_pic'] !== 1)
{
return $streamIndex;
}
}
}
return false;
}
|
[
"private",
"function",
"ffprobeHasVideo",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"metadata",
"[",
"'streams'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadata",
"[",
"'streams'",
"]",
"as",
"$",
"streamIndex",
"=>",
"$",
"stream",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"stream",
"[",
"'codec_type'",
"]",
")",
"&&",
"$",
"stream",
"[",
"'codec_type'",
"]",
"===",
"\"video\"",
"&&",
"$",
"stream",
"[",
"'disposition'",
"]",
"[",
"'attached_pic'",
"]",
"!==",
"1",
")",
"{",
"return",
"$",
"streamIndex",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check our metadata for a video stream.
@return boolean|int Int if video stream index found (CAN BE 0), false if none
|
[
"Check",
"our",
"metadata",
"for",
"a",
"video",
"stream",
"."
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L114-L128
|
21,937
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.ffprobeHasAudio
|
private function ffprobeHasAudio()
{
if (isset($this->metadata['streams']))
{
foreach ($this->metadata['streams'] as $streamIndex => $stream)
{
if (isset($stream['codec_type']) && $stream['codec_type'] === "audio")
{
return $streamIndex;
}
}
}
return false;
}
|
php
|
private function ffprobeHasAudio()
{
if (isset($this->metadata['streams']))
{
foreach ($this->metadata['streams'] as $streamIndex => $stream)
{
if (isset($stream['codec_type']) && $stream['codec_type'] === "audio")
{
return $streamIndex;
}
}
}
return false;
}
|
[
"private",
"function",
"ffprobeHasAudio",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"metadata",
"[",
"'streams'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadata",
"[",
"'streams'",
"]",
"as",
"$",
"streamIndex",
"=>",
"$",
"stream",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"stream",
"[",
"'codec_type'",
"]",
")",
"&&",
"$",
"stream",
"[",
"'codec_type'",
"]",
"===",
"\"audio\"",
")",
"{",
"return",
"$",
"streamIndex",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check our metadata for an audio stream.
@return boolean|int Int if video stream index found (CAN BE 0), false if none
|
[
"Check",
"our",
"metadata",
"for",
"an",
"audio",
"stream",
"."
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L135-L149
|
21,938
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.lead3GP
|
protected function lead3GP()
{
$lead = $this->ffprobeFormat("3gp");
if ($lead === true)
{
return $this->closeCase("3gp", "video/3gp", $this->metadata);
}
return null;
}
|
php
|
protected function lead3GP()
{
$lead = $this->ffprobeFormat("3gp");
if ($lead === true)
{
return $this->closeCase("3gp", "video/3gp", $this->metadata);
}
return null;
}
|
[
"protected",
"function",
"lead3GP",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"3gp\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"3gp\"",
",",
"\"video/3gp\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Checks if the file is a 3GP.
@return boolean|null
|
[
"Checks",
"if",
"the",
"file",
"is",
"a",
"3GP",
"."
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L156-L166
|
21,939
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.leadAAC
|
protected function leadAAC()
{
$lead = $this->ffprobeFormat("aac");
if ($lead === true)
{
return $this->closeCase("aac", "audio/aac", $this->metadata);
}
return null;
}
|
php
|
protected function leadAAC()
{
$lead = $this->ffprobeFormat("aac");
if ($lead === true)
{
return $this->closeCase("aac", "audio/aac", $this->metadata);
}
return null;
}
|
[
"protected",
"function",
"leadAAC",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"aac\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"aac\"",
",",
"\"audio/aac\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Checks if the file is a AAC
@return boolean|null
|
[
"Checks",
"if",
"the",
"file",
"is",
"a",
"AAC"
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L173-L183
|
21,940
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.leadFLV
|
protected function leadFLV()
{
$lead = $this->ffprobeFormat("flv");
if ($lead === true)
{
return $this->closeCase("flv", "video/x-flv", $this->metadata);
}
return null;
}
|
php
|
protected function leadFLV()
{
$lead = $this->ffprobeFormat("flv");
if ($lead === true)
{
return $this->closeCase("flv", "video/x-flv", $this->metadata);
}
return null;
}
|
[
"protected",
"function",
"leadFLV",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"flv\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"flv\"",
",",
"\"video/x-flv\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Checks if the file is a FLV.
@return boolean|null
|
[
"Checks",
"if",
"the",
"file",
"is",
"a",
"FLV",
"."
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L190-L200
|
21,941
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.leadMP3
|
protected function leadMP3()
{
$lead = $this->ffprobeFormat("mp1", "mp2", "mp3", "mpg", "mpeg");
if ($lead === true)
{
return $this->closeCase("mp3", "audio/mpeg", $this->metadata);
}
return null;
}
|
php
|
protected function leadMP3()
{
$lead = $this->ffprobeFormat("mp1", "mp2", "mp3", "mpg", "mpeg");
if ($lead === true)
{
return $this->closeCase("mp3", "audio/mpeg", $this->metadata);
}
return null;
}
|
[
"protected",
"function",
"leadMP3",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"mp1\"",
",",
"\"mp2\"",
",",
"\"mp3\"",
",",
"\"mpg\"",
",",
"\"mpeg\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"mp3\"",
",",
"\"audio/mpeg\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Checks if the file is a MP3
@return boolean|null
|
[
"Checks",
"if",
"the",
"file",
"is",
"a",
"MP3"
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L207-L217
|
21,942
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.leadMP4
|
protected function leadMP4()
{
$lead = $this->ffprobeFormat("mp4", "m4a");
if ($lead === true)
{
if ($this->ffprobeHasVideo() !== false)
{
return $this->closeCase("mp4", "video/mp4", $this->metadata);
}
else if ($this->ffprobeHasAudio() !== false)
{
return $this->closeCase("mp4", "audio/mp4", $this->metadata);
}
else
{
return false;
}
}
return null;
}
|
php
|
protected function leadMP4()
{
$lead = $this->ffprobeFormat("mp4", "m4a");
if ($lead === true)
{
if ($this->ffprobeHasVideo() !== false)
{
return $this->closeCase("mp4", "video/mp4", $this->metadata);
}
else if ($this->ffprobeHasAudio() !== false)
{
return $this->closeCase("mp4", "audio/mp4", $this->metadata);
}
else
{
return false;
}
}
return null;
}
|
[
"protected",
"function",
"leadMP4",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"mp4\"",
",",
"\"m4a\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ffprobeHasVideo",
"(",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"mp4\"",
",",
"\"video/mp4\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"ffprobeHasAudio",
"(",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"mp4\"",
",",
"\"audio/mp4\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Checks if the file is a MP4.
@return boolean|null
|
[
"Checks",
"if",
"the",
"file",
"is",
"a",
"MP4",
"."
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L224-L245
|
21,943
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.leadMKA
|
protected function leadMKA()
{
$lead = $this->ffprobeFormat("matroska", "webm");
if ($lead === true)
{
if ($this->ffprobeHasAudio() !== false)
{
return $this->closeCase("mka", "audio/x-matroska", $this->metadata);
}
else
{
return false;
}
}
return null;
}
|
php
|
protected function leadMKA()
{
$lead = $this->ffprobeFormat("matroska", "webm");
if ($lead === true)
{
if ($this->ffprobeHasAudio() !== false)
{
return $this->closeCase("mka", "audio/x-matroska", $this->metadata);
}
else
{
return false;
}
}
return null;
}
|
[
"protected",
"function",
"leadMKA",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"matroska\"",
",",
"\"webm\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ffprobeHasAudio",
"(",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"mka\"",
",",
"\"audio/x-matroska\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Checks if the file is a MKA.
@return boolean|null
|
[
"Checks",
"if",
"the",
"file",
"is",
"a",
"MKA",
"."
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L252-L269
|
21,944
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.leadMKV
|
protected function leadMKV()
{
$lead = $this->ffprobeFormat("matroska", "webm");
if ($lead === true)
{
if ($this->ffprobeHasVideo() !== false)
{
return $this->closeCase("mkv", "video/x-matroska", $this->metadata);
}
else
{
return false;
}
}
return null;
}
|
php
|
protected function leadMKV()
{
$lead = $this->ffprobeFormat("matroska", "webm");
if ($lead === true)
{
if ($this->ffprobeHasVideo() !== false)
{
return $this->closeCase("mkv", "video/x-matroska", $this->metadata);
}
else
{
return false;
}
}
return null;
}
|
[
"protected",
"function",
"leadMKV",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"matroska\"",
",",
"\"webm\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ffprobeHasVideo",
"(",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"mkv\"",
",",
"\"video/x-matroska\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Checks if the file is a MKV.
@return boolean|null
|
[
"Checks",
"if",
"the",
"file",
"is",
"a",
"MKV",
"."
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L276-L293
|
21,945
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.leadWAV
|
protected function leadWAV()
{
$lead = $this->ffprobeFormat("wav");
if ($lead === true)
{
return $this->closeCase("wav", "audio/wave", $this->metadata);
}
return null;
}
|
php
|
protected function leadWAV()
{
$lead = $this->ffprobeFormat("wav");
if ($lead === true)
{
return $this->closeCase("wav", "audio/wave", $this->metadata);
}
return null;
}
|
[
"protected",
"function",
"leadWAV",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"wav\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"wav\"",
",",
"\"audio/wave\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Checks if the file is a WAV
@return boolean|null
|
[
"Checks",
"if",
"the",
"file",
"is",
"a",
"WAV"
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L328-L338
|
21,946
|
infinity-next/sleuth
|
src/Detectives/ffmpegDetective.php
|
ffmpegDetective.on
|
public static function on()
{
static::fetchBinaries();
return (empty(static::$ffmpeg) ? false : true) && (empty(static::$ffprobe) ? false : true);
}
|
php
|
public static function on()
{
static::fetchBinaries();
return (empty(static::$ffmpeg) ? false : true) && (empty(static::$ffprobe) ? false : true);
}
|
[
"public",
"static",
"function",
"on",
"(",
")",
"{",
"static",
"::",
"fetchBinaries",
"(",
")",
";",
"return",
"(",
"empty",
"(",
"static",
"::",
"$",
"ffmpeg",
")",
"?",
"false",
":",
"true",
")",
"&&",
"(",
"empty",
"(",
"static",
"::",
"$",
"ffprobe",
")",
"?",
"false",
":",
"true",
")",
";",
"}"
] |
Can the system run this Detective?
@return boolean True if we can run, False if not.
|
[
"Can",
"the",
"system",
"run",
"this",
"Detective?"
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L406-L410
|
21,947
|
eXistenZNL/PermCheck
|
src/Message/Bag.php
|
Bag.addMessage
|
public function addMessage($message, $type)
{
if (!is_string($message)) {
throw new \InvalidArgumentException('Message must be a string');
}
if (!$message) {
throw new \InvalidArgumentException('Message can\'t be empty');
}
if (!is_string($type)) {
throw new \InvalidArgumentException('Type must be a string');
}
if (!$type) {
throw new \InvalidArgumentException('Type can\'t be empty');
}
$this->messages[$type][] = $message;
return $this;
}
|
php
|
public function addMessage($message, $type)
{
if (!is_string($message)) {
throw new \InvalidArgumentException('Message must be a string');
}
if (!$message) {
throw new \InvalidArgumentException('Message can\'t be empty');
}
if (!is_string($type)) {
throw new \InvalidArgumentException('Type must be a string');
}
if (!$type) {
throw new \InvalidArgumentException('Type can\'t be empty');
}
$this->messages[$type][] = $message;
return $this;
}
|
[
"public",
"function",
"addMessage",
"(",
"$",
"message",
",",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"message",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Message must be a string'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"message",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Message can\\'t be empty'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Type must be a string'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"type",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Type can\\'t be empty'",
")",
";",
"}",
"$",
"this",
"->",
"messages",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"message",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a message to this message bag.
@param string $message The message to add.
@param string $type The type of message to add.
@throws \InvalidArgumentException When the provided data is incorrect.
@return Bag
|
[
"Add",
"a",
"message",
"to",
"this",
"message",
"bag",
"."
] |
f22f2936350f6b440222fb6ea37dfc382fc4550e
|
https://github.com/eXistenZNL/PermCheck/blob/f22f2936350f6b440222fb6ea37dfc382fc4550e/src/Message/Bag.php#L21-L38
|
21,948
|
inhere/php-librarys
|
src/Helpers/Cli.php
|
Cli.write
|
public static function write($message, $nl = true, $quit = false)
{
if (\is_array($message)) {
$message = implode($nl ? PHP_EOL : '', $message);
}
self::stdout(self::renderColor($message), $nl, $quit);
}
|
php
|
public static function write($message, $nl = true, $quit = false)
{
if (\is_array($message)) {
$message = implode($nl ? PHP_EOL : '', $message);
}
self::stdout(self::renderColor($message), $nl, $quit);
}
|
[
"public",
"static",
"function",
"write",
"(",
"$",
"message",
",",
"$",
"nl",
"=",
"true",
",",
"$",
"quit",
"=",
"false",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"message",
")",
")",
"{",
"$",
"message",
"=",
"implode",
"(",
"$",
"nl",
"?",
"PHP_EOL",
":",
"''",
",",
"$",
"message",
")",
";",
"}",
"self",
"::",
"stdout",
"(",
"self",
"::",
"renderColor",
"(",
"$",
"message",
")",
",",
"$",
"nl",
",",
"$",
"quit",
")",
";",
"}"
] |
write message to console
@param $message
@param bool $nl
@param bool $quit
|
[
"write",
"message",
"to",
"console"
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/Cli.php#L206-L213
|
21,949
|
OpenClassrooms/Cache
|
src/OpenClassrooms/Cache/Cache/CacheImpl.php
|
CacheImpl.invalidate
|
public function invalidate($namespaceId)
{
$namespace = $this->fetch($namespaceId);
if (false === $namespace) {
return false;
}
$newNamespace = rand(0, 10000);
// @codeCoverageIgnoreStart
while ($namespace === $newNamespace) {
$newNamespace = rand(0, 10000);
}
// @codeCoverageIgnoreEnd
return $this->save($namespaceId, $namespaceId . '_' . $newNamespace .'_', 0);
}
|
php
|
public function invalidate($namespaceId)
{
$namespace = $this->fetch($namespaceId);
if (false === $namespace) {
return false;
}
$newNamespace = rand(0, 10000);
// @codeCoverageIgnoreStart
while ($namespace === $newNamespace) {
$newNamespace = rand(0, 10000);
}
// @codeCoverageIgnoreEnd
return $this->save($namespaceId, $namespaceId . '_' . $newNamespace .'_', 0);
}
|
[
"public",
"function",
"invalidate",
"(",
"$",
"namespaceId",
")",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"namespaceId",
")",
";",
"if",
"(",
"false",
"===",
"$",
"namespace",
")",
"{",
"return",
"false",
";",
"}",
"$",
"newNamespace",
"=",
"rand",
"(",
"0",
",",
"10000",
")",
";",
"// @codeCoverageIgnoreStart",
"while",
"(",
"$",
"namespace",
"===",
"$",
"newNamespace",
")",
"{",
"$",
"newNamespace",
"=",
"rand",
"(",
"0",
",",
"10000",
")",
";",
"}",
"// @codeCoverageIgnoreEnd",
"return",
"$",
"this",
"->",
"save",
"(",
"$",
"namespaceId",
",",
"$",
"namespaceId",
".",
"'_'",
".",
"$",
"newNamespace",
".",
"'_'",
",",
"0",
")",
";",
"}"
] |
Invalidate a namespace.
@param string $namespaceId The id of the namespace to invalidate.
@return boolean TRUE if the namespace entry was successfully regenerated, FALSE otherwise.
|
[
"Invalidate",
"a",
"namespace",
"."
] |
7e7bdfd1b1503384f59ff6d5d29ba741a0e18ad6
|
https://github.com/OpenClassrooms/Cache/blob/7e7bdfd1b1503384f59ff6d5d29ba741a0e18ad6/src/OpenClassrooms/Cache/Cache/CacheImpl.php#L122-L138
|
21,950
|
titledk/silverstripe-uploaddirrules
|
code/AssetsFolderExtension.php
|
AssetsFolderExtension.findOrMakeAssetsFolder
|
public function findOrMakeAssetsFolder($url, $doWrite = true)
{
$owner = $this->owner;
$dir = Folder::find_or_make($url);
$owner->AssetsFolderID = $dir->ID;
if ($doWrite) {
$owner->write();
}
//Special case for when creating a new subsite
//the directory will need to be associated with the subsite
if ($owner->ClassName == 'Subsite') {
$dir->SubsiteID = $owner->ID;
$dir->write();
}
return $dir;
}
|
php
|
public function findOrMakeAssetsFolder($url, $doWrite = true)
{
$owner = $this->owner;
$dir = Folder::find_or_make($url);
$owner->AssetsFolderID = $dir->ID;
if ($doWrite) {
$owner->write();
}
//Special case for when creating a new subsite
//the directory will need to be associated with the subsite
if ($owner->ClassName == 'Subsite') {
$dir->SubsiteID = $owner->ID;
$dir->write();
}
return $dir;
}
|
[
"public",
"function",
"findOrMakeAssetsFolder",
"(",
"$",
"url",
",",
"$",
"doWrite",
"=",
"true",
")",
"{",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"dir",
"=",
"Folder",
"::",
"find_or_make",
"(",
"$",
"url",
")",
";",
"$",
"owner",
"->",
"AssetsFolderID",
"=",
"$",
"dir",
"->",
"ID",
";",
"if",
"(",
"$",
"doWrite",
")",
"{",
"$",
"owner",
"->",
"write",
"(",
")",
";",
"}",
"//Special case for when creating a new subsite",
"//the directory will need to be associated with the subsite",
"if",
"(",
"$",
"owner",
"->",
"ClassName",
"==",
"'Subsite'",
")",
"{",
"$",
"dir",
"->",
"SubsiteID",
"=",
"$",
"owner",
"->",
"ID",
";",
"$",
"dir",
"->",
"write",
"(",
")",
";",
"}",
"return",
"$",
"dir",
";",
"}"
] |
Find or make assets folder
called from onBeforeWrite.
@param string $url
@param bool $doWrite
@return Folder|null
|
[
"Find",
"or",
"make",
"assets",
"folder",
"called",
"from",
"onBeforeWrite",
"."
] |
ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c
|
https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/AssetsFolderExtension.php#L89-L106
|
21,951
|
titledk/silverstripe-uploaddirrules
|
code/AssetsFolderExtension.php
|
AssetsFolderExtension.getAssetsFolderDirName
|
public function getAssetsFolderDirName()
{
if ($this->owner->getField('AssetsFolderID') != 0) {
$dirObj = $this->owner->AssetsFolder();
$dirName = str_replace('assets/', '', $dirObj->Filename);
return $dirName;
}
}
|
php
|
public function getAssetsFolderDirName()
{
if ($this->owner->getField('AssetsFolderID') != 0) {
$dirObj = $this->owner->AssetsFolder();
$dirName = str_replace('assets/', '', $dirObj->Filename);
return $dirName;
}
}
|
[
"public",
"function",
"getAssetsFolderDirName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"getField",
"(",
"'AssetsFolderID'",
")",
"!=",
"0",
")",
"{",
"$",
"dirObj",
"=",
"$",
"this",
"->",
"owner",
"->",
"AssetsFolder",
"(",
")",
";",
"$",
"dirName",
"=",
"str_replace",
"(",
"'assets/'",
",",
"''",
",",
"$",
"dirObj",
"->",
"Filename",
")",
";",
"return",
"$",
"dirName",
";",
"}",
"}"
] |
Name of the associated assets folder.
@return string|null
|
[
"Name",
"of",
"the",
"associated",
"assets",
"folder",
"."
] |
ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c
|
https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/AssetsFolderExtension.php#L113-L121
|
21,952
|
simbiosis-group/yii2-helper
|
actions/CreateAction.php
|
CreateAction.assignDefaultValues
|
protected function assignDefaultValues()
{
foreach ($this->defaultValues as $key => $value) {
$this->model[$key] = $value;
}
return true;
}
|
php
|
protected function assignDefaultValues()
{
foreach ($this->defaultValues as $key => $value) {
$this->model[$key] = $value;
}
return true;
}
|
[
"protected",
"function",
"assignDefaultValues",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"defaultValues",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"model",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"true",
";",
"}"
] |
Assign default values to model.
@return boolean
|
[
"Assign",
"default",
"values",
"to",
"model",
"."
] |
c85c4204dd06b16e54210e75fe6deb51869d1dd9
|
https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/actions/CreateAction.php#L158-L165
|
21,953
|
WellCommerce/AppBundle
|
Form/Admin/PackageFormBuilder.php
|
PackageFormBuilder.getPackageVersions
|
protected function getPackageVersions($id)
{
$localPackage = $this->get('package.repository')->findOneById($id);
$remotePackage = $this->get('package.helper')->getPackage($localPackage->getFullName());
$versions = $remotePackage->getVersions();
$result = [];
foreach ($versions as $version) {
$this->getPackageInfo($version, $result);
}
return $result;
}
|
php
|
protected function getPackageVersions($id)
{
$localPackage = $this->get('package.repository')->findOneById($id);
$remotePackage = $this->get('package.helper')->getPackage($localPackage->getFullName());
$versions = $remotePackage->getVersions();
$result = [];
foreach ($versions as $version) {
$this->getPackageInfo($version, $result);
}
return $result;
}
|
[
"protected",
"function",
"getPackageVersions",
"(",
"$",
"id",
")",
"{",
"$",
"localPackage",
"=",
"$",
"this",
"->",
"get",
"(",
"'package.repository'",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"$",
"remotePackage",
"=",
"$",
"this",
"->",
"get",
"(",
"'package.helper'",
")",
"->",
"getPackage",
"(",
"$",
"localPackage",
"->",
"getFullName",
"(",
")",
")",
";",
"$",
"versions",
"=",
"$",
"remotePackage",
"->",
"getVersions",
"(",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"versions",
"as",
"$",
"version",
")",
"{",
"$",
"this",
"->",
"getPackageInfo",
"(",
"$",
"version",
",",
"$",
"result",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns version information for package
@param $id
@return array
|
[
"Returns",
"version",
"information",
"for",
"package"
] |
2add687d1c898dd0b24afd611d896e3811a0eac3
|
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Form/Admin/PackageFormBuilder.php#L83-L95
|
21,954
|
WellCommerce/AppBundle
|
Form/Admin/PackageFormBuilder.php
|
PackageFormBuilder.getPackageInfo
|
protected function getPackageInfo(Version $version, &$result)
{
$date = new \DateTime($version->getTime());
$packageVersion = $version->getVersion();
if ($packageVersion === PackageHelperInterface::DEFAULT_BRANCH_VERSION) {
$result[$packageVersion] = [
'version' => $packageVersion,
'date' => $date->format('Y-m-d H:i:s'),
'authors' => $version->getAuthors(),
'description' => $version->getDescription(),
'homepage' => $version->getHomepage(),
'license' => $version->getLicense(),
];
}
}
|
php
|
protected function getPackageInfo(Version $version, &$result)
{
$date = new \DateTime($version->getTime());
$packageVersion = $version->getVersion();
if ($packageVersion === PackageHelperInterface::DEFAULT_BRANCH_VERSION) {
$result[$packageVersion] = [
'version' => $packageVersion,
'date' => $date->format('Y-m-d H:i:s'),
'authors' => $version->getAuthors(),
'description' => $version->getDescription(),
'homepage' => $version->getHomepage(),
'license' => $version->getLicense(),
];
}
}
|
[
"protected",
"function",
"getPackageInfo",
"(",
"Version",
"$",
"version",
",",
"&",
"$",
"result",
")",
"{",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"version",
"->",
"getTime",
"(",
")",
")",
";",
"$",
"packageVersion",
"=",
"$",
"version",
"->",
"getVersion",
"(",
")",
";",
"if",
"(",
"$",
"packageVersion",
"===",
"PackageHelperInterface",
"::",
"DEFAULT_BRANCH_VERSION",
")",
"{",
"$",
"result",
"[",
"$",
"packageVersion",
"]",
"=",
"[",
"'version'",
"=>",
"$",
"packageVersion",
",",
"'date'",
"=>",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
",",
"'authors'",
"=>",
"$",
"version",
"->",
"getAuthors",
"(",
")",
",",
"'description'",
"=>",
"$",
"version",
"->",
"getDescription",
"(",
")",
",",
"'homepage'",
"=>",
"$",
"version",
"->",
"getHomepage",
"(",
")",
",",
"'license'",
"=>",
"$",
"version",
"->",
"getLicense",
"(",
")",
",",
"]",
";",
"}",
"}"
] |
Adds information about single version to result array
@param Version $version
@param array $result
|
[
"Adds",
"information",
"about",
"single",
"version",
"to",
"result",
"array"
] |
2add687d1c898dd0b24afd611d896e3811a0eac3
|
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Form/Admin/PackageFormBuilder.php#L103-L117
|
21,955
|
surebert/surebert-framework
|
src/sb/Password/Hash.php
|
Hash.create
|
public static function create($password) {
// format: algorithm:iterations:salt:hash
if(function_exists('random_bytes')){
$salt = random_bytes(self::$salt_byte_size);
} else if(function_exists('openssl_random_pseudo_bytes')){
$salt = openssl_random_pseudo_bytes(self::$salt_byte_size);
} else if(function_exists('mcrypt_create_iv')){
$salt = mcrypt_create_iv(self::$salt_byte_size, MCRYPT_DEV_URANDOM);
} else {
throw(new Exception("You must have random_bytes, openssl_random_pseudo_bytes or mcrypt_create_iv function available to create salt"));
}
$salt = base64_encode($salt);
return self::$hash_algorithm . ":" . self::$iterations . ":" . $salt . ":" .
base64_encode(self::calculate(
self::$hash_algorithm, $password, $salt, self::$iterations, self::$hash_byte_size, true
));
}
|
php
|
public static function create($password) {
// format: algorithm:iterations:salt:hash
if(function_exists('random_bytes')){
$salt = random_bytes(self::$salt_byte_size);
} else if(function_exists('openssl_random_pseudo_bytes')){
$salt = openssl_random_pseudo_bytes(self::$salt_byte_size);
} else if(function_exists('mcrypt_create_iv')){
$salt = mcrypt_create_iv(self::$salt_byte_size, MCRYPT_DEV_URANDOM);
} else {
throw(new Exception("You must have random_bytes, openssl_random_pseudo_bytes or mcrypt_create_iv function available to create salt"));
}
$salt = base64_encode($salt);
return self::$hash_algorithm . ":" . self::$iterations . ":" . $salt . ":" .
base64_encode(self::calculate(
self::$hash_algorithm, $password, $salt, self::$iterations, self::$hash_byte_size, true
));
}
|
[
"public",
"static",
"function",
"create",
"(",
"$",
"password",
")",
"{",
"// format: algorithm:iterations:salt:hash",
"if",
"(",
"function_exists",
"(",
"'random_bytes'",
")",
")",
"{",
"$",
"salt",
"=",
"random_bytes",
"(",
"self",
"::",
"$",
"salt_byte_size",
")",
";",
"}",
"else",
"if",
"(",
"function_exists",
"(",
"'openssl_random_pseudo_bytes'",
")",
")",
"{",
"$",
"salt",
"=",
"openssl_random_pseudo_bytes",
"(",
"self",
"::",
"$",
"salt_byte_size",
")",
";",
"}",
"else",
"if",
"(",
"function_exists",
"(",
"'mcrypt_create_iv'",
")",
")",
"{",
"$",
"salt",
"=",
"mcrypt_create_iv",
"(",
"self",
"::",
"$",
"salt_byte_size",
",",
"MCRYPT_DEV_URANDOM",
")",
";",
"}",
"else",
"{",
"throw",
"(",
"new",
"Exception",
"(",
"\"You must have random_bytes, openssl_random_pseudo_bytes or mcrypt_create_iv function available to create salt\"",
")",
")",
";",
"}",
"$",
"salt",
"=",
"base64_encode",
"(",
"$",
"salt",
")",
";",
"return",
"self",
"::",
"$",
"hash_algorithm",
".",
"\":\"",
".",
"self",
"::",
"$",
"iterations",
".",
"\":\"",
".",
"$",
"salt",
".",
"\":\"",
".",
"base64_encode",
"(",
"self",
"::",
"calculate",
"(",
"self",
"::",
"$",
"hash_algorithm",
",",
"$",
"password",
",",
"$",
"salt",
",",
"self",
"::",
"$",
"iterations",
",",
"self",
"::",
"$",
"hash_byte_size",
",",
"true",
")",
")",
";",
"}"
] |
Creates the password hash that you would store for comparison.
Make sure to check the size of the output when creating database tables
to store this hash. The defaults produce a 94 char string. Changing the
public static properties may affect the size of the hash returned.
@param string $password
@return string The hash
<code>
$hash = \sb\Password\Hash::create('password');
</code>
|
[
"Creates",
"the",
"password",
"hash",
"that",
"you",
"would",
"store",
"for",
"comparison",
".",
"Make",
"sure",
"to",
"check",
"the",
"size",
"of",
"the",
"output",
"when",
"creating",
"database",
"tables",
"to",
"store",
"this",
"hash",
".",
"The",
"defaults",
"produce",
"a",
"94",
"char",
"string",
".",
"Changing",
"the",
"public",
"static",
"properties",
"may",
"affect",
"the",
"size",
"of",
"the",
"hash",
"returned",
"."
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Password/Hash.php#L112-L129
|
21,956
|
surebert/surebert-framework
|
src/sb/Password/Hash.php
|
Hash.validate
|
public static function validate($password, $hash) {
$params = explode(":", $hash);
if (count($params) < 4)
return false;
$pbkdf2 = base64_decode($params[self::$hash_pbkdf2_index]);
return self::slowEquals(
$pbkdf2, self::calculate(
$params[self::$hash_alogrithm_index], $password, $params[self::$hash_salt_index], (int) $params[self::$hash_iteration_index], strlen($pbkdf2), true
)
);
}
|
php
|
public static function validate($password, $hash) {
$params = explode(":", $hash);
if (count($params) < 4)
return false;
$pbkdf2 = base64_decode($params[self::$hash_pbkdf2_index]);
return self::slowEquals(
$pbkdf2, self::calculate(
$params[self::$hash_alogrithm_index], $password, $params[self::$hash_salt_index], (int) $params[self::$hash_iteration_index], strlen($pbkdf2), true
)
);
}
|
[
"public",
"static",
"function",
"validate",
"(",
"$",
"password",
",",
"$",
"hash",
")",
"{",
"$",
"params",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"hash",
")",
";",
"if",
"(",
"count",
"(",
"$",
"params",
")",
"<",
"4",
")",
"return",
"false",
";",
"$",
"pbkdf2",
"=",
"base64_decode",
"(",
"$",
"params",
"[",
"self",
"::",
"$",
"hash_pbkdf2_index",
"]",
")",
";",
"return",
"self",
"::",
"slowEquals",
"(",
"$",
"pbkdf2",
",",
"self",
"::",
"calculate",
"(",
"$",
"params",
"[",
"self",
"::",
"$",
"hash_alogrithm_index",
"]",
",",
"$",
"password",
",",
"$",
"params",
"[",
"self",
"::",
"$",
"hash_salt_index",
"]",
",",
"(",
"int",
")",
"$",
"params",
"[",
"self",
"::",
"$",
"hash_iteration_index",
"]",
",",
"strlen",
"(",
"$",
"pbkdf2",
")",
",",
"true",
")",
")",
";",
"}"
] |
Validates a password against its precalculated hash
@param string $password
@param string $hash
@return boolean
<code>
$bool = \sb\Password\Hash::validate('password', $hash_from_create);
</code>
|
[
"Validates",
"a",
"password",
"against",
"its",
"precalculated",
"hash"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Password/Hash.php#L140-L150
|
21,957
|
kenphp/ken
|
src/Helpers/Input.php
|
Input.get
|
public static function get($name = null, $default = null)
{
$queryParams = app()->request->getQueryParams();
if (is_null($name)) {
return $queryParams;
} elseif (isset($queryParams[$name])) {
return $queryParams[$name];
}
return $default;
}
|
php
|
public static function get($name = null, $default = null)
{
$queryParams = app()->request->getQueryParams();
if (is_null($name)) {
return $queryParams;
} elseif (isset($queryParams[$name])) {
return $queryParams[$name];
}
return $default;
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"queryParams",
"=",
"app",
"(",
")",
"->",
"request",
"->",
"getQueryParams",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"queryParams",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"queryParams",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"queryParams",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Retrieves GET parameter.
@param string $name Name of GET parameter, if null then all parameter will be returned
@param mixed $default Default value returned if *$name* is not null but does not exist in GET query parameters
@return mixed
|
[
"Retrieves",
"GET",
"parameter",
"."
] |
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
|
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Input.php#L17-L28
|
21,958
|
kenphp/ken
|
src/Helpers/Input.php
|
Input.delete
|
public static function delete($name = null, $default = null)
{
$parsedBody = app()->request->getParsedBody();
if (is_null($name)) {
return $parsedBody;
}
if (isset($parsedBody[$name])) {
return $parsedBody[$name];
}
return $default;
}
|
php
|
public static function delete($name = null, $default = null)
{
$parsedBody = app()->request->getParsedBody();
if (is_null($name)) {
return $parsedBody;
}
if (isset($parsedBody[$name])) {
return $parsedBody[$name];
}
return $default;
}
|
[
"public",
"static",
"function",
"delete",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"parsedBody",
"=",
"app",
"(",
")",
"->",
"request",
"->",
"getParsedBody",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"parsedBody",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"parsedBody",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"parsedBody",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Retrieves DELETE parameter.
@param string $name Name of DELETE parameter, if null then all parameter will be returned
@param mixed $default Default value returned if *$name* is not null but does not exist in DELETE request
@return mixed
|
[
"Retrieves",
"DELETE",
"parameter",
"."
] |
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
|
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Input.php#L61-L74
|
21,959
|
kenphp/ken
|
src/Helpers/Input.php
|
Input.files
|
public static function files($name = null)
{
$files = app()->request->getUploadedFiles();
if (is_null($name)) {
return $files;
}
if (isset($files[$name])) {
return $files[$name];
}
return null;
}
|
php
|
public static function files($name = null)
{
$files = app()->request->getUploadedFiles();
if (is_null($name)) {
return $files;
}
if (isset($files[$name])) {
return $files[$name];
}
return null;
}
|
[
"public",
"static",
"function",
"files",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"files",
"=",
"app",
"(",
")",
"->",
"request",
"->",
"getUploadedFiles",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"files",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"files",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"files",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Retrieves Uploaded Files.
@param string $name Name of Uploaded Files parameter, if null then all value will be returned
@return \Psr\Http\Message\UploadedFileInterface|array|null
|
[
"Retrieves",
"Uploaded",
"Files",
"."
] |
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
|
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Input.php#L106-L119
|
21,960
|
petrica/php-statsd-system
|
Command/NotifyCommand.php
|
NotifyCommand.getStatsd
|
protected function getStatsd(InputInterface $input)
{
if (null === $this->statsd) {
$this->statsdConnection = new UdpSocket(
$input->getOption('statsd-host'),
$input->getOption('statsd-port')
);
$this->statsd = new Client(
$this->statsdConnection,
$input->getOption('statsd-namespace')
);
}
return $this->statsd;
}
|
php
|
protected function getStatsd(InputInterface $input)
{
if (null === $this->statsd) {
$this->statsdConnection = new UdpSocket(
$input->getOption('statsd-host'),
$input->getOption('statsd-port')
);
$this->statsd = new Client(
$this->statsdConnection,
$input->getOption('statsd-namespace')
);
}
return $this->statsd;
}
|
[
"protected",
"function",
"getStatsd",
"(",
"InputInterface",
"$",
"input",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"statsd",
")",
"{",
"$",
"this",
"->",
"statsdConnection",
"=",
"new",
"UdpSocket",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'statsd-host'",
")",
",",
"$",
"input",
"->",
"getOption",
"(",
"'statsd-port'",
")",
")",
";",
"$",
"this",
"->",
"statsd",
"=",
"new",
"Client",
"(",
"$",
"this",
"->",
"statsdConnection",
",",
"$",
"input",
"->",
"getOption",
"(",
"'statsd-namespace'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"statsd",
";",
"}"
] |
Statically cache statsd client and return a statsd client
@param InputInterface $input
@return Client
|
[
"Statically",
"cache",
"statsd",
"client",
"and",
"return",
"a",
"statsd",
"client"
] |
c476be3514a631a605737888bb8f6eb096789c9d
|
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Command/NotifyCommand.php#L134-L148
|
21,961
|
petrica/php-statsd-system
|
Command/NotifyCommand.php
|
NotifyCommand.getGauges
|
protected function getGauges($config)
{
if (null === $this->gauges) {
$this->gauges = array();
foreach ($config as $path => $details) {
$className = $details['class'];
if (class_exists($className)) {
$reflection = new \ReflectionClass($className);
if ($reflection->getConstructor()) {
$this->gauges[$path] = $reflection->newInstanceArgs(
$details['arguments'] ? $details['arguments'] : array());
}
else {
$this->gauges[$path] = $reflection->newInstance();
}
}
else {
throw new \RuntimeException(sprintf(
'Class does not exists %s'
), $className);
}
}
if (empty($this->gauges)) {
throw new \RuntimeException(
sprintf('No gauges found for provided string %s', $input->getArgument('gauges-class'))
);
}
}
return $this->gauges;
}
|
php
|
protected function getGauges($config)
{
if (null === $this->gauges) {
$this->gauges = array();
foreach ($config as $path => $details) {
$className = $details['class'];
if (class_exists($className)) {
$reflection = new \ReflectionClass($className);
if ($reflection->getConstructor()) {
$this->gauges[$path] = $reflection->newInstanceArgs(
$details['arguments'] ? $details['arguments'] : array());
}
else {
$this->gauges[$path] = $reflection->newInstance();
}
}
else {
throw new \RuntimeException(sprintf(
'Class does not exists %s'
), $className);
}
}
if (empty($this->gauges)) {
throw new \RuntimeException(
sprintf('No gauges found for provided string %s', $input->getArgument('gauges-class'))
);
}
}
return $this->gauges;
}
|
[
"protected",
"function",
"getGauges",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"gauges",
")",
"{",
"$",
"this",
"->",
"gauges",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"path",
"=>",
"$",
"details",
")",
"{",
"$",
"className",
"=",
"$",
"details",
"[",
"'class'",
"]",
";",
"if",
"(",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"if",
"(",
"$",
"reflection",
"->",
"getConstructor",
"(",
")",
")",
"{",
"$",
"this",
"->",
"gauges",
"[",
"$",
"path",
"]",
"=",
"$",
"reflection",
"->",
"newInstanceArgs",
"(",
"$",
"details",
"[",
"'arguments'",
"]",
"?",
"$",
"details",
"[",
"'arguments'",
"]",
":",
"array",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"gauges",
"[",
"$",
"path",
"]",
"=",
"$",
"reflection",
"->",
"newInstance",
"(",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Class does not exists %s'",
")",
",",
"$",
"className",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"gauges",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'No gauges found for provided string %s'",
",",
"$",
"input",
"->",
"getArgument",
"(",
"'gauges-class'",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"gauges",
";",
"}"
] |
Instantiate selected gauges
@param array $config
@return GaugeInterface[] array
|
[
"Instantiate",
"selected",
"gauges"
] |
c476be3514a631a605737888bb8f6eb096789c9d
|
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Command/NotifyCommand.php#L166-L199
|
21,962
|
ClementIV/yii-rest-rbac2.0
|
controllers/RuleController.php
|
RuleController.actionCheckname
|
public function actionCheckname(){
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['checkname']);
}
$model = new BizRule(null);
$mo =$model->find(Yii::$app->request->post()['BizRule']['name']);
if($mo==null){
return ['message'=>true];
}else{
return ['message'=>false];
}
}
|
php
|
public function actionCheckname(){
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['checkname']);
}
$model = new BizRule(null);
$mo =$model->find(Yii::$app->request->post()['BizRule']['name']);
if($mo==null){
return ['message'=>true];
}else{
return ['message'=>false];
}
}
|
[
"public",
"function",
"actionCheckname",
"(",
")",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'checkname'",
"]",
")",
";",
"}",
"$",
"model",
"=",
"new",
"BizRule",
"(",
"null",
")",
";",
"$",
"mo",
"=",
"$",
"model",
"->",
"find",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
"[",
"'BizRule'",
"]",
"[",
"'name'",
"]",
")",
";",
"if",
"(",
"$",
"mo",
"==",
"null",
")",
"{",
"return",
"[",
"'message'",
"=>",
"true",
"]",
";",
"}",
"else",
"{",
"return",
"[",
"'message'",
"=>",
"false",
"]",
";",
"}",
"}"
] |
check is a new item
@return boolan
|
[
"check",
"is",
"a",
"new",
"item"
] |
435ffceca8d51b4d369182db3a06c20f336e9ac4
|
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/RuleController.php#L99-L112
|
21,963
|
NuclearCMS/Hierarchy
|
src/Support/TokenManager.php
|
TokenManager.setToken
|
public function setToken($key, $value, $duration = 60)
{
$this->cache->put('reactor.tokens.' . $key, $value, $duration);
}
|
php
|
public function setToken($key, $value, $duration = 60)
{
$this->cache->put('reactor.tokens.' . $key, $value, $duration);
}
|
[
"public",
"function",
"setToken",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"duration",
"=",
"60",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"put",
"(",
"'reactor.tokens.'",
".",
"$",
"key",
",",
"$",
"value",
",",
"$",
"duration",
")",
";",
"}"
] |
Setter for token
@param string $key
@param string $value
@param int $duration
|
[
"Setter",
"for",
"token"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/TokenManager.php#L47-L50
|
21,964
|
NuclearCMS/Hierarchy
|
src/Support/TokenManager.php
|
TokenManager.makeNewToken
|
public function makeNewToken($key, $duration = 60)
{
$token = str_random(32);
$this->setToken($key, $token, $duration);
return $token;
}
|
php
|
public function makeNewToken($key, $duration = 60)
{
$token = str_random(32);
$this->setToken($key, $token, $duration);
return $token;
}
|
[
"public",
"function",
"makeNewToken",
"(",
"$",
"key",
",",
"$",
"duration",
"=",
"60",
")",
"{",
"$",
"token",
"=",
"str_random",
"(",
"32",
")",
";",
"$",
"this",
"->",
"setToken",
"(",
"$",
"key",
",",
"$",
"token",
",",
"$",
"duration",
")",
";",
"return",
"$",
"token",
";",
"}"
] |
Creates a new token and returns it
@param string $key
@param int $duration
@return string
|
[
"Creates",
"a",
"new",
"token",
"and",
"returns",
"it"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/TokenManager.php#L59-L66
|
21,965
|
NuclearCMS/Hierarchy
|
src/Support/TokenManager.php
|
TokenManager.requestHasToken
|
public function requestHasToken($key)
{
$token = $this->request->input($key, null);
if($token && $token === $this->getToken($key))
{
return true;
}
return false;
}
|
php
|
public function requestHasToken($key)
{
$token = $this->request->input($key, null);
if($token && $token === $this->getToken($key))
{
return true;
}
return false;
}
|
[
"public",
"function",
"requestHasToken",
"(",
"$",
"key",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"request",
"->",
"input",
"(",
"$",
"key",
",",
"null",
")",
";",
"if",
"(",
"$",
"token",
"&&",
"$",
"token",
"===",
"$",
"this",
"->",
"getToken",
"(",
"$",
"key",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if the request has the token
@param string $key
@return bool
|
[
"Checks",
"if",
"the",
"request",
"has",
"the",
"token"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/TokenManager.php#L74-L84
|
21,966
|
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Order.php
|
Order.setOrderStatusDetail
|
public function setOrderStatusDetail(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\OrderStatusDetail $orderStatusDetail = null)
{
$this->order_status_detail = $orderStatusDetail;
return $this;
}
|
php
|
public function setOrderStatusDetail(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\OrderStatusDetail $orderStatusDetail = null)
{
$this->order_status_detail = $orderStatusDetail;
return $this;
}
|
[
"public",
"function",
"setOrderStatusDetail",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"OrderStatusDetail",
"$",
"orderStatusDetail",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"order_status_detail",
"=",
"$",
"orderStatusDetail",
";",
"return",
"$",
"this",
";",
"}"
] |
Set orderStatusDetail.
@param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\OrderStatusDetail $orderStatusDetail
@return Order
|
[
"Set",
"orderStatusDetail",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L714-L719
|
21,967
|
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Order.php
|
Order.setCustomer
|
public function setCustomer(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\Customer $customer = null)
{
$this->customer = $customer;
return $this;
}
|
php
|
public function setCustomer(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\Customer $customer = null)
{
$this->customer = $customer;
return $this;
}
|
[
"public",
"function",
"setCustomer",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Customer",
"\\",
"Customer",
"$",
"customer",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"customer",
"=",
"$",
"customer",
";",
"return",
"$",
"this",
";",
"}"
] |
Set customer.
@param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\Customer $customer
@return Order
|
[
"Set",
"customer",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L738-L743
|
21,968
|
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Order.php
|
Order.setTrading
|
public function setTrading(\Gpupo\CommonSchema\ORM\Entity\Trading\Trading $trading = null)
{
$this->trading = $trading;
return $this;
}
|
php
|
public function setTrading(\Gpupo\CommonSchema\ORM\Entity\Trading\Trading $trading = null)
{
$this->trading = $trading;
return $this;
}
|
[
"public",
"function",
"setTrading",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Trading",
"$",
"trading",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"trading",
"=",
"$",
"trading",
";",
"return",
"$",
"this",
";",
"}"
] |
Set trading.
@param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Trading $trading
@return Order
|
[
"Set",
"trading",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L762-L767
|
21,969
|
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Order.php
|
Order.addShipping
|
public function addShipping(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping)
{
$this->shippings[] = $shipping;
return $this;
}
|
php
|
public function addShipping(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping)
{
$this->shippings[] = $shipping;
return $this;
}
|
[
"public",
"function",
"addShipping",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Shipping",
"$",
"shipping",
")",
"{",
"$",
"this",
"->",
"shippings",
"[",
"]",
"=",
"$",
"shipping",
";",
"return",
"$",
"this",
";",
"}"
] |
Add shipping.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping
@return Order
|
[
"Add",
"shipping",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L786-L791
|
21,970
|
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Order.php
|
Order.removeShipping
|
public function removeShipping(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping)
{
return $this->shippings->removeElement($shipping);
}
|
php
|
public function removeShipping(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping)
{
return $this->shippings->removeElement($shipping);
}
|
[
"public",
"function",
"removeShipping",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Shipping",
"$",
"shipping",
")",
"{",
"return",
"$",
"this",
"->",
"shippings",
"->",
"removeElement",
"(",
"$",
"shipping",
")",
";",
"}"
] |
Remove shipping.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping
@return bool TRUE if this collection contained the specified element, FALSE otherwise
|
[
"Remove",
"shipping",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L800-L803
|
21,971
|
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Order.php
|
Order.removeFeedback
|
public function removeFeedback(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Feedback\Feedback $feedback)
{
return $this->feedbacks->removeElement($feedback);
}
|
php
|
public function removeFeedback(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Feedback\Feedback $feedback)
{
return $this->feedbacks->removeElement($feedback);
}
|
[
"public",
"function",
"removeFeedback",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Feedback",
"\\",
"Feedback",
"$",
"feedback",
")",
"{",
"return",
"$",
"this",
"->",
"feedbacks",
"->",
"removeElement",
"(",
"$",
"feedback",
")",
";",
"}"
] |
Remove feedback.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Feedback\Feedback $feedback
@return bool TRUE if this collection contained the specified element, FALSE otherwise
|
[
"Remove",
"feedback",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L836-L839
|
21,972
|
verdet23/SphinxSearchBundle
|
DependencyInjection/Configuration.php
|
Configuration.addIndexerSection
|
private function addIndexerSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('indexer')
->addDefaultsIfNotSet()
->children()
->booleanNode('sudo')->defaultValue(false)->end()
->scalarNode('bin')->defaultValue('/usr/bin/indexer')->end()
->scalarNode('config')->defaultNull()->end()
->end()
->end()
->end();
}
|
php
|
private function addIndexerSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('indexer')
->addDefaultsIfNotSet()
->children()
->booleanNode('sudo')->defaultValue(false)->end()
->scalarNode('bin')->defaultValue('/usr/bin/indexer')->end()
->scalarNode('config')->defaultNull()->end()
->end()
->end()
->end();
}
|
[
"private",
"function",
"addIndexerSection",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'indexer'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"booleanNode",
"(",
"'sudo'",
")",
"->",
"defaultValue",
"(",
"false",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'bin'",
")",
"->",
"defaultValue",
"(",
"'/usr/bin/indexer'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'config'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"}"
] |
Set indexer parameters
@param ArrayNodeDefinition $node
|
[
"Set",
"indexer",
"parameters"
] |
6452cc3a5fab83647b6c08574164249fb8f03b05
|
https://github.com/verdet23/SphinxSearchBundle/blob/6452cc3a5fab83647b6c08574164249fb8f03b05/DependencyInjection/Configuration.php#L36-L49
|
21,973
|
verdet23/SphinxSearchBundle
|
DependencyInjection/Configuration.php
|
Configuration.addIndexesSection
|
private function addIndexesSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('indexes')
->isRequired()
->requiresAtLeastOneElement()
->useAttributeAsKey('key')
->prototype('scalar')->end()
->end()
->end();
}
|
php
|
private function addIndexesSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('indexes')
->isRequired()
->requiresAtLeastOneElement()
->useAttributeAsKey('key')
->prototype('scalar')->end()
->end()
->end();
}
|
[
"private",
"function",
"addIndexesSection",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'indexes'",
")",
"->",
"isRequired",
"(",
")",
"->",
"requiresAtLeastOneElement",
"(",
")",
"->",
"useAttributeAsKey",
"(",
"'key'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"}"
] |
Set indexes parameters
@param ArrayNodeDefinition $node
|
[
"Set",
"indexes",
"parameters"
] |
6452cc3a5fab83647b6c08574164249fb8f03b05
|
https://github.com/verdet23/SphinxSearchBundle/blob/6452cc3a5fab83647b6c08574164249fb8f03b05/DependencyInjection/Configuration.php#L56-L67
|
21,974
|
verdet23/SphinxSearchBundle
|
DependencyInjection/Configuration.php
|
Configuration.addSearchdSection
|
private function addSearchdSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('searchd')
->addDefaultsIfNotSet()
->children()
->scalarNode('host')->defaultValue('localhost')->end()
->scalarNode('port')->defaultValue('9312')->end()
->scalarNode('socket')->defaultNull()->end()
->end()
->end()
->end();
}
|
php
|
private function addSearchdSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('searchd')
->addDefaultsIfNotSet()
->children()
->scalarNode('host')->defaultValue('localhost')->end()
->scalarNode('port')->defaultValue('9312')->end()
->scalarNode('socket')->defaultNull()->end()
->end()
->end()
->end();
}
|
[
"private",
"function",
"addSearchdSection",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'searchd'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'host'",
")",
"->",
"defaultValue",
"(",
"'localhost'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'port'",
")",
"->",
"defaultValue",
"(",
"'9312'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'socket'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"}"
] |
Set search daemon parameters
@param ArrayNodeDefinition $node
|
[
"Set",
"search",
"daemon",
"parameters"
] |
6452cc3a5fab83647b6c08574164249fb8f03b05
|
https://github.com/verdet23/SphinxSearchBundle/blob/6452cc3a5fab83647b6c08574164249fb8f03b05/DependencyInjection/Configuration.php#L74-L87
|
21,975
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memcache.php
|
ezcCacheStorageMemcache.setOptions
|
public function setOptions( $options )
{
switch ( true )
{
case ( $options instanceof ezcCacheStorageMemcacheOptions ):
$this->properties['options'] = $options;
break;
case ( $options instanceof ezcCacheStorageOptions ):
$this->properties['options']->mergeStorageOptions( $options );
break;
case ( is_array( $options ) ):
$this->properties['options']->merge( $options );
break;
default:
throw new ezcBaseValueException(
'options',
$options,
'instance of ezcCacheStorageMemcacheOptions'
);
}
}
|
php
|
public function setOptions( $options )
{
switch ( true )
{
case ( $options instanceof ezcCacheStorageMemcacheOptions ):
$this->properties['options'] = $options;
break;
case ( $options instanceof ezcCacheStorageOptions ):
$this->properties['options']->mergeStorageOptions( $options );
break;
case ( is_array( $options ) ):
$this->properties['options']->merge( $options );
break;
default:
throw new ezcBaseValueException(
'options',
$options,
'instance of ezcCacheStorageMemcacheOptions'
);
}
}
|
[
"public",
"function",
"setOptions",
"(",
"$",
"options",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"$",
"options",
"instanceof",
"ezcCacheStorageMemcacheOptions",
")",
":",
"$",
"this",
"->",
"properties",
"[",
"'options'",
"]",
"=",
"$",
"options",
";",
"break",
";",
"case",
"(",
"$",
"options",
"instanceof",
"ezcCacheStorageOptions",
")",
":",
"$",
"this",
"->",
"properties",
"[",
"'options'",
"]",
"->",
"mergeStorageOptions",
"(",
"$",
"options",
")",
";",
"break",
";",
"case",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
":",
"$",
"this",
"->",
"properties",
"[",
"'options'",
"]",
"->",
"merge",
"(",
"$",
"options",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"ezcBaseValueException",
"(",
"'options'",
",",
"$",
"options",
",",
"'instance of ezcCacheStorageMemcacheOptions'",
")",
";",
"}",
"}"
] |
Set new options.
Overwrites the options with the given ones.
@param ezcCacheStorageMemcacheOptions $options The options to set.
@throws ezcBasePropertyNotFoundException
If you tried to set a non-existent option value. The accepted
options depend on the ezcCacheStorage implementation and may
vary.
@throws ezcBaseValueException
If the value is not valid for the desired option.
@throws ezcBaseValueException
If you submit neither an array nor an instance of
ezcCacheStorageOptions.
@apichange Use $storage->options instead.
|
[
"Set",
"new",
"options",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memcache.php#L135-L155
|
21,976
|
alevilar/ristorantino-vendor
|
Fidelization/Model/Cliente.php
|
Cliente.getResponsabilidadIva
|
function getResponsabilidadIva($id = 0){
if($id == 0){
$id = $this->id;
}
$ret = $this->find('first',array('conditions'=>array('Cliente.id'=>$id),'contain'=>array('IvaResponsabilidad')));
return $ret;
}
|
php
|
function getResponsabilidadIva($id = 0){
if($id == 0){
$id = $this->id;
}
$ret = $this->find('first',array('conditions'=>array('Cliente.id'=>$id),'contain'=>array('IvaResponsabilidad')));
return $ret;
}
|
[
"function",
"getResponsabilidadIva",
"(",
"$",
"id",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"id",
"==",
"0",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"id",
";",
"}",
"$",
"ret",
"=",
"$",
"this",
"->",
"find",
"(",
"'first'",
",",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"'Cliente.id'",
"=>",
"$",
"id",
")",
",",
"'contain'",
"=>",
"array",
"(",
"'IvaResponsabilidad'",
")",
")",
")",
";",
"return",
"$",
"ret",
";",
"}"
] |
Me devuelve la responsabilidad del cliente frente el IVA
@return array find(first) con Cliente e IvaResponsabilidad
|
[
"Me",
"devuelve",
"la",
"responsabilidad",
"del",
"cliente",
"frente",
"el",
"IVA"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Fidelization/Model/Cliente.php#L344-L350
|
21,977
|
alevilar/ristorantino-vendor
|
Fidelization/Model/Cliente.php
|
Cliente.filerBySearch
|
public function filerBySearch($data) {
$filter = $data['search'];
$condition = array(
'OR' => array(
$this->alias . '.nombre LIKE' => '%' . $filter . '%',
$this->alias . '.nrodocumento LIKE' => '%' . $filter . '%',
$this->alias . '.telefono LIKE' => '%' . $filter . '%',
$this->alias . '.domicilio LIKE' => '%' . $filter . '%',
$this->alias . '.codigo' => $filter,
)
);
return $condition;
}
|
php
|
public function filerBySearch($data) {
$filter = $data['search'];
$condition = array(
'OR' => array(
$this->alias . '.nombre LIKE' => '%' . $filter . '%',
$this->alias . '.nrodocumento LIKE' => '%' . $filter . '%',
$this->alias . '.telefono LIKE' => '%' . $filter . '%',
$this->alias . '.domicilio LIKE' => '%' . $filter . '%',
$this->alias . '.codigo' => $filter,
)
);
return $condition;
}
|
[
"public",
"function",
"filerBySearch",
"(",
"$",
"data",
")",
"{",
"$",
"filter",
"=",
"$",
"data",
"[",
"'search'",
"]",
";",
"$",
"condition",
"=",
"array",
"(",
"'OR'",
"=>",
"array",
"(",
"$",
"this",
"->",
"alias",
".",
"'.nombre LIKE'",
"=>",
"'%'",
".",
"$",
"filter",
".",
"'%'",
",",
"$",
"this",
"->",
"alias",
".",
"'.nrodocumento LIKE'",
"=>",
"'%'",
".",
"$",
"filter",
".",
"'%'",
",",
"$",
"this",
"->",
"alias",
".",
"'.telefono LIKE'",
"=>",
"'%'",
".",
"$",
"filter",
".",
"'%'",
",",
"$",
"this",
"->",
"alias",
".",
"'.domicilio LIKE'",
"=>",
"'%'",
".",
"$",
"filter",
".",
"'%'",
",",
"$",
"this",
"->",
"alias",
".",
"'.codigo'",
"=>",
"$",
"filter",
",",
")",
")",
";",
"return",
"$",
"condition",
";",
"}"
] |
Or conditions with like
|
[
"Or",
"conditions",
"with",
"like"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Fidelization/Model/Cliente.php#L354-L366
|
21,978
|
surebert/surebert-framework
|
src/sb/Email/Attachment.php
|
Attachment.zip
|
public function zip()
{
if (empty($this->filepath)) {
throw(new \Exception("Must set \sb\Email\Attachment::file_path before zipping attachment"));
}
if (empty($this->name)) {
$this->name = basename($this->filepath);
}
$zip = new \ZipArchive();
$zipfile_path = \ROOT . "/private/cache/compression/" . md5(microtime(true)) . '_' . $this->name . ".zip";
$zip_dir = dirname($zipfile_path);
if (!is_dir($zip_dir) && !@mkdir($zip_dir, 0755, true)) {
throw(new \Exception("Cannot create /private/cache/compression directory\n"));
}
if ($zip->open($zipfile_path, \ZIPARCHIVE::CREATE) !== true) {
throw(new \Exception("Cannot open <$zipfile_path>\n"));
}
$zip->addFromString($this->name, \file_get_contents($this->filepath));
$zip->close();
$this->name .= '.zip';
//this is the content, in this case I am ready the blob data from a saved image file but you could easily replace this with blob data from a database. The mime type will be added based on the extension using \sb\Files::extensionToMime. For bizarre mime-types that are not in \sb\Files::extensionToMime you can override this by setting the mime-type manually $myAttachment->mime_type ='bizarre/weird';
$this->contents = \file_get_contents($zipfile_path);
//remove the tmp zip file
\unlink($zipfile_path);
//add mime type for zip files, \sb\Files should handle this after 1.41
$this->mime_type = 'application/x-zip-compressed';
}
|
php
|
public function zip()
{
if (empty($this->filepath)) {
throw(new \Exception("Must set \sb\Email\Attachment::file_path before zipping attachment"));
}
if (empty($this->name)) {
$this->name = basename($this->filepath);
}
$zip = new \ZipArchive();
$zipfile_path = \ROOT . "/private/cache/compression/" . md5(microtime(true)) . '_' . $this->name . ".zip";
$zip_dir = dirname($zipfile_path);
if (!is_dir($zip_dir) && !@mkdir($zip_dir, 0755, true)) {
throw(new \Exception("Cannot create /private/cache/compression directory\n"));
}
if ($zip->open($zipfile_path, \ZIPARCHIVE::CREATE) !== true) {
throw(new \Exception("Cannot open <$zipfile_path>\n"));
}
$zip->addFromString($this->name, \file_get_contents($this->filepath));
$zip->close();
$this->name .= '.zip';
//this is the content, in this case I am ready the blob data from a saved image file but you could easily replace this with blob data from a database. The mime type will be added based on the extension using \sb\Files::extensionToMime. For bizarre mime-types that are not in \sb\Files::extensionToMime you can override this by setting the mime-type manually $myAttachment->mime_type ='bizarre/weird';
$this->contents = \file_get_contents($zipfile_path);
//remove the tmp zip file
\unlink($zipfile_path);
//add mime type for zip files, \sb\Files should handle this after 1.41
$this->mime_type = 'application/x-zip-compressed';
}
|
[
"public",
"function",
"zip",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"filepath",
")",
")",
"{",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"\"Must set \\sb\\Email\\Attachment::file_path before zipping attachment\"",
")",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"name",
")",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"basename",
"(",
"$",
"this",
"->",
"filepath",
")",
";",
"}",
"$",
"zip",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"$",
"zipfile_path",
"=",
"\\",
"ROOT",
".",
"\"/private/cache/compression/\"",
".",
"md5",
"(",
"microtime",
"(",
"true",
")",
")",
".",
"'_'",
".",
"$",
"this",
"->",
"name",
".",
"\".zip\"",
";",
"$",
"zip_dir",
"=",
"dirname",
"(",
"$",
"zipfile_path",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"zip_dir",
")",
"&&",
"!",
"@",
"mkdir",
"(",
"$",
"zip_dir",
",",
"0755",
",",
"true",
")",
")",
"{",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"\"Cannot create /private/cache/compression directory\\n\"",
")",
")",
";",
"}",
"if",
"(",
"$",
"zip",
"->",
"open",
"(",
"$",
"zipfile_path",
",",
"\\",
"ZIPARCHIVE",
"::",
"CREATE",
")",
"!==",
"true",
")",
"{",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"\"Cannot open <$zipfile_path>\\n\"",
")",
")",
";",
"}",
"$",
"zip",
"->",
"addFromString",
"(",
"$",
"this",
"->",
"name",
",",
"\\",
"file_get_contents",
"(",
"$",
"this",
"->",
"filepath",
")",
")",
";",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"$",
"this",
"->",
"name",
".=",
"'.zip'",
";",
"//this is the content, in this case I am ready the blob data from a saved image file but you could easily replace this with blob data from a database. The mime type will be added based on the extension using \\sb\\Files::extensionToMime. For bizarre mime-types that are not in \\sb\\Files::extensionToMime you can override this by setting the mime-type manually $myAttachment->mime_type ='bizarre/weird';",
"$",
"this",
"->",
"contents",
"=",
"\\",
"file_get_contents",
"(",
"$",
"zipfile_path",
")",
";",
"//remove the tmp zip file",
"\\",
"unlink",
"(",
"$",
"zipfile_path",
")",
";",
"//add mime type for zip files, \\sb\\Files should handle this after 1.41",
"$",
"this",
"->",
"mime_type",
"=",
"'application/x-zip-compressed'",
";",
"}"
] |
Zips the attachment before sending and sets the proper mime type
|
[
"Zips",
"the",
"attachment",
"before",
"sending",
"and",
"sets",
"the",
"proper",
"mime",
"type"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Attachment.php#L125-L161
|
21,979
|
OKTOTV/OktolabMediaBundle
|
Model/MediaService.php
|
MediaService.addEpisodeJob
|
public function addEpisodeJob(Keychain $keychain, $uniqID, $overwrite = false, $worker_queue = false ,$first = false)
{
$this->jobService->addJob(
"Oktolab\MediaBundle\Model\ImportEpisodeMetadataJob",
[
'keychain' => $keychain->getUniqID(),
'uniqID' => $uniqID,
'overwrite' => $overwrite
],
$worker_queue,
$first
);
}
|
php
|
public function addEpisodeJob(Keychain $keychain, $uniqID, $overwrite = false, $worker_queue = false ,$first = false)
{
$this->jobService->addJob(
"Oktolab\MediaBundle\Model\ImportEpisodeMetadataJob",
[
'keychain' => $keychain->getUniqID(),
'uniqID' => $uniqID,
'overwrite' => $overwrite
],
$worker_queue,
$first
);
}
|
[
"public",
"function",
"addEpisodeJob",
"(",
"Keychain",
"$",
"keychain",
",",
"$",
"uniqID",
",",
"$",
"overwrite",
"=",
"false",
",",
"$",
"worker_queue",
"=",
"false",
",",
"$",
"first",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"jobService",
"->",
"addJob",
"(",
"\"Oktolab\\MediaBundle\\Model\\ImportEpisodeMetadataJob\"",
",",
"[",
"'keychain'",
"=>",
"$",
"keychain",
"->",
"getUniqID",
"(",
")",
",",
"'uniqID'",
"=>",
"$",
"uniqID",
",",
"'overwrite'",
"=>",
"$",
"overwrite",
"]",
",",
"$",
"worker_queue",
",",
"$",
"first",
")",
";",
"}"
] |
starts an import worker for an episode by uniqID from the given Keychain
|
[
"starts",
"an",
"import",
"worker",
"for",
"an",
"episode",
"by",
"uniqID",
"from",
"the",
"given",
"Keychain"
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/MediaService.php#L92-L104
|
21,980
|
OKTOTV/OktolabMediaBundle
|
Model/MediaService.php
|
MediaService.addImportSeriesPosterframeJob
|
public function addImportSeriesPosterframeJob($uniqID, $keychain, $filekey)
{
$this->jobService->addJob(
"Oktolab\MediaBundle\Model\ImportSeriesPosterframeJob",
['uniqID' => $uniqID, 'keychain' => $keychain->getUniqID(), 'key' => $filekey]
);
}
|
php
|
public function addImportSeriesPosterframeJob($uniqID, $keychain, $filekey)
{
$this->jobService->addJob(
"Oktolab\MediaBundle\Model\ImportSeriesPosterframeJob",
['uniqID' => $uniqID, 'keychain' => $keychain->getUniqID(), 'key' => $filekey]
);
}
|
[
"public",
"function",
"addImportSeriesPosterframeJob",
"(",
"$",
"uniqID",
",",
"$",
"keychain",
",",
"$",
"filekey",
")",
"{",
"$",
"this",
"->",
"jobService",
"->",
"addJob",
"(",
"\"Oktolab\\MediaBundle\\Model\\ImportSeriesPosterframeJob\"",
",",
"[",
"'uniqID'",
"=>",
"$",
"uniqID",
",",
"'keychain'",
"=>",
"$",
"keychain",
"->",
"getUniqID",
"(",
")",
",",
"'key'",
"=>",
"$",
"filekey",
"]",
")",
";",
"}"
] |
please use addSeriesPosterframeJob in the future.
@deprecated
|
[
"please",
"use",
"addSeriesPosterframeJob",
"in",
"the",
"future",
"."
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/MediaService.php#L313-L319
|
21,981
|
wenbinye/PhalconX
|
src/Db/DbHelper.php
|
DbHelper.describeColumns
|
public function describeColumns($conn, $table, $schema = null)
{
$dialect = $this->getDialect($conn);
if (method_exists($dialect, 'showFullColumns')) {
$sql = $this->getDialect($conn)->showFullColumns($table, $schema);
$comments = [];
foreach ($conn->fetchAll($sql, Db::FETCH_ASSOC) as $row) {
$comments[$row['Field']] = $row['Comment'];
}
$columns = [];
foreach ($conn->describeColumns($table, $schema) as $col) {
$column = Column::copy($col);
if (!empty($comments[$col->getName()])) {
$column->setComment($comments[$col->getName()]);
}
$columns[] = $column;
}
return $columns;
} else {
return $conn->describeColumns($table, $schema);
}
}
|
php
|
public function describeColumns($conn, $table, $schema = null)
{
$dialect = $this->getDialect($conn);
if (method_exists($dialect, 'showFullColumns')) {
$sql = $this->getDialect($conn)->showFullColumns($table, $schema);
$comments = [];
foreach ($conn->fetchAll($sql, Db::FETCH_ASSOC) as $row) {
$comments[$row['Field']] = $row['Comment'];
}
$columns = [];
foreach ($conn->describeColumns($table, $schema) as $col) {
$column = Column::copy($col);
if (!empty($comments[$col->getName()])) {
$column->setComment($comments[$col->getName()]);
}
$columns[] = $column;
}
return $columns;
} else {
return $conn->describeColumns($table, $schema);
}
}
|
[
"public",
"function",
"describeColumns",
"(",
"$",
"conn",
",",
"$",
"table",
",",
"$",
"schema",
"=",
"null",
")",
"{",
"$",
"dialect",
"=",
"$",
"this",
"->",
"getDialect",
"(",
"$",
"conn",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"dialect",
",",
"'showFullColumns'",
")",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"getDialect",
"(",
"$",
"conn",
")",
"->",
"showFullColumns",
"(",
"$",
"table",
",",
"$",
"schema",
")",
";",
"$",
"comments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"conn",
"->",
"fetchAll",
"(",
"$",
"sql",
",",
"Db",
"::",
"FETCH_ASSOC",
")",
"as",
"$",
"row",
")",
"{",
"$",
"comments",
"[",
"$",
"row",
"[",
"'Field'",
"]",
"]",
"=",
"$",
"row",
"[",
"'Comment'",
"]",
";",
"}",
"$",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"conn",
"->",
"describeColumns",
"(",
"$",
"table",
",",
"$",
"schema",
")",
"as",
"$",
"col",
")",
"{",
"$",
"column",
"=",
"Column",
"::",
"copy",
"(",
"$",
"col",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"comments",
"[",
"$",
"col",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"$",
"column",
"->",
"setComment",
"(",
"$",
"comments",
"[",
"$",
"col",
"->",
"getName",
"(",
")",
"]",
")",
";",
"}",
"$",
"columns",
"[",
"]",
"=",
"$",
"column",
";",
"}",
"return",
"$",
"columns",
";",
"}",
"else",
"{",
"return",
"$",
"conn",
"->",
"describeColumns",
"(",
"$",
"table",
",",
"$",
"schema",
")",
";",
"}",
"}"
] |
Adds comment to column
@param DbAdapter $conn
@param string $table
@param string $schema
@return Column[]
|
[
"Adds",
"comment",
"to",
"column"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/DbHelper.php#L32-L53
|
21,982
|
wenbinye/PhalconX
|
src/Db/DbHelper.php
|
DbHelper.describeIndexes
|
public function describeIndexes($conn, $table, $schema = null)
{
$dialect = $conn->getDialectType();
$method = 'describeIndexes' . $dialect;
if (!method_exists($this, $method)) {
throw new Exception("Describe index for $dialect is not implemented yet");
}
return $this->$method($conn, $table, $schema);
}
|
php
|
public function describeIndexes($conn, $table, $schema = null)
{
$dialect = $conn->getDialectType();
$method = 'describeIndexes' . $dialect;
if (!method_exists($this, $method)) {
throw new Exception("Describe index for $dialect is not implemented yet");
}
return $this->$method($conn, $table, $schema);
}
|
[
"public",
"function",
"describeIndexes",
"(",
"$",
"conn",
",",
"$",
"table",
",",
"$",
"schema",
"=",
"null",
")",
"{",
"$",
"dialect",
"=",
"$",
"conn",
"->",
"getDialectType",
"(",
")",
";",
"$",
"method",
"=",
"'describeIndexes'",
".",
"$",
"dialect",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Describe index for $dialect is not implemented yet\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"conn",
",",
"$",
"table",
",",
"$",
"schema",
")",
";",
"}"
] |
Describes table indexes
@param DbAdapter $conn
@param string $table
@param string $schema
@return Index[]
|
[
"Describes",
"table",
"indexes"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/DbHelper.php#L63-L71
|
21,983
|
wenbinye/PhalconX
|
src/Db/DbHelper.php
|
DbHelper.createTable
|
public function createTable($conn, $table, $schema, array $definition)
{
if (empty($definition['columns'])) {
throw new Exception("The table must contain at least one column");
}
$conn->execute($this->getDialect($conn)->createTable($table, $schema, $definition));
}
|
php
|
public function createTable($conn, $table, $schema, array $definition)
{
if (empty($definition['columns'])) {
throw new Exception("The table must contain at least one column");
}
$conn->execute($this->getDialect($conn)->createTable($table, $schema, $definition));
}
|
[
"public",
"function",
"createTable",
"(",
"$",
"conn",
",",
"$",
"table",
",",
"$",
"schema",
",",
"array",
"$",
"definition",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"definition",
"[",
"'columns'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"The table must contain at least one column\"",
")",
";",
"}",
"$",
"conn",
"->",
"execute",
"(",
"$",
"this",
"->",
"getDialect",
"(",
"$",
"conn",
")",
"->",
"createTable",
"(",
"$",
"table",
",",
"$",
"schema",
",",
"$",
"definition",
")",
")",
";",
"}"
] |
creates database table
|
[
"creates",
"database",
"table"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/DbHelper.php#L100-L106
|
21,984
|
wenbinye/PhalconX
|
src/Db/DbHelper.php
|
DbHelper.getConnection
|
public static function getConnection($dsn)
{
if (!is_array($dsn)) {
$dsn = self::parseDsn($dsn);
}
if (!isset($dsn['adapter'])) {
throw new Exception("database adapter is missing for " . json_encode($dsn));
}
$class = 'Phalcon\Db\Adapter\Pdo\\' . ucfirst($dsn['adapter']);
$conn = new $class($dsn);
return Mixin::create($conn, new self);
}
|
php
|
public static function getConnection($dsn)
{
if (!is_array($dsn)) {
$dsn = self::parseDsn($dsn);
}
if (!isset($dsn['adapter'])) {
throw new Exception("database adapter is missing for " . json_encode($dsn));
}
$class = 'Phalcon\Db\Adapter\Pdo\\' . ucfirst($dsn['adapter']);
$conn = new $class($dsn);
return Mixin::create($conn, new self);
}
|
[
"public",
"static",
"function",
"getConnection",
"(",
"$",
"dsn",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"dsn",
")",
")",
"{",
"$",
"dsn",
"=",
"self",
"::",
"parseDsn",
"(",
"$",
"dsn",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"dsn",
"[",
"'adapter'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"database adapter is missing for \"",
".",
"json_encode",
"(",
"$",
"dsn",
")",
")",
";",
"}",
"$",
"class",
"=",
"'Phalcon\\Db\\Adapter\\Pdo\\\\'",
".",
"ucfirst",
"(",
"$",
"dsn",
"[",
"'adapter'",
"]",
")",
";",
"$",
"conn",
"=",
"new",
"$",
"class",
"(",
"$",
"dsn",
")",
";",
"return",
"Mixin",
"::",
"create",
"(",
"$",
"conn",
",",
"new",
"self",
")",
";",
"}"
] |
creates database connect by dsn
@param string $dsn
@return DbAdapter
|
[
"creates",
"database",
"connect",
"by",
"dsn"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/DbHelper.php#L159-L170
|
21,985
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php
|
Dwoo_Adapters_ZendFramework_View.setOptions
|
public function setOptions(array $opt = array())
{
// BC checks
// TODO remove in 1.1
if (isset($opt['compileDir']) || isset($opt['compile_dir'])) {
trigger_error('Dwoo ZF Adapter: the compile dir should be set in the $options[\'engine\'][\'compileDir\'] value the adapter settings', E_USER_WARNING);
}
if (isset($opt['cacheDir']) || isset($opt['cache_dir'])) {
trigger_error('Dwoo ZF Adapter: the cache dir should be set in the $options[\'engine\'][\'cacheDir\'] value the adapter settings', E_USER_WARNING);
}
// end BC
// Making sure that everything is loaded.
$classes = array('engine', 'dataProvider', 'compiler');
// Setting options to Dwoo objects...
foreach ($opt as $type => $settings) {
if (!method_exists($this, 'set' . $type)) {
throw new Dwoo_Exception("Unknown type $type");
}
if (is_string($settings) || is_object($settings)) {
call_user_func(array($this, 'set' . $type), $settings);
} elseif (is_array($settings)) {
// Set requested class
if (array_key_exists('type', $settings)) {
call_user_func(array($this, 'set' . $type), $settings['type']);
}
if (in_array($type, $classes)) {
// Call get so that the class is initialized
$rel = call_user_func(array($this, 'get' . $type));
// Call set*() methods so that all the settings are set.
foreach ($settings as $method => $value) {
if (method_exists($rel, 'set' . $method)) {
call_user_func(array($rel, 'set' . $method), $value);
}
}
} elseif ('templateFile' == $type) {
// Remember the settings for the templateFile
$this->_templateFileSettings = $settings;
}
}
}
}
|
php
|
public function setOptions(array $opt = array())
{
// BC checks
// TODO remove in 1.1
if (isset($opt['compileDir']) || isset($opt['compile_dir'])) {
trigger_error('Dwoo ZF Adapter: the compile dir should be set in the $options[\'engine\'][\'compileDir\'] value the adapter settings', E_USER_WARNING);
}
if (isset($opt['cacheDir']) || isset($opt['cache_dir'])) {
trigger_error('Dwoo ZF Adapter: the cache dir should be set in the $options[\'engine\'][\'cacheDir\'] value the adapter settings', E_USER_WARNING);
}
// end BC
// Making sure that everything is loaded.
$classes = array('engine', 'dataProvider', 'compiler');
// Setting options to Dwoo objects...
foreach ($opt as $type => $settings) {
if (!method_exists($this, 'set' . $type)) {
throw new Dwoo_Exception("Unknown type $type");
}
if (is_string($settings) || is_object($settings)) {
call_user_func(array($this, 'set' . $type), $settings);
} elseif (is_array($settings)) {
// Set requested class
if (array_key_exists('type', $settings)) {
call_user_func(array($this, 'set' . $type), $settings['type']);
}
if (in_array($type, $classes)) {
// Call get so that the class is initialized
$rel = call_user_func(array($this, 'get' . $type));
// Call set*() methods so that all the settings are set.
foreach ($settings as $method => $value) {
if (method_exists($rel, 'set' . $method)) {
call_user_func(array($rel, 'set' . $method), $value);
}
}
} elseif ('templateFile' == $type) {
// Remember the settings for the templateFile
$this->_templateFileSettings = $settings;
}
}
}
}
|
[
"public",
"function",
"setOptions",
"(",
"array",
"$",
"opt",
"=",
"array",
"(",
")",
")",
"{",
"// BC checks",
"// TODO remove in 1.1",
"if",
"(",
"isset",
"(",
"$",
"opt",
"[",
"'compileDir'",
"]",
")",
"||",
"isset",
"(",
"$",
"opt",
"[",
"'compile_dir'",
"]",
")",
")",
"{",
"trigger_error",
"(",
"'Dwoo ZF Adapter: the compile dir should be set in the $options[\\'engine\\'][\\'compileDir\\'] value the adapter settings'",
",",
"E_USER_WARNING",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"opt",
"[",
"'cacheDir'",
"]",
")",
"||",
"isset",
"(",
"$",
"opt",
"[",
"'cache_dir'",
"]",
")",
")",
"{",
"trigger_error",
"(",
"'Dwoo ZF Adapter: the cache dir should be set in the $options[\\'engine\\'][\\'cacheDir\\'] value the adapter settings'",
",",
"E_USER_WARNING",
")",
";",
"}",
"// end BC",
"// Making sure that everything is loaded.\t\t",
"$",
"classes",
"=",
"array",
"(",
"'engine'",
",",
"'dataProvider'",
",",
"'compiler'",
")",
";",
"// Setting options to Dwoo objects...",
"foreach",
"(",
"$",
"opt",
"as",
"$",
"type",
"=>",
"$",
"settings",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"'set'",
".",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"\"Unknown type $type\"",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"settings",
")",
"||",
"is_object",
"(",
"$",
"settings",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"'set'",
".",
"$",
"type",
")",
",",
"$",
"settings",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"settings",
")",
")",
"{",
"// Set requested class",
"if",
"(",
"array_key_exists",
"(",
"'type'",
",",
"$",
"settings",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"'set'",
".",
"$",
"type",
")",
",",
"$",
"settings",
"[",
"'type'",
"]",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"$",
"classes",
")",
")",
"{",
"// Call get so that the class is initialized",
"$",
"rel",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"'get'",
".",
"$",
"type",
")",
")",
";",
"// Call set*() methods so that all the settings are set.",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"method",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"rel",
",",
"'set'",
".",
"$",
"method",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"rel",
",",
"'set'",
".",
"$",
"method",
")",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"'templateFile'",
"==",
"$",
"type",
")",
"{",
"// Remember the settings for the templateFile",
"$",
"this",
"->",
"_templateFileSettings",
"=",
"$",
"settings",
";",
"}",
"}",
"}",
"}"
] |
Set object state from options array
- engine = engine class name|engine object|array of options for engine
- dataProvider = data provider class name|data provider object|array of options for data provider
- compiler = compiler class name|compiler object|array of options for compiler
- templateFile =
Array of options:
- type class name or object for engine, dataProvider or compiler
- any set* method (compileDir for setCompileDir ...)
@param array $options
@return Dwoo_Adapters_ZendFramework_View
|
[
"Set",
"object",
"state",
"from",
"options",
"array",
"-",
"engine",
"=",
"engine",
"class",
"name|engine",
"object|array",
"of",
"options",
"for",
"engine",
"-",
"dataProvider",
"=",
"data",
"provider",
"class",
"name|data",
"provider",
"object|array",
"of",
"options",
"for",
"data",
"provider",
"-",
"compiler",
"=",
"compiler",
"class",
"name|compiler",
"object|array",
"of",
"options",
"for",
"compiler",
"-",
"templateFile",
"="
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L93-L139
|
21,986
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php
|
Dwoo_Adapters_ZendFramework_View.setEngine
|
public function setEngine($engine)
{
// if param given as an object
if ($engine instanceof Dwoo) {
$this->_engine = $engine;
}
//
elseif (is_subclass_of($engine, 'Dwoo') || 'Dwoo' === $engine) {
$this->_engine = new $engine();
}
else {
throw new Dwoo_Exception("Custom engine must be a subclass of Dwoo");
}
}
|
php
|
public function setEngine($engine)
{
// if param given as an object
if ($engine instanceof Dwoo) {
$this->_engine = $engine;
}
//
elseif (is_subclass_of($engine, 'Dwoo') || 'Dwoo' === $engine) {
$this->_engine = new $engine();
}
else {
throw new Dwoo_Exception("Custom engine must be a subclass of Dwoo");
}
}
|
[
"public",
"function",
"setEngine",
"(",
"$",
"engine",
")",
"{",
"// if param given as an object",
"if",
"(",
"$",
"engine",
"instanceof",
"Dwoo",
")",
"{",
"$",
"this",
"->",
"_engine",
"=",
"$",
"engine",
";",
"}",
"//",
"elseif",
"(",
"is_subclass_of",
"(",
"$",
"engine",
",",
"'Dwoo'",
")",
"||",
"'Dwoo'",
"===",
"$",
"engine",
")",
"{",
"$",
"this",
"->",
"_engine",
"=",
"new",
"$",
"engine",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"\"Custom engine must be a subclass of Dwoo\"",
")",
";",
"}",
"}"
] |
Sets template engine
@param string|Dwoo Object or name of the class
|
[
"Sets",
"template",
"engine"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L253-L266
|
21,987
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php
|
Dwoo_Adapters_ZendFramework_View.setDataProvider
|
public function setDataProvider($data)
{
if ($data instanceof Dwoo_IDataProvider) {
$this->_dataProvider = $data;
}
elseif (is_subclass_of($data, 'Dwoo_Data') || 'Dwoo_Data' == $data) {
$this->_dataProvider = new $data();
}
else {
throw new Dwoo_Exception("Custom data provider must be a subclass of Dwoo_Data or instance of Dwoo_IDataProvider");
}
}
|
php
|
public function setDataProvider($data)
{
if ($data instanceof Dwoo_IDataProvider) {
$this->_dataProvider = $data;
}
elseif (is_subclass_of($data, 'Dwoo_Data') || 'Dwoo_Data' == $data) {
$this->_dataProvider = new $data();
}
else {
throw new Dwoo_Exception("Custom data provider must be a subclass of Dwoo_Data or instance of Dwoo_IDataProvider");
}
}
|
[
"public",
"function",
"setDataProvider",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Dwoo_IDataProvider",
")",
"{",
"$",
"this",
"->",
"_dataProvider",
"=",
"$",
"data",
";",
"}",
"elseif",
"(",
"is_subclass_of",
"(",
"$",
"data",
",",
"'Dwoo_Data'",
")",
"||",
"'Dwoo_Data'",
"==",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"_dataProvider",
"=",
"new",
"$",
"data",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"\"Custom data provider must be a subclass of Dwoo_Data or instance of Dwoo_IDataProvider\"",
")",
";",
"}",
"}"
] |
Sets Dwoo data object
@param string|Dwoo_Data Object or name of the class
|
[
"Sets",
"Dwoo",
"data",
"object"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L287-L298
|
21,988
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php
|
Dwoo_Adapters_ZendFramework_View.setCompiler
|
public function setCompiler($compiler)
{
// if param given as an object
if ($compiler instanceof Dwoo_ICompiler) {
$this->_compiler = $compiler;
}
// if param given as a string
elseif (is_subclass_of($compiler, 'Dwoo_Compiler') || 'Dwoo_Compiler' == $compiler) {
$this->_compiler = new $compiler;
}
else {
throw new Dwoo_Exception("Custom compiler must be a subclass of Dwoo_Compiler or instance of Dwoo_ICompiler");
}
}
|
php
|
public function setCompiler($compiler)
{
// if param given as an object
if ($compiler instanceof Dwoo_ICompiler) {
$this->_compiler = $compiler;
}
// if param given as a string
elseif (is_subclass_of($compiler, 'Dwoo_Compiler') || 'Dwoo_Compiler' == $compiler) {
$this->_compiler = new $compiler;
}
else {
throw new Dwoo_Exception("Custom compiler must be a subclass of Dwoo_Compiler or instance of Dwoo_ICompiler");
}
}
|
[
"public",
"function",
"setCompiler",
"(",
"$",
"compiler",
")",
"{",
"// if param given as an object",
"if",
"(",
"$",
"compiler",
"instanceof",
"Dwoo_ICompiler",
")",
"{",
"$",
"this",
"->",
"_compiler",
"=",
"$",
"compiler",
";",
"}",
"// if param given as a string",
"elseif",
"(",
"is_subclass_of",
"(",
"$",
"compiler",
",",
"'Dwoo_Compiler'",
")",
"||",
"'Dwoo_Compiler'",
"==",
"$",
"compiler",
")",
"{",
"$",
"this",
"->",
"_compiler",
"=",
"new",
"$",
"compiler",
";",
"}",
"else",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"\"Custom compiler must be a subclass of Dwoo_Compiler or instance of Dwoo_ICompiler\"",
")",
";",
"}",
"}"
] |
Sets Dwoo compiler
@param string|Dwoo_Compiler Object or name of the class
|
[
"Sets",
"Dwoo",
"compiler"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L320-L334
|
21,989
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php
|
Dwoo_Adapters_ZendFramework_View.getCompiler
|
public function getCompiler()
{
if (null === $this->_compiler) {
$this->_compiler = Dwoo_Compiler::compilerFactory();
}
return $this->_compiler;
}
|
php
|
public function getCompiler()
{
if (null === $this->_compiler) {
$this->_compiler = Dwoo_Compiler::compilerFactory();
}
return $this->_compiler;
}
|
[
"public",
"function",
"getCompiler",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"_compiler",
")",
"{",
"$",
"this",
"->",
"_compiler",
"=",
"Dwoo_Compiler",
"::",
"compilerFactory",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_compiler",
";",
"}"
] |
Return the Dwoo compiler object
@return Dwoo_Data
|
[
"Return",
"the",
"Dwoo",
"compiler",
"object"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L341-L348
|
21,990
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php
|
Dwoo_Adapters_ZendFramework_View.getTemplateFile
|
public function getTemplateFile($template) {
$templateFileClass = $this->_templateFileClass;
$dwooTemplateFile = new $templateFileClass($template);
if (!($dwooTemplateFile instanceof Dwoo_ITemplate)) {
throw new Dwoo_Exception("Custom templateFile class must be a subclass of Dwoo_ITemplate");
}
foreach ($this->_templateFileSettings as $method => $value) {
if (method_exists($dwooTemplateFile, 'set' . $method)) {
call_user_func(array($dwooTemplateFile, 'set' . $method), $value);
}
}
return $dwooTemplateFile;
}
|
php
|
public function getTemplateFile($template) {
$templateFileClass = $this->_templateFileClass;
$dwooTemplateFile = new $templateFileClass($template);
if (!($dwooTemplateFile instanceof Dwoo_ITemplate)) {
throw new Dwoo_Exception("Custom templateFile class must be a subclass of Dwoo_ITemplate");
}
foreach ($this->_templateFileSettings as $method => $value) {
if (method_exists($dwooTemplateFile, 'set' . $method)) {
call_user_func(array($dwooTemplateFile, 'set' . $method), $value);
}
}
return $dwooTemplateFile;
}
|
[
"public",
"function",
"getTemplateFile",
"(",
"$",
"template",
")",
"{",
"$",
"templateFileClass",
"=",
"$",
"this",
"->",
"_templateFileClass",
";",
"$",
"dwooTemplateFile",
"=",
"new",
"$",
"templateFileClass",
"(",
"$",
"template",
")",
";",
"if",
"(",
"!",
"(",
"$",
"dwooTemplateFile",
"instanceof",
"Dwoo_ITemplate",
")",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"\"Custom templateFile class must be a subclass of Dwoo_ITemplate\"",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_templateFileSettings",
"as",
"$",
"method",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"dwooTemplateFile",
",",
"'set'",
".",
"$",
"method",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"dwooTemplateFile",
",",
"'set'",
".",
"$",
"method",
")",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"dwooTemplateFile",
";",
"}"
] |
Initializes Dwoo_ITemplate type of class and sets properties from _templateFileSettings
@param string Template location
@return Dwoo_ITemplate
|
[
"Initializes",
"Dwoo_ITemplate",
"type",
"of",
"class",
"and",
"sets",
"properties",
"from",
"_templateFileSettings"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L356-L372
|
21,991
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php
|
Dwoo_Adapters_ZendFramework_View.assign
|
public function assign($name, $val = null)
{
$this->getDataProvider()->assign($name, $val);
return $this;
}
|
php
|
public function assign($name, $val = null)
{
$this->getDataProvider()->assign($name, $val);
return $this;
}
|
[
"public",
"function",
"assign",
"(",
"$",
"name",
",",
"$",
"val",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"getDataProvider",
"(",
")",
"->",
"assign",
"(",
"$",
"name",
",",
"$",
"val",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Passes data to Dwoo_Data object
@see Dwoo_Data::assign()
@param array|string $name
@param mixed $val
@return Dwoo_Adapters_ZendFramework_View
|
[
"Passes",
"data",
"to",
"Dwoo_Data",
"object"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L392-L396
|
21,992
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php
|
Dwoo_Adapters_ZendFramework_View._run
|
public function _run()
{
echo $this->_engine->get(
$this->getTemplateFile(func_get_arg(0)),
$this->getDataProvider(),
$this->getCompiler()
);
}
|
php
|
public function _run()
{
echo $this->_engine->get(
$this->getTemplateFile(func_get_arg(0)),
$this->getDataProvider(),
$this->getCompiler()
);
}
|
[
"public",
"function",
"_run",
"(",
")",
"{",
"echo",
"$",
"this",
"->",
"_engine",
"->",
"get",
"(",
"$",
"this",
"->",
"getTemplateFile",
"(",
"func_get_arg",
"(",
"0",
")",
")",
",",
"$",
"this",
"->",
"getDataProvider",
"(",
")",
",",
"$",
"this",
"->",
"getCompiler",
"(",
")",
")",
";",
"}"
] |
Processes a view script and outputs it. Output is then
passed through filters.
@param string $name The script script name to process.
@return string The script output.
|
[
"Processes",
"a",
"view",
"script",
"and",
"outputs",
"it",
".",
"Output",
"is",
"then",
"passed",
"through",
"filters",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L444-L451
|
21,993
|
surebert/surebert-framework
|
src/sb/FTP/Client.php
|
Client.size
|
public function size($remote_file)
{
$size = @ftp_size($this->connection, $remote_file);
if ($size && $size != -1) {
return $size;
} else {
throw new \Exception("Could not get remote file size: " . $path);
}
}
|
php
|
public function size($remote_file)
{
$size = @ftp_size($this->connection, $remote_file);
if ($size && $size != -1) {
return $size;
} else {
throw new \Exception("Could not get remote file size: " . $path);
}
}
|
[
"public",
"function",
"size",
"(",
"$",
"remote_file",
")",
"{",
"$",
"size",
"=",
"@",
"ftp_size",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"remote_file",
")",
";",
"if",
"(",
"$",
"size",
"&&",
"$",
"size",
"!=",
"-",
"1",
")",
"{",
"return",
"$",
"size",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Could not get remote file size: \"",
".",
"$",
"path",
")",
";",
"}",
"}"
] |
Gets the size of a remote file
@param string $remote_file path to remote file
@return integer The size of the file in bytes
|
[
"Gets",
"the",
"size",
"of",
"a",
"remote",
"file"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/FTP/Client.php#L127-L135
|
21,994
|
surebert/surebert-framework
|
src/sb/FTP/Client.php
|
Client.chmod
|
public function chmod($remote_file, $mode)
{
$mode = octdec(str_pad($mode, 4, '0', STR_PAD_LEFT));
$mode = (int) $mode;
if (!@ftp_chmod($this->connection, $mode, $remote_file) !== false) {
throw new \Exception("Could not change remote file to mode: " . $mode);
}
return true;
}
|
php
|
public function chmod($remote_file, $mode)
{
$mode = octdec(str_pad($mode, 4, '0', STR_PAD_LEFT));
$mode = (int) $mode;
if (!@ftp_chmod($this->connection, $mode, $remote_file) !== false) {
throw new \Exception("Could not change remote file to mode: " . $mode);
}
return true;
}
|
[
"public",
"function",
"chmod",
"(",
"$",
"remote_file",
",",
"$",
"mode",
")",
"{",
"$",
"mode",
"=",
"octdec",
"(",
"str_pad",
"(",
"$",
"mode",
",",
"4",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
")",
";",
"$",
"mode",
"=",
"(",
"int",
")",
"$",
"mode",
";",
"if",
"(",
"!",
"@",
"ftp_chmod",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"mode",
",",
"$",
"remote_file",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Could not change remote file to mode: \"",
".",
"$",
"mode",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Change the file mode of a remote file
@param string $remote_file The path to the remote file
@param integer $mode The file mode e.g. 0644, 0777
@return boolean
|
[
"Change",
"the",
"file",
"mode",
"of",
"a",
"remote",
"file"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/FTP/Client.php#L143-L153
|
21,995
|
webdevvie/pheanstalk-task-queue-bundle
|
Command/StopWorkerTenderCommand.php
|
StopWorkerTenderCommand.findWorkerTenderProcessesForTube
|
private function findWorkerTenderProcessesForTube($tube)
{
$processes = array();
$command = "ps ax ";
$command .= "|grep php ";
$command .= "|grep -v stop ";
$command .= "|grep worker-tender ";
if ($tube !== '') {
$command .= "|grep " . escapeshellarg('use-tube=' . $tube);
}
$data = exec($command);
$lines = explode("\n", $data);
foreach ($lines as $line) {
$line = trim($line);
$parts = explode(" ", $line);
if ($parts[0] === '') {
continue;
}
$processes[] = intval($parts[0]);
}
return $processes;
}
|
php
|
private function findWorkerTenderProcessesForTube($tube)
{
$processes = array();
$command = "ps ax ";
$command .= "|grep php ";
$command .= "|grep -v stop ";
$command .= "|grep worker-tender ";
if ($tube !== '') {
$command .= "|grep " . escapeshellarg('use-tube=' . $tube);
}
$data = exec($command);
$lines = explode("\n", $data);
foreach ($lines as $line) {
$line = trim($line);
$parts = explode(" ", $line);
if ($parts[0] === '') {
continue;
}
$processes[] = intval($parts[0]);
}
return $processes;
}
|
[
"private",
"function",
"findWorkerTenderProcessesForTube",
"(",
"$",
"tube",
")",
"{",
"$",
"processes",
"=",
"array",
"(",
")",
";",
"$",
"command",
"=",
"\"ps ax \"",
";",
"$",
"command",
".=",
"\"|grep php \"",
";",
"$",
"command",
".=",
"\"|grep -v stop \"",
";",
"$",
"command",
".=",
"\"|grep worker-tender \"",
";",
"if",
"(",
"$",
"tube",
"!==",
"''",
")",
"{",
"$",
"command",
".=",
"\"|grep \"",
".",
"escapeshellarg",
"(",
"'use-tube='",
".",
"$",
"tube",
")",
";",
"}",
"$",
"data",
"=",
"exec",
"(",
"$",
"command",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"data",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"line",
")",
";",
"if",
"(",
"$",
"parts",
"[",
"0",
"]",
"===",
"''",
")",
"{",
"continue",
";",
"}",
"$",
"processes",
"[",
"]",
"=",
"intval",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"return",
"$",
"processes",
";",
"}"
] |
Returns a list of processes that match the worker-tender
@param string $tube
@return array
|
[
"Returns",
"a",
"list",
"of",
"processes",
"that",
"match",
"the",
"worker",
"-",
"tender"
] |
db5e63a8f844e345dc2e69ce8e94b32d851020eb
|
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/StopWorkerTenderCommand.php#L69-L92
|
21,996
|
sciactive/nymph-server
|
src/REST.php
|
REST.run
|
public function run($method, $action, $data) {
$method = strtoupper($method);
if (is_callable([$this, $method])) {
return $this->$method($action, $data);
}
return $this->httpError(405, 'Method Not Allowed');
}
|
php
|
public function run($method, $action, $data) {
$method = strtoupper($method);
if (is_callable([$this, $method])) {
return $this->$method($action, $data);
}
return $this->httpError(405, 'Method Not Allowed');
}
|
[
"public",
"function",
"run",
"(",
"$",
"method",
",",
"$",
"action",
",",
"$",
"data",
")",
"{",
"$",
"method",
"=",
"strtoupper",
"(",
"$",
"method",
")",
";",
"if",
"(",
"is_callable",
"(",
"[",
"$",
"this",
",",
"$",
"method",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"action",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"this",
"->",
"httpError",
"(",
"405",
",",
"'Method Not Allowed'",
")",
";",
"}"
] |
Run the Nymph REST server process.
Note that on failure, an HTTP error status code will be sent, usually
along with a message body.
@param string $method The HTTP method.
@param string $action The Nymph action.
@param string $data The JSON encoded data.
@return bool True on success, false on failure.
|
[
"Run",
"the",
"Nymph",
"REST",
"server",
"process",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/REST.php#L26-L32
|
21,997
|
sciactive/nymph-server
|
src/REST.php
|
REST.httpError
|
protected function httpError($errorCode, $message, $exception = null) {
header("HTTP/1.1 $errorCode $message", true, $errorCode);
if ($exception) {
echo json_encode([
'textStatus' => "$errorCode $message",
'exception' => get_class($exception),
'code' => $exception->getCode(),
'message' => $exception->getMessage()
]);
} else {
echo json_encode(['textStatus' => "$errorCode $message"]);
}
return false;
}
|
php
|
protected function httpError($errorCode, $message, $exception = null) {
header("HTTP/1.1 $errorCode $message", true, $errorCode);
if ($exception) {
echo json_encode([
'textStatus' => "$errorCode $message",
'exception' => get_class($exception),
'code' => $exception->getCode(),
'message' => $exception->getMessage()
]);
} else {
echo json_encode(['textStatus' => "$errorCode $message"]);
}
return false;
}
|
[
"protected",
"function",
"httpError",
"(",
"$",
"errorCode",
",",
"$",
"message",
",",
"$",
"exception",
"=",
"null",
")",
"{",
"header",
"(",
"\"HTTP/1.1 $errorCode $message\"",
",",
"true",
",",
"$",
"errorCode",
")",
";",
"if",
"(",
"$",
"exception",
")",
"{",
"echo",
"json_encode",
"(",
"[",
"'textStatus'",
"=>",
"\"$errorCode $message\"",
",",
"'exception'",
"=>",
"get_class",
"(",
"$",
"exception",
")",
",",
"'code'",
"=>",
"$",
"exception",
"->",
"getCode",
"(",
")",
",",
"'message'",
"=>",
"$",
"exception",
"->",
"getMessage",
"(",
")",
"]",
")",
";",
"}",
"else",
"{",
"echo",
"json_encode",
"(",
"[",
"'textStatus'",
"=>",
"\"$errorCode $message\"",
"]",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Return the request with an HTTP error response.
@param int $errorCode The HTTP status code.
@param string $message The message to place on the HTTP status header line.
@param Exception $exception An optional exception object to report.
@return boolean Always returns false.
@access protected
|
[
"Return",
"the",
"request",
"with",
"an",
"HTTP",
"error",
"response",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/REST.php#L457-L470
|
21,998
|
frodeborli/fubber-reactor
|
src/Host.php
|
Host.listen
|
public function listen($request, $response) {
// $this->debug('Host::listen: path='.$request->getPath().'?'.http_build_query($request->getQuery()));
$this->hits++;
$path = '/'.ltrim($request->getPath(), '/');
$endpoint = NULL;
if(isset($this->routes[$path])) {
// Direct lookup
$endpoint = $this->routes[$path];
} else {
$endpointKey = NULL;
if(isset($this->lookupCache[$path])) {
$endpointKey = $this->lookupCache[$path];
// The item was found in the lookupCache, so we move it back to the end of the array (to avoid unshifting it too soon) - LRU algorithm
if($this->lookupCacheCount == 1000) {
unset($this->lookupCache[$path]);
$this->lookupCache[$path] = $endpointKey;
}
$endpoint = $this->searchRoutes[$endpointKey][1];
} else {
foreach($this->searchRoutes as $key => $route) {
if(fnmatch($route[0], $path)) {
$endpointKey = $key;
break;
}
}
if($endpointKey !== NULL) {
// LRU algorithm
$this->lookupCache[$path] = $endpointKey; // Added to the end of the array
$this->lookupCacheCount++;
while($this->lookupCacheCount-- > 1000)
array_shift($this->lookupCache); // Remove something from the beginning of the array
$endpoint = $this->searchRoutes[$endpointKey][1];
}
}
}
if($endpoint) {
// We identified an endpoint
return $endpoint->listen($request, $response);
} else {
// We failed to find an endpoint, so we redirect to /errors/404
// This is not cached, because we don't want anybody to be able to fill the lookupCache with garbage
return $this->respondError(404, $request, $response);
}
}
|
php
|
public function listen($request, $response) {
// $this->debug('Host::listen: path='.$request->getPath().'?'.http_build_query($request->getQuery()));
$this->hits++;
$path = '/'.ltrim($request->getPath(), '/');
$endpoint = NULL;
if(isset($this->routes[$path])) {
// Direct lookup
$endpoint = $this->routes[$path];
} else {
$endpointKey = NULL;
if(isset($this->lookupCache[$path])) {
$endpointKey = $this->lookupCache[$path];
// The item was found in the lookupCache, so we move it back to the end of the array (to avoid unshifting it too soon) - LRU algorithm
if($this->lookupCacheCount == 1000) {
unset($this->lookupCache[$path]);
$this->lookupCache[$path] = $endpointKey;
}
$endpoint = $this->searchRoutes[$endpointKey][1];
} else {
foreach($this->searchRoutes as $key => $route) {
if(fnmatch($route[0], $path)) {
$endpointKey = $key;
break;
}
}
if($endpointKey !== NULL) {
// LRU algorithm
$this->lookupCache[$path] = $endpointKey; // Added to the end of the array
$this->lookupCacheCount++;
while($this->lookupCacheCount-- > 1000)
array_shift($this->lookupCache); // Remove something from the beginning of the array
$endpoint = $this->searchRoutes[$endpointKey][1];
}
}
}
if($endpoint) {
// We identified an endpoint
return $endpoint->listen($request, $response);
} else {
// We failed to find an endpoint, so we redirect to /errors/404
// This is not cached, because we don't want anybody to be able to fill the lookupCache with garbage
return $this->respondError(404, $request, $response);
}
}
|
[
"public",
"function",
"listen",
"(",
"$",
"request",
",",
"$",
"response",
")",
"{",
"//\t\t$this->debug('Host::listen: path='.$request->getPath().'?'.http_build_query($request->getQuery()));",
"$",
"this",
"->",
"hits",
"++",
";",
"$",
"path",
"=",
"'/'",
".",
"ltrim",
"(",
"$",
"request",
"->",
"getPath",
"(",
")",
",",
"'/'",
")",
";",
"$",
"endpoint",
"=",
"NULL",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"routes",
"[",
"$",
"path",
"]",
")",
")",
"{",
"// Direct lookup",
"$",
"endpoint",
"=",
"$",
"this",
"->",
"routes",
"[",
"$",
"path",
"]",
";",
"}",
"else",
"{",
"$",
"endpointKey",
"=",
"NULL",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"lookupCache",
"[",
"$",
"path",
"]",
")",
")",
"{",
"$",
"endpointKey",
"=",
"$",
"this",
"->",
"lookupCache",
"[",
"$",
"path",
"]",
";",
"// The item was found in the lookupCache, so we move it back to the end of the array (to avoid unshifting it too soon) - LRU algorithm",
"if",
"(",
"$",
"this",
"->",
"lookupCacheCount",
"==",
"1000",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"lookupCache",
"[",
"$",
"path",
"]",
")",
";",
"$",
"this",
"->",
"lookupCache",
"[",
"$",
"path",
"]",
"=",
"$",
"endpointKey",
";",
"}",
"$",
"endpoint",
"=",
"$",
"this",
"->",
"searchRoutes",
"[",
"$",
"endpointKey",
"]",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"searchRoutes",
"as",
"$",
"key",
"=>",
"$",
"route",
")",
"{",
"if",
"(",
"fnmatch",
"(",
"$",
"route",
"[",
"0",
"]",
",",
"$",
"path",
")",
")",
"{",
"$",
"endpointKey",
"=",
"$",
"key",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"endpointKey",
"!==",
"NULL",
")",
"{",
"// LRU algorithm",
"$",
"this",
"->",
"lookupCache",
"[",
"$",
"path",
"]",
"=",
"$",
"endpointKey",
";",
"// Added to the end of the array",
"$",
"this",
"->",
"lookupCacheCount",
"++",
";",
"while",
"(",
"$",
"this",
"->",
"lookupCacheCount",
"--",
">",
"1000",
")",
"array_shift",
"(",
"$",
"this",
"->",
"lookupCache",
")",
";",
"// Remove something from the beginning of the array",
"$",
"endpoint",
"=",
"$",
"this",
"->",
"searchRoutes",
"[",
"$",
"endpointKey",
"]",
"[",
"1",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"endpoint",
")",
"{",
"// We identified an endpoint",
"return",
"$",
"endpoint",
"->",
"listen",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"else",
"{",
"// We failed to find an endpoint, so we redirect to /errors/404",
"// This is not cached, because we don't want anybody to be able to fill the lookupCache with garbage",
"return",
"$",
"this",
"->",
"respondError",
"(",
"404",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"}"
] |
Handle an incoming request, map it to the correct endpoint using routes and call the listen method on the endpoint
|
[
"Handle",
"an",
"incoming",
"request",
"map",
"it",
"to",
"the",
"correct",
"endpoint",
"using",
"routes",
"and",
"call",
"the",
"listen",
"method",
"on",
"the",
"endpoint"
] |
3920f86a788c1a73360ebf6a215da15e097a1afa
|
https://github.com/frodeborli/fubber-reactor/blob/3920f86a788c1a73360ebf6a215da15e097a1afa/src/Host.php#L156-L206
|
21,999
|
frodeborli/fubber-reactor
|
src/Host.php
|
Host.scanRoutes
|
protected function scanRoutes($root, $realRoot=NULL) {
if($realRoot === NULL) $realRoot = $root;
$result = array();
$all = glob($root.'/*'); /* */
foreach($all as $path) {
if(!is_dir($path)) {
// This is an endpoint
$res = $this->createRouteFromFile($realRoot, $path);
if($res)
$result[] = $res;
} else {
$res = $this->scanRoutes($path, $realRoot);
foreach($res as $route)
$result[] = $route;
}
}
return $result;
}
|
php
|
protected function scanRoutes($root, $realRoot=NULL) {
if($realRoot === NULL) $realRoot = $root;
$result = array();
$all = glob($root.'/*'); /* */
foreach($all as $path) {
if(!is_dir($path)) {
// This is an endpoint
$res = $this->createRouteFromFile($realRoot, $path);
if($res)
$result[] = $res;
} else {
$res = $this->scanRoutes($path, $realRoot);
foreach($res as $route)
$result[] = $route;
}
}
return $result;
}
|
[
"protected",
"function",
"scanRoutes",
"(",
"$",
"root",
",",
"$",
"realRoot",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"realRoot",
"===",
"NULL",
")",
"$",
"realRoot",
"=",
"$",
"root",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"all",
"=",
"glob",
"(",
"$",
"root",
".",
"'/*'",
")",
";",
"/* */",
"foreach",
"(",
"$",
"all",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"// This is an endpoint",
"$",
"res",
"=",
"$",
"this",
"->",
"createRouteFromFile",
"(",
"$",
"realRoot",
",",
"$",
"path",
")",
";",
"if",
"(",
"$",
"res",
")",
"$",
"result",
"[",
"]",
"=",
"$",
"res",
";",
"}",
"else",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"scanRoutes",
"(",
"$",
"path",
",",
"$",
"realRoot",
")",
";",
"foreach",
"(",
"$",
"res",
"as",
"$",
"route",
")",
"$",
"result",
"[",
"]",
"=",
"$",
"route",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Recursively find all routes within path
|
[
"Recursively",
"find",
"all",
"routes",
"within",
"path"
] |
3920f86a788c1a73360ebf6a215da15e097a1afa
|
https://github.com/frodeborli/fubber-reactor/blob/3920f86a788c1a73360ebf6a215da15e097a1afa/src/Host.php#L283-L301
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.