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
|
---|---|---|---|---|---|---|---|---|---|---|---|
17,000 | teneleven/GeolocatorBundle | Provider/LocationProviderRegistry.php | LocationProviderRegistry.getProvider | public function getProvider($key)
{
if (!$this->hasProvider($key)) {
throw new \InvalidArgumentException(sprintf('Location Provider with key "%s" does not exist', $key));
}
return $this->providers[$key];
} | php | public function getProvider($key)
{
if (!$this->hasProvider($key)) {
throw new \InvalidArgumentException(sprintf('Location Provider with key "%s" does not exist', $key));
}
return $this->providers[$key];
} | [
"public",
"function",
"getProvider",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasProvider",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Location Provider with key \"%s\" does not exist'",
",",
"$",
"key",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"providers",
"[",
"$",
"key",
"]",
";",
"}"
]
| Get specified provider
@param $key
@return LocationProviderInterface
@throws \InvalidArgumentException | [
"Get",
"specified",
"provider"
]
| 4ead8e783a91577f2a67aa302b79641d4b9e99ad | https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Provider/LocationProviderRegistry.php#L73-L80 |
17,001 | JoshuaEstes/FeatureToggle | src/JoshuaEstes/Component/FeatureToggle/Toggle/FeatureToggle.php | FeatureToggle.setOption | public function setOption($option, $value)
{
$this->options[$option] = $value;
$this->resolve($this->options);
} | php | public function setOption($option, $value)
{
$this->options[$option] = $value;
$this->resolve($this->options);
} | [
"public",
"function",
"setOption",
"(",
"$",
"option",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"$",
"option",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"resolve",
"(",
"$",
"this",
"->",
"options",
")",
";",
"}"
]
| Set or modify an option after the object has been initialized
@param string $option
@param string $value | [
"Set",
"or",
"modify",
"an",
"option",
"after",
"the",
"object",
"has",
"been",
"initialized"
]
| d93b95b649acce80a6395d97cd165ba733971d84 | https://github.com/JoshuaEstes/FeatureToggle/blob/d93b95b649acce80a6395d97cd165ba733971d84/src/JoshuaEstes/Component/FeatureToggle/Toggle/FeatureToggle.php#L42-L46 |
17,002 | slashworks/control-bundle | src/Slashworks/AppBundle/Controller/LicenseController.php | LicenseController.createEditForm | private function createEditForm(License $oLicense)
{
$oForm = $this->createForm(new LicenseType(), $oLicense, array(
'action' => $this->generateUrl('license_update', array('id' => $oLicense->getId())),
'method' => 'PUT',
));
$oForm->add('submit', 'submit', array('label' => 'Update'));
return $oForm;
} | php | private function createEditForm(License $oLicense)
{
$oForm = $this->createForm(new LicenseType(), $oLicense, array(
'action' => $this->generateUrl('license_update', array('id' => $oLicense->getId())),
'method' => 'PUT',
));
$oForm->add('submit', 'submit', array('label' => 'Update'));
return $oForm;
} | [
"private",
"function",
"createEditForm",
"(",
"License",
"$",
"oLicense",
")",
"{",
"$",
"oForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"LicenseType",
"(",
")",
",",
"$",
"oLicense",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'license_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"oLicense",
"->",
"getId",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"$",
"oForm",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"'Update'",
")",
")",
";",
"return",
"$",
"oForm",
";",
"}"
]
| Create edit form for lucense
@param \Slashworks\AppBundle\Model\License $oLicense
@return \Symfony\Component\Form\Form | [
"Create",
"edit",
"form",
"for",
"lucense"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/LicenseController.php#L192-L203 |
17,003 | transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Manager/Core/ContentTreeService.php | ContentTreeService.publishContentObjects | private function publishContentObjects(TreeObject $object)
{
$last = $this->objectService->createOrUpdate($object->data);
foreach ($object->getNodes() as $subObject) {
if ($subObject instanceof TreeObject) {
$this->publishContentObjects($subObject);
} else {
/* @var ContentObject $subObject */
$subObject->addParentLocation($last->getProperty('content_info')->mainLocationId);
$this->objectService->createOrUpdate($subObject);
}
}
} | php | private function publishContentObjects(TreeObject $object)
{
$last = $this->objectService->createOrUpdate($object->data);
foreach ($object->getNodes() as $subObject) {
if ($subObject instanceof TreeObject) {
$this->publishContentObjects($subObject);
} else {
/* @var ContentObject $subObject */
$subObject->addParentLocation($last->getProperty('content_info')->mainLocationId);
$this->objectService->createOrUpdate($subObject);
}
}
} | [
"private",
"function",
"publishContentObjects",
"(",
"TreeObject",
"$",
"object",
")",
"{",
"$",
"last",
"=",
"$",
"this",
"->",
"objectService",
"->",
"createOrUpdate",
"(",
"$",
"object",
"->",
"data",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"getNodes",
"(",
")",
"as",
"$",
"subObject",
")",
"{",
"if",
"(",
"$",
"subObject",
"instanceof",
"TreeObject",
")",
"{",
"$",
"this",
"->",
"publishContentObjects",
"(",
"$",
"subObject",
")",
";",
"}",
"else",
"{",
"/* @var ContentObject $subObject */",
"$",
"subObject",
"->",
"addParentLocation",
"(",
"$",
"last",
"->",
"getProperty",
"(",
"'content_info'",
")",
"->",
"mainLocationId",
")",
";",
"$",
"this",
"->",
"objectService",
"->",
"createOrUpdate",
"(",
"$",
"subObject",
")",
";",
"}",
"}",
"}"
]
| Publishes content objects.
@param TreeObject $object
@throws \InvalidArgumentException | [
"Publishes",
"content",
"objects",
"."
]
| 1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ContentTreeService.php#L61-L74 |
17,004 | transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Manager/Core/ContentTreeService.php | ContentTreeService.remove | public function remove($object)
{
if ($this->logger) {
$this->logger->warning(sprintf(
'Attempted to delete using %s, which is not supported. Use the implementations of %s instead.',
__CLASS__,
EzPlatformObject::class
));
}
return;
} | php | public function remove($object)
{
if ($this->logger) {
$this->logger->warning(sprintf(
'Attempted to delete using %s, which is not supported. Use the implementations of %s instead.',
__CLASS__,
EzPlatformObject::class
));
}
return;
} | [
"public",
"function",
"remove",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"sprintf",
"(",
"'Attempted to delete using %s, which is not supported. Use the implementations of %s instead.'",
",",
"__CLASS__",
",",
"EzPlatformObject",
"::",
"class",
")",
")",
";",
"}",
"return",
";",
"}"
]
| Bulk-deletions is not supported.
@param ObjectInterface $object | [
"Bulk",
"-",
"deletions",
"is",
"not",
"supported",
"."
]
| 1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ContentTreeService.php#L81-L92 |
17,005 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/ObjectStorage.php | ObjectStorage.attach | public function attach(Threaded $object, $data = null)
{
$this->data[] = $object;
$this->info[] = $data;
} | php | public function attach(Threaded $object, $data = null)
{
$this->data[] = $object;
$this->info[] = $data;
} | [
"public",
"function",
"attach",
"(",
"Threaded",
"$",
"object",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"]",
"=",
"$",
"object",
";",
"$",
"this",
"->",
"info",
"[",
"]",
"=",
"$",
"data",
";",
"}"
]
| Adds an object in the storage
@param Threaded $object
@param mixed $data [optional]
@return void | [
"Adds",
"an",
"object",
"in",
"the",
"storage"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L35-L39 |
17,006 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/ObjectStorage.php | ObjectStorage.addAll | public function addAll(self $storage)
{
foreach ($storage->data as $object) {
$this->attach($object);
}
} | php | public function addAll(self $storage)
{
foreach ($storage->data as $object) {
$this->attach($object);
}
} | [
"public",
"function",
"addAll",
"(",
"self",
"$",
"storage",
")",
"{",
"foreach",
"(",
"$",
"storage",
"->",
"data",
"as",
"$",
"object",
")",
"{",
"$",
"this",
"->",
"attach",
"(",
"$",
"object",
")",
";",
"}",
"}"
]
| Adds all objects from another storage
@param ObjectStorage $storage
@return void | [
"Adds",
"all",
"objects",
"from",
"another",
"storage"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L79-L84 |
17,007 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/ObjectStorage.php | ObjectStorage.removeAll | public function removeAll(self $storage)
{
foreach ($this->data as $key => $value) {
foreach ($storage->data as $object) {
if ($object === $value) {
unset($this->data[$key]);
unset($this->info[$key]);
}
}
}
} | php | public function removeAll(self $storage)
{
foreach ($this->data as $key => $value) {
foreach ($storage->data as $object) {
if ($object === $value) {
unset($this->data[$key]);
unset($this->info[$key]);
}
}
}
} | [
"public",
"function",
"removeAll",
"(",
"self",
"$",
"storage",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"storage",
"->",
"data",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"$",
"value",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"info",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"}"
]
| Removes objects contained in another storage from the current storage
@param ObjectStorage $storage
@return void | [
"Removes",
"objects",
"contained",
"in",
"another",
"storage",
"from",
"the",
"current",
"storage"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L92-L102 |
17,008 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/ObjectStorage.php | ObjectStorage.getInfo | public function getInfo(Threaded $object)
{
foreach ($this->data as $key => $value) {
if ($object === $value) {
return $this->info[$key];
}
}
} | php | public function getInfo(Threaded $object)
{
foreach ($this->data as $key => $value) {
if ($object === $value) {
return $this->info[$key];
}
}
} | [
"public",
"function",
"getInfo",
"(",
"Threaded",
"$",
"object",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"info",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"}"
]
| Returns the data associated with the current iterator entry
@param Threaded $object
@return mixed The data associated with the current iterator position. | [
"Returns",
"the",
"data",
"associated",
"with",
"the",
"current",
"iterator",
"entry"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L128-L135 |
17,009 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/ObjectStorage.php | ObjectStorage.setInfo | public function setInfo(Threaded $object, $data)
{
foreach ($this->data as $key => $value) {
if ($object->equals($value)) {
$this->info[$key] = $data;
break;
}
}
} | php | public function setInfo(Threaded $object, $data)
{
foreach ($this->data as $key => $value) {
if ($object->equals($value)) {
$this->info[$key] = $data;
break;
}
}
} | [
"public",
"function",
"setInfo",
"(",
"Threaded",
"$",
"object",
",",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"object",
"->",
"equals",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"info",
"[",
"$",
"key",
"]",
"=",
"$",
"data",
";",
"break",
";",
"}",
"}",
"}"
]
| Sets the data associated with the current iterator entry
@param Threaded $object
@param mixed $data
@return void | [
"Sets",
"the",
"data",
"associated",
"with",
"the",
"current",
"iterator",
"entry"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L144-L152 |
17,010 | tableau-mkt/eggs-n-cereal | src/Utils/Converter.php | Converter.toXLIFF | public function toXLIFF($pretty_print = FALSE) {
$this->doc->formatOutput = $pretty_print;
// Do not use getElementById to comply with older versions of libxml.
// getElementById doesn't work properly on libxml 2.7.6 (CentOS)
$xpath = new \DOMXPath($this->doc);
$wrapper_div = $xpath->query("//*[@id='eggs-n-cereal-dont-ever-use-this-id']")->item(0);
$out = $this->doc->createDocumentFragment();
$domNodeList = array();
for ($i = 0; $i < $wrapper_div->childNodes->length; ++$i) {
$domNodeList[] = $wrapper_div->childNodes->item($i);
}
$this->sanitizeMixedDomNodeList($this->doc, $domNodeList);
foreach($domNodeList as $domNode){
if ($output = $this->convert($domNode)) {
$out->appendChild($output);
}
}
return $this->doc->saveXML($out);
} | php | public function toXLIFF($pretty_print = FALSE) {
$this->doc->formatOutput = $pretty_print;
// Do not use getElementById to comply with older versions of libxml.
// getElementById doesn't work properly on libxml 2.7.6 (CentOS)
$xpath = new \DOMXPath($this->doc);
$wrapper_div = $xpath->query("//*[@id='eggs-n-cereal-dont-ever-use-this-id']")->item(0);
$out = $this->doc->createDocumentFragment();
$domNodeList = array();
for ($i = 0; $i < $wrapper_div->childNodes->length; ++$i) {
$domNodeList[] = $wrapper_div->childNodes->item($i);
}
$this->sanitizeMixedDomNodeList($this->doc, $domNodeList);
foreach($domNodeList as $domNode){
if ($output = $this->convert($domNode)) {
$out->appendChild($output);
}
}
return $this->doc->saveXML($out);
} | [
"public",
"function",
"toXLIFF",
"(",
"$",
"pretty_print",
"=",
"FALSE",
")",
"{",
"$",
"this",
"->",
"doc",
"->",
"formatOutput",
"=",
"$",
"pretty_print",
";",
"// Do not use getElementById to comply with older versions of libxml.",
"// getElementById doesn't work properly on libxml 2.7.6 (CentOS)",
"$",
"xpath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"this",
"->",
"doc",
")",
";",
"$",
"wrapper_div",
"=",
"$",
"xpath",
"->",
"query",
"(",
"\"//*[@id='eggs-n-cereal-dont-ever-use-this-id']\"",
")",
"->",
"item",
"(",
"0",
")",
";",
"$",
"out",
"=",
"$",
"this",
"->",
"doc",
"->",
"createDocumentFragment",
"(",
")",
";",
"$",
"domNodeList",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"wrapper_div",
"->",
"childNodes",
"->",
"length",
";",
"++",
"$",
"i",
")",
"{",
"$",
"domNodeList",
"[",
"]",
"=",
"$",
"wrapper_div",
"->",
"childNodes",
"->",
"item",
"(",
"$",
"i",
")",
";",
"}",
"$",
"this",
"->",
"sanitizeMixedDomNodeList",
"(",
"$",
"this",
"->",
"doc",
",",
"$",
"domNodeList",
")",
";",
"foreach",
"(",
"$",
"domNodeList",
"as",
"$",
"domNode",
")",
"{",
"if",
"(",
"$",
"output",
"=",
"$",
"this",
"->",
"convert",
"(",
"$",
"domNode",
")",
")",
"{",
"$",
"out",
"->",
"appendChild",
"(",
"$",
"output",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"doc",
"->",
"saveXML",
"(",
"$",
"out",
")",
";",
"}"
]
| Converts HTML to the corresponding XLIFF representation.
@return string
The source HTML converted to XLIFF. | [
"Converts",
"HTML",
"to",
"the",
"corresponding",
"XLIFF",
"representation",
"."
]
| 778b83ddae1dd687724a84545ce8afa1a31e4bcf | https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Utils/Converter.php#L189-L213 |
17,011 | ARCANEDEV/Sanitizer | src/Http/FormRequest.php | FormRequest.sanitize | protected function sanitize()
{
$sanitized = sanitizer()->make(
$this->all(),
$this->sanitizerRules()
);
$this->replace($sanitized);
} | php | protected function sanitize()
{
$sanitized = sanitizer()->make(
$this->all(),
$this->sanitizerRules()
);
$this->replace($sanitized);
} | [
"protected",
"function",
"sanitize",
"(",
")",
"{",
"$",
"sanitized",
"=",
"sanitizer",
"(",
")",
"->",
"make",
"(",
"$",
"this",
"->",
"all",
"(",
")",
",",
"$",
"this",
"->",
"sanitizerRules",
"(",
")",
")",
";",
"$",
"this",
"->",
"replace",
"(",
"$",
"sanitized",
")",
";",
"}"
]
| Sanitize this request's input. | [
"Sanitize",
"this",
"request",
"s",
"input",
"."
]
| e21990ce6d881366d52a7f4e5040b07cc3ecca96 | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Http/FormRequest.php#L30-L38 |
17,012 | qcubed/orm | src/Database/Mysqli5/MysqliDatabase.php | MysqliDatabase.parseNameFromKeyDefinition | private function parseNameFromKeyDefinition($strKeyDefinition)
{
$strKeyDefinition = trim($strKeyDefinition);
$intPosition = strpos($strKeyDefinition, '(');
if ($intPosition === false) {
throw new \Exception("Invalid Key Definition: $strKeyDefinition");
} else {
if ($intPosition == 0) // No Key Name Defined
{
return null;
}
}
// If we're here, then we have a key name defined
$strName = trim(substr($strKeyDefinition, 0, $intPosition));
// Rip Out leading and trailing "`" character (if applicable)
if (substr($strName, 0, 1) == '`') {
return substr($strName, 1, strlen($strName) - 2);
} else {
return $strName;
}
} | php | private function parseNameFromKeyDefinition($strKeyDefinition)
{
$strKeyDefinition = trim($strKeyDefinition);
$intPosition = strpos($strKeyDefinition, '(');
if ($intPosition === false) {
throw new \Exception("Invalid Key Definition: $strKeyDefinition");
} else {
if ($intPosition == 0) // No Key Name Defined
{
return null;
}
}
// If we're here, then we have a key name defined
$strName = trim(substr($strKeyDefinition, 0, $intPosition));
// Rip Out leading and trailing "`" character (if applicable)
if (substr($strName, 0, 1) == '`') {
return substr($strName, 1, strlen($strName) - 2);
} else {
return $strName;
}
} | [
"private",
"function",
"parseNameFromKeyDefinition",
"(",
"$",
"strKeyDefinition",
")",
"{",
"$",
"strKeyDefinition",
"=",
"trim",
"(",
"$",
"strKeyDefinition",
")",
";",
"$",
"intPosition",
"=",
"strpos",
"(",
"$",
"strKeyDefinition",
",",
"'('",
")",
";",
"if",
"(",
"$",
"intPosition",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid Key Definition: $strKeyDefinition\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"intPosition",
"==",
"0",
")",
"// No Key Name Defined",
"{",
"return",
"null",
";",
"}",
"}",
"// If we're here, then we have a key name defined",
"$",
"strName",
"=",
"trim",
"(",
"substr",
"(",
"$",
"strKeyDefinition",
",",
"0",
",",
"$",
"intPosition",
")",
")",
";",
"// Rip Out leading and trailing \"`\" character (if applicable)",
"if",
"(",
"substr",
"(",
"$",
"strName",
",",
"0",
",",
"1",
")",
"==",
"'`'",
")",
"{",
"return",
"substr",
"(",
"$",
"strName",
",",
"1",
",",
"strlen",
"(",
"$",
"strName",
")",
"-",
"2",
")",
";",
"}",
"else",
"{",
"return",
"$",
"strName",
";",
"}",
"}"
]
| If the key name exists, this will parse it out and return it | [
"If",
"the",
"key",
"name",
"exists",
"this",
"will",
"parse",
"it",
"out",
"and",
"return",
"it"
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/Mysqli5/MysqliDatabase.php#L281-L305 |
17,013 | webforge-labs/psc-cms | lib/Psc/CMS/Controller/FileUploadController.php | FileUploadController.getFiles | public function getFiles(Array $criteria = array(), Array $orderBy = NULL) {
$files = new \Psc\Data\ArrayCollection(
$this->manager->getRepository()->findBy($criteria, $orderBy)
);
foreach ($files as $file) {
$this->manager->attach($file);
}
return $files;
} | php | public function getFiles(Array $criteria = array(), Array $orderBy = NULL) {
$files = new \Psc\Data\ArrayCollection(
$this->manager->getRepository()->findBy($criteria, $orderBy)
);
foreach ($files as $file) {
$this->manager->attach($file);
}
return $files;
} | [
"public",
"function",
"getFiles",
"(",
"Array",
"$",
"criteria",
"=",
"array",
"(",
")",
",",
"Array",
"$",
"orderBy",
"=",
"NULL",
")",
"{",
"$",
"files",
"=",
"new",
"\\",
"Psc",
"\\",
"Data",
"\\",
"ArrayCollection",
"(",
"$",
"this",
"->",
"manager",
"->",
"getRepository",
"(",
")",
"->",
"findBy",
"(",
"$",
"criteria",
",",
"$",
"orderBy",
")",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"manager",
"->",
"attach",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"files",
";",
"}"
]
| Returns a list of all uploaded files
@return array | [
"Returns",
"a",
"list",
"of",
"all",
"uploaded",
"files"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/FileUploadController.php#L64-L74 |
17,014 | CakeCMS/Core | src/View/AppView.php | AppView.getViewFile | public function getViewFile($name)
{
list($plugin, $name) = $this->pluginSplit($name);
$return = null;
foreach ($this->_paths($plugin) as $path) {
$viewFile = FS::clean($path . $name . $this->_ext);
if (FS::isFile($viewFile)) {
$return = $this->_checkFilePath($viewFile, $path);
break;
}
}
return $return;
} | php | public function getViewFile($name)
{
list($plugin, $name) = $this->pluginSplit($name);
$return = null;
foreach ($this->_paths($plugin) as $path) {
$viewFile = FS::clean($path . $name . $this->_ext);
if (FS::isFile($viewFile)) {
$return = $this->_checkFilePath($viewFile, $path);
break;
}
}
return $return;
} | [
"public",
"function",
"getViewFile",
"(",
"$",
"name",
")",
"{",
"list",
"(",
"$",
"plugin",
",",
"$",
"name",
")",
"=",
"$",
"this",
"->",
"pluginSplit",
"(",
"$",
"name",
")",
";",
"$",
"return",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"_paths",
"(",
"$",
"plugin",
")",
"as",
"$",
"path",
")",
"{",
"$",
"viewFile",
"=",
"FS",
"::",
"clean",
"(",
"$",
"path",
".",
"$",
"name",
".",
"$",
"this",
"->",
"_ext",
")",
";",
"if",
"(",
"FS",
"::",
"isFile",
"(",
"$",
"viewFile",
")",
")",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"_checkFilePath",
"(",
"$",
"viewFile",
",",
"$",
"path",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
]
| Get view file path.
@param string $name
@return null|string | [
"Get",
"view",
"file",
"path",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L64-L77 |
17,015 | CakeCMS/Core | src/View/AppView.php | AppView.partial | public function partial($name, array $data = [])
{
$file = $this->_getLayoutPartialPath($name);
if (FS::isFile($file)) {
return $this->_render($file, $data);
}
return null;
} | php | public function partial($name, array $data = [])
{
$file = $this->_getLayoutPartialPath($name);
if (FS::isFile($file)) {
return $this->_render($file, $data);
}
return null;
} | [
"public",
"function",
"partial",
"(",
"$",
"name",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"_getLayoutPartialPath",
"(",
"$",
"name",
")",
";",
"if",
"(",
"FS",
"::",
"isFile",
"(",
"$",
"file",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_render",
"(",
"$",
"file",
",",
"$",
"data",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Render layout partial.
@param string $name
@param array $data
@return null|string | [
"Render",
"layout",
"partial",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L109-L118 |
17,016 | CakeCMS/Core | src/View/AppView.php | AppView._findViewByRequest | protected function _findViewByRequest()
{
$paths = App::path('Template', $this->plugin);
$action = (string) $this->request->getParam('action');
$controller = $this->request->getParam('controller');
$viewFile = $action . $this->_ext;
$viewSubPath = $this->_getSubPaths($controller);
foreach ($paths as $path) {
foreach ($viewSubPath as $subPath) {
$full = $path . $subPath . DS . $viewFile;
if (FS::isFile($full)) {
return $action;
}
$formView = $path . $subPath . DS . self::VIEW_FORM . $this->_ext;
if (FS::isFile($formView)) {
return self::VIEW_FORM;
}
}
}
return null;
} | php | protected function _findViewByRequest()
{
$paths = App::path('Template', $this->plugin);
$action = (string) $this->request->getParam('action');
$controller = $this->request->getParam('controller');
$viewFile = $action . $this->_ext;
$viewSubPath = $this->_getSubPaths($controller);
foreach ($paths as $path) {
foreach ($viewSubPath as $subPath) {
$full = $path . $subPath . DS . $viewFile;
if (FS::isFile($full)) {
return $action;
}
$formView = $path . $subPath . DS . self::VIEW_FORM . $this->_ext;
if (FS::isFile($formView)) {
return self::VIEW_FORM;
}
}
}
return null;
} | [
"protected",
"function",
"_findViewByRequest",
"(",
")",
"{",
"$",
"paths",
"=",
"App",
"::",
"path",
"(",
"'Template'",
",",
"$",
"this",
"->",
"plugin",
")",
";",
"$",
"action",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'action'",
")",
";",
"$",
"controller",
"=",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'controller'",
")",
";",
"$",
"viewFile",
"=",
"$",
"action",
".",
"$",
"this",
"->",
"_ext",
";",
"$",
"viewSubPath",
"=",
"$",
"this",
"->",
"_getSubPaths",
"(",
"$",
"controller",
")",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"viewSubPath",
"as",
"$",
"subPath",
")",
"{",
"$",
"full",
"=",
"$",
"path",
".",
"$",
"subPath",
".",
"DS",
".",
"$",
"viewFile",
";",
"if",
"(",
"FS",
"::",
"isFile",
"(",
"$",
"full",
")",
")",
"{",
"return",
"$",
"action",
";",
"}",
"$",
"formView",
"=",
"$",
"path",
".",
"$",
"subPath",
".",
"DS",
".",
"self",
"::",
"VIEW_FORM",
".",
"$",
"this",
"->",
"_ext",
";",
"if",
"(",
"FS",
"::",
"isFile",
"(",
"$",
"formView",
")",
")",
"{",
"return",
"self",
"::",
"VIEW_FORM",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
]
| Find form view by request.
@return string|null | [
"Find",
"form",
"view",
"by",
"request",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L138-L162 |
17,017 | CakeCMS/Core | src/View/AppView.php | AppView._getFormView | protected function _getFormView($view = null)
{
if (empty($view) && Arr::in($this->request->getParam('action'), $this->_formActions)) {
$view = $this->_findViewByRequest();
}
return $view;
} | php | protected function _getFormView($view = null)
{
if (empty($view) && Arr::in($this->request->getParam('action'), $this->_formActions)) {
$view = $this->_findViewByRequest();
}
return $view;
} | [
"protected",
"function",
"_getFormView",
"(",
"$",
"view",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"view",
")",
"&&",
"Arr",
"::",
"in",
"(",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'action'",
")",
",",
"$",
"this",
"->",
"_formActions",
")",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"_findViewByRequest",
"(",
")",
";",
"}",
"return",
"$",
"view",
";",
"}"
]
| Get current form view.
@param null|string $view
@return null | [
"Get",
"current",
"form",
"view",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L170-L177 |
17,018 | CakeCMS/Core | src/View/AppView.php | AppView._getLayoutPartialPath | protected function _getLayoutPartialPath($name)
{
list($plugin, $name) = $this->pluginSplit($name);
$paths = $this->_paths($plugin);
$layoutPaths = $this->_getSubPaths('Layout' . DS . 'Partial');
foreach ($paths as $path) {
foreach ($layoutPaths as $layoutPath) {
$partial = $path . $layoutPath . DS . $name . $this->_ext;
if (FS::isFile($partial)) {
return $partial;
}
}
}
return false;
} | php | protected function _getLayoutPartialPath($name)
{
list($plugin, $name) = $this->pluginSplit($name);
$paths = $this->_paths($plugin);
$layoutPaths = $this->_getSubPaths('Layout' . DS . 'Partial');
foreach ($paths as $path) {
foreach ($layoutPaths as $layoutPath) {
$partial = $path . $layoutPath . DS . $name . $this->_ext;
if (FS::isFile($partial)) {
return $partial;
}
}
}
return false;
} | [
"protected",
"function",
"_getLayoutPartialPath",
"(",
"$",
"name",
")",
"{",
"list",
"(",
"$",
"plugin",
",",
"$",
"name",
")",
"=",
"$",
"this",
"->",
"pluginSplit",
"(",
"$",
"name",
")",
";",
"$",
"paths",
"=",
"$",
"this",
"->",
"_paths",
"(",
"$",
"plugin",
")",
";",
"$",
"layoutPaths",
"=",
"$",
"this",
"->",
"_getSubPaths",
"(",
"'Layout'",
".",
"DS",
".",
"'Partial'",
")",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"layoutPaths",
"as",
"$",
"layoutPath",
")",
"{",
"$",
"partial",
"=",
"$",
"path",
".",
"$",
"layoutPath",
".",
"DS",
".",
"$",
"name",
".",
"$",
"this",
"->",
"_ext",
";",
"if",
"(",
"FS",
"::",
"isFile",
"(",
"$",
"partial",
")",
")",
"{",
"return",
"$",
"partial",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
]
| Finds an partial filename, returns false on failure.
@param string $name
@return bool|string | [
"Finds",
"an",
"partial",
"filename",
"returns",
"false",
"on",
"failure",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L185-L202 |
17,019 | traderinteractive/util-file-php | src/File.php | File.deleteDirectoryContents | public static function deleteDirectoryContents(string $directoryPath)
{
$paths = scandir($directoryPath);
if ($paths === false) {
throw new \Exception("cannot list directory '{$directoryPath}'");
}
foreach ($paths as $path) {
if ($path === '.' || $path === '..') {
continue;
}
$fullPath = "{$directoryPath}/{$path}";
if (is_dir($fullPath)) {
self::deleteDirectoryContents($fullPath);//RECURSIVE CALL
self::throwIfFalse(rmdir($fullPath), "cannot delete '{$fullPath}'", 1);
continue;
}
self::throwIfFalse(unlink($fullPath), "cannot delete '{$fullPath}'", 2);
}
} | php | public static function deleteDirectoryContents(string $directoryPath)
{
$paths = scandir($directoryPath);
if ($paths === false) {
throw new \Exception("cannot list directory '{$directoryPath}'");
}
foreach ($paths as $path) {
if ($path === '.' || $path === '..') {
continue;
}
$fullPath = "{$directoryPath}/{$path}";
if (is_dir($fullPath)) {
self::deleteDirectoryContents($fullPath);//RECURSIVE CALL
self::throwIfFalse(rmdir($fullPath), "cannot delete '{$fullPath}'", 1);
continue;
}
self::throwIfFalse(unlink($fullPath), "cannot delete '{$fullPath}'", 2);
}
} | [
"public",
"static",
"function",
"deleteDirectoryContents",
"(",
"string",
"$",
"directoryPath",
")",
"{",
"$",
"paths",
"=",
"scandir",
"(",
"$",
"directoryPath",
")",
";",
"if",
"(",
"$",
"paths",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"cannot list directory '{$directoryPath}'\"",
")",
";",
"}",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"'.'",
"||",
"$",
"path",
"===",
"'..'",
")",
"{",
"continue",
";",
"}",
"$",
"fullPath",
"=",
"\"{$directoryPath}/{$path}\"",
";",
"if",
"(",
"is_dir",
"(",
"$",
"fullPath",
")",
")",
"{",
"self",
"::",
"deleteDirectoryContents",
"(",
"$",
"fullPath",
")",
";",
"//RECURSIVE CALL",
"self",
"::",
"throwIfFalse",
"(",
"rmdir",
"(",
"$",
"fullPath",
")",
",",
"\"cannot delete '{$fullPath}'\"",
",",
"1",
")",
";",
"continue",
";",
"}",
"self",
"::",
"throwIfFalse",
"(",
"unlink",
"(",
"$",
"fullPath",
")",
",",
"\"cannot delete '{$fullPath}'\"",
",",
"2",
")",
";",
"}",
"}"
]
| Recursively deletes directory contents
@param string $directoryPath absolute path of directory
@return void
@throws \Exception if file cannot be deleted
@throws \Exception if directory cannot be deleted
@throws \Exception if $directoryPath cannot be listed | [
"Recursively",
"deletes",
"directory",
"contents"
]
| 07711b5f91232c39264c706c30dab07356dc823f | https://github.com/traderinteractive/util-file-php/blob/07711b5f91232c39264c706c30dab07356dc823f/src/File.php#L24-L46 |
17,020 | simplisti/jasper-starter | src/OptionFileTrait.php | OptionFileTrait.getCsvfile | public function getCsvfile ($key)
{
if (array_key_exists($key, $this->csv)) {
return $this->csv[$key];
}
return false;
} | php | public function getCsvfile ($key)
{
if (array_key_exists($key, $this->csv)) {
return $this->csv[$key];
}
return false;
} | [
"public",
"function",
"getCsvfile",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"csv",
")",
")",
"{",
"return",
"$",
"this",
"->",
"csv",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"false",
";",
"}"
]
| Get the CSV file details for data source or false on failure
@return string | [
"Get",
"the",
"CSV",
"file",
"details",
"for",
"data",
"source",
"or",
"false",
"on",
"failure"
]
| e03e24663e983710fb4f1afad6c85bde8553de65 | https://github.com/simplisti/jasper-starter/blob/e03e24663e983710fb4f1afad6c85bde8553de65/src/OptionFileTrait.php#L46-L53 |
17,021 | simplisti/jasper-starter | src/OptionFileTrait.php | OptionFileTrait.setCsvOptions | public function setCsvOptions ($charSet = 'utf-8', $delimField = ",", $delimNewLine = "\n", array $columnHeaderNames = [])
{
$this->csv['charSet'] = $charSet;
$this->csv['delimField'] = $delimField;
$this->csv['delimNewLine'] = $delimNewLine;
$this->csv['columnHeaderNames'] = $columnHeaderNames;
return $this;
} | php | public function setCsvOptions ($charSet = 'utf-8', $delimField = ",", $delimNewLine = "\n", array $columnHeaderNames = [])
{
$this->csv['charSet'] = $charSet;
$this->csv['delimField'] = $delimField;
$this->csv['delimNewLine'] = $delimNewLine;
$this->csv['columnHeaderNames'] = $columnHeaderNames;
return $this;
} | [
"public",
"function",
"setCsvOptions",
"(",
"$",
"charSet",
"=",
"'utf-8'",
",",
"$",
"delimField",
"=",
"\",\"",
",",
"$",
"delimNewLine",
"=",
"\"\\n\"",
",",
"array",
"$",
"columnHeaderNames",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"csv",
"[",
"'charSet'",
"]",
"=",
"$",
"charSet",
";",
"$",
"this",
"->",
"csv",
"[",
"'delimField'",
"]",
"=",
"$",
"delimField",
";",
"$",
"this",
"->",
"csv",
"[",
"'delimNewLine'",
"]",
"=",
"$",
"delimNewLine",
";",
"$",
"this",
"->",
"csv",
"[",
"'columnHeaderNames'",
"]",
"=",
"$",
"columnHeaderNames",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the CSV file details for data source
@return $this | [
"Set",
"the",
"CSV",
"file",
"details",
"for",
"data",
"source"
]
| e03e24663e983710fb4f1afad6c85bde8553de65 | https://github.com/simplisti/jasper-starter/blob/e03e24663e983710fb4f1afad6c85bde8553de65/src/OptionFileTrait.php#L60-L69 |
17,022 | catacgc/juice-di-container | src/Container.php | JuiceContainer.offsetSet | public function offsetSet($id, $value)
{
if ($this->locked) {
throw new BadMethodCallException('Setting values into a locked container is not allowed');
}
if ($value instanceof JuiceParam) {
$this->values[$id] = $value->value;
return;
}
if (is_callable($value) || $value instanceof JuiceDefinition) {
$this->definitions[$id] = $value;
return;
}
if (is_string($value) && '@' == $value[0]) {
$this->aliases[$id] = substr($value, 1);
return;
}
$this->values[$id] = $value;
} | php | public function offsetSet($id, $value)
{
if ($this->locked) {
throw new BadMethodCallException('Setting values into a locked container is not allowed');
}
if ($value instanceof JuiceParam) {
$this->values[$id] = $value->value;
return;
}
if (is_callable($value) || $value instanceof JuiceDefinition) {
$this->definitions[$id] = $value;
return;
}
if (is_string($value) && '@' == $value[0]) {
$this->aliases[$id] = substr($value, 1);
return;
}
$this->values[$id] = $value;
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"id",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locked",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'Setting values into a locked container is not allowed'",
")",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"JuiceParam",
")",
"{",
"$",
"this",
"->",
"values",
"[",
"$",
"id",
"]",
"=",
"$",
"value",
"->",
"value",
";",
"return",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"value",
")",
"||",
"$",
"value",
"instanceof",
"JuiceDefinition",
")",
"{",
"$",
"this",
"->",
"definitions",
"[",
"$",
"id",
"]",
"=",
"$",
"value",
";",
"return",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
"&&",
"'@'",
"==",
"$",
"value",
"[",
"0",
"]",
")",
"{",
"$",
"this",
"->",
"aliases",
"[",
"$",
"id",
"]",
"=",
"substr",
"(",
"$",
"value",
",",
"1",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"values",
"[",
"$",
"id",
"]",
"=",
"$",
"value",
";",
"}"
]
| Sets a parameter or a definition | [
"Sets",
"a",
"parameter",
"or",
"a",
"definition"
]
| 773bb155b9d2fd8b8bed7754d88edc3b06d6d12d | https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L46-L68 |
17,023 | catacgc/juice-di-container | src/Container.php | JuiceContainer.getServiceOrParameter | private function getServiceOrParameter($id)
{
if (array_key_exists($id, $this->aliases)) {
return $this->offsetGet($this->aliases[$id]);
}
if (array_key_exists($id, $this->values)) {
return $this->values[$id];
}
if (array_key_exists($id, $this->definitions)) {
return $this->values[$id] = $this->build($this->definitions[$id]);
}
throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
} | php | private function getServiceOrParameter($id)
{
if (array_key_exists($id, $this->aliases)) {
return $this->offsetGet($this->aliases[$id]);
}
if (array_key_exists($id, $this->values)) {
return $this->values[$id];
}
if (array_key_exists($id, $this->definitions)) {
return $this->values[$id] = $this->build($this->definitions[$id]);
}
throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
} | [
"private",
"function",
"getServiceOrParameter",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"aliases",
")",
")",
"{",
"return",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"this",
"->",
"aliases",
"[",
"$",
"id",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"values",
")",
")",
"{",
"return",
"$",
"this",
"->",
"values",
"[",
"$",
"id",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"definitions",
")",
")",
"{",
"return",
"$",
"this",
"->",
"values",
"[",
"$",
"id",
"]",
"=",
"$",
"this",
"->",
"build",
"(",
"$",
"this",
"->",
"definitions",
"[",
"$",
"id",
"]",
")",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Identifier \"%s\" is not defined.'",
",",
"$",
"id",
")",
")",
";",
"}"
]
| Return the service associated with this unique identifier
@param string $id The unique identifier
@return mixed
@throws InvalidArgumentException | [
"Return",
"the",
"service",
"associated",
"with",
"this",
"unique",
"identifier"
]
| 773bb155b9d2fd8b8bed7754d88edc3b06d6d12d | https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L102-L117 |
17,024 | catacgc/juice-di-container | src/Container.php | JuiceContainer.build | public function build($definition)
{
if (is_callable($definition)) {
return call_user_func($definition, $this);
}
return $this->buildFromDefinition($definition);
} | php | public function build($definition)
{
if (is_callable($definition)) {
return call_user_func($definition, $this);
}
return $this->buildFromDefinition($definition);
} | [
"public",
"function",
"build",
"(",
"$",
"definition",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"definition",
")",
")",
"{",
"return",
"call_user_func",
"(",
"$",
"definition",
",",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"buildFromDefinition",
"(",
"$",
"definition",
")",
";",
"}"
]
| Build a definition and return the instantiated object
@param $definition
@return mixed | [
"Build",
"a",
"definition",
"and",
"return",
"the",
"instantiated",
"object"
]
| 773bb155b9d2fd8b8bed7754d88edc3b06d6d12d | https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L175-L182 |
17,025 | catacgc/juice-di-container | src/Container.php | JuiceContainer.resolveValue | protected function resolveValue($value)
{
if (is_array($value)) {
foreach ($value as $index => $val) {
$value[$index] = $this->resolveValue($val);
}
return $value;
}
if (is_string($value) && '@' == $value[0]) {
return $this->offsetGet(substr($value, 1));
}
return $value;
} | php | protected function resolveValue($value)
{
if (is_array($value)) {
foreach ($value as $index => $val) {
$value[$index] = $this->resolveValue($val);
}
return $value;
}
if (is_string($value) && '@' == $value[0]) {
return $this->offsetGet(substr($value, 1));
}
return $value;
} | [
"protected",
"function",
"resolveValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"index",
"=>",
"$",
"val",
")",
"{",
"$",
"value",
"[",
"$",
"index",
"]",
"=",
"$",
"this",
"->",
"resolveValue",
"(",
"$",
"val",
")",
";",
"}",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
"&&",
"'@'",
"==",
"$",
"value",
"[",
"0",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"offsetGet",
"(",
"substr",
"(",
"$",
"value",
",",
"1",
")",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Finds and marks references (strings beginning with an @) to other services or parameters | [
"Finds",
"and",
"marks",
"references",
"(",
"strings",
"beginning",
"with",
"an"
]
| 773bb155b9d2fd8b8bed7754d88edc3b06d6d12d | https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L202-L217 |
17,026 | struzik-vladislav/php-error-handler | src/Processor/LoggerProcessor.php | LoggerProcessor.getAssociatedLogLevel | private function getAssociatedLogLevel($errno)
{
$associations = [
E_WARNING => LogLevel::WARNING,
E_NOTICE => LogLevel::NOTICE,
E_USER_ERROR => LogLevel::ERROR,
E_USER_WARNING => LogLevel::WARNING,
E_USER_NOTICE => LogLevel::NOTICE,
E_STRICT => LogLevel::NOTICE,
E_RECOVERABLE_ERROR => LogLevel::ERROR,
E_DEPRECATED => LogLevel::NOTICE,
E_USER_DEPRECATED => LogLevel::NOTICE,
];
if (isset($associations[$errno])) {
return $associations[$errno];
}
return LogLevel::CRITICAL;
} | php | private function getAssociatedLogLevel($errno)
{
$associations = [
E_WARNING => LogLevel::WARNING,
E_NOTICE => LogLevel::NOTICE,
E_USER_ERROR => LogLevel::ERROR,
E_USER_WARNING => LogLevel::WARNING,
E_USER_NOTICE => LogLevel::NOTICE,
E_STRICT => LogLevel::NOTICE,
E_RECOVERABLE_ERROR => LogLevel::ERROR,
E_DEPRECATED => LogLevel::NOTICE,
E_USER_DEPRECATED => LogLevel::NOTICE,
];
if (isset($associations[$errno])) {
return $associations[$errno];
}
return LogLevel::CRITICAL;
} | [
"private",
"function",
"getAssociatedLogLevel",
"(",
"$",
"errno",
")",
"{",
"$",
"associations",
"=",
"[",
"E_WARNING",
"=>",
"LogLevel",
"::",
"WARNING",
",",
"E_NOTICE",
"=>",
"LogLevel",
"::",
"NOTICE",
",",
"E_USER_ERROR",
"=>",
"LogLevel",
"::",
"ERROR",
",",
"E_USER_WARNING",
"=>",
"LogLevel",
"::",
"WARNING",
",",
"E_USER_NOTICE",
"=>",
"LogLevel",
"::",
"NOTICE",
",",
"E_STRICT",
"=>",
"LogLevel",
"::",
"NOTICE",
",",
"E_RECOVERABLE_ERROR",
"=>",
"LogLevel",
"::",
"ERROR",
",",
"E_DEPRECATED",
"=>",
"LogLevel",
"::",
"NOTICE",
",",
"E_USER_DEPRECATED",
"=>",
"LogLevel",
"::",
"NOTICE",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"associations",
"[",
"$",
"errno",
"]",
")",
")",
"{",
"return",
"$",
"associations",
"[",
"$",
"errno",
"]",
";",
"}",
"return",
"LogLevel",
"::",
"CRITICAL",
";",
"}"
]
| Getting the log level constant associated with error code.
@param int $errno level of the error raised
@return string | [
"Getting",
"the",
"log",
"level",
"constant",
"associated",
"with",
"error",
"code",
"."
]
| 87fa9f56edca7011f78e00659bb094b4fe713ebe | https://github.com/struzik-vladislav/php-error-handler/blob/87fa9f56edca7011f78e00659bb094b4fe713ebe/src/Processor/LoggerProcessor.php#L81-L100 |
17,027 | anime-db/world-art-filler-bundle | src/Service/Refiller.php | Refiller.isCanSearch | public function isCanSearch(Item $item, $field)
{
if (!in_array($field, $this->supported_fields)) {
return false;
}
if ($this->isCanRefill($item, $field) || $item->getName()) {
return true;
}
/* @var $name \AnimeDb\Bundle\CatalogBundle\Entity\Name */
foreach ($item->getNames() as $name) {
if ($name->getName()) {
return true;
}
}
return false;
} | php | public function isCanSearch(Item $item, $field)
{
if (!in_array($field, $this->supported_fields)) {
return false;
}
if ($this->isCanRefill($item, $field) || $item->getName()) {
return true;
}
/* @var $name \AnimeDb\Bundle\CatalogBundle\Entity\Name */
foreach ($item->getNames() as $name) {
if ($name->getName()) {
return true;
}
}
return false;
} | [
"public",
"function",
"isCanSearch",
"(",
"Item",
"$",
"item",
",",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"supported_fields",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isCanRefill",
"(",
"$",
"item",
",",
"$",
"field",
")",
"||",
"$",
"item",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"/* @var $name \\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Name */",
"foreach",
"(",
"$",
"item",
"->",
"getNames",
"(",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Is can search.
@param \AnimeDb\Bundle\CatalogBundle\Entity\Item $item
@param string $field
@return bool | [
"Is",
"can",
"search",
"."
]
| f2ef4dbd12fe39c18183d1628b5049b8d381e42c | https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Service/Refiller.php#L165-L181 |
17,028 | anime-db/world-art-filler-bundle | src/Service/Refiller.php | Refiller.search | public function search(Item $item, $field)
{
// can refill from source. not need search
if ($url = $this->getSourceForFill($item)) {
return [
new ItemRefiller(
$item->getName(),
['url' => $url],
$url,
$item->getCover(),
$item->getSummary()
),
];
}
// get name for search
if (!($name = $item->getName())) {
foreach ($item->getNames() as $name) {
if ($name) {
break;
}
}
}
$result = [];
// do search
if ($name) {
$result = $this->search->search(['name' => $name]);
/* @var $item \AnimeDb\Bundle\CatalogBundle\Plugin\Fill\Search\Item */
foreach ($result as $key => $item) {
parse_str(parse_url($item->getLink(), PHP_URL_QUERY), $query);
$link = array_values($query)[0]['url'];
$result[$key] = new ItemRefiller(
$item->getName(),
['url' => $link],
$link,
$item->getImage(),
$item->getDescription()
);
}
}
return $result;
} | php | public function search(Item $item, $field)
{
// can refill from source. not need search
if ($url = $this->getSourceForFill($item)) {
return [
new ItemRefiller(
$item->getName(),
['url' => $url],
$url,
$item->getCover(),
$item->getSummary()
),
];
}
// get name for search
if (!($name = $item->getName())) {
foreach ($item->getNames() as $name) {
if ($name) {
break;
}
}
}
$result = [];
// do search
if ($name) {
$result = $this->search->search(['name' => $name]);
/* @var $item \AnimeDb\Bundle\CatalogBundle\Plugin\Fill\Search\Item */
foreach ($result as $key => $item) {
parse_str(parse_url($item->getLink(), PHP_URL_QUERY), $query);
$link = array_values($query)[0]['url'];
$result[$key] = new ItemRefiller(
$item->getName(),
['url' => $link],
$link,
$item->getImage(),
$item->getDescription()
);
}
}
return $result;
} | [
"public",
"function",
"search",
"(",
"Item",
"$",
"item",
",",
"$",
"field",
")",
"{",
"// can refill from source. not need search",
"if",
"(",
"$",
"url",
"=",
"$",
"this",
"->",
"getSourceForFill",
"(",
"$",
"item",
")",
")",
"{",
"return",
"[",
"new",
"ItemRefiller",
"(",
"$",
"item",
"->",
"getName",
"(",
")",
",",
"[",
"'url'",
"=>",
"$",
"url",
"]",
",",
"$",
"url",
",",
"$",
"item",
"->",
"getCover",
"(",
")",
",",
"$",
"item",
"->",
"getSummary",
"(",
")",
")",
",",
"]",
";",
"}",
"// get name for search",
"if",
"(",
"!",
"(",
"$",
"name",
"=",
"$",
"item",
"->",
"getName",
"(",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"item",
"->",
"getNames",
"(",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
")",
"{",
"break",
";",
"}",
"}",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"// do search",
"if",
"(",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"search",
"->",
"search",
"(",
"[",
"'name'",
"=>",
"$",
"name",
"]",
")",
";",
"/* @var $item \\AnimeDb\\Bundle\\CatalogBundle\\Plugin\\Fill\\Search\\Item */",
"foreach",
"(",
"$",
"result",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"parse_str",
"(",
"parse_url",
"(",
"$",
"item",
"->",
"getLink",
"(",
")",
",",
"PHP_URL_QUERY",
")",
",",
"$",
"query",
")",
";",
"$",
"link",
"=",
"array_values",
"(",
"$",
"query",
")",
"[",
"0",
"]",
"[",
"'url'",
"]",
";",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"new",
"ItemRefiller",
"(",
"$",
"item",
"->",
"getName",
"(",
")",
",",
"[",
"'url'",
"=>",
"$",
"link",
"]",
",",
"$",
"link",
",",
"$",
"item",
"->",
"getImage",
"(",
")",
",",
"$",
"item",
"->",
"getDescription",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Search items for refill.
@param \AnimeDb\Bundle\CatalogBundle\Entity\Item $item
@param string $field
@return array [\AnimeDb\Bundle\CatalogBundle\Plugin\Fill\Refiller\Item] | [
"Search",
"items",
"for",
"refill",
"."
]
| f2ef4dbd12fe39c18183d1628b5049b8d381e42c | https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Service/Refiller.php#L191-L234 |
17,029 | anime-db/world-art-filler-bundle | src/Service/Refiller.php | Refiller.fillItem | protected function fillItem(Item $item, Item $new_item, $field)
{
switch ($field) {
case self::FIELD_COUNTRY:
$item->setCountry($new_item->getCountry());
break;
case self::FIELD_DATE_END:
$item->setDateEnd($new_item->getDateEnd());
break;
case self::FIELD_DATE_PREMIERE:
$item->setDatePremiere($new_item->getDatePremiere());
break;
case self::FIELD_DURATION:
$item->setDuration($new_item->getDuration());
break;
case self::FIELD_EPISODES:
$item->setEpisodes($new_item->getEpisodes());
break;
case self::FIELD_EPISODES_NUMBER:
$item->setEpisodesNumber($new_item->getEpisodesNumber());
break;
case self::FIELD_FILE_INFO:
$item->setFileInfo($new_item->getFileInfo());
break;
case self::FIELD_GENRES:
/* @var $new_genre \AnimeDb\Bundle\CatalogBundle\Entity\Genre */
foreach ($new_item->getGenres() as $new_genre) {
$item->addGenre($new_genre);
}
break;
case self::FIELD_NAMES:
// set main name in top of names list
$new_names = $new_item->getNames()->toArray();
array_unshift($new_names, (new Name())->setName($new_item->getName()));
foreach ($new_names as $new_name) {
$item->addName($new_name);
}
break;
case self::FIELD_SOURCES:
foreach ($new_item->getSources() as $new_source) {
$item->addSource($new_source);
}
break;
case self::FIELD_STUDIO:
$item->setStudio($new_item->getStudio());
break;
case self::FIELD_SUMMARY:
$item->setSummary($new_item->getSummary());
break;
}
return $item;
} | php | protected function fillItem(Item $item, Item $new_item, $field)
{
switch ($field) {
case self::FIELD_COUNTRY:
$item->setCountry($new_item->getCountry());
break;
case self::FIELD_DATE_END:
$item->setDateEnd($new_item->getDateEnd());
break;
case self::FIELD_DATE_PREMIERE:
$item->setDatePremiere($new_item->getDatePremiere());
break;
case self::FIELD_DURATION:
$item->setDuration($new_item->getDuration());
break;
case self::FIELD_EPISODES:
$item->setEpisodes($new_item->getEpisodes());
break;
case self::FIELD_EPISODES_NUMBER:
$item->setEpisodesNumber($new_item->getEpisodesNumber());
break;
case self::FIELD_FILE_INFO:
$item->setFileInfo($new_item->getFileInfo());
break;
case self::FIELD_GENRES:
/* @var $new_genre \AnimeDb\Bundle\CatalogBundle\Entity\Genre */
foreach ($new_item->getGenres() as $new_genre) {
$item->addGenre($new_genre);
}
break;
case self::FIELD_NAMES:
// set main name in top of names list
$new_names = $new_item->getNames()->toArray();
array_unshift($new_names, (new Name())->setName($new_item->getName()));
foreach ($new_names as $new_name) {
$item->addName($new_name);
}
break;
case self::FIELD_SOURCES:
foreach ($new_item->getSources() as $new_source) {
$item->addSource($new_source);
}
break;
case self::FIELD_STUDIO:
$item->setStudio($new_item->getStudio());
break;
case self::FIELD_SUMMARY:
$item->setSummary($new_item->getSummary());
break;
}
return $item;
} | [
"protected",
"function",
"fillItem",
"(",
"Item",
"$",
"item",
",",
"Item",
"$",
"new_item",
",",
"$",
"field",
")",
"{",
"switch",
"(",
"$",
"field",
")",
"{",
"case",
"self",
"::",
"FIELD_COUNTRY",
":",
"$",
"item",
"->",
"setCountry",
"(",
"$",
"new_item",
"->",
"getCountry",
"(",
")",
")",
";",
"break",
";",
"case",
"self",
"::",
"FIELD_DATE_END",
":",
"$",
"item",
"->",
"setDateEnd",
"(",
"$",
"new_item",
"->",
"getDateEnd",
"(",
")",
")",
";",
"break",
";",
"case",
"self",
"::",
"FIELD_DATE_PREMIERE",
":",
"$",
"item",
"->",
"setDatePremiere",
"(",
"$",
"new_item",
"->",
"getDatePremiere",
"(",
")",
")",
";",
"break",
";",
"case",
"self",
"::",
"FIELD_DURATION",
":",
"$",
"item",
"->",
"setDuration",
"(",
"$",
"new_item",
"->",
"getDuration",
"(",
")",
")",
";",
"break",
";",
"case",
"self",
"::",
"FIELD_EPISODES",
":",
"$",
"item",
"->",
"setEpisodes",
"(",
"$",
"new_item",
"->",
"getEpisodes",
"(",
")",
")",
";",
"break",
";",
"case",
"self",
"::",
"FIELD_EPISODES_NUMBER",
":",
"$",
"item",
"->",
"setEpisodesNumber",
"(",
"$",
"new_item",
"->",
"getEpisodesNumber",
"(",
")",
")",
";",
"break",
";",
"case",
"self",
"::",
"FIELD_FILE_INFO",
":",
"$",
"item",
"->",
"setFileInfo",
"(",
"$",
"new_item",
"->",
"getFileInfo",
"(",
")",
")",
";",
"break",
";",
"case",
"self",
"::",
"FIELD_GENRES",
":",
"/* @var $new_genre \\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Genre */",
"foreach",
"(",
"$",
"new_item",
"->",
"getGenres",
"(",
")",
"as",
"$",
"new_genre",
")",
"{",
"$",
"item",
"->",
"addGenre",
"(",
"$",
"new_genre",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"FIELD_NAMES",
":",
"// set main name in top of names list",
"$",
"new_names",
"=",
"$",
"new_item",
"->",
"getNames",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"array_unshift",
"(",
"$",
"new_names",
",",
"(",
"new",
"Name",
"(",
")",
")",
"->",
"setName",
"(",
"$",
"new_item",
"->",
"getName",
"(",
")",
")",
")",
";",
"foreach",
"(",
"$",
"new_names",
"as",
"$",
"new_name",
")",
"{",
"$",
"item",
"->",
"addName",
"(",
"$",
"new_name",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"FIELD_SOURCES",
":",
"foreach",
"(",
"$",
"new_item",
"->",
"getSources",
"(",
")",
"as",
"$",
"new_source",
")",
"{",
"$",
"item",
"->",
"addSource",
"(",
"$",
"new_source",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"FIELD_STUDIO",
":",
"$",
"item",
"->",
"setStudio",
"(",
"$",
"new_item",
"->",
"getStudio",
"(",
")",
")",
";",
"break",
";",
"case",
"self",
"::",
"FIELD_SUMMARY",
":",
"$",
"item",
"->",
"setSummary",
"(",
"$",
"new_item",
"->",
"getSummary",
"(",
")",
")",
";",
"break",
";",
"}",
"return",
"$",
"item",
";",
"}"
]
| Fill item.
@param \AnimeDb\Bundle\CatalogBundle\Entity\Item $item
@param \AnimeDb\Bundle\CatalogBundle\Entity\Item $new_item
@param string $field
@return \AnimeDb\Bundle\CatalogBundle\Entity\Item | [
"Fill",
"item",
"."
]
| f2ef4dbd12fe39c18183d1628b5049b8d381e42c | https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Service/Refiller.php#L266-L318 |
17,030 | yuncms/framework | src/admin/models/AdminRoute.php | AdminRoute.setDefaultRule | protected function setDefaultRule()
{
if (RBACHelper::getAuthManager()->getRule(RouteRule::RULE_NAME) === null) {
RBACHelper::getAuthManager()->add(new RouteRule());
}
} | php | protected function setDefaultRule()
{
if (RBACHelper::getAuthManager()->getRule(RouteRule::RULE_NAME) === null) {
RBACHelper::getAuthManager()->add(new RouteRule());
}
} | [
"protected",
"function",
"setDefaultRule",
"(",
")",
"{",
"if",
"(",
"RBACHelper",
"::",
"getAuthManager",
"(",
")",
"->",
"getRule",
"(",
"RouteRule",
"::",
"RULE_NAME",
")",
"===",
"null",
")",
"{",
"RBACHelper",
"::",
"getAuthManager",
"(",
")",
"->",
"add",
"(",
"new",
"RouteRule",
"(",
")",
")",
";",
"}",
"}"
]
| Set default rule of parametrize route.
@throws Exception | [
"Set",
"default",
"rule",
"of",
"parametrize",
"route",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/models/AdminRoute.php#L264-L269 |
17,031 | nyeholt/silverstripe-external-content | code/transform/QueuedExternalContentImporter.php | QueuedExternalContentImporter.getJobType | public function getJobType() {
$sourceObject = ExternalContent::getDataObjectFor($this->sourceObjectID);
if (!$sourceObject) {
$this->addMessage("ERROR: Source object $this->sourceObjectID cannot be found");
return QueuedJob::QUEUED;
}
// go a couple levels deep and see how many items we're looking at
if (!$this->includeChildren) {
return QueuedJob::QUEUED;
}
$children = $sourceObject->stageChildren();
if (!$children) {
return QueuedJob::QUEUED;
}
$count = 1;
foreach ($children as $child) {
$count++;
if ($count > 20) {
$this->totalSteps = $count;
return QueuedJob::QUEUED;
}
$subChildren = $child->stageChildren();
if ($subChildren) {
foreach ($subChildren as $sub) {
$count++;
if ($count > 20) {
$this->totalSteps = $count;
return QueuedJob::QUEUED;
}
}
}
}
$this->totalSteps = $count;
return QueuedJob::QUEUED;
} | php | public function getJobType() {
$sourceObject = ExternalContent::getDataObjectFor($this->sourceObjectID);
if (!$sourceObject) {
$this->addMessage("ERROR: Source object $this->sourceObjectID cannot be found");
return QueuedJob::QUEUED;
}
// go a couple levels deep and see how many items we're looking at
if (!$this->includeChildren) {
return QueuedJob::QUEUED;
}
$children = $sourceObject->stageChildren();
if (!$children) {
return QueuedJob::QUEUED;
}
$count = 1;
foreach ($children as $child) {
$count++;
if ($count > 20) {
$this->totalSteps = $count;
return QueuedJob::QUEUED;
}
$subChildren = $child->stageChildren();
if ($subChildren) {
foreach ($subChildren as $sub) {
$count++;
if ($count > 20) {
$this->totalSteps = $count;
return QueuedJob::QUEUED;
}
}
}
}
$this->totalSteps = $count;
return QueuedJob::QUEUED;
} | [
"public",
"function",
"getJobType",
"(",
")",
"{",
"$",
"sourceObject",
"=",
"ExternalContent",
"::",
"getDataObjectFor",
"(",
"$",
"this",
"->",
"sourceObjectID",
")",
";",
"if",
"(",
"!",
"$",
"sourceObject",
")",
"{",
"$",
"this",
"->",
"addMessage",
"(",
"\"ERROR: Source object $this->sourceObjectID cannot be found\"",
")",
";",
"return",
"QueuedJob",
"::",
"QUEUED",
";",
"}",
"// go a couple levels deep and see how many items we're looking at",
"if",
"(",
"!",
"$",
"this",
"->",
"includeChildren",
")",
"{",
"return",
"QueuedJob",
"::",
"QUEUED",
";",
"}",
"$",
"children",
"=",
"$",
"sourceObject",
"->",
"stageChildren",
"(",
")",
";",
"if",
"(",
"!",
"$",
"children",
")",
"{",
"return",
"QueuedJob",
"::",
"QUEUED",
";",
"}",
"$",
"count",
"=",
"1",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"count",
"++",
";",
"if",
"(",
"$",
"count",
">",
"20",
")",
"{",
"$",
"this",
"->",
"totalSteps",
"=",
"$",
"count",
";",
"return",
"QueuedJob",
"::",
"QUEUED",
";",
"}",
"$",
"subChildren",
"=",
"$",
"child",
"->",
"stageChildren",
"(",
")",
";",
"if",
"(",
"$",
"subChildren",
")",
"{",
"foreach",
"(",
"$",
"subChildren",
"as",
"$",
"sub",
")",
"{",
"$",
"count",
"++",
";",
"if",
"(",
"$",
"count",
">",
"20",
")",
"{",
"$",
"this",
"->",
"totalSteps",
"=",
"$",
"count",
";",
"return",
"QueuedJob",
"::",
"QUEUED",
";",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"totalSteps",
"=",
"$",
"count",
";",
"return",
"QueuedJob",
"::",
"QUEUED",
";",
"}"
]
| By default jobs should just go into the default processing queue
@return String | [
"By",
"default",
"jobs",
"should",
"just",
"go",
"into",
"the",
"default",
"processing",
"queue"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/transform/QueuedExternalContentImporter.php#L43-L81 |
17,032 | nyeholt/silverstripe-external-content | code/transform/QueuedExternalContentImporter.php | QueuedExternalContentImporter.process | public function process() {
$remainingChildren = $this->remainingChildren;
if (!count($remainingChildren)) {
$this->isComplete = true;
return;
}
$this->currentStep++;
// lets process our first item
$pair = array_shift($remainingChildren);
$sourceObject = ExternalContent::getDataObjectFor($pair->sourceID);
if (!$sourceObject) {
$this->addMessage("Missing source object for " . $pair->sourceID, 'WARNING');
$this->remainingChildren = $remainingChildren;
return;
}
$targetObject = DataObject::get_by_id($pair->targetType, $pair->targetID);
if (!$targetObject) {
$this->addMessage("Missing target object for $pair->targetType $pair->sourceID", 'WARNING');
$this->remainingChildren = $remainingChildren;
return;
}
// lets do a single import first, then check the children and append them
$pageType = $this->getExternalType($sourceObject);
if (isset($this->contentTransforms[$pageType])) {
$transformer = $this->contentTransforms[$pageType];
$result = $transformer->transform($sourceObject, $targetObject, $this->duplicateStrategy);
// if there's more, then transform them
if ($this->includeChildren && $result && $result->children && count($result->children)) {
foreach ($result->children as $child) {
$remainingChildren[] = new EC_SourceTarget($child->ID, $result->page->ID, $result->page->ClassName);
$this->totalSteps++;
}
}
}
$this->remainingChildren = $remainingChildren;
if (!count($remainingChildren)) {
$this->isComplete = true;
return;
}
} | php | public function process() {
$remainingChildren = $this->remainingChildren;
if (!count($remainingChildren)) {
$this->isComplete = true;
return;
}
$this->currentStep++;
// lets process our first item
$pair = array_shift($remainingChildren);
$sourceObject = ExternalContent::getDataObjectFor($pair->sourceID);
if (!$sourceObject) {
$this->addMessage("Missing source object for " . $pair->sourceID, 'WARNING');
$this->remainingChildren = $remainingChildren;
return;
}
$targetObject = DataObject::get_by_id($pair->targetType, $pair->targetID);
if (!$targetObject) {
$this->addMessage("Missing target object for $pair->targetType $pair->sourceID", 'WARNING');
$this->remainingChildren = $remainingChildren;
return;
}
// lets do a single import first, then check the children and append them
$pageType = $this->getExternalType($sourceObject);
if (isset($this->contentTransforms[$pageType])) {
$transformer = $this->contentTransforms[$pageType];
$result = $transformer->transform($sourceObject, $targetObject, $this->duplicateStrategy);
// if there's more, then transform them
if ($this->includeChildren && $result && $result->children && count($result->children)) {
foreach ($result->children as $child) {
$remainingChildren[] = new EC_SourceTarget($child->ID, $result->page->ID, $result->page->ClassName);
$this->totalSteps++;
}
}
}
$this->remainingChildren = $remainingChildren;
if (!count($remainingChildren)) {
$this->isComplete = true;
return;
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"$",
"remainingChildren",
"=",
"$",
"this",
"->",
"remainingChildren",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"remainingChildren",
")",
")",
"{",
"$",
"this",
"->",
"isComplete",
"=",
"true",
";",
"return",
";",
"}",
"$",
"this",
"->",
"currentStep",
"++",
";",
"// lets process our first item",
"$",
"pair",
"=",
"array_shift",
"(",
"$",
"remainingChildren",
")",
";",
"$",
"sourceObject",
"=",
"ExternalContent",
"::",
"getDataObjectFor",
"(",
"$",
"pair",
"->",
"sourceID",
")",
";",
"if",
"(",
"!",
"$",
"sourceObject",
")",
"{",
"$",
"this",
"->",
"addMessage",
"(",
"\"Missing source object for \"",
".",
"$",
"pair",
"->",
"sourceID",
",",
"'WARNING'",
")",
";",
"$",
"this",
"->",
"remainingChildren",
"=",
"$",
"remainingChildren",
";",
"return",
";",
"}",
"$",
"targetObject",
"=",
"DataObject",
"::",
"get_by_id",
"(",
"$",
"pair",
"->",
"targetType",
",",
"$",
"pair",
"->",
"targetID",
")",
";",
"if",
"(",
"!",
"$",
"targetObject",
")",
"{",
"$",
"this",
"->",
"addMessage",
"(",
"\"Missing target object for $pair->targetType $pair->sourceID\"",
",",
"'WARNING'",
")",
";",
"$",
"this",
"->",
"remainingChildren",
"=",
"$",
"remainingChildren",
";",
"return",
";",
"}",
"// lets do a single import first, then check the children and append them",
"$",
"pageType",
"=",
"$",
"this",
"->",
"getExternalType",
"(",
"$",
"sourceObject",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"contentTransforms",
"[",
"$",
"pageType",
"]",
")",
")",
"{",
"$",
"transformer",
"=",
"$",
"this",
"->",
"contentTransforms",
"[",
"$",
"pageType",
"]",
";",
"$",
"result",
"=",
"$",
"transformer",
"->",
"transform",
"(",
"$",
"sourceObject",
",",
"$",
"targetObject",
",",
"$",
"this",
"->",
"duplicateStrategy",
")",
";",
"// if there's more, then transform them",
"if",
"(",
"$",
"this",
"->",
"includeChildren",
"&&",
"$",
"result",
"&&",
"$",
"result",
"->",
"children",
"&&",
"count",
"(",
"$",
"result",
"->",
"children",
")",
")",
"{",
"foreach",
"(",
"$",
"result",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"remainingChildren",
"[",
"]",
"=",
"new",
"EC_SourceTarget",
"(",
"$",
"child",
"->",
"ID",
",",
"$",
"result",
"->",
"page",
"->",
"ID",
",",
"$",
"result",
"->",
"page",
"->",
"ClassName",
")",
";",
"$",
"this",
"->",
"totalSteps",
"++",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"remainingChildren",
"=",
"$",
"remainingChildren",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"remainingChildren",
")",
")",
"{",
"$",
"this",
"->",
"isComplete",
"=",
"true",
";",
"return",
";",
"}",
"}"
]
| Lets process a single node, and collect its children | [
"Lets",
"process",
"a",
"single",
"node",
"and",
"collect",
"its",
"children"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/transform/QueuedExternalContentImporter.php#L115-L163 |
17,033 | SachaMorard/phalcon-console-migration | Library/Phalcon/Migrations.php | Migrations._migrateFile | protected function _migrateFile($version, $filePath, $direction = 'up')
{
$classVersion = preg_replace('/[^0-9A-Za-z]/', '', $version);
$className = 'Migration_' . $classVersion;
if (file_exists($filePath)) {
require_once $filePath;
if (class_exists($className)) {
$migration = new $className($this->config, $version);
if ($direction === 'up') {
$migration->up();
if (method_exists($migration, 'afterUp')) {
$migration->afterUp();
}
print PHP_EOL . Color::success('Upgrade Version ' . $version . ' was successfully migrated') . PHP_EOL;
} elseif ($direction === 'down') {
$migration->down();
if (method_exists($migration, 'afterDown')) {
$migration->afterDown();
}
print PHP_EOL . Color::info('Downgrade Version ' . $version . ' was successfully migrated') . PHP_EOL;
}
}
} else {
throw new CommandsException('Migration class cannot be found ' . $className . ' at ' . $filePath);
}
} | php | protected function _migrateFile($version, $filePath, $direction = 'up')
{
$classVersion = preg_replace('/[^0-9A-Za-z]/', '', $version);
$className = 'Migration_' . $classVersion;
if (file_exists($filePath)) {
require_once $filePath;
if (class_exists($className)) {
$migration = new $className($this->config, $version);
if ($direction === 'up') {
$migration->up();
if (method_exists($migration, 'afterUp')) {
$migration->afterUp();
}
print PHP_EOL . Color::success('Upgrade Version ' . $version . ' was successfully migrated') . PHP_EOL;
} elseif ($direction === 'down') {
$migration->down();
if (method_exists($migration, 'afterDown')) {
$migration->afterDown();
}
print PHP_EOL . Color::info('Downgrade Version ' . $version . ' was successfully migrated') . PHP_EOL;
}
}
} else {
throw new CommandsException('Migration class cannot be found ' . $className . ' at ' . $filePath);
}
} | [
"protected",
"function",
"_migrateFile",
"(",
"$",
"version",
",",
"$",
"filePath",
",",
"$",
"direction",
"=",
"'up'",
")",
"{",
"$",
"classVersion",
"=",
"preg_replace",
"(",
"'/[^0-9A-Za-z]/'",
",",
"''",
",",
"$",
"version",
")",
";",
"$",
"className",
"=",
"'Migration_'",
".",
"$",
"classVersion",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filePath",
")",
")",
"{",
"require_once",
"$",
"filePath",
";",
"if",
"(",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"$",
"migration",
"=",
"new",
"$",
"className",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"version",
")",
";",
"if",
"(",
"$",
"direction",
"===",
"'up'",
")",
"{",
"$",
"migration",
"->",
"up",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"migration",
",",
"'afterUp'",
")",
")",
"{",
"$",
"migration",
"->",
"afterUp",
"(",
")",
";",
"}",
"print",
"PHP_EOL",
".",
"Color",
"::",
"success",
"(",
"'Upgrade Version '",
".",
"$",
"version",
".",
"' was successfully migrated'",
")",
".",
"PHP_EOL",
";",
"}",
"elseif",
"(",
"$",
"direction",
"===",
"'down'",
")",
"{",
"$",
"migration",
"->",
"down",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"migration",
",",
"'afterDown'",
")",
")",
"{",
"$",
"migration",
"->",
"afterDown",
"(",
")",
";",
"}",
"print",
"PHP_EOL",
".",
"Color",
"::",
"info",
"(",
"'Downgrade Version '",
".",
"$",
"version",
".",
"' was successfully migrated'",
")",
".",
"PHP_EOL",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"CommandsException",
"(",
"'Migration class cannot be found '",
".",
"$",
"className",
".",
"' at '",
".",
"$",
"filePath",
")",
";",
"}",
"}"
]
| Migrate Single File Up or Down
@param $version
@param $filePath
@param string $direction
@throws CommandsException | [
"Migrate",
"Single",
"File",
"Up",
"or",
"Down"
]
| 6b79ecb04f3790844eae04d33e3489a98f4f1214 | https://github.com/SachaMorard/phalcon-console-migration/blob/6b79ecb04f3790844eae04d33e3489a98f4f1214/Library/Phalcon/Migrations.php#L209-L234 |
17,034 | SachaMorard/phalcon-console-migration | Library/Phalcon/Migrations.php | Migrations.generate | public function generate()
{
$version = date('YmdHis');
$this->_generateMigrationFile($version);
print PHP_EOL . Color::success('Version ' . $version . ' was successfully generated') . PHP_EOL;
} | php | public function generate()
{
$version = date('YmdHis');
$this->_generateMigrationFile($version);
print PHP_EOL . Color::success('Version ' . $version . ' was successfully generated') . PHP_EOL;
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"version",
"=",
"date",
"(",
"'YmdHis'",
")",
";",
"$",
"this",
"->",
"_generateMigrationFile",
"(",
"$",
"version",
")",
";",
"print",
"PHP_EOL",
".",
"Color",
"::",
"success",
"(",
"'Version '",
".",
"$",
"version",
".",
"' was successfully generated'",
")",
".",
"PHP_EOL",
";",
"}"
]
| Generate Empty Migration file | [
"Generate",
"Empty",
"Migration",
"file"
]
| 6b79ecb04f3790844eae04d33e3489a98f4f1214 | https://github.com/SachaMorard/phalcon-console-migration/blob/6b79ecb04f3790844eae04d33e3489a98f4f1214/Library/Phalcon/Migrations.php#L240-L246 |
17,035 | SachaMorard/phalcon-console-migration | Library/Phalcon/Migrations.php | Migrations._generateMigrationFile | protected function _generateMigrationFile($version, $contentUp = "", $contentDown = "")
{
$classVersion = preg_replace('/[^0-9A-Za-z]/', '', $version);
$className = 'Migration_' . $classVersion;
$classData = "<?php
use Phalcon\Migrations\MigrationScript as Migration;
class " . $className . " extends Migration\n" .
"{\n\n" .
"\tpublic function up()\n" .
"\t{\n" . $contentUp .
"\n\t}" .
"\n\n" .
"\tpublic function down()\n" .
"\t{\n" . $contentDown .
"\n\t}" .
"\n}\n";
$classData = str_replace("\t", " ", $classData);
file_put_contents($this->migrationsDir . '/' . $version . '.php', $classData);
return $classData;
} | php | protected function _generateMigrationFile($version, $contentUp = "", $contentDown = "")
{
$classVersion = preg_replace('/[^0-9A-Za-z]/', '', $version);
$className = 'Migration_' . $classVersion;
$classData = "<?php
use Phalcon\Migrations\MigrationScript as Migration;
class " . $className . " extends Migration\n" .
"{\n\n" .
"\tpublic function up()\n" .
"\t{\n" . $contentUp .
"\n\t}" .
"\n\n" .
"\tpublic function down()\n" .
"\t{\n" . $contentDown .
"\n\t}" .
"\n}\n";
$classData = str_replace("\t", " ", $classData);
file_put_contents($this->migrationsDir . '/' . $version . '.php', $classData);
return $classData;
} | [
"protected",
"function",
"_generateMigrationFile",
"(",
"$",
"version",
",",
"$",
"contentUp",
"=",
"\"\"",
",",
"$",
"contentDown",
"=",
"\"\"",
")",
"{",
"$",
"classVersion",
"=",
"preg_replace",
"(",
"'/[^0-9A-Za-z]/'",
",",
"''",
",",
"$",
"version",
")",
";",
"$",
"className",
"=",
"'Migration_'",
".",
"$",
"classVersion",
";",
"$",
"classData",
"=",
"\"<?php\n\nuse Phalcon\\Migrations\\MigrationScript as Migration;\n\nclass \"",
".",
"$",
"className",
".",
"\" extends Migration\\n\"",
".",
"\"{\\n\\n\"",
".",
"\"\\tpublic function up()\\n\"",
".",
"\"\\t{\\n\"",
".",
"$",
"contentUp",
".",
"\"\\n\\t}\"",
".",
"\"\\n\\n\"",
".",
"\"\\tpublic function down()\\n\"",
".",
"\"\\t{\\n\"",
".",
"$",
"contentDown",
".",
"\"\\n\\t}\"",
".",
"\"\\n}\\n\"",
";",
"$",
"classData",
"=",
"str_replace",
"(",
"\"\\t\"",
",",
"\" \"",
",",
"$",
"classData",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"migrationsDir",
".",
"'/'",
".",
"$",
"version",
".",
"'.php'",
",",
"$",
"classData",
")",
";",
"return",
"$",
"classData",
";",
"}"
]
| Generate Migration file
@param $version
@param string $contentUp
@param string $contentDown
@return mixed|string | [
"Generate",
"Migration",
"file"
]
| 6b79ecb04f3790844eae04d33e3489a98f4f1214 | https://github.com/SachaMorard/phalcon-console-migration/blob/6b79ecb04f3790844eae04d33e3489a98f4f1214/Library/Phalcon/Migrations.php#L257-L280 |
17,036 | redaigbaria/oauth2 | src/Grant/PasswordGrant.php | PasswordGrant.getVerifyCredentialsCallback | protected function getVerifyCredentialsCallback()
{
if (is_null($this->callback) || !is_callable($this->callback)) {
throw new Exception\ServerErrorException('Null or non-callable callback set on Password grant');
}
return $this->callback;
} | php | protected function getVerifyCredentialsCallback()
{
if (is_null($this->callback) || !is_callable($this->callback)) {
throw new Exception\ServerErrorException('Null or non-callable callback set on Password grant');
}
return $this->callback;
} | [
"protected",
"function",
"getVerifyCredentialsCallback",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"callback",
")",
"||",
"!",
"is_callable",
"(",
"$",
"this",
"->",
"callback",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ServerErrorException",
"(",
"'Null or non-callable callback set on Password grant'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"callback",
";",
"}"
]
| Return the callback function
@return callable
@throws | [
"Return",
"the",
"callback",
"function"
]
| 54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Grant/PasswordGrant.php#L74-L81 |
17,037 | redaigbaria/oauth2 | src/Entity/RefreshTokenEntity.php | RefreshTokenEntity.getAccessToken | public function getAccessToken()
{
if (! $this->accessTokenEntity instanceof AccessTokenEntity) {
$this->accessTokenEntity = $this->server->getAccessTokenStorage()->get($this->accessTokenId);
}
return $this->accessTokenEntity;
} | php | public function getAccessToken()
{
if (! $this->accessTokenEntity instanceof AccessTokenEntity) {
$this->accessTokenEntity = $this->server->getAccessTokenStorage()->get($this->accessTokenId);
}
return $this->accessTokenEntity;
} | [
"public",
"function",
"getAccessToken",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"accessTokenEntity",
"instanceof",
"AccessTokenEntity",
")",
"{",
"$",
"this",
"->",
"accessTokenEntity",
"=",
"$",
"this",
"->",
"server",
"->",
"getAccessTokenStorage",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"accessTokenId",
")",
";",
"}",
"return",
"$",
"this",
"->",
"accessTokenEntity",
";",
"}"
]
| Return access token
@return AccessTokenEntity | [
"Return",
"access",
"token"
]
| 54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/RefreshTokenEntity.php#L66-L73 |
17,038 | nyeholt/silverstripe-external-content | thirdparty/Zend/Validate/Abstract.php | Zend_Validate_Abstract.setDefaultTranslator | public static function setDefaultTranslator($translator = null)
{
if ((null === $translator) || ($translator instanceof Zend_Translate_Adapter)) {
self::$_defaultTranslator = $translator;
} elseif ($translator instanceof Zend_Translate) {
self::$_defaultTranslator = $translator->getAdapter();
} else {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('Invalid translator specified');
}
} | php | public static function setDefaultTranslator($translator = null)
{
if ((null === $translator) || ($translator instanceof Zend_Translate_Adapter)) {
self::$_defaultTranslator = $translator;
} elseif ($translator instanceof Zend_Translate) {
self::$_defaultTranslator = $translator->getAdapter();
} else {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('Invalid translator specified');
}
} | [
"public",
"static",
"function",
"setDefaultTranslator",
"(",
"$",
"translator",
"=",
"null",
")",
"{",
"if",
"(",
"(",
"null",
"===",
"$",
"translator",
")",
"||",
"(",
"$",
"translator",
"instanceof",
"Zend_Translate_Adapter",
")",
")",
"{",
"self",
"::",
"$",
"_defaultTranslator",
"=",
"$",
"translator",
";",
"}",
"elseif",
"(",
"$",
"translator",
"instanceof",
"Zend_Translate",
")",
"{",
"self",
"::",
"$",
"_defaultTranslator",
"=",
"$",
"translator",
"->",
"getAdapter",
"(",
")",
";",
"}",
"else",
"{",
"require_once",
"'Zend/Validate/Exception.php'",
";",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"'Invalid translator specified'",
")",
";",
"}",
"}"
]
| Set default translation object for all validate objects
@param Zend_Translate|Zend_Translate_Adapter|null $translator
@return void | [
"Set",
"default",
"translation",
"object",
"for",
"all",
"validate",
"objects"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/Abstract.php#L343-L353 |
17,039 | nyeholt/silverstripe-external-content | thirdparty/Zend/Validate/Abstract.php | Zend_Validate_Abstract.getDefaultTranslator | public static function getDefaultTranslator()
{
if (null === self::$_defaultTranslator) {
require_once 'Zend/Registry.php';
if (Zend_Registry::isRegistered('Zend_Translate')) {
$translator = Zend_Registry::get('Zend_Translate');
if ($translator instanceof Zend_Translate_Adapter) {
return $translator;
} elseif ($translator instanceof Zend_Translate) {
return $translator->getAdapter();
}
}
}
return self::$_defaultTranslator;
} | php | public static function getDefaultTranslator()
{
if (null === self::$_defaultTranslator) {
require_once 'Zend/Registry.php';
if (Zend_Registry::isRegistered('Zend_Translate')) {
$translator = Zend_Registry::get('Zend_Translate');
if ($translator instanceof Zend_Translate_Adapter) {
return $translator;
} elseif ($translator instanceof Zend_Translate) {
return $translator->getAdapter();
}
}
}
return self::$_defaultTranslator;
} | [
"public",
"static",
"function",
"getDefaultTranslator",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"_defaultTranslator",
")",
"{",
"require_once",
"'Zend/Registry.php'",
";",
"if",
"(",
"Zend_Registry",
"::",
"isRegistered",
"(",
"'Zend_Translate'",
")",
")",
"{",
"$",
"translator",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'Zend_Translate'",
")",
";",
"if",
"(",
"$",
"translator",
"instanceof",
"Zend_Translate_Adapter",
")",
"{",
"return",
"$",
"translator",
";",
"}",
"elseif",
"(",
"$",
"translator",
"instanceof",
"Zend_Translate",
")",
"{",
"return",
"$",
"translator",
"->",
"getAdapter",
"(",
")",
";",
"}",
"}",
"}",
"return",
"self",
"::",
"$",
"_defaultTranslator",
";",
"}"
]
| Get default translation object for all validate objects
@return Zend_Translate_Adapter|null | [
"Get",
"default",
"translation",
"object",
"for",
"all",
"validate",
"objects"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/Abstract.php#L360-L375 |
17,040 | ClanCats/Core | src/bundles/UI/Builder/Bootstrap.php | Builder_Bootstrap.build_alert | public function build_alert( $alerts )
{
return HTML::tag( 'div', function() use( $alerts )
{
// loop trough all alert types
foreach( $alerts as $type => $items )
{
foreach( $items as $alert )
{
$alert = implode( "<br>\n", $alert );
// close button
$close = HTML::tag( 'button', '×' )
->add_class( 'close' )
->type( 'button' )
->data( 'dismiss', 'alert' );
// alert div
echo HTML::tag( 'div', $close.$alert )
->add_class( 'alert fade in' )
->add_class( 'alert-'.$type );
}
}
})->add_class( 'ui-alert-container' );
} | php | public function build_alert( $alerts )
{
return HTML::tag( 'div', function() use( $alerts )
{
// loop trough all alert types
foreach( $alerts as $type => $items )
{
foreach( $items as $alert )
{
$alert = implode( "<br>\n", $alert );
// close button
$close = HTML::tag( 'button', '×' )
->add_class( 'close' )
->type( 'button' )
->data( 'dismiss', 'alert' );
// alert div
echo HTML::tag( 'div', $close.$alert )
->add_class( 'alert fade in' )
->add_class( 'alert-'.$type );
}
}
})->add_class( 'ui-alert-container' );
} | [
"public",
"function",
"build_alert",
"(",
"$",
"alerts",
")",
"{",
"return",
"HTML",
"::",
"tag",
"(",
"'div'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"alerts",
")",
"{",
"// loop trough all alert types",
"foreach",
"(",
"$",
"alerts",
"as",
"$",
"type",
"=>",
"$",
"items",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"alert",
")",
"{",
"$",
"alert",
"=",
"implode",
"(",
"\"<br>\\n\"",
",",
"$",
"alert",
")",
";",
"// close button",
"$",
"close",
"=",
"HTML",
"::",
"tag",
"(",
"'button'",
",",
"'×'",
")",
"->",
"add_class",
"(",
"'close'",
")",
"->",
"type",
"(",
"'button'",
")",
"->",
"data",
"(",
"'dismiss'",
",",
"'alert'",
")",
";",
"// alert div",
"echo",
"HTML",
"::",
"tag",
"(",
"'div'",
",",
"$",
"close",
".",
"$",
"alert",
")",
"->",
"add_class",
"(",
"'alert fade in'",
")",
"->",
"add_class",
"(",
"'alert-'",
".",
"$",
"type",
")",
";",
"}",
"}",
"}",
")",
"->",
"add_class",
"(",
"'ui-alert-container'",
")",
";",
"}"
]
| Build the UI alerts
@param array $alerts
@return UI\HTML | [
"Build",
"the",
"UI",
"alerts"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Builder/Bootstrap.php#L74-L98 |
17,041 | SergioMadness/taxes-laravel | src/services/TaxFacade.php | TaxFacade.setCurrentDriver | public function setCurrentDriver(string $name): ITaxFacade
{
$this->currentDriverName = $name;
$this->makeCurrentDriver($name);
return $this;
} | php | public function setCurrentDriver(string $name): ITaxFacade
{
$this->currentDriverName = $name;
$this->makeCurrentDriver($name);
return $this;
} | [
"public",
"function",
"setCurrentDriver",
"(",
"string",
"$",
"name",
")",
":",
"ITaxFacade",
"{",
"$",
"this",
"->",
"currentDriverName",
"=",
"$",
"name",
";",
"$",
"this",
"->",
"makeCurrentDriver",
"(",
"$",
"name",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set current driver
@param string $name
@return ITaxFacade | [
"Set",
"current",
"driver"
]
| ca33644d924700e858ecbfcf3c311bac7d3ffd26 | https://github.com/SergioMadness/taxes-laravel/blob/ca33644d924700e858ecbfcf3c311bac7d3ffd26/src/services/TaxFacade.php#L41-L48 |
17,042 | SergioMadness/taxes-laravel | src/services/TaxFacade.php | TaxFacade.driverInstance | public function driverInstance(string $driver): ?ITaxFacade
{
if (($driverClass = $this->getDriver($driver)) !== null) {
return app($driverClass, [
'config' => config('taxes.' . $driverClass),
]);
}
return null;
} | php | public function driverInstance(string $driver): ?ITaxFacade
{
if (($driverClass = $this->getDriver($driver)) !== null) {
return app($driverClass, [
'config' => config('taxes.' . $driverClass),
]);
}
return null;
} | [
"public",
"function",
"driverInstance",
"(",
"string",
"$",
"driver",
")",
":",
"?",
"ITaxFacade",
"{",
"if",
"(",
"(",
"$",
"driverClass",
"=",
"$",
"this",
"->",
"getDriver",
"(",
"$",
"driver",
")",
")",
"!==",
"null",
")",
"{",
"return",
"app",
"(",
"$",
"driverClass",
",",
"[",
"'config'",
"=>",
"config",
"(",
"'taxes.'",
".",
"$",
"driverClass",
")",
",",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Build driver by name
@param string $driver
@return null|ITaxFacade | [
"Build",
"driver",
"by",
"name"
]
| ca33644d924700e858ecbfcf3c311bac7d3ffd26 | https://github.com/SergioMadness/taxes-laravel/blob/ca33644d924700e858ecbfcf3c311bac7d3ffd26/src/services/TaxFacade.php#L140-L149 |
17,043 | nyeholt/silverstripe-external-content | thirdparty/Zend/Validate/File/MimeType.php | Zend_Validate_File_MimeType.setMagicFile | public function setMagicFile($file)
{
if (empty($file)) {
$this->_magicfile = null;
} else if (!is_readable($file)) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('The given magicfile can not be read');
} else {
$this->_magicfile = (string) $file;
}
return $this;
} | php | public function setMagicFile($file)
{
if (empty($file)) {
$this->_magicfile = null;
} else if (!is_readable($file)) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('The given magicfile can not be read');
} else {
$this->_magicfile = (string) $file;
}
return $this;
} | [
"public",
"function",
"setMagicFile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"_magicfile",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"require_once",
"'Zend/Validate/Exception.php'",
";",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"'The given magicfile can not be read'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_magicfile",
"=",
"(",
"string",
")",
"$",
"file",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sets the magicfile to use
if null, the MAGIC constant from php is used
@param string $file
@return Zend_Validate_File_MimeType Provides fluid interface | [
"Sets",
"the",
"magicfile",
"to",
"use",
"if",
"null",
"the",
"MAGIC",
"constant",
"from",
"php",
"is",
"used"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/File/MimeType.php#L125-L137 |
17,044 | steeffeen/FancyManiaLinks | FML/Elements/TemplateScript.php | TemplateScript.getScriptText | public function getScriptText($parameters = null)
{
if (!$parameters) {
$parameters = $this->parameters;
}
ob_start();
include $this->filePath;
$scriptText = ob_get_contents();
ob_end_clean();
return $scriptText;
} | php | public function getScriptText($parameters = null)
{
if (!$parameters) {
$parameters = $this->parameters;
}
ob_start();
include $this->filePath;
$scriptText = ob_get_contents();
ob_end_clean();
return $scriptText;
} | [
"public",
"function",
"getScriptText",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"parameters",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"parameters",
";",
"}",
"ob_start",
"(",
")",
";",
"include",
"$",
"this",
"->",
"filePath",
";",
"$",
"scriptText",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"scriptText",
";",
"}"
]
| Get the compiled script text
@param mixed $parameters (optional) Parameters
@return string | [
"Get",
"the",
"compiled",
"script",
"text"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Elements/TemplateScript.php#L111-L126 |
17,045 | teneleven/GeolocatorBundle | Provider/LocationProvider.php | LocationProvider.decorateResults | protected function decorateResults(Coordinates $searchCenter, array $results)
{
$search = new Search();
$search->setCenter($searchCenter);
foreach ($results as $result) {
$distanceInMiles = UnitConverter::kmToMiles($result['distance']);
$search->addResult(new Result($result[0], $distanceInMiles));
}
return $search;
} | php | protected function decorateResults(Coordinates $searchCenter, array $results)
{
$search = new Search();
$search->setCenter($searchCenter);
foreach ($results as $result) {
$distanceInMiles = UnitConverter::kmToMiles($result['distance']);
$search->addResult(new Result($result[0], $distanceInMiles));
}
return $search;
} | [
"protected",
"function",
"decorateResults",
"(",
"Coordinates",
"$",
"searchCenter",
",",
"array",
"$",
"results",
")",
"{",
"$",
"search",
"=",
"new",
"Search",
"(",
")",
";",
"$",
"search",
"->",
"setCenter",
"(",
"$",
"searchCenter",
")",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"result",
")",
"{",
"$",
"distanceInMiles",
"=",
"UnitConverter",
"::",
"kmToMiles",
"(",
"$",
"result",
"[",
"'distance'",
"]",
")",
";",
"$",
"search",
"->",
"addResult",
"(",
"new",
"Result",
"(",
"$",
"result",
"[",
"0",
"]",
",",
"$",
"distanceInMiles",
")",
")",
";",
"}",
"return",
"$",
"search",
";",
"}"
]
| Helper method to decorate search results
@param Coordinates $searchCenter
@param array $results
@return Search | [
"Helper",
"method",
"to",
"decorate",
"search",
"results"
]
| 4ead8e783a91577f2a67aa302b79641d4b9e99ad | https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Provider/LocationProvider.php#L110-L121 |
17,046 | CakeCMS/Core | src/Nav.php | Nav._clear | protected static function _clear($menu)
{
if (array_key_exists($menu, self::$_items)) {
self::$_items[$menu] = [];
} else {
throw new \UnexpectedValueException('Invalid menu: ' . $menu);
}
} | php | protected static function _clear($menu)
{
if (array_key_exists($menu, self::$_items)) {
self::$_items[$menu] = [];
} else {
throw new \UnexpectedValueException('Invalid menu: ' . $menu);
}
} | [
"protected",
"static",
"function",
"_clear",
"(",
"$",
"menu",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"menu",
",",
"self",
"::",
"$",
"_items",
")",
")",
"{",
"self",
"::",
"$",
"_items",
"[",
"$",
"menu",
"]",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Invalid menu: '",
".",
"$",
"menu",
")",
";",
"}",
"}"
]
| Clear menu items.
@param $menu
@throws \UnexpectedValueException | [
"Clear",
"menu",
"items",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Nav.php#L199-L206 |
17,047 | CakeCMS/Core | src/Nav.php | Nav._replace | protected static function _replace(&$target, $path, $options)
{
$pathE = explode('.', $path);
$path = array_shift($pathE);
$fragment = join('.', $pathE);
if (!empty($pathE)) {
self::_replace($target[$path], $fragment, $options);
} else {
$target[$path] = self::_merge($target[$path], $options);
}
} | php | protected static function _replace(&$target, $path, $options)
{
$pathE = explode('.', $path);
$path = array_shift($pathE);
$fragment = join('.', $pathE);
if (!empty($pathE)) {
self::_replace($target[$path], $fragment, $options);
} else {
$target[$path] = self::_merge($target[$path], $options);
}
} | [
"protected",
"static",
"function",
"_replace",
"(",
"&",
"$",
"target",
",",
"$",
"path",
",",
"$",
"options",
")",
"{",
"$",
"pathE",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"array_shift",
"(",
"$",
"pathE",
")",
";",
"$",
"fragment",
"=",
"join",
"(",
"'.'",
",",
"$",
"pathE",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"pathE",
")",
")",
"{",
"self",
"::",
"_replace",
"(",
"$",
"target",
"[",
"$",
"path",
"]",
",",
"$",
"fragment",
",",
"$",
"options",
")",
";",
"}",
"else",
"{",
"$",
"target",
"[",
"$",
"path",
"]",
"=",
"self",
"::",
"_merge",
"(",
"$",
"target",
"[",
"$",
"path",
"]",
",",
"$",
"options",
")",
";",
"}",
"}"
]
| Replace a menu element.
@param array $target pointer to start of array
@param string $path path to search for in dot separated format
@param array $options data to replace with
@return void | [
"Replace",
"a",
"menu",
"element",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Nav.php#L235-L246 |
17,048 | CakeCMS/Core | src/Nav.php | Nav._setupOptions | protected static function _setupOptions(&$options)
{
$options = self::_merge(self::$_defaults, $options);
foreach ($options['children'] as &$child) {
self::_setupOptions($child);
}
} | php | protected static function _setupOptions(&$options)
{
$options = self::_merge(self::$_defaults, $options);
foreach ($options['children'] as &$child) {
self::_setupOptions($child);
}
} | [
"protected",
"static",
"function",
"_setupOptions",
"(",
"&",
"$",
"options",
")",
"{",
"$",
"options",
"=",
"self",
"::",
"_merge",
"(",
"self",
"::",
"$",
"_defaults",
",",
"$",
"options",
")",
";",
"foreach",
"(",
"$",
"options",
"[",
"'children'",
"]",
"as",
"&",
"$",
"child",
")",
"{",
"self",
"::",
"_setupOptions",
"(",
"$",
"child",
")",
";",
"}",
"}"
]
| Setup options.
@param array $options
@return void | [
"Setup",
"options",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Nav.php#L254-L260 |
17,049 | ClanCats/Core | src/classes/CCCli.php | CCCli.write | public static function write( $str, $color = null, $background = null )
{
if ( !is_null( $color ) )
{
$str = static::color( $str, $color, $background );
}
fwrite( STDOUT, $str );
} | php | public static function write( $str, $color = null, $background = null )
{
if ( !is_null( $color ) )
{
$str = static::color( $str, $color, $background );
}
fwrite( STDOUT, $str );
} | [
"public",
"static",
"function",
"write",
"(",
"$",
"str",
",",
"$",
"color",
"=",
"null",
",",
"$",
"background",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"color",
")",
")",
"{",
"$",
"str",
"=",
"static",
"::",
"color",
"(",
"$",
"str",
",",
"$",
"color",
",",
"$",
"background",
")",
";",
"}",
"fwrite",
"(",
"STDOUT",
",",
"$",
"str",
")",
";",
"}"
]
| Write to the standard output device
@param string $str
@return void | [
"Write",
"to",
"the",
"standard",
"output",
"device"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCCli.php#L80-L88 |
17,050 | ClanCats/Core | src/classes/CCCli.php | CCCli.line | public static function line( $str, $color = null, $background = null )
{
if ( is_array( $str ) )
{
$str = implode( PHP_EOL, $str );
}
static::write( $str.PHP_EOL, $color, $background );
} | php | public static function line( $str, $color = null, $background = null )
{
if ( is_array( $str ) )
{
$str = implode( PHP_EOL, $str );
}
static::write( $str.PHP_EOL, $color, $background );
} | [
"public",
"static",
"function",
"line",
"(",
"$",
"str",
",",
"$",
"color",
"=",
"null",
",",
"$",
"background",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"str",
")",
")",
"{",
"$",
"str",
"=",
"implode",
"(",
"PHP_EOL",
",",
"$",
"str",
")",
";",
"}",
"static",
"::",
"write",
"(",
"$",
"str",
".",
"PHP_EOL",
",",
"$",
"color",
",",
"$",
"background",
")",
";",
"}"
]
| Write to the standard output device with an end of line.
@param string $str
@return void | [
"Write",
"to",
"the",
"standard",
"output",
"device",
"with",
"an",
"end",
"of",
"line",
"."
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCCli.php#L96-L104 |
17,051 | ClanCats/Core | src/classes/CCCli.php | CCCli.confirm | public static function confirm( $question, $strict = false )
{
$question .= ' [yes/no]: ';
if ( $strict )
{
do
{
$res = strtolower( static::read( $question ) );
}
while ( $res !== 'yes' && $res !== 'no' );
return ( $res == 'yes' ) ? true : false;
}
do
{
$res = strtolower( static::read( $question ) );
}
while ( empty( $res ) );
$positives = array(
'yes', 'y', 'ya', 'ye', 'yeah', 'yup',
'jep', 'jap', 'ja',
'si', 'sim',
'true',
'hai',
'oui',
'no problemo',
);
return in_array( $res, $positives );
} | php | public static function confirm( $question, $strict = false )
{
$question .= ' [yes/no]: ';
if ( $strict )
{
do
{
$res = strtolower( static::read( $question ) );
}
while ( $res !== 'yes' && $res !== 'no' );
return ( $res == 'yes' ) ? true : false;
}
do
{
$res = strtolower( static::read( $question ) );
}
while ( empty( $res ) );
$positives = array(
'yes', 'y', 'ya', 'ye', 'yeah', 'yup',
'jep', 'jap', 'ja',
'si', 'sim',
'true',
'hai',
'oui',
'no problemo',
);
return in_array( $res, $positives );
} | [
"public",
"static",
"function",
"confirm",
"(",
"$",
"question",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"$",
"question",
".=",
"' [yes/no]: '",
";",
"if",
"(",
"$",
"strict",
")",
"{",
"do",
"{",
"$",
"res",
"=",
"strtolower",
"(",
"static",
"::",
"read",
"(",
"$",
"question",
")",
")",
";",
"}",
"while",
"(",
"$",
"res",
"!==",
"'yes'",
"&&",
"$",
"res",
"!==",
"'no'",
")",
";",
"return",
"(",
"$",
"res",
"==",
"'yes'",
")",
"?",
"true",
":",
"false",
";",
"}",
"do",
"{",
"$",
"res",
"=",
"strtolower",
"(",
"static",
"::",
"read",
"(",
"$",
"question",
")",
")",
";",
"}",
"while",
"(",
"empty",
"(",
"$",
"res",
")",
")",
";",
"$",
"positives",
"=",
"array",
"(",
"'yes'",
",",
"'y'",
",",
"'ya'",
",",
"'ye'",
",",
"'yeah'",
",",
"'yup'",
",",
"'jep'",
",",
"'jap'",
",",
"'ja'",
",",
"'si'",
",",
"'sim'",
",",
"'true'",
",",
"'hai'",
",",
"'oui'",
",",
"'no problemo'",
",",
")",
";",
"return",
"in_array",
"(",
"$",
"res",
",",
"$",
"positives",
")",
";",
"}"
]
| Get a bool value from the user
This will write the question down and waiting for a yes or no.
When strict is true, it wil only accept yes or no. And not y, n, jep etc.
@param string $question
@param bool $strict
@return bool | [
"Get",
"a",
"bool",
"value",
"from",
"the",
"user",
"This",
"will",
"write",
"the",
"question",
"down",
"and",
"waiting",
"for",
"a",
"yes",
"or",
"no",
"."
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCCli.php#L221-L253 |
17,052 | ClanCats/Core | src/classes/CCCli.php | CCCli.read | public static function read( $prefix = '' )
{
if ( !static::is_windows() )
{
$line = readline( $prefix );
readline_add_history( $line );
}
else
{
static::write( $prefix );
$line = trim( fgets( STDIN ) );
}
return $line;
} | php | public static function read( $prefix = '' )
{
if ( !static::is_windows() )
{
$line = readline( $prefix );
readline_add_history( $line );
}
else
{
static::write( $prefix );
$line = trim( fgets( STDIN ) );
}
return $line;
} | [
"public",
"static",
"function",
"read",
"(",
"$",
"prefix",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is_windows",
"(",
")",
")",
"{",
"$",
"line",
"=",
"readline",
"(",
"$",
"prefix",
")",
";",
"readline_add_history",
"(",
"$",
"line",
")",
";",
"}",
"else",
"{",
"static",
"::",
"write",
"(",
"$",
"prefix",
")",
";",
"$",
"line",
"=",
"trim",
"(",
"fgets",
"(",
"STDIN",
")",
")",
";",
"}",
"return",
"$",
"line",
";",
"}"
]
| Read from comman line
Because windows does not support readline we use normal fgets in that case.
@param string $prefix The prefix will be printet before the user can respond.
@return string | [
"Read",
"from",
"comman",
"line",
"Because",
"windows",
"does",
"not",
"support",
"readline",
"we",
"use",
"normal",
"fgets",
"in",
"that",
"case",
"."
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCCli.php#L262-L276 |
17,053 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Controller/BaseCrudController.php | BaseCrudController.manageEdit | protected function manageEdit($entity, Request $request, $formTypeFQCN)
{
$form = $this->createForm($formTypeFQCN, $entity, array(
'action' => $this->getEditUrl($entity),
'method' => 'POST',
));
$form
->add('save', SubmitType::class, array('attr' => array('class' => 'btn btn-primary')))
->add('delete', SubmitType::class, array('attr' => array('class' => 'btn btn-danger')));
$form->handleRequest($request);
if ($form->isSubmitted()) {
if ($form->get('save')->isClicked()) {
if ($form->isValid()) {
return $this->crudManage($entity, AdminCrudEvent::UPDATE);
}
} elseif ($form->get('delete')->isClicked()) {
return $this->crudManage($entity, AdminCrudEvent::DELETE);
}
}
return $this->render(
$this->getEditTemplate(),
array(
'entity' => $entity,
'form' => $form->createView(),
));
} | php | protected function manageEdit($entity, Request $request, $formTypeFQCN)
{
$form = $this->createForm($formTypeFQCN, $entity, array(
'action' => $this->getEditUrl($entity),
'method' => 'POST',
));
$form
->add('save', SubmitType::class, array('attr' => array('class' => 'btn btn-primary')))
->add('delete', SubmitType::class, array('attr' => array('class' => 'btn btn-danger')));
$form->handleRequest($request);
if ($form->isSubmitted()) {
if ($form->get('save')->isClicked()) {
if ($form->isValid()) {
return $this->crudManage($entity, AdminCrudEvent::UPDATE);
}
} elseif ($form->get('delete')->isClicked()) {
return $this->crudManage($entity, AdminCrudEvent::DELETE);
}
}
return $this->render(
$this->getEditTemplate(),
array(
'entity' => $entity,
'form' => $form->createView(),
));
} | [
"protected",
"function",
"manageEdit",
"(",
"$",
"entity",
",",
"Request",
"$",
"request",
",",
"$",
"formTypeFQCN",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"$",
"formTypeFQCN",
",",
"$",
"entity",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"getEditUrl",
"(",
"$",
"entity",
")",
",",
"'method'",
"=>",
"'POST'",
",",
")",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'save'",
",",
"SubmitType",
"::",
"class",
",",
"array",
"(",
"'attr'",
"=>",
"array",
"(",
"'class'",
"=>",
"'btn btn-primary'",
")",
")",
")",
"->",
"add",
"(",
"'delete'",
",",
"SubmitType",
"::",
"class",
",",
"array",
"(",
"'attr'",
"=>",
"array",
"(",
"'class'",
"=>",
"'btn btn-danger'",
")",
")",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"if",
"(",
"$",
"form",
"->",
"get",
"(",
"'save'",
")",
"->",
"isClicked",
"(",
")",
")",
"{",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"crudManage",
"(",
"$",
"entity",
",",
"AdminCrudEvent",
"::",
"UPDATE",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"form",
"->",
"get",
"(",
"'delete'",
")",
"->",
"isClicked",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"crudManage",
"(",
"$",
"entity",
",",
"AdminCrudEvent",
"::",
"DELETE",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getEditTemplate",
"(",
")",
",",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
]
| Generic edit controller helper.
@param $entity
@param Request $request
@return string|\Symfony\Component\HttpFoundation\RedirectResponse | [
"Generic",
"edit",
"controller",
"helper",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Controller/BaseCrudController.php#L103-L132 |
17,054 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Controller/BaseCrudController.php | BaseCrudController.manageNew | protected function manageNew($entity, Request $request, $formTypeFQCN)
{
$form = $this->createForm($formTypeFQCN, $entity, array(
'action' => $this->getNewUrl($entity),
'method' => 'POST',
));
$form
->add('create', submitType::class, array('attr' => array('class' => 'btn btn-primary')));
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
return $this->crudManage($entity, AdminCrudEvent::CREATE);
}
return $this->render(
$this->getNewTemplate(),
array(
'entity' => $entity,
'form' => $form->createView(),
));
} | php | protected function manageNew($entity, Request $request, $formTypeFQCN)
{
$form = $this->createForm($formTypeFQCN, $entity, array(
'action' => $this->getNewUrl($entity),
'method' => 'POST',
));
$form
->add('create', submitType::class, array('attr' => array('class' => 'btn btn-primary')));
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
return $this->crudManage($entity, AdminCrudEvent::CREATE);
}
return $this->render(
$this->getNewTemplate(),
array(
'entity' => $entity,
'form' => $form->createView(),
));
} | [
"protected",
"function",
"manageNew",
"(",
"$",
"entity",
",",
"Request",
"$",
"request",
",",
"$",
"formTypeFQCN",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"$",
"formTypeFQCN",
",",
"$",
"entity",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"getNewUrl",
"(",
"$",
"entity",
")",
",",
"'method'",
"=>",
"'POST'",
",",
")",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'create'",
",",
"submitType",
"::",
"class",
",",
"array",
"(",
"'attr'",
"=>",
"array",
"(",
"'class'",
"=>",
"'btn btn-primary'",
")",
")",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
"&&",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"crudManage",
"(",
"$",
"entity",
",",
"AdminCrudEvent",
"::",
"CREATE",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getNewTemplate",
"(",
")",
",",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
]
| Generic new controller helper.
@param $entity
@param Request $request
@return string|\Symfony\Component\HttpFoundation\RedirectResponse | [
"Generic",
"new",
"controller",
"helper",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Controller/BaseCrudController.php#L142-L164 |
17,055 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Controller/BaseCrudController.php | BaseCrudController.dispatchCrudEvent | protected function dispatchCrudEvent($entity, $action, $eventName)
{
$event = new AdminCrudEvent($entity, $action, $this->getUser());
$this->get('event_dispatcher')->dispatch($eventName, $event);
return $event;
} | php | protected function dispatchCrudEvent($entity, $action, $eventName)
{
$event = new AdminCrudEvent($entity, $action, $this->getUser());
$this->get('event_dispatcher')->dispatch($eventName, $event);
return $event;
} | [
"protected",
"function",
"dispatchCrudEvent",
"(",
"$",
"entity",
",",
"$",
"action",
",",
"$",
"eventName",
")",
"{",
"$",
"event",
"=",
"new",
"AdminCrudEvent",
"(",
"$",
"entity",
",",
"$",
"action",
",",
"$",
"this",
"->",
"getUser",
"(",
")",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'event_dispatcher'",
")",
"->",
"dispatch",
"(",
"$",
"eventName",
",",
"$",
"event",
")",
";",
"return",
"$",
"event",
";",
"}"
]
| Generic Event dispatcher.
@param $entity
@param $action
@param $eventName
@return AdminCrudEvent | [
"Generic",
"Event",
"dispatcher",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Controller/BaseCrudController.php#L249-L255 |
17,056 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Controller/BaseCrudController.php | BaseCrudController.dispatchAssociationActionEvent | protected function dispatchAssociationActionEvent($entity, $action, $target, $eventName)
{
$event = new AdminAssociationActionEvent($entity, $action, $target, $this->getUser());
$this->get('event_dispatcher')->dispatch($eventName, $event);
return $event;
} | php | protected function dispatchAssociationActionEvent($entity, $action, $target, $eventName)
{
$event = new AdminAssociationActionEvent($entity, $action, $target, $this->getUser());
$this->get('event_dispatcher')->dispatch($eventName, $event);
return $event;
} | [
"protected",
"function",
"dispatchAssociationActionEvent",
"(",
"$",
"entity",
",",
"$",
"action",
",",
"$",
"target",
",",
"$",
"eventName",
")",
"{",
"$",
"event",
"=",
"new",
"AdminAssociationActionEvent",
"(",
"$",
"entity",
",",
"$",
"action",
",",
"$",
"target",
",",
"$",
"this",
"->",
"getUser",
"(",
")",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'event_dispatcher'",
")",
"->",
"dispatch",
"(",
"$",
"eventName",
",",
"$",
"event",
")",
";",
"return",
"$",
"event",
";",
"}"
]
| Generic Association Action dispatcher.
@param $entity
@param $action
@param $target
@param $eventName
@return AdminAssociationActionEvent | [
"Generic",
"Association",
"Action",
"dispatcher",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Controller/BaseCrudController.php#L293-L299 |
17,057 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.charAt | public static function charAt(string $str, int $i): string
{
return (string)BaseStringy::create($str)->at($i);
} | php | public static function charAt(string $str, int $i): string
{
return (string)BaseStringy::create($str)->at($i);
} | [
"public",
"static",
"function",
"charAt",
"(",
"string",
"$",
"str",
",",
"int",
"$",
"i",
")",
":",
"string",
"{",
"return",
"(",
"string",
")",
"BaseStringy",
"::",
"create",
"(",
"$",
"str",
")",
"->",
"at",
"(",
"$",
"i",
")",
";",
"}"
]
| Returns the character at a specific point in a potentially multibyte string.
@param string $str The string to check.
@param int $i The 0-offset position in the string to check.
@return string | [
"Returns",
"the",
"character",
"at",
"a",
"specific",
"point",
"in",
"a",
"potentially",
"multibyte",
"string",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L247-L250 |
17,058 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.lines | public static function lines(string $str): array
{
$lines = BaseStringy::create($str)->lines();
foreach ($lines as $i => $line) {
$lines[$i] = $line;
}
/** @var string[] $lines */
return $lines;
} | php | public static function lines(string $str): array
{
$lines = BaseStringy::create($str)->lines();
foreach ($lines as $i => $line) {
$lines[$i] = $line;
}
/** @var string[] $lines */
return $lines;
} | [
"public",
"static",
"function",
"lines",
"(",
"string",
"$",
"str",
")",
":",
"array",
"{",
"$",
"lines",
"=",
"BaseStringy",
"::",
"create",
"(",
"$",
"str",
")",
"->",
"lines",
"(",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"i",
"=>",
"$",
"line",
")",
"{",
"$",
"lines",
"[",
"$",
"i",
"]",
"=",
"$",
"line",
";",
"}",
"/** @var string[] $lines */",
"return",
"$",
"lines",
";",
"}"
]
| Splits on newlines and carriage returns, returning an array of strings corresponding to the lines in the string.
@param string $str The string to split.
@return string[] An array of strings. | [
"Splits",
"on",
"newlines",
"and",
"carriage",
"returns",
"returning",
"an",
"array",
"of",
"strings",
"corresponding",
"to",
"the",
"lines",
"in",
"the",
"string",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L422-L432 |
17,059 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.toKebabCase | public static function toKebabCase(string $string, string $glue = '-', bool $lower = true, bool $removePunctuation = true): string
{
$words = self::_prepStringForCasing($string, $lower, $removePunctuation);
return implode($glue, $words);
} | php | public static function toKebabCase(string $string, string $glue = '-', bool $lower = true, bool $removePunctuation = true): string
{
$words = self::_prepStringForCasing($string, $lower, $removePunctuation);
return implode($glue, $words);
} | [
"public",
"static",
"function",
"toKebabCase",
"(",
"string",
"$",
"string",
",",
"string",
"$",
"glue",
"=",
"'-'",
",",
"bool",
"$",
"lower",
"=",
"true",
",",
"bool",
"$",
"removePunctuation",
"=",
"true",
")",
":",
"string",
"{",
"$",
"words",
"=",
"self",
"::",
"_prepStringForCasing",
"(",
"$",
"string",
",",
"$",
"lower",
",",
"$",
"removePunctuation",
")",
";",
"return",
"implode",
"(",
"$",
"glue",
",",
"$",
"words",
")",
";",
"}"
]
| kebab-cases a string.
@param string $string The string
@param string $glue The string used to glue the words together (default is a hyphen)
@param bool $lower Whether the string should be lowercased (default is true)
@param bool $removePunctuation Whether punctuation marks should be removed (default is true)
@return string The kebab-cased string
@see toCamelCase()
@see toPascalCase()
@see toSnakeCase() | [
"kebab",
"-",
"cases",
"a",
"string",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L457-L462 |
17,060 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.toCamelCase | public static function toCamelCase(string $string): string
{
$words = self::_prepStringForCasing($string);
if (empty($words)) {
return '';
}
$string = array_shift($words) . implode('', array_map([
static::class,
'upperCaseFirst'
], $words));
return $string;
} | php | public static function toCamelCase(string $string): string
{
$words = self::_prepStringForCasing($string);
if (empty($words)) {
return '';
}
$string = array_shift($words) . implode('', array_map([
static::class,
'upperCaseFirst'
], $words));
return $string;
} | [
"public",
"static",
"function",
"toCamelCase",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"$",
"words",
"=",
"self",
"::",
"_prepStringForCasing",
"(",
"$",
"string",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"words",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"string",
"=",
"array_shift",
"(",
"$",
"words",
")",
".",
"implode",
"(",
"''",
",",
"array_map",
"(",
"[",
"static",
"::",
"class",
",",
"'upperCaseFirst'",
"]",
",",
"$",
"words",
")",
")",
";",
"return",
"$",
"string",
";",
"}"
]
| camelCases a string.
@param string $string The string
@return string
@see toKebabCase()
@see toPascalCase()
@see toSnakeCase() | [
"camelCases",
"a",
"string",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L473-L487 |
17,061 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.toPascalCase | public static function toPascalCase(string $string): string
{
$words = self::_prepStringForCasing($string);
$string = implode('', array_map([
static::class,
'upperCaseFirst'
], $words));
return $string;
} | php | public static function toPascalCase(string $string): string
{
$words = self::_prepStringForCasing($string);
$string = implode('', array_map([
static::class,
'upperCaseFirst'
], $words));
return $string;
} | [
"public",
"static",
"function",
"toPascalCase",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"$",
"words",
"=",
"self",
"::",
"_prepStringForCasing",
"(",
"$",
"string",
")",
";",
"$",
"string",
"=",
"implode",
"(",
"''",
",",
"array_map",
"(",
"[",
"static",
"::",
"class",
",",
"'upperCaseFirst'",
"]",
",",
"$",
"words",
")",
")",
";",
"return",
"$",
"string",
";",
"}"
]
| PascalCases a string.
@param string $string The string
@return string
@see toKebabCase()
@see toCamelCase()
@see toSnakeCase() | [
"PascalCases",
"a",
"string",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L498-L507 |
17,062 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.toSnakeCase | public static function toSnakeCase(string $string): string
{
$words = self::_prepStringForCasing($string);
return implode('_', $words);
} | php | public static function toSnakeCase(string $string): string
{
$words = self::_prepStringForCasing($string);
return implode('_', $words);
} | [
"public",
"static",
"function",
"toSnakeCase",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"$",
"words",
"=",
"self",
"::",
"_prepStringForCasing",
"(",
"$",
"string",
")",
";",
"return",
"implode",
"(",
"'_'",
",",
"$",
"words",
")",
";",
"}"
]
| snake_cases a string.
@param string $string The string
@return string
@see toKebabCase()
@see toCamelCase()
@see toPascalCase() | [
"snake_cases",
"a",
"string",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L518-L523 |
17,063 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.split | public static function split(string $string, string $delimiter = ','): array
{
return preg_split('/\s*' . preg_quote($delimiter, '/') . '\s*/', $string, -1, PREG_SPLIT_NO_EMPTY);
} | php | public static function split(string $string, string $delimiter = ','): array
{
return preg_split('/\s*' . preg_quote($delimiter, '/') . '\s*/', $string, -1, PREG_SPLIT_NO_EMPTY);
} | [
"public",
"static",
"function",
"split",
"(",
"string",
"$",
"string",
",",
"string",
"$",
"delimiter",
"=",
"','",
")",
":",
"array",
"{",
"return",
"preg_split",
"(",
"'/\\s*'",
".",
"preg_quote",
"(",
"$",
"delimiter",
",",
"'/'",
")",
".",
"'\\s*/'",
",",
"$",
"string",
",",
"-",
"1",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"}"
]
| Splits a string into chunks on a given delimiter.
@param string $string The string
@param string $delimiter The delimiter to split the string on (defaults to a comma)
@return string[] The segments of the string | [
"Splits",
"a",
"string",
"into",
"chunks",
"on",
"a",
"given",
"delimiter",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L532-L535 |
17,064 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.padBoth | public static function padBoth($str, $length, $padStr = ' '): string
{
return (string)BaseStringy::create($str)->padBoth($length, $padStr);
} | php | public static function padBoth($str, $length, $padStr = ' '): string
{
return (string)BaseStringy::create($str)->padBoth($length, $padStr);
} | [
"public",
"static",
"function",
"padBoth",
"(",
"$",
"str",
",",
"$",
"length",
",",
"$",
"padStr",
"=",
"' '",
")",
":",
"string",
"{",
"return",
"(",
"string",
")",
"BaseStringy",
"::",
"create",
"(",
"$",
"str",
")",
"->",
"padBoth",
"(",
"$",
"length",
",",
"$",
"padStr",
")",
";",
"}"
]
| Returns a new string of a given length such that both sides of the string are padded.
@param string $str The string to pad.
@param int $length The desired string length after padding.
@param string $padStr The string used to pad, defaults to space.
@return string The padded string. | [
"Returns",
"a",
"new",
"string",
"of",
"a",
"given",
"length",
"such",
"that",
"both",
"sides",
"of",
"the",
"string",
"are",
"padded",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L570-L573 |
17,065 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.padLeft | public static function padLeft(string $str, int $length, string $padStr = ' '): string
{
return (string)BaseStringy::create($str)->padLeft($length, $padStr);
} | php | public static function padLeft(string $str, int $length, string $padStr = ' '): string
{
return (string)BaseStringy::create($str)->padLeft($length, $padStr);
} | [
"public",
"static",
"function",
"padLeft",
"(",
"string",
"$",
"str",
",",
"int",
"$",
"length",
",",
"string",
"$",
"padStr",
"=",
"' '",
")",
":",
"string",
"{",
"return",
"(",
"string",
")",
"BaseStringy",
"::",
"create",
"(",
"$",
"str",
")",
"->",
"padLeft",
"(",
"$",
"length",
",",
"$",
"padStr",
")",
";",
"}"
]
| Returns a new string of a given length such that the beginning of the string is padded.
@param string $str The string to pad.
@param int $length The desired string length after padding.
@param string $padStr The string used to pad, defaults to space.
@return string The padded string. | [
"Returns",
"a",
"new",
"string",
"of",
"a",
"given",
"length",
"such",
"that",
"the",
"beginning",
"of",
"the",
"string",
"is",
"padded",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L583-L586 |
17,066 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.padRight | public static function padRight(string $str, int $length, string $padStr = ' '): string
{
return (string)BaseStringy::create($str)->padRight($length, $padStr);
} | php | public static function padRight(string $str, int $length, string $padStr = ' '): string
{
return (string)BaseStringy::create($str)->padRight($length, $padStr);
} | [
"public",
"static",
"function",
"padRight",
"(",
"string",
"$",
"str",
",",
"int",
"$",
"length",
",",
"string",
"$",
"padStr",
"=",
"' '",
")",
":",
"string",
"{",
"return",
"(",
"string",
")",
"BaseStringy",
"::",
"create",
"(",
"$",
"str",
")",
"->",
"padRight",
"(",
"$",
"length",
",",
"$",
"padStr",
")",
";",
"}"
]
| Returns a new string of a given length such that the end of the string is padded.
@param string $str The string to pad.
@param int $length The desired string length after padding.
@param string $padStr The string used to pad, defaults to space.
@return string The padded string. | [
"Returns",
"a",
"new",
"string",
"of",
"a",
"given",
"length",
"such",
"that",
"the",
"end",
"of",
"the",
"string",
"is",
"padded",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L596-L599 |
17,067 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.asciiCharMap | public static function asciiCharMap(): array
{
if (self::$_asciiCharMap !== null) {
return self::$_asciiCharMap;
}
// Get the map from Stringy.
self::$_asciiCharMap = (new Stringy(''))->getAsciiCharMap();
return self::$_asciiCharMap;
} | php | public static function asciiCharMap(): array
{
if (self::$_asciiCharMap !== null) {
return self::$_asciiCharMap;
}
// Get the map from Stringy.
self::$_asciiCharMap = (new Stringy(''))->getAsciiCharMap();
return self::$_asciiCharMap;
} | [
"public",
"static",
"function",
"asciiCharMap",
"(",
")",
":",
"array",
"{",
"if",
"(",
"self",
"::",
"$",
"_asciiCharMap",
"!==",
"null",
")",
"{",
"return",
"self",
"::",
"$",
"_asciiCharMap",
";",
"}",
"// Get the map from Stringy.",
"self",
"::",
"$",
"_asciiCharMap",
"=",
"(",
"new",
"Stringy",
"(",
"''",
")",
")",
"->",
"getAsciiCharMap",
"(",
")",
";",
"return",
"self",
"::",
"$",
"_asciiCharMap",
";",
"}"
]
| Returns ASCII character mappings, merging in any custom defined mappings from the 'customAsciiCharMappings'
config setting.
@return array The fully merged ASCII character mappings. | [
"Returns",
"ASCII",
"character",
"mappings",
"merging",
"in",
"any",
"custom",
"defined",
"mappings",
"from",
"the",
"customAsciiCharMappings",
"config",
"setting",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L948-L958 |
17,068 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.convertToUtf8 | public static function convertToUtf8(string $string): string
{
// If it's already a UTF8 string, just clean and return it
if (static::isUtf8($string)) {
return HtmlPurifier::cleanUtf8($string);
}
// Otherwise set HTMLPurifier to the actual string encoding
$config = \HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', static::encoding($string));
// Clean it
$string = HtmlPurifier::cleanUtf8($string);
// Convert it to UTF8 if possible
if (function_exists('iconv') && \HTMLPurifier_Encoder::testIconvTruncateBug() === \HTMLPurifier_Encoder::ICONV_OK) {
$string = HtmlPurifier::convertToUtf8($string, $config);
} else {
$encoding = static::encoding($string);
$string = mb_convert_encoding($string, 'utf-8', $encoding);
}
return $string;
} | php | public static function convertToUtf8(string $string): string
{
// If it's already a UTF8 string, just clean and return it
if (static::isUtf8($string)) {
return HtmlPurifier::cleanUtf8($string);
}
// Otherwise set HTMLPurifier to the actual string encoding
$config = \HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', static::encoding($string));
// Clean it
$string = HtmlPurifier::cleanUtf8($string);
// Convert it to UTF8 if possible
if (function_exists('iconv') && \HTMLPurifier_Encoder::testIconvTruncateBug() === \HTMLPurifier_Encoder::ICONV_OK) {
$string = HtmlPurifier::convertToUtf8($string, $config);
} else {
$encoding = static::encoding($string);
$string = mb_convert_encoding($string, 'utf-8', $encoding);
}
return $string;
} | [
"public",
"static",
"function",
"convertToUtf8",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"// If it's already a UTF8 string, just clean and return it",
"if",
"(",
"static",
"::",
"isUtf8",
"(",
"$",
"string",
")",
")",
"{",
"return",
"HtmlPurifier",
"::",
"cleanUtf8",
"(",
"$",
"string",
")",
";",
"}",
"// Otherwise set HTMLPurifier to the actual string encoding",
"$",
"config",
"=",
"\\",
"HTMLPurifier_Config",
"::",
"createDefault",
"(",
")",
";",
"$",
"config",
"->",
"set",
"(",
"'Core.Encoding'",
",",
"static",
"::",
"encoding",
"(",
"$",
"string",
")",
")",
";",
"// Clean it",
"$",
"string",
"=",
"HtmlPurifier",
"::",
"cleanUtf8",
"(",
"$",
"string",
")",
";",
"// Convert it to UTF8 if possible",
"if",
"(",
"function_exists",
"(",
"'iconv'",
")",
"&&",
"\\",
"HTMLPurifier_Encoder",
"::",
"testIconvTruncateBug",
"(",
")",
"===",
"\\",
"HTMLPurifier_Encoder",
"::",
"ICONV_OK",
")",
"{",
"$",
"string",
"=",
"HtmlPurifier",
"::",
"convertToUtf8",
"(",
"$",
"string",
",",
"$",
"config",
")",
";",
"}",
"else",
"{",
"$",
"encoding",
"=",
"static",
"::",
"encoding",
"(",
"$",
"string",
")",
";",
"$",
"string",
"=",
"mb_convert_encoding",
"(",
"$",
"string",
",",
"'utf-8'",
",",
"$",
"encoding",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
]
| Attempts to convert a string to UTF-8 and clean any non-valid UTF-8 characters.
@param string $string
@return string | [
"Attempts",
"to",
"convert",
"a",
"string",
"to",
"UTF",
"-",
"8",
"and",
"clean",
"any",
"non",
"-",
"valid",
"UTF",
"-",
"8",
"characters",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L978-L1001 |
17,069 | yuncms/framework | src/helpers/StringHelper.php | StringHelper.encodeMb4 | public static function encodeMb4(string $string): string
{
// Does this string have any 4+ byte Unicode chars?
if (max(array_map('ord', str_split($string))) >= 240) {
$string = preg_replace_callback('/./u', function (array $match) {
if (strlen($match[0]) >= 4) {
// (Logic pulled from WP's wp_encode_emoji() function)
// UTF-32's hex encoding is the same as HTML's hex encoding.
// So, by converting from UTF-8 to UTF-32, we magically
// get the correct hex encoding.
$unpacked = unpack('H*', mb_convert_encoding($match[0], 'UTF-32', 'UTF-8'));
return isset($unpacked[1]) ? '&#x' . ltrim($unpacked[1], '0') . ';' : '';
}
return $match[0];
}, $string);
}
return $string;
} | php | public static function encodeMb4(string $string): string
{
// Does this string have any 4+ byte Unicode chars?
if (max(array_map('ord', str_split($string))) >= 240) {
$string = preg_replace_callback('/./u', function (array $match) {
if (strlen($match[0]) >= 4) {
// (Logic pulled from WP's wp_encode_emoji() function)
// UTF-32's hex encoding is the same as HTML's hex encoding.
// So, by converting from UTF-8 to UTF-32, we magically
// get the correct hex encoding.
$unpacked = unpack('H*', mb_convert_encoding($match[0], 'UTF-32', 'UTF-8'));
return isset($unpacked[1]) ? '&#x' . ltrim($unpacked[1], '0') . ';' : '';
}
return $match[0];
}, $string);
}
return $string;
} | [
"public",
"static",
"function",
"encodeMb4",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"// Does this string have any 4+ byte Unicode chars?",
"if",
"(",
"max",
"(",
"array_map",
"(",
"'ord'",
",",
"str_split",
"(",
"$",
"string",
")",
")",
")",
">=",
"240",
")",
"{",
"$",
"string",
"=",
"preg_replace_callback",
"(",
"'/./u'",
",",
"function",
"(",
"array",
"$",
"match",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"match",
"[",
"0",
"]",
")",
">=",
"4",
")",
"{",
"// (Logic pulled from WP's wp_encode_emoji() function)",
"// UTF-32's hex encoding is the same as HTML's hex encoding.",
"// So, by converting from UTF-8 to UTF-32, we magically",
"// get the correct hex encoding.",
"$",
"unpacked",
"=",
"unpack",
"(",
"'H*'",
",",
"mb_convert_encoding",
"(",
"$",
"match",
"[",
"0",
"]",
",",
"'UTF-32'",
",",
"'UTF-8'",
")",
")",
";",
"return",
"isset",
"(",
"$",
"unpacked",
"[",
"1",
"]",
")",
"?",
"'&#x'",
".",
"ltrim",
"(",
"$",
"unpacked",
"[",
"1",
"]",
",",
"'0'",
")",
".",
"';'",
":",
"''",
";",
"}",
"return",
"$",
"match",
"[",
"0",
"]",
";",
"}",
",",
"$",
"string",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
]
| HTML-encodes any 4-byte UTF-8 characters.
@param string $string The string
@return string The string with converted 4-byte UTF-8 characters
@see http://stackoverflow.com/a/16496730/1688568 | [
"HTML",
"-",
"encodes",
"any",
"4",
"-",
"byte",
"UTF",
"-",
"8",
"characters",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L1032-L1052 |
17,070 | askupasoftware/amarkal | Extensions/WordPress/Admin/AdminPage.php | AdminPage.add_page | public function add_page( $config )
{
foreach( $this->required_params() as $param )
{
if( !isset( $config[$param] ) )
{
throw new \RuntimeException( 'Missing required parameter "'.$param.'" for submenu' );
}
}
$this->config['submenu-pages'][] = $config;
} | php | public function add_page( $config )
{
foreach( $this->required_params() as $param )
{
if( !isset( $config[$param] ) )
{
throw new \RuntimeException( 'Missing required parameter "'.$param.'" for submenu' );
}
}
$this->config['submenu-pages'][] = $config;
} | [
"public",
"function",
"add_page",
"(",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"required_params",
"(",
")",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"param",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Missing required parameter \"'",
".",
"$",
"param",
".",
"'\" for submenu'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"config",
"[",
"'submenu-pages'",
"]",
"[",
"]",
"=",
"$",
"config",
";",
"}"
]
| Add a page to this menu.
If there is only one page set for this menu, no submenu will be created.
If there is more than one page set for this menu, a submenu will
automatically be created with all the pages of this menu.
Possible options are:
title: (Required) Submenu title AND submenu page title tag.
capability: (Required) The capability required for this menu to be displayed to the user.
content: (Required) The function that displays the page content for the menu page.
@param mixed[] $config The page's configuration.
@throws \RuntimeException If one of the required options was not set. | [
"Add",
"a",
"page",
"to",
"this",
"menu",
"."
]
| fe8283e2d6847ef697abec832da7ee741a85058c | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Admin/AdminPage.php#L64-L74 |
17,071 | askupasoftware/amarkal | Extensions/WordPress/Admin/AdminPage.php | AdminPage.set_config | private function set_config( $config )
{
if( !isset( $config['title'] ) )
{
throw new \RuntimeException( 'Missing required parameter "title" for menu' );
}
if( !isset( $config['slug'] ) || '' == $config['slug'] )
{
$config['slug'] = \Amarkal\Common\Tools::strtoslug( $config['title'] );
}
$this->config = array_merge( $this->get_defaults(), $config );
} | php | private function set_config( $config )
{
if( !isset( $config['title'] ) )
{
throw new \RuntimeException( 'Missing required parameter "title" for menu' );
}
if( !isset( $config['slug'] ) || '' == $config['slug'] )
{
$config['slug'] = \Amarkal\Common\Tools::strtoslug( $config['title'] );
}
$this->config = array_merge( $this->get_defaults(), $config );
} | [
"private",
"function",
"set_config",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'title'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Missing required parameter \"title\" for menu'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'slug'",
"]",
")",
"||",
"''",
"==",
"$",
"config",
"[",
"'slug'",
"]",
")",
"{",
"$",
"config",
"[",
"'slug'",
"]",
"=",
"\\",
"Amarkal",
"\\",
"Common",
"\\",
"Tools",
"::",
"strtoslug",
"(",
"$",
"config",
"[",
"'title'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"config",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"get_defaults",
"(",
")",
",",
"$",
"config",
")",
";",
"}"
]
| Set the configuration for this menu page.
Validates that all the required parameters have been provided.
Auto generates a slug if none was provided.
@param mixed[] $config The configuraion.
@throws \RuntimeException If one of the required options was not provided. | [
"Set",
"the",
"configuration",
"for",
"this",
"menu",
"page",
"."
]
| fe8283e2d6847ef697abec832da7ee741a85058c | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Admin/AdminPage.php#L124-L136 |
17,072 | askupasoftware/amarkal | Extensions/WordPress/Admin/AdminPage.php | AdminPage.add_menu_page | public function add_menu_page()
{
extract( $this->config );
$icon .= '' != $class ? '" class="'.$class : '';
$icon .= array() != $style ? '" style="'.$this->array_to_css($style) : '';
$page = $this->config['submenu-pages'][0];
\add_menu_page(
$title,
$title,
$page['capability'],
$slug,
$page['content'],
$icon,
$position
);
if( count($this->config['submenu-pages']) > 1 )
{
$this->add_submenu_pages();
}
} | php | public function add_menu_page()
{
extract( $this->config );
$icon .= '' != $class ? '" class="'.$class : '';
$icon .= array() != $style ? '" style="'.$this->array_to_css($style) : '';
$page = $this->config['submenu-pages'][0];
\add_menu_page(
$title,
$title,
$page['capability'],
$slug,
$page['content'],
$icon,
$position
);
if( count($this->config['submenu-pages']) > 1 )
{
$this->add_submenu_pages();
}
} | [
"public",
"function",
"add_menu_page",
"(",
")",
"{",
"extract",
"(",
"$",
"this",
"->",
"config",
")",
";",
"$",
"icon",
".=",
"''",
"!=",
"$",
"class",
"?",
"'\" class=\"'",
".",
"$",
"class",
":",
"''",
";",
"$",
"icon",
".=",
"array",
"(",
")",
"!=",
"$",
"style",
"?",
"'\" style=\"'",
".",
"$",
"this",
"->",
"array_to_css",
"(",
"$",
"style",
")",
":",
"''",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"config",
"[",
"'submenu-pages'",
"]",
"[",
"0",
"]",
";",
"\\",
"add_menu_page",
"(",
"$",
"title",
",",
"$",
"title",
",",
"$",
"page",
"[",
"'capability'",
"]",
",",
"$",
"slug",
",",
"$",
"page",
"[",
"'content'",
"]",
",",
"$",
"icon",
",",
"$",
"position",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"config",
"[",
"'submenu-pages'",
"]",
")",
">",
"1",
")",
"{",
"$",
"this",
"->",
"add_submenu_pages",
"(",
")",
";",
"}",
"}"
]
| Add this page, and all it's submenus, to the admin sidebar.
Internally used when the admin_menu action is called.
This function is called by AdminPage::register(). | [
"Add",
"this",
"page",
"and",
"all",
"it",
"s",
"submenus",
"to",
"the",
"admin",
"sidebar",
"."
]
| fe8283e2d6847ef697abec832da7ee741a85058c | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Admin/AdminPage.php#L144-L165 |
17,073 | askupasoftware/amarkal | Extensions/WordPress/Admin/AdminPage.php | AdminPage.array_to_css | private function array_to_css( array $rules )
{
$css = '';
foreach( $rules as $rule => $value )
{
$css .= $rule.':'.$value.';';
}
return $css;
} | php | private function array_to_css( array $rules )
{
$css = '';
foreach( $rules as $rule => $value )
{
$css .= $rule.':'.$value.';';
}
return $css;
} | [
"private",
"function",
"array_to_css",
"(",
"array",
"$",
"rules",
")",
"{",
"$",
"css",
"=",
"''",
";",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"rule",
"=>",
"$",
"value",
")",
"{",
"$",
"css",
".=",
"$",
"rule",
".",
"':'",
".",
"$",
"value",
".",
"';'",
";",
"}",
"return",
"$",
"css",
";",
"}"
]
| Array to CSS.
Converts an array of rule => value into proper CSS formatted rules.
@param string[] $rules The CSS rules.
@return string The CSS formatted string. | [
"Array",
"to",
"CSS",
"."
]
| fe8283e2d6847ef697abec832da7ee741a85058c | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Admin/AdminPage.php#L199-L207 |
17,074 | milkyway-multimedia/ss-mwm-formfields | src/RecordMapField.php | RecordMapField.available_map_fields | public static function available_map_fields($class)
{
if (!in_array($class, self::config()->allowed_classes) || !\ClassInfo::exists($class))
return false;
$available = \Config::inst()->get($class, 'public_fields') ? \Config::inst()->get($class, 'public_fields') : array_keys(singleton($class)->summaryFields());
$fields = array_diff($available, self::config()->disable_map_fields);
return count($fields) ? $fields : false;
} | php | public static function available_map_fields($class)
{
if (!in_array($class, self::config()->allowed_classes) || !\ClassInfo::exists($class))
return false;
$available = \Config::inst()->get($class, 'public_fields') ? \Config::inst()->get($class, 'public_fields') : array_keys(singleton($class)->summaryFields());
$fields = array_diff($available, self::config()->disable_map_fields);
return count($fields) ? $fields : false;
} | [
"public",
"static",
"function",
"available_map_fields",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"class",
",",
"self",
"::",
"config",
"(",
")",
"->",
"allowed_classes",
")",
"||",
"!",
"\\",
"ClassInfo",
"::",
"exists",
"(",
"$",
"class",
")",
")",
"return",
"false",
";",
"$",
"available",
"=",
"\\",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"'public_fields'",
")",
"?",
"\\",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"'public_fields'",
")",
":",
"array_keys",
"(",
"singleton",
"(",
"$",
"class",
")",
"->",
"summaryFields",
"(",
")",
")",
";",
"$",
"fields",
"=",
"array_diff",
"(",
"$",
"available",
",",
"self",
"::",
"config",
"(",
")",
"->",
"disable_map_fields",
")",
";",
"return",
"count",
"(",
"$",
"fields",
")",
"?",
"$",
"fields",
":",
"false",
";",
"}"
]
| Return an array of fields that can be mapped to a class name
Looks for public_fields set via config, otherwise defaults to summary_fields
@param string $class
@return array|bool | [
"Return",
"an",
"array",
"of",
"fields",
"that",
"can",
"be",
"mapped",
"to",
"a",
"class",
"name",
"Looks",
"for",
"public_fields",
"set",
"via",
"config",
"otherwise",
"defaults",
"to",
"summary_fields"
]
| b98d84d494c92d6881dcea50c9c8334e5f487e1d | https://github.com/milkyway-multimedia/ss-mwm-formfields/blob/b98d84d494c92d6881dcea50c9c8334e5f487e1d/src/RecordMapField.php#L66-L76 |
17,075 | jfusion/org.jfusion.framework | src/User/Sync.php | Sync.init | private static function init() {
ob_start();
set_time_limit(0);
ini_set('memory_limit', '256M');
ini_set('upload_max_filesize', '128M');
ini_set('post_max_size', '256M');
ini_set('max_input_time', '7200');
ini_set('max_execution_time', '0');
ini_set('expect.timeout', '7200');
ini_set('default_socket_timeout', '7200');
ob_end_clean();
} | php | private static function init() {
ob_start();
set_time_limit(0);
ini_set('memory_limit', '256M');
ini_set('upload_max_filesize', '128M');
ini_set('post_max_size', '256M');
ini_set('max_input_time', '7200');
ini_set('max_execution_time', '0');
ini_set('expect.timeout', '7200');
ini_set('default_socket_timeout', '7200');
ob_end_clean();
} | [
"private",
"static",
"function",
"init",
"(",
")",
"{",
"ob_start",
"(",
")",
";",
"set_time_limit",
"(",
"0",
")",
";",
"ini_set",
"(",
"'memory_limit'",
",",
"'256M'",
")",
";",
"ini_set",
"(",
"'upload_max_filesize'",
",",
"'128M'",
")",
";",
"ini_set",
"(",
"'post_max_size'",
",",
"'256M'",
")",
";",
"ini_set",
"(",
"'max_input_time'",
",",
"'7200'",
")",
";",
"ini_set",
"(",
"'max_execution_time'",
",",
"'0'",
")",
";",
"ini_set",
"(",
"'expect.timeout'",
",",
"'7200'",
")",
";",
"ini_set",
"(",
"'default_socket_timeout'",
",",
"'7200'",
")",
";",
"ob_end_clean",
"(",
")",
";",
"}"
]
| function will attempt to alocate more resources to run the sync | [
"function",
"will",
"attempt",
"to",
"alocate",
"more",
"resources",
"to",
"run",
"the",
"sync"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L42-L54 |
17,076 | jfusion/org.jfusion.framework | src/User/Sync.php | Sync.getLogData | public static function getLogData($syncid, $type = 'all', $limitstart = null, $limit = null, $sort = 'id', $dir = 'ASC')
{
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('*')
->from('#__jfusion_sync_details')
->where('syncid = ' . $db->quote($syncid));
if (!empty($sort)) {
$query->order($sort . ' ' . $dir);
}
if ($type != 'all') {
$query->where('action = ' . $db->quote($type));
}
$db->setQuery($query, $limitstart, $limit);
$results = $db->loadObjectList('id');
return $results;
} | php | public static function getLogData($syncid, $type = 'all', $limitstart = null, $limit = null, $sort = 'id', $dir = 'ASC')
{
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('*')
->from('#__jfusion_sync_details')
->where('syncid = ' . $db->quote($syncid));
if (!empty($sort)) {
$query->order($sort . ' ' . $dir);
}
if ($type != 'all') {
$query->where('action = ' . $db->quote($type));
}
$db->setQuery($query, $limitstart, $limit);
$results = $db->loadObjectList('id');
return $results;
} | [
"public",
"static",
"function",
"getLogData",
"(",
"$",
"syncid",
",",
"$",
"type",
"=",
"'all'",
",",
"$",
"limitstart",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"sort",
"=",
"'id'",
",",
"$",
"dir",
"=",
"'ASC'",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'*'",
")",
"->",
"from",
"(",
"'#__jfusion_sync_details'",
")",
"->",
"where",
"(",
"'syncid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"syncid",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sort",
")",
")",
"{",
"$",
"query",
"->",
"order",
"(",
"$",
"sort",
".",
"' '",
".",
"$",
"dir",
")",
";",
"}",
"if",
"(",
"$",
"type",
"!=",
"'all'",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'action = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"type",
")",
")",
";",
"}",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
",",
"$",
"limitstart",
",",
"$",
"limit",
")",
";",
"$",
"results",
"=",
"$",
"db",
"->",
"loadObjectList",
"(",
"'id'",
")",
";",
"return",
"$",
"results",
";",
"}"
]
| Retrieve log data
@param string $syncid the usersync id
@param string $type
@param int $limitstart
@param int $limit
@param string $sort
@param string $dir
@return stdClass[] nothing | [
"Retrieve",
"log",
"data"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L162-L183 |
17,077 | jfusion/org.jfusion.framework | src/User/Sync.php | Sync.saveData | public static function saveData(Registry $syncdata)
{
$db = Factory::getDBO();
$data = new stdClass;
$data->syncdata = $syncdata->toString();
$data->syncid = $syncdata->get('syncid');
$data->time_start = time();
$data->action = $syncdata->get('action');
$db->insertObject('#__jfusion_sync', $data);
} | php | public static function saveData(Registry $syncdata)
{
$db = Factory::getDBO();
$data = new stdClass;
$data->syncdata = $syncdata->toString();
$data->syncid = $syncdata->get('syncid');
$data->time_start = time();
$data->action = $syncdata->get('action');
$db->insertObject('#__jfusion_sync', $data);
} | [
"public",
"static",
"function",
"saveData",
"(",
"Registry",
"$",
"syncdata",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"data",
"=",
"new",
"stdClass",
";",
"$",
"data",
"->",
"syncdata",
"=",
"$",
"syncdata",
"->",
"toString",
"(",
")",
";",
"$",
"data",
"->",
"syncid",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'syncid'",
")",
";",
"$",
"data",
"->",
"time_start",
"=",
"time",
"(",
")",
";",
"$",
"data",
"->",
"action",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'action'",
")",
";",
"$",
"db",
"->",
"insertObject",
"(",
"'#__jfusion_sync'",
",",
"$",
"data",
")",
";",
"}"
]
| Save sync data
@param Registry &$syncdata the actual syncdata
@return string nothing | [
"Save",
"sync",
"data"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L216-L226 |
17,078 | jfusion/org.jfusion.framework | src/User/Sync.php | Sync.markResolved | public static function markResolved($id) {
$db = Factory::getDBO();
$query = $db->getQuery(true)
->update('#__jfusion_sync_details')
->set('action = ' . $db->quote('resolved'))
->where('id = ' . $db->quote($id));
$db->setQuery($query);
$db->execute();
} | php | public static function markResolved($id) {
$db = Factory::getDBO();
$query = $db->getQuery(true)
->update('#__jfusion_sync_details')
->set('action = ' . $db->quote('resolved'))
->where('id = ' . $db->quote($id));
$db->setQuery($query);
$db->execute();
} | [
"public",
"static",
"function",
"markResolved",
"(",
"$",
"id",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"update",
"(",
"'#__jfusion_sync_details'",
")",
"->",
"set",
"(",
"'action = '",
".",
"$",
"db",
"->",
"quote",
"(",
"'resolved'",
")",
")",
"->",
"where",
"(",
"'id = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"id",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}"
]
| Marks an error in sync details as resolved to prevent it from constantly showing up in the resolve error view
@param $id | [
"Marks",
"an",
"error",
"in",
"sync",
"details",
"as",
"resolved",
"to",
"prevent",
"it",
"from",
"constantly",
"showing",
"up",
"in",
"the",
"resolve",
"error",
"view"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L386-L396 |
17,079 | fubhy/graphql-php | src/Utility/TypeInfo.php | TypeInfo.getFieldDefinition | protected static function getFieldDefinition(Schema $schema, Type $parentType, Field $fieldAST)
{
$name = $fieldAST->get('name')->get('value');
$schemaMeta = Introspection::schemaMetaFieldDefinition();
if ($name === $schemaMeta->getName() && $schema->getQueryType() === $parentType) {
return $schemaMeta;
}
$typeMeta = Introspection::typeMetaFieldDefinition();
if ($name === $typeMeta->getName() && $schema->getQueryType() === $parentType) {
return $typeMeta;
}
$typeNameMeta = Introspection::typeNameMetaFieldDefinition();
if ($name === $typeNameMeta->getName() && ($parentType instanceof ObjectType || $parentType instanceof InterfaceType || $parentType instanceof UnionType)) {
return $typeNameMeta;
}
if ($parentType instanceof ObjectType || $parentType instanceof InterfaceType) {
$fields = $parentType->getFields();
return isset($fields[$name]) ? $fields[$name] : NULL;
}
return NULL;
} | php | protected static function getFieldDefinition(Schema $schema, Type $parentType, Field $fieldAST)
{
$name = $fieldAST->get('name')->get('value');
$schemaMeta = Introspection::schemaMetaFieldDefinition();
if ($name === $schemaMeta->getName() && $schema->getQueryType() === $parentType) {
return $schemaMeta;
}
$typeMeta = Introspection::typeMetaFieldDefinition();
if ($name === $typeMeta->getName() && $schema->getQueryType() === $parentType) {
return $typeMeta;
}
$typeNameMeta = Introspection::typeNameMetaFieldDefinition();
if ($name === $typeNameMeta->getName() && ($parentType instanceof ObjectType || $parentType instanceof InterfaceType || $parentType instanceof UnionType)) {
return $typeNameMeta;
}
if ($parentType instanceof ObjectType || $parentType instanceof InterfaceType) {
$fields = $parentType->getFields();
return isset($fields[$name]) ? $fields[$name] : NULL;
}
return NULL;
} | [
"protected",
"static",
"function",
"getFieldDefinition",
"(",
"Schema",
"$",
"schema",
",",
"Type",
"$",
"parentType",
",",
"Field",
"$",
"fieldAST",
")",
"{",
"$",
"name",
"=",
"$",
"fieldAST",
"->",
"get",
"(",
"'name'",
")",
"->",
"get",
"(",
"'value'",
")",
";",
"$",
"schemaMeta",
"=",
"Introspection",
"::",
"schemaMetaFieldDefinition",
"(",
")",
";",
"if",
"(",
"$",
"name",
"===",
"$",
"schemaMeta",
"->",
"getName",
"(",
")",
"&&",
"$",
"schema",
"->",
"getQueryType",
"(",
")",
"===",
"$",
"parentType",
")",
"{",
"return",
"$",
"schemaMeta",
";",
"}",
"$",
"typeMeta",
"=",
"Introspection",
"::",
"typeMetaFieldDefinition",
"(",
")",
";",
"if",
"(",
"$",
"name",
"===",
"$",
"typeMeta",
"->",
"getName",
"(",
")",
"&&",
"$",
"schema",
"->",
"getQueryType",
"(",
")",
"===",
"$",
"parentType",
")",
"{",
"return",
"$",
"typeMeta",
";",
"}",
"$",
"typeNameMeta",
"=",
"Introspection",
"::",
"typeNameMetaFieldDefinition",
"(",
")",
";",
"if",
"(",
"$",
"name",
"===",
"$",
"typeNameMeta",
"->",
"getName",
"(",
")",
"&&",
"(",
"$",
"parentType",
"instanceof",
"ObjectType",
"||",
"$",
"parentType",
"instanceof",
"InterfaceType",
"||",
"$",
"parentType",
"instanceof",
"UnionType",
")",
")",
"{",
"return",
"$",
"typeNameMeta",
";",
"}",
"if",
"(",
"$",
"parentType",
"instanceof",
"ObjectType",
"||",
"$",
"parentType",
"instanceof",
"InterfaceType",
")",
"{",
"$",
"fields",
"=",
"$",
"parentType",
"->",
"getFields",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"fields",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"fields",
"[",
"$",
"name",
"]",
":",
"NULL",
";",
"}",
"return",
"NULL",
";",
"}"
]
| Not exactly the same as the executor's definition of getFieldDef, in this
statically evaluated environment we do not always have an Object type,
and need to handle Interface and Union types.
@param Schema $schema
@param Type $parentType
@param Field $fieldAST
@return FieldDefinition | [
"Not",
"exactly",
"the",
"same",
"as",
"the",
"executor",
"s",
"definition",
"of",
"getFieldDef",
"in",
"this",
"statically",
"evaluated",
"environment",
"we",
"do",
"not",
"always",
"have",
"an",
"Object",
"type",
"and",
"need",
"to",
"handle",
"Interface",
"and",
"Union",
"types",
"."
]
| c1de2233c731ca29e5c5db4c43f3b9db36478c83 | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Utility/TypeInfo.php#L89-L113 |
17,080 | ufocoder/yii2-SyncSocial | src/components/Synchronizer.php | Synchronizer.factorySyncService | protected function factorySyncService( $serviceName ) {
$syncClass = '\\ufocoder\\SyncSocial\\components\\services\\' . ucfirst( $serviceName );
if ( ! class_exists( $syncClass ) ) {
throw new Exception( Yii::t( 'SyncSocial', 'SyncSocial Extension not support "{serviceName}" service', [
'serviceName' => $serviceName
] ) );
}
return new $syncClass( [
'serviceSettings' => isset( $this->settings[ $serviceName ] ) ? $this->settings[ $serviceName ] : [ ],
'connectUrl' => $this->getConnectUrl( $serviceName )
] );
} | php | protected function factorySyncService( $serviceName ) {
$syncClass = '\\ufocoder\\SyncSocial\\components\\services\\' . ucfirst( $serviceName );
if ( ! class_exists( $syncClass ) ) {
throw new Exception( Yii::t( 'SyncSocial', 'SyncSocial Extension not support "{serviceName}" service', [
'serviceName' => $serviceName
] ) );
}
return new $syncClass( [
'serviceSettings' => isset( $this->settings[ $serviceName ] ) ? $this->settings[ $serviceName ] : [ ],
'connectUrl' => $this->getConnectUrl( $serviceName )
] );
} | [
"protected",
"function",
"factorySyncService",
"(",
"$",
"serviceName",
")",
"{",
"$",
"syncClass",
"=",
"'\\\\ufocoder\\\\SyncSocial\\\\components\\\\services\\\\'",
".",
"ucfirst",
"(",
"$",
"serviceName",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"syncClass",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"Yii",
"::",
"t",
"(",
"'SyncSocial'",
",",
"'SyncSocial Extension not support \"{serviceName}\" service'",
",",
"[",
"'serviceName'",
"=>",
"$",
"serviceName",
"]",
")",
")",
";",
"}",
"return",
"new",
"$",
"syncClass",
"(",
"[",
"'serviceSettings'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"serviceName",
"]",
")",
"?",
"$",
"this",
"->",
"settings",
"[",
"$",
"serviceName",
"]",
":",
"[",
"]",
",",
"'connectUrl'",
"=>",
"$",
"this",
"->",
"getConnectUrl",
"(",
"$",
"serviceName",
")",
"]",
")",
";",
"}"
]
| Create service synchronizer wrapper class
@param $serviceName
@return \yii\authclient\BaseOAuth
@throws Exception | [
"Create",
"service",
"synchronizer",
"wrapper",
"class"
]
| 2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b | https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L143-L157 |
17,081 | ufocoder/yii2-SyncSocial | src/components/Synchronizer.php | Synchronizer.syncActiveRecord | public function syncActiveRecord( $serviceName = null, ActiveRecord $model ) {
$service = $this->getService( $serviceName );
if ( $service->isConnected() && ! $this->isExistsSyncModelByActiveRecord( $service, $model ) ) {
$message = $model->{$this->modelAttribute};
$function = $this->absolutePostUrl;
$url = null;
if ( is_callable( $function ) && ( $function instanceof Closure ) ) {
$url = $function( $serviceName, $model->getPrimaryKey() );
}
$publishData = $service->publishPost( $message, $url );
return $this->checkPostData( $publishData ) && $this->createSyncModel( $service, $model, $publishData );
} else {
return false;
}
} | php | public function syncActiveRecord( $serviceName = null, ActiveRecord $model ) {
$service = $this->getService( $serviceName );
if ( $service->isConnected() && ! $this->isExistsSyncModelByActiveRecord( $service, $model ) ) {
$message = $model->{$this->modelAttribute};
$function = $this->absolutePostUrl;
$url = null;
if ( is_callable( $function ) && ( $function instanceof Closure ) ) {
$url = $function( $serviceName, $model->getPrimaryKey() );
}
$publishData = $service->publishPost( $message, $url );
return $this->checkPostData( $publishData ) && $this->createSyncModel( $service, $model, $publishData );
} else {
return false;
}
} | [
"public",
"function",
"syncActiveRecord",
"(",
"$",
"serviceName",
"=",
"null",
",",
"ActiveRecord",
"$",
"model",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"serviceName",
")",
";",
"if",
"(",
"$",
"service",
"->",
"isConnected",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"isExistsSyncModelByActiveRecord",
"(",
"$",
"service",
",",
"$",
"model",
")",
")",
"{",
"$",
"message",
"=",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"modelAttribute",
"}",
";",
"$",
"function",
"=",
"$",
"this",
"->",
"absolutePostUrl",
";",
"$",
"url",
"=",
"null",
";",
"if",
"(",
"is_callable",
"(",
"$",
"function",
")",
"&&",
"(",
"$",
"function",
"instanceof",
"Closure",
")",
")",
"{",
"$",
"url",
"=",
"$",
"function",
"(",
"$",
"serviceName",
",",
"$",
"model",
"->",
"getPrimaryKey",
"(",
")",
")",
";",
"}",
"$",
"publishData",
"=",
"$",
"service",
"->",
"publishPost",
"(",
"$",
"message",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"checkPostData",
"(",
"$",
"publishData",
")",
"&&",
"$",
"this",
"->",
"createSyncModel",
"(",
"$",
"service",
",",
"$",
"model",
",",
"$",
"publishData",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
]
| Post message with URL to Social Network
@param null $serviceName
@param \yii\db\ActiveRecord $model
@return bool | [
"Post",
"message",
"with",
"URL",
"to",
"Social",
"Network"
]
| 2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b | https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L432-L453 |
17,082 | webforge-labs/psc-cms | lib/Psc/Code/Event/Manager.php | Manager.dispatch | public function dispatch(Event $event) {
foreach ($this->getSubscribers($event) as $subscriber) {
$subscriber->trigger($event);
}
return $this;
} | php | public function dispatch(Event $event) {
foreach ($this->getSubscribers($event) as $subscriber) {
$subscriber->trigger($event);
}
return $this;
} | [
"public",
"function",
"dispatch",
"(",
"Event",
"$",
"event",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSubscribers",
"(",
"$",
"event",
")",
"as",
"$",
"subscriber",
")",
"{",
"$",
"subscriber",
"->",
"trigger",
"(",
"$",
"event",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Dispatched ein Event
@chainable | [
"Dispatched",
"ein",
"Event"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Event/Manager.php#L13-L20 |
17,083 | ClanCats/Core | src/bundles/Auth/Handler.php | Handler.create | public static function create( $name = null, $conf = null )
{
if ( is_null( $name ) )
{
$name = static::$_default;
}
if ( !is_null( $conf ) && is_array( $conf ) )
{
return static::$_instances[$name] = new static( $name, $conf );
}
if ( !isset( static::$_instances[$name] ) )
{
static::$_instances[$name] = new static( $name );
}
return static::$_instances[$name];
} | php | public static function create( $name = null, $conf = null )
{
if ( is_null( $name ) )
{
$name = static::$_default;
}
if ( !is_null( $conf ) && is_array( $conf ) )
{
return static::$_instances[$name] = new static( $name, $conf );
}
if ( !isset( static::$_instances[$name] ) )
{
static::$_instances[$name] = new static( $name );
}
return static::$_instances[$name];
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"conf",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"static",
"::",
"$",
"_default",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"conf",
")",
"&&",
"is_array",
"(",
"$",
"conf",
")",
")",
"{",
"return",
"static",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
"=",
"new",
"static",
"(",
"$",
"name",
",",
"$",
"conf",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"static",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
"=",
"new",
"static",
"(",
"$",
"name",
")",
";",
"}",
"return",
"static",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
";",
"}"
]
| Get an auth instance or create one
@param string $name
@param array $conf You can pass optionally a configuration directly. This will overwrite.
@return Auth_Handler | [
"Get",
"an",
"auth",
"instance",
"or",
"create",
"one"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L38-L56 |
17,084 | ClanCats/Core | src/bundles/Auth/Handler.php | Handler.kill_restore | public function kill_restore()
{
CCCookie::delete( $this->config->get( 'restore.id_cookie' ) );
CCCookie::delete( $this->config->get( 'restore.token_cookie' ) );
} | php | public function kill_restore()
{
CCCookie::delete( $this->config->get( 'restore.id_cookie' ) );
CCCookie::delete( $this->config->get( 'restore.token_cookie' ) );
} | [
"public",
"function",
"kill_restore",
"(",
")",
"{",
"CCCookie",
"::",
"delete",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'restore.id_cookie'",
")",
")",
";",
"CCCookie",
"::",
"delete",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'restore.token_cookie'",
")",
")",
";",
"}"
]
| Kill the restore keys
@return void | [
"Kill",
"the",
"restore",
"keys"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L266-L270 |
17,085 | ClanCats/Core | src/bundles/Auth/Handler.php | Handler.restore_key | public function restore_key( $user )
{
return \CCStr::hash( $user->password.'@'.$user->{$this->config->user_key}.'%'.\CCIn::client()->agent );
} | php | public function restore_key( $user )
{
return \CCStr::hash( $user->password.'@'.$user->{$this->config->user_key}.'%'.\CCIn::client()->agent );
} | [
"public",
"function",
"restore_key",
"(",
"$",
"user",
")",
"{",
"return",
"\\",
"CCStr",
"::",
"hash",
"(",
"$",
"user",
"->",
"password",
".",
"'@'",
".",
"$",
"user",
"->",
"{",
"$",
"this",
"->",
"config",
"->",
"user_key",
"}",
".",
"'%'",
".",
"\\",
"CCIn",
"::",
"client",
"(",
")",
"->",
"agent",
")",
";",
"}"
]
| generate the current restore key
@param User $user
@return string | [
"generate",
"the",
"current",
"restore",
"key"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L298-L301 |
17,086 | ClanCats/Core | src/bundles/Auth/Handler.php | Handler.login | public function login()
{
return $this->select_logins()
->where( 'restore_id', $this->user->{$this->config->user_key} )
->where( 'restore_token', $this->restore_key( $this->user ) )
->limit( 1 )
->run();
} | php | public function login()
{
return $this->select_logins()
->where( 'restore_id', $this->user->{$this->config->user_key} )
->where( 'restore_token', $this->restore_key( $this->user ) )
->limit( 1 )
->run();
} | [
"public",
"function",
"login",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"select_logins",
"(",
")",
"->",
"where",
"(",
"'restore_id'",
",",
"$",
"this",
"->",
"user",
"->",
"{",
"$",
"this",
"->",
"config",
"->",
"user_key",
"}",
")",
"->",
"where",
"(",
"'restore_token'",
",",
"$",
"this",
"->",
"restore_key",
"(",
"$",
"this",
"->",
"user",
")",
")",
"->",
"limit",
"(",
"1",
")",
"->",
"run",
"(",
")",
";",
"}"
]
| Get the current login of the user
@return stdObject|null | [
"Get",
"the",
"current",
"login",
"of",
"the",
"user"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L322-L329 |
17,087 | ClanCats/Core | src/bundles/Auth/Handler.php | Handler.validate | public function validate( $identifier, $password )
{
$user = null;
$user_model = $this->config->user_model;
foreach( $this->config->identifiers as $property )
{
if ( $user = $user_model::find( $property, $identifier ) )
{
break;
}
}
// when could not find a user matching the identifiers return false
if ( !$user )
{
return false;
}
// in case the user has no password set always return false
// you might implement a oauth login so you dont need to set a
// password but this makes sure that validating fails the password fails
if ( empty( $user->password ) )
{
return false;
}
// when the passwords match return the user object
if ( \CCStr::verify_hash( $password, $user->password ))
{
return $user;
}
// otherwise return false
return false;
} | php | public function validate( $identifier, $password )
{
$user = null;
$user_model = $this->config->user_model;
foreach( $this->config->identifiers as $property )
{
if ( $user = $user_model::find( $property, $identifier ) )
{
break;
}
}
// when could not find a user matching the identifiers return false
if ( !$user )
{
return false;
}
// in case the user has no password set always return false
// you might implement a oauth login so you dont need to set a
// password but this makes sure that validating fails the password fails
if ( empty( $user->password ) )
{
return false;
}
// when the passwords match return the user object
if ( \CCStr::verify_hash( $password, $user->password ))
{
return $user;
}
// otherwise return false
return false;
} | [
"public",
"function",
"validate",
"(",
"$",
"identifier",
",",
"$",
"password",
")",
"{",
"$",
"user",
"=",
"null",
";",
"$",
"user_model",
"=",
"$",
"this",
"->",
"config",
"->",
"user_model",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"identifiers",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"user",
"=",
"$",
"user_model",
"::",
"find",
"(",
"$",
"property",
",",
"$",
"identifier",
")",
")",
"{",
"break",
";",
"}",
"}",
"// when could not find a user matching the identifiers return false",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"return",
"false",
";",
"}",
"// in case the user has no password set always return false",
"// you might implement a oauth login so you dont need to set a ",
"// password but this makes sure that validating fails the password fails",
"if",
"(",
"empty",
"(",
"$",
"user",
"->",
"password",
")",
")",
"{",
"return",
"false",
";",
"}",
"// when the passwords match return the user object",
"if",
"(",
"\\",
"CCStr",
"::",
"verify_hash",
"(",
"$",
"password",
",",
"$",
"user",
"->",
"password",
")",
")",
"{",
"return",
"$",
"user",
";",
"}",
"// otherwise return false",
"return",
"false",
";",
"}"
]
| Validate an identifier with the password
In other words is the login correct?
@param string $identifier
@param string $password
@return mixed false on failure, user object on success | [
"Validate",
"an",
"identifier",
"with",
"the",
"password",
"In",
"other",
"words",
"is",
"the",
"login",
"correct?"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L339-L374 |
17,088 | ClanCats/Core | src/bundles/Auth/Handler.php | Handler.sign_in | public function sign_in( \Auth\User $user, $keep_login = true )
{
// set the session key so the session knows we are logged in
$this->session->set( $this->config->session_key, $user->{$this->config->user_key} );
// update the current user object
$this->user = $user;
// update the last login timestamp
$this->user->last_login = time();
// pass the user trough the events to allow modifications
// of the user object at sign in
$this->user = \CCEvent::pass( 'auth.sign_in', $this->user );
// save the user object to the database
$this->user->save();
// set the restore keys to keep the login
// after the session ends
if ( $keep_login )
{
$restore_id_cookie = $this->config->get( 'restore.id_cookie' );
$restore_token_cookie = $this->config->get( 'restore.token_cookie' );
$restore_lifetime = $this->config->get( 'restore.lifetime' );
$restore_id = $this->session->get( $this->config->session_key );
$restore_token = $this->restore_key( $this->user );
CCCookie::set( $restore_id_cookie, $restore_id, $restore_lifetime );
CCCookie::set( $restore_token_cookie, $restore_token, $restore_lifetime );
// try to get the current login
$login = $this->select_logins()
->where( 'restore_id', $restore_id )
->where( 'restore_token', $restore_token );
// prepare the login data
$login_data = array(
'restore_id' => $restore_id,
'restore_token' => $restore_token,
'last_login' => time(),
'client_agent' => \CCIn::client()->agent,
);
// pass the login data trough the events
$login_data = \CCEvent::pass( 'auth.store_login', $login_data );
// if there is no such login create a new one
if ( !$login->run() )
{
\DB::insert( $this->config->get( 'logins.table' ), $login_data )
->run( $this->config->get( 'logins.handler' ) );
}
else
{
\DB::update( $this->config->get( 'logins.table' ), $login_data )
->where( 'restore_id', $restore_id )
->where( 'restore_token', $restore_token )
->run( $this->config->get( 'logins.handler' ) );
}
}
// and finally we are authenticated
return $this->authenticated = true;
} | php | public function sign_in( \Auth\User $user, $keep_login = true )
{
// set the session key so the session knows we are logged in
$this->session->set( $this->config->session_key, $user->{$this->config->user_key} );
// update the current user object
$this->user = $user;
// update the last login timestamp
$this->user->last_login = time();
// pass the user trough the events to allow modifications
// of the user object at sign in
$this->user = \CCEvent::pass( 'auth.sign_in', $this->user );
// save the user object to the database
$this->user->save();
// set the restore keys to keep the login
// after the session ends
if ( $keep_login )
{
$restore_id_cookie = $this->config->get( 'restore.id_cookie' );
$restore_token_cookie = $this->config->get( 'restore.token_cookie' );
$restore_lifetime = $this->config->get( 'restore.lifetime' );
$restore_id = $this->session->get( $this->config->session_key );
$restore_token = $this->restore_key( $this->user );
CCCookie::set( $restore_id_cookie, $restore_id, $restore_lifetime );
CCCookie::set( $restore_token_cookie, $restore_token, $restore_lifetime );
// try to get the current login
$login = $this->select_logins()
->where( 'restore_id', $restore_id )
->where( 'restore_token', $restore_token );
// prepare the login data
$login_data = array(
'restore_id' => $restore_id,
'restore_token' => $restore_token,
'last_login' => time(),
'client_agent' => \CCIn::client()->agent,
);
// pass the login data trough the events
$login_data = \CCEvent::pass( 'auth.store_login', $login_data );
// if there is no such login create a new one
if ( !$login->run() )
{
\DB::insert( $this->config->get( 'logins.table' ), $login_data )
->run( $this->config->get( 'logins.handler' ) );
}
else
{
\DB::update( $this->config->get( 'logins.table' ), $login_data )
->where( 'restore_id', $restore_id )
->where( 'restore_token', $restore_token )
->run( $this->config->get( 'logins.handler' ) );
}
}
// and finally we are authenticated
return $this->authenticated = true;
} | [
"public",
"function",
"sign_in",
"(",
"\\",
"Auth",
"\\",
"User",
"$",
"user",
",",
"$",
"keep_login",
"=",
"true",
")",
"{",
"// set the session key so the session knows we are logged in",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"$",
"this",
"->",
"config",
"->",
"session_key",
",",
"$",
"user",
"->",
"{",
"$",
"this",
"->",
"config",
"->",
"user_key",
"}",
")",
";",
"// update the current user object",
"$",
"this",
"->",
"user",
"=",
"$",
"user",
";",
"// update the last login timestamp",
"$",
"this",
"->",
"user",
"->",
"last_login",
"=",
"time",
"(",
")",
";",
"// pass the user trough the events to allow modifications",
"// of the user object at sign in",
"$",
"this",
"->",
"user",
"=",
"\\",
"CCEvent",
"::",
"pass",
"(",
"'auth.sign_in'",
",",
"$",
"this",
"->",
"user",
")",
";",
"// save the user object to the database ",
"$",
"this",
"->",
"user",
"->",
"save",
"(",
")",
";",
"// set the restore keys to keep the login",
"// after the session ends",
"if",
"(",
"$",
"keep_login",
")",
"{",
"$",
"restore_id_cookie",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'restore.id_cookie'",
")",
";",
"$",
"restore_token_cookie",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'restore.token_cookie'",
")",
";",
"$",
"restore_lifetime",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'restore.lifetime'",
")",
";",
"$",
"restore_id",
"=",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"$",
"this",
"->",
"config",
"->",
"session_key",
")",
";",
"$",
"restore_token",
"=",
"$",
"this",
"->",
"restore_key",
"(",
"$",
"this",
"->",
"user",
")",
";",
"CCCookie",
"::",
"set",
"(",
"$",
"restore_id_cookie",
",",
"$",
"restore_id",
",",
"$",
"restore_lifetime",
")",
";",
"CCCookie",
"::",
"set",
"(",
"$",
"restore_token_cookie",
",",
"$",
"restore_token",
",",
"$",
"restore_lifetime",
")",
";",
"// try to get the current login",
"$",
"login",
"=",
"$",
"this",
"->",
"select_logins",
"(",
")",
"->",
"where",
"(",
"'restore_id'",
",",
"$",
"restore_id",
")",
"->",
"where",
"(",
"'restore_token'",
",",
"$",
"restore_token",
")",
";",
"// prepare the login data",
"$",
"login_data",
"=",
"array",
"(",
"'restore_id'",
"=>",
"$",
"restore_id",
",",
"'restore_token'",
"=>",
"$",
"restore_token",
",",
"'last_login'",
"=>",
"time",
"(",
")",
",",
"'client_agent'",
"=>",
"\\",
"CCIn",
"::",
"client",
"(",
")",
"->",
"agent",
",",
")",
";",
"// pass the login data trough the events",
"$",
"login_data",
"=",
"\\",
"CCEvent",
"::",
"pass",
"(",
"'auth.store_login'",
",",
"$",
"login_data",
")",
";",
"// if there is no such login create a new one",
"if",
"(",
"!",
"$",
"login",
"->",
"run",
"(",
")",
")",
"{",
"\\",
"DB",
"::",
"insert",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'logins.table'",
")",
",",
"$",
"login_data",
")",
"->",
"run",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'logins.handler'",
")",
")",
";",
"}",
"else",
"{",
"\\",
"DB",
"::",
"update",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'logins.table'",
")",
",",
"$",
"login_data",
")",
"->",
"where",
"(",
"'restore_id'",
",",
"$",
"restore_id",
")",
"->",
"where",
"(",
"'restore_token'",
",",
"$",
"restore_token",
")",
"->",
"run",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'logins.handler'",
")",
")",
";",
"}",
"}",
"// and finally we are authenticated",
"return",
"$",
"this",
"->",
"authenticated",
"=",
"true",
";",
"}"
]
| Sign the user and optinal also set the resore keys
@param Auth\User $user
@param bool $keep_login
@return bool | [
"Sign",
"the",
"user",
"and",
"optinal",
"also",
"set",
"the",
"resore",
"keys"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L383-L449 |
17,089 | ClanCats/Core | src/bundles/Auth/Handler.php | Handler.sign_out | public function sign_out() {
if ( !$this->authenticated )
{
return false;
}
// remove the restore login
\DB::delete( $this->config->get( 'logins.table' ) )
->where( 'restore_token', $this->restore_key( $this->user ) )
->run();
// logout the user
$this->session->delete( $this->config->session_key );
// pass the user object through all user hooks
$this->user = \CCEvent::pass( 'auth.sign_out', $this->user );
$this->user->save();
$user_model = $this->config->user_model;
// create new empty user
$this->user = new $user_model;
return $this->authenticated = false;
} | php | public function sign_out() {
if ( !$this->authenticated )
{
return false;
}
// remove the restore login
\DB::delete( $this->config->get( 'logins.table' ) )
->where( 'restore_token', $this->restore_key( $this->user ) )
->run();
// logout the user
$this->session->delete( $this->config->session_key );
// pass the user object through all user hooks
$this->user = \CCEvent::pass( 'auth.sign_out', $this->user );
$this->user->save();
$user_model = $this->config->user_model;
// create new empty user
$this->user = new $user_model;
return $this->authenticated = false;
} | [
"public",
"function",
"sign_out",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"authenticated",
")",
"{",
"return",
"false",
";",
"}",
"// remove the restore login",
"\\",
"DB",
"::",
"delete",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'logins.table'",
")",
")",
"->",
"where",
"(",
"'restore_token'",
",",
"$",
"this",
"->",
"restore_key",
"(",
"$",
"this",
"->",
"user",
")",
")",
"->",
"run",
"(",
")",
";",
"// logout the user",
"$",
"this",
"->",
"session",
"->",
"delete",
"(",
"$",
"this",
"->",
"config",
"->",
"session_key",
")",
";",
"// pass the user object through all user hooks",
"$",
"this",
"->",
"user",
"=",
"\\",
"CCEvent",
"::",
"pass",
"(",
"'auth.sign_out'",
",",
"$",
"this",
"->",
"user",
")",
";",
"$",
"this",
"->",
"user",
"->",
"save",
"(",
")",
";",
"$",
"user_model",
"=",
"$",
"this",
"->",
"config",
"->",
"user_model",
";",
"// create new empty user",
"$",
"this",
"->",
"user",
"=",
"new",
"$",
"user_model",
";",
"return",
"$",
"this",
"->",
"authenticated",
"=",
"false",
";",
"}"
]
| Sign a user out
@param id $user_id
@param string $name
@return false | [
"Sign",
"a",
"user",
"out"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L458-L483 |
17,090 | 2amigos/yiifoundation | widgets/Reveal.php | Reveal.renderToggleButton | public function renderToggleButton()
{
if ($this->toggleButton !== null) {
$tag = ArrayHelper::removeValue($this->toggleButton, 'tag', 'button');
$label = ArrayHelper::removeValue($this->toggleButton, 'label', 'Show');
if ($tag === 'button' && !isset($this->toggleButton['type'])) {
$this->toggleButton['type'] = 'button';
}
$this->toggleButton['data-reveal-id'] = $this->getId();
return \CHtml::tag($tag, $this->toggleButton, $label);
} else {
return null;
}
} | php | public function renderToggleButton()
{
if ($this->toggleButton !== null) {
$tag = ArrayHelper::removeValue($this->toggleButton, 'tag', 'button');
$label = ArrayHelper::removeValue($this->toggleButton, 'label', 'Show');
if ($tag === 'button' && !isset($this->toggleButton['type'])) {
$this->toggleButton['type'] = 'button';
}
$this->toggleButton['data-reveal-id'] = $this->getId();
return \CHtml::tag($tag, $this->toggleButton, $label);
} else {
return null;
}
} | [
"public",
"function",
"renderToggleButton",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"toggleButton",
"!==",
"null",
")",
"{",
"$",
"tag",
"=",
"ArrayHelper",
"::",
"removeValue",
"(",
"$",
"this",
"->",
"toggleButton",
",",
"'tag'",
",",
"'button'",
")",
";",
"$",
"label",
"=",
"ArrayHelper",
"::",
"removeValue",
"(",
"$",
"this",
"->",
"toggleButton",
",",
"'label'",
",",
"'Show'",
")",
";",
"if",
"(",
"$",
"tag",
"===",
"'button'",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"toggleButton",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"toggleButton",
"[",
"'type'",
"]",
"=",
"'button'",
";",
"}",
"$",
"this",
"->",
"toggleButton",
"[",
"'data-reveal-id'",
"]",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"$",
"tag",
",",
"$",
"this",
"->",
"toggleButton",
",",
"$",
"label",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
]
| Renders the toggle button
@return null|string the rendering result | [
"Renders",
"the",
"toggle",
"button"
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Reveal.php#L150-L163 |
17,091 | 2amigos/yiifoundation | widgets/Reveal.php | Reveal.renderCloseButton | protected function renderCloseButton()
{
if ($this->closeButton !== null) {
$tag = ArrayHelper::removeValue($this->closeButton, 'tag', 'a');
$label = ArrayHelper::removeValue($this->closeButton, 'label', '×');
if ($tag === 'button' && !isset($this->closeButton['type'])) {
$this->closeButton['type'] = 'button';
}
Html::addCssClass($this->closeButton, Enum::DIALOG_CLOSE);
return \CHtml::tag($tag, $this->closeButton, $label);
} else {
return null;
}
} | php | protected function renderCloseButton()
{
if ($this->closeButton !== null) {
$tag = ArrayHelper::removeValue($this->closeButton, 'tag', 'a');
$label = ArrayHelper::removeValue($this->closeButton, 'label', '×');
if ($tag === 'button' && !isset($this->closeButton['type'])) {
$this->closeButton['type'] = 'button';
}
Html::addCssClass($this->closeButton, Enum::DIALOG_CLOSE);
return \CHtml::tag($tag, $this->closeButton, $label);
} else {
return null;
}
} | [
"protected",
"function",
"renderCloseButton",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"closeButton",
"!==",
"null",
")",
"{",
"$",
"tag",
"=",
"ArrayHelper",
"::",
"removeValue",
"(",
"$",
"this",
"->",
"closeButton",
",",
"'tag'",
",",
"'a'",
")",
";",
"$",
"label",
"=",
"ArrayHelper",
"::",
"removeValue",
"(",
"$",
"this",
"->",
"closeButton",
",",
"'label'",
",",
"'×'",
")",
";",
"if",
"(",
"$",
"tag",
"===",
"'button'",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"closeButton",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"closeButton",
"[",
"'type'",
"]",
"=",
"'button'",
";",
"}",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"closeButton",
",",
"Enum",
"::",
"DIALOG_CLOSE",
")",
";",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"$",
"tag",
",",
"$",
"this",
"->",
"closeButton",
",",
"$",
"label",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
]
| Renders the close button.
@return string the rendering result | [
"Renders",
"the",
"close",
"button",
"."
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Reveal.php#L169-L182 |
17,092 | npbtrac/yii2-enpii-cms | libs/override/db/NpActiveRecord.php | NpActiveRecord.init | public function init()
{
parent::init();
$this->datetimeFormat = (empty(Yii::$app->params['site']->datetimeFormat)) ? $this->datetimeFormat : Yii::$app->params['site']->datetimeFormat;
$this->timezone = (empty(Yii::$app->params['site']->timezone)) ? $this->timezone : Yii::$app->params['site']->timezone;
} | php | public function init()
{
parent::init();
$this->datetimeFormat = (empty(Yii::$app->params['site']->datetimeFormat)) ? $this->datetimeFormat : Yii::$app->params['site']->datetimeFormat;
$this->timezone = (empty(Yii::$app->params['site']->timezone)) ? $this->timezone : Yii::$app->params['site']->timezone;
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"$",
"this",
"->",
"datetimeFormat",
"=",
"(",
"empty",
"(",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'site'",
"]",
"->",
"datetimeFormat",
")",
")",
"?",
"$",
"this",
"->",
"datetimeFormat",
":",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'site'",
"]",
"->",
"datetimeFormat",
";",
"$",
"this",
"->",
"timezone",
"=",
"(",
"empty",
"(",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'site'",
"]",
"->",
"timezone",
")",
")",
"?",
"$",
"this",
"->",
"timezone",
":",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'site'",
"]",
"->",
"timezone",
";",
"}"
]
| Set default timezone and datetime format for model | [
"Set",
"default",
"timezone",
"and",
"datetime",
"format",
"for",
"model"
]
| 3495e697509a57a573983f552629ff9f707a63b9 | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L24-L30 |
17,093 | npbtrac/yii2-enpii-cms | libs/override/db/NpActiveRecord.php | NpActiveRecord.getDisplayDateTime | public function getDisplayDateTime($input, $format = null, $timezone = null)
{
return \enpii\enpiiCms\helpers\DateTimeHelper::fromDbFormat($input,
($format === null ? $this->datetimeFormat : $format),
($timezone === null ? $this->timezone : $timezone));
} | php | public function getDisplayDateTime($input, $format = null, $timezone = null)
{
return \enpii\enpiiCms\helpers\DateTimeHelper::fromDbFormat($input,
($format === null ? $this->datetimeFormat : $format),
($timezone === null ? $this->timezone : $timezone));
} | [
"public",
"function",
"getDisplayDateTime",
"(",
"$",
"input",
",",
"$",
"format",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"return",
"\\",
"enpii",
"\\",
"enpiiCms",
"\\",
"helpers",
"\\",
"DateTimeHelper",
"::",
"fromDbFormat",
"(",
"$",
"input",
",",
"(",
"$",
"format",
"===",
"null",
"?",
"$",
"this",
"->",
"datetimeFormat",
":",
"$",
"format",
")",
",",
"(",
"$",
"timezone",
"===",
"null",
"?",
"$",
"this",
"->",
"timezone",
":",
"$",
"timezone",
")",
")",
";",
"}"
]
| Display datetime from the result retrieve from database (stored by GMT datetime
@param $input
@param null $format
@param null $timezone
@return bool|string | [
"Display",
"datetime",
"from",
"the",
"result",
"retrieve",
"from",
"database",
"(",
"stored",
"by",
"GMT",
"datetime"
]
| 3495e697509a57a573983f552629ff9f707a63b9 | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L54-L59 |
17,094 | npbtrac/yii2-enpii-cms | libs/override/db/NpActiveRecord.php | NpActiveRecord.getCreatedAt | public function getCreatedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->created_at, $format, $timezone);
} | php | public function getCreatedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->created_at, $format, $timezone);
} | [
"public",
"function",
"getCreatedAt",
"(",
"$",
"format",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getDisplayDateTime",
"(",
"$",
"this",
"->",
"created_at",
",",
"$",
"format",
",",
"$",
"timezone",
")",
";",
"}"
]
| Display create_at datetime
@param null $format
@param null $timezone
@return bool|string | [
"Display",
"create_at",
"datetime"
]
| 3495e697509a57a573983f552629ff9f707a63b9 | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L67-L70 |
17,095 | npbtrac/yii2-enpii-cms | libs/override/db/NpActiveRecord.php | NpActiveRecord.getUpdatedAt | public function getUpdatedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->updated_at, $format, $timezone);
} | php | public function getUpdatedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->updated_at, $format, $timezone);
} | [
"public",
"function",
"getUpdatedAt",
"(",
"$",
"format",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getDisplayDateTime",
"(",
"$",
"this",
"->",
"updated_at",
",",
"$",
"format",
",",
"$",
"timezone",
")",
";",
"}"
]
| Display updated_at datetime
@param null $format
@param null $timezone
@return bool|string | [
"Display",
"updated_at",
"datetime"
]
| 3495e697509a57a573983f552629ff9f707a63b9 | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L78-L81 |
17,096 | npbtrac/yii2-enpii-cms | libs/override/db/NpActiveRecord.php | NpActiveRecord.getPublishedAt | public function getPublishedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->published_at, $format, $timezone);
} | php | public function getPublishedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->published_at, $format, $timezone);
} | [
"public",
"function",
"getPublishedAt",
"(",
"$",
"format",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getDisplayDateTime",
"(",
"$",
"this",
"->",
"published_at",
",",
"$",
"format",
",",
"$",
"timezone",
")",
";",
"}"
]
| Display published_at datetime
@param null $format
@param null $timezone
@return bool|string | [
"Display",
"published_at",
"datetime"
]
| 3495e697509a57a573983f552629ff9f707a63b9 | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L89-L92 |
17,097 | npbtrac/yii2-enpii-cms | libs/override/db/NpActiveRecord.php | NpActiveRecord.getUploadTmpPath | public function getUploadTmpPath()
{
$path = Yii::getAlias('@root' . '/' . Yii::$app->params['uploads']['folderName'] . '/' . 'tmp');
if (!file_exists($path)) {
FileHelper::createDirectory($path, 0777);
}
return $path;
} | php | public function getUploadTmpPath()
{
$path = Yii::getAlias('@root' . '/' . Yii::$app->params['uploads']['folderName'] . '/' . 'tmp');
if (!file_exists($path)) {
FileHelper::createDirectory($path, 0777);
}
return $path;
} | [
"public",
"function",
"getUploadTmpPath",
"(",
")",
"{",
"$",
"path",
"=",
"Yii",
"::",
"getAlias",
"(",
"'@root'",
".",
"'/'",
".",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'uploads'",
"]",
"[",
"'folderName'",
"]",
".",
"'/'",
".",
"'tmp'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"FileHelper",
"::",
"createDirectory",
"(",
"$",
"path",
",",
"0777",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
]
| Temporary upload path
@return bool|string | [
"Temporary",
"upload",
"path"
]
| 3495e697509a57a573983f552629ff9f707a63b9 | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L98-L105 |
17,098 | steeffeen/FancyManiaLinks | FML/Script/Features/Toggle.php | Toggle.setTogglingControl | public function setTogglingControl(Control $control)
{
$control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
}
$this->togglingControl = $control;
return $this;
} | php | public function setTogglingControl(Control $control)
{
$control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
}
$this->togglingControl = $control;
return $this;
} | [
"public",
"function",
"setTogglingControl",
"(",
"Control",
"$",
"control",
")",
"{",
"$",
"control",
"->",
"checkId",
"(",
")",
";",
"if",
"(",
"$",
"control",
"instanceof",
"Scriptable",
")",
"{",
"$",
"control",
"->",
"setScriptEvents",
"(",
"true",
")",
";",
"}",
"$",
"this",
"->",
"togglingControl",
"=",
"$",
"control",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the toggling Control
@api
@param Control $control Toggling Control
@return static | [
"Set",
"the",
"toggling",
"Control"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Toggle.php#L98-L106 |
17,099 | steeffeen/FancyManiaLinks | FML/Script/Features/Toggle.php | Toggle.setOnlyShow | public function setOnlyShow($onlyShow)
{
$this->onlyShow = (bool)$onlyShow;
if ($this->onlyShow) {
$this->onlyHide = null;
}
return $this;
} | php | public function setOnlyShow($onlyShow)
{
$this->onlyShow = (bool)$onlyShow;
if ($this->onlyShow) {
$this->onlyHide = null;
}
return $this;
} | [
"public",
"function",
"setOnlyShow",
"(",
"$",
"onlyShow",
")",
"{",
"$",
"this",
"->",
"onlyShow",
"=",
"(",
"bool",
")",
"$",
"onlyShow",
";",
"if",
"(",
"$",
"this",
"->",
"onlyShow",
")",
"{",
"$",
"this",
"->",
"onlyHide",
"=",
"null",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set Show Only
@api
@param bool $onlyShow If it should only show the Control but not toggle
@return static | [
"Set",
"Show",
"Only"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Toggle.php#L175-L182 |
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.