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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
22,300
|
qlake/framework
|
src/Qlake/Support/Autoload.php
|
Autoload.load
|
public static function load($class)
{
$file = static::normalizePath($class);
if (file_exists($path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$file))
{
require $path;
return true;
}
foreach (static::$directories as $directory)
{
if (file_exists($path = $directory.DIRECTORY_SEPARATOR.$file))
{
require $path;
return true;
}
}
if (static::$aliases[$class])
{
class_alias(static::$aliases[$class], $class);
return true;
}
return false;
}
|
php
|
public static function load($class)
{
$file = static::normalizePath($class);
if (file_exists($path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$file))
{
require $path;
return true;
}
foreach (static::$directories as $directory)
{
if (file_exists($path = $directory.DIRECTORY_SEPARATOR.$file))
{
require $path;
return true;
}
}
if (static::$aliases[$class])
{
class_alias(static::$aliases[$class], $class);
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"load",
"(",
"$",
"class",
")",
"{",
"$",
"file",
"=",
"static",
"::",
"normalizePath",
"(",
"$",
"class",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
"=",
"__DIR__",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
")",
")",
"{",
"require",
"$",
"path",
";",
"return",
"true",
";",
"}",
"foreach",
"(",
"static",
"::",
"$",
"directories",
"as",
"$",
"directory",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
"=",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
")",
")",
"{",
"require",
"$",
"path",
";",
"return",
"true",
";",
"}",
"}",
"if",
"(",
"static",
"::",
"$",
"aliases",
"[",
"$",
"class",
"]",
")",
"{",
"class_alias",
"(",
"static",
"::",
"$",
"aliases",
"[",
"$",
"class",
"]",
",",
"$",
"class",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Search and Include a Class by class name like Qlake\Router\Route.
@param string $class Like Qlake\Router\Route
@return bool
|
[
"Search",
"and",
"Include",
"a",
"Class",
"by",
"class",
"name",
"like",
"Qlake",
"\\",
"Router",
"\\",
"Route",
"."
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Support/Autoload.php#L41-L70
|
22,301
|
surebert/surebert-framework
|
src/sb/Web/Captcha.php
|
Captcha.createWord
|
private function createWord()
{
$this->word ='';
for($x=0;$x<rand(5,7);$x++){
$this->word .=$this->allowed_characters[ rand(0, strlen($this->allowed_characters)-1)];
}
return $this->word;
}
|
php
|
private function createWord()
{
$this->word ='';
for($x=0;$x<rand(5,7);$x++){
$this->word .=$this->allowed_characters[ rand(0, strlen($this->allowed_characters)-1)];
}
return $this->word;
}
|
[
"private",
"function",
"createWord",
"(",
")",
"{",
"$",
"this",
"->",
"word",
"=",
"''",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"rand",
"(",
"5",
",",
"7",
")",
";",
"$",
"x",
"++",
")",
"{",
"$",
"this",
"->",
"word",
".=",
"$",
"this",
"->",
"allowed_characters",
"[",
"rand",
"(",
"0",
",",
"strlen",
"(",
"$",
"this",
"->",
"allowed_characters",
")",
"-",
"1",
")",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"word",
";",
"}"
] |
Creates the word from the allowed characters
@return string
|
[
"Creates",
"the",
"word",
"from",
"the",
"allowed",
"characters"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Web/Captcha.php#L107-L116
|
22,302
|
surebert/surebert-framework
|
src/sb/Web/Captcha.php
|
Captcha.addInterference
|
public function addInterference()
{
for($i=0;$i<20;$i++){
$radius = rand(0,150);
imageellipse($this->image, rand(0,200), rand(0,200), $radius, $radius, $this->ink_color);
}
}
|
php
|
public function addInterference()
{
for($i=0;$i<20;$i++){
$radius = rand(0,150);
imageellipse($this->image, rand(0,200), rand(0,200), $radius, $radius, $this->ink_color);
}
}
|
[
"public",
"function",
"addInterference",
"(",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"20",
";",
"$",
"i",
"++",
")",
"{",
"$",
"radius",
"=",
"rand",
"(",
"0",
",",
"150",
")",
";",
"imageellipse",
"(",
"$",
"this",
"->",
"image",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"$",
"radius",
",",
"$",
"radius",
",",
"$",
"this",
"->",
"ink_color",
")",
";",
"}",
"}"
] |
Adds interference as circles int he backgroun the make it more difficult to parse. This is optional
|
[
"Adds",
"interference",
"as",
"circles",
"int",
"he",
"backgroun",
"the",
"make",
"it",
"more",
"difficult",
"to",
"parse",
".",
"This",
"is",
"optional"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Web/Captcha.php#L122-L129
|
22,303
|
surebert/surebert-framework
|
src/sb/Web/Captcha.php
|
Captcha.draw
|
public function draw($filters=Array())
{
$word = $this->createWord();
for($j=0;$j<5;$j++){
if(file_exists($this->font)){
imagettftext($this->image, rand(8,18), rand(0,30), rand(0,200), rand(0,200), $this->ink_color, $this->font, 'not the code');
} else {
imagestring($this->image, rand(1,3), rand(0,200), rand(0,200), 'not the word', $this->ink_color );
}
}
if(file_exists($this->font)){
imagettftext($this->image, 30, rand(-45,45), rand(10,80), rand(80,120), $this->ink_color, $this->font, $this->word);
} else {
imagestring($this->image, 5, rand(10,80), rand(80,120), $this->word, $this->ink_color );
}
foreach($filters as $filter){
imagefilter($this->image, $filter);
}
return $this->image;
}
|
php
|
public function draw($filters=Array())
{
$word = $this->createWord();
for($j=0;$j<5;$j++){
if(file_exists($this->font)){
imagettftext($this->image, rand(8,18), rand(0,30), rand(0,200), rand(0,200), $this->ink_color, $this->font, 'not the code');
} else {
imagestring($this->image, rand(1,3), rand(0,200), rand(0,200), 'not the word', $this->ink_color );
}
}
if(file_exists($this->font)){
imagettftext($this->image, 30, rand(-45,45), rand(10,80), rand(80,120), $this->ink_color, $this->font, $this->word);
} else {
imagestring($this->image, 5, rand(10,80), rand(80,120), $this->word, $this->ink_color );
}
foreach($filters as $filter){
imagefilter($this->image, $filter);
}
return $this->image;
}
|
[
"public",
"function",
"draw",
"(",
"$",
"filters",
"=",
"Array",
"(",
")",
")",
"{",
"$",
"word",
"=",
"$",
"this",
"->",
"createWord",
"(",
")",
";",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"5",
";",
"$",
"j",
"++",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"font",
")",
")",
"{",
"imagettftext",
"(",
"$",
"this",
"->",
"image",
",",
"rand",
"(",
"8",
",",
"18",
")",
",",
"rand",
"(",
"0",
",",
"30",
")",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"$",
"this",
"->",
"ink_color",
",",
"$",
"this",
"->",
"font",
",",
"'not the code'",
")",
";",
"}",
"else",
"{",
"imagestring",
"(",
"$",
"this",
"->",
"image",
",",
"rand",
"(",
"1",
",",
"3",
")",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"'not the word'",
",",
"$",
"this",
"->",
"ink_color",
")",
";",
"}",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"font",
")",
")",
"{",
"imagettftext",
"(",
"$",
"this",
"->",
"image",
",",
"30",
",",
"rand",
"(",
"-",
"45",
",",
"45",
")",
",",
"rand",
"(",
"10",
",",
"80",
")",
",",
"rand",
"(",
"80",
",",
"120",
")",
",",
"$",
"this",
"->",
"ink_color",
",",
"$",
"this",
"->",
"font",
",",
"$",
"this",
"->",
"word",
")",
";",
"}",
"else",
"{",
"imagestring",
"(",
"$",
"this",
"->",
"image",
",",
"5",
",",
"rand",
"(",
"10",
",",
"80",
")",
",",
"rand",
"(",
"80",
",",
"120",
")",
",",
"$",
"this",
"->",
"word",
",",
"$",
"this",
"->",
"ink_color",
")",
";",
"}",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filter",
")",
"{",
"imagefilter",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"filter",
")",
";",
"}",
"return",
"$",
"this",
"->",
"image",
";",
"}"
] |
Draws the wor text on the image using the true type font specified. If no font is specified than
@param arary $filters AN array of GD filter constants to run on the image
@return resource THe image is returned and can be used with imagepng to display or export to file
|
[
"Draws",
"the",
"wor",
"text",
"on",
"the",
"image",
"using",
"the",
"true",
"type",
"font",
"specified",
".",
"If",
"no",
"font",
"is",
"specified",
"than"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Web/Captcha.php#L137-L164
|
22,304
|
hametuha/wpametu
|
src/WPametu/API/Controller.php
|
Controller.nonce_field
|
public function nonce_field($key = '_wpnonce', $referrer = false, $echo = true){
return wp_nonce_field($this->action, $key, $referrer, $echo);
}
|
php
|
public function nonce_field($key = '_wpnonce', $referrer = false, $echo = true){
return wp_nonce_field($this->action, $key, $referrer, $echo);
}
|
[
"public",
"function",
"nonce_field",
"(",
"$",
"key",
"=",
"'_wpnonce'",
",",
"$",
"referrer",
"=",
"false",
",",
"$",
"echo",
"=",
"true",
")",
"{",
"return",
"wp_nonce_field",
"(",
"$",
"this",
"->",
"action",
",",
"$",
"key",
",",
"$",
"referrer",
",",
"$",
"echo",
")",
";",
"}"
] |
Echo nonce field
@param string $key Default _wpnonce
@param bool $referrer Default false.
@param bool $echo Default true
@return string
|
[
"Echo",
"nonce",
"field"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Controller.php#L152-L154
|
22,305
|
hametuha/wpametu
|
src/WPametu/API/Controller.php
|
Controller.view
|
public static function view($slug, $name = '', array $args = []){
$class_name = get_called_class();
/** @var Controller $instance */
$instance = $class_name::get_instance();
$instance->lazy_scripts();
$instance->load_template($slug, $name, $args);
}
|
php
|
public static function view($slug, $name = '', array $args = []){
$class_name = get_called_class();
/** @var Controller $instance */
$instance = $class_name::get_instance();
$instance->lazy_scripts();
$instance->load_template($slug, $name, $args);
}
|
[
"public",
"static",
"function",
"view",
"(",
"$",
"slug",
",",
"$",
"name",
"=",
"''",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"class_name",
"=",
"get_called_class",
"(",
")",
";",
"/** @var Controller $instance */",
"$",
"instance",
"=",
"$",
"class_name",
"::",
"get_instance",
"(",
")",
";",
"$",
"instance",
"->",
"lazy_scripts",
"(",
")",
";",
"$",
"instance",
"->",
"load_template",
"(",
"$",
"slug",
",",
"$",
"name",
",",
"$",
"args",
")",
";",
"}"
] |
Load view template with arguments
@param string $slug
@param string $name
@param array $args
|
[
"Load",
"view",
"template",
"with",
"arguments"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Controller.php#L193-L199
|
22,306
|
ekuiter/feature-php
|
FeaturePhp/Generator/ExtendGenerator.php
|
ExtendGenerator.getExtendableFile
|
private function getExtendableFile($specification) {
$target = $specification->getTarget();
if (!array_key_exists($target, $this->extendableFiles)) {
if (!$specification->mayCreate())
return null;
$this->extendableFiles[$target] = $this->getExtendableFileFromSpecification($specification);
$this->logFile->log(null, "added file \"{$specification->getTarget()}\"");
}
return $this->extendableFiles[$target];
}
|
php
|
private function getExtendableFile($specification) {
$target = $specification->getTarget();
if (!array_key_exists($target, $this->extendableFiles)) {
if (!$specification->mayCreate())
return null;
$this->extendableFiles[$target] = $this->getExtendableFileFromSpecification($specification);
$this->logFile->log(null, "added file \"{$specification->getTarget()}\"");
}
return $this->extendableFiles[$target];
}
|
[
"private",
"function",
"getExtendableFile",
"(",
"$",
"specification",
")",
"{",
"$",
"target",
"=",
"$",
"specification",
"->",
"getTarget",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"target",
",",
"$",
"this",
"->",
"extendableFiles",
")",
")",
"{",
"if",
"(",
"!",
"$",
"specification",
"->",
"mayCreate",
"(",
")",
")",
"return",
"null",
";",
"$",
"this",
"->",
"extendableFiles",
"[",
"$",
"target",
"]",
"=",
"$",
"this",
"->",
"getExtendableFileFromSpecification",
"(",
"$",
"specification",
")",
";",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"null",
",",
"\"added file \\\"{$specification->getTarget()}\\\"\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"extendableFiles",
"[",
"$",
"target",
"]",
";",
"}"
] |
Creates an extendable file from a specification.
If the extendable file was already created, returns the cached extendable file.
If the extendable file does not yet exist, create it if it may be created from
this specification.
@param \FeaturePhp\Specification\Specification $specification
@return \FeaturePhp\File\ExtendableFile
|
[
"Creates",
"an",
"extendable",
"file",
"from",
"a",
"specification",
".",
"If",
"the",
"extendable",
"file",
"was",
"already",
"created",
"returns",
"the",
"cached",
"extendable",
"file",
".",
"If",
"the",
"extendable",
"file",
"does",
"not",
"yet",
"exist",
"create",
"it",
"if",
"it",
"may",
"be",
"created",
"from",
"this",
"specification",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/ExtendGenerator.php#L41-L50
|
22,307
|
ekuiter/feature-php
|
FeaturePhp/Generator/ExtendGenerator.php
|
ExtendGenerator.generateFilesForArtifacts
|
private function generateFilesForArtifacts($artifacts, $fileSettingsGetter, $extend) {
foreach ($artifacts as $artifact) {
$settings = $artifact->getGeneratorSettings(static::getKey());
foreach (call_user_func(array($this, $fileSettingsGetter), $settings) as $file) {
$specification = $this->getSpecification($file, $settings, $artifact);
$extendableFile = $this->getExtendableFile($specification);
if ($extendableFile && $extend) {
$places = $extendableFile->extend($specification);
foreach ($places as $placePair) {
if (!is_array($placePair))
$placePair = array(new \FeaturePhp\Artifact\SettingsPlace($artifact), $placePair);
$this->tracingLinks[] = new fphp\Artifact\TracingLink(
static::getKey() === "template" ? "rule" : "chunk", $artifact, $placePair[0], $placePair[1]);
}
$this->logFile->log($artifact, "extended file \"{$specification->getTarget()}\"");
}
}
}
}
|
php
|
private function generateFilesForArtifacts($artifacts, $fileSettingsGetter, $extend) {
foreach ($artifacts as $artifact) {
$settings = $artifact->getGeneratorSettings(static::getKey());
foreach (call_user_func(array($this, $fileSettingsGetter), $settings) as $file) {
$specification = $this->getSpecification($file, $settings, $artifact);
$extendableFile = $this->getExtendableFile($specification);
if ($extendableFile && $extend) {
$places = $extendableFile->extend($specification);
foreach ($places as $placePair) {
if (!is_array($placePair))
$placePair = array(new \FeaturePhp\Artifact\SettingsPlace($artifact), $placePair);
$this->tracingLinks[] = new fphp\Artifact\TracingLink(
static::getKey() === "template" ? "rule" : "chunk", $artifact, $placePair[0], $placePair[1]);
}
$this->logFile->log($artifact, "extended file \"{$specification->getTarget()}\"");
}
}
}
}
|
[
"private",
"function",
"generateFilesForArtifacts",
"(",
"$",
"artifacts",
",",
"$",
"fileSettingsGetter",
",",
"$",
"extend",
")",
"{",
"foreach",
"(",
"$",
"artifacts",
"as",
"$",
"artifact",
")",
"{",
"$",
"settings",
"=",
"$",
"artifact",
"->",
"getGeneratorSettings",
"(",
"static",
"::",
"getKey",
"(",
")",
")",
";",
"foreach",
"(",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"fileSettingsGetter",
")",
",",
"$",
"settings",
")",
"as",
"$",
"file",
")",
"{",
"$",
"specification",
"=",
"$",
"this",
"->",
"getSpecification",
"(",
"$",
"file",
",",
"$",
"settings",
",",
"$",
"artifact",
")",
";",
"$",
"extendableFile",
"=",
"$",
"this",
"->",
"getExtendableFile",
"(",
"$",
"specification",
")",
";",
"if",
"(",
"$",
"extendableFile",
"&&",
"$",
"extend",
")",
"{",
"$",
"places",
"=",
"$",
"extendableFile",
"->",
"extend",
"(",
"$",
"specification",
")",
";",
"foreach",
"(",
"$",
"places",
"as",
"$",
"placePair",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"placePair",
")",
")",
"$",
"placePair",
"=",
"array",
"(",
"new",
"\\",
"FeaturePhp",
"\\",
"Artifact",
"\\",
"SettingsPlace",
"(",
"$",
"artifact",
")",
",",
"$",
"placePair",
")",
";",
"$",
"this",
"->",
"tracingLinks",
"[",
"]",
"=",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"TracingLink",
"(",
"static",
"::",
"getKey",
"(",
")",
"===",
"\"template\"",
"?",
"\"rule\"",
":",
"\"chunk\"",
",",
"$",
"artifact",
",",
"$",
"placePair",
"[",
"0",
"]",
",",
"$",
"placePair",
"[",
"1",
"]",
")",
";",
"}",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"$",
"artifact",
",",
"\"extended file \\\"{$specification->getTarget()}\\\"\"",
")",
";",
"}",
"}",
"}",
"}"
] |
Generates the extendable files for a set of artifacts and file settings.
@param \FeaturePhp\Artifact\Artifact[] $artifacts
@param callable $fileSettingsGetter
@param bool $extend
|
[
"Generates",
"the",
"extendable",
"files",
"for",
"a",
"set",
"of",
"artifacts",
"and",
"file",
"settings",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/ExtendGenerator.php#L58-L77
|
22,308
|
ekuiter/feature-php
|
FeaturePhp/Generator/ExtendGenerator.php
|
ExtendGenerator._generateFiles
|
protected function _generateFiles() {
$this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", false);
$this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", false);
$this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", true);
$this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", true);
foreach ($this->extendableFiles as $extendableFile)
$this->files[] = $extendableFile;
}
|
php
|
protected function _generateFiles() {
$this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", false);
$this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", false);
$this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", true);
$this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", true);
foreach ($this->extendableFiles as $extendableFile)
$this->files[] = $extendableFile;
}
|
[
"protected",
"function",
"_generateFiles",
"(",
")",
"{",
"$",
"this",
"->",
"generateFilesForArtifacts",
"(",
"$",
"this",
"->",
"selectedArtifacts",
",",
"\"getFileSettingsForSelected\"",
",",
"false",
")",
";",
"$",
"this",
"->",
"generateFilesForArtifacts",
"(",
"$",
"this",
"->",
"deselectedArtifacts",
",",
"\"getFileSettingsForDeselected\"",
",",
"false",
")",
";",
"$",
"this",
"->",
"generateFilesForArtifacts",
"(",
"$",
"this",
"->",
"selectedArtifacts",
",",
"\"getFileSettingsForSelected\"",
",",
"true",
")",
";",
"$",
"this",
"->",
"generateFilesForArtifacts",
"(",
"$",
"this",
"->",
"deselectedArtifacts",
",",
"\"getFileSettingsForDeselected\"",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"extendableFiles",
"as",
"$",
"extendableFile",
")",
"$",
"this",
"->",
"files",
"[",
"]",
"=",
"$",
"extendableFile",
";",
"}"
] |
Generates the extendable files.
|
[
"Generates",
"the",
"extendable",
"files",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/ExtendGenerator.php#L82-L91
|
22,309
|
zicht/z
|
src/Zicht/Tool/Packager/Node/Stub.php
|
Stub.compile
|
final public function compile(Buffer $buffer)
{
$buffer
->writeln("Phar::mapPhar('z.phar');")
->writeln("define('ZPREFIX', 'phar://z.phar/');")
->writeln("require_once 'phar://z.phar/vendor/autoload.php';")
;
$this->compileInitialization($buffer);
$buffer
->writeln('$app->run();')
->writeln('__HALT_COMPILER();')
;
}
|
php
|
final public function compile(Buffer $buffer)
{
$buffer
->writeln("Phar::mapPhar('z.phar');")
->writeln("define('ZPREFIX', 'phar://z.phar/');")
->writeln("require_once 'phar://z.phar/vendor/autoload.php';")
;
$this->compileInitialization($buffer);
$buffer
->writeln('$app->run();')
->writeln('__HALT_COMPILER();')
;
}
|
[
"final",
"public",
"function",
"compile",
"(",
"Buffer",
"$",
"buffer",
")",
"{",
"$",
"buffer",
"->",
"writeln",
"(",
"\"Phar::mapPhar('z.phar');\"",
")",
"->",
"writeln",
"(",
"\"define('ZPREFIX', 'phar://z.phar/');\"",
")",
"->",
"writeln",
"(",
"\"require_once 'phar://z.phar/vendor/autoload.php';\"",
")",
";",
"$",
"this",
"->",
"compileInitialization",
"(",
"$",
"buffer",
")",
";",
"$",
"buffer",
"->",
"writeln",
"(",
"'$app->run();'",
")",
"->",
"writeln",
"(",
"'__HALT_COMPILER();'",
")",
";",
"}"
] |
Compiles into the specified buffer.
@param \Zicht\Tool\Script\Buffer $buffer
@return void
|
[
"Compiles",
"into",
"the",
"specified",
"buffer",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Packager/Node/Stub.php#L43-L56
|
22,310
|
surebert/surebert-framework
|
src/sb/RSS/Feed.php
|
Feed.createNode
|
private function createNode($nodeName, $nodeValue, $cdata = false)
{
$node = $this->createElement($nodeName);
if($cdata){
$text = $this->createCDATASection($nodeValue);
} else {
$text = $this->createTextNode($nodeValue);
}
$node->appendChild($text);
return $node;
}
|
php
|
private function createNode($nodeName, $nodeValue, $cdata = false)
{
$node = $this->createElement($nodeName);
if($cdata){
$text = $this->createCDATASection($nodeValue);
} else {
$text = $this->createTextNode($nodeValue);
}
$node->appendChild($text);
return $node;
}
|
[
"private",
"function",
"createNode",
"(",
"$",
"nodeName",
",",
"$",
"nodeValue",
",",
"$",
"cdata",
"=",
"false",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"$",
"nodeName",
")",
";",
"if",
"(",
"$",
"cdata",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"createCDATASection",
"(",
"$",
"nodeValue",
")",
";",
"}",
"else",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"createTextNode",
"(",
"$",
"nodeValue",
")",
";",
"}",
"$",
"node",
"->",
"appendChild",
"(",
"$",
"text",
")",
";",
"return",
"$",
"node",
";",
"}"
] |
Creates and returns a new node with textNode, ready for appending
@param string $nodeName
@param string $nodeValue
@return object DOM node
|
[
"Creates",
"and",
"returns",
"a",
"new",
"node",
"with",
"textNode",
"ready",
"for",
"appending"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/RSS/Feed.php#L282-L294
|
22,311
|
surebert/surebert-framework
|
src/sb/RSS/Feed.php
|
Feed.appendItem
|
private function appendItem(\sb\RSS\Item $item)
{
$new_item = $this->createElement("item");
foreach(get_object_vars($item) as $key=>$val){
if($item->{$key} instanceof \sb\RSS\ItemEnclosure){
$enclosure = $this->createElement('enclosure');
foreach($item->{$key} as $n=>$v){
$enclosure->setAttribute($n, $v);
}
$new_item->appendChild($enclosure);
}
if($key == 'categories'){
foreach($item->{$key} as $category){
$new_item->appendChild($this->createNode('category', $category));
}
}
if(is_string($val) && !empty($val)){
$new_item->appendChild($this->createNode($key, $val, $key == 'description'));
}
}
if(empty($item->guid)){
$new_item->appendChild($this->createNode('guid', $item->link));
}
$this->channel->appendChild($new_item);
}
|
php
|
private function appendItem(\sb\RSS\Item $item)
{
$new_item = $this->createElement("item");
foreach(get_object_vars($item) as $key=>$val){
if($item->{$key} instanceof \sb\RSS\ItemEnclosure){
$enclosure = $this->createElement('enclosure');
foreach($item->{$key} as $n=>$v){
$enclosure->setAttribute($n, $v);
}
$new_item->appendChild($enclosure);
}
if($key == 'categories'){
foreach($item->{$key} as $category){
$new_item->appendChild($this->createNode('category', $category));
}
}
if(is_string($val) && !empty($val)){
$new_item->appendChild($this->createNode($key, $val, $key == 'description'));
}
}
if(empty($item->guid)){
$new_item->appendChild($this->createNode('guid', $item->link));
}
$this->channel->appendChild($new_item);
}
|
[
"private",
"function",
"appendItem",
"(",
"\\",
"sb",
"\\",
"RSS",
"\\",
"Item",
"$",
"item",
")",
"{",
"$",
"new_item",
"=",
"$",
"this",
"->",
"createElement",
"(",
"\"item\"",
")",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"item",
")",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"{",
"$",
"key",
"}",
"instanceof",
"\\",
"sb",
"\\",
"RSS",
"\\",
"ItemEnclosure",
")",
"{",
"$",
"enclosure",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'enclosure'",
")",
";",
"foreach",
"(",
"$",
"item",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"n",
"=>",
"$",
"v",
")",
"{",
"$",
"enclosure",
"->",
"setAttribute",
"(",
"$",
"n",
",",
"$",
"v",
")",
";",
"}",
"$",
"new_item",
"->",
"appendChild",
"(",
"$",
"enclosure",
")",
";",
"}",
"if",
"(",
"$",
"key",
"==",
"'categories'",
")",
"{",
"foreach",
"(",
"$",
"item",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"category",
")",
"{",
"$",
"new_item",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"'category'",
",",
"$",
"category",
")",
")",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"val",
")",
"&&",
"!",
"empty",
"(",
"$",
"val",
")",
")",
"{",
"$",
"new_item",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"$",
"key",
",",
"$",
"val",
",",
"$",
"key",
"==",
"'description'",
")",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"item",
"->",
"guid",
")",
")",
"{",
"$",
"new_item",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"'guid'",
",",
"$",
"item",
"->",
"link",
")",
")",
";",
"}",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"new_item",
")",
";",
"}"
] |
Takes an \sb\RSS\Item and converts it into a DOMM node followed by inserting it into the feed DOM
@param \sb\RSS\Item $item
|
[
"Takes",
"an",
"\\",
"sb",
"\\",
"RSS",
"\\",
"Item",
"and",
"converts",
"it",
"into",
"a",
"DOMM",
"node",
"followed",
"by",
"inserting",
"it",
"into",
"the",
"feed",
"DOM"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/RSS/Feed.php#L301-L334
|
22,312
|
surebert/surebert-framework
|
src/sb/RSS/Feed.php
|
Feed.channelPropertiesToDOM
|
private function channelPropertiesToDOM()
{
foreach(get_object_vars($this) as $key=>$val){
//parse string based key value pairs
if (is_string($val) && !empty($val)){
$this->channel->appendChild($this->createNode($key, $val, $key == 'description'));
//parse image
} elseif ($this->{$key} instanceof \sb\RSS\Image){
$image = $this->createElement('image');
foreach($this->{$key} as $n=>$v){
$image->appendChild($this->createNode($n, $v));
}
$image->appendChild($this->createNode('link', $this->link));
$this->channel->appendChild($image);
//parse cloud
} elseif ($this->{$key} instanceof \sb\RSS_Cloud){
$cloud = $this->createElement('cloud');
foreach($this->{$key} as $n=>$v){
$cloud->setAttribute($n, $v);
}
$this->channel->appendChild($cloud);
} elseif($key == 'categories'){
foreach($this->{$key} as $category){
$this->channel->appendChild($this->createNode('category', $category));
}
//parse skipHours and skipDays
} elseif($key == 'skipHours' || $key == 'skipDays'){
$node = $this->createElement($key);
$nodeName = ($key =='skipHours') ? 'hour' : 'day';
foreach($this->{$key} as $value){
//force caps on day name as it is required to validate
$node->appendChild($this->createNode($nodeName, ucwords($value)));
}
$this->channel->appendChild($node);
}
}
}
|
php
|
private function channelPropertiesToDOM()
{
foreach(get_object_vars($this) as $key=>$val){
//parse string based key value pairs
if (is_string($val) && !empty($val)){
$this->channel->appendChild($this->createNode($key, $val, $key == 'description'));
//parse image
} elseif ($this->{$key} instanceof \sb\RSS\Image){
$image = $this->createElement('image');
foreach($this->{$key} as $n=>$v){
$image->appendChild($this->createNode($n, $v));
}
$image->appendChild($this->createNode('link', $this->link));
$this->channel->appendChild($image);
//parse cloud
} elseif ($this->{$key} instanceof \sb\RSS_Cloud){
$cloud = $this->createElement('cloud');
foreach($this->{$key} as $n=>$v){
$cloud->setAttribute($n, $v);
}
$this->channel->appendChild($cloud);
} elseif($key == 'categories'){
foreach($this->{$key} as $category){
$this->channel->appendChild($this->createNode('category', $category));
}
//parse skipHours and skipDays
} elseif($key == 'skipHours' || $key == 'skipDays'){
$node = $this->createElement($key);
$nodeName = ($key =='skipHours') ? 'hour' : 'day';
foreach($this->{$key} as $value){
//force caps on day name as it is required to validate
$node->appendChild($this->createNode($nodeName, ucwords($value)));
}
$this->channel->appendChild($node);
}
}
}
|
[
"private",
"function",
"channelPropertiesToDOM",
"(",
")",
"{",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"//parse string based key value pairs",
"if",
"(",
"is_string",
"(",
"$",
"val",
")",
"&&",
"!",
"empty",
"(",
"$",
"val",
")",
")",
"{",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"$",
"key",
",",
"$",
"val",
",",
"$",
"key",
"==",
"'description'",
")",
")",
";",
"//parse image",
"}",
"elseif",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"instanceof",
"\\",
"sb",
"\\",
"RSS",
"\\",
"Image",
")",
"{",
"$",
"image",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'image'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"n",
"=>",
"$",
"v",
")",
"{",
"$",
"image",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"$",
"n",
",",
"$",
"v",
")",
")",
";",
"}",
"$",
"image",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"'link'",
",",
"$",
"this",
"->",
"link",
")",
")",
";",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"image",
")",
";",
"//parse cloud",
"}",
"elseif",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"instanceof",
"\\",
"sb",
"\\",
"RSS_Cloud",
")",
"{",
"$",
"cloud",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'cloud'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"n",
"=>",
"$",
"v",
")",
"{",
"$",
"cloud",
"->",
"setAttribute",
"(",
"$",
"n",
",",
"$",
"v",
")",
";",
"}",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"cloud",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'categories'",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"category",
")",
"{",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"'category'",
",",
"$",
"category",
")",
")",
";",
"}",
"//parse skipHours and skipDays",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'skipHours'",
"||",
"$",
"key",
"==",
"'skipDays'",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"$",
"key",
")",
";",
"$",
"nodeName",
"=",
"(",
"$",
"key",
"==",
"'skipHours'",
")",
"?",
"'hour'",
":",
"'day'",
";",
"foreach",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"value",
")",
"{",
"//force caps on day name as it is required to validate",
"$",
"node",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"$",
"nodeName",
",",
"ucwords",
"(",
"$",
"value",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"}",
"}"
] |
Converts all the feed object properties into RSS DOM nodes and adds them to the channel node
|
[
"Converts",
"all",
"the",
"feed",
"object",
"properties",
"into",
"RSS",
"DOM",
"nodes",
"and",
"adds",
"them",
"to",
"the",
"channel",
"node"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/RSS/Feed.php#L340-L393
|
22,313
|
xiewulong/yii2-fileupload
|
oss/libs/symfony/yaml/Symfony/Component/Yaml/Unescaper.php
|
Unescaper.unescapeCharacter
|
public function unescapeCharacter($value)
{
switch ($value{1}) {
case '0':
return "\x0";
case 'a':
return "\x7";
case 'b':
return "\x8";
case 't':
return "\t";
case "\t":
return "\t";
case 'n':
return "\n";
case 'v':
return "\xb";
case 'f':
return "\xc";
case 'r':
return "\xd";
case 'e':
return "\x1b";
case ' ':
return ' ';
case '"':
return '"';
case '/':
return '/';
case '\\':
return '\\';
case 'N':
// U+0085 NEXT LINE
return $this->convertEncoding("\x00\x85", self::ENCODING, 'UCS-2BE');
case '_':
// U+00A0 NO-BREAK SPACE
return $this->convertEncoding("\x00\xA0", self::ENCODING, 'UCS-2BE');
case 'L':
// U+2028 LINE SEPARATOR
return $this->convertEncoding("\x20\x28", self::ENCODING, 'UCS-2BE');
case 'P':
// U+2029 PARAGRAPH SEPARATOR
return $this->convertEncoding("\x20\x29", self::ENCODING, 'UCS-2BE');
case 'x':
$char = pack('n', hexdec(substr($value, 2, 2)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE');
case 'u':
$char = pack('n', hexdec(substr($value, 2, 4)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE');
case 'U':
$char = pack('N', hexdec(substr($value, 2, 8)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-4BE');
}
}
|
php
|
public function unescapeCharacter($value)
{
switch ($value{1}) {
case '0':
return "\x0";
case 'a':
return "\x7";
case 'b':
return "\x8";
case 't':
return "\t";
case "\t":
return "\t";
case 'n':
return "\n";
case 'v':
return "\xb";
case 'f':
return "\xc";
case 'r':
return "\xd";
case 'e':
return "\x1b";
case ' ':
return ' ';
case '"':
return '"';
case '/':
return '/';
case '\\':
return '\\';
case 'N':
// U+0085 NEXT LINE
return $this->convertEncoding("\x00\x85", self::ENCODING, 'UCS-2BE');
case '_':
// U+00A0 NO-BREAK SPACE
return $this->convertEncoding("\x00\xA0", self::ENCODING, 'UCS-2BE');
case 'L':
// U+2028 LINE SEPARATOR
return $this->convertEncoding("\x20\x28", self::ENCODING, 'UCS-2BE');
case 'P':
// U+2029 PARAGRAPH SEPARATOR
return $this->convertEncoding("\x20\x29", self::ENCODING, 'UCS-2BE');
case 'x':
$char = pack('n', hexdec(substr($value, 2, 2)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE');
case 'u':
$char = pack('n', hexdec(substr($value, 2, 4)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE');
case 'U':
$char = pack('N', hexdec(substr($value, 2, 8)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-4BE');
}
}
|
[
"public",
"function",
"unescapeCharacter",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"value",
"{",
"1",
"}",
")",
"{",
"case",
"'0'",
":",
"return",
"\"\\x0\"",
";",
"case",
"'a'",
":",
"return",
"\"\\x7\"",
";",
"case",
"'b'",
":",
"return",
"\"\\x8\"",
";",
"case",
"'t'",
":",
"return",
"\"\\t\"",
";",
"case",
"\"\\t\"",
":",
"return",
"\"\\t\"",
";",
"case",
"'n'",
":",
"return",
"\"\\n\"",
";",
"case",
"'v'",
":",
"return",
"\"\\xb\"",
";",
"case",
"'f'",
":",
"return",
"\"\\xc\"",
";",
"case",
"'r'",
":",
"return",
"\"\\xd\"",
";",
"case",
"'e'",
":",
"return",
"\"\\x1b\"",
";",
"case",
"' '",
":",
"return",
"' '",
";",
"case",
"'\"'",
":",
"return",
"'\"'",
";",
"case",
"'/'",
":",
"return",
"'/'",
";",
"case",
"'\\\\'",
":",
"return",
"'\\\\'",
";",
"case",
"'N'",
":",
"// U+0085 NEXT LINE",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"\"\\x00\\x85\"",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'_'",
":",
"// U+00A0 NO-BREAK SPACE",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"\"\\x00\\xA0\"",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'L'",
":",
"// U+2028 LINE SEPARATOR",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"\"\\x20\\x28\"",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'P'",
":",
"// U+2029 PARAGRAPH SEPARATOR",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"\"\\x20\\x29\"",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'x'",
":",
"$",
"char",
"=",
"pack",
"(",
"'n'",
",",
"hexdec",
"(",
"substr",
"(",
"$",
"value",
",",
"2",
",",
"2",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"$",
"char",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'u'",
":",
"$",
"char",
"=",
"pack",
"(",
"'n'",
",",
"hexdec",
"(",
"substr",
"(",
"$",
"value",
",",
"2",
",",
"4",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"$",
"char",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'U'",
":",
"$",
"char",
"=",
"pack",
"(",
"'N'",
",",
"hexdec",
"(",
"substr",
"(",
"$",
"value",
",",
"2",
",",
"8",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"$",
"char",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-4BE'",
")",
";",
"}",
"}"
] |
Unescapes a character that was found in a double-quoted string
@param string $value An escaped character
@return string The unescaped character
|
[
"Unescapes",
"a",
"character",
"that",
"was",
"found",
"in",
"a",
"double",
"-",
"quoted",
"string"
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Unescaper.php#L66-L122
|
22,314
|
gregoryv/php-logger
|
src/State.php
|
State.toggle
|
public function toggle($flag, $name)
{
switch ($flag) {
case 'on':
$onoff = true;
break;
case 'off':
$onoff = false;
break;
default:
throw new \InvalidArgumentException("Flag must be 'on' or 'off'");
}
switch ($name) {
case 'debug':
$this->debug = $onoff;
break;
case 'info':
$this->info = $onoff;
break;
case 'notice':
$this->notice = $onoff;
break;
case 'warn':
$this->warn = $onoff;
break;
case 'error':
$this->error = $onoff;
break;
case 'critical':
$this->critical = $onoff;
break;
case 'alert':
$this->alert = $onoff;
break;
case 'emergency':
$this->emergency = $onoff;
break;
default:
throw new \InvalidArgumentException("Name must be on (debug|info|notice|warn|error|critical|alert|emergency)");
}
}
|
php
|
public function toggle($flag, $name)
{
switch ($flag) {
case 'on':
$onoff = true;
break;
case 'off':
$onoff = false;
break;
default:
throw new \InvalidArgumentException("Flag must be 'on' or 'off'");
}
switch ($name) {
case 'debug':
$this->debug = $onoff;
break;
case 'info':
$this->info = $onoff;
break;
case 'notice':
$this->notice = $onoff;
break;
case 'warn':
$this->warn = $onoff;
break;
case 'error':
$this->error = $onoff;
break;
case 'critical':
$this->critical = $onoff;
break;
case 'alert':
$this->alert = $onoff;
break;
case 'emergency':
$this->emergency = $onoff;
break;
default:
throw new \InvalidArgumentException("Name must be on (debug|info|notice|warn|error|critical|alert|emergency)");
}
}
|
[
"public",
"function",
"toggle",
"(",
"$",
"flag",
",",
"$",
"name",
")",
"{",
"switch",
"(",
"$",
"flag",
")",
"{",
"case",
"'on'",
":",
"$",
"onoff",
"=",
"true",
";",
"break",
";",
"case",
"'off'",
":",
"$",
"onoff",
"=",
"false",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Flag must be 'on' or 'off'\"",
")",
";",
"}",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'debug'",
":",
"$",
"this",
"->",
"debug",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'info'",
":",
"$",
"this",
"->",
"info",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'notice'",
":",
"$",
"this",
"->",
"notice",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'warn'",
":",
"$",
"this",
"->",
"warn",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'error'",
":",
"$",
"this",
"->",
"error",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'critical'",
":",
"$",
"this",
"->",
"critical",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'alert'",
":",
"$",
"this",
"->",
"alert",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'emergency'",
":",
"$",
"this",
"->",
"emergency",
"=",
"$",
"onoff",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Name must be on (debug|info|notice|warn|error|critical|alert|emergency)\"",
")",
";",
"}",
"}"
] |
Sets the named attribute to true or false
@param string $flag (on|off)
@param string $name (debug|info|notice|warn|error|critical|alert|emergency)
@throws InvalidArgumentException on badly formated $flag or $name
|
[
"Sets",
"the",
"named",
"attribute",
"to",
"true",
"or",
"false"
] |
0f8ffc360a0233531a9775359929af8876997862
|
https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/State.php#L26-L67
|
22,315
|
OKTOTV/OktolabMediaBundle
|
Model/FFprobeService.php
|
FFprobeService.audioCanBeEncoded
|
private function audioCanBeEncoded($resolution, $metainfo) {
return
// sample rate of file is better or as good as defined in resolution
$resolution['audio_sample_rate'] >= $metainfo['sample_rate'] &&
// bitrate of file is better or as good as defined in resolution
$resolution['audio_bitrate'] <= $metainfo['max_bit_rate'] ||
// or we allow worse quality to be used for encoding
filter_var(
$resolution['allow_lower_audio_bitrate'],
FILTER_VALIDATE_BOOLEAN
)
;
}
|
php
|
private function audioCanBeEncoded($resolution, $metainfo) {
return
// sample rate of file is better or as good as defined in resolution
$resolution['audio_sample_rate'] >= $metainfo['sample_rate'] &&
// bitrate of file is better or as good as defined in resolution
$resolution['audio_bitrate'] <= $metainfo['max_bit_rate'] ||
// or we allow worse quality to be used for encoding
filter_var(
$resolution['allow_lower_audio_bitrate'],
FILTER_VALIDATE_BOOLEAN
)
;
}
|
[
"private",
"function",
"audioCanBeEncoded",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
")",
"{",
"return",
"// sample rate of file is better or as good as defined in resolution",
"$",
"resolution",
"[",
"'audio_sample_rate'",
"]",
">=",
"$",
"metainfo",
"[",
"'sample_rate'",
"]",
"&&",
"// bitrate of file is better or as good as defined in resolution",
"$",
"resolution",
"[",
"'audio_bitrate'",
"]",
"<=",
"$",
"metainfo",
"[",
"'max_bit_rate'",
"]",
"||",
"// or we allow worse quality to be used for encoding",
"filter_var",
"(",
"$",
"resolution",
"[",
"'allow_lower_audio_bitrate'",
"]",
",",
"FILTER_VALIDATE_BOOLEAN",
")",
";",
"}"
] |
determines if the the audiotrack meets minimum standards to be encoded
|
[
"determines",
"if",
"the",
"the",
"audiotrack",
"meets",
"minimum",
"standards",
"to",
"be",
"encoded"
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/FFprobeService.php#L158-L170
|
22,316
|
OKTOTV/OktolabMediaBundle
|
Model/FFprobeService.php
|
FFprobeService.getMediaType
|
private function getMediaType($metainfo) {
if (
$metainfo['audio'] != false &&
(
$metainfo['video'] == false ||
$metainfo['video']['codec_name'] == 'png' ||
$metainfo['video']['codec_name'] == 'jpg'
)
) {
return $this::MEDIA_TYPE_AUDIO;
}
if ($metainfo['video'] != false && $metainfo['audio'] == false) {
return $this::MEDIA_TYPE_VIDEO_ONLY;
}
if ($metainfo['video'] != false && $metainfo['audio'] != false) {
return $this::MEDIA_TYPE_VIDEO;
}
return $this::MEDIA_TYPE_UNKNOWN;
}
|
php
|
private function getMediaType($metainfo) {
if (
$metainfo['audio'] != false &&
(
$metainfo['video'] == false ||
$metainfo['video']['codec_name'] == 'png' ||
$metainfo['video']['codec_name'] == 'jpg'
)
) {
return $this::MEDIA_TYPE_AUDIO;
}
if ($metainfo['video'] != false && $metainfo['audio'] == false) {
return $this::MEDIA_TYPE_VIDEO_ONLY;
}
if ($metainfo['video'] != false && $metainfo['audio'] != false) {
return $this::MEDIA_TYPE_VIDEO;
}
return $this::MEDIA_TYPE_UNKNOWN;
}
|
[
"private",
"function",
"getMediaType",
"(",
"$",
"metainfo",
")",
"{",
"if",
"(",
"$",
"metainfo",
"[",
"'audio'",
"]",
"!=",
"false",
"&&",
"(",
"$",
"metainfo",
"[",
"'video'",
"]",
"==",
"false",
"||",
"$",
"metainfo",
"[",
"'video'",
"]",
"[",
"'codec_name'",
"]",
"==",
"'png'",
"||",
"$",
"metainfo",
"[",
"'video'",
"]",
"[",
"'codec_name'",
"]",
"==",
"'jpg'",
")",
")",
"{",
"return",
"$",
"this",
"::",
"MEDIA_TYPE_AUDIO",
";",
"}",
"if",
"(",
"$",
"metainfo",
"[",
"'video'",
"]",
"!=",
"false",
"&&",
"$",
"metainfo",
"[",
"'audio'",
"]",
"==",
"false",
")",
"{",
"return",
"$",
"this",
"::",
"MEDIA_TYPE_VIDEO_ONLY",
";",
"}",
"if",
"(",
"$",
"metainfo",
"[",
"'video'",
"]",
"!=",
"false",
"&&",
"$",
"metainfo",
"[",
"'audio'",
"]",
"!=",
"false",
")",
"{",
"return",
"$",
"this",
"::",
"MEDIA_TYPE_VIDEO",
";",
"}",
"return",
"$",
"this",
"::",
"MEDIA_TYPE_UNKNOWN",
";",
"}"
] |
returns the mediatype depending on given metainfos
MEDIA_TYPE_AUDIO if soundfile,
MEDIA_TYPE_VIDEO if videofile,
MEDIA_TYPE_VIDEO_ONLY if videofile without soundstream.
|
[
"returns",
"the",
"mediatype",
"depending",
"on",
"given",
"metainfos",
"MEDIA_TYPE_AUDIO",
"if",
"soundfile",
"MEDIA_TYPE_VIDEO",
"if",
"videofile",
"MEDIA_TYPE_VIDEO_ONLY",
"if",
"videofile",
"without",
"soundstream",
"."
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/FFprobeService.php#L178-L198
|
22,317
|
OKTOTV/OktolabMediaBundle
|
Model/FFprobeService.php
|
FFprobeService.getMetainfoForEpisode
|
private function getMetainfoForEpisode($episode) {
$uri = $this->bprs_asset_helper->getAbsoluteUrl(
$episode->getVideo()
);
if (!$uri) { // can't create uri of episode video
$this->logbook->error(
'oktolab_media.episode_encode_no_streams',
[],
$episode->getUniqID()
);
return false;
}
$metainfo = json_decode(
shell_exec(
sprintf(
'ffprobe -v error -show_streams -print_format json %s',
$uri)
),
true
);
$metadata = ['video' => false, 'audio' => false];
// run through all streams to find the primary video and audio stream
foreach ($metainfo['streams'] as $stream) {
// found both streams, skip the rest
if ($metadata['video'] && $metadata['audio']) {
break;
}
// found an audio stream
if ($stream['codec_type'] == "audio" && $metadata['audio'] == false) {
$metadata['audio'] = $stream;
if (
!array_key_exists('max_bit_rate', $metadata['audio']) &&
array_key_exists('tags', $metadata['audio'])
) {
$metadata['audio']['max_bit_rate'] = $metadata['tags']['BPS'];
}
}
if ($stream['codec_type'] == "video") {
$metadata['video'] = $stream;
if (!array_key_exists('duration', $metadata['video'])) {
$metadata['video']['duration'] = 0;
} else {
$episode->setDuration($metadata['video']['duration']);
}
}
}
return $metadata;
}
|
php
|
private function getMetainfoForEpisode($episode) {
$uri = $this->bprs_asset_helper->getAbsoluteUrl(
$episode->getVideo()
);
if (!$uri) { // can't create uri of episode video
$this->logbook->error(
'oktolab_media.episode_encode_no_streams',
[],
$episode->getUniqID()
);
return false;
}
$metainfo = json_decode(
shell_exec(
sprintf(
'ffprobe -v error -show_streams -print_format json %s',
$uri)
),
true
);
$metadata = ['video' => false, 'audio' => false];
// run through all streams to find the primary video and audio stream
foreach ($metainfo['streams'] as $stream) {
// found both streams, skip the rest
if ($metadata['video'] && $metadata['audio']) {
break;
}
// found an audio stream
if ($stream['codec_type'] == "audio" && $metadata['audio'] == false) {
$metadata['audio'] = $stream;
if (
!array_key_exists('max_bit_rate', $metadata['audio']) &&
array_key_exists('tags', $metadata['audio'])
) {
$metadata['audio']['max_bit_rate'] = $metadata['tags']['BPS'];
}
}
if ($stream['codec_type'] == "video") {
$metadata['video'] = $stream;
if (!array_key_exists('duration', $metadata['video'])) {
$metadata['video']['duration'] = 0;
} else {
$episode->setDuration($metadata['video']['duration']);
}
}
}
return $metadata;
}
|
[
"private",
"function",
"getMetainfoForEpisode",
"(",
"$",
"episode",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"bprs_asset_helper",
"->",
"getAbsoluteUrl",
"(",
"$",
"episode",
"->",
"getVideo",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"uri",
")",
"{",
"// can't create uri of episode video",
"$",
"this",
"->",
"logbook",
"->",
"error",
"(",
"'oktolab_media.episode_encode_no_streams'",
",",
"[",
"]",
",",
"$",
"episode",
"->",
"getUniqID",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"$",
"metainfo",
"=",
"json_decode",
"(",
"shell_exec",
"(",
"sprintf",
"(",
"'ffprobe -v error -show_streams -print_format json %s'",
",",
"$",
"uri",
")",
")",
",",
"true",
")",
";",
"$",
"metadata",
"=",
"[",
"'video'",
"=>",
"false",
",",
"'audio'",
"=>",
"false",
"]",
";",
"// run through all streams to find the primary video and audio stream",
"foreach",
"(",
"$",
"metainfo",
"[",
"'streams'",
"]",
"as",
"$",
"stream",
")",
"{",
"// found both streams, skip the rest",
"if",
"(",
"$",
"metadata",
"[",
"'video'",
"]",
"&&",
"$",
"metadata",
"[",
"'audio'",
"]",
")",
"{",
"break",
";",
"}",
"// found an audio stream",
"if",
"(",
"$",
"stream",
"[",
"'codec_type'",
"]",
"==",
"\"audio\"",
"&&",
"$",
"metadata",
"[",
"'audio'",
"]",
"==",
"false",
")",
"{",
"$",
"metadata",
"[",
"'audio'",
"]",
"=",
"$",
"stream",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'max_bit_rate'",
",",
"$",
"metadata",
"[",
"'audio'",
"]",
")",
"&&",
"array_key_exists",
"(",
"'tags'",
",",
"$",
"metadata",
"[",
"'audio'",
"]",
")",
")",
"{",
"$",
"metadata",
"[",
"'audio'",
"]",
"[",
"'max_bit_rate'",
"]",
"=",
"$",
"metadata",
"[",
"'tags'",
"]",
"[",
"'BPS'",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"stream",
"[",
"'codec_type'",
"]",
"==",
"\"video\"",
")",
"{",
"$",
"metadata",
"[",
"'video'",
"]",
"=",
"$",
"stream",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'duration'",
",",
"$",
"metadata",
"[",
"'video'",
"]",
")",
")",
"{",
"$",
"metadata",
"[",
"'video'",
"]",
"[",
"'duration'",
"]",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"episode",
"->",
"setDuration",
"(",
"$",
"metadata",
"[",
"'video'",
"]",
"[",
"'duration'",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"metadata",
";",
"}"
] |
extracts streaminformations of an episode from its video.
@param object $episode Entity you want the stream infos from
@return false|array if informations can't be extracted,
array of video and audio info
|
[
"extracts",
"streaminformations",
"of",
"an",
"episode",
"from",
"its",
"video",
"."
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/FFprobeService.php#L206-L258
|
22,318
|
wearenolte/wp-cpt
|
src/Cpt.php
|
Cpt.init
|
public function init() {
if ( ! post_type_exists( $this->post_type ) ) {
$post_type = register_post_type( $this->post_type, $this->args );
if ( is_wp_error( $post_type ) ) {
return $post_type;
}
}
if ( '' !== $this->title_placeholder ) {
add_filter( 'enter_title_here', array( $this, 'update_placeholder' ) );
}
}
|
php
|
public function init() {
if ( ! post_type_exists( $this->post_type ) ) {
$post_type = register_post_type( $this->post_type, $this->args );
if ( is_wp_error( $post_type ) ) {
return $post_type;
}
}
if ( '' !== $this->title_placeholder ) {
add_filter( 'enter_title_here', array( $this, 'update_placeholder' ) );
}
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"post_type_exists",
"(",
"$",
"this",
"->",
"post_type",
")",
")",
"{",
"$",
"post_type",
"=",
"register_post_type",
"(",
"$",
"this",
"->",
"post_type",
",",
"$",
"this",
"->",
"args",
")",
";",
"if",
"(",
"is_wp_error",
"(",
"$",
"post_type",
")",
")",
"{",
"return",
"$",
"post_type",
";",
"}",
"}",
"if",
"(",
"''",
"!==",
"$",
"this",
"->",
"title_placeholder",
")",
"{",
"add_filter",
"(",
"'enter_title_here'",
",",
"array",
"(",
"$",
"this",
",",
"'update_placeholder'",
")",
")",
";",
"}",
"}"
] |
Function that register the CPT first tests if there is no such CPT on
the site.
@since 0.1.0
|
[
"Function",
"that",
"register",
"the",
"CPT",
"first",
"tests",
"if",
"there",
"is",
"no",
"such",
"CPT",
"on",
"the",
"site",
"."
] |
b6c11946e8f53a7c5ad5b347f66848c6df355812
|
https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L177-L187
|
22,319
|
wearenolte/wp-cpt
|
src/Cpt.php
|
Cpt.set_labels
|
public function set_labels( $labels ) {
$this->merge( $this->labels, $labels );
$this->update_arg( 'labels', $this->labels );
}
|
php
|
public function set_labels( $labels ) {
$this->merge( $this->labels, $labels );
$this->update_arg( 'labels', $this->labels );
}
|
[
"public",
"function",
"set_labels",
"(",
"$",
"labels",
")",
"{",
"$",
"this",
"->",
"merge",
"(",
"$",
"this",
"->",
"labels",
",",
"$",
"labels",
")",
";",
"$",
"this",
"->",
"update_arg",
"(",
"'labels'",
",",
"$",
"this",
"->",
"labels",
")",
";",
"}"
] |
Allows to overwrite any of the default labels for this CPT, just
send an associate array with the value you want to update.
@since 0.1.0
@param array $labels The group of labels to update.
|
[
"Allows",
"to",
"overwrite",
"any",
"of",
"the",
"default",
"labels",
"for",
"this",
"CPT",
"just",
"send",
"an",
"associate",
"array",
"with",
"the",
"value",
"you",
"want",
"to",
"update",
"."
] |
b6c11946e8f53a7c5ad5b347f66848c6df355812
|
https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L229-L232
|
22,320
|
wearenolte/wp-cpt
|
src/Cpt.php
|
Cpt.set_default_labels
|
private function set_default_labels() {
$this->labels = array(
'name' => $this->interpolate( '%s', $this->plural ),
'singular_name' => $this->interpolate( '%s', $this->singular ),
'add_new' => $this->interpolate( 'Add New' ),
'all_items' => $this->interpolate( 'All %s', $this-> plural ),
'new_item' => $this->interpolate( 'New %s', $this->singular ),
'edit_item' => $this->interpolate( 'Edit %s', $this->singular ),
'add_new_item' => $this->interpolate( 'Add New %s', $this->singular ),
'view_item' => $this->interpolate( 'View %S', $this->singular ),
'menu_name' => $this->interpolate( '%s', $this->plural ),
'search_items' => $this->interpolate( 'Search %s', $this->plural ),
'not_found' => $this->interpolate( 'No %s found.', $this->plural ),
'not_found_in_trash' => $this->interpolate( 'No %s found in trash.', $this->plural ),
);
}
|
php
|
private function set_default_labels() {
$this->labels = array(
'name' => $this->interpolate( '%s', $this->plural ),
'singular_name' => $this->interpolate( '%s', $this->singular ),
'add_new' => $this->interpolate( 'Add New' ),
'all_items' => $this->interpolate( 'All %s', $this-> plural ),
'new_item' => $this->interpolate( 'New %s', $this->singular ),
'edit_item' => $this->interpolate( 'Edit %s', $this->singular ),
'add_new_item' => $this->interpolate( 'Add New %s', $this->singular ),
'view_item' => $this->interpolate( 'View %S', $this->singular ),
'menu_name' => $this->interpolate( '%s', $this->plural ),
'search_items' => $this->interpolate( 'Search %s', $this->plural ),
'not_found' => $this->interpolate( 'No %s found.', $this->plural ),
'not_found_in_trash' => $this->interpolate( 'No %s found in trash.', $this->plural ),
);
}
|
[
"private",
"function",
"set_default_labels",
"(",
")",
"{",
"$",
"this",
"->",
"labels",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'%s'",
",",
"$",
"this",
"->",
"plural",
")",
",",
"'singular_name'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'%s'",
",",
"$",
"this",
"->",
"singular",
")",
",",
"'add_new'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'Add New'",
")",
",",
"'all_items'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'All %s'",
",",
"$",
"this",
"->",
"plural",
")",
",",
"'new_item'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'New %s'",
",",
"$",
"this",
"->",
"singular",
")",
",",
"'edit_item'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'Edit %s'",
",",
"$",
"this",
"->",
"singular",
")",
",",
"'add_new_item'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'Add New %s'",
",",
"$",
"this",
"->",
"singular",
")",
",",
"'view_item'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'View %S'",
",",
"$",
"this",
"->",
"singular",
")",
",",
"'menu_name'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'%s'",
",",
"$",
"this",
"->",
"plural",
")",
",",
"'search_items'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'Search %s'",
",",
"$",
"this",
"->",
"plural",
")",
",",
"'not_found'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'No %s found.'",
",",
"$",
"this",
"->",
"plural",
")",
",",
"'not_found_in_trash'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'No %s found in trash.'",
",",
"$",
"this",
"->",
"plural",
")",
",",
")",
";",
"}"
] |
Creates the default labels to be used with this CPT.
@since 0.10
|
[
"Creates",
"the",
"default",
"labels",
"to",
"be",
"used",
"with",
"this",
"CPT",
"."
] |
b6c11946e8f53a7c5ad5b347f66848c6df355812
|
https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L256-L271
|
22,321
|
wearenolte/wp-cpt
|
src/Cpt.php
|
Cpt.set_supports
|
public function set_supports( $support ) {
if ( is_array( $support ) ) {
$this->supports = $support;
$this->update_arg( 'supports', $this->supports );
}
}
|
php
|
public function set_supports( $support ) {
if ( is_array( $support ) ) {
$this->supports = $support;
$this->update_arg( 'supports', $this->supports );
}
}
|
[
"public",
"function",
"set_supports",
"(",
"$",
"support",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"support",
")",
")",
"{",
"$",
"this",
"->",
"supports",
"=",
"$",
"support",
";",
"$",
"this",
"->",
"update_arg",
"(",
"'supports'",
",",
"$",
"this",
"->",
"supports",
")",
";",
"}",
"}"
] |
Allow to update the default supports values for the CPT.
@since 0.1.0
@param array $support The new array with the supported featurs.
|
[
"Allow",
"to",
"update",
"the",
"default",
"supports",
"values",
"for",
"the",
"CPT",
"."
] |
b6c11946e8f53a7c5ad5b347f66848c6df355812
|
https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L342-L347
|
22,322
|
Eresus/EresusCMS
|
src/core/Application.php
|
Eresus_Application.detectFsRoot
|
protected function detectFsRoot()
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'start');
switch (true)
{
case Eresus_Kernel::isCLI():
$path = reset($GLOBALS['argv']);
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Using global $argv variable: %s', $path);
$path = dirname($path);
break;
default:
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Using $_SERVER["SCRIPT_FILENAME"]: %s',
$_SERVER['SCRIPT_FILENAME']);
$path = dirname($_SERVER['SCRIPT_FILENAME']);
}
$path = Eresus_FS_Tool::normalize($path);
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '"%s"', $path);
return $path;
}
|
php
|
protected function detectFsRoot()
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'start');
switch (true)
{
case Eresus_Kernel::isCLI():
$path = reset($GLOBALS['argv']);
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Using global $argv variable: %s', $path);
$path = dirname($path);
break;
default:
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Using $_SERVER["SCRIPT_FILENAME"]: %s',
$_SERVER['SCRIPT_FILENAME']);
$path = dirname($_SERVER['SCRIPT_FILENAME']);
}
$path = Eresus_FS_Tool::normalize($path);
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '"%s"', $path);
return $path;
}
|
[
"protected",
"function",
"detectFsRoot",
"(",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'start'",
")",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"Eresus_Kernel",
"::",
"isCLI",
"(",
")",
":",
"$",
"path",
"=",
"reset",
"(",
"$",
"GLOBALS",
"[",
"'argv'",
"]",
")",
";",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'Using global $argv variable: %s'",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"break",
";",
"default",
":",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'Using $_SERVER[\"SCRIPT_FILENAME\"]: %s'",
",",
"$",
"_SERVER",
"[",
"'SCRIPT_FILENAME'",
"]",
")",
";",
"$",
"path",
"=",
"dirname",
"(",
"$",
"_SERVER",
"[",
"'SCRIPT_FILENAME'",
"]",
")",
";",
"}",
"$",
"path",
"=",
"Eresus_FS_Tool",
"::",
"normalize",
"(",
"$",
"path",
")",
";",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'\"%s\"'",
",",
"$",
"path",
")",
";",
"return",
"$",
"path",
";",
"}"
] |
Trying to determine application root directory
In CLI mode $GLOBALS['argv'][0] used.
In other modes $_SERVER['SCRIPT_FILENAME'] used.
@return string
@see fsRoot, getFsRoot()
|
[
"Trying",
"to",
"determine",
"application",
"root",
"directory"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Application.php#L115-L135
|
22,323
|
xinix-technology/bono-blade
|
src/Xinix/Blade/BladeView.php
|
BladeView.resolvePath
|
protected function resolvePath(array $originalPaths)
{
$paths = array();
foreach ($originalPaths as $key => $path) {
if (count(explode('templates', $path)) == 1) {
$path = $path . DIRECTORY_SEPARATOR . 'templates';
}
if (realpath($path)) {
$paths[$key] = realpath($path);
}
}
return array_unique($paths);
}
|
php
|
protected function resolvePath(array $originalPaths)
{
$paths = array();
foreach ($originalPaths as $key => $path) {
if (count(explode('templates', $path)) == 1) {
$path = $path . DIRECTORY_SEPARATOR . 'templates';
}
if (realpath($path)) {
$paths[$key] = realpath($path);
}
}
return array_unique($paths);
}
|
[
"protected",
"function",
"resolvePath",
"(",
"array",
"$",
"originalPaths",
")",
"{",
"$",
"paths",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"originalPaths",
"as",
"$",
"key",
"=>",
"$",
"path",
")",
"{",
"if",
"(",
"count",
"(",
"explode",
"(",
"'templates'",
",",
"$",
"path",
")",
")",
"==",
"1",
")",
"{",
"$",
"path",
"=",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"'templates'",
";",
"}",
"if",
"(",
"realpath",
"(",
"$",
"path",
")",
")",
"{",
"$",
"paths",
"[",
"$",
"key",
"]",
"=",
"realpath",
"(",
"$",
"path",
")",
";",
"}",
"}",
"return",
"array_unique",
"(",
"$",
"paths",
")",
";",
"}"
] |
Build an array for templates path directory
@return void
|
[
"Build",
"an",
"array",
"for",
"templates",
"path",
"directory"
] |
5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f
|
https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L97-L113
|
22,324
|
xinix-technology/bono-blade
|
src/Xinix/Blade/BladeView.php
|
BladeView.setLayout
|
public function setLayout($layout, array $data = array())
{
if (is_null($layout)) {
$this->layout = null;
return;
}
$this->layout = $this->make($this->resolve($layout), $data);
}
|
php
|
public function setLayout($layout, array $data = array())
{
if (is_null($layout)) {
$this->layout = null;
return;
}
$this->layout = $this->make($this->resolve($layout), $data);
}
|
[
"public",
"function",
"setLayout",
"(",
"$",
"layout",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"layout",
")",
")",
"{",
"$",
"this",
"->",
"layout",
"=",
"null",
";",
"return",
";",
"}",
"$",
"this",
"->",
"layout",
"=",
"$",
"this",
"->",
"make",
"(",
"$",
"this",
"->",
"resolve",
"(",
"$",
"layout",
")",
",",
"$",
"data",
")",
";",
"}"
] |
Manually set the layout
This method will output the rendered template content, so you can set the layout on the air
@param string $layout name
@return void
|
[
"Manually",
"set",
"the",
"layout"
] |
5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f
|
https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L278-L287
|
22,325
|
xinix-technology/bono-blade
|
src/Xinix/Blade/BladeView.php
|
BladeView.fetch
|
public function fetch($template, $data = array())
{
$view = $this->render($template, $data);
return ($view) ? $view->render() : '';
}
|
php
|
public function fetch($template, $data = array())
{
$view = $this->render($template, $data);
return ($view) ? $view->render() : '';
}
|
[
"public",
"function",
"fetch",
"(",
"$",
"template",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"template",
",",
"$",
"data",
")",
";",
"return",
"(",
"$",
"view",
")",
"?",
"$",
"view",
"->",
"render",
"(",
")",
":",
"''",
";",
"}"
] |
Return the contents of a rendered template file
@var string $template The template pathname, relative to the template base directory
@return Illuminate\View\View
|
[
"Return",
"the",
"contents",
"of",
"a",
"rendered",
"template",
"file"
] |
5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f
|
https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L308-L313
|
22,326
|
xinix-technology/bono-blade
|
src/Xinix/Blade/BladeView.php
|
BladeView.render
|
protected function render($template, $data = array())
{
$view = null;
$data = array_merge_recursive($this->all(), $data);
$data['app'] = $this->app;
$template = $this->resolve($template);
if (! $template) {
return;
}
if (! $this->layout) {
$view = $this->make($template, $data);
} else {
$view = $this->layout->nest('content', $template, $data);
}
return $view;
}
|
php
|
protected function render($template, $data = array())
{
$view = null;
$data = array_merge_recursive($this->all(), $data);
$data['app'] = $this->app;
$template = $this->resolve($template);
if (! $template) {
return;
}
if (! $this->layout) {
$view = $this->make($template, $data);
} else {
$view = $this->layout->nest('content', $template, $data);
}
return $view;
}
|
[
"protected",
"function",
"render",
"(",
"$",
"template",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"view",
"=",
"null",
";",
"$",
"data",
"=",
"array_merge_recursive",
"(",
"$",
"this",
"->",
"all",
"(",
")",
",",
"$",
"data",
")",
";",
"$",
"data",
"[",
"'app'",
"]",
"=",
"$",
"this",
"->",
"app",
";",
"$",
"template",
"=",
"$",
"this",
"->",
"resolve",
"(",
"$",
"template",
")",
";",
"if",
"(",
"!",
"$",
"template",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"layout",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"make",
"(",
"$",
"template",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"layout",
"->",
"nest",
"(",
"'content'",
",",
"$",
"template",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"view",
";",
"}"
] |
This method will output the rendered template content
@param string $template The path to the Blade template, relative to the Blade templates directory.
@return Illuminate\View\View
|
[
"This",
"method",
"will",
"output",
"the",
"rendered",
"template",
"content"
] |
5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f
|
https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L322-L341
|
22,327
|
xinix-technology/bono-blade
|
src/Xinix/Blade/BladeView.php
|
BladeView.resolve
|
public function resolve($path)
{
$path = str_replace('/', '.', preg_replace('/\/:\w+/', '', $path));
$finder = $this->container['view.finder'];
try {
$finder->find($path);
} catch (InvalidArgumentException $e) {
$explodedPath = explode('.', $path);
if ($explodedPath[0] === 'static') {
return null;
}
if (count($explodedPath) > 1) {
$explodedPath[0] = 'shared';
$explodedPath = array('shared', end($explodedPath));
try {
$finder->find(implode('.', $explodedPath));
$path = implode('.', $explodedPath);
} catch (InvalidArgumentException $e) {
$this->app->error($e);
}
}
}
return $path;
}
|
php
|
public function resolve($path)
{
$path = str_replace('/', '.', preg_replace('/\/:\w+/', '', $path));
$finder = $this->container['view.finder'];
try {
$finder->find($path);
} catch (InvalidArgumentException $e) {
$explodedPath = explode('.', $path);
if ($explodedPath[0] === 'static') {
return null;
}
if (count($explodedPath) > 1) {
$explodedPath[0] = 'shared';
$explodedPath = array('shared', end($explodedPath));
try {
$finder->find(implode('.', $explodedPath));
$path = implode('.', $explodedPath);
} catch (InvalidArgumentException $e) {
$this->app->error($e);
}
}
}
return $path;
}
|
[
"public",
"function",
"resolve",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"'/'",
",",
"'.'",
",",
"preg_replace",
"(",
"'/\\/:\\w+/'",
",",
"''",
",",
"$",
"path",
")",
")",
";",
"$",
"finder",
"=",
"$",
"this",
"->",
"container",
"[",
"'view.finder'",
"]",
";",
"try",
"{",
"$",
"finder",
"->",
"find",
"(",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"explodedPath",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
"if",
"(",
"$",
"explodedPath",
"[",
"0",
"]",
"===",
"'static'",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"explodedPath",
")",
">",
"1",
")",
"{",
"$",
"explodedPath",
"[",
"0",
"]",
"=",
"'shared'",
";",
"$",
"explodedPath",
"=",
"array",
"(",
"'shared'",
",",
"end",
"(",
"$",
"explodedPath",
")",
")",
";",
"try",
"{",
"$",
"finder",
"->",
"find",
"(",
"implode",
"(",
"'.'",
",",
"$",
"explodedPath",
")",
")",
";",
"$",
"path",
"=",
"implode",
"(",
"'.'",
",",
"$",
"explodedPath",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"error",
"(",
"$",
"e",
")",
";",
"}",
"}",
"}",
"return",
"$",
"path",
";",
"}"
] |
This method will try to find the existing of template file
@param string $path The relative template path
@return string
@throws InvalidArgumentException If we cannot find view
|
[
"This",
"method",
"will",
"try",
"to",
"find",
"the",
"existing",
"of",
"template",
"file"
] |
5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f
|
https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L351-L380
|
22,328
|
DevGroup-ru/yii2-users-module
|
src/models/User.php
|
User.rules
|
public function rules()
{
$module = UsersModule::module();
$rules = [
[
['phone'],
'safe',
],
[
[
'password',
],
'safe',
'on' => self::SCENARIO_DEFAULT,
],
[
[
'password',
],
'required',
'on' => self::SCENARIO_PASSWORD_RESET,
],
[
'username',
'unique',
],
[
'email',
'unique',
],
'standardEmailRules' => [
[
'email',
],
'email',
'checkDNS' => $module->authorizationScenario()->emailCheckDNS,
'enableIDN' => $module->authorizationScenario()->emailEnableIDN,
'skipOnEmpty' => true,
'on' => self::SCENARIO_PROFILE_UPDATE,
],
'trimEmail' => [
[
'email',
],
'filter',
'filter' => 'trim',
'on' => self::SCENARIO_PROFILE_UPDATE,
],
[
[
'username_is_temporary',
'password_is_temporary',
'is_active',
],
'filter',
'filter' => 'boolval',
]
];
$property_rules = $this->propertiesRules();
if (!empty($property_rules)) {
$rules = array_merge($rules, $property_rules);
}
if (count(UsersModule::module()->requiredUserAttributes) > 0) {
$rules['requiredAttributes'] = [
UsersModule::module()->requiredUserAttributes,
'required',
'on' => self::SCENARIO_PROFILE_UPDATE,
];
}
return $rules;
}
|
php
|
public function rules()
{
$module = UsersModule::module();
$rules = [
[
['phone'],
'safe',
],
[
[
'password',
],
'safe',
'on' => self::SCENARIO_DEFAULT,
],
[
[
'password',
],
'required',
'on' => self::SCENARIO_PASSWORD_RESET,
],
[
'username',
'unique',
],
[
'email',
'unique',
],
'standardEmailRules' => [
[
'email',
],
'email',
'checkDNS' => $module->authorizationScenario()->emailCheckDNS,
'enableIDN' => $module->authorizationScenario()->emailEnableIDN,
'skipOnEmpty' => true,
'on' => self::SCENARIO_PROFILE_UPDATE,
],
'trimEmail' => [
[
'email',
],
'filter',
'filter' => 'trim',
'on' => self::SCENARIO_PROFILE_UPDATE,
],
[
[
'username_is_temporary',
'password_is_temporary',
'is_active',
],
'filter',
'filter' => 'boolval',
]
];
$property_rules = $this->propertiesRules();
if (!empty($property_rules)) {
$rules = array_merge($rules, $property_rules);
}
if (count(UsersModule::module()->requiredUserAttributes) > 0) {
$rules['requiredAttributes'] = [
UsersModule::module()->requiredUserAttributes,
'required',
'on' => self::SCENARIO_PROFILE_UPDATE,
];
}
return $rules;
}
|
[
"public",
"function",
"rules",
"(",
")",
"{",
"$",
"module",
"=",
"UsersModule",
"::",
"module",
"(",
")",
";",
"$",
"rules",
"=",
"[",
"[",
"[",
"'phone'",
"]",
",",
"'safe'",
",",
"]",
",",
"[",
"[",
"'password'",
",",
"]",
",",
"'safe'",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_DEFAULT",
",",
"]",
",",
"[",
"[",
"'password'",
",",
"]",
",",
"'required'",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_PASSWORD_RESET",
",",
"]",
",",
"[",
"'username'",
",",
"'unique'",
",",
"]",
",",
"[",
"'email'",
",",
"'unique'",
",",
"]",
",",
"'standardEmailRules'",
"=>",
"[",
"[",
"'email'",
",",
"]",
",",
"'email'",
",",
"'checkDNS'",
"=>",
"$",
"module",
"->",
"authorizationScenario",
"(",
")",
"->",
"emailCheckDNS",
",",
"'enableIDN'",
"=>",
"$",
"module",
"->",
"authorizationScenario",
"(",
")",
"->",
"emailEnableIDN",
",",
"'skipOnEmpty'",
"=>",
"true",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_PROFILE_UPDATE",
",",
"]",
",",
"'trimEmail'",
"=>",
"[",
"[",
"'email'",
",",
"]",
",",
"'filter'",
",",
"'filter'",
"=>",
"'trim'",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_PROFILE_UPDATE",
",",
"]",
",",
"[",
"[",
"'username_is_temporary'",
",",
"'password_is_temporary'",
",",
"'is_active'",
",",
"]",
",",
"'filter'",
",",
"'filter'",
"=>",
"'boolval'",
",",
"]",
"]",
";",
"$",
"property_rules",
"=",
"$",
"this",
"->",
"propertiesRules",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"property_rules",
")",
")",
"{",
"$",
"rules",
"=",
"array_merge",
"(",
"$",
"rules",
",",
"$",
"property_rules",
")",
";",
"}",
"if",
"(",
"count",
"(",
"UsersModule",
"::",
"module",
"(",
")",
"->",
"requiredUserAttributes",
")",
">",
"0",
")",
"{",
"$",
"rules",
"[",
"'requiredAttributes'",
"]",
"=",
"[",
"UsersModule",
"::",
"module",
"(",
")",
"->",
"requiredUserAttributes",
",",
"'required'",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_PROFILE_UPDATE",
",",
"]",
";",
"}",
"return",
"$",
"rules",
";",
"}"
] |
Validation rules for this model.
|
[
"Validation",
"rules",
"for",
"this",
"model",
"."
] |
ff0103dc55c3462627ccc704c33e70c96053f750
|
https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/User.php#L118-L190
|
22,329
|
DevGroup-ru/yii2-users-module
|
src/models/User.php
|
User.afterFind
|
public function afterFind()
{
parent::afterFind();
$this->username_is_temporary = boolval($this->username_is_temporary);
$this->is_active = boolval($this->is_active);
}
|
php
|
public function afterFind()
{
parent::afterFind();
$this->username_is_temporary = boolval($this->username_is_temporary);
$this->is_active = boolval($this->is_active);
}
|
[
"public",
"function",
"afterFind",
"(",
")",
"{",
"parent",
"::",
"afterFind",
"(",
")",
";",
"$",
"this",
"->",
"username_is_temporary",
"=",
"boolval",
"(",
"$",
"this",
"->",
"username_is_temporary",
")",
";",
"$",
"this",
"->",
"is_active",
"=",
"boolval",
"(",
"$",
"this",
"->",
"is_active",
")",
";",
"}"
] |
Performs after find action and casts attributes to proper type
|
[
"Performs",
"after",
"find",
"action",
"and",
"casts",
"attributes",
"to",
"proper",
"type"
] |
ff0103dc55c3462627ccc704c33e70c96053f750
|
https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/User.php#L213-L218
|
22,330
|
DevGroup-ru/yii2-users-module
|
src/models/User.php
|
User.register
|
public function register()
{
if ($this->getIsNewRecord() == false) {
throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
$module = UsersModule::module();
if (empty($this->password) === true) {
$this->password = PasswordHelper::generate($module->generatedPasswordLength);
}
if ($module->emailConfirmationNeeded === false) {
$this->is_active = true;
}
$event = new RegistrationEvent();
$this->trigger(self::EVENT_BEFORE_REGISTER, $event);
if ($event->isValid === false) {
return false;
}
if (!$this->save()) {
return false;
}
$this->trigger(self::EVENT_AFTER_REGISTER, $event);
return $this;
}
|
php
|
public function register()
{
if ($this->getIsNewRecord() == false) {
throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
$module = UsersModule::module();
if (empty($this->password) === true) {
$this->password = PasswordHelper::generate($module->generatedPasswordLength);
}
if ($module->emailConfirmationNeeded === false) {
$this->is_active = true;
}
$event = new RegistrationEvent();
$this->trigger(self::EVENT_BEFORE_REGISTER, $event);
if ($event->isValid === false) {
return false;
}
if (!$this->save()) {
return false;
}
$this->trigger(self::EVENT_AFTER_REGISTER, $event);
return $this;
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIsNewRecord",
"(",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Calling \"'",
".",
"__CLASS__",
".",
"'::'",
".",
"__METHOD__",
".",
"'\" on existing user'",
")",
";",
"}",
"$",
"module",
"=",
"UsersModule",
"::",
"module",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"password",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"password",
"=",
"PasswordHelper",
"::",
"generate",
"(",
"$",
"module",
"->",
"generatedPasswordLength",
")",
";",
"}",
"if",
"(",
"$",
"module",
"->",
"emailConfirmationNeeded",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"is_active",
"=",
"true",
";",
"}",
"$",
"event",
"=",
"new",
"RegistrationEvent",
"(",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_BEFORE_REGISTER",
",",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"->",
"isValid",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"save",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_AFTER_REGISTER",
",",
"$",
"event",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
This method is used to register new user account.
@return bool|User
|
[
"This",
"method",
"is",
"used",
"to",
"register",
"new",
"user",
"account",
"."
] |
ff0103dc55c3462627ccc704c33e70c96053f750
|
https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/User.php#L285-L314
|
22,331
|
DevGroup-ru/yii2-users-module
|
src/models/User.php
|
User.login
|
public function login($loginDuration = 0)
{
$loginStatus = Yii::$app->getUser()->login($this, $loginDuration);
if ($loginStatus) {
$this->trigger(User::EVENT_LOGIN);
}
return $loginStatus;
}
|
php
|
public function login($loginDuration = 0)
{
$loginStatus = Yii::$app->getUser()->login($this, $loginDuration);
if ($loginStatus) {
$this->trigger(User::EVENT_LOGIN);
}
return $loginStatus;
}
|
[
"public",
"function",
"login",
"(",
"$",
"loginDuration",
"=",
"0",
")",
"{",
"$",
"loginStatus",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getUser",
"(",
")",
"->",
"login",
"(",
"$",
"this",
",",
"$",
"loginDuration",
")",
";",
"if",
"(",
"$",
"loginStatus",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"User",
"::",
"EVENT_LOGIN",
")",
";",
"}",
"return",
"$",
"loginStatus",
";",
"}"
] |
Login user.
@param integer $loginDuration
@return bool true if success
|
[
"Login",
"user",
"."
] |
ff0103dc55c3462627ccc704c33e70c96053f750
|
https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/User.php#L321-L328
|
22,332
|
SporkCode/Spork
|
src/CSS/UpdateListener.php
|
UpdateListener.getFileKey
|
protected function getFileKey($basePath, \SplFileInfo $file)
{
$baseLength = strlen(rtrim($basePath, DIRECTORY_SEPARATOR));
return substr($file->getPath(), $baseLength) . DIRECTORY_SEPARATOR
. $file->getBasename('.' . $file->getExtension());
}
|
php
|
protected function getFileKey($basePath, \SplFileInfo $file)
{
$baseLength = strlen(rtrim($basePath, DIRECTORY_SEPARATOR));
return substr($file->getPath(), $baseLength) . DIRECTORY_SEPARATOR
. $file->getBasename('.' . $file->getExtension());
}
|
[
"protected",
"function",
"getFileKey",
"(",
"$",
"basePath",
",",
"\\",
"SplFileInfo",
"$",
"file",
")",
"{",
"$",
"baseLength",
"=",
"strlen",
"(",
"rtrim",
"(",
"$",
"basePath",
",",
"DIRECTORY_SEPARATOR",
")",
")",
";",
"return",
"substr",
"(",
"$",
"file",
"->",
"getPath",
"(",
")",
",",
"$",
"baseLength",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
"->",
"getBasename",
"(",
"'.'",
".",
"$",
"file",
"->",
"getExtension",
"(",
")",
")",
";",
"}"
] |
Get relative key for a file
@param string $basepath
@param \SplFileInfo $file
|
[
"Get",
"relative",
"key",
"for",
"a",
"file"
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/CSS/UpdateListener.php#L200-L206
|
22,333
|
SporkCode/Spork
|
src/CSS/UpdateListener.php
|
UpdateListener.isOutOfDate
|
protected function isOutOfDate($source, $destination, array $includes = null)
{
$includes = (array) $includes;
$extensions = $this->compiler->getExtensions();
if (!file_exists($destination)) {
return true;
}
if (is_file($source) && is_file($destination)) {
$sourceFiles = array(new \SplFileInfo($source));
$destinationFiles = array(new \SplFileInfo($destination));
} else {
$sourceFiles = $this->scanDirectory($source, $extensions);
$destinationFiles = $this->scanDirectory($destination, array('css'));
}
$youngest = time();
foreach ($sourceFiles as $key => $file) {
if (array_key_exists($key, $destinationFiles)) {
if ($file->getMTime() > $destinationFiles[$key]->getMTime()) {
return true;
}
if ($file->getMTime() < $youngest) {
$youngest = $file->getMTime();
}
} else {
return true;
}
}
// $oldest = time();
// foreach ($destinationFiles as $file) {
// $modified = $file->getMTime();
// if ($modified < $oldest) {
// $oldest = $modified;
// }
// }
foreach ($includes as $include) {
$includeFiles = $this->scanDirectory($include, $extensions);
foreach ($includeFiles as $file) {
if ($file->getMTime() > $youngest) {
return true;
}
}
}
return false;
}
|
php
|
protected function isOutOfDate($source, $destination, array $includes = null)
{
$includes = (array) $includes;
$extensions = $this->compiler->getExtensions();
if (!file_exists($destination)) {
return true;
}
if (is_file($source) && is_file($destination)) {
$sourceFiles = array(new \SplFileInfo($source));
$destinationFiles = array(new \SplFileInfo($destination));
} else {
$sourceFiles = $this->scanDirectory($source, $extensions);
$destinationFiles = $this->scanDirectory($destination, array('css'));
}
$youngest = time();
foreach ($sourceFiles as $key => $file) {
if (array_key_exists($key, $destinationFiles)) {
if ($file->getMTime() > $destinationFiles[$key]->getMTime()) {
return true;
}
if ($file->getMTime() < $youngest) {
$youngest = $file->getMTime();
}
} else {
return true;
}
}
// $oldest = time();
// foreach ($destinationFiles as $file) {
// $modified = $file->getMTime();
// if ($modified < $oldest) {
// $oldest = $modified;
// }
// }
foreach ($includes as $include) {
$includeFiles = $this->scanDirectory($include, $extensions);
foreach ($includeFiles as $file) {
if ($file->getMTime() > $youngest) {
return true;
}
}
}
return false;
}
|
[
"protected",
"function",
"isOutOfDate",
"(",
"$",
"source",
",",
"$",
"destination",
",",
"array",
"$",
"includes",
"=",
"null",
")",
"{",
"$",
"includes",
"=",
"(",
"array",
")",
"$",
"includes",
";",
"$",
"extensions",
"=",
"$",
"this",
"->",
"compiler",
"->",
"getExtensions",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"destination",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"source",
")",
"&&",
"is_file",
"(",
"$",
"destination",
")",
")",
"{",
"$",
"sourceFiles",
"=",
"array",
"(",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"source",
")",
")",
";",
"$",
"destinationFiles",
"=",
"array",
"(",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"destination",
")",
")",
";",
"}",
"else",
"{",
"$",
"sourceFiles",
"=",
"$",
"this",
"->",
"scanDirectory",
"(",
"$",
"source",
",",
"$",
"extensions",
")",
";",
"$",
"destinationFiles",
"=",
"$",
"this",
"->",
"scanDirectory",
"(",
"$",
"destination",
",",
"array",
"(",
"'css'",
")",
")",
";",
"}",
"$",
"youngest",
"=",
"time",
"(",
")",
";",
"foreach",
"(",
"$",
"sourceFiles",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"destinationFiles",
")",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"getMTime",
"(",
")",
">",
"$",
"destinationFiles",
"[",
"$",
"key",
"]",
"->",
"getMTime",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"file",
"->",
"getMTime",
"(",
")",
"<",
"$",
"youngest",
")",
"{",
"$",
"youngest",
"=",
"$",
"file",
"->",
"getMTime",
"(",
")",
";",
"}",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"// $oldest = time();",
"// foreach ($destinationFiles as $file) {",
"// $modified = $file->getMTime(); ",
"// if ($modified < $oldest) {",
"// $oldest = $modified;",
"// }",
"// }",
"foreach",
"(",
"$",
"includes",
"as",
"$",
"include",
")",
"{",
"$",
"includeFiles",
"=",
"$",
"this",
"->",
"scanDirectory",
"(",
"$",
"include",
",",
"$",
"extensions",
")",
";",
"foreach",
"(",
"$",
"includeFiles",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"getMTime",
"(",
")",
">",
"$",
"youngest",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Test is destination file or folder is out of date from the source.
@param string $source
@param string $destination
@return boolean
|
[
"Test",
"is",
"destination",
"file",
"or",
"folder",
"is",
"out",
"of",
"date",
"from",
"the",
"source",
"."
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/CSS/UpdateListener.php#L215-L264
|
22,334
|
SporkCode/Spork
|
src/CSS/UpdateListener.php
|
UpdateListener.scanDirectory
|
protected function scanDirectory($path, $extensions)
{
if (is_file($path)) {
$file = new \SplFileInfo($path);
return array($this->getFileKey($file->getPath(), $file) => $file);
}
$files = array();
$extensions = (array) $extensions;
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$path,
\FileSystemIterator::SKIP_DOTS
| \FileSystemIterator::CURRENT_AS_FILEINFO)
);
foreach ($iterator as $file) {
if (in_array($file->getExtension(), $extensions)) {
$files[$this->getFileKey($path, $file)] = $file;
}
}
return $files;
}
|
php
|
protected function scanDirectory($path, $extensions)
{
if (is_file($path)) {
$file = new \SplFileInfo($path);
return array($this->getFileKey($file->getPath(), $file) => $file);
}
$files = array();
$extensions = (array) $extensions;
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$path,
\FileSystemIterator::SKIP_DOTS
| \FileSystemIterator::CURRENT_AS_FILEINFO)
);
foreach ($iterator as $file) {
if (in_array($file->getExtension(), $extensions)) {
$files[$this->getFileKey($path, $file)] = $file;
}
}
return $files;
}
|
[
"protected",
"function",
"scanDirectory",
"(",
"$",
"path",
",",
"$",
"extensions",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"$",
"file",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"path",
")",
";",
"return",
"array",
"(",
"$",
"this",
"->",
"getFileKey",
"(",
"$",
"file",
"->",
"getPath",
"(",
")",
",",
"$",
"file",
")",
"=>",
"$",
"file",
")",
";",
"}",
"$",
"files",
"=",
"array",
"(",
")",
";",
"$",
"extensions",
"=",
"(",
"array",
")",
"$",
"extensions",
";",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"path",
",",
"\\",
"FileSystemIterator",
"::",
"SKIP_DOTS",
"|",
"\\",
"FileSystemIterator",
"::",
"CURRENT_AS_FILEINFO",
")",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"file",
"->",
"getExtension",
"(",
")",
",",
"$",
"extensions",
")",
")",
"{",
"$",
"files",
"[",
"$",
"this",
"->",
"getFileKey",
"(",
"$",
"path",
",",
"$",
"file",
")",
"]",
"=",
"$",
"file",
";",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] |
Scan a directory and return a list of files with matching extenstions
@param string $path Directory path to scan
@param string|array $extensions Match files with these extensions
|
[
"Scan",
"a",
"directory",
"and",
"return",
"a",
"list",
"of",
"files",
"with",
"matching",
"extenstions"
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/CSS/UpdateListener.php#L272-L293
|
22,335
|
FrenzelGmbH/cm-address
|
controllers/DefaultController.php
|
DefaultController.actionCreate
|
public function actionCreate()
{
$model = new Address(['scenario' => 'create']);
Yii::$app->response->format = Response::FORMAT_JSON;
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
if ($model->save(false)) {
return $this->tree($model);
} else {
Yii::$app->response->setStatusCode(500);
return \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_FAIL_CREATE');
}
} elseif (Yii::$app->request->isAjax) {
Yii::$app->response->setStatusCode(400);
return ActiveForm::validate($model);
}
}
}
|
php
|
public function actionCreate()
{
$model = new Address(['scenario' => 'create']);
Yii::$app->response->format = Response::FORMAT_JSON;
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
if ($model->save(false)) {
return $this->tree($model);
} else {
Yii::$app->response->setStatusCode(500);
return \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_FAIL_CREATE');
}
} elseif (Yii::$app->request->isAjax) {
Yii::$app->response->setStatusCode(400);
return ActiveForm::validate($model);
}
}
}
|
[
"public",
"function",
"actionCreate",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"Address",
"(",
"[",
"'scenario'",
"=>",
"'create'",
"]",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"validate",
"(",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"save",
"(",
"false",
")",
")",
"{",
"return",
"$",
"this",
"->",
"tree",
"(",
"$",
"model",
")",
";",
"}",
"else",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"setStatusCode",
"(",
"500",
")",
";",
"return",
"\\",
"Yii",
"::",
"t",
"(",
"'net_frenzel_address'",
",",
"'FRONTEND_FLASH_FAIL_CREATE'",
")",
";",
"}",
"}",
"elseif",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"setStatusCode",
"(",
"400",
")",
";",
"return",
"ActiveForm",
"::",
"validate",
"(",
"$",
"model",
")",
";",
"}",
"}",
"}"
] |
Create Address.
|
[
"Create",
"Address",
"."
] |
4295671dc603beed4bea6c5a7f77dac9846127f3
|
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/DefaultController.php#L46-L63
|
22,336
|
FrenzelGmbH/cm-address
|
controllers/DefaultController.php
|
DefaultController.actionUpdate
|
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->setScenario('update');
Yii::$app->response->format = Response::FORMAT_JSON;
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
if ($model->save(false)) {
return $this->renderAjax('@vendor/frenzelgmbh/cm-address/views/widgets/views/_index_single_item', ['model' => $model]);
} else {
Yii::$app->response->setStatusCode(500);
return \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_FAIL_UPDATE');
}
} elseif (Yii::$app->request->isAjax) {
Yii::$app->response->setStatusCode(400);
return ActiveForm::validate($model);
}
}
}
|
php
|
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->setScenario('update');
Yii::$app->response->format = Response::FORMAT_JSON;
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
if ($model->save(false)) {
return $this->renderAjax('@vendor/frenzelgmbh/cm-address/views/widgets/views/_index_single_item', ['model' => $model]);
} else {
Yii::$app->response->setStatusCode(500);
return \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_FAIL_UPDATE');
}
} elseif (Yii::$app->request->isAjax) {
Yii::$app->response->setStatusCode(400);
return ActiveForm::validate($model);
}
}
}
|
[
"public",
"function",
"actionUpdate",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"->",
"setScenario",
"(",
"'update'",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"validate",
"(",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"save",
"(",
"false",
")",
")",
"{",
"return",
"$",
"this",
"->",
"renderAjax",
"(",
"'@vendor/frenzelgmbh/cm-address/views/widgets/views/_index_single_item'",
",",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}",
"else",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"setStatusCode",
"(",
"500",
")",
";",
"return",
"\\",
"Yii",
"::",
"t",
"(",
"'net_frenzel_address'",
",",
"'FRONTEND_FLASH_FAIL_UPDATE'",
")",
";",
"}",
"}",
"elseif",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"setStatusCode",
"(",
"400",
")",
";",
"return",
"ActiveForm",
"::",
"validate",
"(",
"$",
"model",
")",
";",
"}",
"}",
"}"
] |
Update Communication.
@param integer $id Communication ID
@return mixed
|
[
"Update",
"Communication",
"."
] |
4295671dc603beed4bea6c5a7f77dac9846127f3
|
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/DefaultController.php#L71-L89
|
22,337
|
FrenzelGmbH/cm-address
|
controllers/DefaultController.php
|
DefaultController.actionFetch
|
public function actionFetch($id)
{
$model = $this->findModel($id);
$model->setScenario('update');
Yii::$app->response->format = Response::FORMAT_HTML;
return $this->renderAjax('@vendor/frenzelgmbh/cm-address/views/widgets/views/_form_update', ['model' => $model]);
}
|
php
|
public function actionFetch($id)
{
$model = $this->findModel($id);
$model->setScenario('update');
Yii::$app->response->format = Response::FORMAT_HTML;
return $this->renderAjax('@vendor/frenzelgmbh/cm-address/views/widgets/views/_form_update', ['model' => $model]);
}
|
[
"public",
"function",
"actionFetch",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"->",
"setScenario",
"(",
"'update'",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_HTML",
";",
"return",
"$",
"this",
"->",
"renderAjax",
"(",
"'@vendor/frenzelgmbh/cm-address/views/widgets/views/_form_update'",
",",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] |
fetch Communication.
@param integer $id Communication ID
@return mixed
|
[
"fetch",
"Communication",
"."
] |
4295671dc603beed4bea6c5a7f77dac9846127f3
|
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/DefaultController.php#L97-L103
|
22,338
|
globalis-ms/wp-cubi-robo
|
src/GitTrait.php
|
GitTrait.hotfixStart
|
public function hotfixStart($options = ['semversion' => null, 'type' => 'patch'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskHotfixStart((string)$version)->run();
}
|
php
|
public function hotfixStart($options = ['semversion' => null, 'type' => 'patch'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskHotfixStart((string)$version)->run();
}
|
[
"public",
"function",
"hotfixStart",
"(",
"$",
"options",
"=",
"[",
"'semversion'",
"=>",
"null",
",",
"'type'",
"=>",
"'patch'",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'semversion'",
"]",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
"->",
"increment",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"version",
"=",
"$",
"options",
"[",
"'semversion'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"taskHotfixStart",
"(",
"(",
"string",
")",
"$",
"version",
")",
"->",
"run",
"(",
")",
";",
"}"
] |
Start a new hotfix
@option string $semversion Version number
@option string $type Hotfix type (path, minor)
|
[
"Start",
"a",
"new",
"hotfix"
] |
4acc9d37c77e24a968a950d59b5ba53818c53bc1
|
https://github.com/globalis-ms/wp-cubi-robo/blob/4acc9d37c77e24a968a950d59b5ba53818c53bc1/src/GitTrait.php#L36-L45
|
22,339
|
globalis-ms/wp-cubi-robo
|
src/GitTrait.php
|
GitTrait.hotfixFinish
|
public function hotfixFinish($options = ['semversion' => null, 'type' => 'patch'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskHotfixFinish((string)$version)->run();
}
|
php
|
public function hotfixFinish($options = ['semversion' => null, 'type' => 'patch'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskHotfixFinish((string)$version)->run();
}
|
[
"public",
"function",
"hotfixFinish",
"(",
"$",
"options",
"=",
"[",
"'semversion'",
"=>",
"null",
",",
"'type'",
"=>",
"'patch'",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'semversion'",
"]",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
"->",
"increment",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"version",
"=",
"$",
"options",
"[",
"'semversion'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"taskHotfixFinish",
"(",
"(",
"string",
")",
"$",
"version",
")",
"->",
"run",
"(",
")",
";",
"}"
] |
Finish a hotfix
@option string $semversion Version number
@option string $type Hotfix type (path, minor)
|
[
"Finish",
"a",
"hotfix"
] |
4acc9d37c77e24a968a950d59b5ba53818c53bc1
|
https://github.com/globalis-ms/wp-cubi-robo/blob/4acc9d37c77e24a968a950d59b5ba53818c53bc1/src/GitTrait.php#L53-L62
|
22,340
|
globalis-ms/wp-cubi-robo
|
src/GitTrait.php
|
GitTrait.releaseStart
|
public function releaseStart($options = ['semversion' => null, 'type' => 'minor'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskReleaseStart((string)$version)->run();
}
|
php
|
public function releaseStart($options = ['semversion' => null, 'type' => 'minor'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskReleaseStart((string)$version)->run();
}
|
[
"public",
"function",
"releaseStart",
"(",
"$",
"options",
"=",
"[",
"'semversion'",
"=>",
"null",
",",
"'type'",
"=>",
"'minor'",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'semversion'",
"]",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
"->",
"increment",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"version",
"=",
"$",
"options",
"[",
"'semversion'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"taskReleaseStart",
"(",
"(",
"string",
")",
"$",
"version",
")",
"->",
"run",
"(",
")",
";",
"}"
] |
Start a new release
@option string $semversion Version number
@option string $type Relase type (minor, major)
|
[
"Start",
"a",
"new",
"release"
] |
4acc9d37c77e24a968a950d59b5ba53818c53bc1
|
https://github.com/globalis-ms/wp-cubi-robo/blob/4acc9d37c77e24a968a950d59b5ba53818c53bc1/src/GitTrait.php#L70-L79
|
22,341
|
globalis-ms/wp-cubi-robo
|
src/GitTrait.php
|
GitTrait.releaseFinish
|
public function releaseFinish($options = ['semversion' => null, 'type' => 'minor'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskReleaseFinish((string)$version)->run();
}
|
php
|
public function releaseFinish($options = ['semversion' => null, 'type' => 'minor'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskReleaseFinish((string)$version)->run();
}
|
[
"public",
"function",
"releaseFinish",
"(",
"$",
"options",
"=",
"[",
"'semversion'",
"=>",
"null",
",",
"'type'",
"=>",
"'minor'",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'semversion'",
"]",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
"->",
"increment",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"version",
"=",
"$",
"options",
"[",
"'semversion'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"taskReleaseFinish",
"(",
"(",
"string",
")",
"$",
"version",
")",
"->",
"run",
"(",
")",
";",
"}"
] |
Finish a release
@option string $semversion Version number
@option string $type Relase type (minor, major)
|
[
"Finish",
"a",
"release"
] |
4acc9d37c77e24a968a950d59b5ba53818c53bc1
|
https://github.com/globalis-ms/wp-cubi-robo/blob/4acc9d37c77e24a968a950d59b5ba53818c53bc1/src/GitTrait.php#L87-L96
|
22,342
|
globalis-ms/wp-cubi-robo
|
src/GitTrait.php
|
GitTrait.getVersion
|
protected function getVersion()
{
// Get version from tag
$cmd = new Command('git');
$cmd = $cmd->arg('tag')
->execute();
$output = explode(PHP_EOL, trim($cmd->getOutput()));
$currentVersion = '0.0.0';
foreach ($output as $tag) {
if (preg_match(SemanticVersion::REGEX, $tag)) {
if (version_compare($currentVersion, $tag, '<')) {
$currentVersion = $tag;
}
}
}
return new SemanticVersion($currentVersion);
}
|
php
|
protected function getVersion()
{
// Get version from tag
$cmd = new Command('git');
$cmd = $cmd->arg('tag')
->execute();
$output = explode(PHP_EOL, trim($cmd->getOutput()));
$currentVersion = '0.0.0';
foreach ($output as $tag) {
if (preg_match(SemanticVersion::REGEX, $tag)) {
if (version_compare($currentVersion, $tag, '<')) {
$currentVersion = $tag;
}
}
}
return new SemanticVersion($currentVersion);
}
|
[
"protected",
"function",
"getVersion",
"(",
")",
"{",
"// Get version from tag",
"$",
"cmd",
"=",
"new",
"Command",
"(",
"'git'",
")",
";",
"$",
"cmd",
"=",
"$",
"cmd",
"->",
"arg",
"(",
"'tag'",
")",
"->",
"execute",
"(",
")",
";",
"$",
"output",
"=",
"explode",
"(",
"PHP_EOL",
",",
"trim",
"(",
"$",
"cmd",
"->",
"getOutput",
"(",
")",
")",
")",
";",
"$",
"currentVersion",
"=",
"'0.0.0'",
";",
"foreach",
"(",
"$",
"output",
"as",
"$",
"tag",
")",
"{",
"if",
"(",
"preg_match",
"(",
"SemanticVersion",
"::",
"REGEX",
",",
"$",
"tag",
")",
")",
"{",
"if",
"(",
"version_compare",
"(",
"$",
"currentVersion",
",",
"$",
"tag",
",",
"'<'",
")",
")",
"{",
"$",
"currentVersion",
"=",
"$",
"tag",
";",
"}",
"}",
"}",
"return",
"new",
"SemanticVersion",
"(",
"$",
"currentVersion",
")",
";",
"}"
] |
Return current version
@return SemanticVersion
|
[
"Return",
"current",
"version"
] |
4acc9d37c77e24a968a950d59b5ba53818c53bc1
|
https://github.com/globalis-ms/wp-cubi-robo/blob/4acc9d37c77e24a968a950d59b5ba53818c53bc1/src/GitTrait.php#L183-L199
|
22,343
|
xiewulong/yii2-fileupload
|
oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMultiProxy.php
|
CurlMultiProxy.getAvailableHandle
|
protected function getAvailableHandle()
{
// Grab a handle that is not claimed
foreach ($this->handles as $h) {
if (!in_array($h, $this->groups, true)) {
return $h;
}
}
// All are claimed, so create one
$handle = new CurlMulti();
$handle->setEventDispatcher($this->getEventDispatcher());
$this->handles[] = $handle;
return $handle;
}
|
php
|
protected function getAvailableHandle()
{
// Grab a handle that is not claimed
foreach ($this->handles as $h) {
if (!in_array($h, $this->groups, true)) {
return $h;
}
}
// All are claimed, so create one
$handle = new CurlMulti();
$handle->setEventDispatcher($this->getEventDispatcher());
$this->handles[] = $handle;
return $handle;
}
|
[
"protected",
"function",
"getAvailableHandle",
"(",
")",
"{",
"// Grab a handle that is not claimed",
"foreach",
"(",
"$",
"this",
"->",
"handles",
"as",
"$",
"h",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"h",
",",
"$",
"this",
"->",
"groups",
",",
"true",
")",
")",
"{",
"return",
"$",
"h",
";",
"}",
"}",
"// All are claimed, so create one",
"$",
"handle",
"=",
"new",
"CurlMulti",
"(",
")",
";",
"$",
"handle",
"->",
"setEventDispatcher",
"(",
"$",
"this",
"->",
"getEventDispatcher",
"(",
")",
")",
";",
"$",
"this",
"->",
"handles",
"[",
"]",
"=",
"$",
"handle",
";",
"return",
"$",
"handle",
";",
"}"
] |
Get an existing available CurlMulti handle or create a new one
@return CurlMulti
|
[
"Get",
"an",
"existing",
"available",
"CurlMulti",
"handle",
"or",
"create",
"a",
"new",
"one"
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMultiProxy.php#L115-L130
|
22,344
|
HedronDev/hedron
|
src/Bootstrap.php
|
Bootstrap.getConfiguration
|
public static function getConfiguration(string $input) {
list($oldrev, $newrev, $refname) = explode(' ', $input);
list(,, $branch) = explode('/', $refname);
return new ParserVariableConfiguration($oldrev, $newrev, $refname, $branch);
}
|
php
|
public static function getConfiguration(string $input) {
list($oldrev, $newrev, $refname) = explode(' ', $input);
list(,, $branch) = explode('/', $refname);
return new ParserVariableConfiguration($oldrev, $newrev, $refname, $branch);
}
|
[
"public",
"static",
"function",
"getConfiguration",
"(",
"string",
"$",
"input",
")",
"{",
"list",
"(",
"$",
"oldrev",
",",
"$",
"newrev",
",",
"$",
"refname",
")",
"=",
"explode",
"(",
"' '",
",",
"$",
"input",
")",
";",
"list",
"(",
",",
",",
"$",
"branch",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"refname",
")",
";",
"return",
"new",
"ParserVariableConfiguration",
"(",
"$",
"oldrev",
",",
"$",
"newrev",
",",
"$",
"refname",
",",
"$",
"branch",
")",
";",
"}"
] |
Extracts data from the post-receive hook as configuration for easy use.
@param string $input
Input to the post-receive git hook
@return \Hedron\Configuration\ParserVariableConfiguration
A simple configuration object.
|
[
"Extracts",
"data",
"from",
"the",
"post",
"-",
"receive",
"hook",
"as",
"configuration",
"for",
"easy",
"use",
"."
] |
3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00
|
https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Bootstrap.php#L48-L52
|
22,345
|
HedronDev/hedron
|
src/Bootstrap.php
|
Bootstrap.getEnvironmentVariables
|
public static function getEnvironmentVariables() {
$dir = shell_exec('pwd');
$dir_parts = explode(DIRECTORY_SEPARATOR, $dir);
$project = trim(array_pop($dir_parts));
$client = trim(array_pop($dir_parts));
$dir = $dir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'project' . DIRECTORY_SEPARATOR . $client . DIRECTORY_SEPARATOR . $project;
$environment_file = file_get_contents($dir . DIRECTORY_SEPARATOR . 'environment.yml');
if (!$environment_file) {
throw new MissingEnvironmentConfigurationException("The environment configuration is missing, please contact your administrator.");
}
return new EnvironmentVariables(Yaml::parse($environment_file));
}
|
php
|
public static function getEnvironmentVariables() {
$dir = shell_exec('pwd');
$dir_parts = explode(DIRECTORY_SEPARATOR, $dir);
$project = trim(array_pop($dir_parts));
$client = trim(array_pop($dir_parts));
$dir = $dir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'project' . DIRECTORY_SEPARATOR . $client . DIRECTORY_SEPARATOR . $project;
$environment_file = file_get_contents($dir . DIRECTORY_SEPARATOR . 'environment.yml');
if (!$environment_file) {
throw new MissingEnvironmentConfigurationException("The environment configuration is missing, please contact your administrator.");
}
return new EnvironmentVariables(Yaml::parse($environment_file));
}
|
[
"public",
"static",
"function",
"getEnvironmentVariables",
"(",
")",
"{",
"$",
"dir",
"=",
"shell_exec",
"(",
"'pwd'",
")",
";",
"$",
"dir_parts",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"dir",
")",
";",
"$",
"project",
"=",
"trim",
"(",
"array_pop",
"(",
"$",
"dir_parts",
")",
")",
";",
"$",
"client",
"=",
"trim",
"(",
"array_pop",
"(",
"$",
"dir_parts",
")",
")",
";",
"$",
"dir",
"=",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"'project'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"client",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"project",
";",
"$",
"environment_file",
"=",
"file_get_contents",
"(",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"'environment.yml'",
")",
";",
"if",
"(",
"!",
"$",
"environment_file",
")",
"{",
"throw",
"new",
"MissingEnvironmentConfigurationException",
"(",
"\"The environment configuration is missing, please contact your administrator.\"",
")",
";",
"}",
"return",
"new",
"EnvironmentVariables",
"(",
"Yaml",
"::",
"parse",
"(",
"$",
"environment_file",
")",
")",
";",
"}"
] |
Bootstraps the environment variables.
@return \Hedron\Configuration\EnvironmentVariables
The environment variables from yaml.
@throws \Hedron\Exception\MissingEnvironmentConfigurationException
If the yaml file is missing, throws this exception.
|
[
"Bootstraps",
"the",
"environment",
"variables",
"."
] |
3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00
|
https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Bootstrap.php#L63-L74
|
22,346
|
HedronDev/hedron
|
src/Bootstrap.php
|
Bootstrap.collectServices
|
public static function collectServices(ContainerBuilder $container, \Traversable $namespaces) {
$service_directories = [];
foreach ($namespaces as $directory) {
// $directory will correspond to the src dir, so up one level.
$service_directories[] = $directory . DIRECTORY_SEPARATOR . '..';
}
$loader = new PhpFileLoader($container, new FileLocator($service_directories));
$loader->load('services.php');
}
|
php
|
public static function collectServices(ContainerBuilder $container, \Traversable $namespaces) {
$service_directories = [];
foreach ($namespaces as $directory) {
// $directory will correspond to the src dir, so up one level.
$service_directories[] = $directory . DIRECTORY_SEPARATOR . '..';
}
$loader = new PhpFileLoader($container, new FileLocator($service_directories));
$loader->load('services.php');
}
|
[
"public",
"static",
"function",
"collectServices",
"(",
"ContainerBuilder",
"$",
"container",
",",
"\\",
"Traversable",
"$",
"namespaces",
")",
"{",
"$",
"service_directories",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"directory",
")",
"{",
"// $directory will correspond to the src dir, so up one level.",
"$",
"service_directories",
"[",
"]",
"=",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
";",
"}",
"$",
"loader",
"=",
"new",
"PhpFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"$",
"service_directories",
")",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'services.php'",
")",
";",
"}"
] |
Iterate through all namespace dirs and add services to the container.
@param \Symfony\Component\DependencyInjection\ContainerBuilder $container
The container builder.
@param \Traversable $namespaces
The namespaces.
|
[
"Iterate",
"through",
"all",
"namespace",
"dirs",
"and",
"add",
"services",
"to",
"the",
"container",
"."
] |
3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00
|
https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Bootstrap.php#L84-L92
|
22,347
|
HedronDev/hedron
|
src/Bootstrap.php
|
Bootstrap.getValidParsers
|
public static function getValidParsers(ProjectTypeInterface $project, ParserDictionary $parserDictionary, EventDispatcherInterface $dispatcher) {
$parserSet = $project::getFileParsers($parserDictionary);
$event = new ParserSetEvent($project, $parserSet);
$dispatcher->dispatch(ProjectTypeInterface::COLLECT_PARSER_SET, $event);
$plugins = [];
foreach ($event->getParserDefinitionSet() as $parserDefinition) {
$plugins[] = $parserDictionary->createInstance($parserDefinition->getPluginId(), $parserDefinition, $project);
}
return $plugins;
}
|
php
|
public static function getValidParsers(ProjectTypeInterface $project, ParserDictionary $parserDictionary, EventDispatcherInterface $dispatcher) {
$parserSet = $project::getFileParsers($parserDictionary);
$event = new ParserSetEvent($project, $parserSet);
$dispatcher->dispatch(ProjectTypeInterface::COLLECT_PARSER_SET, $event);
$plugins = [];
foreach ($event->getParserDefinitionSet() as $parserDefinition) {
$plugins[] = $parserDictionary->createInstance($parserDefinition->getPluginId(), $parserDefinition, $project);
}
return $plugins;
}
|
[
"public",
"static",
"function",
"getValidParsers",
"(",
"ProjectTypeInterface",
"$",
"project",
",",
"ParserDictionary",
"$",
"parserDictionary",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"parserSet",
"=",
"$",
"project",
"::",
"getFileParsers",
"(",
"$",
"parserDictionary",
")",
";",
"$",
"event",
"=",
"new",
"ParserSetEvent",
"(",
"$",
"project",
",",
"$",
"parserSet",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"ProjectTypeInterface",
"::",
"COLLECT_PARSER_SET",
",",
"$",
"event",
")",
";",
"$",
"plugins",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"event",
"->",
"getParserDefinitionSet",
"(",
")",
"as",
"$",
"parserDefinition",
")",
"{",
"$",
"plugins",
"[",
"]",
"=",
"$",
"parserDictionary",
"->",
"createInstance",
"(",
"$",
"parserDefinition",
"->",
"getPluginId",
"(",
")",
",",
"$",
"parserDefinition",
",",
"$",
"project",
")",
";",
"}",
"return",
"$",
"plugins",
";",
"}"
] |
Gets an array of valid parser plugins for the project type.
@param \Hedron\ProjectTypeInterface $project
The project plugin for the current environment settings.
@param \Hedron\ParserDictionary $parserDictionary
The parser dictionary.
@param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
The event dispatcher.
@return \Hedron\FileParserInterface[]
The valid parser plugins.
|
[
"Gets",
"an",
"array",
"of",
"valid",
"parser",
"plugins",
"for",
"the",
"project",
"type",
"."
] |
3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00
|
https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Bootstrap.php#L120-L129
|
22,348
|
nathan-fiscaletti/extended-arrays
|
src/ExtendedArrays/Traits/Restricted.php
|
Restricted.offsetSet
|
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
throw new \Exception('Must supply key to modify an associative array.');
} else {
if ($this->_isFillable($offset)) {
$this->_args[$offset] = $value;
} else {
throw new \Exception('Cannot modify element \''.$offset.'\'. Not fillable.');
}
}
}
|
php
|
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
throw new \Exception('Must supply key to modify an associative array.');
} else {
if ($this->_isFillable($offset)) {
$this->_args[$offset] = $value;
} else {
throw new \Exception('Cannot modify element \''.$offset.'\'. Not fillable.');
}
}
}
|
[
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"offset",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Must supply key to modify an associative array.'",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"_isFillable",
"(",
"$",
"offset",
")",
")",
"{",
"$",
"this",
"->",
"_args",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cannot modify element \\''",
".",
"$",
"offset",
".",
"'\\'. Not fillable.'",
")",
";",
"}",
"}",
"}"
] |
Override the offsetSet function to enforce
the list of restricted keys.
@param mixed $offset
@param mixed $value
@throws \Exception
|
[
"Override",
"the",
"offsetSet",
"function",
"to",
"enforce",
"the",
"list",
"of",
"restricted",
"keys",
"."
] |
a641856115131f76417521d3e4aa2d951158050a
|
https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/Traits/Restricted.php#L51-L62
|
22,349
|
LordDashMe/wordpress-db-schema-extender
|
src/SchemaExtender.php
|
SchemaExtender.setSeedQuery
|
public function setSeedQuery($key, $value)
{
$index = $this->getSeedQueryIndex();
$this->seedQueries[$index][$key] = $value;
}
|
php
|
public function setSeedQuery($key, $value)
{
$index = $this->getSeedQueryIndex();
$this->seedQueries[$index][$key] = $value;
}
|
[
"public",
"function",
"setSeedQuery",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getSeedQueryIndex",
"(",
")",
";",
"$",
"this",
"->",
"seedQueries",
"[",
"$",
"index",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] |
The stter for the seed queries class property.
@param string $key
@param mixed $value
@return void
|
[
"The",
"stter",
"for",
"the",
"seed",
"queries",
"class",
"property",
"."
] |
1798435ec064256174b034a16d9683081c0c299f
|
https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L219-L224
|
22,350
|
LordDashMe/wordpress-db-schema-extender
|
src/SchemaExtender.php
|
SchemaExtender.getWordpressDatabaseInstance
|
protected function getWordpressDatabaseInstance()
{
global $wpdb;
if ((! \class_exists('wpdb')) || (! $wpdb) || (! $wpdb instanceof \wpdb)) {
throw InvalidDatabaseInstanceException::wordpressDatabaseIsNotSet();
}
$this->db = $wpdb;
}
|
php
|
protected function getWordpressDatabaseInstance()
{
global $wpdb;
if ((! \class_exists('wpdb')) || (! $wpdb) || (! $wpdb instanceof \wpdb)) {
throw InvalidDatabaseInstanceException::wordpressDatabaseIsNotSet();
}
$this->db = $wpdb;
}
|
[
"protected",
"function",
"getWordpressDatabaseInstance",
"(",
")",
"{",
"global",
"$",
"wpdb",
";",
"if",
"(",
"(",
"!",
"\\",
"class_exists",
"(",
"'wpdb'",
")",
")",
"||",
"(",
"!",
"$",
"wpdb",
")",
"||",
"(",
"!",
"$",
"wpdb",
"instanceof",
"\\",
"wpdb",
")",
")",
"{",
"throw",
"InvalidDatabaseInstanceException",
"::",
"wordpressDatabaseIsNotSet",
"(",
")",
";",
"}",
"$",
"this",
"->",
"db",
"=",
"$",
"wpdb",
";",
"}"
] |
Tightly coupled to the wordpress database instance.
@throws LordDashMe\Wordpress\DB\Exception\InvalidDatabaseInstance
@return void
|
[
"Tightly",
"coupled",
"to",
"the",
"wordpress",
"database",
"instance",
"."
] |
1798435ec064256174b034a16d9683081c0c299f
|
https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L302-L311
|
22,351
|
LordDashMe/wordpress-db-schema-extender
|
src/SchemaExtender.php
|
SchemaExtender.table
|
public function table($name, $callback = null)
{
if (! $callback instanceof \Closure) {
throw InvalidArgumentPassedException::isNotClosure();
}
$this->setTableName($name);
$callback($this);
$tableNamePrefixed = $this->getTableNamePrefix($this->getTableName());
$tableStructure = \substr($this->getColumnsQuery() . $this->getPrimaryKeyQuery(), 0, -2);
$tableCharsetCollate = $this->getCharacterSetCollate();
$this->buildCreateTableQuery($tableNamePrefixed, $tableStructure, $tableCharsetCollate);
$this->flushColumns();
$this->flushPrimaryKey();
}
|
php
|
public function table($name, $callback = null)
{
if (! $callback instanceof \Closure) {
throw InvalidArgumentPassedException::isNotClosure();
}
$this->setTableName($name);
$callback($this);
$tableNamePrefixed = $this->getTableNamePrefix($this->getTableName());
$tableStructure = \substr($this->getColumnsQuery() . $this->getPrimaryKeyQuery(), 0, -2);
$tableCharsetCollate = $this->getCharacterSetCollate();
$this->buildCreateTableQuery($tableNamePrefixed, $tableStructure, $tableCharsetCollate);
$this->flushColumns();
$this->flushPrimaryKey();
}
|
[
"public",
"function",
"table",
"(",
"$",
"name",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"callback",
"instanceof",
"\\",
"Closure",
")",
"{",
"throw",
"InvalidArgumentPassedException",
"::",
"isNotClosure",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setTableName",
"(",
"$",
"name",
")",
";",
"$",
"callback",
"(",
"$",
"this",
")",
";",
"$",
"tableNamePrefixed",
"=",
"$",
"this",
"->",
"getTableNamePrefix",
"(",
"$",
"this",
"->",
"getTableName",
"(",
")",
")",
";",
"$",
"tableStructure",
"=",
"\\",
"substr",
"(",
"$",
"this",
"->",
"getColumnsQuery",
"(",
")",
".",
"$",
"this",
"->",
"getPrimaryKeyQuery",
"(",
")",
",",
"0",
",",
"-",
"2",
")",
";",
"$",
"tableCharsetCollate",
"=",
"$",
"this",
"->",
"getCharacterSetCollate",
"(",
")",
";",
"$",
"this",
"->",
"buildCreateTableQuery",
"(",
"$",
"tableNamePrefixed",
",",
"$",
"tableStructure",
",",
"$",
"tableCharsetCollate",
")",
";",
"$",
"this",
"->",
"flushColumns",
"(",
")",
";",
"$",
"this",
"->",
"flushPrimaryKey",
"(",
")",
";",
"}"
] |
The composer of the database table schema.
@param string $name
@param \Closure $callback
@throws LordDashMe\Wordpress\DB\Exception\InvalidArgumentPassed
@return void
|
[
"The",
"composer",
"of",
"the",
"database",
"table",
"schema",
"."
] |
1798435ec064256174b034a16d9683081c0c299f
|
https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L323-L341
|
22,352
|
LordDashMe/wordpress-db-schema-extender
|
src/SchemaExtender.php
|
SchemaExtender.buildCreateTableQuery
|
protected function buildCreateTableQuery($name, $struture, $charsetCollate)
{
$total = $this->totalQueries();
$this->queries[$total] = "CREATE TABLE `{$name}` ({$struture}) {$charsetCollate};";
}
|
php
|
protected function buildCreateTableQuery($name, $struture, $charsetCollate)
{
$total = $this->totalQueries();
$this->queries[$total] = "CREATE TABLE `{$name}` ({$struture}) {$charsetCollate};";
}
|
[
"protected",
"function",
"buildCreateTableQuery",
"(",
"$",
"name",
",",
"$",
"struture",
",",
"$",
"charsetCollate",
")",
"{",
"$",
"total",
"=",
"$",
"this",
"->",
"totalQueries",
"(",
")",
";",
"$",
"this",
"->",
"queries",
"[",
"$",
"total",
"]",
"=",
"\"CREATE TABLE `{$name}` ({$struture}) {$charsetCollate};\"",
";",
"}"
] |
Build a create table query base on the complete details given.
@param string $name The table name with prefix.
@param string $structure The structure of the tables containing columns, etc.
@param string $charsetCollate The character set for the table structure.
@return void
|
[
"Build",
"a",
"create",
"table",
"query",
"base",
"on",
"the",
"complete",
"details",
"given",
"."
] |
1798435ec064256174b034a16d9683081c0c299f
|
https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L382-L387
|
22,353
|
LordDashMe/wordpress-db-schema-extender
|
src/SchemaExtender.php
|
SchemaExtender.tableSeed
|
public function tableSeed($tableName, $callback)
{
if (! is_array($callback) && ! ($callback instanceof \Closure)) {
throw InvalidArgumentPassedException::isNotArrayOrClosure();
}
$this->setTableName($tableName);
// Make sure to flush the old seed query index
// to avoid collision with the new incoming value.
$this->flushSeedQueryIndex();
if ($callback instanceof \Closure) {
$obj = (object) array();
$callback = (array) $callback($obj);
}
$seeds = array();
foreach ($callback as $column => $value) {
$seeds[$column] = $value;
}
$this->setSeedQueryIndex($this->totalSeedQueries());
$this->setSeedQuery('table', $this->getTableNamePrefix($this->getTableName()));
$this->setSeedQuery('record', $seeds);
return $this;
}
|
php
|
public function tableSeed($tableName, $callback)
{
if (! is_array($callback) && ! ($callback instanceof \Closure)) {
throw InvalidArgumentPassedException::isNotArrayOrClosure();
}
$this->setTableName($tableName);
// Make sure to flush the old seed query index
// to avoid collision with the new incoming value.
$this->flushSeedQueryIndex();
if ($callback instanceof \Closure) {
$obj = (object) array();
$callback = (array) $callback($obj);
}
$seeds = array();
foreach ($callback as $column => $value) {
$seeds[$column] = $value;
}
$this->setSeedQueryIndex($this->totalSeedQueries());
$this->setSeedQuery('table', $this->getTableNamePrefix($this->getTableName()));
$this->setSeedQuery('record', $seeds);
return $this;
}
|
[
"public",
"function",
"tableSeed",
"(",
"$",
"tableName",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"callback",
")",
"&&",
"!",
"(",
"$",
"callback",
"instanceof",
"\\",
"Closure",
")",
")",
"{",
"throw",
"InvalidArgumentPassedException",
"::",
"isNotArrayOrClosure",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setTableName",
"(",
"$",
"tableName",
")",
";",
"// Make sure to flush the old seed query index",
"// to avoid collision with the new incoming value.",
"$",
"this",
"->",
"flushSeedQueryIndex",
"(",
")",
";",
"if",
"(",
"$",
"callback",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"obj",
"=",
"(",
"object",
")",
"array",
"(",
")",
";",
"$",
"callback",
"=",
"(",
"array",
")",
"$",
"callback",
"(",
"$",
"obj",
")",
";",
"}",
"$",
"seeds",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"callback",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"$",
"seeds",
"[",
"$",
"column",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"setSeedQueryIndex",
"(",
"$",
"this",
"->",
"totalSeedQueries",
"(",
")",
")",
";",
"$",
"this",
"->",
"setSeedQuery",
"(",
"'table'",
",",
"$",
"this",
"->",
"getTableNamePrefix",
"(",
"$",
"this",
"->",
"getTableName",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"setSeedQuery",
"(",
"'record'",
",",
"$",
"seeds",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
The composer for seeding the given table name.
@param string $tableName
@param array|\Closure $callback
@throws LordDashMe\Wordpress\DB\Exception\InvalidArgumentPassed
@return $this
|
[
"The",
"composer",
"for",
"seeding",
"the",
"given",
"table",
"name",
"."
] |
1798435ec064256174b034a16d9683081c0c299f
|
https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L399-L426
|
22,354
|
LordDashMe/wordpress-db-schema-extender
|
src/SchemaExtender.php
|
SchemaExtender.iterate
|
public function iterate($counter)
{
if (! \is_numeric($counter)) {
throw InvalidArgumentPassedException::isNotNumeric();
}
$this->setSeedQuery('iterate', \round($counter));
}
|
php
|
public function iterate($counter)
{
if (! \is_numeric($counter)) {
throw InvalidArgumentPassedException::isNotNumeric();
}
$this->setSeedQuery('iterate', \round($counter));
}
|
[
"public",
"function",
"iterate",
"(",
"$",
"counter",
")",
"{",
"if",
"(",
"!",
"\\",
"is_numeric",
"(",
"$",
"counter",
")",
")",
"{",
"throw",
"InvalidArgumentPassedException",
"::",
"isNotNumeric",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setSeedQuery",
"(",
"'iterate'",
",",
"\\",
"round",
"(",
"$",
"counter",
")",
")",
";",
"}"
] |
The repetition that will apply for the given record.
@param int $counter Total number of repetition for the given record.
@throws LordDashMe\Wordpress\DB\Exception\InvalidArgumentPassed
@return void
|
[
"The",
"repetition",
"that",
"will",
"apply",
"for",
"the",
"given",
"record",
"."
] |
1798435ec064256174b034a16d9683081c0c299f
|
https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L437-L444
|
22,355
|
LordDashMe/wordpress-db-schema-extender
|
src/SchemaExtender.php
|
SchemaExtender.rawQuery
|
public function rawQuery($query = '')
{
if (! \is_string($query)) {
throw InvalidArgumentPassedException::isNotString();
}
$total = $this->totalQueries();
$this->queries[$total] = \trim($query);
}
|
php
|
public function rawQuery($query = '')
{
if (! \is_string($query)) {
throw InvalidArgumentPassedException::isNotString();
}
$total = $this->totalQueries();
$this->queries[$total] = \trim($query);
}
|
[
"public",
"function",
"rawQuery",
"(",
"$",
"query",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"query",
")",
")",
"{",
"throw",
"InvalidArgumentPassedException",
"::",
"isNotString",
"(",
")",
";",
"}",
"$",
"total",
"=",
"$",
"this",
"->",
"totalQueries",
"(",
")",
";",
"$",
"this",
"->",
"queries",
"[",
"$",
"total",
"]",
"=",
"\\",
"trim",
"(",
"$",
"query",
")",
";",
"}"
] |
Allow to compose raw database query.
@param string $query
@throws LordDashMe\Wordpress\DB\Exception\InvalidArgumentPassed
@return void
|
[
"Allow",
"to",
"compose",
"raw",
"database",
"query",
"."
] |
1798435ec064256174b034a16d9683081c0c299f
|
https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L455-L464
|
22,356
|
LordDashMe/wordpress-db-schema-extender
|
src/SchemaExtender.php
|
SchemaExtender.processQueries
|
protected function processQueries()
{
if (! \function_exists('dbDelta')) {
throw WPDatabaseUpdateFunctionsNotFoundException::dbDeltaIsNotExist();
}
$queries = '';
foreach ($this->getQueries() as $index => $query) {
$queries .= \trim($query);
}
\dbDelta($queries);
}
|
php
|
protected function processQueries()
{
if (! \function_exists('dbDelta')) {
throw WPDatabaseUpdateFunctionsNotFoundException::dbDeltaIsNotExist();
}
$queries = '';
foreach ($this->getQueries() as $index => $query) {
$queries .= \trim($query);
}
\dbDelta($queries);
}
|
[
"protected",
"function",
"processQueries",
"(",
")",
"{",
"if",
"(",
"!",
"\\",
"function_exists",
"(",
"'dbDelta'",
")",
")",
"{",
"throw",
"WPDatabaseUpdateFunctionsNotFoundException",
"::",
"dbDeltaIsNotExist",
"(",
")",
";",
"}",
"$",
"queries",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"getQueries",
"(",
")",
"as",
"$",
"index",
"=>",
"$",
"query",
")",
"{",
"$",
"queries",
".=",
"\\",
"trim",
"(",
"$",
"query",
")",
";",
"}",
"\\",
"dbDelta",
"(",
"$",
"queries",
")",
";",
"}"
] |
Process the queries using the wordpress "dbDelta".
This function is tightly coupled to the wordpress "dbDelta".
@return void
|
[
"Process",
"the",
"queries",
"using",
"the",
"wordpress",
"dbDelta",
".",
"This",
"function",
"is",
"tightly",
"coupled",
"to",
"the",
"wordpress",
"dbDelta",
"."
] |
1798435ec064256174b034a16d9683081c0c299f
|
https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L485-L498
|
22,357
|
LordDashMe/wordpress-db-schema-extender
|
src/SchemaExtender.php
|
SchemaExtender.processTableSeeds
|
protected function processTableSeeds()
{
foreach ($this->getSeedQueries() as $index => $query) {
if (isset($query['iterate'])) {
for ($x = 1; $x <= $query['iterate']; $x++) {
$this->db->insert($query['table'], $query['record']);
}
continue;
}
$this->db->insert($query['table'], $query['record']);
}
}
|
php
|
protected function processTableSeeds()
{
foreach ($this->getSeedQueries() as $index => $query) {
if (isset($query['iterate'])) {
for ($x = 1; $x <= $query['iterate']; $x++) {
$this->db->insert($query['table'], $query['record']);
}
continue;
}
$this->db->insert($query['table'], $query['record']);
}
}
|
[
"protected",
"function",
"processTableSeeds",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSeedQueries",
"(",
")",
"as",
"$",
"index",
"=>",
"$",
"query",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"query",
"[",
"'iterate'",
"]",
")",
")",
"{",
"for",
"(",
"$",
"x",
"=",
"1",
";",
"$",
"x",
"<=",
"$",
"query",
"[",
"'iterate'",
"]",
";",
"$",
"x",
"++",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"insert",
"(",
"$",
"query",
"[",
"'table'",
"]",
",",
"$",
"query",
"[",
"'record'",
"]",
")",
";",
"}",
"continue",
";",
"}",
"$",
"this",
"->",
"db",
"->",
"insert",
"(",
"$",
"query",
"[",
"'table'",
"]",
",",
"$",
"query",
"[",
"'record'",
"]",
")",
";",
"}",
"}"
] |
Process the seed queries using the wordpress database "insert".
@return void
|
[
"Process",
"the",
"seed",
"queries",
"using",
"the",
"wordpress",
"database",
"insert",
"."
] |
1798435ec064256174b034a16d9683081c0c299f
|
https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L505-L518
|
22,358
|
LordDashMe/wordpress-db-schema-extender
|
src/SchemaExtender.php
|
SchemaExtender.dropTable
|
public function dropTable($tableName)
{
$this->db->query('SET FOREIGN_KEY_CHECKS = 0;');
$this->db->query("DROP TABLE IF EXISTS `{$this->getTableNamePrefix($tableName)}`;");
$this->db->query('SET FOREIGN_KEY_CHECKS = 1;');
}
|
php
|
public function dropTable($tableName)
{
$this->db->query('SET FOREIGN_KEY_CHECKS = 0;');
$this->db->query("DROP TABLE IF EXISTS `{$this->getTableNamePrefix($tableName)}`;");
$this->db->query('SET FOREIGN_KEY_CHECKS = 1;');
}
|
[
"public",
"function",
"dropTable",
"(",
"$",
"tableName",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SET FOREIGN_KEY_CHECKS = 0;'",
")",
";",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"DROP TABLE IF EXISTS `{$this->getTableNamePrefix($tableName)}`;\"",
")",
";",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SET FOREIGN_KEY_CHECKS = 1;'",
")",
";",
"}"
] |
Process the drop table base on the given table name.
Foreign key checks disable before processing the drop action and
enable it back again after the process.
@param string $tableName
@return void
|
[
"Process",
"the",
"drop",
"table",
"base",
"on",
"the",
"given",
"table",
"name",
".",
"Foreign",
"key",
"checks",
"disable",
"before",
"processing",
"the",
"drop",
"action",
"and",
"enable",
"it",
"back",
"again",
"after",
"the",
"process",
"."
] |
1798435ec064256174b034a16d9683081c0c299f
|
https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L529-L534
|
22,359
|
inhere/php-librarys
|
src/Helpers/JsonHelper.php
|
JsonHelper.encode
|
public static function encode($data): string
{
if (PHP_VERSION_ID >= 50400) {
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
return json_encode($data);
}
|
php
|
public static function encode($data): string
{
if (PHP_VERSION_ID >= 50400) {
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
return json_encode($data);
}
|
[
"public",
"static",
"function",
"encode",
"(",
"$",
"data",
")",
":",
"string",
"{",
"if",
"(",
"PHP_VERSION_ID",
">=",
"50400",
")",
"{",
"return",
"json_encode",
"(",
"$",
"data",
",",
"JSON_UNESCAPED_SLASHES",
"|",
"JSON_UNESCAPED_UNICODE",
")",
";",
"}",
"return",
"json_encode",
"(",
"$",
"data",
")",
";",
"}"
] |
encode data to json
@param $data
@return string
|
[
"encode",
"data",
"to",
"json"
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/JsonHelper.php#L24-L31
|
22,360
|
dragonmantank/fillet
|
src/Fillet/Fillet.php
|
Fillet.parse
|
public function parse()
{
foreach($this->parser->parse($this->inputFile) as $item) {
$writer = WriterFactory::create($item['type'], $this->config);
if($writer) {
$writer->write($item);
}
}
}
|
php
|
public function parse()
{
foreach($this->parser->parse($this->inputFile) as $item) {
$writer = WriterFactory::create($item['type'], $this->config);
if($writer) {
$writer->write($item);
}
}
}
|
[
"public",
"function",
"parse",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"this",
"->",
"inputFile",
")",
"as",
"$",
"item",
")",
"{",
"$",
"writer",
"=",
"WriterFactory",
"::",
"create",
"(",
"$",
"item",
"[",
"'type'",
"]",
",",
"$",
"this",
"->",
"config",
")",
";",
"if",
"(",
"$",
"writer",
")",
"{",
"$",
"writer",
"->",
"write",
"(",
"$",
"item",
")",
";",
"}",
"}",
"}"
] |
Calls the parser and generates the files
@throws \Exception
|
[
"Calls",
"the",
"parser",
"and",
"generates",
"the",
"files"
] |
b197947608c05ac2318e8f6b296345494004d9c6
|
https://github.com/dragonmantank/fillet/blob/b197947608c05ac2318e8f6b296345494004d9c6/src/Fillet/Fillet.php#L53-L62
|
22,361
|
dave-redfern/laravel-doctrine-entity-audit
|
src/ServiceProvider.php
|
ServiceProvider.registerEntityAuditConfigurations
|
protected function registerEntityAuditConfigurations(Repository $config)
{
$this->app->afterResolving(IlluminateRegistry::class, function ($registry) use ($config) {
$table = $config->get('entity_audit.global.table');
$users = $config->get('entity_audit.global.username_for');
$columns = $config->get('entity_audit.global.ignore_columns');
$auditRegistry = $this->app->make(AuditRegistry::class);
foreach ($config->get('entity_audit.entity_managers', []) as $emName => $emConfig) {
$users = array_merge($users, data_get($emConfig, 'username_for', []));
$metadata = new MetadataFactory(data_get($emConfig, 'entities', []));
$auditConfig = new AuditConfiguration(
new UserResolver(
$this->app->make(Guard::class),
$users['unknown_authenticated_user'],
$users['unknown_unauthenticated_user']
),
new TableConfiguration(array_merge($table, data_get($emConfig, 'table', []))),
data_get($emConfig, 'ignore_columns', $columns)
);
/** @var IlluminateRegistry $registry */
/** @var EntityManager $em */
$em = $registry->getManager($emName);
$reader = new AuditReader($em, $auditConfig, $metadata);
$manager = new AuditManager($auditConfig, $metadata, $reader);
$em->getEventManager()->addEventSubscriber(new CreateSchemaListener($manager));
$em->getEventManager()->addEventSubscriber(new LogRevisionsListener($manager));
$auditRegistry->add($emName, $manager);
$this->app->instance(sprintf('entity_audit.%s.manager', $emName), $manager);
$this->app->instance(sprintf('entity_audit.%s.reader', $emName), $reader);
}
});
}
|
php
|
protected function registerEntityAuditConfigurations(Repository $config)
{
$this->app->afterResolving(IlluminateRegistry::class, function ($registry) use ($config) {
$table = $config->get('entity_audit.global.table');
$users = $config->get('entity_audit.global.username_for');
$columns = $config->get('entity_audit.global.ignore_columns');
$auditRegistry = $this->app->make(AuditRegistry::class);
foreach ($config->get('entity_audit.entity_managers', []) as $emName => $emConfig) {
$users = array_merge($users, data_get($emConfig, 'username_for', []));
$metadata = new MetadataFactory(data_get($emConfig, 'entities', []));
$auditConfig = new AuditConfiguration(
new UserResolver(
$this->app->make(Guard::class),
$users['unknown_authenticated_user'],
$users['unknown_unauthenticated_user']
),
new TableConfiguration(array_merge($table, data_get($emConfig, 'table', []))),
data_get($emConfig, 'ignore_columns', $columns)
);
/** @var IlluminateRegistry $registry */
/** @var EntityManager $em */
$em = $registry->getManager($emName);
$reader = new AuditReader($em, $auditConfig, $metadata);
$manager = new AuditManager($auditConfig, $metadata, $reader);
$em->getEventManager()->addEventSubscriber(new CreateSchemaListener($manager));
$em->getEventManager()->addEventSubscriber(new LogRevisionsListener($manager));
$auditRegistry->add($emName, $manager);
$this->app->instance(sprintf('entity_audit.%s.manager', $emName), $manager);
$this->app->instance(sprintf('entity_audit.%s.reader', $emName), $reader);
}
});
}
|
[
"protected",
"function",
"registerEntityAuditConfigurations",
"(",
"Repository",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"afterResolving",
"(",
"IlluminateRegistry",
"::",
"class",
",",
"function",
"(",
"$",
"registry",
")",
"use",
"(",
"$",
"config",
")",
"{",
"$",
"table",
"=",
"$",
"config",
"->",
"get",
"(",
"'entity_audit.global.table'",
")",
";",
"$",
"users",
"=",
"$",
"config",
"->",
"get",
"(",
"'entity_audit.global.username_for'",
")",
";",
"$",
"columns",
"=",
"$",
"config",
"->",
"get",
"(",
"'entity_audit.global.ignore_columns'",
")",
";",
"$",
"auditRegistry",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"AuditRegistry",
"::",
"class",
")",
";",
"foreach",
"(",
"$",
"config",
"->",
"get",
"(",
"'entity_audit.entity_managers'",
",",
"[",
"]",
")",
"as",
"$",
"emName",
"=>",
"$",
"emConfig",
")",
"{",
"$",
"users",
"=",
"array_merge",
"(",
"$",
"users",
",",
"data_get",
"(",
"$",
"emConfig",
",",
"'username_for'",
",",
"[",
"]",
")",
")",
";",
"$",
"metadata",
"=",
"new",
"MetadataFactory",
"(",
"data_get",
"(",
"$",
"emConfig",
",",
"'entities'",
",",
"[",
"]",
")",
")",
";",
"$",
"auditConfig",
"=",
"new",
"AuditConfiguration",
"(",
"new",
"UserResolver",
"(",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"Guard",
"::",
"class",
")",
",",
"$",
"users",
"[",
"'unknown_authenticated_user'",
"]",
",",
"$",
"users",
"[",
"'unknown_unauthenticated_user'",
"]",
")",
",",
"new",
"TableConfiguration",
"(",
"array_merge",
"(",
"$",
"table",
",",
"data_get",
"(",
"$",
"emConfig",
",",
"'table'",
",",
"[",
"]",
")",
")",
")",
",",
"data_get",
"(",
"$",
"emConfig",
",",
"'ignore_columns'",
",",
"$",
"columns",
")",
")",
";",
"/** @var IlluminateRegistry $registry */",
"/** @var EntityManager $em */",
"$",
"em",
"=",
"$",
"registry",
"->",
"getManager",
"(",
"$",
"emName",
")",
";",
"$",
"reader",
"=",
"new",
"AuditReader",
"(",
"$",
"em",
",",
"$",
"auditConfig",
",",
"$",
"metadata",
")",
";",
"$",
"manager",
"=",
"new",
"AuditManager",
"(",
"$",
"auditConfig",
",",
"$",
"metadata",
",",
"$",
"reader",
")",
";",
"$",
"em",
"->",
"getEventManager",
"(",
")",
"->",
"addEventSubscriber",
"(",
"new",
"CreateSchemaListener",
"(",
"$",
"manager",
")",
")",
";",
"$",
"em",
"->",
"getEventManager",
"(",
")",
"->",
"addEventSubscriber",
"(",
"new",
"LogRevisionsListener",
"(",
"$",
"manager",
")",
")",
";",
"$",
"auditRegistry",
"->",
"add",
"(",
"$",
"emName",
",",
"$",
"manager",
")",
";",
"$",
"this",
"->",
"app",
"->",
"instance",
"(",
"sprintf",
"(",
"'entity_audit.%s.manager'",
",",
"$",
"emName",
")",
",",
"$",
"manager",
")",
";",
"$",
"this",
"->",
"app",
"->",
"instance",
"(",
"sprintf",
"(",
"'entity_audit.%s.reader'",
",",
"$",
"emName",
")",
",",
"$",
"reader",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Registers auditing to the specified entity managers
@param Repository $config
@return void
|
[
"Registers",
"auditing",
"to",
"the",
"specified",
"entity",
"managers"
] |
ab79e305fe512ceefbc14d585fefe0a40cf911ab
|
https://github.com/dave-redfern/laravel-doctrine-entity-audit/blob/ab79e305fe512ceefbc14d585fefe0a40cf911ab/src/ServiceProvider.php#L99-L134
|
22,362
|
digipolisgent/robo-digipolis-general
|
src/ReadProperties.php
|
ReadProperties.parseConfigFiles
|
protected function parseConfigFiles(Finder $files)
{
$config = [];
foreach ($files as $file) {
// Check if this is part of a Robo package.
$path = $file->getRealPath();
if (!file_exists(dirname($path) . '/RoboFile.php')) {
continue;
}
$this->printTaskInfo(sprintf('Parsing config from %s.', $path));
$contents = file_get_contents($path);
$this->printTaskDebug(sprintf('Parsing %s', $contents));
$config += Yaml::parse($contents);
}
return $config;
}
|
php
|
protected function parseConfigFiles(Finder $files)
{
$config = [];
foreach ($files as $file) {
// Check if this is part of a Robo package.
$path = $file->getRealPath();
if (!file_exists(dirname($path) . '/RoboFile.php')) {
continue;
}
$this->printTaskInfo(sprintf('Parsing config from %s.', $path));
$contents = file_get_contents($path);
$this->printTaskDebug(sprintf('Parsing %s', $contents));
$config += Yaml::parse($contents);
}
return $config;
}
|
[
"protected",
"function",
"parseConfigFiles",
"(",
"Finder",
"$",
"files",
")",
"{",
"$",
"config",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"// Check if this is part of a Robo package.",
"$",
"path",
"=",
"$",
"file",
"->",
"getRealPath",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"path",
")",
".",
"'/RoboFile.php'",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"printTaskInfo",
"(",
"sprintf",
"(",
"'Parsing config from %s.'",
",",
"$",
"path",
")",
")",
";",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"printTaskDebug",
"(",
"sprintf",
"(",
"'Parsing %s'",
",",
"$",
"contents",
")",
")",
";",
"$",
"config",
"+=",
"Yaml",
"::",
"parse",
"(",
"$",
"contents",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Helper function to parse config files.
@param \Symfony\Component\Finder\Finder $files
The files to parse.
@return array
The parsed config.
|
[
"Helper",
"function",
"to",
"parse",
"config",
"files",
"."
] |
66f0806c9ed7bd4e5aaf3f57ae1363f6aaae7cd9
|
https://github.com/digipolisgent/robo-digipolis-general/blob/66f0806c9ed7bd4e5aaf3f57ae1363f6aaae7cd9/src/ReadProperties.php#L155-L170
|
22,363
|
wenbinye/PhalconX
|
src/Serializer/Serializer.php
|
Serializer.normalize
|
public function normalize($obj)
{
$properties = $this->getClassProperties(get_class($obj));
$data = [];
foreach ($properties as $name => $prop) {
if (isset($prop['getter'])) {
$getter = $prop['getter'];
$value = $obj->$getter();
} else {
$key = $prop['name'];
$value = $obj->$key;
}
if (isset($prop['type'])) {
if ($prop['type'] === 'array') {
$value = array_map(function ($elem) use ($prop) {
return $this->normalize($elem);
}, $value);
} else {
$value = $this->normalize($value);
}
}
if (isset($prop['serializeName'])) {
$name = $prop['serializeName'];
}
$data[$name] = $value;
}
return $data;
}
|
php
|
public function normalize($obj)
{
$properties = $this->getClassProperties(get_class($obj));
$data = [];
foreach ($properties as $name => $prop) {
if (isset($prop['getter'])) {
$getter = $prop['getter'];
$value = $obj->$getter();
} else {
$key = $prop['name'];
$value = $obj->$key;
}
if (isset($prop['type'])) {
if ($prop['type'] === 'array') {
$value = array_map(function ($elem) use ($prop) {
return $this->normalize($elem);
}, $value);
} else {
$value = $this->normalize($value);
}
}
if (isset($prop['serializeName'])) {
$name = $prop['serializeName'];
}
$data[$name] = $value;
}
return $data;
}
|
[
"public",
"function",
"normalize",
"(",
"$",
"obj",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getClassProperties",
"(",
"get_class",
"(",
"$",
"obj",
")",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"name",
"=>",
"$",
"prop",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"prop",
"[",
"'getter'",
"]",
")",
")",
"{",
"$",
"getter",
"=",
"$",
"prop",
"[",
"'getter'",
"]",
";",
"$",
"value",
"=",
"$",
"obj",
"->",
"$",
"getter",
"(",
")",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"prop",
"[",
"'name'",
"]",
";",
"$",
"value",
"=",
"$",
"obj",
"->",
"$",
"key",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"prop",
"[",
"'type'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"prop",
"[",
"'type'",
"]",
"===",
"'array'",
")",
"{",
"$",
"value",
"=",
"array_map",
"(",
"function",
"(",
"$",
"elem",
")",
"use",
"(",
"$",
"prop",
")",
"{",
"return",
"$",
"this",
"->",
"normalize",
"(",
"$",
"elem",
")",
";",
"}",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"value",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"prop",
"[",
"'serializeName'",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"prop",
"[",
"'serializeName'",
"]",
";",
"}",
"$",
"data",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Normalizes the object into an array of scalars|arrays.
|
[
"Normalizes",
"the",
"object",
"into",
"an",
"array",
"of",
"scalars|arrays",
"."
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Serializer/Serializer.php#L88-L115
|
22,364
|
wenbinye/PhalconX
|
src/Serializer/Serializer.php
|
Serializer.getClassProperties
|
private function getClassProperties($class)
{
$properties = $this->getCache()->get('_PHX.serialze_properties.'. $class);
if (!isset($properties)) {
$classResolver = $this->getClassResolver();
$properties = $this->getReflectionProperties($class);
foreach ($this->getAnnotations()->get($class) as $annotation) {
if ($annotation instanceof IsA) {
$properties[$this->getAnnotationProperty($annotation)]['type']
= $classResolver->resolve($annotation->class, $annotation->getDeclaringClass());
} elseif ($annotation instanceof IsArray && is_scalar($annotation->element)) {
$name = $this->getAnnotationProperty($annotation);
$properties[$name]['type'] = 'array';
$properties[$name]['element']
= $classResolver->resolve($annotation->element, $annotation->getDeclaringClass());
} elseif ($annotation instanceof SerializeName) {
$properties[$this->getAnnotationProperty($annotation)]['serializeName']
= $annotation->value;
}
}
$this->getCache()->save('_PHX.serialze_properties.'.$class, $properties);
}
return $properties;
}
|
php
|
private function getClassProperties($class)
{
$properties = $this->getCache()->get('_PHX.serialze_properties.'. $class);
if (!isset($properties)) {
$classResolver = $this->getClassResolver();
$properties = $this->getReflectionProperties($class);
foreach ($this->getAnnotations()->get($class) as $annotation) {
if ($annotation instanceof IsA) {
$properties[$this->getAnnotationProperty($annotation)]['type']
= $classResolver->resolve($annotation->class, $annotation->getDeclaringClass());
} elseif ($annotation instanceof IsArray && is_scalar($annotation->element)) {
$name = $this->getAnnotationProperty($annotation);
$properties[$name]['type'] = 'array';
$properties[$name]['element']
= $classResolver->resolve($annotation->element, $annotation->getDeclaringClass());
} elseif ($annotation instanceof SerializeName) {
$properties[$this->getAnnotationProperty($annotation)]['serializeName']
= $annotation->value;
}
}
$this->getCache()->save('_PHX.serialze_properties.'.$class, $properties);
}
return $properties;
}
|
[
"private",
"function",
"getClassProperties",
"(",
"$",
"class",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"get",
"(",
"'_PHX.serialze_properties.'",
".",
"$",
"class",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"properties",
")",
")",
"{",
"$",
"classResolver",
"=",
"$",
"this",
"->",
"getClassResolver",
"(",
")",
";",
"$",
"properties",
"=",
"$",
"this",
"->",
"getReflectionProperties",
"(",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAnnotations",
"(",
")",
"->",
"get",
"(",
"$",
"class",
")",
"as",
"$",
"annotation",
")",
"{",
"if",
"(",
"$",
"annotation",
"instanceof",
"IsA",
")",
"{",
"$",
"properties",
"[",
"$",
"this",
"->",
"getAnnotationProperty",
"(",
"$",
"annotation",
")",
"]",
"[",
"'type'",
"]",
"=",
"$",
"classResolver",
"->",
"resolve",
"(",
"$",
"annotation",
"->",
"class",
",",
"$",
"annotation",
"->",
"getDeclaringClass",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"annotation",
"instanceof",
"IsArray",
"&&",
"is_scalar",
"(",
"$",
"annotation",
"->",
"element",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getAnnotationProperty",
"(",
"$",
"annotation",
")",
";",
"$",
"properties",
"[",
"$",
"name",
"]",
"[",
"'type'",
"]",
"=",
"'array'",
";",
"$",
"properties",
"[",
"$",
"name",
"]",
"[",
"'element'",
"]",
"=",
"$",
"classResolver",
"->",
"resolve",
"(",
"$",
"annotation",
"->",
"element",
",",
"$",
"annotation",
"->",
"getDeclaringClass",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"annotation",
"instanceof",
"SerializeName",
")",
"{",
"$",
"properties",
"[",
"$",
"this",
"->",
"getAnnotationProperty",
"(",
"$",
"annotation",
")",
"]",
"[",
"'serializeName'",
"]",
"=",
"$",
"annotation",
"->",
"value",
";",
"}",
"}",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"save",
"(",
"'_PHX.serialze_properties.'",
".",
"$",
"class",
",",
"$",
"properties",
")",
";",
"}",
"return",
"$",
"properties",
";",
"}"
] |
gets class properties metadata
|
[
"gets",
"class",
"properties",
"metadata"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Serializer/Serializer.php#L120-L143
|
22,365
|
odiaseo/pagebuilder
|
src/PageBuilder/Entity/Site.php
|
Site.getSiteFilterQuery
|
public function getSiteFilterQuery($targetTableAlias)
{
$parent = $this->getParent();
if ($parent and $parentId = $parent->getId()) {
return $targetTableAlias . '.site_id = ' . $parentId;
} elseif ($id = $this->getId()) {
return $targetTableAlias . '.site_id = ' . $id;
}
return '';
}
|
php
|
public function getSiteFilterQuery($targetTableAlias)
{
$parent = $this->getParent();
if ($parent and $parentId = $parent->getId()) {
return $targetTableAlias . '.site_id = ' . $parentId;
} elseif ($id = $this->getId()) {
return $targetTableAlias . '.site_id = ' . $id;
}
return '';
}
|
[
"public",
"function",
"getSiteFilterQuery",
"(",
"$",
"targetTableAlias",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"$",
"parent",
"and",
"$",
"parentId",
"=",
"$",
"parent",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"$",
"targetTableAlias",
".",
"'.site_id = '",
".",
"$",
"parentId",
";",
"}",
"elseif",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"$",
"targetTableAlias",
".",
"'.site_id = '",
".",
"$",
"id",
";",
"}",
"return",
"''",
";",
"}"
] |
Get filter query
@param $targetTableAlias
@return string
|
[
"Get",
"filter",
"query"
] |
88ef7cccf305368561307efe4ca07fac8e5774f3
|
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Entity/Site.php#L384-L394
|
22,366
|
odiaseo/pagebuilder
|
src/PageBuilder/Entity/Site.php
|
Site.sumOfferCount
|
public function sumOfferCount()
{
$count = $this->getOfferCount();
if ($this->getParent()) {
$count += $this->getParent()->getOfferCount();
}
if ($this->getLinkedSites()->count()) {
/** @var Site $linked */
foreach ($this->getLinkedSites() as $linked) {
$count += $linked->getOfferCount();
}
}
if ($this->getSubDomains()->count()) {
foreach ($this->getSubDomains() as $linked) {
$count += $linked->getOfferCount();
}
}
return $count;
}
|
php
|
public function sumOfferCount()
{
$count = $this->getOfferCount();
if ($this->getParent()) {
$count += $this->getParent()->getOfferCount();
}
if ($this->getLinkedSites()->count()) {
/** @var Site $linked */
foreach ($this->getLinkedSites() as $linked) {
$count += $linked->getOfferCount();
}
}
if ($this->getSubDomains()->count()) {
foreach ($this->getSubDomains() as $linked) {
$count += $linked->getOfferCount();
}
}
return $count;
}
|
[
"public",
"function",
"sumOfferCount",
"(",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"getOfferCount",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getParent",
"(",
")",
")",
"{",
"$",
"count",
"+=",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getOfferCount",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getLinkedSites",
"(",
")",
"->",
"count",
"(",
")",
")",
"{",
"/** @var Site $linked */",
"foreach",
"(",
"$",
"this",
"->",
"getLinkedSites",
"(",
")",
"as",
"$",
"linked",
")",
"{",
"$",
"count",
"+=",
"$",
"linked",
"->",
"getOfferCount",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"getSubDomains",
"(",
")",
"->",
"count",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSubDomains",
"(",
")",
"as",
"$",
"linked",
")",
"{",
"$",
"count",
"+=",
"$",
"linked",
"->",
"getOfferCount",
"(",
")",
";",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] |
Get sum of all offers
@return mixed
|
[
"Get",
"sum",
"of",
"all",
"offers"
] |
88ef7cccf305368561307efe4ca07fac8e5774f3
|
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Entity/Site.php#L451-L472
|
22,367
|
zicht/z
|
src/Zicht/Tool/Script/Node/Script/ForIn.php
|
ForIn.afterScript
|
public function afterScript(Buffer $buffer)
{
$buffer->write(sprintf('$z->pop(\'%s\');', $this->key));
$buffer->write(sprintf('$z->pop(\'%s\');', $this->value));
$buffer->indent(-1);
$buffer->writeln('}');
}
|
php
|
public function afterScript(Buffer $buffer)
{
$buffer->write(sprintf('$z->pop(\'%s\');', $this->key));
$buffer->write(sprintf('$z->pop(\'%s\');', $this->value));
$buffer->indent(-1);
$buffer->writeln('}');
}
|
[
"public",
"function",
"afterScript",
"(",
"Buffer",
"$",
"buffer",
")",
"{",
"$",
"buffer",
"->",
"write",
"(",
"sprintf",
"(",
"'$z->pop(\\'%s\\');'",
",",
"$",
"this",
"->",
"key",
")",
")",
";",
"$",
"buffer",
"->",
"write",
"(",
"sprintf",
"(",
"'$z->pop(\\'%s\\');'",
",",
"$",
"this",
"->",
"value",
")",
")",
";",
"$",
"buffer",
"->",
"indent",
"(",
"-",
"1",
")",
";",
"$",
"buffer",
"->",
"writeln",
"(",
"'}'",
")",
";",
"}"
] |
Allows the annotation to modify the buffer after the script is compiled.
@param Buffer $buffer
@return void
|
[
"Allows",
"the",
"annotation",
"to",
"modify",
"the",
"buffer",
"after",
"the",
"script",
"is",
"compiled",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Script/Node/Script/ForIn.php#L58-L64
|
22,368
|
sokil/php-mongo-yii
|
src/Sokil/Mongo/Yii/LogRoute.php
|
LogRoute._timeToMongoDate
|
protected function _timeToMongoDate($time)
{
if(!is_numeric($time)) {
$time = strtotime($time);
if(!$time) {
$time = time();
}
}
return new \MongoDate($time);
}
|
php
|
protected function _timeToMongoDate($time)
{
if(!is_numeric($time)) {
$time = strtotime($time);
if(!$time) {
$time = time();
}
}
return new \MongoDate($time);
}
|
[
"protected",
"function",
"_timeToMongoDate",
"(",
"$",
"time",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"time",
")",
")",
"{",
"$",
"time",
"=",
"strtotime",
"(",
"$",
"time",
")",
";",
"if",
"(",
"!",
"$",
"time",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"}",
"}",
"return",
"new",
"\\",
"MongoDate",
"(",
"$",
"time",
")",
";",
"}"
] |
Convert time in different formats to mongo date
@param mixed $time
@return \MongoDate
|
[
"Convert",
"time",
"in",
"different",
"formats",
"to",
"mongo",
"date"
] |
d41b3b70953bc6521c73fcacc501e1596a9ed7d3
|
https://github.com/sokil/php-mongo-yii/blob/d41b3b70953bc6521c73fcacc501e1596a9ed7d3/src/Sokil/Mongo/Yii/LogRoute.php#L16-L26
|
22,369
|
sokil/php-mongo-yii
|
src/Sokil/Mongo/Yii/LogRoute.php
|
LogRoute.processLogs
|
protected function processLogs($logs)
{
$logCollection = \Yii::app()
->{$this->serviceName}
->getCollection($this->collectionName);
foreach ($logs as $log) {
// time
$logCollection
->createDocument(array(
'level' => $log[1],
'category' => $log[2],
'logtime' => $this->_timeToMongoDate($log[3]),
'message' => $log[0],
'requestUri' => isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null,
'userAgent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null,
))
->save();
}
}
|
php
|
protected function processLogs($logs)
{
$logCollection = \Yii::app()
->{$this->serviceName}
->getCollection($this->collectionName);
foreach ($logs as $log) {
// time
$logCollection
->createDocument(array(
'level' => $log[1],
'category' => $log[2],
'logtime' => $this->_timeToMongoDate($log[3]),
'message' => $log[0],
'requestUri' => isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null,
'userAgent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null,
))
->save();
}
}
|
[
"protected",
"function",
"processLogs",
"(",
"$",
"logs",
")",
"{",
"$",
"logCollection",
"=",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"{",
"$",
"this",
"->",
"serviceName",
"}",
"->",
"getCollection",
"(",
"$",
"this",
"->",
"collectionName",
")",
";",
"foreach",
"(",
"$",
"logs",
"as",
"$",
"log",
")",
"{",
"// time",
"$",
"logCollection",
"->",
"createDocument",
"(",
"array",
"(",
"'level'",
"=>",
"$",
"log",
"[",
"1",
"]",
",",
"'category'",
"=>",
"$",
"log",
"[",
"2",
"]",
",",
"'logtime'",
"=>",
"$",
"this",
"->",
"_timeToMongoDate",
"(",
"$",
"log",
"[",
"3",
"]",
")",
",",
"'message'",
"=>",
"$",
"log",
"[",
"0",
"]",
",",
"'requestUri'",
"=>",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
":",
"null",
",",
"'userAgent'",
"=>",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
":",
"null",
",",
")",
")",
"->",
"save",
"(",
")",
";",
"}",
"}"
] |
Write log messages
@param array $logs list of messages
|
[
"Write",
"log",
"messages"
] |
d41b3b70953bc6521c73fcacc501e1596a9ed7d3
|
https://github.com/sokil/php-mongo-yii/blob/d41b3b70953bc6521c73fcacc501e1596a9ed7d3/src/Sokil/Mongo/Yii/LogRoute.php#L32-L52
|
22,370
|
phootwork/lang
|
src/text/CheckerTrait.php
|
CheckerTrait.isSingular
|
public function isSingular(Pluralizer $pluralizer = null) {
$pluralizer = $pluralizer ?: new EnglishPluralizer();
return $pluralizer->isSingular($this->string);
}
|
php
|
public function isSingular(Pluralizer $pluralizer = null) {
$pluralizer = $pluralizer ?: new EnglishPluralizer();
return $pluralizer->isSingular($this->string);
}
|
[
"public",
"function",
"isSingular",
"(",
"Pluralizer",
"$",
"pluralizer",
"=",
"null",
")",
"{",
"$",
"pluralizer",
"=",
"$",
"pluralizer",
"?",
":",
"new",
"EnglishPluralizer",
"(",
")",
";",
"return",
"$",
"pluralizer",
"->",
"isSingular",
"(",
"$",
"this",
"->",
"string",
")",
";",
"}"
] |
Check if a string is singular form.
@param Pluralizer $pluralizer
A custom pluralizer. Default is the EnglishPluralizer
@return boolean
|
[
"Check",
"if",
"a",
"string",
"is",
"singular",
"form",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/text/CheckerTrait.php#L101-L105
|
22,371
|
phootwork/lang
|
src/text/CheckerTrait.php
|
CheckerTrait.isPlural
|
public function isPlural(Pluralizer $pluralizer = null) {
$pluralizer = $pluralizer ?: new EnglishPluralizer();
return $pluralizer->isPlural($this->string);
}
|
php
|
public function isPlural(Pluralizer $pluralizer = null) {
$pluralizer = $pluralizer ?: new EnglishPluralizer();
return $pluralizer->isPlural($this->string);
}
|
[
"public",
"function",
"isPlural",
"(",
"Pluralizer",
"$",
"pluralizer",
"=",
"null",
")",
"{",
"$",
"pluralizer",
"=",
"$",
"pluralizer",
"?",
":",
"new",
"EnglishPluralizer",
"(",
")",
";",
"return",
"$",
"pluralizer",
"->",
"isPlural",
"(",
"$",
"this",
"->",
"string",
")",
";",
"}"
] |
Check if a string is plural form.
@param Pluralizer $pluralizer
A custom pluralizer. Default is the EnglishPluralizer
@return boolean
|
[
"Check",
"if",
"a",
"string",
"is",
"plural",
"form",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/text/CheckerTrait.php#L114-L118
|
22,372
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo.php
|
Dwoo.initRuntimeVars
|
protected function initRuntimeVars(Dwoo_ITemplate $tpl)
{
$this->runtimePlugins = array();
$this->scope =& $this->data;
$this->scopeTree = array();
$this->stack = array();
$this->curBlock = null;
$this->buffer = '';
}
|
php
|
protected function initRuntimeVars(Dwoo_ITemplate $tpl)
{
$this->runtimePlugins = array();
$this->scope =& $this->data;
$this->scopeTree = array();
$this->stack = array();
$this->curBlock = null;
$this->buffer = '';
}
|
[
"protected",
"function",
"initRuntimeVars",
"(",
"Dwoo_ITemplate",
"$",
"tpl",
")",
"{",
"$",
"this",
"->",
"runtimePlugins",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"scope",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"$",
"this",
"->",
"scopeTree",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"stack",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"curBlock",
"=",
"null",
";",
"$",
"this",
"->",
"buffer",
"=",
"''",
";",
"}"
] |
re-initializes the runtime variables before each template run
override this method to inject data in the globals array if needed, this
method is called before each template execution
@param Dwoo_ITemplate $tpl the template that is going to be rendered
|
[
"re",
"-",
"initializes",
"the",
"runtime",
"variables",
"before",
"each",
"template",
"run"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo.php#L443-L451
|
22,373
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo.php
|
Dwoo.addPlugin
|
public function addPlugin($name, $callback, $compilable = false)
{
$compilable = $compilable ? self::COMPILABLE_PLUGIN : 0;
if (is_array($callback)) {
if (is_subclass_of(is_object($callback[0]) ? get_class($callback[0]) : $callback[0], 'Dwoo_Block_Plugin')) {
$this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]));
} else {
$this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]), 'function'=>$callback[1]);
}
} elseif (class_exists($callback, false)) {
if (is_subclass_of($callback, 'Dwoo_Block_Plugin')) {
$this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback);
} else {
$this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback, 'function'=>'process');
}
} elseif (function_exists($callback)) {
$this->plugins[$name] = array('type'=>self::FUNC_PLUGIN | $compilable, 'callback'=>$callback);
} else {
throw new Dwoo_Exception('Callback could not be processed correctly, please check that the function/class you used exists');
}
}
|
php
|
public function addPlugin($name, $callback, $compilable = false)
{
$compilable = $compilable ? self::COMPILABLE_PLUGIN : 0;
if (is_array($callback)) {
if (is_subclass_of(is_object($callback[0]) ? get_class($callback[0]) : $callback[0], 'Dwoo_Block_Plugin')) {
$this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]));
} else {
$this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]), 'function'=>$callback[1]);
}
} elseif (class_exists($callback, false)) {
if (is_subclass_of($callback, 'Dwoo_Block_Plugin')) {
$this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback);
} else {
$this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback, 'function'=>'process');
}
} elseif (function_exists($callback)) {
$this->plugins[$name] = array('type'=>self::FUNC_PLUGIN | $compilable, 'callback'=>$callback);
} else {
throw new Dwoo_Exception('Callback could not be processed correctly, please check that the function/class you used exists');
}
}
|
[
"public",
"function",
"addPlugin",
"(",
"$",
"name",
",",
"$",
"callback",
",",
"$",
"compilable",
"=",
"false",
")",
"{",
"$",
"compilable",
"=",
"$",
"compilable",
"?",
"self",
"::",
"COMPILABLE_PLUGIN",
":",
"0",
";",
"if",
"(",
"is_array",
"(",
"$",
"callback",
")",
")",
"{",
"if",
"(",
"is_subclass_of",
"(",
"is_object",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
"?",
"get_class",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
":",
"$",
"callback",
"[",
"0",
"]",
",",
"'Dwoo_Block_Plugin'",
")",
")",
"{",
"$",
"this",
"->",
"plugins",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'type'",
"=>",
"self",
"::",
"BLOCK_PLUGIN",
"|",
"$",
"compilable",
",",
"'callback'",
"=>",
"$",
"callback",
",",
"'class'",
"=>",
"(",
"is_object",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
"?",
"get_class",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
":",
"$",
"callback",
"[",
"0",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"plugins",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'type'",
"=>",
"self",
"::",
"CLASS_PLUGIN",
"|",
"$",
"compilable",
",",
"'callback'",
"=>",
"$",
"callback",
",",
"'class'",
"=>",
"(",
"is_object",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
"?",
"get_class",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
":",
"$",
"callback",
"[",
"0",
"]",
")",
",",
"'function'",
"=>",
"$",
"callback",
"[",
"1",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"class_exists",
"(",
"$",
"callback",
",",
"false",
")",
")",
"{",
"if",
"(",
"is_subclass_of",
"(",
"$",
"callback",
",",
"'Dwoo_Block_Plugin'",
")",
")",
"{",
"$",
"this",
"->",
"plugins",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'type'",
"=>",
"self",
"::",
"BLOCK_PLUGIN",
"|",
"$",
"compilable",
",",
"'callback'",
"=>",
"$",
"callback",
",",
"'class'",
"=>",
"$",
"callback",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"plugins",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'type'",
"=>",
"self",
"::",
"CLASS_PLUGIN",
"|",
"$",
"compilable",
",",
"'callback'",
"=>",
"$",
"callback",
",",
"'class'",
"=>",
"$",
"callback",
",",
"'function'",
"=>",
"'process'",
")",
";",
"}",
"}",
"elseif",
"(",
"function_exists",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"this",
"->",
"plugins",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'type'",
"=>",
"self",
"::",
"FUNC_PLUGIN",
"|",
"$",
"compilable",
",",
"'callback'",
"=>",
"$",
"callback",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"'Callback could not be processed correctly, please check that the function/class you used exists'",
")",
";",
"}",
"}"
] |
adds a custom plugin that is not in one of the plugin directories
@param string $name the plugin name to be used in the templates
@param callback $callback the plugin callback, either a function name,
a class name or an array containing an object
or class name and a method name
@param bool $compilable if set to true, the plugin is assumed to be compilable
|
[
"adds",
"a",
"custom",
"plugin",
"that",
"is",
"not",
"in",
"one",
"of",
"the",
"plugin",
"directories"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo.php#L466-L486
|
22,374
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo.php
|
Dwoo.addFilter
|
public function addFilter($callback, $autoload = false)
{
if ($autoload) {
$class = 'Dwoo_Filter_'.$callback;
if (!class_exists($class, false) && !function_exists($class)) {
try {
$this->getLoader()->loadPlugin($callback);
} catch (Dwoo_Exception $e) {
if (strstr($callback, 'Dwoo_Filter_')) {
throw new Dwoo_Exception('Wrong filter name : '.$callback.', the "Dwoo_Filter_" prefix should not be used, please only use "'.str_replace('Dwoo_Filter_', '', $callback).'"');
} else {
throw new Dwoo_Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"');
}
}
}
if (class_exists($class, false)) {
$callback = array(new $class($this), 'process');
} elseif (function_exists($class)) {
$callback = $class;
} else {
throw new Dwoo_Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"');
}
$this->filters[] = $callback;
} else {
$this->filters[] = $callback;
}
}
|
php
|
public function addFilter($callback, $autoload = false)
{
if ($autoload) {
$class = 'Dwoo_Filter_'.$callback;
if (!class_exists($class, false) && !function_exists($class)) {
try {
$this->getLoader()->loadPlugin($callback);
} catch (Dwoo_Exception $e) {
if (strstr($callback, 'Dwoo_Filter_')) {
throw new Dwoo_Exception('Wrong filter name : '.$callback.', the "Dwoo_Filter_" prefix should not be used, please only use "'.str_replace('Dwoo_Filter_', '', $callback).'"');
} else {
throw new Dwoo_Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"');
}
}
}
if (class_exists($class, false)) {
$callback = array(new $class($this), 'process');
} elseif (function_exists($class)) {
$callback = $class;
} else {
throw new Dwoo_Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"');
}
$this->filters[] = $callback;
} else {
$this->filters[] = $callback;
}
}
|
[
"public",
"function",
"addFilter",
"(",
"$",
"callback",
",",
"$",
"autoload",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"autoload",
")",
"{",
"$",
"class",
"=",
"'Dwoo_Filter_'",
".",
"$",
"callback",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
",",
"false",
")",
"&&",
"!",
"function_exists",
"(",
"$",
"class",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getLoader",
"(",
")",
"->",
"loadPlugin",
"(",
"$",
"callback",
")",
";",
"}",
"catch",
"(",
"Dwoo_Exception",
"$",
"e",
")",
"{",
"if",
"(",
"strstr",
"(",
"$",
"callback",
",",
"'Dwoo_Filter_'",
")",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"'Wrong filter name : '",
".",
"$",
"callback",
".",
"', the \"Dwoo_Filter_\" prefix should not be used, please only use \"'",
".",
"str_replace",
"(",
"'Dwoo_Filter_'",
",",
"''",
",",
"$",
"callback",
")",
".",
"'\"'",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"'Wrong filter name : '",
".",
"$",
"callback",
".",
"', when using autoload the filter must be in one of your plugin dir as \"name.php\" containg a class or function named \"Dwoo_Filter_name\"'",
")",
";",
"}",
"}",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"class",
",",
"false",
")",
")",
"{",
"$",
"callback",
"=",
"array",
"(",
"new",
"$",
"class",
"(",
"$",
"this",
")",
",",
"'process'",
")",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"class",
";",
"}",
"else",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"'Wrong filter name : '",
".",
"$",
"callback",
".",
"', when using autoload the filter must be in one of your plugin dir as \"name.php\" containg a class or function named \"Dwoo_Filter_name\"'",
")",
";",
"}",
"$",
"this",
"->",
"filters",
"[",
"]",
"=",
"$",
"callback",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"filters",
"[",
"]",
"=",
"$",
"callback",
";",
"}",
"}"
] |
adds a filter to this Dwoo instance, it will be used to filter the output of all the templates rendered by this instance
@param mixed $callback a callback or a filter name if it is autoloaded from a plugin directory
@param bool $autoload if true, the first parameter must be a filter name from one of the plugin directories
|
[
"adds",
"a",
"filter",
"to",
"this",
"Dwoo",
"instance",
"it",
"will",
"be",
"used",
"to",
"filter",
"the",
"output",
"of",
"all",
"the",
"templates",
"rendered",
"by",
"this",
"instance"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo.php#L506-L535
|
22,375
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo.php
|
Dwoo.removeFilter
|
public function removeFilter($callback)
{
if (($index = array_search('Dwoo_Filter_'.$callback, $this->filters, true)) !== false) {
unset($this->filters[$index]);
} elseif (($index = array_search($callback, $this->filters, true)) !== false) {
unset($this->filters[$index]);
} else {
$class = 'Dwoo_Filter_' . $callback;
foreach ($this->filters as $index=>$filter) {
if (is_array($filter) && $filter[0] instanceof $class) {
unset($this->filters[$index]);
break;
}
}
}
}
|
php
|
public function removeFilter($callback)
{
if (($index = array_search('Dwoo_Filter_'.$callback, $this->filters, true)) !== false) {
unset($this->filters[$index]);
} elseif (($index = array_search($callback, $this->filters, true)) !== false) {
unset($this->filters[$index]);
} else {
$class = 'Dwoo_Filter_' . $callback;
foreach ($this->filters as $index=>$filter) {
if (is_array($filter) && $filter[0] instanceof $class) {
unset($this->filters[$index]);
break;
}
}
}
}
|
[
"public",
"function",
"removeFilter",
"(",
"$",
"callback",
")",
"{",
"if",
"(",
"(",
"$",
"index",
"=",
"array_search",
"(",
"'Dwoo_Filter_'",
".",
"$",
"callback",
",",
"$",
"this",
"->",
"filters",
",",
"true",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"index",
"]",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"index",
"=",
"array_search",
"(",
"$",
"callback",
",",
"$",
"this",
"->",
"filters",
",",
"true",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"index",
"]",
")",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"'Dwoo_Filter_'",
".",
"$",
"callback",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"index",
"=>",
"$",
"filter",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"filter",
")",
"&&",
"$",
"filter",
"[",
"0",
"]",
"instanceof",
"$",
"class",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"index",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
removes a filter
@param mixed $callback callback or filter name if it was autoloaded
|
[
"removes",
"a",
"filter"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo.php#L542-L557
|
22,376
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo.php
|
Dwoo.addResource
|
public function addResource($name, $class, $compilerFactory = null)
{
if (strlen($name) < 2) {
throw new Dwoo_Exception('Resource names must be at least two-character long to avoid conflicts with Windows paths');
}
if (!class_exists($class)) {
throw new Dwoo_Exception('Resource class does not exist');
}
$interfaces = class_implements($class);
if (in_array('Dwoo_ITemplate', $interfaces) === false) {
throw new Dwoo_Exception('Resource class must implement Dwoo_ITemplate');
}
$this->resources[$name] = array('class'=>$class, 'compiler'=>$compilerFactory);
}
|
php
|
public function addResource($name, $class, $compilerFactory = null)
{
if (strlen($name) < 2) {
throw new Dwoo_Exception('Resource names must be at least two-character long to avoid conflicts with Windows paths');
}
if (!class_exists($class)) {
throw new Dwoo_Exception('Resource class does not exist');
}
$interfaces = class_implements($class);
if (in_array('Dwoo_ITemplate', $interfaces) === false) {
throw new Dwoo_Exception('Resource class must implement Dwoo_ITemplate');
}
$this->resources[$name] = array('class'=>$class, 'compiler'=>$compilerFactory);
}
|
[
"public",
"function",
"addResource",
"(",
"$",
"name",
",",
"$",
"class",
",",
"$",
"compilerFactory",
"=",
"null",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"name",
")",
"<",
"2",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"'Resource names must be at least two-character long to avoid conflicts with Windows paths'",
")",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"'Resource class does not exist'",
")",
";",
"}",
"$",
"interfaces",
"=",
"class_implements",
"(",
"$",
"class",
")",
";",
"if",
"(",
"in_array",
"(",
"'Dwoo_ITemplate'",
",",
"$",
"interfaces",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"'Resource class must implement Dwoo_ITemplate'",
")",
";",
"}",
"$",
"this",
"->",
"resources",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"class",
",",
"'compiler'",
"=>",
"$",
"compilerFactory",
")",
";",
"}"
] |
adds a resource or overrides a default one
@param string $name the resource name
@param string $class the resource class (which must implement Dwoo_ITemplate)
@param callback $compilerFactory the compiler factory callback, a function that must return a compiler instance used to compile this resource, if none is provided. by default it will produce a Dwoo_Compiler object
|
[
"adds",
"a",
"resource",
"or",
"overrides",
"a",
"default",
"one"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo.php#L566-L582
|
22,377
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo.php
|
Dwoo.getLoader
|
public function getLoader()
{
if ($this->loader === null) {
$this->loader = new Dwoo_Loader($this->getCompileDir());
}
return $this->loader;
}
|
php
|
public function getLoader()
{
if ($this->loader === null) {
$this->loader = new Dwoo_Loader($this->getCompileDir());
}
return $this->loader;
}
|
[
"public",
"function",
"getLoader",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"loader",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"loader",
"=",
"new",
"Dwoo_Loader",
"(",
"$",
"this",
"->",
"getCompileDir",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"loader",
";",
"}"
] |
returns the current loader object or a default one if none is currently found
@param Dwoo_ILoader
|
[
"returns",
"the",
"current",
"loader",
"object",
"or",
"a",
"default",
"one",
"if",
"none",
"is",
"currently",
"found"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo.php#L616-L623
|
22,378
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo.php
|
Dwoo.getCacheDir
|
public function getCacheDir()
{
if ($this->cacheDir === null) {
$this->setCacheDir(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR);
}
return $this->cacheDir;
}
|
php
|
public function getCacheDir()
{
if ($this->cacheDir === null) {
$this->setCacheDir(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR);
}
return $this->cacheDir;
}
|
[
"public",
"function",
"getCacheDir",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheDir",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setCacheDir",
"(",
"dirname",
"(",
"__FILE__",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'cache'",
".",
"DIRECTORY_SEPARATOR",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cacheDir",
";",
"}"
] |
returns the cache directory with a trailing DIRECTORY_SEPARATOR
@return string
|
[
"returns",
"the",
"cache",
"directory",
"with",
"a",
"trailing",
"DIRECTORY_SEPARATOR"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo.php#L642-L649
|
22,379
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo.php
|
Dwoo.setCacheDir
|
public function setCacheDir($dir)
{
$this->cacheDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
if (is_writable($this->cacheDir) === false) {
throw new Dwoo_Exception('The cache directory must be writable, chmod "'.$this->cacheDir.'" to make it writable');
}
}
|
php
|
public function setCacheDir($dir)
{
$this->cacheDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
if (is_writable($this->cacheDir) === false) {
throw new Dwoo_Exception('The cache directory must be writable, chmod "'.$this->cacheDir.'" to make it writable');
}
}
|
[
"public",
"function",
"setCacheDir",
"(",
"$",
"dir",
")",
"{",
"$",
"this",
"->",
"cacheDir",
"=",
"rtrim",
"(",
"$",
"dir",
",",
"'/\\\\'",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"if",
"(",
"is_writable",
"(",
"$",
"this",
"->",
"cacheDir",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"'The cache directory must be writable, chmod \"'",
".",
"$",
"this",
"->",
"cacheDir",
".",
"'\" to make it writable'",
")",
";",
"}",
"}"
] |
sets the cache directory and automatically appends a DIRECTORY_SEPARATOR
@param string $dir the cache directory
|
[
"sets",
"the",
"cache",
"directory",
"and",
"automatically",
"appends",
"a",
"DIRECTORY_SEPARATOR"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo.php#L656-L662
|
22,380
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo.php
|
Dwoo.getCompileDir
|
public function getCompileDir()
{
if ($this->compileDir === null) {
$this->setCompileDir(dirname(__FILE__).DIRECTORY_SEPARATOR.'compiled'.DIRECTORY_SEPARATOR);
}
return $this->compileDir;
}
|
php
|
public function getCompileDir()
{
if ($this->compileDir === null) {
$this->setCompileDir(dirname(__FILE__).DIRECTORY_SEPARATOR.'compiled'.DIRECTORY_SEPARATOR);
}
return $this->compileDir;
}
|
[
"public",
"function",
"getCompileDir",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"compileDir",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setCompileDir",
"(",
"dirname",
"(",
"__FILE__",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'compiled'",
".",
"DIRECTORY_SEPARATOR",
")",
";",
"}",
"return",
"$",
"this",
"->",
"compileDir",
";",
"}"
] |
returns the compile directory with a trailing DIRECTORY_SEPARATOR
@return string
|
[
"returns",
"the",
"compile",
"directory",
"with",
"a",
"trailing",
"DIRECTORY_SEPARATOR"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo.php#L669-L676
|
22,381
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo.php
|
Dwoo.setCompileDir
|
public function setCompileDir($dir)
{
$this->compileDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
if (is_writable($this->compileDir) === false) {
throw new Dwoo_Exception('The compile directory must be writable, chmod "'.$this->compileDir.'" to make it writable');
}
}
|
php
|
public function setCompileDir($dir)
{
$this->compileDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
if (is_writable($this->compileDir) === false) {
throw new Dwoo_Exception('The compile directory must be writable, chmod "'.$this->compileDir.'" to make it writable');
}
}
|
[
"public",
"function",
"setCompileDir",
"(",
"$",
"dir",
")",
"{",
"$",
"this",
"->",
"compileDir",
"=",
"rtrim",
"(",
"$",
"dir",
",",
"'/\\\\'",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"if",
"(",
"is_writable",
"(",
"$",
"this",
"->",
"compileDir",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"'The compile directory must be writable, chmod \"'",
".",
"$",
"this",
"->",
"compileDir",
".",
"'\" to make it writable'",
")",
";",
"}",
"}"
] |
sets the compile directory and automatically appends a DIRECTORY_SEPARATOR
@param string $dir the compile directory
|
[
"sets",
"the",
"compile",
"directory",
"and",
"automatically",
"appends",
"a",
"DIRECTORY_SEPARATOR"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo.php#L683-L689
|
22,382
|
ekuiter/feature-php
|
FeaturePhp/ProductLine/Product.php
|
Product.getAllGenerators
|
private function getAllGenerators() {
$allGenerators = array();
foreach (fphp\Generator\Generator::getGeneratorMap() as $key => $klass)
$allGenerators[$key] = new $klass($this->productLine->getGeneratorSettings($key));
return $allGenerators;
}
|
php
|
private function getAllGenerators() {
$allGenerators = array();
foreach (fphp\Generator\Generator::getGeneratorMap() as $key => $klass)
$allGenerators[$key] = new $klass($this->productLine->getGeneratorSettings($key));
return $allGenerators;
}
|
[
"private",
"function",
"getAllGenerators",
"(",
")",
"{",
"$",
"allGenerators",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"fphp",
"\\",
"Generator",
"\\",
"Generator",
"::",
"getGeneratorMap",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"klass",
")",
"$",
"allGenerators",
"[",
"$",
"key",
"]",
"=",
"new",
"$",
"klass",
"(",
"$",
"this",
"->",
"productLine",
"->",
"getGeneratorSettings",
"(",
"$",
"key",
")",
")",
";",
"return",
"$",
"allGenerators",
";",
"}"
] |
Returns all generators.
The generators are instantiated with their respective generator settings.
@return \FeaturePhp\Generator\Generator[]
|
[
"Returns",
"all",
"generators",
".",
"The",
"generators",
"are",
"instantiated",
"with",
"their",
"respective",
"generator",
"settings",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/Product.php#L69-L74
|
22,383
|
ekuiter/feature-php
|
FeaturePhp/ProductLine/Product.php
|
Product.addArtifactToUsedGenerators
|
private function addArtifactToUsedGenerators($allGenerators, $feature, $func) {
$artifact = $this->productLine->getArtifact($feature);
foreach ($artifact->getGenerators() as $key => $cfg) {
if (!array_key_exists($key, $allGenerators))
throw new ProductException("\"$key\" is not a valid generator");
call_user_func(array($allGenerators[$key], $func), $artifact);
}
}
|
php
|
private function addArtifactToUsedGenerators($allGenerators, $feature, $func) {
$artifact = $this->productLine->getArtifact($feature);
foreach ($artifact->getGenerators() as $key => $cfg) {
if (!array_key_exists($key, $allGenerators))
throw new ProductException("\"$key\" is not a valid generator");
call_user_func(array($allGenerators[$key], $func), $artifact);
}
}
|
[
"private",
"function",
"addArtifactToUsedGenerators",
"(",
"$",
"allGenerators",
",",
"$",
"feature",
",",
"$",
"func",
")",
"{",
"$",
"artifact",
"=",
"$",
"this",
"->",
"productLine",
"->",
"getArtifact",
"(",
"$",
"feature",
")",
";",
"foreach",
"(",
"$",
"artifact",
"->",
"getGenerators",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"cfg",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"allGenerators",
")",
")",
"throw",
"new",
"ProductException",
"(",
"\"\\\"$key\\\" is not a valid generator\"",
")",
";",
"call_user_func",
"(",
"array",
"(",
"$",
"allGenerators",
"[",
"$",
"key",
"]",
",",
"$",
"func",
")",
",",
"$",
"artifact",
")",
";",
"}",
"}"
] |
Adds a feature's artifact to all generators it specifies.
This is done independently from whether the corresponding feature is
selected or deselected to support generating code for both cases.
@param \FeaturePhp\Generator\Generator[] $allGenerators
@param \FeaturePhp\Model\Feature $feature
@param callable $func whether to add a selected or deselected artifact
|
[
"Adds",
"a",
"feature",
"s",
"artifact",
"to",
"all",
"generators",
"it",
"specifies",
".",
"This",
"is",
"done",
"independently",
"from",
"whether",
"the",
"corresponding",
"feature",
"is",
"selected",
"or",
"deselected",
"to",
"support",
"generating",
"code",
"for",
"both",
"cases",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/Product.php#L84-L91
|
22,384
|
ekuiter/feature-php
|
FeaturePhp/ProductLine/Product.php
|
Product.getGeneratorElements
|
private function getGeneratorElements($func) {
$allGenerators = $this->getAllGenerators();
foreach ($this->configuration->getSelectedFeatures() as $feature)
$this->addArtifactToUsedGenerators($allGenerators, $feature, "addSelectedArtifact");
foreach ($this->configuration->getDeselectedFeatures() as $feature)
$this->addArtifactToUsedGenerators($allGenerators, $feature, "addDeselectedArtifact");
$elements = array();
foreach ($allGenerators as $generator)
if ($generator->hasArtifacts())
$elements = array_merge($elements, call_user_func(array($generator, $func)));
return $elements;
}
|
php
|
private function getGeneratorElements($func) {
$allGenerators = $this->getAllGenerators();
foreach ($this->configuration->getSelectedFeatures() as $feature)
$this->addArtifactToUsedGenerators($allGenerators, $feature, "addSelectedArtifact");
foreach ($this->configuration->getDeselectedFeatures() as $feature)
$this->addArtifactToUsedGenerators($allGenerators, $feature, "addDeselectedArtifact");
$elements = array();
foreach ($allGenerators as $generator)
if ($generator->hasArtifacts())
$elements = array_merge($elements, call_user_func(array($generator, $func)));
return $elements;
}
|
[
"private",
"function",
"getGeneratorElements",
"(",
"$",
"func",
")",
"{",
"$",
"allGenerators",
"=",
"$",
"this",
"->",
"getAllGenerators",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"configuration",
"->",
"getSelectedFeatures",
"(",
")",
"as",
"$",
"feature",
")",
"$",
"this",
"->",
"addArtifactToUsedGenerators",
"(",
"$",
"allGenerators",
",",
"$",
"feature",
",",
"\"addSelectedArtifact\"",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"configuration",
"->",
"getDeselectedFeatures",
"(",
")",
"as",
"$",
"feature",
")",
"$",
"this",
"->",
"addArtifactToUsedGenerators",
"(",
"$",
"allGenerators",
",",
"$",
"feature",
",",
"\"addDeselectedArtifact\"",
")",
";",
"$",
"elements",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"allGenerators",
"as",
"$",
"generator",
")",
"if",
"(",
"$",
"generator",
"->",
"hasArtifacts",
"(",
")",
")",
"$",
"elements",
"=",
"array_merge",
"(",
"$",
"elements",
",",
"call_user_func",
"(",
"array",
"(",
"$",
"generator",
",",
"$",
"func",
")",
")",
")",
";",
"return",
"$",
"elements",
";",
"}"
] |
Returns elements generated for the product.
To do this, every artifact is registered with the generators it specifies.
Then every generator generates some elements. Finally all the elements are merged.
@param callable $func
@return mixed[]
|
[
"Returns",
"elements",
"generated",
"for",
"the",
"product",
".",
"To",
"do",
"this",
"every",
"artifact",
"is",
"registered",
"with",
"the",
"generators",
"it",
"specifies",
".",
"Then",
"every",
"generator",
"generates",
"some",
"elements",
".",
"Finally",
"all",
"the",
"elements",
"are",
"merged",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/Product.php#L100-L114
|
22,385
|
ekuiter/feature-php
|
FeaturePhp/ProductLine/Product.php
|
Product.generateFiles
|
public function generateFiles() {
$files = $this->getGeneratorElements("generateFiles");
$files = fphp\Helper\_Array::assertNoDuplicates($files, "getTarget");
$files = fphp\Helper\_Array::sortByKey($files, "getTarget");
return $files;
}
|
php
|
public function generateFiles() {
$files = $this->getGeneratorElements("generateFiles");
$files = fphp\Helper\_Array::assertNoDuplicates($files, "getTarget");
$files = fphp\Helper\_Array::sortByKey($files, "getTarget");
return $files;
}
|
[
"public",
"function",
"generateFiles",
"(",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"getGeneratorElements",
"(",
"\"generateFiles\"",
")",
";",
"$",
"files",
"=",
"fphp",
"\\",
"Helper",
"\\",
"_Array",
"::",
"assertNoDuplicates",
"(",
"$",
"files",
",",
"\"getTarget\"",
")",
";",
"$",
"files",
"=",
"fphp",
"\\",
"Helper",
"\\",
"_Array",
"::",
"sortByKey",
"(",
"$",
"files",
",",
"\"getTarget\"",
")",
";",
"return",
"$",
"files",
";",
"}"
] |
Generates the product's files.
@return \FeaturePhp\File\File[]
|
[
"Generates",
"the",
"product",
"s",
"files",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/Product.php#L120-L125
|
22,386
|
ekuiter/feature-php
|
FeaturePhp/ProductLine/Product.php
|
Product.trace
|
public function trace() {
$tracingLinks = array_merge(
$this->getGeneratorElements("trace"),
$this->getAllGenerators()["runtime"]->traceRuntimeCalls($this->generateFiles(), $this->productLine)
);
$tracingLinks = fphp\Helper\_Array::sortByKey($tracingLinks, "getFeatureName");
return $tracingLinks;
}
|
php
|
public function trace() {
$tracingLinks = array_merge(
$this->getGeneratorElements("trace"),
$this->getAllGenerators()["runtime"]->traceRuntimeCalls($this->generateFiles(), $this->productLine)
);
$tracingLinks = fphp\Helper\_Array::sortByKey($tracingLinks, "getFeatureName");
return $tracingLinks;
}
|
[
"public",
"function",
"trace",
"(",
")",
"{",
"$",
"tracingLinks",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getGeneratorElements",
"(",
"\"trace\"",
")",
",",
"$",
"this",
"->",
"getAllGenerators",
"(",
")",
"[",
"\"runtime\"",
"]",
"->",
"traceRuntimeCalls",
"(",
"$",
"this",
"->",
"generateFiles",
"(",
")",
",",
"$",
"this",
"->",
"productLine",
")",
")",
";",
"$",
"tracingLinks",
"=",
"fphp",
"\\",
"Helper",
"\\",
"_Array",
"::",
"sortByKey",
"(",
"$",
"tracingLinks",
",",
"\"getFeatureName\"",
")",
";",
"return",
"$",
"tracingLinks",
";",
"}"
] |
Returns tracing links for the product.
@return \FeaturePhp\Artifact\TracingLink[]
|
[
"Returns",
"tracing",
"links",
"for",
"the",
"product",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/Product.php#L131-L138
|
22,387
|
ouropencode/dachi
|
src/Session.php
|
Session.hasSessionMoved
|
public static function hasSessionMoved() {
if(!isset($_SESSION['dachi_agent']))
return true;
$agents = $_SESSION['dachi_agent'];
$agentc = $_SERVER['HTTP_USER_AGENT'];
if($agents != $agentc) {
if(strpos($agentc, "Trident") !== false && strpos($agents, "Trident") !== false)
return false;
return true;
}
return false;
}
|
php
|
public static function hasSessionMoved() {
if(!isset($_SESSION['dachi_agent']))
return true;
$agents = $_SESSION['dachi_agent'];
$agentc = $_SERVER['HTTP_USER_AGENT'];
if($agents != $agentc) {
if(strpos($agentc, "Trident") !== false && strpos($agents, "Trident") !== false)
return false;
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"hasSessionMoved",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"'dachi_agent'",
"]",
")",
")",
"return",
"true",
";",
"$",
"agents",
"=",
"$",
"_SESSION",
"[",
"'dachi_agent'",
"]",
";",
"$",
"agentc",
"=",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
";",
"if",
"(",
"$",
"agents",
"!=",
"$",
"agentc",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"agentc",
",",
"\"Trident\"",
")",
"!==",
"false",
"&&",
"strpos",
"(",
"$",
"agents",
",",
"\"Trident\"",
")",
"!==",
"false",
")",
"return",
"false",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Has this session moved
Moving is currently defined as "changing user agent".
@return boolean
|
[
"Has",
"this",
"session",
"moved"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Session.php#L63-L78
|
22,388
|
ouropencode/dachi
|
src/Session.php
|
Session.isValid
|
public static function isValid() {
if(isset($_SESSION['dachi_closed']) && !isset($_SESSION['dachi_expires']))
return false;
if(isset($_SESSION['dachi_expires']) && $_SESSION['dachi_expires'] < time())
return false;
return true;
}
|
php
|
public static function isValid() {
if(isset($_SESSION['dachi_closed']) && !isset($_SESSION['dachi_expires']))
return false;
if(isset($_SESSION['dachi_expires']) && $_SESSION['dachi_expires'] < time())
return false;
return true;
}
|
[
"public",
"static",
"function",
"isValid",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'dachi_closed'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"'dachi_expires'",
"]",
")",
")",
"return",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'dachi_expires'",
"]",
")",
"&&",
"$",
"_SESSION",
"[",
"'dachi_expires'",
"]",
"<",
"time",
"(",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] |
Is this session still valid?
Sessions are invalidated 10 seconds after regeneration, this is to allow AJAX
requests to complete execution before terminating the session. This method will
return false if the 10 second period has expired.
@return boolean
|
[
"Is",
"this",
"session",
"still",
"valid?"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Session.php#L89-L97
|
22,389
|
ouropencode/dachi
|
src/Session.php
|
Session.regenerate
|
public static function regenerate() {
if(isset($_SESSION['dachi_closed']) && $_SESSION['dachi_closed'] == true)
return false;
$_SESSION['dachi_closed'] = true;
$_SESSION['dachi_expires'] = time() + 10;
session_regenerate_id(false);
$new_session = session_id();
session_write_close();
session_id($new_session);
session_start();
unset($_SESSION['dachi_closed']);
unset($_SESSION['dachi_expires']);
}
|
php
|
public static function regenerate() {
if(isset($_SESSION['dachi_closed']) && $_SESSION['dachi_closed'] == true)
return false;
$_SESSION['dachi_closed'] = true;
$_SESSION['dachi_expires'] = time() + 10;
session_regenerate_id(false);
$new_session = session_id();
session_write_close();
session_id($new_session);
session_start();
unset($_SESSION['dachi_closed']);
unset($_SESSION['dachi_expires']);
}
|
[
"public",
"static",
"function",
"regenerate",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'dachi_closed'",
"]",
")",
"&&",
"$",
"_SESSION",
"[",
"'dachi_closed'",
"]",
"==",
"true",
")",
"return",
"false",
";",
"$",
"_SESSION",
"[",
"'dachi_closed'",
"]",
"=",
"true",
";",
"$",
"_SESSION",
"[",
"'dachi_expires'",
"]",
"=",
"time",
"(",
")",
"+",
"10",
";",
"session_regenerate_id",
"(",
"false",
")",
";",
"$",
"new_session",
"=",
"session_id",
"(",
")",
";",
"session_write_close",
"(",
")",
";",
"session_id",
"(",
"$",
"new_session",
")",
";",
"session_start",
"(",
")",
";",
"unset",
"(",
"$",
"_SESSION",
"[",
"'dachi_closed'",
"]",
")",
";",
"unset",
"(",
"$",
"_SESSION",
"[",
"'dachi_expires'",
"]",
")",
";",
"}"
] |
Regenerate the session for security
There is a 5% random chance on any page request that the session ID will be regenerated
and a new session identity served to the user. This prevents static session IDs that
can be stolen and reused.
This method sets the old session to expire in 10 seconds. This allows for any pending
requests to be served before the session ID changes.
@return null
|
[
"Regenerate",
"the",
"session",
"for",
"security"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Session.php#L111-L128
|
22,390
|
netzmacht/contao-leaflet-geocode-widget
|
src/Widget/GeocodeWidget.php
|
GeocodeWidget.buildRadiusOptions
|
private function buildRadiusOptions()
{
if (!$this->radius || !isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->radius])) {
return null;
}
$options = [
'element' => 'ctrl_' . $this->radius,
'min' => 0,
'max' => 0,
'defaultValue' => 0
];
if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->radius]['eval'])) {
$config = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->radius]['eval'];
$options['min'] = isset($config['minval']) ? (int) $config['minval'] : 0;
$options['max'] = isset($config['maxval']) ? (int) $config['maxval'] : 0;
$options['defaultValue'] = isset($config['default']) ? (int) $config['default'] : 0;
$options['steps'] = isset($config['steps']) ? (int) $config['steps'] : 0;
}
return $options;
}
|
php
|
private function buildRadiusOptions()
{
if (!$this->radius || !isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->radius])) {
return null;
}
$options = [
'element' => 'ctrl_' . $this->radius,
'min' => 0,
'max' => 0,
'defaultValue' => 0
];
if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->radius]['eval'])) {
$config = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->radius]['eval'];
$options['min'] = isset($config['minval']) ? (int) $config['minval'] : 0;
$options['max'] = isset($config['maxval']) ? (int) $config['maxval'] : 0;
$options['defaultValue'] = isset($config['default']) ? (int) $config['default'] : 0;
$options['steps'] = isset($config['steps']) ? (int) $config['steps'] : 0;
}
return $options;
}
|
[
"private",
"function",
"buildRadiusOptions",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"radius",
"||",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"$",
"this",
"->",
"strTable",
"]",
"[",
"'fields'",
"]",
"[",
"$",
"this",
"->",
"radius",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"options",
"=",
"[",
"'element'",
"=>",
"'ctrl_'",
".",
"$",
"this",
"->",
"radius",
",",
"'min'",
"=>",
"0",
",",
"'max'",
"=>",
"0",
",",
"'defaultValue'",
"=>",
"0",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"$",
"this",
"->",
"strTable",
"]",
"[",
"'fields'",
"]",
"[",
"$",
"this",
"->",
"radius",
"]",
"[",
"'eval'",
"]",
")",
")",
"{",
"$",
"config",
"=",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"$",
"this",
"->",
"strTable",
"]",
"[",
"'fields'",
"]",
"[",
"$",
"this",
"->",
"radius",
"]",
"[",
"'eval'",
"]",
";",
"$",
"options",
"[",
"'min'",
"]",
"=",
"isset",
"(",
"$",
"config",
"[",
"'minval'",
"]",
")",
"?",
"(",
"int",
")",
"$",
"config",
"[",
"'minval'",
"]",
":",
"0",
";",
"$",
"options",
"[",
"'max'",
"]",
"=",
"isset",
"(",
"$",
"config",
"[",
"'maxval'",
"]",
")",
"?",
"(",
"int",
")",
"$",
"config",
"[",
"'maxval'",
"]",
":",
"0",
";",
"$",
"options",
"[",
"'defaultValue'",
"]",
"=",
"isset",
"(",
"$",
"config",
"[",
"'default'",
"]",
")",
"?",
"(",
"int",
")",
"$",
"config",
"[",
"'default'",
"]",
":",
"0",
";",
"$",
"options",
"[",
"'steps'",
"]",
"=",
"isset",
"(",
"$",
"config",
"[",
"'steps'",
"]",
")",
"?",
"(",
"int",
")",
"$",
"config",
"[",
"'steps'",
"]",
":",
"0",
";",
"}",
"return",
"$",
"options",
";",
"}"
] |
Build the radius options.
@return array|null
@SuppressWarnings(PHPMD.Superglobals)
|
[
"Build",
"the",
"radius",
"options",
"."
] |
08acfbc473696f385d7c6aed6148e51c91443e12
|
https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/08acfbc473696f385d7c6aed6148e51c91443e12/src/Widget/GeocodeWidget.php#L143-L166
|
22,391
|
laraning/boost
|
src/Traits/CanCreateMany.php
|
CanCreateMany.createMany
|
public static function createMany(array $datasets) : array
{
$models = [];
foreach ($datasets as $dataset) {
$models[] = static::create($dataset);
}
return $models;
}
|
php
|
public static function createMany(array $datasets) : array
{
$models = [];
foreach ($datasets as $dataset) {
$models[] = static::create($dataset);
}
return $models;
}
|
[
"public",
"static",
"function",
"createMany",
"(",
"array",
"$",
"datasets",
")",
":",
"array",
"{",
"$",
"models",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"datasets",
"as",
"$",
"dataset",
")",
"{",
"$",
"models",
"[",
"]",
"=",
"static",
"::",
"create",
"(",
"$",
"dataset",
")",
";",
"}",
"return",
"$",
"models",
";",
"}"
] |
Creates many Models.
@param array $datasets The data array of arrays.
@return array The created models array.
|
[
"Creates",
"many",
"Models",
"."
] |
a57ac46f93eead7959c6743f5e709b1fb1429053
|
https://github.com/laraning/boost/blob/a57ac46f93eead7959c6743f5e709b1fb1429053/src/Traits/CanCreateMany.php#L17-L26
|
22,392
|
99designs/ergo-http
|
src/ResponseBuilder.php
|
ResponseBuilder.expires
|
public function expires($time)
{
if (!empty($time) && is_string($time) && !$timestamp = strtotime($time)) {
throw new \Ergo\Routing\Exception("Invalid expiry time: $timestamp");
} else if (is_numeric($time)) {
$timestamp = $time;
} else if ($time == false) {
return $this;
}
$this->addHeader('Expires', date('r', $timestamp));
return $this;
}
|
php
|
public function expires($time)
{
if (!empty($time) && is_string($time) && !$timestamp = strtotime($time)) {
throw new \Ergo\Routing\Exception("Invalid expiry time: $timestamp");
} else if (is_numeric($time)) {
$timestamp = $time;
} else if ($time == false) {
return $this;
}
$this->addHeader('Expires', date('r', $timestamp));
return $this;
}
|
[
"public",
"function",
"expires",
"(",
"$",
"time",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"time",
")",
"&&",
"is_string",
"(",
"$",
"time",
")",
"&&",
"!",
"$",
"timestamp",
"=",
"strtotime",
"(",
"$",
"time",
")",
")",
"{",
"throw",
"new",
"\\",
"Ergo",
"\\",
"Routing",
"\\",
"Exception",
"(",
"\"Invalid expiry time: $timestamp\"",
")",
";",
"}",
"else",
"if",
"(",
"is_numeric",
"(",
"$",
"time",
")",
")",
"{",
"$",
"timestamp",
"=",
"$",
"time",
";",
"}",
"else",
"if",
"(",
"$",
"time",
"==",
"false",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"addHeader",
"(",
"'Expires'",
",",
"date",
"(",
"'r'",
",",
"$",
"timestamp",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the Expires header based on a Unix timestamp.
@param int Unix timestamp
@chainable
|
[
"Sets",
"the",
"Expires",
"header",
"based",
"on",
"a",
"Unix",
"timestamp",
"."
] |
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
|
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/ResponseBuilder.php#L171-L184
|
22,393
|
jasny/controller
|
src/Controller/Output.php
|
Output.created
|
public function created($location = null)
{
$this->respondWith(201);
if (!empty($location)) {
$this->setResponseHeader('Location', $location);
}
}
|
php
|
public function created($location = null)
{
$this->respondWith(201);
if (!empty($location)) {
$this->setResponseHeader('Location', $location);
}
}
|
[
"public",
"function",
"created",
"(",
"$",
"location",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"respondWith",
"(",
"201",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"location",
")",
")",
"{",
"$",
"this",
"->",
"setResponseHeader",
"(",
"'Location'",
",",
"$",
"location",
")",
";",
"}",
"}"
] |
Response with created 201 code, and optionally the created location
@param string $location Url of created resource
|
[
"Response",
"with",
"created",
"201",
"code",
"and",
"optionally",
"the",
"created",
"location"
] |
28edf64343f1d8218c166c0c570128e1ee6153d8
|
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Output.php#L109-L116
|
22,394
|
jasny/controller
|
src/Controller/Output.php
|
Output.partialContent
|
public function partialContent($rangeFrom, $rangeTo, $totalSize)
{
$this->respondWith(206);
$this->setResponseHeader('Content-Range', "bytes {$rangeFrom}-{$rangeTo}/{$totalSize}");
$this->setResponseHeader('Content-Length', $rangeTo - $rangeFrom);
}
|
php
|
public function partialContent($rangeFrom, $rangeTo, $totalSize)
{
$this->respondWith(206);
$this->setResponseHeader('Content-Range', "bytes {$rangeFrom}-{$rangeTo}/{$totalSize}");
$this->setResponseHeader('Content-Length', $rangeTo - $rangeFrom);
}
|
[
"public",
"function",
"partialContent",
"(",
"$",
"rangeFrom",
",",
"$",
"rangeTo",
",",
"$",
"totalSize",
")",
"{",
"$",
"this",
"->",
"respondWith",
"(",
"206",
")",
";",
"$",
"this",
"->",
"setResponseHeader",
"(",
"'Content-Range'",
",",
"\"bytes {$rangeFrom}-{$rangeTo}/{$totalSize}\"",
")",
";",
"$",
"this",
"->",
"setResponseHeader",
"(",
"'Content-Length'",
",",
"$",
"rangeTo",
"-",
"$",
"rangeFrom",
")",
";",
"}"
] |
Respond with a 206 Partial content with `Content-Range` header
@param int $rangeFrom Beginning of the range in bytes
@param int $rangeTo End of the range in bytes
@param int $totalSize Total size in bytes
|
[
"Respond",
"with",
"a",
"206",
"Partial",
"content",
"with",
"Content",
"-",
"Range",
"header"
] |
28edf64343f1d8218c166c0c570128e1ee6153d8
|
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Output.php#L143-L149
|
22,395
|
jasny/controller
|
src/Controller/Output.php
|
Output.redirect
|
public function redirect($url, $code = 303)
{
$this->respondWith($code);
$this->setResponseHeader('Location', $url);
$urlHtml = htmlentities($url);
$this->output('You are being redirected to <a href="' . $urlHtml . '">' . $urlHtml . '</a>', 'text/html');
}
|
php
|
public function redirect($url, $code = 303)
{
$this->respondWith($code);
$this->setResponseHeader('Location', $url);
$urlHtml = htmlentities($url);
$this->output('You are being redirected to <a href="' . $urlHtml . '">' . $urlHtml . '</a>', 'text/html');
}
|
[
"public",
"function",
"redirect",
"(",
"$",
"url",
",",
"$",
"code",
"=",
"303",
")",
"{",
"$",
"this",
"->",
"respondWith",
"(",
"$",
"code",
")",
";",
"$",
"this",
"->",
"setResponseHeader",
"(",
"'Location'",
",",
"$",
"url",
")",
";",
"$",
"urlHtml",
"=",
"htmlentities",
"(",
"$",
"url",
")",
";",
"$",
"this",
"->",
"output",
"(",
"'You are being redirected to <a href=\"'",
".",
"$",
"urlHtml",
".",
"'\">'",
".",
"$",
"urlHtml",
".",
"'</a>'",
",",
"'text/html'",
")",
";",
"}"
] |
Redirect to url and output a short message with the link
@param string $url
@param int $code 301 (Moved Permanently), 302 (Found), 303 (See Other) or 307 (Temporary Redirect)
|
[
"Redirect",
"to",
"url",
"and",
"output",
"a",
"short",
"message",
"with",
"the",
"link"
] |
28edf64343f1d8218c166c0c570128e1ee6153d8
|
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Output.php#L158-L165
|
22,396
|
jasny/controller
|
src/Controller/Output.php
|
Output.getContentType
|
protected function getContentType($format)
{
// Check if it's already MIME
if (\Jasny\str_contains($format, '/')) {
return $format;
}
$repository = new ApacheMimeTypes();
$mime = $repository->findType($format);
if (!isset($mime)) {
throw new \UnexpectedValueException("Format '$format' doesn't correspond with a MIME type");
}
return $mime;
}
|
php
|
protected function getContentType($format)
{
// Check if it's already MIME
if (\Jasny\str_contains($format, '/')) {
return $format;
}
$repository = new ApacheMimeTypes();
$mime = $repository->findType($format);
if (!isset($mime)) {
throw new \UnexpectedValueException("Format '$format' doesn't correspond with a MIME type");
}
return $mime;
}
|
[
"protected",
"function",
"getContentType",
"(",
"$",
"format",
")",
"{",
"// Check if it's already MIME",
"if",
"(",
"\\",
"Jasny",
"\\",
"str_contains",
"(",
"$",
"format",
",",
"'/'",
")",
")",
"{",
"return",
"$",
"format",
";",
"}",
"$",
"repository",
"=",
"new",
"ApacheMimeTypes",
"(",
")",
";",
"$",
"mime",
"=",
"$",
"repository",
"->",
"findType",
"(",
"$",
"format",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"mime",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Format '$format' doesn't correspond with a MIME type\"",
")",
";",
"}",
"return",
"$",
"mime",
";",
"}"
] |
Get MIME type for extension
@param string $format
@return string
|
[
"Get",
"MIME",
"type",
"for",
"extension"
] |
28edf64343f1d8218c166c0c570128e1ee6153d8
|
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Output.php#L291-L306
|
22,397
|
jasny/controller
|
src/Controller/Output.php
|
Output.outputContentType
|
protected function outputContentType($format)
{
if (!isset($format)) {
$contentType = $this->getResponse()->getHeaderLine('Content-Type');
if (empty($contentType)) {
$format = $this->defaultFormat ?: 'text/html';
}
}
if (empty($contentType)) {
$contentType = $this->getContentType($format);
$this->setResponseHeader('Content-Type', $contentType);
}
return $contentType;
}
|
php
|
protected function outputContentType($format)
{
if (!isset($format)) {
$contentType = $this->getResponse()->getHeaderLine('Content-Type');
if (empty($contentType)) {
$format = $this->defaultFormat ?: 'text/html';
}
}
if (empty($contentType)) {
$contentType = $this->getContentType($format);
$this->setResponseHeader('Content-Type', $contentType);
}
return $contentType;
}
|
[
"protected",
"function",
"outputContentType",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"format",
")",
")",
"{",
"$",
"contentType",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getHeaderLine",
"(",
"'Content-Type'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"contentType",
")",
")",
"{",
"$",
"format",
"=",
"$",
"this",
"->",
"defaultFormat",
"?",
":",
"'text/html'",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"contentType",
")",
")",
"{",
"$",
"contentType",
"=",
"$",
"this",
"->",
"getContentType",
"(",
"$",
"format",
")",
";",
"$",
"this",
"->",
"setResponseHeader",
"(",
"'Content-Type'",
",",
"$",
"contentType",
")",
";",
"}",
"return",
"$",
"contentType",
";",
"}"
] |
Set the content type for the output
@param string $format
@return string
|
[
"Set",
"the",
"content",
"type",
"for",
"the",
"output"
] |
28edf64343f1d8218c166c0c570128e1ee6153d8
|
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Output.php#L385-L401
|
22,398
|
delaneymethod/sharepoint-api
|
src/Client.php
|
Client.listFolder
|
public function listFolder(string $path, bool $recursive = false) : array
{
$path = $this->normalizePath($path);
$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFolderByServerRelativeUrl(\''.$this->folderPath.$path.'\')/Folders';
$options = [
'headers' => $this->requestHeaders,
];
$response = $this->send('GET', $requestUrl, $options);
$folders = json_decode($response->getBody())->d ?? ['results' => []];
// Making sure we convert the object to an array
if (!is_array($folders)) {
$folders = json_decode(json_encode($folders), true);
}
return $folders['results'];
}
|
php
|
public function listFolder(string $path, bool $recursive = false) : array
{
$path = $this->normalizePath($path);
$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFolderByServerRelativeUrl(\''.$this->folderPath.$path.'\')/Folders';
$options = [
'headers' => $this->requestHeaders,
];
$response = $this->send('GET', $requestUrl, $options);
$folders = json_decode($response->getBody())->d ?? ['results' => []];
// Making sure we convert the object to an array
if (!is_array($folders)) {
$folders = json_decode(json_encode($folders), true);
}
return $folders['results'];
}
|
[
"public",
"function",
"listFolder",
"(",
"string",
"$",
"path",
",",
"bool",
"$",
"recursive",
"=",
"false",
")",
":",
"array",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
";",
"$",
"requestUrl",
"=",
"$",
"this",
"->",
"siteUrl",
".",
"'/sites/'",
".",
"$",
"this",
"->",
"siteName",
".",
"'/_api/Web/GetFolderByServerRelativeUrl(\\''",
".",
"$",
"this",
"->",
"folderPath",
".",
"$",
"path",
".",
"'\\')/Folders'",
";",
"$",
"options",
"=",
"[",
"'headers'",
"=>",
"$",
"this",
"->",
"requestHeaders",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"send",
"(",
"'GET'",
",",
"$",
"requestUrl",
",",
"$",
"options",
")",
";",
"$",
"folders",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
"->",
"d",
"??",
"[",
"'results'",
"=>",
"[",
"]",
"]",
";",
"// Making sure we convert the object to an array",
"if",
"(",
"!",
"is_array",
"(",
"$",
"folders",
")",
")",
"{",
"$",
"folders",
"=",
"json_decode",
"(",
"json_encode",
"(",
"$",
"folders",
")",
",",
"true",
")",
";",
"}",
"return",
"$",
"folders",
"[",
"'results'",
"]",
";",
"}"
] |
Returns the contents of a folder.
|
[
"Returns",
"the",
"contents",
"of",
"a",
"folder",
"."
] |
1ede2742292a13896f071427da5995abf5e9a545
|
https://github.com/delaneymethod/sharepoint-api/blob/1ede2742292a13896f071427da5995abf5e9a545/src/Client.php#L168-L188
|
22,399
|
delaneymethod/sharepoint-api
|
src/Client.php
|
Client.copy
|
public function copy(string $fromPath, string $toPath, array $mimeType) : bool
{
$fromPath = $this->normalizePath($fromPath);
$toPath = $this->normalizePath($toPath);
// If plain/text, its a folder
if (substr($mimeType['mimetype'], 0, 4) === 'text') {
$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFolderByServerRelativeUrl(\''.$this->folderPath.$fromPath.'\')/copyTo(strNewUrl=\''.$this->folderPath.$toPath.'\', bOverWrite=true)';
} else {
$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFileByServerRelativeUrl(\''.$this->folderPath.$fromPath.'\')/copyTo(strNewUrl=\''.$this->folderPath.$toPath.'\', bOverWrite=true)';
}
$options = [
'headers' => $this->requestHeaders,
];
$response = $this->send('POST', $requestUrl, $options);
return $response->getStatusCode() === 200 ? true : false;
}
|
php
|
public function copy(string $fromPath, string $toPath, array $mimeType) : bool
{
$fromPath = $this->normalizePath($fromPath);
$toPath = $this->normalizePath($toPath);
// If plain/text, its a folder
if (substr($mimeType['mimetype'], 0, 4) === 'text') {
$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFolderByServerRelativeUrl(\''.$this->folderPath.$fromPath.'\')/copyTo(strNewUrl=\''.$this->folderPath.$toPath.'\', bOverWrite=true)';
} else {
$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFileByServerRelativeUrl(\''.$this->folderPath.$fromPath.'\')/copyTo(strNewUrl=\''.$this->folderPath.$toPath.'\', bOverWrite=true)';
}
$options = [
'headers' => $this->requestHeaders,
];
$response = $this->send('POST', $requestUrl, $options);
return $response->getStatusCode() === 200 ? true : false;
}
|
[
"public",
"function",
"copy",
"(",
"string",
"$",
"fromPath",
",",
"string",
"$",
"toPath",
",",
"array",
"$",
"mimeType",
")",
":",
"bool",
"{",
"$",
"fromPath",
"=",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"fromPath",
")",
";",
"$",
"toPath",
"=",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"toPath",
")",
";",
"// If plain/text, its a folder",
"if",
"(",
"substr",
"(",
"$",
"mimeType",
"[",
"'mimetype'",
"]",
",",
"0",
",",
"4",
")",
"===",
"'text'",
")",
"{",
"$",
"requestUrl",
"=",
"$",
"this",
"->",
"siteUrl",
".",
"'/sites/'",
".",
"$",
"this",
"->",
"siteName",
".",
"'/_api/Web/GetFolderByServerRelativeUrl(\\''",
".",
"$",
"this",
"->",
"folderPath",
".",
"$",
"fromPath",
".",
"'\\')/copyTo(strNewUrl=\\''",
".",
"$",
"this",
"->",
"folderPath",
".",
"$",
"toPath",
".",
"'\\', bOverWrite=true)'",
";",
"}",
"else",
"{",
"$",
"requestUrl",
"=",
"$",
"this",
"->",
"siteUrl",
".",
"'/sites/'",
".",
"$",
"this",
"->",
"siteName",
".",
"'/_api/Web/GetFileByServerRelativeUrl(\\''",
".",
"$",
"this",
"->",
"folderPath",
".",
"$",
"fromPath",
".",
"'\\')/copyTo(strNewUrl=\\''",
".",
"$",
"this",
"->",
"folderPath",
".",
"$",
"toPath",
".",
"'\\', bOverWrite=true)'",
";",
"}",
"$",
"options",
"=",
"[",
"'headers'",
"=>",
"$",
"this",
"->",
"requestHeaders",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"send",
"(",
"'POST'",
",",
"$",
"requestUrl",
",",
"$",
"options",
")",
";",
"return",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"===",
"200",
"?",
"true",
":",
"false",
";",
"}"
] |
Copy a file or folder to a different location.
https://msdn.microsoft.com/en-us/library/office/jj247198%28v=office.15%29.aspx
|
[
"Copy",
"a",
"file",
"or",
"folder",
"to",
"a",
"different",
"location",
"."
] |
1ede2742292a13896f071427da5995abf5e9a545
|
https://github.com/delaneymethod/sharepoint-api/blob/1ede2742292a13896f071427da5995abf5e9a545/src/Client.php#L195-L215
|
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.